Stream: conformance
Topic: Type on First Element in Differential for Logical Models
Alexander Zautke (May 17 2021 at 12:26):
Due to the changes implemented in https://github.com/hapifhir/org.hl7.fhir.core/issues/466, the Java validator now throws an exception when validating any logical model generated by the .NET tooling. The .NET tooling adds "Element" as the type of the first element by default. Having discussed before that the type on the first element doesn't have much use (https://chat.fhir.org/#narrow/stream/179177-conformance/topic/sdf-15.20and.20Logical.20Models), I generally agree with the change. However, it currently breaks a lot of logical model tooling. Would it be possible to not throw an hard error here? It is still allowed by sdf-15a (if I read this correctly) and is an unexpected change in a minor version update.
Alexander Zautke (May 19 2021 at 11:24):
@Grahame Grieve @Mark Iantorno Would you say that there should be an exception in the Java validator for Logical Models? Otherwise I would move this issue to the .NET SDK Team. I'm unsure what we would break if the .NET snapshot generator would leave out the type on the first element. I'm a bit afraid that this would break more than expected.
Grahame Grieve (May 19 2021 at 11:49):
it's on my to think about tlist
Alexander Zautke (May 19 2021 at 12:01):
Alright, thanks!
Patrick Werner (May 25 2021 at 17:56):
we also stumbled upon a kind of related issue with sdf-15a:
We wanted to add a pattern to the root of a dataType profile, which isn't possible as the first differential element doesn't include a.
in the path but needs a type for the pattern.
Simone Heckmann (May 26 2021 at 08:04):
...which is a bummer because adding patterns to DataType profiles which are ususally used in pattern type slicings (e.g. Identifier, Coding) would be very useful feature...
Grahame Grieve (Jun 14 2021 at 17:20):
@Alexander Zautke what's an example of a logical model that this affects?
Grahame Grieve (Jun 14 2021 at 17:21):
the spec says that this rule doesn't apply to logical models, so I don't know why there's a problem
Grahame Grieve (Jun 14 2021 at 17:23):
We wanted to add a pattern to the root of a dataType profile, which isn't possible as the first differential element doesn't include a.in the path but needs a type for the pattern.
Why does it need a type for the pattern?
Chris Moesel (Jun 14 2021 at 19:23):
I suspect the issue is what do you put in place of the [x]
in pattern[x]
? Is it just thetype
of the logical model itself?
That aside, however, according to the spec, pattern[x]
is prohibited from type definitions anyway. So technically speaking, it is illegal to use pattern[x]
in a logical model definition at all. See: http://hl7.org/fhir/R4/elementdefinition.html#interpretation
Grahame Grieve (Jun 14 2021 at 19:58):
well, the type issue was raised on data type profiles.
Grahame Grieve (Jun 14 2021 at 19:58):
patterns and fixed values on logical models is an outstanding issue that's a todo for me
Chris Moesel (Jun 14 2021 at 20:00):
Ah sorry. Too many topics mixed into this one thread. I got confused.
Alexander Zautke (Jun 24 2021 at 12:37):
Grahame Grieve said:
Alexander Zautke what's an example of a logical model that this affects?
I tried to debug the problem a bit more in detail. This issue does not occur when you try to validate a logical model with a type on the first element directly. It only happens if the Java validator tries to generate a snapshot for such logical model, e.g. when it's loaded as part of a package dependency or a folder.
Here's the stack trace:
FHIR Validation tool Version 5.3.15-SNAPSHOT (Git# f082ed15ee4d). Built 2021-05-19T09:48:44.426+02:00 (36 days old)
Java: 1.8.0_292 from /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/jre on x86_64 (64bit). 7282MB available
Paths: Current = /Users/alex/Dev/FHIR/org.hl7.fhir.core, Package Cache = /Users/alex/.fhir/packages
Params: -version 4.0 -ig /Users/alex/Desktop/LM/ /Users/alex/Desktop/Patient.json
Loading
Load FHIR v4.0 from hl7.fhir.r4.core#4.0.1 - 4575 resources (00:04.0631)
Load hl7.terminology#2.1.0 - 3767 resources (00:00.0752)
Terminology server http://tx.fhir.org - Version 1.9.378 (00:01.0810)
Load /Users/alex/Desktop/LM/ - 1 resources (00:00.0004)
Get set... Exception in thread "main" java.lang.Error: type on first differential element!
at org.hl7.fhir.r5.conformance.ProfileUtilities.checkDifferentialBaseType(ProfileUtilities.java:789)
at org.hl7.fhir.r5.conformance.ProfileUtilities.generateSnapshot(ProfileUtilities.java:624)
at org.hl7.fhir.validation.ValidationEngine.makeSnapshot(ValidationEngine.java:520)
at org.hl7.fhir.validation.ValidationEngine.prepare(ValidationEngine.java:504)
at org.hl7.fhir.validation.cli.services.ValidationService.initializeValidator(ValidationService.java:257)
at org.hl7.fhir.validation.cli.services.ValidationService.initializeValidator(ValidationService.java:212)
at org.hl7.fhir.validation.ValidatorCli.doValidation(ValidatorCli.java:203)
at org.hl7.fhir.validation.ValidatorCli.main(ValidatorCli.java:159)
Alexander Zautke (Jun 24 2021 at 12:38):
In my case "/Users/alex/Desktop/LM/" contains the following logical model TestWithTypeOnFirstElement.json
Alexander Zautke (Jun 24 2021 at 12:48):
Chris Moesel said:
I suspect the issue is what do you put in place of the
[x]
inpattern[x]
? Is it just thetype
of the logical model itself?That aside, however, according to the spec,
pattern[x]
is prohibited from type definitions anyway. So technically speaking, it is illegal to usepattern[x]
in a logical model definition at all. See: http://hl7.org/fhir/R4/elementdefinition.html#interpretation
Yes, exactly. What we wanted to do is to define a data type profile on Coding. On the first element of such profile we wanted to add a pattern, so that all other profiles using the data type profile would get this pattern automatically. Issue is that if you place a patternCoding on the first element of the diff, you'll get the following error:
Unable to generate snapshot for CodingAlphaID from Coding because Profile CodingAlphaID (http://fhir.de/StructureDefinition/CodingAlphaID), element Coding. Error generating snapshot: The fixed value has type 'Coding' which is not valid (valid types: [])
org.hl7.fhir.exceptions.DefinitionException: Profile CodingAlphaID (http://fhir.de/StructureDefinition/CodingAlphaID), element Coding. Error generating snapshot: The fixed value has type 'Coding' which is not valid (valid types: [])
at org.hl7.fhir.r5.context.SimpleWorkerContext.generateSnapshot(SimpleWorkerContext.java:785)
at org.hl7.fhir.r5.context.SimpleWorkerContext.generateSnapshot(SimpleWorkerContext.java:752)
at org.hl7.fhir.r5.context.SimpleWorkerContext.allStructures(SimpleWorkerContext.java:635)
at org.hl7.fhir.validation.ValidationEngine.prepare(ValidationEngine.java:500)
at org.hl7.fhir.validation.cli.services.ValidationService.initializeValidator(ValidationService.java:256)
at org.hl7.fhir.validation.cli.services.ValidationService.initializeValidator(ValidationService.java:212)
at org.hl7.fhir.validation.ValidatorCli.doValidation(ValidatorCli.java:203)
at org.hl7.fhir.validation.ValidatorCli.main(ValidatorCli.java:159)
Alexander Zautke (Jun 24 2021 at 12:51):
This issue is totally unrelated to logical models, we can discuss this in a different thread, although I suspect there is nothing much we can do about it.
Grahame Grieve (Jun 25 2021 at 05:03):
ok I think @Chris Moesel's error will be fixed next release
Grahame Grieve (Jun 25 2021 at 05:03):
@Alexander Zautke do you have a logical model I can try that with?
Grahame Grieve (Jun 25 2021 at 05:23):
found it. Fixed next release
Chris Moesel (Jun 25 2021 at 13:09):
@Grahame Grieve -- I'm not sure what error you're referring to. As far as I know I didn't report an error in this thread... I mentioned that the spec prohibits fixed[x]
and pattern[x]
on logicals/resources, but that's not an error; that's the spec doing what specs do.
Grahame Grieve (Jun 25 2021 at 20:54):
where does the spec do that?
Chris Moesel (Jun 25 2021 at 21:15):
@Grahame Grieve here: http://hl7.org/fhir/R4/elementdefinition.html#interpretation
Grahame Grieve (Jun 25 2021 at 21:16):
logical != specialization
Chris Moesel (Jun 25 2021 at 21:17):
OK. I am confused. Logicals can introduce new elements. You can't introduce new elements in derivation: constraint
, so the only other option is derivation: specialization
. What am I missing?
Grahame Grieve (Jun 25 2021 at 21:22):
you can have a constraint on a logical model, and that's what we're talking about
Chris Moesel (Jun 25 2021 at 21:27):
I don't think that's clear, because the logical model that @Alexander Zautke linked to above has "derivation": "specialization"
. Wouldn't constraining a logical model require "derivation": "constraint"
(and then prohibit adding further elements)?
Grahame Grieve (Jun 25 2021 at 21:34):
umm. I'm confused. Alexander's issue was the Java snapshot generator didn't allow 'type' on the base element. Logical models (not specializations) are not subject to that rule. The fixed value thing is a different issue
Chris Moesel (Jun 25 2021 at 21:41):
OK. I think we're just talking in circles then. Although I still don't know what error of mine you said is fixed in the next release. ;-)
Grahame Grieve (Jun 25 2021 at 21:43):
you'll get a validation error not an exception if you put a fixed value or a pattern at the root of a profile
Chris Moesel (Jun 25 2021 at 21:45):
OK. That wasn't my bug, but I'm glad it's fixed!
Last updated: Apr 12 2022 at 19:14 UTC