On my HL7 Msg, on the PID Section, I have the field DateTimeOfBirth
and I want to calculate the Age so that if the Person (Baby) is < 2 I
Send the Msg otherwise it's ignored.
So on my Message Routing Rule I would like a Condition expression
like:
IF Age(source.{DateTimeOfBirth}) < “2”
Is that possible?
Currently using the $zdatetimeh function to get the date to $horolog
format - so I have:
Round(($h-$zdatetimeh(source.{DateTimeOfBirth},8))/365,1)
and then it’s a case of storing the age on an available field within
the Msg and re-routing the HL7 amd using ObjectScript code Etc Was
wondering if there was a more optimal way?
All comments appreciated - Many Thanks
You could probably create a user defined function which will extend
Ens.Rule.Functionset and then use that in your Rule passing in the
date of birth field and using the less than condition.
Check out the documentation at
http://docs.intersystems.com/ens20102/csp/docbook/DocBook.UI.Page.cls?KEY=EGDV_prod_create#EGDV_prod_utility_functions
- this should give you enough to go on.
Regards,
Gary
--
You received this message because you are subscribed to the Google Groups "InterSystems: Ensemble in Healthcare Community" group.
To post to this group, send email to Ensemble-in...@googlegroups.com
To unsubscribe from this group, send email to Ensemble-in-Healt...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/Ensemble-in-Healthcare?hl=en
On Dec 1, 5:07 pm, Lawrence Harris <lhar...@emrlogic.com> wrote:
> Two items to note, the age is relative to some point in time, if you were to re-avaluate the message from an archive several years from now your calculation would be wrong. I would base it at least on the date from the MSH header and not $H, usually I base it on a date from the OBR segment or the encounter date from the PV1. Also a better divisor if you want to be simple is 365.25 which handles leap years better. If you need to be more exact you are going to have to manage the day, month and year. I have often had issues where the simple calculation is off by a few days and the complaints come back that the person is not yet x age or is x+1 at the time.
>
> Creating a UDF based on Ens.Rule.FunctionSet is definitely the way to go. At least you can change your mind and adjust it in one place and/or find all occurrences of the function call to make adjustments. I would give the function two arguments; date-of-birth and as-of-date.
>
> Good luck, Lawrence
>
> On 2011-12-01, at 8:07 AM, Ricardo Santos wrote:
>
> One way I've done this is how Gary mentioned. I created a UDF on a class extending Ens.Rule.Functionset, to which I passed a DOB.
>
> Getting the horolog value of the DOB and today's, it was a matter of subtracting first element of the horolog value - $P($H,",") and subtracting the DOB's from today's value. The result was the number of days elapsed since DOB and today. Checking that is less than 365 * nrYears gave me the filtering threshold you are looking for.
>
> Conversely, you can MOD the difference by 365 and that should give you patient's age in years.
>
> Hope this helps!
>
> Regards,
> Ricardo
>
> <http://www.linkedin.com/in/ricardolsantos>
>
> On 1 Dec 2011, at 15:44, Gary wrote:
>
> Hi,
>
> You could probably create a user defined function which will extend
> Ens.Rule.Functionset and then use that in your Rule passing in the
> date of birth field and using the less than condition.
>
> Check out the documentation athttp://docs.intersystems.com/ens20102/csp/docbook/DocBook.UI.Page.cls...
> - this should give you enough to go on.
>
> Regards,
> Gary
>
> On Dec 1, 3:29 pm, YM <yunus.ma<http://yunus.ma>....@midyorks.nhs.uk> wrote:
> Hi All,
>
> On my HL7 Msg, on the PID Section, I have the field DateTimeOfBirth
> and I want to calculate the Age so that if the Person (Baby) is < 2 I
> Send the Msg otherwise it's ignored.
>
> So on my Message Routing Rule I would like a Condition expression
> like:
>
> IF Age(source.{DateTimeOfBirth}) < “2”
>
> Is that possible?
>
> Currently using the $zdatetimeh function to get the date to $horolog
> format - so I have:
>
> Round(($h-$zdatetimeh(source.{DateTimeOfBirth},8))/365,1)
>
> and then it’s a case of storing the age on an available field within
> the Msg and re-routing the HL7 amd using ObjectScript code Etc Was
> wondering if there was a more optimal way?
>
> All comments appreciated - Many Thanks
>
> --
> You received this message because you are subscribed to the Google Groups "InterSystems: Ensemble in Healthcare Community" group.
> To post to this group, send email to Ensemble-in...@googlegroups.com<mailto:Ensemble-in-Healthcare@googlegroups.com>
> To unsubscribe from this group, send email to Ensemble-in-Healt...@googlegroups.com<mailto:Ensemble-in-Healthcare-un...@googlegroups.com>
> For more options, visit this group athttp://groups.google.com/group/Ensemble-in-Healthcare?hl=en
>
> --
> You received this message because you are subscribed to the Google Groups "InterSystems: Ensemble in Healthcare Community" group.
> To post to this group, send email to Ensemble-in...@googlegroups.com<mailto:Ensemble-in-Healthcare@googlegroups.com>
> To unsubscribe from this group, send email to Ensemble-in-Healt...@googlegroups.com<mailto:Ensemble-in-Healthcare-un...@googlegroups.com>
I hope that proves helpful,
Dale
This means you and our support will instantly recognize them as your functions not standard functions. It means they will appear together in the drop down list of the rules editor. And perhaps most importantly, if InterSystems add an Age() function at some stage in the future there will be no conflict.
Dave
eg. The first should be 50, the second 51. It appears to only look at the year
USER>w $system.SQL.DATEDIFF("year","15 jun 1960","14 jun 2011")
51
USER>w $system.SQL.DATEDIFF("year","15 jun 1960","16 jun 2011")
51
Where as using 365.25 works most of the time though it has problems at low ages. There is where you might have to actually look carefully at the birthday to decide between age A and A+1.say
USER>w $system.SQL.DATEDIFF("day","15 jun 1960","16 jun 2011")/365.25\1
51
USER>w $system.SQL.DATEDIFF("day","15 jun 1960","14 jun 2011")/365.25\1
50
> > For more options, visit this group athttp://groups.google.com/group/Ensemble-in-Healthcare?hl=en- Hide quoted text -
>
> - Show quoted text -
ClassMethod CalculateAge(dateOfBirth As %String) As %Integer
{
set now = $ZDATE($NOW(), 3)
set dobYear = $SYSTEM.SQL.YEAR(dateOfBirth)
w "Dob year ",dobYear,!
set thisYear = $SYSTEM.SQL.YEAR(now)
w "This year ",thisYear,!
set dobMonth = ($SYSTEM.SQL.MONTH(dateOfBirth))
w "Dob month ",dobMonth,!
set thisMonth = ($SYSTEM.SQL.MONTH(now))
w "This month ",thisMonth,!
set dobDay = ($SYSTEM.SQL.DAYOFMONTH(dateOfBirth))
w "Dob day ",dobDay,!
set thisDay = ($SYSTEM.SQL.DAYOFMONTH(now))
w "This day ",thisDay,!
set age = thisYear - dobYear
if (dobMonth = thisMonth)
{
w "Dob month is equal to this month",!
if (dobDay > thisDay)
{
w "Persons birthday hasn't passed this year",!
set age = age - 1
}
}
w "age is ",age,!
quit age
}
It could be called like so:
do ##class(GGC.Utilities.DateHelper).CalculateAge("1982-12-13")