I’m working on a custom form for a Doctor (he’s quite wordy) and I’m trying to only create one button for both male and female patients. Can someone check my if then else statement to see if it will work? The form says no build error but I don’t want to test it until complete as I don’t have a test environment besides test patients. I am trying to say if the patient is male, say this in the note, but I also want the patient first and last name in the statement. Do I have to put some type of brackets around the first and last name symbols in VFE like you do in templates and handouts in CPS? Any guidance would be very helpful. I’m trying... Here is my statement below.
{If (PATIENT.SEX=="M") then "PATIENT.FIRSTNAME PATIENT.LASTNAME statement"
else if (PATIENT.SEX =="F") then "PATIENT.FIRSTNAME PATIENT.LASTNAME statement."
else
endif }
Thanks so much!
Yes you need the brackets and you need an action for the else:
{If (PATIENT.SEX==”M”) then {PATIENT.FIRSTNAME}{ PATIENT.LASTNAME} statement”
else if (PATIENT.SEX ==”F”) then {PATIENT.FIRSTNAME}{ PATIENT.LASTNAME} statement.”
else ""
endif }
You also need an endif for every if you have in your statement. You have two IF's so you need two ENDIF's
You will have to concatenate the strings together as follows:
{If (PATIENT.SEX==”M”) then {PATIENT.FIRSTNAME} + " " + {PATIENT.LASTNAME} + " statement"
else if (PATIENT.SEX ==”F”) then {PATIENT.FIRSTNAME} + " " + {PATIENT.LASTNAME} + " statement.”
else
endif
endif }
Also, unrelated to your specific question, but if you don't have a test environment, just create a test folder and save to that. That way you can test out your work beforehand without it impacting an of the encounters the users need.
Let me clean that up:
{If (PATIENT.SEX==”M”) then str(PATIENT.FIRSTNAME) + " " + str(PATIENT.LASTNAME) + " statement"
else if (PATIENT.SEX ==”F”) then str(PATIENT.FIRSTNAME) + " " + str(PATIENT.LASTNAME) + " statement.”
else
endif
endif }
You do not want to place curly braces within curly braces - ever - in any MEL statement.
You are correct sir. Thanks.
OK, what if the patient name is imbedded in the statement do I still need to use the command str? It's part of his note and he states the patient name about 3 times. Super type A Doc so I'm trying to get this right.
"Saw (patient.firstname) " " (patient.lastname) today for a blah blah blah"
Will this work? I got the first part with the sex right.....
Thanks for all your help on this, this group rocks. Glad I was able to meet some of you in Phoenix.
Thank you Lee! I learn something new everyday. Most of my VFE and MEL training has been trial by error!
MEL can be a bit wonky at times. Typically, 'PATIENT.XXX' data symbols behave oddly unless they are converted to strings, so as a habit, I always 'str()' them. If there is an issue noted, I 'un-string' them.
To answer your question, yes, you will need to call the data symbol the same way for each instance. The key here is to realize what you are asking the EMR to compile:
1) Strings
2) Data Symbols (pre-defined native functions)
The open and closed curly braces tell the compiler that the code inside them is a single statement.
The text inside the double quotes tells the compiler that the text inside them is a singe 'string' statement.
The str() command converts the data inside it into a string.
The PATIENT.XXX data symbol is the native function call
{"Some text" + str(data symbol) + " " + str(data symbol) + " some more text."}
Because you need to insert data symbols inside of an otherwise single string of text, you must break up the string into multiple parts: Pre-text, Spacer, Post-text.
Alternatively, you could define a global patient name statement, but the 'breaking of the string' is still required.
We are all so busy that typos happen when we reply on the fly. What makes this community outstanding is the effort we all put forth to ensure the information we share is accurate. As was stated, this community is awesome!