LinuxForHealth / hl7v2-fhir-converter

Converts HL7 v2 Messages to FHIR Resources

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Repeating messages do not completely reset internal variables.

cragun47 opened this issue · comments

Describe the bug
When creating multiple Immunization resources from multiple ORC/RXA segments in a VXU message, messages interfere with each other. In this case, references and reference objects are not created when they should be. By changing the order or removing some segments, other segment references and reference objects are created correctly.

To Reproduce
A workaround was found, and a test was created to test the workaround. The original problem is easily reproduced by using the test, and removing the workaround.

The test is Hl7ImmunizationFHIRConversionTest.testMultipleImmunizationsNoInterference. In this test, there are three ORC/RXA segments. The first and the third have RXA.17 which should create a manufacturer reference and Organization objects. The second ORC/RXA does not have RXA.17.

The test works successfully now because this workaround, condition: rxa17 NOT_NULL was to added to Immunization.yml:

manufacturer:
   condition: rxa17 NOT_NULL
   valueOf: resource/Organization
   expressionType: reference
   specs: RXA.17
   vars: 
      rxa17: RXA.17

The condition prevents the reference code from even starting if there is no RXA.17.

To reproduce the problem, remove condition: rxa17 NOT_NULL. This will cause the test to fail because the third ORC/RXA will create an Immunization, but not the manufacturer reference and Organization.

Expected behavior
The specs: RXA.17 in the yaml should be sufficient to prevent resource/Organization code from being created when RXA.17 is missing. The additional condition condition: rxa17 NOT_NULL should not be needed, and the test should run cleanly without it.

Additional context

@pbhallam tagging you. Please let me know if you have questions.