jueves, 8 de marzo de 2012

HL7 with HAPI: OBX-5 is valued, but OBX-2 is not

Exception: ca.uhn.hl7v2.HL7Exception: OBX-5 is valued, but OBX-2 is not.  A datatype for OBX-5 must be specified using OBX-2. See JavaDoc for Varies#fixOBX5(Segment, ModelClassFactory)

Look at the HL7 message you're trying to parse. OBX-2 makes reference to the second field (you have to count the "first" "OBX" field as 0). OBX-5 makes reference to the fifth field.

OBX||[OBX-2_FIELD]|PESO||[OBX-5_FIELD]

The specification says that the data type for the OBX-5 value is variable and not known until run time. For that reason, that data type is specified in the OBX-2 value. In conclusion, if you set a value in the OBX-5 field, you must specify its data type in the OBX-2 field. For example, the following OBX line is wrong:

OBX|1||PESO||0

But the following is OK:

OBX|1|NM|PESO||0

If you want to bypass this kind of cases, the HAPI API provides some system properties that let you specify a default value for OBX-2 in case it is empty or with a wrong value:

System.setProperty(Varies.INVALID_OBX2_TYPE_PROP, "ST");

and

System.setProperty(Varies.DEFAULT_OBX2_TYPE_PROP, "ST");

Reference: http://hl7api.sourceforge.net/xref/ca/uhn/hl7v2/examples/ParseInvalidObx2Values.html





No hay comentarios: