Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OBX-5 is valued, but OBX-2 is not. A datatype for OBX-5 must be specified using OBX-2. #63

Closed
AlexFJaxFL opened this issue Oct 20, 2016 · 6 comments · Fixed by #250
Closed

Comments

@AlexFJaxFL
Copy link

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.

but can this be done in nHAPI ?

Regards,
-Alex

@darrenfurr
Copy link

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:
image

If this is approved by @duaneedwards - I'll create a pull request.
-Darren

vyfster pushed a commit to vyfster/nHapi that referenced this issue Apr 4, 2019
 - This small patch fixes errors thrown in nHapiNET#63 as well as nHapiNET#84 Applying these fixes as per inbound HIE data found in a real use case.
 - taken from nHapiNET#108
@ChrisMeeusen
Copy link

Seems like this is still a problem in version 2.5.0.6

@milkshakeuk
Copy link
Member

@AlexFJaxFL is this a feature request / enhancement to allow configuration or a defect with the current behaviour?

@AlexFJaxFL
Copy link
Author

it is both

@milkshakeuk
Copy link
Member

@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.

@AlexFJaxFL
Copy link
Author

agree, no defect here, my previous statement was incorrect

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants