Hello,
I am just delving into the world of MEL and am trying to digest the "Creating Clinical Content" pdf.
I am trying to put together an if-then statement that will compare: if the last OBSDATE for colonfit test is > 1 year ago, then order the FIT test. I can get the MEL statements for the orders and I think I have the basics down, but comparing the dates is a challenge for me.
Here is what I have so far:
if
DURATIONDAYS(LASTOBSDATE('FECIMMTEST'),._TODAYSDATE) > 365
then
MEL_ADD_ORDER('T','Labs','Fecal Immunochemical Test (FIT)','','ICD-Z12.11','Colorectal screening')''
else
"Patient is not due for colonoscopy until " + HEMOCULTDUE +"."
endif
The one problem I see is that you must convert your dates to a string before you can use the DURATIONDAYS() function. This is a common oversight when learning MEL.
The line:
DURATIONDAYS(LASTOBSDATE(‘FECIMMTEST’),._TODAYSDATE) > 365
should be:
DURATIONDAYS(LASTOBSDATE(‘FECIMMTEST’),str(._TODAYSDATE)) > 365
Hope that helps.
That works for the if/then logic and order, but I can't get it to display HEMOCULT due date. any ideas?
You have to use LASTOBSVALUE("HEMOCULTDUE")
If HEMOCULTDUE is an OBS term that contains the due date, try:
“Patient is not due for colonoscopy until ” + OBSANY("HEMOCULTDUE") +”.”
That should return the most recent value of your OBS term named HEMOCULTDUE. Be careful about copying and pasting from this forum; the double quotes characters do not always translate well. I would just type the above out manually in your code to be sure.
thank you again!
thank you all.
final code:
{if
DURATIONDAYS(LASTOBSDATE('FECIMMTEST'),str(._TODAYSDATE)) > 365
then
MEL_ADD_ORDER('T','Labs','Fecal Immunochemical Test (FIT)','','ICD-Z12.11','Colorectal screening')'' + "Colorectal FIT test ordered"
else
"Patient is not due for colon FIT test until " + OBSANY("HEMOCULTDUE") +"."
endif}
next steps: to add further if-then to identify if they've had a colonoscopy