Creating multiple Record Map Records from a single HL7 message

So I have an interesting problem. I am going to be using a process and rule to determine if an HL7 message qualifies to be sent out, then using a record map to write certain aspects of that HL7 message to disk (with an HL7 to record map DTL). This is simple enough but the recipient of this file is requiring a single record map entry per DG1 segment in the HL7 message.

 

For instance if said HL7 message for PATIENT^TEST  has 3 DG1 segments, I would need to write three lines (or records) like so:

123^^^^MR|TEST|PATIENT|DG1(1) TEXT|DG1(1) CODE|DG1(1) DATE

123^^^^MR|TEST|PATIENT|DG1(2) TEXT|DG1(2) CODE|DG1(2) DATE

123^^^^MR|TEST|PATIENT|DG1(3) TEXT|DG1(3) CODE|DG1(3) DATE

 

 

Is there a way to do this? I know I can make repeating fields in the record map and can loop over repeating fields/segments in a DTL but I am not sure how to write multiple lines using one incoming message

  • 0
  • 1
  • 97
  • 7
  • 1

Answers

The usual way of accomplishing this is to combine a DTL with a BPL. The BPL is responsible for calling the DTL and sending a record map message for each DG1 segment in the source message.

The DTL rules would look something like this:

The Main BPL structure would first get the number of DG1 segments in the message and <assign> it to a context variable (ex. context.DG1cnt), check to see if any are present, and if yes loop over them. The top-level BPL might resemble this:

The <while> block would create the record using data from the non-repeating portion of the HL7 message and the current DG1 segment, increment the segment counter, and send the record to the outbound operation:

If you haven't worked with BPLs before, you might want to take a look at the self-paced, on-line course.

Comments

@Jeff Drumm Thanks for your response. I would love to walk through that course but I get a 404 when I try to start it. I will let someone at InterSystems know

Very strange. I just tried the link and it works for me.

So I got into and did the course. I wish it was more HL7 oriented. I wondered if maybe you could confirm a few things for me if possible.

If I am accepting an HL7 message (request) and want to send to a RecordMapBatch operation is it correct that in my context the request class would be 'EnsLib.HL7.Message' and response class be 'EnsLib.RecordMap.BatchResponse'?

Secondly I am used to using the HL7.{SEG:FIELD} notation when building rules. Is this possible within a BPL?

How would you build the ASSIGN to set the DG1 count context variable?

Thank You,

G

Yes, it makes sense to set the request class to EnsLib.HL7.Message. However, the response class as Ens.Response is fine since you don't need to create anything to send back to the source business service. Here's a sample Context configuration for the BPL:

To get the segment count for the DG1s, you'd use the GetValueAt() method of the EnsLib.HL7.Message class, and assign it to a context variable. For this you would use the same notation as you would use in the DTL editor to get the segment count:

In COS, a non-zero value is treated as true, so you can use the variable to which you've assigned the count of DG1 segments as the condition for the <if>:

Finally, the context.DG1rec variable from the BPL's Context tab screenshot above was assigned to the record map class used to define the delimited structure. This variable is later used as the Target for the DTL and the value to which the <call> activity's callrequest was set.

I used the same record map class in the Business Operation (BO defined as class type EnsLib.RecordMap.Operation.FileOperation) for the RecordMap field:

This BO will roll over to a new file at midnight each night.

Thank you so much. This clears everything up. I really appreciate it

I hate to bother you again but I am so close and have 2 more questions. In the <transform> action, I have my DTL set up with the source as the HL7 schema and the target as the Record Map class that I have built. In the activity is that also what goes here:

Second question. I have the <call> activity set up to send to the RecordMap file Operation on the production but am having trouble understanding how to build that request. I am guessing that request message class should be my Record Map class but when I go to "build request" the source seems to be HL7 message header fields. It should just be a direct passthrough now?

I actually gave  you half of the answer in my previous comment, but it was easy to miss ... laugh

The Target variable of the DTL will contain the value to which you'll set the callrequest property of the <call> activity:

EDIT: You don't really need to use the request builder for this. Just click on the "+" after Request Actions,  select "set", then select the property and value from their respective drop-down lists.