I'm completely new to MEL and VFE, and while some of it has come quickly, certain aspects are just a huge struggle.
Here's what I'm trying to accomplish: I have a vital signs form that automatically calculates BMI based on height and weight. If the BMI is considered unhealthy, a problem is automatically posted to the Problem list. If the provider has to change the BMI during the appointment or the patient is still unhealthy on the next visit, a new BMI problem is posted to the list, rather than simply updating the old one.
I want the new BMI problem to essentially overwrite the old one. I've been struggling with this on and off for a week now, and I have it 90% working. I'm just having a hard time getting the PRID out, and documentation has been no help at all (aside: Why make the PRID so important to use, then not provide any indication of how to get it or even write a function to grab it for us?).
Here's my code (some of it might be familiar to readers of other MEL_REMOVE_PROBLEM or PRID threads... previously shared examples either don't work, don't make sense to me, or both):
fn changeOldProblem() {
local ProbArray = ""
local ProbSubArray = ""
ProbArray = getfield(PROB_AFTER("delimited"),"|","") /*
i=0
for i = 1, i <= size(ProbArray),i = i + 1
do
/*ProbSubArray[5] should access the ICD10*/
ProbSubArray = getfield(ProbArray[i],"^","")
if match(ProbSubArray[5], "ICD10-E66.3") == 0
/*I'm guessing that ProbSubArray[5] is the ICD10 number. I'm also guessing that I can do a match like this, rather than matching ProbSubArray to a document variable or something.*/
then
/* ProbSubArray[9] should access the PRID!*/
MEL_REMOVE_PROBLEM(ProbSubArray[9],"", "", "")
MEL_ADD_PROBLEM(ProbSubArray[1],ProbSubArray[2],ProbSubArray[3],"03/03/1990","",str(OBSNOW("BMI")),"","")
else
MEL_ADD_PROBLEM("","TEST","","04/04/2000","",str(OBSNOW("BMI")),"","")
endif
endfor
}
Can anyone give me some guidance?
Finally, does anyone know how to display variables in Data Fields? I've been using Data Fields to show information I'm trying to get, like the status of certain document variables. But, for example, if I want to display the PRID or ICD10 on the actual form, is there a way I can make a Data Field show that? Does that question make sense? For testing purposes, I want to be able to see that I'm even getting the number I think I'm getting.
Hi Ramon,
I went over your function, and made a few edits. I will explain them in the comments of the code.
fn changeOldProblem() {
//FlagVar checks if the loop was sucessful or not.
local FlagVar = FALSE
local ProbArray = ""
local ProbSubArray = ""
ProbArray = getfield(PROB_AFTER("delimited"),"|","")
i=0
for i = 1, i <= size(ProbArray),i = i + 1
do
/*ProbSubArray[8] should access the ICD10*/
ProbSubArray = getfield(ProbArray[i],"^","")
//check if the match function returns greater than zero. this indicates a match was found.
if match(ProbSubArray[8], "ICD10-E66.3") > 0
/*ProbSubArray[8] is the ICD10 code. Had to do some digging for this.*/
then
/* ProbSubArray[9] should access the PRID!*/
MEL_REMOVE_PROBLEM(ProbSubArray[9],"", "", "")
MEL_ADD_PROBLEM(ProbSubArray[1],ProbSubArray[2],ProbSubArray[3],"03/03/1990","",str(OBSNOW("BMI")),"","")
FlagVar = TRUE
i = 100
endif
endfor
/*If the loop did not find the problem to update, add a new one. This happens after the FOR loop ends*/
if FlagVar == FALSE then
MEL_ADD_PROBLEM("","TEST","","04/04/2000","",str(OBSNOW("BMI")),"","")
endif
}
I ran this and managed to both overwrite the existing problem, and to create a TEST problem if there was no match.
I am also including a zip file with my MEL Tester form. it allows you to run MEL code inside of a chart document, and see what it spits out. I ran the section where you use PROB_AFTER("delimited"), and I waas able to see the ICD10 code, and the PRID.
Finally, you can display a global variable in a Data Display by setting the type to "MEL expression" and just typing the name of the variable in the box. I use this alot to see what results I am getting. I even use it with my MEL tester form. 🙂
Thank you so much for this! There are some problems I'm encountering, but they might be with the rest of my form. Three test problems currently post when I open the form again, and sometimes when I attempt to update the old data, all the fields fill with the raw MEL code. But your loop works in all the ways mine didn't!
I do have a few questions, however.
First, where did you find the ICD10 code? I see it now in your MEL Tester (thanks for sharing that, by the way!). Is that what you used? I was using ProbSubArray[5] based on my counting PROB_AFTER's return in the Centricity Help Database... EDIT: My mistake! I misunderstood that carrots marked the beginning and end of each entry, rather than being a single entry themlselves... So the documentation is right, just hard for me to read.
Second, why do you put i = 100 at the end of the FOR loop? Is that just a safeguard to make sure the loop has a forced stopping point?
This was a huge help, not only in helping me figure out this function, but also in helping to lead me (and hopefully any other CHUG users) to a clear understanding of how to get this data. Also, thanks for sharing your MEL Test form! I really appreciate your help.
EDIT: I think I was wrong! This is working!
Hooray! I am glad it is working! The MEL Tester has been a huge help in figuring out code, and troubleshooting my forms while I build them
Yeah, the Carets can be confusing. I have done things where I misread the documentation too many times to count. it does get easier though.
To answer your 2nd question, setting i = 100 will cause the loop to stop checking every problem in the problem list once a match is found. For example, if the patient has 25 problems in the chart, but the 2nd problem in the problem list is a match for the code E66.3, then the loop would normally still check the remaining 23 problems. once the match is found , setting i to 100 ends the loop, thus making your code run faster.
It is not very noticeable in smaller forms, but if you have a large form with lots of code, this can cut down on the loading time when running different code. I figure that most patients wont have 100 problems on the list at once.
I am glad to be of help! The CHUG boards have been a huge resource for me in learning the system, and I am happy to pass on what I learn. If you need any further assistance, please post again, or shoot me an email ([email protected]) ^_^