Stream: shorthand
Topic: two code.coding values
John Moehrke (Nov 19 2020 at 17:46):
How do I specify that I want to force in a profile that the coding element in a code have TWO specific values?
For example in Observation.code, where I need to indicate both a LOINC and SNOMED code for this Observation.
Instance looks like:
- code.coding = LOINC#72514-3 "Pain severity - 0-10 verbal numeric rating"
- code.coding[1] = SNO#225908003 "Pain Score"
Elliot Silver (Nov 19 2020 at 17:47):
Is this a resource example or a profile you're trying to create?
John Moehrke (Nov 19 2020 at 17:47):
I am trying to make a profile that would force instances to have these two codes
John Moehrke (Nov 19 2020 at 17:48):
so the example above comes from an instance that builds... but if I put that same thing into a profile, sushi complains about the second coding
Elliot Silver (Nov 19 2020 at 17:48):
You'll probably need to define slices for them and require each to be present.
John Moehrke (Nov 19 2020 at 17:49):
show me
Jean Duteau (Nov 19 2020 at 17:53):
I think this might do what you want...
code ^slicing.discriminator.type = #value
code ^slicing.discriminator.path = "coding"
code contains loincCode 1..1 MS and snomedCode 1..1 MS
code[loincCode].coding = LOINC#stuff (exactly)
code[snomedCode].coding = SNO#stuff (exactly)
Elliot Silver (Nov 19 2020 at 17:55):
John, are you trying to bind to specific values or just say that there must be a LOINC code and a SNOMED code?
John Moehrke (Nov 19 2020 at 18:05):
specific values
John Moehrke (Nov 19 2020 at 18:05):
@jean. the repetition is not on .code... it is on code.coding
Jean Duteau (Nov 19 2020 at 18:06):
yes, but coding doesn't repeat. code does. so you slice on code
John Moehrke (Nov 19 2020 at 18:08):
not in Observation
John Moehrke (Nov 19 2020 at 18:08):
.code is 1..1
John Moehrke (Nov 19 2020 at 18:09):
thus I need to repeat at .code.coding
John Moehrke (Nov 19 2020 at 18:09):
the loinc and snomed codes are equivilant
Jean Duteau (Nov 19 2020 at 18:28):
Yeah, you're right. maybe this is better...
code.coding ^slicing.discriminator.type = #value
code.coding ^slicing.discriminator.path = "this"
code.coding contains loincCode 1..1 MS and snomedCode 1..1 MS
code.coding[loincCode] = LOINC#stuff (exactly)
code.coding[snomedCode] = SNO#stuff (exactly)
John Moehrke (Nov 19 2020 at 18:35):
It worked!!!!! :heart: Excellent. thanks
John Moehrke (Nov 19 2020 at 19:13):
I tried to make it a closed slice by adding
- code.coding ^slicing.rules = #closed
but it doesn't seem to stop instances from having MORE coding than these two.
Jean Duteau (Nov 19 2020 at 19:14):
yeah, I think you'd have to profile code.coding to be 2..2. #closed should mean that you can only have those so you could have 20 repetitions but only of those 2 specific codings.
John Moehrke (Nov 19 2020 at 19:17):
yeah... again, that did work.
Jean Duteau (Nov 19 2020 at 19:17):
wow, I actually am starting to understand this FHIR and FSH stuff! :)
Chris Moesel (Nov 19 2020 at 19:18):
Just for fun, here is another approach:
* code ^patternCodeableConcept.coding[0].system = LOINC
* code ^patternCodeableConcept.coding[0].code = #stuff
* code ^patternCodeableConcept.coding[1].system = SNO
* code ^patternCodeableConcept.coding[1].code = #stuff
It results in:
{
"id": "Observation.code",
"path": "Observation.code",
"patternCodeableConcept": {
"coding": [
{
"system": "http://loinc.org",
"code": "stuff"
},
{
"system": "http://snomed.info/sct",
"code": "stuff"
}
]
}
}
John Moehrke (Nov 19 2020 at 19:19):
well. slight change of topic... I need ValueQuantity.value to be between 0-10. So I tried this
- valueQuantity.value ^minValueInteger = 0
- valueQuantity.value ^maxValueInteger = 10
but this seems to allow 11
Chris Moesel (Nov 19 2020 at 19:19):
Regarding my last approach, one thing I don't recall is if patterns enforce ordering in arrays or not.
Chris Moesel (Nov 19 2020 at 19:21):
John Moehrke said:
well. slight change of topic... I need ValueQuantity.value to be between 0-10. So I tried this
- valueQuantity.value ^minValueInteger = 0
- valueQuantity.value ^maxValueInteger = 10
but this seems to allow 11
What do you mean by "this seems to allow 11"? If you're saying that SUSHI allows you to create an instance with the value 11
then that doesn't really mean anything -- because SUSHI only does very very limited validation. You'd want to test it w/ a real FHIR validator to see if it works as expected.
Jean Duteau (Nov 19 2020 at 19:22):
John Moehrke said:
well. slight change of topic... I need ValueQuantity.value to be between 0-10. So I tried this
- valueQuantity.value ^minValueInteger = 0
- valueQuantity.value ^maxValueInteger = 10
but this seems to allow 11
Does that mean it’s louder? Is it any louder? Well, it’s one louder, isn’t it? It’s not ten. You see, most blokes, you know, will be playing at ten...Where can you go from there? Where?
Chris Moesel (Nov 19 2020 at 19:25):
Oh man, @Jean Duteau -- I can't believe I missed that opportunity. There I was, like a dope, providing a serious answer.
John Moehrke (Nov 19 2020 at 19:36):
I am not disappointed... yes, I understand Sushi would not be validating. but the build continues and does not complain. so I wondered if I had done the right sushi thing. first always expect chair-to-keyboard failure
John Moehrke (Nov 19 2020 at 19:51):
note.. I am getting a build error with that code.coding slicing trick. I might have messed something up in the slicing trick?
I have
"
- code.coding ^slicing.discriminator.type = #value
- code.coding ^slicing.discriminator.path = "this"
- code.coding ^slicing.rules = #closed
- code.coding 2..2
- code.coding contains loincCode 1..1 and snomedCode 1..1
- code.coding[loincCode] = LOINC#72514-3 "Pain severity - 0-10 verbal numeric rating [Score] - Reported"
- code.coding[snomedCode] = SNO#225908003 "Pain Score"
"
but get this error from the build
"
Observation/ex-MHV-pain-0: Observation.code.coding[0] (l28/c8) error Internal error: Unable to resolve discriminator in definitions: this (@char 1)
Observation/ex-MHV-pain-0: Observation.code.coding[1] (l33/c8) error Internal error: Unable to resolve discriminator in definitions: this (@char 1)
Observation/ex-MHV-pain-0: Observation.code (l27/c16) information Observation.code.coding:loincCode: Unable to check minimum required (Observation.code.coding) due to lack of slicing validation (from https://johnmoehrke.github.io/MHV-PGHD/StructureDefinition/VA.MHV.pain)
Observation/ex-MHV-pain-0: Observation.code (l27/c16) information Observation.code.coding:snomedCode: Unable to check minimum required (Observation.code.coding) due to lack of slicing validation (from https://johnmoehrke.github.io/MHV-PGHD/StructureDefinition/VA.MHV.pain)
"
David Pyke (Nov 19 2020 at 19:54):
i might be wrong but shouldn't it be "$this"?
John Moehrke (Nov 19 2020 at 19:58):
see... problem is in the chair-to-keyboard interface implementation
David Pyke (Nov 19 2020 at 20:00):
Time to get a new, more intuitive keyboard
Julian Sass (Apr 28 2021 at 12:39):
Picking up on this with a question about two codings
inside code
. I'm defining two coding
slices, one of which should be optional. And I want code.coding
to remain 0..*
. Sushi sets the minimum cardinality of code.coding
to the number of slices defined. Plus it sets the minimum cardinality of the optional slice to 1. Am I missing something in my FSH file? Here's my snippet:
Alias: $loinc = http://loinc.org
Alias: $snomed = http://snomed.info/sct
Profile: RespRate
Parent: Observation
* code.coding ^slicing.discriminator[0].type = #pattern
* code.coding ^slicing.discriminator[0].path = "$this"
* code.coding ^slicing.rules = #open
* code.coding contains
loinc 1..* and
snomed 0..*
* code.coding[loinc] = $loinc#9279-1
* code.coding[loinc].system 1..
* code.coding[loinc].code 1..
* code.coding[snomed] = $snomed#86290005
* code.coding[snomed].system 1..
* code.coding[snomed].code 1..
https://fshschool.org/FSHOnline/#/share/3tZBeml
Nick Freiter (Apr 28 2021 at 13:19):
I'm not quite sure what is going on here, it seems like for some reason this line
* code.coding[snomed] = $snomed#86290005
leads SUSHI to believe that code.coding
must contain $snomed#86290005
, but that does not seem right. We will have to investigate this more, I'll log it as a bug. In the meantime, you should be able to accomplish something logically equivalent to what you want by applying that assignment constraint at the system
and code
level instead of the coding
level. See here https://fshschool.org/FSHOnline/#/share/3vE7JXZ for an example of what I mean.
Nick Freiter (Apr 28 2021 at 13:24):
Here is the bug: https://github.com/FHIR/sushi/issues/810.
Julian Sass (Apr 28 2021 at 13:26):
Thanks @Nick Freiter
Last updated: Apr 12 2022 at 19:14 UTC