I have a radio button linked to OBSNOW("SMOK STATUS") with choices:
current every day smoker
current some day smoker
former smoker
never smoker
current tobacco use status unknown
unknown if ever smoked
I have a function print_smoke_sentences() being called in the translation area of this radio button.
{
if(OBSNOW("SMOK STATUS")<>"")then
print_smoke_sentences()
else ""
endif
}
In print_smoke_sentences(), I have
if(OBSNOW("SMOK STATUS")=="current every day smoker" or OBSNOW("SMOK STATUS")=="current some day smoker")then
if(OBSNOW("CIGARET SMKG")<>"" and OBSNOW("CIGARETTE/D")<>"")then
return_string = "Patient currently smokes " + OBSNOW("CIGARETTE/D")
+ " packs of cigarettes per day."
endif
endif
.
.
.
return return_string
For some reason, nothing prints in my chart note until I select the radio button for the second time. For example, I click "current every day smoker", click the cigarettes checkbox, and type in '2' for 'packs per day' and nothing prints. But, if I deselect the radio button and select it again, it prints perfectly.
I've used this approach in my Pediatrics, Adult, and Neuro-Opthamology forms and it worked fine, without having to 'trick' the radio button. When I tried it in my Child Development form, I ran into this issue.
Seemingly, there is no difference between the smoking sections on the forms that do work and the one that is having this issue, except that the smoking section is only visible in Pediatrics and Child Development if the child is >=10 years old. Pediatrics still works fine though.
I've tried changing obs terms, and the same thing happens.
I've removed all suppression and visibility, just in case, and it still happens.
I've tried calling my print function in another area of the form, and it still happens.
I can't find any code anywhere that uses OBSNOW("SMOK STATUS") except this print function.
Once I perform the radio button trickery and the note prints correctly, I try to change from "1" pack per day to "2" packs per day. The note does not update automatically, and I must deselect/reselect the radio button again in order for the note to update.
Has anyone had any experience with stubborn radio buttons and translation, and if so, how did you manage to solve your issues?
Because at the time of clicking the radio button the packs per day field isn't populated and the function only gets called when the radio button is changed.
That's the thing, this method works in several other forms.
fn definition has a ! in front of it
{
! fn print_smoke_sentences(){.......}
}
In other forms, I have the same function called in exactly the same way. Nothing will print unless the radio button is selected, the cigarette box is checked, and cigarettes per day has a value. The instant that all three fields are populated, the sentence prints. Additionally, if I change the cigarettes/day from "1" to "2", the note will immediately reflect this change.
I only intended to extend this chart note functionality to an additional form, but there's something different about it that is causing this issue with the note not updating.
That's because the function only gets called when the radio button obs term is populated. In the function itself, both of the other 2 obsterms have to be populated for the your text to be returned...'and'.
Try:
if(OBSNOW("SMOK STATUS")=="current every day smoker" or OBSNOW("SMOK STATUS")=="current some day smoker")then
if OBSNOW("CIGARET SMKG")<>"" then
return_string = "Patient currently smokes" + CFMT(OBSNOW("CIGARETTE/D"), "", "", "", " packs of cigarettes per day") + "."
endif
endif
I tried this already.
It would print:
Patient currently smokes packes of cigarette(s) per day.
Then when I typed in '2' for packs per day it would still print:
Patient currently smokes packs of cigarette(s) per day.
But if i deselect/reselect the radio button, the note updates to:
Patient currently smokes 2 packs of cigarette(s) per day.
I eventually got it to work yesterday by doing all of my MEL in the translation tab without calling my function. I would just wait to print when the fields I needed were all populated, rather than calling my print_smoke_sentences() function. I still have no idea why one approach worked for several different forms, but not for one of them.
Thanks for the suggestions.