Having trouble with a form function in VFE...
I have a form in VFE with a Data display set to run a MEL Expression: {displayWhenReviewed("Medications",DOCUMENT.REVIEWED_MEDS_TODAY)}
The above document variable DOCUMENT.REVIEWED_MEDS_TODAY is a checkbox that is set to "DONE" when checked.
Below is the function that is called for the data display
{!fn displayWhenReviewed(Type,checkbox){
local ObsToCheck
if Type == "Medications" then
ObsToCheck = "MEDS REVIEW"
else if Type == "Allergies" then
ObsToCheck = "ALLERGY REV"
else if Type == "Problems" then
ObsToCheck = "PROBLEMS REV"
if checkbox <> "" then
OBSNOW("ObsToCheck", checkbox)
return "The " + Type + " List was reviewed during this update: " + LASTOBSDATETIME("ObsToCheck")
else
OBSNOW("ObsToCheck", "")
endif
if checkbox == "" and OBSPREV("ObsToCheck") == "" then
return Type + " have not been reviewed."
else
return "The Patient's " + Type + " List was last reviewed on :" + LastObsValueByUser("ObsToCheck")
endif
}}
Here is the MEL vomit that spills out into the chart update when the checkbox is checked:
{"
" + FMT("Medications & Allergies Review ", "B,2") + "
" + "
" + FMT("Current Medications: ", "B,2") + "
" + CFMT(MEDS_AFTER("LIST"), "", "Current Medications:
", "B,2", "
") + if DOCUMENT.REVIEWED_MEDS_TODAY_4641_1340729963_912 <> "" then
displayWhenMedsReviewed( DOCUMENT.REVIEWED_MEDS_TODAY_4641_1340729963_912)
else "" endif <-FUNCTION DEFINITION IS NOT EXECUTABLE
Can anyone see what I am doing wrong, here? Thanks guys!
missing 3 endif's after:
if Type == "Medications" then
ObsToCheck = "MEDS REVIEW"
else if Type == "Allergies" then
ObsToCheck = "ALLERGY REV"
else if Type == "Problems" then
ObsToCheck = "PROBLEMS REV"
Geez, NOOB mistake! agghh. Well I input the 3 missing endif's, however I'm still getting MEL vomit.
The updated function is:
{!fn displayWhenReviewed(Type,checkbox){
local ObsToCheck
if Type == "Medications" then
ObsToCheck = "MEDS REVIEW"
else if Type == "Allergies" then
ObsToCheck = "ALLERGY REV"
else if Type == "Problems" then
ObsToCheck = "PROBLEMS REV"
endif
endif
endif
if checkbox <> "" then
OBSNOW("ObsToCheck", checkbox)
return "The " + Type + " List was reviewed during this update: " + LASTOBSDATETIME("ObsToCheck")
else
OBSNOW("ObsToCheck", "")
endif
if checkbox == "" and OBSPREV("ObsToCheck") == "" then
return Type + " have not been reviewed."
else
return "The Patient's " + Type + " List was last reviewed on :" + LastObsValueByUser("ObsToCheck")
endif
}}
...and the MEL that spills into the chart text is the same:
{"
" + FMT("Medications & Allergies Review ", "B,2") + "
" + "
" + FMT("Current Medications: ", "B,2") + "
" + CFMT(MEDS_AFTER("LIST"), "", "Current Medications:
", "B,2", "
") + if DOCUMENT.REVIEWED_MEDS_TODAY_4641_1340729963_912 <> "" then
displayWhenMedsReviewed( DOCUMENT.REVIEWED_MEDS_TODAY_4641_1340729963_912)
else "" endif <-FUNCTION DEFINITION IS NOT EXECUTABLE
Any ideas?
your call to the function has Meds in it.
Sorry, @jjordet, I don't follow. The checkbox that produces the above error has a document variable of DOCUMENT.REVIEWED_MEDS_TODAY, yes.
What I am aiming for is to pass this doc var to the function along with it's type so that the function can do the work and respond with the appropriate value (whether Medications, Allergies, or Problems were reviewed, if not when they last were).
So I'm lost, because I am intending to include Meds in the function call, right?
No...your function name doesn't have 'Meds' in it, but the call to the function does.
Ah, yes. You, my friend are a genius. Thank you so much.
For anyone who's following, my mistake was in the function call that was placed in the translation section/tab of the data display in VFE.
I had an earlier version of the function that I was using just for medications. Further down the road, I decided to recycle this function to make it work for allergies and problems, too. I took out Meds from the function name (was displayWhenMedsReviewed, changed it to displayWhenReviewed ) to make it more versatile. However I did not update the change in the text translation area, thus the MEL garbage in the chart note.
Thanks again to jjordet for the keen eyes and help!