Registry Mirror
Skip to content

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

Closed

Description

@AlexFJaxFL

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

Activity

  1. darrenfurr commented on Nov 9, 2016

    @darrenfurr

    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

  2. ChrisMeeusen commented on Apr 4, 2019

    @ChrisMeeusen

    Seems like this is still a problem in version 2.5.0.6

  3. milkshakeuk commented on Apr 12, 2021

    @milkshakeuk
    Member

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

  4. AlexFJaxFL commented on Apr 12, 2021

    @AlexFJaxFL
    Author

    it is both

  5. milkshakeuk commented on Apr 12, 2021

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

  6. AlexFJaxFL commented on Apr 12, 2021

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions