FHIR / sushi

SUSHI (aka "SUSHI Unshortens Short Hand Inputs") is a reference implementation command-line interpreter/compiler for FHIR Shorthand (FSH).
Apache License 2.0
145 stars 44 forks source link

Improve Logical Model type controls to not re-add elements #1450

Closed jafeltra closed 6 months ago

jafeltra commented 6 months ago

Fixes CIMPL-1249.

This PR improves the logic for overwriting the type of a Logical Model with a caret value rule to only allow URIs to be set. This seems to line up with the FHIR spec for type. Because you can only overwrite type with a URI, I also updated the message of the InvalideTypeAccessError to be a little more specific for Logical Models. This also uses this.pathType when adding elements so the element id path is properly calculated so that elements that were in the parent aren't re-added when when the logical model overwrites the type.

This issue came up due to changes in the IntelliSOFT-Consulting/ChanjoKe-FHIR-IG#main repo after PR #1443. With this branch, there are still changes, but I think the changes are correct. Running a full 1-year regression resulted in 5 repos with changes. Looking at the differences, they all resulted from types that were not full URIs, which is not allowed in FHIR and no longer allowed on this branch. These are the 5 repos:

HL7/sdc#master
IHE-Germany/ITI.XDS.VS#main
IHE/pharm-vaccination#main
IntelliSOFT-Consulting/ChanjoKe-FHIR-IG#main
WorldHealthOrganization/ddcc#main
jafeltra commented 6 months ago

bb0dd4c switches back to overwriting the type of a Logical Model but now logs a warning when that type is not an absolute URL. With this change, three of the repos have no actual differences, but do now log warnings about changing the type.

IntelliSOFT-Consulting/ChanjoKe-FHIR-IG#main and WorldHealthOrganization/ddcc#main do still have changes where elements from the parent were previously re-added but now they are not added and an error is logged instead. They also have warnings for non-URL types. It looks like the elements that are trying to be re-added are all the same but change cardinality min from 0 to 1. I think both should be able to update to use regular card rules.