So I'm stringing together some drop downs and I want the result to be whatever was selected last among the drop downs.
Here's a slimmed down version;
{ddlDiagnosis(DOCUMENT.DIAGNOSIS,DOCUMENT.DIAGNOSIS2,DOCUMENT.DIAGNOSIS3)}
{fn ddlDiagnosis(stra,strb,strc)
{
local strDX=""
if (size(stra) > 0) then
strDX = stra
endif
if (size(strb) > 0) then
strDX = strb
endif
if (size(strc) > 0) then
strDX = strc
endif
return strDX
}}
This is working fine if I'm selecting in order. ie. stra is drop down 1 i get that result strb is drop down 2 and I get that as a result.
The problem arises when I selected strb and then select stra. The {ddlDiagnosis(DOCUMENT.DIAGNOSIS,DOCUMENT.DIAGNOSIS2,DOCUMENT.DIAGNOSIS3)} reflects strb.
Thanks the help in advance!
EDIT: I hope I can explain this well enough to make sense. The reason i need to string together these drop downs are because they're 11 containing the same choices. I need to see if in any of those if a particular choice is selected add the diagnosis. So in my if then I can have the string instead of individual variables. For example:
if document.stopadd2 = "" and PullFirstSetPriorProbs() == "" and ddlDiagnosis(DOCUMENT.DIAGNOSIS,DOCUMENT.DIAGNOSIS2,DOCUMENT.DIAGNOSIS3,DOCUMENT.DIAGNOSIS4,DOCUMENT.DIAGNOSIS5,DOCUMENT.DIAGNOSIS6,DOCUMENT.DIAGNOSIS7,DOCUMENT.DIAGNOSIS8,DOCUMENT.DIAGNOSIS9,DOCUMENT.DIAGNOSIS10,DOCUMENT.DIAGNOSIS11) = "Abnormal Cervical Pap ICD10-R876.19" then
MEL_ADD_PROBLEM("", "ABNORMAL CERVICAL PAP", "ICD10-R87.619", str(._TODAYSDATE), "", "")
document.stopadd2 = "x"
The reason it only works in order is because the 3 if statements are executing in the order they are written. Since the code is simply checking that the drop-down is not null, it is doing the following:
1. if stra > 0, then strDX=stra
2.if strb > 0, then strDX=strb
3.if strc > 0, then strDX=strc
this means that stra will only be returned if strb and strc are blank. and if strc is picked, you will always get strc back regardless of the other 2 choices.
My inital thought is to add a hidden Document Variable in the form that will hold the data of the last function entered, and use watcher expressions to see when any of the 3 drop-downs are changed. it would probably look something like this:
{ddlDiagnosis(DOCUMENT.DIAGNOSIS)}
{ddlDiagnosis(DOCUMENT.DIAGNOSIS2)}
{ddlDiagnosis(DOCUMENT.DIAGNOSIS3)}
{fn ddlDiagnosis(strVar)
{
local strDX=””
if (size(stra) > 0) then
DOCUMENT.LAST_DX_PICKED = strVar
strDX = strVar
else
strDX = DOCUMENT.LST_DX_PICKED
endif
return strDX
}}
Depending on what you are trying to accomplish, you may need more error-checking to make sure that you always have some value. Let me know if I can be of any more assistance. I'm interested to know the end goal of this function in a form. 🙂
Simpler solution, have three watcher variables. The one that is called is the last one. Ocam's razor strikes again.
So my goal is to when a choice is selected from the drop down add it to the problem list is if doesn't already exist, so I have pieces in there to check for that, and works fine except for my issue above. I'll attach the form and a text document of the watcher expression.
Oh I see what it is you are working on. Very nice! so the function that checks the dropdown list is making sure that whatever is selected on the list has an problem added, but only if the problem has not already been added to the pt chart.
In this scenario, you could use the MATCH Mel code to check the patient's current problem list, and see if the problem was added (PROB_AFTER() should do nicely.) It would also cut down on your 17 extra document variables that are being set.
Does that make sense? I am going to lunch now, but I'll get back to you as soon as possible. The form looks really great though. Good job!