Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Conditional Resource Templates #507

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

stueynz
Copy link

@stueynz stueynz commented Sep 12, 2023

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:

  • hl7spec uses the same dot notation as expression syntax inside templates and can be of the folowing forms:

    • SEGMENT
    • SEGMENT.FIELD
    • SEGMENT.FIELD.COMPONENT
    • SEGMENT.FIELD.COMPONENT.SUBCOMPONENT
    • SEGMENT.FIELD(REPETITION)
    • SEGMENT.FIELD(REPETITION).COMPONENT
    • SEGMENT.FIELD(REPETITION).COMPONENT.SUBCOMPONENT

    ZAL, ZAL.2, ZAL.2.1, ZAL.2.1.2, PID.14(1).2 & PID.14(1).2.1 are all valid values for hl7spec.

  • The SEGMENT part of hl7spec MUST match the value of the segment field.

  • EQUALS and NOT_EQUALS expressions only accept a single value on the right-hand side of the expression.

  • IN and NOT_IN expressions only accept a list of values, delimited by comma, in square brackets on the right-hand side of the expression.

  • NULL and NOT_NULL do not accept any value.

  • The condition expression cannot be much more complex, as there are no context variables available at evaluation time.

Examples:

  • PID.5.1.2 EQUALS van
  • ZAL.2.1.3 NOT_NULL
  • ZAL.2(1).1 NULL
  • ZAL.3.1 IN [A3, A4, H1, H3, FA, DA]
  • ZAL.3.1 NOT_IN [A2, F3, DA]
  • ZAL.2 EQUALS A4
  • ZAL NOT_EQUALS H2

Stuart McGrigor added 14 commits September 7, 2023 17:34
…etimes ignore weird empty HL7 Segments

Signed-off-by: Stuart McGrigor <stuart.mcgrigor@midcentraldhb.govt.nz>
…y AL1 and ZAL segments; just for testing

Signed-off-by: Stuart McGrigor <stuart.mcgrigor@midcentraldhb.govt.nz>
…arked as ignoreEmpty and is actually empty then don't attempt to make a matching Resource

Signed-off-by: Stuart McGrigor <stuart.mcgrigor@midcentraldhb.govt.nz>
Signed-off-by: Stuart McGrigor <stuart.mcgrigor@midcentraldhb.govt.nz>
Signed-off-by: Stuart McGrigor <stuart.mcgrigor@midcentraldhb.govt.nz>
Signed-off-by: Stuart McGrigor <stuart.mcgrigor@midcentraldhb.govt.nz>
Signed-off-by: Stuart McGrigor <stuart.mcgrigor@midcentraldhb.govt.nz>
…alue doesn't qualify as empty

Signed-off-by: Stuart McGrigor <stuart.mcgrigor@midcentraldhb.govt.nz>
…o sometime not map a particular segment to a particular Resource

Signed-off-by: Stuart McGrigor <stuart.mcgrigor@midcentraldhb.govt.nz>
…pply a template to a particular segment

Signed-off-by: Stuart McGrigor <stuart.mcgrigor@midcentraldhb.govt.nz>
…a valid segment name; PID.5.1.2 is a valid hl7 specification, and it includes SubComponent

Signed-off-by: Stuart McGrigor <stuart.mcgrigor@midcentraldhb.govt.nz>
… condition is true

Signed-off-by: Stuart McGrigor <stuart.mcgrigor@midcentraldhb.govt.nz>
…h expressions inside templates

Signed-off-by: Stuart McGrigor <stuart.mcgrigor@midcentraldhb.govt.nz>
…NIQUES.md

Signed-off-by: Stuart McGrigor <stuart.mcgrigor@midcentraldhb.govt.nz>
@stueynz
Copy link
Author

stueynz commented Sep 12, 2023

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

@stueynz stueynz changed the title Feat/conditional resource template Feature: Conditional Resource Templates Sep 12, 2023
* We need to be able to use FIELDS, COMPONENTS and SUBCOMPONENTS from custom segments in Conditions
* Added a note that fields, components & sub-components can now be included in expressions

Signed-off-by: Stuart McGrigor <stuart.mcgrigor@midcentraldhb.govt.nz>
@LisaWellman
Copy link
Collaborator

@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
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants