Menu

#46 OBX-5 type assignment only operates on first rep

closed-fixed
None
5
2012-04-13
2005-09-07
Bryan Tripp
No

From David Ellis:

Bryan,

Our software development group (VA CHDR project) has
found what appears
to be a bug in the HAPI parser.

The method Varies.fixOBX5() sets the correct datatype
of only the first
repetition of the OBX.5 field in an OBX segment. When
there is more
than one repetition, the datatype ends up as
UNKNOWN for all repetitions
after the first, and this makes its way into the element
tags of the XML
encoding.

As an example, an OBX segment with two repetitions of
OBX.5 that should
parse into an XML encoding like:

<OBX>
<OBX.1>1</OBX.1>
<OBX.2>CE</OBX.2>
...
<OBX.5>
<CE.1>foo</CE.1>
<CE.2>fooText</CE.2>
...
</OBX.5>
<OBX.5>
<CE.1>bar</CE.1>
<CE.2>barText</CE.2>
...
</OBX.5>
...
</OBX>

ends up with the erroneous encoding:

<OBX>
<OBX.1>1</OBX.1>
<OBX.2>CE</OBX.2>
...
<OBX.5>
<CE.1>foo</CE.1>
<CE.2>fooText</CE.2>
...
</OBX.5>
<OBX.5>
<UNKNOWN.1>bar</UNKNOWN.1>
<UNKNOWN.2>barText</UNKNOWN.2>
...
</OBX.5>
...
</OBX>

The corrected code in Varies.fixOBX5() is below.

Thanks for your attention!

/ David /

--------------------- original code ------------------------

Varies v = (Varies) segment.getField(5, 0); //
gets only the
first repetition

if (obx2.getValue() == null) {
...
}
else {
//set class
Class c =
ca.uhn.hl7v2.parser.Parser.findClass(obx2.getValue(),

segment.getMessage().getVersion(),
"datatype");
v.setData((Type) c.newInstance());
}

------------------- corrected code ----------------------------

Type [] va = segment.getField(5); // get all OBX.5
repetitions into an array
Varies v;
for (int i = 0; i < va.length; i++) { // loop over all
the
repetitions
v = (Varies) va[i];

if (obx2.getValue() == null) {
...
}
else {
//set class
Class c =
ca.uhn.hl7v2.parser.Parser.findClass(obx2.getValue(),

segment.getMessage().getVersion(),
"datatype");
v.setData((Type) c.newInstance());
}

}

Discussion

  • James Agnew

    James Agnew - 2006-12-12

    Logged In: YES
    user_id=881509
    Originator: NO

    This has been fixed. I will test it an add it to the next release.

    Thanks for the report!

     
  • James Agnew

    James Agnew - 2006-12-12
    • assigned_to: nobody --> jamesagnew
     
  • Christian Ohr

    Christian Ohr - 2012-04-13
    • status: open --> closed-fixed
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.