Hello,
I'm trying to set up a MEL_ADD_PROBLEM on a custom form, with IF conditions for a new OBS value from a dropdown within the form. We're creating a custom workflow for Chronic Pain narcotic use, and would like to push a Dx code to the problem list under any of these conditions.
Each of these are entered in separate Data Displays, using MEL Expression. The Dx codes are custom within a custom problem list.
What am I missing? Or does MEL_ADD_PROBLEM not work with custom Dx codes?
Thanks for any help on this.
{IF (OBSNOW("NARCRISKRATG") = "low risk") then
(MEL_ADD_PROBLEM("dx of", "Disuse Risk-Low", "DRL",str(._TODAYSDATE), "", ""))
else
endif}
{IF (OBSNOW("NARCRISKRATG") = "moderate risk") then
(MEL_ADD_PROBLEM("dx of", "Disuse Risk-Moderate", "DRM",str(._TODAYSDATE), "", ""))
else
endif}
{IF (OBSNOW("NARCRISKRATG") = "high risk") then
(MEL_ADD_PROBLEM("dx of", "Disuse Risk-High", "DRH",str(._TODAYSDATE), "", ""))
else
endif}
.
Looking at your code, there are 2 issues here.
1) the number of arguments. Even if you choose not to give an end date or other field, you still have to put in an empty string. It should look like this:
(MEL_ADD_PROBLEM("", "Disuse Risk-Low", "", str(._TODAYSDATE),"", ""))
2)the ICD code. you are right on the money that MEL_ADD_PROBLEM does not like custom codes. even if you put "ICD-RDL" into the code field, you will get an error of -3, which means the code does not exist in the database. if you omit the code, as in the example above, you will add this problem to the patient's problem list as an uncoded problem.
I'm not sure how important the actual code is to you, or if you can work with the problem list having the uncoded problem with the correct name. but this should get you started on the right track to using the MEL code. Please let me know if you have any questions.
Thank you,
Dan
Thanks Dan. Removing the custom Dx code and copying your string worked.
What I'm finding now is when a risk level is selected in the form and then changed to another risk level, both risk levels are being added to the problem list.
PROBLEMS:
Added new problem of Disuse Risk-Low
Added new problem of Disuse Risk-High
Is there a way to write these functions so that just one, the last one selected, gets added to the problem list? I tried separating them out with an OR, but it errored out. I think I need to include an IF for each and then three 'end if' statements but not sure how to write that to make it work.
{IF (OBSNOW("NARCRISKRATG") = "low risk") then
(MEL_ADD_PROBLEM("","Disuse Risk-Low","",str(._TODAYSDATE),"",""))
OR
(OBSNOW("NARCRISKRATG") = "moderate risk") then
(MEL_ADD_PROBLEM("","Disuse Risk-Moderate","",str(._TODAYSDATE),"",""))
or
(OBSNOW("NARCRISKRATG") = "high risk") then
(MEL_ADD_PROBLEM("","Disuse Risk-High","",str(._TODAYSDATE),"",""))
else
endif}
There are 2 solutions to this issue. and it really depends on your workflow, and how the staff like to work.
Solution 1. have a button to add the problem code that is manually clicked by a user after a final selection for the obs term is made. if they change their mind they will need to manually remove the problem they entered from the problem list.
Pros: less coding for you.
Cons: more work on the user, especially if they click the button and then change their mind.
Solution 2. Have the MEL code run a function that searches the problem list to remove anyproblem code that does not match the current obs term.
Pros: less work for provider
Cons: more coding for you, but not impossible.
I assume solution 2 will be the method most users would prefer. I actually have a BMI code that does this, where the old BMI problem code is removed, and a correct one is put in it's place. if the patient weight was entered wrong, it autocorrects the problem code in the background when the user enters the correct weight value.
I am not available for the rest of today. but I help you with getting the code to do this up and running tomorrow I think. let me know if this sounds good.
Thanks. I'm leaning towards Solution 2, especially considering that the Dx risk level may change as their treatment progresses. Sounds like Solution 1 would require the previous Dx to be manually removed if a different Dx risk level was added at a later date.
I certainly would appreciate your help with getting the code to work. I'm east coast and available almost anytime tomorrow between 8-11 and 1-4.
Thank you
Sorry to get back to you so late. I have had a very busy day, despite my calendar being open.
So I wrote and tested a function that takes the Obsterm you are setting, and clears the problem list while adding a new problem reflecting the current risk status. here is the function:
{fn problemListUpdate(newRiskName){
local pArray = getfield(PROB_AFTER("delim"),"|","")
//a for loop to go through the problem codes and remove the BMI code that is being replaced.
for c = 1, c <= size(pArray), c = c+1 do
if match(pArray[c],"Disuse Risk-Low") >0 OR match(pArray[c],"Disuse Risk-Moderate") >0 OR match(pArray[c],"Disuse Risk-High") >0then
pArray[c] = getfield(pArray[c],"^","")
MEL_REMOVE_PROBLEM(pArray[c][9],str(._TODAYSDATE),"FALSE","Resolved")
endif
endfor
//set the new risk level in the problem list. if blank, do nothing.
if (newRiskName <> "") then
cond
case newRiskName == "low risk"
MEL_ADD_PROBLEM("", "Disuse Risk-Low", "", str(._TODAYSDATE),"", "")
case newRiskName == "moderate risk"
MEL_ADD_PROBLEM("", "Disuse Risk-Moderate", "", str(._TODAYSDATE),"", "")
case newRiskName == "high risk"
MEL_ADD_PROBLEM("", "Disuse Risk-High", "", str(._TODAYSDATE),"", "")
else userok("risk level entered that the function does not recognize. please update function, or change the value that is being entered. Thank you.")
endcond
endif
}}//end of function
If you have a watcher expression, you can run the code above when the obsterm is changed in a visit. here is an example:
{! If OBSNOW("NARCRISKRATG") <> "" then
problemListUpdate(OBSNOW("problemListUpdate"))
endif
}
Please let me know if you have any problems setting this up in your form. it can sometimes be tricky to get automatic functions to work properly.
Thank you,
Dan
A word of caution regarding this solution: Some time back, I set up something similar to this that would autofire when a patient's BMI was changed. If the BMI was determined to be unhealthy, a different problem would be added depending on the number. Every time the BMI was recalculated, the old problem would be removed and the new problem would be added, even if it was the same problem. This would also happen whenever the form was held and reopened.
This all looked fine, but when we gave the form to our testers, they found that all of the additions and removals were still logged in the Problem List, they were just listed under All Items. This filled up the problem list really quickly and made a mess of things.
We ended up making the different values trigger a button to appear, prompting the user to decide when the BMI problem should be added or updated.
It might work for you, depending on how you're going to be using it, but I thought I'd speak up, as this discovery was a really rude, deflating surprise.
Hi Dan,
Apologies for the delay in replying. The last few months have been focused on our CPS12.2 upgrade and EPCS and we are finally at a point to pick up where we left off on our chronic pain intake form.
I'm not having success in getting the {fn problemListUpdate(newRiskName)... to push the problem to the problem list. Not sure if I'm adding it to the form wrong or if there is something in the code that's off.
I used the full function {fn problemListUpdate(newRiskName) ... in a MEL Expression Data Display, and placed the Watcher function in a second Data Display.
After saving the form changes, I'm getting WARNING: Observation term problemListUpdate not found in database.
The problems we're trying to add are custom problems in a custom problem list, so not actual ICD-10 codes. Maybe that's the problem?
Also, after importing the form, the data files for both the function and watcher data displays are displaying "COMPILER ERROR NEARBY: EXPECT RIGHT CURLY BRACKET instead had" and couldn't read the rest.
What do you think I am doing wrong? If it would help to take a look at the VFE source file, send me your email and I'll send that along to you.
If all else fails, I will resort to just using Solution 1, and adding an NEWPROBLEM button that points to our custom Problem List for these Dx codes.
Would like to try to automate it for them if possible. I've taken the BMI example in this thread into consideration and think that the Risk Level Dx code changes will be minimal and won't create over populating the problem list 'All." - Thanks for that piece of information.
Anna