crs4 / hl7apy

Python library to parse, create and handle HL7 v2 messages.
http://crs4.github.io/hl7apy/
MIT License
215 stars 85 forks source link

Parse Null values from HL7 Message (parse || as null value ) #98

Closed ovisioneg closed 4 months ago

ovisioneg commented 2 years ago

How can I parse || as null values to be injected as null or '' in my JSON object? For example: when i parse hl7 message like : PID|1|99999911^^^MRN^MRN^""|51685^^^Community Medical Record Number^CMRN^""~99999911^^^MRN^MRN^""| JSON Object will be : 'pid': { 'set_id_patient_id': { 'si': { 'si': '1' } }, 'patient_id_external_id': { 'id': { 'st': '99999911' }, 'assigning_authority': { 'namespace_id': 'MRN' }, 'identifier_type_code': { 'is': 'MRN' }, 'assigning_facility': { 'namespace_id': '""' } } }

But if the hl7 message becomes: PID||99999911^^^MRN^MRN^""|51685^^^Community Medical Record Number^CMRN^""~99999911^^^MRN^MRN^""|

the JSON Object will be : 'pid': { 'patient_id_external_id': { 'id': { 'st': '99999911' }, 'assigning_authority': { 'namespace_id': 'MRN' }, 'identifier_type_code': { 'is': 'MRN' }, 'assigning_facility': { 'namespace_id': '""' } } }

in this case i can't find the property : set_id_patient_id in my JSON Object

How can I get this property even if it's not found as a field in the HL7 Message?

svituz commented 4 months ago

I guess you don't need this anymore, but JSON conversion is not part of the library, so you'd need to handle it yourself.