I'm trying to have a form display (everything is in a single visibility region at this point, and that's fine) only for females between the ages of 12 - 65. I've been successful with it when I have only the age criteria as shown below:
(patient._ageinmonths > 244 AND patient._ageinmonths < 781)
I haven't tried changing that to:
(PATIENT_AGE() > "12" AND PATIENT_AGE() < "65")
but I'm contemplating trying that only after I get the female criteria to work as well. I've looked around the forum and the closest I can find is this: https://forum.centricityusers.com/forum/visibility-region-for-agesex/, but even after editing mine to something similar, I am still getting false readings.
I suspect it has something to do with the order of parentheses or perhaps I need brackets. I've tried the following:
(patient._ageinmonths > 244 AND patient._ageinmonths < 781) (PATIENT.SEX == "F")
and:
(patient._ageinmonths > 244 AND patient._ageinmonths < 781) AND (PATIENT.SEX == "F")
and:
(patient._ageinmonths > 244 AND patient._ageinmonths < 781 AND PATIENT.SEX == "F")
and:
patient._ageinmonths > 244 AND patient._ageinmonths < 781 AND PATIENT.SEX == "F"
and:
patient._ageinmonths>244 AND patient._ageinmonths<781 AND PATIENT.SEX=="F"
and:
(patient._ageinmonths>244 AND patient._ageinmonths<781 AND PATIENT.SEX=="F")
and other combinations I have forgotten. Any thoughts?
Noted some issues in your statement, but you were not far off. 🙂
If age is 12 yrs to 65 yrs, then ensure it is inclusive by using <= or >=, as appropriate.
Check your math. 12 years = 144 months ; 65 years = 780 months.
Be certain that you are using the ASCII 34 double quote and not the ASCII 147/148 double quote set. MEL does not process the higher code quote characters.
For this statement, the grouping in the parenthesis really does not matter, however in the name of good syntax, you should establish a standard for use so that when you are coding more complex logic, it will make debugging much easier. Grouping by types, when feasible, is a good method.
(PATIENT._AGEINMONTHS >= 144 and PATIENT._AGEINMONTHS <= 780) and (PATIENT.SEX == "F")
The above should get you what you want.
Hope this helps.
So, here's the code that works as is:
(patient._ageinmonths >= 144 AND patient._ageinmonths <= 780) AND (PATIENT.SEX == "F")
but now they'd like to add text that if the patient doesn't meet these requirements, it says something like:
Does not meet form requirements
Am I now looking at a case or an if, then, else statement?
No, you are looking at a new visibility layer (stacked on top of the existing layer) and logic essentially opposite from the previous layer. Inside that layer, you will have a text item with the text you desire.
It is important to understand how visibility layers work. The basic principle is that any expression that is connected to it will evaluate to either TRUE or FALSE. TRUE will show the layer while FALSE will hide it. If you always want to show a layer, a simple TRUE will suffice to do so while FALSE entered in the MEL connection of a visibility layer will always hide it.
The code you need is:
(PATIENT._AGEINMONTHS < 144 OR PATIENT._AGEINMONTHS > 780) AND (PATIENT.SEX == "F")) OR (PATIENT.SEX == "M")
When using 'OR' within parentheses, it will evaluate all expressions within and return the result. If one is TRUE, then the statement is TRUE even if the other is FALSE (because of the 'OR' statement).
So, if a female patient is 100 months old, the visibility would be seen because
100 is < 144 (TRUE) 'OR' 100 is > 780 (FALSE) RESULT: TRUE
'AND' Patient is Female (TRUE) RESULT: TRUE AND TRUE ---> SHOW
If Patient is MALE the 'OR' kicks in and regardless of the age/F requirements due to the parenthesis grouping. (FALSE OR TRUE = TRUE)
Play around with the parenthesis placement, review a MEL TRACE after each change, and watch how MEL interprets the code. This will give you far more understanding than anything anyone can tell or show you. It tunes you in to how the EMR 'thinks' and often will answer most of the questions that you might have.