Closed joofio closed 4 months ago
from hl7apy.parser import parse_message
p = parse_message(
"""MSH|^~\&|Ntierprise|Ntierprise Clinic|Healthmatics EHR|Healthmatics Clinic|20190423113910||ADT^A08|8899-39|P|2.5|
EVN|A08|20190423113910||01
PID|1||151||Bond^Tiny||19990723|M|||8388 Secret Agent Way^^Raleigh^NC^27677|||||||151||||||||||||N
NK1|1|Bond^Lady^T|Spouse^Spouse|007 Soho Lane^^Cary^NC^27511|(919)007-0007^^PH^^^919^0070007
PV1|1|R|||||Manning^Manning^Terry^^^^^^&7654321&UPIN|||||||||N||A
GT1|1|150|Bond^James^^007||007 Soho Lane^^Cary^NC^27511|(919)007-0007^^PH^^^919^0070007~(777)707-0707^^CP^^^777^7070707~^NET^X.400^007@BritishSecretService.com|(919)851-6177 X007^^^^^919^8516177^007|19770920|M|||007-00-0007|||||2988 England Drive^^London^DC|||F||||||||||M|||||||||||||||||||||British Secret Service"""
)
p.validate()
returns
File "/opt/homebrew/Caskroom/miniforge/base/envs/py3/lib/python3.11/site-packages/hl7apy/core.py", line 751, in validate
return Validator.validate(self, reference=self.reference, report_file=report_file)
^^^^^^^^^^^^^^
File "/opt/homebrew/Caskroom/miniforge/base/envs/py3/lib/python3.11/site-packages/hl7apy/core.py", line 848, in __getattr__
raise AttributeError(name)
AttributeError: reference
Hi @joofio, I think in version 2.5 you need to specify also the trigger event. Apparently, ADT_A08 is not a valid ADT trigger event, so you need to specify a valid ADT trigger event
Hi @joofio, Same thing here, were you able to solve it?
no...
I was able to solve it by adding the missing event to the messages.py of the specific version (check the file ../python3.10/site-packages/hl7apy/v2_5/messages.py and add whatever event missing). there should be away to extend adding the event to your code instead of adding to into the library files, if it works for you let me know please.
As previously said, ADT_A08 is not a valid HL7 version 2.5 message. That's why the structure is not in the library. A08 trigger event is used with ADT_A01, as stated in Chapter 3 paragraph 3.3.8 of the 2.5 manual. @msatti if you want to use it without changing the library, you can use the message profiles.
yes your answer makes sense, I dont think its a problem with the library (we can close the issue) but it is a problem for when people use v2 without proper complying with the structure which makes it difficult to validate. The logic between message and event should be in the app that leverages the library.
Dear Svitus and Joofio,
Thank you for your replies. I reviewed section 3.3.8 ADT/ACK - Update Patient Information (Event A08) in both HL7 v2.5 and v2.5.1 manuals:
HL7 v2.5 Manual, Section 3.3.8 HL7 v2.5.1 Manual, Section 3.3.8 From the manual, it appears that ADT_A08 is indeed a valid event in both HL7 version 2.5 and 2.5.1. This trigger event is specifically used to update patient information when no other specific trigger event applies.
Could you please clarify why there seems to be a discrepancy in the interpretation? Am I missing something here?
Thank you for your assistance.
Hi @msatti, the MSH.9 field has three parts: MSH.9.1 Message Code MSH.9.2 Trigger event MSH.9.3 Message Structure.
In the message we are discussing, A08 is the trigger event but the message structure is ADT_A01, not ADT_A08. It's also clear from the links you shared, where the first field of the header is the whole MSH.9 (ADT^A08^ADTA01).
When hl7apy parses a message that misses the MSH.9.3, it tries to create it as `in this case it tries ADT_A08 which doesn't exist. So if you get a message
ADT^A08` such as the one of @joofio, it's right that the structure is not found. Notice that in version 2.5 the MSH.9.3 is required, so that message is not considered valid also because of that
Thank you for your answer, it clarify everything. My message was missing MSH.9.3 Message Structure. not it works after adding it. appreciate your time.
I think the fact there is no message for this strucutre returns error for parse/validation for every message after v2.2.
Is this reading correct? how can we solve it?