User bio
404 bio not found
Member since Nov 2, 2017
Stephen has not published any posts yet.

Here is a custom function that you may call from rules or transformations that will return the age in your choice of years, months, days.

Note that this is a complete export.

<?xml version="1.0" encoding="UTF-8"?>
<Export generator="Cache" version="25" zv="Cache for Windows (x86-64) 2017.2.1 (Build 801U)" ts="2020-03-16 16:31:49">
<Class name="Custom.GetAge">
Calculates and returns the age from the birthday passed in %Y%m%d format comparing to current date or passed in date.
ReturnUnits is "Y" (Default) for Years, "m" for Months, or "d" for Days
currentday in HL7 format, defaults to today if blank  </Description>

<UDLText name="T">
// ClassMethod GetAge(birthday As %String, ReturnUnits As %String, currentday As %String) As %String [ Final ]


<Method name="GetAge">
returns the current age in years with birtday passed in %Y%m%d format</Description>

    // convert date times into correct format
    set Tbirthformat = ##class(Ens.Util.Time).ConvertDateTime(birthday,"%Y%m%d","%q(3)" )
    if currentday '= ""
       set Tcurrentformat = ##class(Ens.Util.Time).ConvertDateTime(currentday,"%Y%m%d","%q(3)")
    {   set Tcurrentformat = $h
    set bmonth = $SYSTEM.SQL.DATEPART("mm",Tbirthformat)       
    set cmonth = $system.SQL.DATEPART("mm",Tcurrentformat)
    set bday = $system.SQL.DATEPART("dd",Tbirthformat)
    set cday = $system.SQL.DATEPART("dd",Tcurrentformat)
    set tretval = 0
    if (ReturnUnits = "Y") || (ReturnUnits = "y") || (ReturnUnits = "")
      // calculate the difference in years by subtracting the birthday from the currentday
      set difftimeYear = $SYSTEM.SQL.DATEDIFF("yy",Tbirthformat,Tcurrentformat) // get the years

      if bmonth = cmonth   //check day since the month is the same
         if cday < bday
           set difftimeYear = difftimeYear - 1
      {  if cmonth < bmonth
           set difftimeYear = difftimeYear - 1
      // return the age in years
      set tretval = difftimeYear
    { if (ReturnUnits = "M") || (ReturnUnits = "m")
          set difftimeMonth = $SYSTEM.SQL.DATEDIFF("mm",Tbirthformat,Tcurrentformat)  // get the months
          if bmonth = cmonth
          { if cday < bday
            {  set difftimeMonth = difftimeMonth - 1
           // return the age in months
           set tretval = difftimeMonth
      {  if (ReturnUnits = "D") || (ReturnUnits = "d")
         { set difftimeDay = $SYSTEM.SQL.DATEDIFF("dd",Tbirthformat,Tcurrentformat)  // get the days
           // return the age in days
           set tretval = difftimeDay
    quit tretval

How are you bringing the messages in?   I assume through an HL7 service.    The MessageSchemaCategory must be set correctly in the service and the DocType will get set correctly.

If parsed correctly according to the schema then the message will show as Blue in the contents tab of the the message viewer,  if any segments do not match the schema then the message will show as Black at the point of mismatch.   You need to get the message to show as all Blue or the paths (word or numerical) cannot be followed.

Your screenshots showed using the testing facility for the rules and you are using "User Input".   If you scroll down in the form you will find a field to enter the DocType manually.   This field needs to have the syntax I showed above with the schemaname:ORU_R01 in your case.

The DocType is not set in the message header.  

It should look more like the following:  Note that the example below is a custom schema ORUPDF.

Without this set the word paths cannot be used to retrieve the values because these depend on referencing the schema named in the DocType.  

This DocType is assigned within the service normally.

I believe you could also change all the paths to be numerical and it may work:  such as MSH:9.2

Certifications & Credly badges:
Stephen has no Certifications & Credly badges yet.
Global Masters badges:
Stephen has no Global Masters badges yet.
Stephen has no followers yet.
Stephen has not followed anybody yet.