Skip to content

TypeSchema: better error + skip R5 types in R4-target extensions#153

Open
ryukzak wants to merge 3 commits intomainfrom
fix/r5-types-in-r4-extensions
Open

TypeSchema: better error + skip R5 types in R4-target extensions#153
ryukzak wants to merge 3 commits intomainfrom
fix/r5-types-in-r4-extensions

Conversation

@ryukzak
Copy link
Copy Markdown
Collaborator

@ryukzak ryukzak commented Apr 30, 2026

Context

Generating against kbv.ita.for@1.3.1 together with de.basisprofil.r4@1.6.0-ballot2 pulls in the transitive dep hl7.fhir.uv.extensions.r4@5.2.0. That package ships R4-targeted extensions whose value[x] choices are typed as R5-only datatypes (CodeableReference, Availability). On R4 generation those types do not resolve — codegen aborts with an unhelpful single-line error.

Changes

TypeSchema: improve field type resolution error

Replace the single-line throw in field-builder.ts with a structured multi-line message and an R4-context-gated hint.

Before

Could not resolve field type: <http://hl7.org/fhir/StructureDefinition/biologicallyderivedproduct-manipulation>.valueCodeableReference: <CodeableReference> (pkg: 'hl7.fhir.uv.extensions.r4#5.2.0'))

After

Could not resolve field type:
  package: hl7.fhir.uv.extensions.r4#5.2.0
  schema:  http://hl7.org/fhir/StructureDefinition/biologicallyderivedproduct-manipulation
  field:   valueCodeableReference
  type:    CodeableReference
  hint:    'CodeableReference' is an R5+ type and is not available when generating against R4.
           Either skip this canonical via skip-hack.ts, or upgrade the target to R5.

The hint only fires when:

  • element.type is in R5_ONLY_TYPES (Availability, CodeableReference, ExtendedContactDetail, MonetaryComponent, RatioRange, VirtualServiceDetail), AND
  • the failing schema's package transitively depends on hl7.fhir.r4.core (otherwise the hint would mislead R5 generation).

TypeSchema: skip biologicallyderivedproduct R5-typed extensions

Two more entries in src/typeschema/skip-hack.ts for hl7.fhir.uv.extensions.r4:

  • biologicallyderivedproduct-manipulation
  • biologicallyderivedproduct-processing

Both reference CodeableReference. Joins the existing six entries (extended-contact-availability, immunization-procedure, specimen-additive, workflow-barrier, workflow-protectiveFactor, workflow-reason).

TypeSchema: extend kbv-r4 example with de.basisprofil + kbv.basis

Update examples/on-the-fly/kbv-r4/generate.ts to pin the cross-package version graph that surfaced the issue:

-    .fromPackage("hl7.fhir.r4.core", "4.0.1")
     .fromPackage("kbv.ita.for", "1.3.1")
+    .fromPackage("de.basisprofil.r4", "1.6.0-ballot2")
+    .fromPackage("kbv.basis", "1.8.0")

hl7.fhir.r4.core is now pulled transitively. The example now exercises the R4/R5-extensions interaction so future regressions are caught.

Notes

ryukzak added 3 commits April 30, 2026 17:23
- Multi-line error with package, schema, field, type rows
- R5_ONLY_TYPES set + dependsOnR4Core helper to gate the hint
- Hint suggests skip-hack.ts entry or upgrading to R5
Add biologicallyderivedproduct-manipulation and -processing from
hl7.fhir.uv.extensions.r4 to the skip list. Both reference
CodeableReference, which is R5-only and unavailable when
generating against R4.
Replace the explicit hl7.fhir.r4.core dep (now pulled transitively)
with de.basisprofil.r4@1.6.0-ballot2 and kbv.basis@1.8.0 to
exercise the cross-package version graph from PR #151.
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