LinuxForHealth / hl7v2-fhir-converter

Converts HL7 v2 Messages to FHIR Resources
Apache License 2.0
86 stars 34 forks source link

Feature: Conditional Resource Templates #507

Open stueynz opened 1 year ago

stueynz commented 1 year ago

Sometimes, when dealing with custom HL7 segments the correct FHIR resource for the segment differs depending upon some value in the segment. For example, in our ZAL custom Alert segment field ZAL.2.1 denotes the Alert Category, and when the value is one of A1, A3, H2 or H4 then the correct FHIR resource is AllergyIntolerance; for all other alert category values the correct FHIR resource is Flag

Two resources template entries with suitable condition expressions will direct each ZAL segment to its correct resource template.

resources:
    - resourceName: AllergyIntolerance
      segment: ZAL
      resourcePath: resource/AllergyIntoleranceZAL
      repeats: true
      condition: ZAL.2.1 IN [A1, A3, H2, H4]          ## Some of our custom ZAL segments are AllergyIntolerance
      additionalSegments:

    - resourceName: Flag
      segment: ZAL
      resourcePath: resource/FlagZAL
      repeats: true
      condition: ZAL.2.1 NOT_IN [A1, A3, H2, H4]      ## The rest of our custom ZAL segments are more general alert Flags
      additionalSegments:

The grammar for the condition field is as follows:

   <hl7spec>  EQUALS | NOT_EQUALS | IN | NOT_IN | NULL | NOT_NULL   <value> | [ ... ]

Notes:

Examples:

stueynz commented 1 year ago

Discussion on whether or not this is a GoodThing (tm) should probably take place in the matching #508 Issue.

LisaWellman commented 9 months ago

@stueynz thank you for your contribution, I have not reviewed but a quick glance it looks quite complete! Can you sign to handle the DCO?

LisaWellman commented 7 months ago

@stueynz I see no activity here; do you still want to pursue?