Skip to content

Detect non-BackboneElement nested types via elements-based analysis#83

Merged
ryukzak merged 3 commits intomainfrom
non-backbone-nested-element
Mar 3, 2026
Merged

Detect non-BackboneElement nested types via elements-based analysis#83
ryukzak merged 3 commits intomainfrom
non-backbone-nested-element

Conversation

@ryukzak
Copy link
Collaborator

@ryukzak ryukzak commented Mar 3, 2026

Summary

Closes #77

  • Fix TypeScript reexport naming for URL-based identifiers (e.g. CDA logical types) by extracting the name from canonical URLs instead of using the raw identifier name
  • Replace type-name enumeration (NESTED_TYPES set) with elements-based detectionhasStructuralElements walks the specialization chain and compares sub-element keys against the element's type genealogy to distinguish structural nested types (e.g. EN.item adding family/given beyond Base) from constraining elements (e.g. typeId mirroring II's own fields)
  • Include all inherited sub-elements in constraint profile nested typestransformNestedElements now collects keys from the full genealogy chain, so profiles like vitalsigns#component get all 16 fields from Observation.component, not just the constrained ones
  • Rename fsElementSnapshotmergeFsElementProps to clarify its intent (merges scalar props, intentionally strips nested structure)

Test plan

  • Unit tests for tsResourceName with URL-based identifiers
  • Constraint profile test: base type with 3 BackboneElement sub-fields, constraint touching 1 — all 3 appear
  • CDA tests updated (ON with inherited EN.item fields, file count 79 → 124)
  • make all passes — all 12 generation pipelines green (TypeScript R4, CCDA, SQL-on-FHIR, C#, Python, Mustache)
  • 194 tests pass, 0 fail

🤖 Generated with Claude Code

ryukzak added 3 commits March 3, 2026 09:57
tsResourceName now extracts the last path segment from URL-form names
(e.g. http://hl7.org/.../Base → Base). Use tsResourceName instead of
uppercaseFirstLetter for complex-type imports and reexports in the
TypeScript writer.
Overhaul nested type detection to handle CDA and constraint profiles:

- Move isNestedElement to nested-types.ts as a broad pre-filter for any
  element with sub-elements (not just BackboneElement)
- Add hasStructuralElements to check whether sub-elements define new
  fields beyond the element's type (structural) vs merely constraining
  existing type fields (e.g. typeId constraining II's root/extension)
- Add isStructurallyNested combining snapshot and specialization-chain
  analysis to guard against false positives from constraint profiles
  (e.g. bodyweight constraining code.coding)
- Collect all sub-element keys from the genealogy chain in
  transformNestedElements so constraint profiles include inherited fields
  (e.g. vitalsigns#component gets all 16 fields, not just 2)
- Rework mkNestedIdentifier to resolve inherited nested type origins
  without recursively calling mkNestedTypes
@ryukzak ryukzak force-pushed the non-backbone-nested-element branch from 7cc84d9 to aac5290 Compare March 3, 2026 10:17
@ryukzak ryukzak merged commit 8dca22b into main Mar 3, 2026
29 checks passed
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.

CDA types: incorrect backbone elements processing.

1 participant