Question
Ben Webb · Oct 28

Can anyone tell me how to get the DocType from looking at a HL7 message body?

Hi all, 

Just wondering if there's a quick way to get the DocType, without knowing it in advance, from a message body by building a string from the VersionID, MessageType, and TriggerEvent fields? (Similar to how it might be done dynamically in Rhapsody)

Can this then be used to set the DocType for a source message?

If this is not the best practice what is a suitable alternative approach?

Thanks for your help,
Ben

10
1 0 6 104
Log in or sign up to continue

Not sure what you want ?

If request is 'request As EnsLib.HL7.Message' then request.DocType.
 

Hi Michel, 
Thanks for the reply, 
What I'm looking for is a way to have one DTL that performs the same operation (e.g changing the MSH:receiving application field) on many different event types (ADT_01, ADT_A08 etc.), without having to create a separate DTL to perform the operation for each event type, 
My thinking was you could programmatically build a string for DocType from the message body and use that to tell the engine how to parse each message event at runtime as the different events pass through the DTL,
Is there a way of doing this, or is there a better approach?
Thanks

Class UMMS.UMMC.HL7.ALL.RouterRoutines Extends Ens.Rule.FunctionSet
{

ClassMethod SetDocTypeId(pMessageId As %String, pDocType As %String) As %String
{
    set $ZTRAP="SetDocTypeIdError"
    set oref=##class(EnsLib.HL7.Message).%OpenId(pMessageId)
    if '$IsObject(oref) {
        &js<document.all.display.innerHTML='Unable to open HL7 message';>
        quit
    }
    s oldDT = oref.DocType
    s oref.DocType = pDocType
    // the next call doesn't seem to be necessary unless we are running from the terminal
    // (at least as long as the production isn't bounced!)
    do oref.%Save()
    
    // only see in router's log if trace is enabled 
    $$$TRACE("ROUTER TESTING:: Was able to set old oref.DocType ["_oldDT_"] to new ["_oref.DocType_"] from passed in ["_pDocType_"] for msgID ["_pMessageId_"] ...\n")
    
    Quit 1

SetDocTypeIdError
    set $ZTRAP=""
    If $ZE $$$LOGERROR("$ZE: "_$ZE) //test unnecessary but ...
    $$$TRACE( "error setting ID doctype ["_pDocType_"] for ID ["_pMessageId_"] ... \n\n" )
    quit ""
}

}

Examples of calling a function from csession, and setting DocType ad hoc:

ENSEMBLE>do ##class(UMMS.UMMC.HL7.ALL.RouterRoutines).SetDocTypeId( "40382754","2.3:ORM_O01")
/// note: quotes around the msgId don't seem to be necessary. Cache casts num to string?
/// Also, the shorter version of above is:
/// ENSEMBLE>set oref=##class(EnsLib.HL7.Message).%OpenId(40382754)
/// ENSEMBLE>s oref.DocType = "2.3:ORM_O01"  
/// ENSEMBLE>w oref.DocType
/// 2.3:ORM_O01
/// ENSEMBLE>do oref.%Save()Examples of calling ad hoc:

...where msgId is the first number listed in the Message Viewer Contents panel.

Hi James, 
Thanks for the reply, this will help me out a lot, 
Much appreciated,
Thanks

Hi Ben,

You can use EnsLib.HL7.Schema ResolveSchemaTypeToDocType() class method to resolve DocType dynamically.

For example, if message is an OREF to an instance of EnsLib.HL7.Message :

s message.DocType = ##class(EnsLib.HL7.Schema).ResolveSchemaTypeToDocType("2.5",message.Name)