Someone was nice enough to help me with a script to update problems without an onset date in EMR that worked great. I am now looking to update our meds that were entered without a start date. Your assistance is greatly appreciated.
Virginia
What is the logic that it would use to set the date? Should it be based on the date it was entered?
This is how I would do it in oracle if I wanted to update the startdate to the date that the medication was added to the chart (the date the row in the DB was created):
update medicate set startdate = ml.convert_id_to_date(medicate.mid) where startdate is null;
commit;
It looks like you are on CPS according to your profile. I do not have a CPS database but my best guess would be a command like this (note, I am not sure if the convert_id_to_date function exists in cps but I will assume it does)
begin tran;
update medicate set startdate = convert_id_to_date(medicate.mid) where startdate is null;
commit;
These would update every start date that was null. I am not sure if you would want to do that to replaced medications. If you only wanted to do it for active rows you would and "and change = 2" to the end of the queries.
Just a word of caution, be very careful when you are updating tables directly from SQL queries. GE is not sympathetic when there is a problem.