Question
· Aug 30, 2016

NACK - pulling HL7 message raw content into an Alert

Ensemble 2015.  Working on an a way to send NACK'd HL7 messages to a flat file for external review/troubleshooting. (Similar to the way BadMessageHandler deals with validation errors.)

I think I have the Alert piece down, but need assistance with the exact syntax to do an SQL query in the DTL (or a custom function) to pull the HL7 message Raw Content into the Alert, based on the SessionID.

(Also, anything special to write alerts to the File Operation?)

 

Thanks,  Brian

Discussion (3)1
Log in or sign up to continue

Brian,

Try this.

ClassMethod getRawHL7Content(pSessionID As %String = "", pTargetName As %String = "") As %String
{
    set RawContent= "Message Not Found: Contact Interface Team"
    set pID = ""
    
    if (..NotEmpty(pSessionID)) && (..NotEmpty(pTargetName)) 
    {
        &sql(
            SELECT TOP 1 MessageBodyId INTO :pID
            FROM Ens.MessageHeader
            WHERE (TargetConfigName=:pTargetName AND SessionId=:pSessionID)    
            OR    (SourceConfigName=:pTargetName AND SessionId=:pSessionID)
        )
        if SQLCODE '= 0 {
            set RawContent = "Message Not Found: Contact Interface Team"
        }
        else
        {
            set RawContent = ##class(EnsLib.HL7.Message).%OpenId(pID).OutputToString()
        }
    }
    
    
    Quit RawContent
}
 

Thanks.  Didn't like the "set RawContent = ##class(EnsLib.HL7.Message).%OpenId(pID).OutputToString()" piece for some reason, so ended up with a seoncd SQL statement to pull the data.  Here is my custom function code:

ClassMethod CHNwGetRawMessageForAlerts(
pSessionID As %String = "",
pTargetName As %String = "") As %String
{
    set HL7RawContent= "Message Not Found: Contact Interface Team"
    set pID = ""
    
         &sql(
            SELECT TOP 1 MessageBodyId INTO :pID
            FROM Ens.MessageHeader
            WHERE (TargetConfigName=:pTargetName AND SessionId=:pSessionID)
            OR (SourceConfigName=:pTargetName AND SessionId=:pSessionID)
        )
        if SQLCODE '= 0 {
            set HL7RawContent = "SQL1 Message Not Found: Contact Interface Team"
        }
        else
        {
            &sql(
            SELECT RawContent INTO :HL7RawContent
            FROM EnsLib_HL7.Message
            WHERE ID=:pID
           
        )
        if SQLCODE '= 0 {
            set HL7RawContent = "SQL2 Message Not Found: Contact Interface Team"
        }
        }
    
       Quit HL7RawContent
}

Hi

In our case the ID for the Message is in the field MessageControl ID

if we replace ID with Identifier, which holds the MessageControl ID, the Query bellow does not work...

&sql(
            SELECT RawContent INTO :HL7RawContent
            FROM EnsLib_HL7.Message
            WHERE ID=:pID           
        )

Anyone have an Idea why and how to work around this?

The "Identifier" column exists in EnsLib_HL7.Message...

Thank you