Character Streams within HL7 message

171 views
Skip to first unread message

Steve Roselius

unread,
Jun 17, 2010, 10:13:38 AM6/17/10
to InterSystems: Ensemble in Healthcare
There are two methods capable of manipulating stream data that is part
of an HL7 message (for example, an OBX Observation).
EnsLib.HL7.Segment.ReadRawDataStream() and
EnsLib.HL7.Segment.StoreRawDataStream().

Has anybody used these methods before, or have a sample of how you can
use these within a data transformation/subtransform? I have a message
with a very large observation text, and the only workaround I can
envision is splitting this segment into multiple (text property)
segments; doing the transformations that I need; then knitting the
individual segments back together again. Obviously if there is a
shortcut available with these methods I'd like to use them!

Thanks in advance
Steve

Liang (Simon) Sha

unread,
Jun 17, 2010, 10:42:31 AM6/17/10
to ensemble-in...@googlegroups.com
Steve,

I have some transformation code that accumulates many source OBX segments into one stream and write the stream (>32k) to one target OBX. Just the opposite of what you want to do though:

<code>
<![CDATA[
// (1) instantiate a stream variable
set tStream=##class(%GlobalCharacterStream).%New()
// (2) build the first components of the segment
set tSC = tStream.Write("OBX|1|TX|||")
]]

<foreach property='source.{PIDgrpgrp(1).ORCgrp(1).OBXgrp()}' key='k1'>
<assign property='tempOBX05' value='source.{PIDgrpgrp(1).ORCgrp(1).OBXgrp(k1).OBX:5}' action='set'/>
<code>
<![CDATA[
// (3) accumulate value into the tstream
set tSC = tStream.Write("~"_tempOBX05)
]]>
</code>
</foreach>

<code>
<![CDATA[
//(4) create an OBX segment
set tSegment= ##class(EnsLib.HL7.Segment).%New()
set tSegment.SegType = "2.1:OBX"

//(5) put the stream into the segment
set tSC= tSegment.StoreRawDataStream(tStream)

//(6) put the segment into the target HL7 message
set tSC= target.setSegmentByPath(tSegment,"PIDgrpgrp(1).ORCgrp(1).OBXgrp(1).OBX")

]]>
</code>

Thanks in advance
Steve

--
You received this message because you are subscribed to the Google Groups "InterSystems: Ensemble in Healthcare Community" group.
To post to this group, send email to Ensemble-in...@googlegroups.com
To unsubscribe from this group, send email to Ensemble-in-Healt...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/Ensemble-in-Healthcare?hl=en

Steve Roselius

unread,
Jun 19, 2010, 1:54:08 PM6/19/10
to InterSystems: Ensemble in Healthcare
Simon,

Thanks very much, this is helpful.

I have been trying to use this approach, but I'm getting an error. Is
this a bug, or developer's blunder?

Here is my DTL code. You'll notice it doesn't really do anything:

<?xml version="1.0" ?>
<transform targetClass='EnsLib.HL7.Message'
targetDocType='2.1:ORU_R01' sourceClass='EnsLib.HL7.Message'
sourceDocType='2.1:ORU_R01' create='copy' language='objectscript'>
<code>
<![CDATA[
s tStream=##class(%GlobalCharacterStream).%New()
s tSegment=##class(EnsLib.HL7.Segment).%New()
s tSegment.SegType="2.1:OBX"
]]>
</code>
<foreach property='source.{PIDgrpgrp()}' key='k1'>
<foreach property='source.{PIDgrpgrp(k1).ORCgrp()}' key='k2'>
<foreach property='source.{PIDgrpgrp(k1).ORCgrp(k2).OBXgrp()}'
key='k3'>
<assign property='tSegOBX' value='source.
{PIDgrpgrp(k1).ORCgrp(k2).OBXgrp(k3).OBX}' action='set'/>
<code>
<![CDATA[
s tStream=tSegment.ReadRawDataStream(.tSegOBX)
]]>
</code>
</foreach>
</foreach>
</foreach>
</transform>

And here is the error message I get when I try to run it:

ERROR <Ens>ErrException: <CLASS TOO BIG TO LOAD>zReadRawDataStream
+1^EnsLib.HL7.Segment.1 -- logged as '19 Jun 2010' number 5 @'
Set:'($Data(pStream)#2&&IsObject(pStream)) pStream=
$zobjclassmethod($S(""=$G (pStream):pStream,
1:"%Library.GlobalCharacterStream"),"%New")'

Ensemble 2010.2 b317 Windows-64 bit.

On Jun 17, 7:42 am, "Liang (Simon) Sha" <simon....@intersystems.com>
wrote:
> For more options, visit this group athttp://groups.google.com/group/Ensemble-in-Healthcare?hl=en- Hide quoted text -
>
> - Show quoted text -

Liang (Simon) Sha

unread,
Jun 19, 2010, 5:05:52 PM6/19/10
to ensemble-in...@googlegroups.com
Steven, attached are some sample code and messages to merge and split ORU messages with OBX > 32K using these methods. They work fine on 2009.1. Note that you will have to use syntax like ReadRawDataContent(.tStream, "field number in the segment, e.g. 5")

If it doesn't work on versions other than 2009.1 please let me know.

HTH

ToMerge.TXT
ToSplit.txt
OBX split merge DTL.xml
Reply all
Reply to author
Forward
0 new messages