FHIR Chat · How to create new resource to be used as an extension · shorthand

Stream: shorthand

Topic: How to create new resource to be used as an extension


view this post on Zulip Al Pivonka (Apr 05 2022 at 20:31):

I may be going about his all wrong.
We have some custom groupings of attributes that we need to store at the Questionnaire.item groups of "settings"(general, scale, data).
I've created a Resource "QuestionnaireItemSettings" that I hope to add to Questionnaire.item as an extension (is this a good idea or not?)

The resource is basically the following after generation to json.

{
"general":{
   ...
}
"data" :{
 ....
}
"scale" :{
 ...
}
}
...     Indicates attributes just not shown.

I'd like to reuse how questionnaire.maxvalue is defined and add a max/min value to my Resource above.

So I copied the defintion of questionnaire.maxvalue and saw it formats the attribute as

  • minValue 0..1 only date or dateTime or time or instant or decimal or integer "minValue"

Yet FSH complains about the keyword 'only'

error As a FHIR choice data type, the specified data.minValue for AddElementRule must end with '[x]'.

How would one define a minValue to allow the use of those datatypes ?

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

Hi @Al Pivonka. I think you've raised a few questions here. I'll try to respond as best I can, but let me know if anything is unclear.

While FSH allows you to create custom resources, this should be done with care -- as you can't expect any other systems to support them. Typically, custom resources would only be used in an enclosed system where you control all of the FHIR-related software and can build in support for your custom resources. Custom resources are not generally a good solution for cross-system interoperability.

As for carrying a custom resource in an extension, this would likely also cause issues (even in a closed system as described above). The Extension definition only allows a particular list of types (see the Notes in the previously linked definition) -- so you couldn't define an extension whose value is a custom resource.

If you want to add general, data, and scale attributes to Questionnaire.item, the most common approach would be to create a complex extension for them (assuming they should always be grouped together). You would then apply that extension to Questionnaire.item. The extensibility page discusses simple and complex extensions. The FHIR Shorthand spec discusses extensions w/ examples in the Defining Extensions section. It describes how to apply them to a profile in the Contains Rules for Extensions section. Since Questionnaire.item is recursive, if you wanted to apply this extension to all recursions, you should also see Jean Duteau's recent thread here (and my response to it).

As for your last question about the only rule -- you're getting that error because FHIR choices (where more than one data type is allowed) must have names ending in [x]. So to make it work, you would have to say minValue[x]. But minValue[x] is actually a property of ElementDefinition, which is the backing type for all elements -- so depending on your use case, it might be more appropriate to set it via a caret path assignment rule.

view this post on Zulip Al Pivonka (Apr 06 2022 at 14:50):

@Chris Moesel thank you for your response.
Great information and I will continue to push onward.

view this post on Zulip Al Pivonka (Apr 06 2022 at 18:16):

@Chris Moesel

You may know.. I'm searching GITHUB for examples of what I'm trying to do; " I know they will be things I will have to interpret from those examples"

I'm hoping to find std. tag that is used for FHIR-FSH within GITHUB. Any Ideas?

Any assistance you can provide would be greatly appreciated.

view this post on Zulip Chris Moesel (Apr 06 2022 at 18:48):

Hi @Al Pivonka -- I'm afraid I don't really have any tips for searching GitHub. If it's helpful, FSH Finder lists IGs that use FSH. So you could look through them for examples. FSH Online also has some built-in examples. Otherwise, searching Zulip can be very helpful too.


Last updated: Apr 12 2022 at 19:14 UTC