Has anyone done this in the past. Take some prior obsterms that have been entered into the system, then based on the date, have it write to a new obsterm for the date of the original then have it make sure that it does not write again after the first time?
Trying to condense some information down into a more manageable level.
I think that this is what you're looking for:
fn dn_map_former_obsterms_to_new(){
local x, outdated_obs, current_obs, pair_array
local limit_values=""
for x=1, x<=getnargs(), x=x+1
do
pair_array=getfield(getarg(x),"^","")
current_obs=pair_array[1]
outdated_obs=pair_array[2]
if size(pair_array)=3 then limit_values=pair_array[3] else "" endif
local last_outdated_obs=last_signed_obs_value(outdated_obs)
local last_outdated_obs_date=last_signed_obs_date(outdated_obs)
local last_current_obs=last_signed_obs_value(current_obs)
local last_current_obs_date=last_signed_obs_date(current_obs)
if limit_values<>"" and match(limit_values,last_outdated_obs)==0 then continue else "" endif
if last_current_obs_date==last_outdated_obs_date then continue else "" endif
if durationdays(last_outdated_obs_date,last_current_obs_date)>0 then continue else "" endif
if last_outdated_obs_date=="" then continue else "" endif
if last_outdated_obs=="" then continue else "" endif
obsnow(current_obs,last_outdated_obs,last_outdated_obs_date)
endfor
return "done"
}
here's what "fires" it:
{if document.dn_map_unused_obsterms_to_new=="" then document.dn_map_unused_obsterms_to_new=dn_map_former_obsterms_to_new("ALBUMIN^ALBUMIN EOP","VIT-D 25-OH^vit D 25-OH","OPHTH EXAM^EYE EXAM^nl by patient reportabnormalblindrefused-counseled") "" else "" endif}
also be sure to "initialize" the tracking doctemp so it only fires once
{!document.dn_map_unused_obsterms_to_new}
also the 3rd element of the array that's created:
OPHTH EXAM^EYE EXAM^nl by patient reportabnormalblindrefused-counseled
let's you filter so that you only "map" structured entries and not garbage.
Thank you for this. I tried it out and it is not documenting anything. So when I do a mel trace, I am getting this error
01/24/2013 11:14:30.827-execute>call DN_MAP_FORMER_OBSTERMS_TO_NEW("VARICELLA^VARICELLA", "CVX21#2^CVX21#3", "CVX21#2^CVX21#3^GIVEN") ERROR: 32847 FUNCTION DEFINITION IS NOT EXECUTABLE
Not sure else to do about it. This is how I have my trigger setup:
{!if document.dn_map_unused_obsterms_to_new=="" then
document.dn_map_unused_obsterms_to_new=dn_map_former_obsterms_to_new("VARICELLA^VARICELLA","CVX21#2^CVX21#3","CVX21#2^CVX21#3^GIVEN") "" else "" endif}
this doesn't document anything it just "pushes" the obs in the background.
using the argument "VARICELLA^VARICELLA" wouldn't make sense and could cause your error. Both of these are the same obsterm. Unless I am missing something n the spelling.
This is used to "move" the last value of a legacy observation over to a new observation if and only if the legacy observation is more recent than the new one or the new one is absent. The first element is the name of the "new" obs, the second is the "legacy" obs.
FUNCTION DEFINITION IS NOT EXECUTABLE either means that the function is not loaded and not visible to MEL or that there's something deadly wrong with the function. My favorite is to forget the "fn" label.
try putting the function in usrlib or loading with a text component then just calling it with quicktext and work forward from there.
What if you do not have anything for the new obs on that date of the old obs and want to write the new obs to the same date as the old one?
Can this be modified to do that you think?