hl7apy icon indicating copy to clipboard operation
hl7apy copied to clipboard

Why no strucuture for ADT_A08 after 2.2?

Open joofio opened this issue 1 year ago • 2 comments

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?

joofio avatar Feb 25 '24 12:02 joofio

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^[email protected]|(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

joofio avatar Feb 25 '24 12:02 joofio

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

svituz avatar Mar 12 '24 13:03 svituz

Hi @joofio, Same thing here, were you able to solve it?

msatti avatar Jul 02 '24 18:07 msatti

no...

joofio avatar Jul 02 '24 19:07 joofio

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.

msatti avatar Jul 02 '24 22:07 msatti

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.

svituz avatar Jul 03 '24 08:07 svituz

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.

joofio avatar Jul 03 '24 09:07 joofio

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.

msatti avatar Jul 16 '24 20:07 msatti

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^ADT_A01). When hl7apy parses a message that misses the MSH.9.3, it tries to create it as <MSH.9.1>_<MSH.9.2> 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

svituz avatar Jul 17 '24 12:07 svituz

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.

msatti avatar Jul 17 '24 18:07 msatti