FirelyTeam / firely-validator-api

Firely's official FHIR validator API for validating HL7 FHIR resources against profiles.
Other
8 stars 2 forks source link

Don't allow more required slices than max cardiniality of intro #310

Open mmsmits opened 4 years ago

mmsmits commented 4 years ago

Example:

<StructureDefinition xmlns="http://hl7.org/fhir">
  <id value="obs-5"/>
  <url value="urn:uuid:9a788a05-e881-4c0c-a3e7-cce309aab2d7"/>
  <name value="Obs5"/>
  <status value="draft"/>
  <description value="fixture for FirelyTeam/firely-net-sdk#1: closed slicing on polymorphic"/>
  <kind value="resource"/>
  <abstract value="false"/>
  <type value="Observation"/>
  <baseDefinition value="http://hl7.org/fhir/StructureDefinition/Observation"/>
  <derivation value="constraint"/>
  <differential>
    <element>
      <path value="Observation.value[x]"/>
      <slicing>
        <rules value="open"/>
      </slicing>
    </element>
    <element>
      <path value="Observation.value[x]"/>
      <sliceName value="valueCodeableConcept"/>
      <min value="1"/>
      <type>  
        <code value="CodeableConcept"/>
      </type>
      <binding>
        <strength value="required"/>
        <valueSet value="http://somewhere/something"/>
      </binding>
    </element>
    <element>
      <path value="Observation.value[x]"/>
      <sliceName value="valueQuantity"/>
      <type>  
        <code value="Quantity"/>
      </type>
      <binding>
        <strength value="required"/>
        <valueSet value="http://somewhere/something"/>
      </binding>
    </element>
  </differential>
</StructureDefinition>

In the example above, two slices are introduced. One has min cardinality of 1. However, observation.value[x] has a max card of 1. And a second slice therefor shouldn't be allowed. Should the snapshotgenerator throw an error when when this occurs? Or leave it up to the validator or other tooling to notice these things?

mmsmits commented 5 months ago

This one is for the validator

ewoutkramer commented 1 month ago

This is an enterprise validation on StructureDefinition.