I am trying to write something to indicate if the gestational age is greater than 40 weeks that the banner should update to Complete. If it is less than 40 weeks it should display the weeks and days.
Here is what I have but it only prints the code not the output I am looking for.
Simple as possible is best as I am not very familiar with the if; else, endif statements.
Thanks everyone!!
if val(DurationDays(str(._TodaysDate),obsany("EDD FINAL")))>=14 then " GA: "+fmt(str(div(280-val(DurationDays(str(._TodaysDate),obsany("EDD FINAL"))),7))+" wks " +str(mod(280-val(DurationDays(str(._TodaysDate),obsany("EDD FINAL"))),7))+" days","B") else " Completed" endif}
Are you getting any kind of error when the code is displayed in the banner? In my experience the banner is a bit finicky about formatting etc. compared to forms and letters.
It may be something else but try removing the val() around your durationdays() functions. They return a number by default. When you try to convert a number into a number, a string into a string or convert the same variable repeatedly, it will sometimes throw an error.
Curious to know a few details:
1) Noted the presence of a close curly brace but no opening curly brace. Does the original code include it?
2) Noticed some hi-ascii characters in the pasted code. It might be due to the forum, but just in case, copy and paste the code snippet into NOTEPAD then copy and paste it back into the banner to get rid of any hidden characters. These type of characters do not play well in the EMR.
3) Noticed that you are not including an exception for patients who do not have an EDD value. Might want to add one if it is possible.
4) You might need to enclose the entire 'text' portion of the FMT statement in parens - it can be a bit picky. You can also troubleshoot the code by removing portions and adding it back in sections until it fails to aid in narrowing it down.
Also understand that the banner code is unique in that it is only updated when the chart is first entered into. To get it to refresh, you will need to exit the chart (desktop or different patient) then return.
Beyond the above, I don't see anything outright.