Stream: conformance
Topic: fixed/pattern on min = 0
Grahame Grieve (Jul 21 2020 at 23:05):
So an issue arises here: https://chat.fhir.org/#narrow/stream/179166-implementers/topic/Slicing.20on.20pattern.2Ffixed :
What does a profile mean when it assigns a fixed value or a pattern but leaves min = 0?
As far as I can tell , there's 3 options:
- if min=0, it doesn't matter what the fixed/pattern is
- if there's a fixed or a pattern, it doesn't matter what the min is
- if there's a fixed/pattern, and min=0, that's an error in the profile
The specification is silent on this. The relevant definitions are, so far as I can find:
- fixed[x]: Specifies a value that SHALL be exactly the value for this element in the instance. For purposes of comparison, non-significant whitespace is ignored, and all values must be an exact match (case and accent sensitive). Missing elements/attributes must also be missing.
-
pattern[x]:
Specifies a value that the value in the instance SHALL follow - that is, any value in the pattern must be found in the instance. Other additional values may be found too. This is effectively constraint by example -
min: The minimum number of times this element SHALL appear in the instance
I think that the spec leans to #2 above.
@Ewout Kramer @Lloyd McKenzie
Grahame Grieve (Jul 21 2020 at 23:08):
presently the validator follows #1 for both fixed and pattern
Lloyd McKenzie (Jul 22 2020 at 04:41):
My preference is 3. Having a min that's ignored is going to be confusing to implementers and I can't see any reason to allow min of 0 when there's a fixed value or pattern
Richard Townley-O'Neill (Jul 22 2020 at 05:05):
I like option 3 as it naturally fits with this case:
I want to specify a min of 2 with a pattern that describes only one use.
So the min has to be >= the number of instances in the pattern.
Ewout Kramer (Jul 22 2020 at 07:28):
The .NET validator is doing 1 - if an element is not there, none of the validations are run on it (except, of course, the cardinality validation)
Ewout Kramer (Jul 22 2020 at 07:29):
This is true for both 'fixed' and 'pattern'.
Ewout Kramer (Jul 22 2020 at 07:31):
I don't see (yet) why a fixed/pattern would require the element to be present. A required binding (which feels similar to me), does not require a min cardinality of 1 either?
Frank Oemig (Jul 22 2020 at 09:04):
:+1:
Chris Moesel (Jul 22 2020 at 13:57):
I always interpreted fixed/pattern with min 0 to mean that the element is not required, but if it is there, it must be this fixed value (or follow this pattern). I think this aligns with @Ewout Kramer's thoughts above.
Chris Moesel (Jul 22 2020 at 13:59):
Trying to think of a use case...
Chris Moesel (Jul 22 2020 at 14:01):
If a Patient profile has active
0..1
and fixedBoolean: true
, then it's effectively saying "don't give me explicitly inactive patients" -- I only want patients that are explicitly active or don't have active set (which generally implies active).
Chris Moesel (Jul 22 2020 at 14:02):
Otherwise I guess you'd need to use an invariant to say that.
Lloyd McKenzie (Jul 22 2020 at 14:25):
That can work only if the "meaningIfMissing" exactly corresponds to the fixed value.
Chris Moesel (Jul 22 2020 at 14:35):
I guess another use case would be for Quantity
. If you leave system
as 0..1
but also have fixedSystem: "http://unitsofmeasure.org"
, you're saying you allow unit-less quantities (e.g., 5
) but if your quantity has a unit code, it better be UCUM.
Nik Klassen (Jul 22 2020 at 15:07):
If we don't interpret it as #1 then it doesn't seem like there's a way to express the use case of "it can be missing, but if it's here it has to look like this". I have no idea how realistic that use case is though
Nik Klassen (Jul 22 2020 at 15:09):
Like Ewout said, it's the most consistent (and easiest to implement) to just ignore all other validations when the item is missing.
Grahame Grieve (Jul 22 2020 at 20:17):
ok we line up with #1. So task to clarify: J#28126
Richard Townley-O'Neill (Jul 23 2020 at 23:56):
Lloyd McKenzie said:
That can work only if the "meaningIfMissing" exactly corresponds to the fixed value.
@Lloyd McKenzie are you saying that when doing what @Chris Moesel describes we need to use also ElementDefinition.meaningWhenMissing ?
Lloyd McKenzie (Jul 24 2020 at 00:09):
I'm saying that if you're going to presume that an absent element corresponds to equivalent to having a fixed value, the meaningIfMissing for that element better be equivalent. Otherwise I could just as easily have had a fixedBoolean=false for Patient.active - and omitting the 0..1 element would have been a huge issue.
Last updated: Apr 12 2022 at 19:14 UTC