Does GetValueAt on an HL7 message have side-effects?
Does the GetValueAt method of an EnsLib.HL7.message object change the contents of the HL7 message?
We want to do two things, given an incoming HL7 message, in our production:
- transform the HL7 to XML, where the class TNHS.Utils.HL7toXML provides the same methods as, for example, EnsLib.HL7.Util.FormatSimpleXMLv2:
set sc = message.OutputToLibraryStream(xmlstream,"","","TNHS.Utils.HL7toXML")
ObjectScriptObjectScript - extract a value from a particular field in the message:
Set ReportId = message.GetValueAt("PIDgrpgrp(1).ORCgrp(1).ORC:3.1")
ObjectScriptObjectScript
If we sequence these as (1) generate XML, (2) extract value using GetValueAt, it works. If we do them in the other order the XML generation fails - produces bad XML (unbalanced elements - no '<PIDgrpgrp>' but lots of '</PIDgrpgrp>' elements). Which suggests that GetValueAt is changing the contents of the HL7 message in some way. Is this right, or is something else going on?
Product version: Caché 2018.1
$ZV: Cache for Windows (x86-64) 2018.1 (Build 184U) Wed Sep 19 2018 09:09:22 EDT
Follow-up, as a quick and dirty check, I replaced the call to GetValueAt above with:
set step1 = $PIECE(message.RawContent,"OBR|") set step2 = $PIECE(part1, "ORC|", *) set ReportId = $PIECE(part2, "|", 3, 3)
This works before calling the XML generation code when GetValueAt doesn't - so GetValueAt is definitely doing something to the contents of the HL7 message....
Follow-up/solution: we can do:
set message2 = message.%ConstructClone(1)
and then use message for the XML generation and message2 for calls to GetValueAt, and that works OK.
Still don't know why GetValueAt appears to change the content of the message...
I'm guessing you're running into this limitation "The ObjectScript method used by DTL transformations, GetValueAt, truncates HL7 segment fields at 3.6MB."
Docs cover how to work around this.
https://docs.intersystems.com/irisforhealth20233/csp/docbook/DocBook.UI.Page.cls?KEY=EHL72_transformation#EHL72_transformation_longsegments