Stream: shorthand
Topic: example of a FSH Instance with contained resources
John Moehrke (Nov 23 2020 at 23:42):
Is there an example of how to define a FSH instance with contained resources?
Chris Moesel (Nov 24 2020 at 00:21):
We call this capability "inlined" instances. There is an example or two in the spec, but not specific to how it is used with contained. So here is one:
Instance: EveAnyperson
InstanceOf: Patient
Usage: #inline // #inline means this instance should not be exported as a separate example
* name.given[0] = "Eve"
* name.family = "Anyperson"
Instance: EvesCondition
InstanceOf: Condition
Usage: #example
Description: "An example that uses contained"
* contained[0] = EveAnyperson // this inlines EveAnyperson definition here
* code = http://foo.org#bar
* subject = Reference(EveAnyperson) // this automatically creates the relative reference correctly
That produces:
{
"resourceType": "Condition",
"id": "EvesCondition",
"contained": [
{
"resourceType": "Patient",
"id": "EveAnyperson",
"name": [
{
"given": [
"Eve"
],
"family": "Anyperson"
}
]
}
],
"code": {
"coding": [
{
"code": "bar",
"system": "http://foo.org"
}
]
},
"subject": {
"reference": "#EveAnyperson"
}
}
John Moehrke (Nov 24 2020 at 12:50):
thanks. Would be good to have a sentence in the shorthand spec that states that inline means contained... inline is a good word, but not when one is thinking they need to figure out how to do a contained resource.
John Moehrke (Nov 24 2020 at 12:52):
I now see a sentence, but it is a sentence in the middle of a paragraph.
David Pyke (Nov 24 2020 at 13:02):
An example in the docs would be very helpful
John Moehrke (Nov 24 2020 at 13:41):
or just link the examples already in the spec... given that DrDavidAnydoc is defined as #inline... using it somewhere would show how to use it.
Chris Moesel (Nov 24 2020 at 20:24):
@Mark Kramer -- John and David suggest that we provide clarification and more complete examples in the spec for using #inline
instances with contained
.
Mark Kramer (Nov 25 2020 at 15:23):
Good suggestion. I will add an example of this sort. It will appear on the continuous integration version of the docs
Petter Wolff (Nov 25 2020 at 15:58):
Thanks John, Chris and Mark, was just looking for this!
Elliot Silver (Nov 26 2020 at 21:51):
Inline seems to work nicely with standard resources, but how do you do a contained ValueSet? I can't specify usage, can I?
My use case is that I have a questionnaire. I want question Q.n to be: "select all values that apply or other", and Q.n.1 to be a text field for the other text, enabled only when "other" is selected from the first question. When the response is filled out, I don't want "other" to be an accepted value, so I don't want to "publicly" define the valueset to contain other, I'd like a contained valueset within the questionnaire defined as standard valueset + "other".
Chris Moesel (Nov 27 2020 at 04:22):
So... you want to use the FSH syntax to create a ValueSet that includes "other", but you want that ValueSet only to be used as a contained resource in a Questionnaire, and not to be published as an official ValueSet of the IG? Do I have that right? As you noted, you can't mark a FSH ValueSet as inline, so you'd probably need to define it using the Instance:
syntax instead (it would be an InstanceOf: ValueSet
. In truth, ValueSet
s aren't terribly complicated, so it might not be too bad?
Elliot Silver (Nov 27 2020 at 04:24):
Yes, that was what I was trying to do, and how I was thinking I’d have to do it.
Chris Moesel (Nov 27 2020 at 04:26):
Actually, there is another thing you could try -- if you're letting SUSHI generate your IG JSON. There is a little known feature in the config to have SUSHI omit a FSH resource from the IG. I nearly forgot about it myself. Look at the SUSHI Configuration documentation and search the page for "omit". You'll find info for how to do this. But basically, in your sushi-config.yaml
, you'll want to add something like this:
resources:
ValueSet/id-of-vs-to-omit: omit
Elliot Silver (Nov 27 2020 at 04:28):
So, put it in Questionnaire.contained, but omit it from being generated as an independent resource? Hmm, sounds interesting.
Chris Moesel (Nov 27 2020 at 04:31):
Yeah. I've never tried this exact use case, but I think that, in theory, it should work. The only thing I can't remember for sure is if it
- still generates the omitted file but just doesn't put it in the IG JSON, or
- doesn't generate the file at all
I'd check the code, but I'm not even supposed to be working right now. ;-)
Elliot Silver (Nov 27 2020 at 04:31):
I can check it out tomorrow too, don’t bother—enjoy your holiday.
Chris Moesel (Nov 27 2020 at 04:32):
Alright, you too (that is, if you're U.S.-based). Have a great rest of your day/night!
Elliot Silver (Dec 01 2020 at 22:14):
@Chris Moesel, over the weekend, I tried creating just a regular FSH ValueSet, containing it, and omitting the resource. This doesn't seem to work. I'm going to have to look at it again in the next day or two to see if I can come up with a solution.
John Moehrke (Dec 01 2020 at 22:18):
I am struggling with understanding any possible use-case for a contained valueSet... What is wrong with an IG defined valueSet?
Elliot Silver (Dec 01 2020 at 22:28):
I have a published Flavours value set with values Vanilla, Chocolate, Strawberry. I want a questionnaire with:
What is your favourite ice cream flavour: * Vanilla * Chocolate * Strawberry * Other
If Other, please specify: [ ]
The response goes into a codeableConcept.
I don't want to hard-code 4 answerOption, I'd like to use answerValueSet. But I'd also prefer not to have "Other" as a published value in the ValueSet. So, my plan is to create a contained ValueSet with all of the Flavours plus "Other" that I can reference from within the Questionnaire, but not use anywhere else.
(I'm open to a better approach. This is tied to the fact that the Questionnaire "open-choice" question type doesn't actually have the "other text", only Vanilla, Chocolate, Strawberry [ ], which is a poor UI in my mind. Maybe @Lloyd McKenzie has a better idea.)
Lloyd McKenzie (Dec 01 2020 at 22:41):
Your approach seems viable to me
John Keyes (Dec 01 2020 at 22:44):
Great -- thanks everyone!
Elliot Silver (Dec 01 2020 at 22:47):
Thanks @Lloyd McKenzie
Ideally, it would be nice to not have to do this, but instead to have an element/extension for open-choice questions to be able to specify the "other" text.
Lloyd McKenzie (Dec 01 2020 at 23:03):
You can submit a change request if you wish :)
Chris Moesel (Dec 01 2020 at 23:06):
@Elliot Silver -- after you look at it again, if it's still not working, let us know some more details about _how_ it's not working. If it's a bug in SUSHI, we'd like to know!
John Moehrke (Dec 02 2020 at 00:40):
if the valueset is contained in the questionnaire, then it is effectively static values.... distinction without a difference.... I am unclear as to the down side of an IG based valueset.
Elliot Silver (Dec 02 2020 at 00:42):
Is it static? even if it is build using compose?
Lloyd McKenzie (Dec 02 2020 at 02:19):
The contained value set is important a non-contained value set - so it's not static.
Gino Canessa (Dec 02 2020 at 15:58):
If this is a common pattern, I think I'd like to see it specified in a different way. E.g., an extension on the question to enable an Other
(or specified text value prompt), show a text field to input the data, and (I assume) stuff the text into a CodeableConcept.text
field.
Creating/maintaining a separate custom ValueSet for every question with this behavior feels error-prone.
Elliot Silver (Dec 04 2020 at 00:26):
Hmm, so Questionnaire.item.answerValueSet needs a canonical url to the value set. What does a canonical url for a contained resource look like? Do I need to specify ValueSet.url, or is it something inherited from the enclosing Questionnaire?
Elliot Silver (Dec 04 2020 at 00:40):
Nevermind -- there is an example in the spec (https://www.hl7.org/fhir/references.html#canonical-fragments) of exactly this issue.
Elliot Silver (Dec 04 2020 at 00:42):
(Relevant to FSH, there doesn't appear to be an automated way to reference the contained resource as a canonical fragment. I have to explicitly put in #my-instance-name
.)
Chris Moesel (Dec 04 2020 at 13:34):
Thanks for letting us know, @Elliot Silver. I've logged a bug: SUSHI #688
Vadim Peretokin (Dec 02 2021 at 11:03):
I also needed to contain a valueset in a questionnaire, though for a different reason - the rendering tool I'm looking at only supports valueset inclusion this way. This doesn't mean that the valueset should be published separately in the IG, I'd like that to be as-is.
The challenge with doing this out of the box is that you can't point to an instance of a valueset in the contained field, it needs to be an instance of a non-terminology resource. Trying to represent the valueset as an instance instead, like Chris suggested earlier, raised quite a few errors and looked a bit like a rabbithole - due to time pressure I decided not to go that way, but thought I'd raise the usecase here just so we're across it.
Chris Moesel (Dec 02 2021 at 23:08):
I think this conversation took a few turns (ending in discussion about canonicals) and perhaps we lost sight of one of the original issues -- which was containing a non-instance definition. So @Vadim Peretokin -- are you saying that if you define a value set (using ValueSet:
), that you can't assign it as a contained resource in something else? I just want to be sure I understand the issue.
Chris Moesel (Dec 02 2021 at 23:17):
OK. I see now. I was able to reproduce. What's interesting is that we do support this when you're assigning a VS to ^contained
in a profile -- but we don't when assigning it to contained
on an instance. This seems like an oversight to me and hopefully something that is easy to remedy. I've reproduced it here: https://fshschool.org/FSHOnline/#/share/3rLqOJ5
I've logged it as SUSHI#971
Vadim Peretokin (Dec 03 2021 at 09:09):
That's exactly it. Thanks, @Chris Moesel
Chris Moesel (Jan 06 2022 at 00:46):
@Vadim Peretokin -- this has been fixed in SUSHI 2.2.6.
Last updated: Apr 12 2022 at 19:14 UTC