FHIR Chat · Creating an advanced codesystem · shorthand

Stream: shorthand

Topic: Creating an advanced codesystem


view this post on Zulip Jean Duteau (Apr 23 2020 at 22:30):

If I want to create a code system and define a property on each code, is that possible with FSH? I'm assuming not based on the note about not supporting relationships between codes and the fact that I'm not sure what the syntax would be. :)

view this post on Zulip Nick Freiter (Apr 24 2020 at 12:19):

It is actually possible, but to get that level of detail, you actually have to define the the CodeSystem using Instance so here is an example:

Instance: YogaCS2
InstanceOf: CodeSystem
Usage: #definition
* title = "Yoga Code System 2"
* name = "YogaCS2"
* description = "A brief vocabulary of yoga-related terms."
* version = "x.y.z"
* url = "http://my-canonical/CodeSystem/YogaCS2"
* status = #active
* content = #complete
* property[0].code = #prop0
* property[0].type = #string
* property[1].code = #prop1
* property[1].type = #string
* concept[0].code = #Sirsasana
* concept[0].display = "Headstand"
* concept[0].property.code = #prop0
* concept[0].property.valueString = "Hello!"
* concept[1].code = #Halasana
* concept[1].display = "Plough Pose"
* concept[1].property.code = #prop1
* concept[1].property.valueString = "Bonjour!"

Note that I put Usage: #definition to indicate to SUSHI that this is a definitional instance, not one that should be treated as an example. And then you can directly set values on this Instance of CodeSystem as if you were setting values on an Instance of any other resource. Note that I have to set a lot of metadata in the first 7 lines that is automatically set when using the CodeSystem keyword, and I don't have access to the nice syntax available when using the CodeSystem keyword to set concepts. But it is possible.

view this post on Zulip Chris Moesel (Apr 24 2020 at 13:06):

That said, I wouldn't be 100% surprised if there are some spots in SUSHI where a CS defined using Instance: works different than a CS defined using CodeSystem:. For example, given @Nick Freiter's excellent example above, would SUSHI do the right thing if you specified a code somewhere else in the IG using YogaCS2#Sirsasana? I'm not sure. But it should -- so it's good to try these things out!


Last updated: Apr 12 2022 at 19:14 UTC