Skip to content

Fix StructureMapUtilities failures by updating the StructureMap runtime in R4, R4B, and R5.#2361

Open
jurmous wants to merge 1 commit into
hapifhir:masterfrom
jurmous:fix/2360
Open

Fix StructureMapUtilities failures by updating the StructureMap runtime in R4, R4B, and R5.#2361
jurmous wants to merge 1 commit into
hapifhir:masterfrom
jurmous:fix/2360

Conversation

@jurmous
Copy link
Copy Markdown

@jurmous jurmous commented Mar 21, 2026

This addresses two related runtime problems:

  • named groups were only resolved from direct imports, not through transitive imports
  • element-model targets could fail when assigning a non-primitive datatype into a choice element such as Extension.value[x] during anonymous backbone supplementation

This issue was identified while investigating the downstream HAPI report hapifhir/hapi-fhir#7690.

Problem

StructureMapUtilities.resolveGroupReference(...) stopped at the first import layer. That meant a map could not invoke a group that existed only in an imported map of an imported map.

StructureMapUtilities.processTarget(...) also mishandled some element-model assignments when the produced value was a non-primitive datatype. In practice this broke cases such as assigning a Reference into Extension.value[x] while materializing an extension under an anonymously supplemented backbone element.

Changes

  • add recursive group lookup across the full import graph, with cycle protection and duplicate-match detection preserved
  • normalize converted non-primitive datatype values before calling setProperty(...) on element-model targets
  • apply the fix consistently in:
    • org.hl7.fhir.r4
    • org.hl7.fhir.r4b
    • org.hl7.fhir.r5
  • add regression tests for:
    • transitive imported group resolution
    • anonymous backbone supplementation with Extension.valueReference

Impact

After this change:

  • dependent groups such as CopyHumanName resolve correctly through transitive imports
  • assignments like src -> tgt.value = create('Reference') as t then CopyReference(src, t) materialize correctly in the element model for anonymous backbone supplementation scenarios

Testing

Added focused regression coverage for R4, R4B, and R5.

References

  • hapifhir/org.hl7.fhir.core#2360
  • hapifhir/hapi-fhir#7690

Enhance `StructureMapUtilities` in R4/R4B/R5 to support:
- Recursive group resolution in imports.
- Type normalization for non-primitive values during property setting.

Add comprehensive unit tests for `StructureMapUtilities`, including multi-layer import resolution and backbone element handling.
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.

1 participant