FirelyTeam / firely-net-sdk

The official Firely .NET SDK for HL7 FHIR
Other
821 stars 342 forks source link

Snapshot generator does not merge Element.Id value for element definition properties. #2839

Open Rob5045 opened 1 month ago

Rob5045 commented 1 month ago

Almost all element definition properties have Element as base type. It looks like Element.Extensions is merged for all properties but Element.Id is not merged at all.

Source code: SnapshotGenerator -> ElementDefnMerger.

For example: mergeBinding

snap.StrengthElement = mergePrimitiveElement(snap.StrengthElement, diff.StrengthElement); snap.DescriptionElement = mergePrimitiveElement(snap.DescriptionElement, diff.DescriptionElement); snap.ValueSetElement = mergeComplexAttribute(snap.ValueSetElement, diff.ValueSetElement); snap.Extension = mergeExtensions(snap.Extension, diff.Extension); snap.Additional = mergeCollection(snap.Additional, diff.Additional, matchExactly);

Example resource: MyObservation.StructureDefinition.json

The result is that when loading the example resource in Forge the binding.id with value "Test" for the "Observation.category" element is still set to the value 'null' after calling SnapshotGenerator.Generate.

mmsmits commented 2 weeks ago

Please be careful when merging Element.id, since elementDefinition has Id's that are "protected" and generated by the snapshot generator itself, and should not be merged.

Rob5045 commented 2 weeks ago

@mmsmits Thanks for reminding me. In Forge I had to be careful for the same reason.