Question
· Oct 26, 2021

DTL Editor: How to get DocType at runtime?

Hi all, 

I'm fairly new to this engine so I was wondering what the best approach for creating a dynamic mapper to downgrade from one HL7 version to another (e.g 2.4 to 2.3) with the DTL Editor,  It seems like something that would be quite commonly needed but I haven't found a method that works yet,

I would like to Map any 2.4 ADT message to the same event type in a lower version (e.g DocType 2.4:ADT_A01 to 2.3:ADT_A01), without having to create a specific map for each trigger event and without having to specify the DocType ahead of time. At the moment I'd need 40 or so unique maps if I was to specify the docType ahead of time so was looking for a more streamlined solution.

Is there a way of using the code action in the DTL Editor to extract the MessageType and TriggerEvent from the source message at runtime, without already having an explicit DocType defined, to use it to specify the DocType for the source and target messages so the rest of the segments can be mapped?

My current approach doesn't compile but it might explain what I'm trying to do 

SET msg=##class(EnsLib.HL7.Message).%OpenId(26872)  //Bring the source message into scope
SET msgEvent = msg.FindSegmentValues("MSH:9.2")           //Get the event type from MSH segment field 9, subfield 2
SET msg.DocType =  "2.4:ADT_"_msgEvent                              //Concatenate into a DocType string and replace the source docType with this value so the engine knows the DocType at runtime

Any help, different approaches, or insight will be very appreciated, 

Thanks, 
Ben

Product version: HealthShare 2020.2
Discussion (6)2
Log in or sign up to continue

You can change the message DocType, but you can't change the message content:

HICG > s msg=##class(EnsLib.HL7.Message).%OpenId(7463)
HICG > w msg.IsMutable
0
HICG > w msg.DocType
2.3.1:ORU_R01
HICG > s msg.DocType="2.5.1:ADT_A01"
HICG > d msg.%Save()
HICG > w msg.DocType
2.5.1:ADT_A01
HICG >

Unfortunately there's no easy way to "reset" the source document type in the DTL editor dynamically. You could, however, dynamically set the document type in either a BPL or COS business process and then invoke the appropriate DTL for translation.

@Tony Alexander, @Jeffrey Drumm 
I came across your replies here and wanted to confirm I am having the same issue, but I am using the DTL editor and not so much code.  My base ADT is version 2.3.1 and I am transforming to 2.4.  In the DTL it seems that's there's no problem bridging the two messages, however, when the message is ultimately routed out of Ensemble, the message body says the DocType is 2.3.1 but the TypeVersion is 2.4, but also the DocTypeCategory is 2.3.1.  I suppose I would expect that after the transformation the message body would reflect the correct metadata but maybe I misundersand what it's supposed to represent in the context of the whole process?

In the DTL, I select "existing" as the Create action thinking that this will overwrite the data on the base object.

Would be interested in your understanding of all of this.

DocTypeCategory and DocTypeName are populated based on the contents of DocType. The DocType property can be changed even though the message is immutable.

TypeVersion is populated based on the value of the MSH:12 field in the message body. If you're attempting to modify the properties of an inbound message received from a business service, I don't think you'll be able to change TypeVersion with "Existing" set in the DTL editor because you can't modify MSH:12.

Are you working with messages newly arrived through a service that haven't undergone any prior transformations?