Hello all,
I have some Mel code in a patient banner that displays the patients next appointment and who it is with. For a very few patients, it breaks, and I don't know why. Here is my code.
{if match(APPT_NEXT(), ":") > 0 then arr=getfield(APPT_NEXT(),",","")
arr[1]+","+arr[2]+arr[5]+","+sub(arr[6],1,2)+"."
else
"None"
endif}
It seems to be breaking for patients whose next appointment is a nurse visit, so there is no doctor assigned. How would I modify this to not break if there isn't a doctor resource assigned to the appointment?
Thank you.
I'm not very familiar with the array format, so I'd have to look up what you're putting in the arr variable or what arr 1, 2, 5, and 6 are. That won't stop my first guess though.
First thought is a special character issue in a field. Does the nurse's name happen to have a special character like an apostrophe or space? Does one of your fields contain a leading or trailing space that isn't obvious?
-dp
The 5th and 6th fields in APPT_NEXT are not documented within GE Help (or at least my site).
Because of what you are saying, I am wondering if you are not getting all 6 fields every time. What happens if you create a quicktext (simple to test) that does something like:
{APPTS_BY_STATUS("scheduled","FULL")} and execute the QT when in that patient chart?
I wonder if you will see all six fields for every entry.
Thank you for the reply. There aren't any special characters or leading/trailing spaces. There is a space in the middle though, "Cascade Nurse"
Thank you for your reply. I entered that quick text into a form on the patients chart, and it populated the patients upcoming appointments, including the nurse visit with no doctor. Here is what the output is:
05/22/2019, 9:30 AM, MAT-Work in, Cascade Center, Cascade Nurse
05/23/2019, 3:00 PM, MAT New Pt Eval/Admit - 60, Cascade Center, Crawford CSWA, Lisa
05/28/2019, 3:30 PM, Physical, SouthRiver Community Health Center, Russell PA, Jonathan F
Ok, so it looks like it's breaking when there isn't a value in array position 6. I'm new to MEL, so I'm having a hard time figuring out how to check for an empty array value, so it doesn't break the banner.
In your first line (5/22/19 @ 9:30am) there are only 5 fields.
Could it be a problem with referencing arr[6] when it is null?
-dp
That's what it looks like. I'm fairly new to MEL, how do I code against that?
To determine the number of elements in your array, take a look at the SIZE command, and the 2nd example below (from HELP files)
description
Returns the size of its argument.
type
MEL utility function
syntax
size(value)
arguments
value |
A string or array to get the size of. |
returns
A long which is the size of the string or array
example 1
{global x = "hello"
size(x)
returns
5
example 2
global x = array(1,2,3)
size(x)
returns
3
So I could check if the array size is 5 or 6, and create separate banners based on each total, is that the idea?
Yes, checking the array size would be one approach.