Stream: implementers
Topic: Validation for required
nicola (RIO/SS) (Dec 09 2016 at 14:27):
We've fixed required validation in our FHIR library and run tests against FHIR 1.6 distrib - got about 22 failures like:
[{:expected "field :code is required", :actual {:extension [ {:url "http://hl7.org/fhir/StructureDefinition/structuredefinition-regex", :valueString "-?([0]|([1-9][0-9]*))(\\.[0-9]+)?"}], :_code {:extension [{:url "http://hl7.org/fhir/StructureDefinition/structuredefinition-json-type", :valueString "number"} {:url "http://hl7.org/fhir/StructureDefinition/structuredefinition-xml-type", :valueString "xsd:decimal"} {:url "http://hl7.org/fhir/StructureDefinition/structuredefinition-rdf-type", :valueString "xsd:decimal"}]}}, :path [:snapshot :element 3 :type 0]} {:expected "field :code is required", :actual {:extension [ {:url "http://hl7.org/fhir/StructureDefinition/structuredefinition-regex", :valueString "-?([0]|([1-9][0-9]*))(\\.[0-9]+)?"}], :_code {:extension [{:url "http://hl7.org/fhir/StructureDefinition/structuredefinition-json-type", :valueString "number"} {:url "http://hl7.org/fhir/StructureDefinition/structuredefinition-xml-type", :valueString "xsd:decimal"} {:url "http://hl7.org/fhir/StructureDefinition/structuredefinition-rdf-type", :valueString "xsd:decimal"}]}}, :path [:differential :element 1 :type 0]}]))
By spec StructureDefinition.differential.element.type.code is required, but here we see there is no code element, but only _code (primative extension) - should we treat it like code required
is satisfied??
All this errors are related to profiles of primitive types.
Grahame Grieve (Dec 09 2016 at 19:11):
this is not an error. if there's a code present, it must come from the value set. but in this case, there isn't a code present.
nicola (RIO/SS) (Dec 09 2016 at 22:34):
http://build.fhir.org/elementdefinition-definitions.html#ElementDefinition.type.code 1..1?
nicola (RIO/SS) (Dec 11 2016 at 07:31):
It looks strange to use extensions in core to define primitives, isn't it?
Grahame Grieve (Dec 11 2016 at 09:26):
well, those things correspond to compiler magic in any other language. Whatever we do would be anomalous in so way.
Grahame Grieve (Dec 11 2016 at 09:26):
though we later came up with a solution that could solve this better, actually, in that type is a URI now
Grahame Grieve (Dec 11 2016 at 09:27):
I could just reference the XSD type directly, and make the JSON and RDF information an extension
Grahame Grieve (Dec 11 2016 at 09:27):
couldn't do that earlier when we solved that dfferently.
Grahame Grieve (Dec 11 2016 at 09:28):
@Chris Grenz @Ewout Kramer @Michel Rutten @Lloyd McKenzie @James Agnew I think that this would be a better approach
Grahame Grieve (Dec 11 2016 at 09:30):
so, specifically, we currently have:
<!-- Note: primitive values do not have an assigned type. e.g. this is compiler magic. XML, JSON and RDF types provided by extension --> <type> <code> <extension url="http://hl7.org/fhir/StructureDefinition/structuredefinition-json-type"> <valueString value="boolean"/> </extension> <extension url="http://hl7.org/fhir/StructureDefinition/structuredefinition-xml-type"> <valueString value="xsd:boolean"/> </extension> <extension url="http://hl7.org/fhir/StructureDefinition/structuredefinition-rdf-type"> <valueString value="xsd:boolean"/> </extension> </code> </type>
Grahame Grieve (Dec 11 2016 at 09:33):
this would change to:
<type> <code value="http://www.w3.org/2001/XMLSchema#boolean"> <extension url="http://hl7.org/fhir/StructureDefinition/structuredefinition-json-type"> <valueString value="boolean"/> </extension> <extension url="http://hl7.org/fhir/StructureDefinition/structuredefinition-rdf-type"> <valueUri value="xsd:boolean"/> </extension> </code> </type>
Grahame Grieve (Dec 11 2016 at 09:34):
somwhat arbitrarily, I have chosen xsd as the master, because a/ it's richer then the json types and b/ RDF uses the same types
nicola (RIO/SS) (Dec 11 2016 at 11:38):
May be add special elements to structure definition to do it without extensions?
Lloyd McKenzie (Dec 11 2016 at 16:02):
I don't have a strong preference on this, though some may find it distasteful that XML is somehow "preferred". (I understand that's not why you're doing it, just noting the impression it may trigger)
nicola (RIO/SS) (Dec 11 2016 at 19:46):
I mean, that basic core feature is defined in terms of extensions, breakage of semantic layers :)
Grahame Grieve (Dec 11 2016 at 19:55):
one that would be used in 6 places?
nicola (RIO/SS) (Dec 11 2016 at 19:56):
why not, you introduced contentReferences, which used in 5 places
Grahame Grieve (Dec 11 2016 at 20:01):
we expect that to be used more.
Grahame Grieve (Dec 11 2016 at 20:07):
RDF type differs from xml type in one place - RDF makes anyURI a bNode (e.g. reference to RDF node) so we mapped anyURI to string for RDF
Grahame Grieve (Dec 11 2016 at 20:08):
JSON type is matching type, but that often means string since the type system is simpler. But it's done by rules, so it might be simpler to hard code the equivalence as a table somewhere
Last updated: Apr 12 2022 at 19:14 UTC