We can see patient age in years and patient age in months in Centricity. I am trying to come up with a way to show a patient's age in days in a form. This is for our newborn follow ups and 2 week well-checks. I tried creating the following calculation with an action button that ran the process of "fnAgeindays()" but it did not work:
fn fnAgeindays()
{
local lvalue
lvalue = str(._TODAYSDATE) - PATIENT.DATEOFBIRTH
OBSNOW("AGE MONTHS", str(lvalue))
}
Any suggestions?
Thanks in advance.
Bill James
Treehouse Pediatrics
Round Rock, TX
You want to use DURATIONDAYS(date1,date2) to get how many days.
DURATIONDAYS( str(PATIENT.DATEOFBIRTH), str(._TODAYSDATE) )
should give you the number of days since baby was born to todays date.
If you are putting documents on hold for several days or longer,
you might want to use DOCUMENT.CLINICALDATE instead of ._TODAYSDATE
DOCUMENT.CLINICALDATE returns datetime of that encounter visit,
so if it returns: 06/17/2014 11:24 AM, you need to parse out just the date:
DURATIONDAYS( str(PATIENT.DATEOFBIRTH)
, sub(str(DOCUMENT.CLINICALDATE), 1, 10) )
Perfect. Thank you very much! The calculation language I used is as follows:
fn fnAgeindays()
{
local lvalue
lvalue = DURATIONDAYS( str(PATIENT.DATEOFBIRTH), str(._TODAYSDATE))
OBSNOW("AGE MONTHS", str(lvalue))
}
... and I put in an action button with a run process that said fnAgeindays()
Thank you very much.
so you want to store "days" into obsterm "AGE MONTHS" ?
... just checking 🙂
I have already requested the obs term from Centricity.
It all works, no matter what obsterm you store it in.
You might want to have it clear in the flowsheet that this obsterm contains "days" not "months". You could append " days" to the lvalue.
OBSNOW("AGE MONTHS", str(lvalue) + " days")
Then if you need to retrieve this value to use in any calculations,
you can strip off the " days" by using the VAL( ) function.
VAL() strips off any whitespace or characters and just leaves the number.
numDays = val( OBSANY("AGE MONTHS") )
They are now interested in taking this one step further. We will frequently calculate the number of ounces gained or lost per day. The providers will look at the date of the newborn follow up, the weight that day, the current date of the 2 week well check exam, and the weight that day to calculate this. Any ideas?
This is just math…walking through it…
Do you store babys weight
1) in an obsterm X in lbs and oz ?
Or do you want (moving forward),
2) to add to your forms a new 2nd weight obsterm Y, that you store the babys weight in as total oz ?
For (1), I would suggest using GETFIELD twice, once to parse out the lbs, and a 2nd time to parse out the oz. Then it's just math to reduce it to total oz, and subtract past weight from current weight (which you have also converted to total oz), to get change in weight.
…So…if obsprev("X") contains "6 lbs 7 oz"
local prevLBS_Array = getfield(obsprev("X"),"lbs","")
prevLBS_Array[1] <— will contain "6 "
prevLBS_Array[2] <— will contain " 7 oz"
local prevOZ_Array = getfield(prevLBS_Array[2],"oz","")
prevOZ_Array[1] <— will contain " 7 "
local prevTotalWt_oz = val(prevLBS_Array[1]) * 16 + val(prevOZ_Array[1])
… I have not tested the example code above, but that's the logic…
For (2), you have total oz stored in OBSPREV("Y"), then you can
take (current weight – OBSPREV("Y") ), to get change in weight.
There are many ways to code this…but this is off the top of my head…post here and let us know how it works out. 🙂
Noticed I had forgotten to multiply lbs by 16 to get oz
Corrected previous post to:
local prevTotalWt_oz = val(prevLBS_Array[1]) * 16 + val(prevOZ_Array[1])
You will also need to check for other types of data, and use appropriate if.. stmts
Example: if obsprev("X") contains "8 lbs" - but no "oz"
if match( obsprev("X"), "lbs" ) > 0 then
prevLBS_Array = getfield(obsprev("X"),"lbs","")
…
if match( prevLBS_Array[2],"oz" ) > 0 then
prevOZ_Array = getfield(prevLBS_Array[2],"oz","")
…
else
// prevOZ is 0
""
endif
else
// prevLBS is 0
""
endif
Wow. I am impressed.
I will try to install this and see where it goes.
BTW, all I see on your posts is "blackmanb." Who are you?
Beverly Blackman
Northern Arizona Orthopaedics
I keep meaning to update my profile 🙂
Your kung fu is good. Thank you for the brilliant suggestions!