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

Replace references when applying caret rules on CodeSystems #1444

Closed mint-thompson closed 6 months ago

mint-thompson commented 7 months ago

Completes task CIMPL-1211.

The replaceReferences function is now used by CodeSystemExporter in a similar manner to how it is used by StructureDefinitionExporter. CodeSystems only need this for caret rules.

mint-thompson commented 6 months ago

The reason for this behavior comes from ElementDefinition.assignFshCode. When an element's type is code, uri, or string, the FshCode's code property is assigned. So, you are correct in observing that this isn't really helpful for the scenario in the zulip thread. Setting CodeSystem.property.uri to a specific code within a system appears to be the typical usage, in that FHIR uses it in the CodeSystem that defines some common concept properties. So, it would be useful for this to be easy to do in FSH. If uri elements were assigned with system#code instead of just code, that would let us do it. That seems reasonable, so I'll see if that causes any unfortunate regressions.

cmoesel commented 6 months ago

Good observation, @jafeltra, and good investigation, @mint-thompson! I agree -- given that setting the URI to {system}#{code} is apparently common, I think it makes sense to look into this. It's a little outside of spec, because the spec says this format can be assigned to code, Coding, CodeableConcept, and CodeableReference (and does not mention uri) -- but we're already allowing the assignment in SUSHI anyway; so we might as well make it useful I guess. Of course this all depends on whether or not @mint-thompson's regression finds any reasonable use cases for doing it the other way.

mint-thompson commented 6 months ago

I ran a regression that assigned system#code to uri-type elements, and it showed some undesirable regressions. So, I don't think we can make that change as part of this PR. But, it's probably still worth thinking about how to try to handle this situation in the future.