<< Click to Display Table of Contents >> Navigation: Designing Templates > Template HTML > HL7 Tag Shorthand > The ##HL7## Tag > Consolidation and Compression |
This section is about working with embedded text reports in HL7 messages. Specifically, this section details how you can COMPRESS the display value of an embedded text report by removing extraneous empty lines if you desire.
Whether it is a text report embedded in the OBX segment(s) field #5 or a NTE segment, or other possibly transcription related segments. This section deals ONLY with TEXT reports. For working with other types of embedded objects (PDF, Images, Word Docs, etc) see Embedded Binary Data.
Embedded text reports are very "old" in HL7 time. They've been around almost since the very beginning and are (and have always been) woefully under documented. Here we will give our tutorial based on many years working with customers in this area.
Embedded text reports come in 2 "flavors", SINGLE segment and MULTI segment. These days the most (slightly most) common method of embedding a text report into a HL7 message is to use the SINGLE segment method which uses 1 HL7 field to contain the report (see example below).
In the SINGLE segment method the ENTIRE text report is placed into 1 field and it uses EITHER the Repeat delimiter ( ~ ) or the HL7 "Escaped" value ( \.br\ ) to represent the line feeds. The 2 examples below should produce IDENTICAL output.
Example 1: OBX|1|TX|||When he was nearly thirteen,~my brother Jem got his arm~~~~badly broken at the elbow.|
Example 2 (uses HL7 Escape Rules): OBX|1|TX|||When he was nearly thirteen,/.br/my brother Jem got his arm/.br//.br//.br//.br/badly broken at the elbow.|
Output value: When he was nearly thirteen, my brother Jem got his arm
badly broken at the elbow.
NOTE: The empty lines placed in the report by the report creator.
|
Also in very common use is the oldest method of embedding text reports, the MULTI segment method which creates multiple repeating segments and every segment contains a "line" in the report (see example below)
In the MULTI segment method the embedded text report is placed into multiple repeating segments and it is the responsibility of the interpreting system to CONSOLIDATE all of the repeating segment field values (with a line-feed between) to produce the output. In the example below the text report is in field #5 of the OBX segment.
ORC|RE|1095|56785||||^^30^20150617090900..........| OBR|1|15510|3976285|NA^To Kill a Mockingbird|||20150617102414........| OBX|1|TX|||When he was nearly thirteen, my brother Jem got his arm badly broken at the| OBX|2|TX|||elbow. When it healed, and Jem's fears of never being able to play football were| OBX|3|TX|||assuaged, he was seldom self-conscious about his injury. His left arm was| OBX|4|TX|||somewhat shorter than his right; when he stood or walked, the back of his hand| OBX|5|TX|||was at right angles to his body, his thumb parallel to his thigh. He couldn't have| OBX|6|TX|||cared less, so long as he could pass and punt.| OBX|8|TX| OBX|9|TX| OBX|10|TX| OBX|11|TX|||When enough years had gone by to enable us to look back on them, we| OBX|12|TX|||sometimes discussed the events leading to his accident. I maintain that the Ewells| OBX|13|TX|||started it all, but Jem, who was four years my senior, said it started long before| OBX|14|TX|||that. He said it began the summer Dill came to us, when Dill first gave us the idea| OBX|15|TX|||of making Boo Radley come out.| OBX|16|TX| OBX|17|TX| OBX|18|TX| OBX|19|TX|||I said if he wanted to take a broad view of the thing, it really began with Andrew| OBX|20|TX|||Jackson. If General Jackson hadn't run the Creeks up the creek, Simon Finch| OBX|21|TX|||would never have paddled up the Alabama, and where would we be if he hadn't?| OBX|22|TX| OBX|23|TX| OBX|24|TX| OBX|25|TX|||We were far too old to settle an argument with a fist-fight, so we consulted| OBX|26|TX|||Atticus. Our father said we were both right.| OBX|27|TX| OBX|28|TX| OBX|29|TX|
NOTE that the report creator is using 3 blank lines between each "paragraph".
|
In your HL7 templates you work with embedded text reports using the TEXTREPORT1 and TEXTREPORT2 Tag Attributes. Our end goal is to COMPRESS the embedded text report, but before we can do that we have to address CONSOLIDATION which ONLY applies to HL7 messages which use the MULTI segment method of embedding text reports (see example above). If your messages only use the SINGLE segment method you can jump straight to COMPRESSION.
Consolidation works by combining the values of all of the repeating segments which make up your embedded report into ONE html container. Of the 2 tag attributes we recommend using TEXTREPORT2 if your messages use (or you are unsure) the MULTI segment method. Consider the Template HTML snippet below:
<-- This is a VERY simple example. Real templates will likely be much more complex -->
$$HL7SECTION segment="OBR" childsegments="OBX"$$
$$HL7SECTION segment="OBX" childsegments="NTE"$$
<p style="font-family:courier;font-size:9pt;">##HL7.OBX.5.0.TextReport2##</p>
$$ENDSECTION$$ <!-- End Section OBX -->
$$ENDSECTION$$ <!-- End Section OBR -->
The snippet above establishes a "loop" (HL7Section Tag) when a OBR segment is encountered in the message with allowable child segments of OBX. Inside of that it establishes another "loop" on the OBX section with allowable child segments of NTE.
IF the HL7 looked like this:
OBX|1|TX|||When he was nearly thirteen, my brother Jem got his arm badly broken at the|
OBX|2|TX|||elbow. When it healed, and Jem's fears of never being able to play football were|
OBX|3|TX|||assuaged, he was seldom self-conscious about his injury. His left arm was|
OBX|4|TX|||somewhat shorter than his right; when he stood or walked, the back of his hand|
OBX|5|TX|||was at right angles to his body, his thumb parallel to his thigh. He couldn't have|
OBX|6|TX|||cared less, so long as he could pass and punt.|
OBX|7|TX|
OBX|8|TX|
OBX|9|TX|
The resulting final rendered HTML would look like this:
<p style="font-family:courier;font-size:9pt;">When he was nearly thirteen, my brother Jem got his arm badly broken at the</p>
<p style="font-family:courier;font-size:9pt;">elbow. When it healed, and Jem's fears of never being able to play football were</p>
<p style="font-family:courier;font-size:9pt;">assuaged, he was seldom self-conscious about his injury. His left arm was</p>
<p style="font-family:courier;font-size:9pt;">somewhat shorter than his right; when he stood or walked, the back of his hand</p>
<p style="font-family:courier;font-size:9pt;">was at right angles to his body, his thumb parallel to his thigh. He couldn't have</p>
<p style="font-family:courier;font-size:9pt;">cared less, so long as he could pass and punt.</p>
<p style="font-family:courier;font-size:9pt;"></p>
<p style="font-family:courier;font-size:9pt;"></p>
<p style="font-family:courier;font-size:9pt;"></p>
It looks like this because each OBX segment in the HL7 section is evaluated individually. What we need to do BEFORE we can achieve COMPRESSION is to preprocess the HTML and CONSOLIDATE all of the OBX segments into 1 container. To achieve this you use the consolidate attribute in our container like so.
$$HL7SECTION segment="OBR" childsegments="OBX"$$
$$HL7SECTION segment="OBX" childsegments="NTE"$$
<p consolidate="1" style="font-family:courier;font-size:9pt;">##HL7.OBX.5.0.TextReport2##</p>
$$ENDSECTION$$ <!-- End Section OBX -->
$$ENDSECTION$$ <!-- End Section OBR -->
You add the consolidate attribute AND give it a value (any value, in the example we give it a value of "1")When processing the Template parser will then consolidate all of the XML InnerText of the container and produce ONE consolidated container and then removes the consolidate attribute so the rendered HTML would look more like this:
<p style="font-family:courier;font-size:9pt;">
When he was nearly thirteen, my brother Jem got his arm badly broken at the<br />
elbow. When it healed, and Jem's fears of never being able to play football were<br />
assuaged, he was seldom self-conscious about his injury. His left arm was<br />
somewhat shorter than his right; when he stood or walked, the back of his hand<br />
was at right angles to his body, his thumb parallel to his thigh. He couldn't have<br />
cared less, so long as he could pass and punt.<br /><br /><br /><br />
</p>
IMPORTANT: In order for this to work correctly the consolidate attribute MUST be on whatever container contains the TEXTREPORT2 Tag Attribute and the TEXTREPORT2 tag must be the ONLY InnerText for that container. Example:
This is good:
$$HL7SECTION segment="OBR" childsegments="OBX"$$
$$HL7SECTION segment="OBX" childsegments="NTE"$$
<p consolidate="1" style="font-family:courier;font-size:9pt;">##HL7.OBX.5.0.TextReport2##</p>
$$ENDSECTION$$ <!-- End Section OBX -->
$$ENDSECTION$$ <!-- End Section OBR -->
This is bad:
$$HL7SECTION segment="OBR" childsegments="OBX"$$
$$HL7SECTION segment="OBX" childsegments="NTE"$$
<p consolidate="1" style="font-family:courier;">
<span style="font-size:9pt;" >##HL7.OBX.5.0.TextReport2##</span>
</p>
$$ENDSECTION$$ <!-- End Section OBX -->
$$ENDSECTION$$ <!-- End Section OBR -->
This is good:
<p style="font-family:courier;">
$$HL7SECTION segment="OBR" childsegments="OBX"$$
$$HL7SECTION segment="OBX" childsegments="NTE"$$
<span consolidate="1" style="font-size:9pt;" >##HL7.OBX.5.0.TextReport2##</span>
$$ENDSECTION$$ <!-- End Section OBX -->
$$ENDSECTION$$ <!-- End Section OBR -->
</p>
When you implement COMPRESSION you should keep a couple of things in mind.
1.If your HL7 message with the embedded text report uses the MULTI segment method you MUST implement CONSOLIDATION for it to work properly.
2.You should always remain keenly aware that IF you implement COMPRESSION you are in fact altering the way that whomever created the embedded text report actually intended that it be displayed to the user.
It's because of #2 above that we keep your options for compression very limited. To implement compression you add a couple of attributes to the HTML container which contains your TEXTREPORT1 or TEXTREPORT2 tag attribute like so:
<p style="font-family:courier;">
$$HL7SECTION segment="OBR" childsegments="OBX"$$
$$HL7SECTION segment="OBX" childsegments="NTE"$$
<span consolidate="1" hl7compressed="true" hl7compressto="1" style="font-size:9pt;" >##HL7.OBX.5.0.TextReport2##</span>
$$ENDSECTION$$ <!-- End Section OBX -->
$$ENDSECTION$$ <!-- End Section OBR -->
</p>
hl7compressed is mandatory and the value must be "true".
hl7compressto is optional and instructs the parser how many sequential blank lines to allow in the report. The value must be either "1" or "2". If the attribute is omitted it will default to "2". If the value entered is < 1 it will default to "1" if the value is > 2 it will default to "2". If a Non-Numeric value is entered Compression will fail.
If the value is 1 then when compressing the embedded report the parser will allow a maximum of ONE sequential BLANK line. If 2 it will allow up to 2 sequential BLANK lines.
HL7 Example:
OBX|1|TX|||When he was nearly thirteen,~my brother Jem got his arm~~~~badly broken at the elbow.|
Output value (no compression):
When he was nearly thirteen,
my brother Jem got his arm
badly broken at the elbow.
Output value (hl7compressto="1"):
When he was nearly thirteen,
my brother Jem got his arm
badly broken at the elbow.
Output value (hl7compressto="2"):
When he was nearly thirteen,
my brother Jem got his arm
badly broken at the elbow.
See Also: Tag Attribute Reference, HL7Sections