Description
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
milkshakeuk commentedon Jan 23, 2021
@devshangar I wonder if this is a duplicate of #62?
I'll see if I can have a look over the weekend.
milkshakeuk commentedon Jan 23, 2021
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.
nHapi/src/NHapi.Base/Model/Varies.cs
Line 168 in 2c90922
I wonder what hapi does in this scenario. I'll see if I can look more into this over the weekend.
milkshakeuk commentedon Jan 23, 2021
Ok I figured it out, all the
IDdata types for each hl7 version inherit from abstract classNHapi.Base.Model.Primitive.IDthis 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
IDdatatype 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.
milkshakeuk commentedon Jan 23, 2021
I managed to fix it locally for
IDdatatypes but adding the required constructors but it then failed on another datatypeIS, 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.
milkshakeuk commentedon Jan 23, 2021
Looking at the source code generation
IS,ID,DT,DTMandTMdatatypes are coded manually i.e. not source code generated.So at least now I know which ones are most likely affected.
devshangari commentedon Jan 24, 2021
Thanks for looking into this @milkshakeuk
milkshakeuk commentedon Jan 27, 2021
@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.
Add missing constructors to primatives, brought Varies fixOBX5 method…
milkshakeuk commentedon Jan 29, 2021
@devshangari ok I have a PR up for this #136 hopefully will be merged soon then I'll create a new preview release.
Merge pull request #136 from nHapiNET/OBX5-Fix
milkshakeuk commentedon Jan 30, 2021
@devshangari I have published a new preview release with the bug fixes in.
https://www.nuget.org/packages/nHapi/3.0.0-preview.2