Registry Mirror
Skip to content

HL7 Exception when parsing ORM_O01 message  #133

Closed

Description

@devshangari

HL7 Message:
MSH|^~\&|A|B1|C|C|20201208134545||ORM^O01|Q3255132777T3949289903||2.3||||||8859/1 PID|1||0123456789||PATIENT01^TEST||19700101|M||ASA|1234 Here Street^^Spokane^WA^99202||(509) 555-1212^^^jdoe@paml.com| PV1|1||^^^DrSmith^^^Building1^^Description||||||||||||||||||||||||||||||||||||654321| IN1|1|PLANID|INSCOMPANYID|Insurance Company, Inc.|123 Ins Way^^Spokane^WA^99202|||GROUP1234|||Worldwide Widgets||20141001|||PATIENT01^TEST|SEL^Self^HL70063|19700101|1234 Here Street^^Spokane^WA^99202||||||||||||S|||||POLICY1234 GT1|1||PATIENT01^TEST||1234 Here Street^^Spokane^WA^99202||||||||||||||||Guarantor Organization Name ORC|NW|123456|||||||20130607103421||||I123O OBR|1|123456||80100.DA33^DAT Apolipoprotein A|R||201307220009|0||||||||1234567890|||C| NTE|1||Order Note DG1|1||700^Diagnosis Description^I9C|||F|||||||||1 OBX|1|ST|99199.Z56^Specimen Source||AOE Value|Units|||||F OBX|2|ID|I have confirmed the Patient, Procedure^I have confirmed the Patient, Procedure||Y OBX|3|IS|COVID-19 Status^COVID-19 Status||COVID-19 - Not Suspected

Error:
Result StackTrace:
at NHapi.Base.Model.Varies.fixOBX5(ISegment segment, IModelClassFactory factory) in E:\nHapi\src\nHapi.Base\Model\Varies.cs:line 178
at NHapi.Base.Parser.PipeParser.Parse(ISegment destination, String segment, EncodingCharacters encodingChars) in E:\nHapi\src\nHapi.Base\Parser\PipeParser.cs:line 389
at NHapi.Base.Parser.PipeParser.DoParse(String message, String version) in E:\nHapi\src\nHapi.Base\Parser\PipeParser.cs:line 313
at NHapi.Base.Parser.ParserBase.Parse(String message, String version) in E:\nHapi\src\nHapi.Base\Parser\ParserBase.cs:line 148
at NHapi.Base.Parser.ParserBase.Parse(String message) in E:\nHapi\src\nHapi.Base\Parser\ParserBase.cs:line 129
at NHapi.NUnit.ParserTestOrm.TestSpecialCharacterEncoding() in E:\nHapi\tests\NHapi.NUnit\ParserTestOrm.cs:line 34
--NullReferenceException
at NHapi.Base.Model.Varies.fixOBX5(ISegment segment, IModelClassFactory factory) in E:\nHapi\src\nHapi.Base\Model\Varies.cs:line 168
Result Message:
NHapi.Base.HL7Exception : System.NullReferenceException trying to set data type of OBX-5
----> System.NullReferenceException : Object reference not set to an instance of an object.

Looks to be a bug in the source code generation for OBX segments with data type ID or IS

Activity

  1. milkshakeuk commented on Jan 23, 2021

    @milkshakeuk
    Member

    @devshangar I wonder if this is a duplicate of #62?

    I'll see if I can have a look over the weekend.

  2. added
    bug
    on Jan 23, 2021
  3. milkshakeuk commented on Jan 23, 2021

    @milkshakeuk
    Member

    Okay, yes seems like an issue. but looks more like a bug with the parser when it tries to construct the ID (OBX-2) using the wrong constructor arguments.

    v.Data = (IType) c.GetConstructor(new [] {typeof (IMessage), typeof(String)}).Invoke(new Object[] {v.Message, v.Description});

    I wonder what hapi does in this scenario. I'll see if I can look more into this over the weekend.

  4. self-assigned this
    on Jan 23, 2021
  5. milkshakeuk commented on Jan 23, 2021

    @milkshakeuk
    Member

    Ok I figured it out, all the ID data types for each hl7 version inherit from abstract class NHapi.Base.Model.Primitive.ID this class has the required constructors needed however public constructors on an abstract class get converted to protected at build time since you can't have public constructors on abstract classes.

    Unless public constructors are added to the derived ID datatype classed which then call down to the base constructors it will always below up because of the reflection used here cant find a constructor with the correct arguments.

    So yes actually an issue with source the code generation.

  6. milkshakeuk commented on Jan 23, 2021

    @milkshakeuk
    Member

    I managed to fix it locally for ID datatypes but adding the required constructors but it then failed on another datatype IS, seems more time will need to be spent on this.

    We currently can't rerun the source generator until we obtain the HL7 Normative database, but we can update the output.
    It might take me a few weeks to ensure I have captured all the data types with this constructor issue.

  7. milkshakeuk commented on Jan 23, 2021

    @milkshakeuk
    Member

    Looking at the source code generation IS, ID, DT, DTM and TM datatypes are coded manually i.e. not source code generated.

    if (dataType.Equals("FT") || dataType.Equals("ST") || dataType.Equals("TX") || dataType.Equals("NM") ||
        dataType.Equals("SI") || dataType.Equals("TN") || dataType.Equals("GTS"))
    {
    	source = makePrimitive(dataType, description, version);
    }
    else
    {
    	source = null; //note: IS, ID, DT, DTM, and TM are coded manually
    }

    So at least now I know which ones are most likely affected.

  8. devshangari commented on Jan 24, 2021

    @devshangari
    Author

    Thanks for looking into this @milkshakeuk

  9. added this to the v3.0.0.0 milestone on Jan 25, 2021
  10. milkshakeuk commented on Jan 27, 2021

    @milkshakeuk
    Member

    @devshangari I have made lots of progress on this, just adding unit tests and should have a PR up by the weekend at the latest.

  11. milkshakeuk commented on Jan 29, 2021

    @milkshakeuk
    Member

    @devshangari ok I have a PR up for this #136 hopefully will be merged soon then I'll create a new preview release.

  12. added a commit that references this issue on Jan 30, 2021
    e544c06
  13. milkshakeuk commented on Jan 30, 2021

    @milkshakeuk
    Member

    @devshangari I have published a new preview release with the bug fixes in.
    https://www.nuget.org/packages/nHapi/3.0.0-preview.2

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

Metadata

Metadata

Assignees

Labels

bugduplicate

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions