Can you evaluate more than 1 observation term in 1 if-then-else statement?
Here is what I am trying to do but it fails. And how do I look at the current obs term and not all for a particular obs term when pulling into the note?
{if OBSNOW("AASCRNDCL") <> " " and OBSNOW("AAASCRNNEXT") == " " then "Abdominal aortic aneurysm screening is recommended, but you have declined it." else if OBSNOW("AASCRNDCL") == " " and OBSNOW("AAASCRNNEXT") <> " " then "Abdominal aortic aneurysm screening is next due on or after" + OBSNOW("AAASCRNNEXT") else " " endif endif}
The answer to your question is "Yes." You can evaluate more than one condition in an if statement.
Are you attempting to do this for text translation purposes or is this code inside of a function that is being called? If it's for text translation purposes, you may want to use a global variable and set the value of the variable to the text translation you desire in a watcher expression. You can then reference the global variable in your text translation of the document (in this example, the myvar variable). You could also use a case statement (cond/endcond) instead of an if/then/else if you wanted the code to read more clearly.
{
!if ((OBSNOW(“AASCRNDCL”) <> ” ”) AND (OBSNOW(“AAASCRNNEXT”) == ” ”)) then
myvar = “Abdominal aortic aneurysm screening is recommended, but you have declined it.”
else
if ((OBSNOW(“AASCRNDCL”) == ” ”) AND (OBSNOW(“AAASCRNNEXT”) <> ” ”)) then
myvar = “Abdominal aortic aneurysm screening is next due on or after” + OBSNOW(“AAASCRNNEXT”)
else ” ”
endif
endif
}
The code you have written is correct, but I found that the Quotation Marks are stylized. Open a notepad or wordpad (not microsoft word) and notice that the quotes are not straight. I have this break my code alot, so I always make sure to use notepad++ for my building of MEL code. here is the code with the straight quotes
{if OBSNOW("AASCRNDCL") <> " " and OBSNOW("AAASCRNNEXT") == " " then "Abdominal aortic aneurysm screening is recommended, but you have declined it." else if OBSNOW("AASCRNDCL") == " " and OBSNOW("AAASCRNNEXT") <> " " then "Abdominal aortic aneurysm screening is next due on or after" + OBSNOW("AAASCRNNEXT") else "" endif endif}
as for your second question, the OBSNOW code will only pull in the observation if it was made inside of the current document. OBSPREV will only pull in signed observations from previous documents, and OBSANY will grab the latest one it can find (either signed in a different note, or a new one for today)
I hope this helps
Just saw that you are using this in a letter template. I suspect Daniel's answer is correct regarding the stylized quotes.
Additionally OBSNOW will only work in a letter template if you are trying to print the letter while the current document is still open (Not on Hold). OBSPREV or OBSANY will work better within a Letter because they will represent the most recently signed OBS. OBSNOW is only visible/usable within an open document.