Detect non-BackboneElement nested types via elements-based analysis#83
Merged
Detect non-BackboneElement nested types via elements-based analysis#83
Conversation
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
7cc84d9 to
aac5290
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #77
NESTED_TYPESset) with elements-based detection —hasStructuralElementswalks the specialization chain and compares sub-element keys against the element's type genealogy to distinguish structural nested types (e.g.EN.itemaddingfamily/givenbeyondBase) from constraining elements (e.g.typeIdmirroringII's own fields)transformNestedElementsnow collects keys from the full genealogy chain, so profiles likevitalsigns#componentget all 16 fields fromObservation.component, not just the constrained onesfsElementSnapshot→mergeFsElementPropsto clarify its intent (merges scalar props, intentionally strips nested structure)Test plan
tsResourceNamewith URL-based identifiersmake allpasses — all 12 generation pipelines green (TypeScript R4, CCDA, SQL-on-FHIR, C#, Python, Mustache)🤖 Generated with Claude Code