User bio
404 bio not found
Member since Jul 24, 2017
Posts:
Joe has not published any posts yet.
Replies:

Hello Jonathan,

Assuming you have a class which overrides Ens.Rule.FunctionSet

e.g. 

Class LDH.Lib.FunctionSet Extends Ens.Rule.FunctionSet
    /// This method will append an offset from UTC to a datetime passed in as HL7 Format
    /// e.g. "20190711083705" returns "20190711083705+0100"
    /// - NB BST was introduced in 1970 so dates passed in before 1970 will return +0000 offsets for all dates
    ClassMethod GetLocalTimeWithUTCOffset(pHL7DateTime As %String) As %String
    {
        // If blank datetime passed in return blank
        Quit:pHL7DateTime="" ""
        // If the datetime passed in is without a time then return the date unmodified
        Quit:$Length(pHL7DateTime)<=8 pHL7DateTime
            
        // Otherwise convert pHL7DateTime to Local Time with offset from utc
        Set tLocalTimeStamp = $ZDT(..ConvertDateTime(pHL7DateTime,"%q(0)","%q(3)"),1,5)
        // Seperate offset from this and remove the : between hours and seconds
        Set tOffset="+"_$PIECE(tLocalTimeStamp,"+",2)
        Set:tOffset="+" tOffset="-"_$PIECE(tLocalTimeStamp,"-",2)
        Set tOffset=$ZSTRIP(tOffset,"*",":")
        
        // Append Offset to pHL7DateTime
        Quit pHL7DateTime_tOffset
    }

}

Then you can use it like this:

<assign value='##class(LDH.Lib.FunctionSet).GetLocalTimeWithUTCOffset(source.{DateTimeOfMessage.timeofanevent})' property='target.{DateTimeOfMessage.timeofanevent}' action='set' />
 

Hello Jonathan,

This is the method I wrote to do this:

/// This method will append an offset from UTC to a datetime passed in as HL7 Format
/// e.g. "20190711083705" returns "20190711083705+0100"
/// - NB BST was introduced in 1970 so dates passed in before 1970 will return +0000 offsets for all dates
ClassMethod GetLocalTimeWithUTCOffset(pHL7DateTime As %String) As %String
{
    // If blank datetime passed in return blank
    Quit:pHL7DateTime="" ""
    // If the datetime passed in is without a time then return the date unmodified
    Quit:$Length(pHL7DateTime)<=8 pHL7DateTime
        
    // Otherwise convert pHL7DateTime to Local Time with offset from utc
    Set tLocalTimeStamp = $ZDT(..ConvertDateTime(pHL7DateTime,"%q(0)","%q(3)"),1,5)
    // Seperate offset from this and remove the : between hours and seconds
    Set tOffset="+"_$PIECE(tLocalTimeStamp,"+",2)
    Set:tOffset="+" tOffset="-"_$PIECE(tLocalTimeStamp,"-",2)
    Set tOffset=$ZSTRIP(tOffset,"*",":")
    
    // Append Offset to pHL7DateTime
    Quit pHL7DateTime_tOffset
}

Certifications & Credly badges:
Joe has no Certifications & Credly badges yet.
Global Masters badges:
Joe has no Global Masters badges yet.
Followers:
Joe has no followers yet.
Following:
Joe has not followed anybody yet.