I am trying to get the calculation below, a data display from my Random Pill Count form to show up in the text translation. I have tried many different ways. I was able to do it with other similar data display calculations but not this one. Does anyone have ideas? It should look something like this in the document:
# of pills patient should have: 8
{val(DOCUMENT.LASTREFILL1) - (durationdays(obsnow("LASTREFILL"), str(._TODAYSDATE)) * val(DOCUMENT.MAX1))}
Make sure "lastrefill" is a valid date, I would a positive integer mask to the MAX1 and LASTREFILL1 fields, just to be safe. Durationdays returns a string so add a val() to that, and data displays like strings so put a str() around the whole thing.
I tried some of this but it still isn't working for some reason, but thank you. The formula itself works and displays for the user but the text just won't show up so I must have something wrong under the chart note box.
I would do this in the code panel
{document.temp = str(val(DOCUMENT.LASTREFILL1) – (val(durationdays(obsnow("LASTREFILL"), str(._TODAYSDATE))) * val(DOCUMENT.MAX1)))}
and set the display to show (but you could leave as is if it is working)
{document.temp}
and use
{CFMT(document.temp,"","# of pills patient should have: ","","
")}
in the text translation.
I finally had a chance to try this today and it worked like a charm, thanks Michael!