I'm hoping someone has some insight...
I'm trying to tweak this statement so it shows me the last physical the patient arrived to and/or is scheduled for.
so, if I put it in a letter the result displays something like:
09/23/2016, 7:30 PM, PHYSICAL EXAM NEW PT, Family Doctors, LLC, Smith MD, Joseph
I feel like I am on the right track but maybe I'm thinking too hard about it? I know the below statement will only return some numbers greater than '0' but maybe theres a get function or find function or something? Thanks in advance!!
{
if match(tolower(APPTS_BY_STATUS('arrived','FULL')),'physical')>0
then match(tolower(APPTS_BY_STATUS('arrived','FULL')),'physical')
else if match( tolower(APPTS_BY_STATUS('arrived','FULL')),'well') >0
then match(tolower(APPTS_BY_STATUS('arrived','FULL')),'well')
else if match(tolower(APPTS_BY_STATUS('scheduled','FULL')),'well') >0
then match(tolower(APPTS_BY_STATUS('scheduled','FULL')),'well') >0
else if match(tolower(APPTS_BY_STATUS('arrived','FULL')),'physical') >0
then match(tolower(APPTS_BY_STATUS('arrived','FULL')),'physical') >0
else "<NO PHYSICAL ON FILE>"
endif
endif
endif
endif
}
A few thoughts...
1. I would recommend a COND/CASE statement instead of a nested IF/ELSE, as it will make it much easier to read and/or make changes to in the future.
2. When your IF statements are evaluating to TRUE, you are returning a MATCH statement, which will only display an integer, and not the full string of text you are looking for. The integer returned will be the character number in the string you are evaluating. Ex: MATCH("The sky is blue", 1, "blue") will return 12.
3. MEL statements are case-sensitive, so if your appointment type is "Physical" instead of "physical", nothing will be returned.
Hi, Thanks for the pointers regarding cond/case. I'll definitely apply...
The statement isn't missing any appointments because of the tolower() function. so, it's matching with anything that contains "physical".
And as you said, the match only returns an integer. Do you know or have an idea of a statement that would return any string that contains "physical"?
Thanks again!
APPTS_BY_STATUS returns a giant string of every appointment that matches the parameters. These appointments are separated by a delimiting character...in the case of APPTS_BY_STATUS, it's a hard return.
So...from a VERY high level, what you're going to want to do is...
1. Bring the results of APPTS_BY_STATUS into a string.
2. Split this string into an array by using the GETFIELD function. Ex: apptArrayOV1 = getfield(APPTS_BY_STATUS("Confirmed", "FULL"), "\r", "")
3. Loop through this array...when you go through an element, use the COND/CASE + MATCH function to check for the appointment type and determine if this particular appointment should be included. If something in your COND/CASE evaluates to TRUE, then you can print this into your return string.
I would write it as a function and then call that function from your form/letter template. It's actually somewhat complicated...I recommend doing a MEL Trace to watch what's happening in this function. We've gotten this to work, but it takes some effort.
Perhaps someone has an easier method, but that's how we accomplish this task.