You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
OBX-5 is valued, but OBX-2 is not. A datatype for OBX-5 must be specified using OBX-2. #63
it appears that HAPI has a valid solution for this exception
The HAPI Parser may be configured using a ParserConfiguration object.
The ParserConfiguration is a bean which sets and retrieves parser configuration properties and may be shared among multiple parser instances.
Default behaviour for OBX-2
In a normal OBX (Observation) segment, OBX-2 provides the datatype to be applied to OBX-5. So, for instance if an OBX repetition was conveying a timestamp (TS), it might look like:
OBX||TS|||200901011259
If the OBX-2 value is missing (which sometimes happens because of a misbehaving sending system), you may see an error such as "OBX-5 is valued, but OBX-2 is not. A datatype for OBX-5 must be specified using OBX-2".
In this case, you may specify that HAPI should use a default type when none is found by specifying a default OBX-2 type:
parser.getParserConfiguration().setDefaultObx2Type("ST");
ORU_R01 parsedMessage = (ORU_R01)parser.parse(someInvalidMessage);
If the OBX-2 value is invalid, meaning that it has a value but that value is not a valid HL7 datatype (e.g. "String" instead of "ST"), you may specify a default type to assume if the OBX-2 value can not be understood.
parser.getParserConfiguration().setInvalidObx2Type("ST");
ORU_R01 parsedMessage = (ORU_R01)parser.parse(someInvalidMessage);
See the JavaDoc for examples.
I checked the Parser source code & there is a fixOBX5 method in the Varies.cs that appears to attempt to set the data type, however it is not working because the v.Data.Value != null, but the OBX-2 is.
if (!(v.Data is IPrimitive) || ((IPrimitive)v.Data).Value != null)
{
throw new HL7Exception("OBX-5 is valued, but OBX-2 is not. A datatype for OBX-5 must be specified using OBX-2.", HL7Exception.REQUIRED_FIELD_MISSING);
}
In my case, my messageType had no OBX-2:
OBX|14||Mro||MRSA
With this code change -
if (!(v.Data is IPrimitive))
{
throw new HL7Exception("OBX-5 is valued, but OBX-2 is not. A datatype for OBX-5 must be specified using OBX-2.", HL7Exception.REQUIRED_FIELD_MISSING);`
}
else if (((IPrimitive)v.Data).Value != null)
{
//default datatype to ST = String
Type c = factory.GetTypeClass("ST", segment.Message.Version);
v.Data = (IType)c.GetConstructor(new System.Type[] { typeof(IMessage) }).Invoke(new System.Object[] { v.Message });
}
It now pulls the value as String:
If this is approved by @duaneedwards - I'll create a pull request.
-Darren
@AlexFJaxFL I understand the wish for to be able to configure the default type if OBX-2 is empty so ill add the enhancement label but not sure what the defect is.
Activity
darrenfurr commentedon Nov 9, 2016
I checked the Parser source code & there is a fixOBX5 method in the Varies.cs that appears to attempt to set the data type, however it is not working because the v.Data.Value != null, but the OBX-2 is.
In my case, my messageType had no OBX-2:
OBX|14||Mro||MRSA
With this code change -
It now pulls the value as String:

If this is approved by @duaneedwards - I'll create a pull request.
-Darren
Parsing fixes for Message v2.1 OBX and ORU
ChrisMeeusen commentedon Apr 4, 2019
Seems like this is still a problem in version 2.5.0.6
milkshakeuk commentedon Apr 12, 2021
@AlexFJaxFL is this a feature request / enhancement to allow configuration or a defect with the current behaviour?
AlexFJaxFL commentedon Apr 12, 2021
it is both
milkshakeuk commentedon Apr 12, 2021
@AlexFJaxFL I understand the wish for to be able to configure the default type if
OBX-2is empty so ill add theenhancementlabel but not sure what the defect is.AlexFJaxFL commentedon Apr 12, 2021
agree, no defect here, my previous statement was incorrect