<StructureDefinition xmlns="http://hl7.org/fhir">
  <id value="mii-pr-pupillary-examination-mono" />
  <url value="http://example.org/fhir/StructureDefinition/MII-PR-PupillaryExaminationMono" />
  <version value="0.1.0" />
  <name value="MII_PR_PupillaryExaminationMono" />
  <title value="Entwurf Pupillary Examination Mono" />
  <status value="draft" />
  <fhirVersion value="4.0.1" />
  <kind value="resource" />
  <abstract value="false" />
  <type value="Observation" />
  <baseDefinition value="http://hl7.org/fhir/StructureDefinition/Observation" />
  <derivation value="constraint" />
  <differential>
    <element id="Observation">
      <path value="Observation" />
      <short value="Entwurf Pupillary Examination Mono" />
      <definition value="Bilaterale Pupillenuntersuchung in einer Observation mit seitengetrennten Components." />
      <constraint>
        <key value="pupil-single-cons-1" />
        <severity value="error" />
        <human value="Konsensuelle Lichtreaktion darf nur dokumentiert werden, wenn beide Augen beurteilbar sind; dann müssen rechts und links dokumentiert werden." />
        <expression value="let rightAssessable := component.where(code.coding.where(system = 'http://example.org/fhir/CodeSystem/pupil' and code = 'eye-assessment-possible-right-eye').exists()).valueBoolean = true let leftAssessable := component.where(code.coding.where(system = 'http://example.org/fhir/CodeSystem/pupil' and code = 'eye-assessment-possible-left-eye').exists()).valueBoolean = true let eyesAssessableCount := ({ rightAssessable, leftAssessable }).where($this).count() let consRight := component.where(code.coding.where(system = 'http://example.org/fhir/CodeSystem/pupil' and code = 'consensual-light-reflex-right-eye').exists()) let consLeft := component.where(code.coding.where(system = 'http://example.org/fhir/CodeSystem/pupil' and code = 'consensual-light-reflex-left-eye').exists()) in (eyesAssessableCount = 2 implies (consRight.exists() and consLeft.exists())) and (eyesAssessableCount &lt; 2 implies (consRight.empty() and consLeft.empty()))" />
      </constraint>
      <constraint>
        <key value="pupil-single-sym-1" />
        <severity value="error" />
        <human value="Symmetrie darf nur dokumentiert werden, wenn beide Augen beurteilbar sind; dann muss sie angegeben werden." />
        <expression value="let rightAssessable := component.where(code.coding.where(system = 'http://example.org/fhir/CodeSystem/pupil' and code = 'eye-assessment-possible-right-eye').exists()).valueBoolean = true let leftAssessable := component.where(code.coding.where(system = 'http://example.org/fhir/CodeSystem/pupil' and code = 'eye-assessment-possible-left-eye').exists()).valueBoolean = true let eyesAssessableCount := ({ rightAssessable, leftAssessable }).where($this).count() let sym := component.where(code.coding.where(system = 'http://example.org/fhir/CodeSystem/pupil' and code = 'pupil-symmetry').exists()) in (eyesAssessableCount = 2 implies sym.exists()) and (eyesAssessableCount &lt; 2 implies sym.empty())" />
      </constraint>
      <constraint>
        <key value="pupil-single-ana-1" />
        <severity value="warning" />
        <human value="Bei dokumentierter Anisokorie sollten Inspektionsbefunde (Weite/Form) für beide Augen vorhanden sein." />
        <expression value="let sym := component.where(code.coding.where(system = 'http://example.org/fhir/CodeSystem/pupil' and code = 'pupil-symmetry').exists()).valueCodeableConcept.coding.where(system = 'http://example.org/fhir/CodeSystem/pupil' and code in {'anisocoria-right-greater','anisocoria-left-greater'}) let sizeRight := component.where(code.coding.where(system = 'http://example.org/fhir/CodeSystem/pupil' and code in {'pupil-size-right-eye','pupil-shape-right-eye'}).exists()) let sizeLeft := component.where(code.coding.where(system = 'http://example.org/fhir/CodeSystem/pupil' and code in {'pupil-size-left-eye','pupil-shape-left-eye'}).exists()) in sym.exists().implies(sizeRight.exists() and sizeLeft.exists())" />
      </constraint>
      <constraint>
        <key value="pupil-single-value-absent-1" />
        <severity value="error" />
        <human value="Für jede Component muss entweder ein Wert oder ein dataAbsentReason angegeben werden, aber nicht beides." />
        <expression value="component.all(value.exists() xor dataAbsentReason.exists())" />
      </constraint>
    </element>
    <element id="Observation.status">
      <path value="Observation.status" />
      <mustSupport value="true" />
    </element>
    <element id="Observation.code">
      <path value="Observation.code" />
      <min value="1" />
      <fixedCodeableConcept>
        <coding>
          <system value="http://example.org/fhir/CodeSystem/pupil" />
          <code value="pupil-exam-mono" />
          <display value="Pupillary examination (mono, bilateral)" />
        </coding>
      </fixedCodeableConcept>
      <mustSupport value="true" />
    </element>
    <element id="Observation.subject">
      <path value="Observation.subject" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Observation.encounter">
      <path value="Observation.encounter" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Observation.effective[x]">
      <path value="Observation.effective[x]" />
      <min value="1" />
      <type>
        <code value="dateTime" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="Observation.performer">
      <path value="Observation.performer" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Observation.component">
      <path value="Observation.component" />
      <slicing>
        <discriminator>
          <type value="pattern" />
          <path value="code" />
        </discriminator>
        <ordered value="false" />
        <rules value="open" />
      </slicing>
    </element>
    <element id="Observation.component:eye-assessment-possible-right-eye">
      <path value="Observation.component" />
      <sliceName value="eye-assessment-possible-right-eye" />
      <min value="1" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Observation.component:eye-assessment-possible-right-eye.code">
      <path value="Observation.component.code" />
      <patternCodeableConcept>
        <coding>
          <system value="http://example.org/fhir/CodeSystem/pupil" />
          <code value="eye-assessment-possible-right-eye" />
          <display value="Eye assessment possible (right eye)" />
        </coding>
      </patternCodeableConcept>
    </element>
    <element id="Observation.component:eye-assessment-possible-right-eye.value[x]">
      <path value="Observation.component.value[x]" />
      <min value="0" />
      <max value="1" />
      <type>
        <code value="boolean" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="Observation.component:eye-assessment-possible-right-eye.dataAbsentReason">
      <path value="Observation.component.dataAbsentReason" />
      <min value="0" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Observation.component:eye-assessment-possible-left-eye">
      <path value="Observation.component" />
      <sliceName value="eye-assessment-possible-left-eye" />
      <min value="1" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Observation.component:eye-assessment-possible-left-eye.code">
      <path value="Observation.component.code" />
      <patternCodeableConcept>
        <coding>
          <system value="http://example.org/fhir/CodeSystem/pupil" />
          <code value="eye-assessment-possible-left-eye" />
          <display value="Eye assessment possible (left eye)" />
        </coding>
      </patternCodeableConcept>
    </element>
    <element id="Observation.component:eye-assessment-possible-left-eye.value[x]">
      <path value="Observation.component.value[x]" />
      <min value="0" />
      <max value="1" />
      <type>
        <code value="boolean" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="Observation.component:eye-assessment-possible-left-eye.dataAbsentReason">
      <path value="Observation.component.dataAbsentReason" />
      <min value="0" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Observation.component:pupil-symmetry">
      <path value="Observation.component" />
      <sliceName value="pupil-symmetry" />
      <min value="0" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Observation.component:pupil-symmetry.code">
      <path value="Observation.component.code" />
      <patternCodeableConcept>
        <coding>
          <system value="http://example.org/fhir/CodeSystem/pupil" />
          <code value="pupil-symmetry" />
          <display value="Pupillary symmetry" />
        </coding>
      </patternCodeableConcept>
    </element>
    <element id="Observation.component:pupil-symmetry.value[x]">
      <path value="Observation.component.value[x]" />
      <min value="0" />
      <max value="1" />
      <type>
        <code value="CodeableConcept" />
      </type>
      <mustSupport value="true" />
      <binding>
        <strength value="required" />
        <valueSet value="http://example.org/fhir/ValueSet/MII-PR-VS-PupillarySymmetry" />
      </binding>
    </element>
    <element id="Observation.component:pupil-symmetry.dataAbsentReason">
      <path value="Observation.component.dataAbsentReason" />
      <min value="0" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Observation.component:pupil-size-right-eye">
      <path value="Observation.component" />
      <sliceName value="pupil-size-right-eye" />
      <min value="0" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Observation.component:pupil-size-right-eye.code">
      <path value="Observation.component.code" />
      <patternCodeableConcept>
        <coding>
          <system value="http://example.org/fhir/CodeSystem/pupil" />
          <code value="pupil-size-right-eye" />
          <display value="Pupil size (right eye)" />
        </coding>
      </patternCodeableConcept>
    </element>
    <element id="Observation.component:pupil-size-right-eye.value[x]">
      <path value="Observation.component.value[x]" />
      <min value="0" />
      <max value="1" />
      <type>
        <code value="CodeableConcept" />
      </type>
      <mustSupport value="true" />
      <binding>
        <strength value="required" />
        <valueSet value="http://example.org/fhir/ValueSet/MII-PR-VS-PupilSizeQuantitative" />
      </binding>
    </element>
    <element id="Observation.component:pupil-size-right-eye.dataAbsentReason">
      <path value="Observation.component.dataAbsentReason" />
      <min value="0" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Observation.component:pupil-size-left-eye">
      <path value="Observation.component" />
      <sliceName value="pupil-size-left-eye" />
      <min value="0" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Observation.component:pupil-size-left-eye.code">
      <path value="Observation.component.code" />
      <patternCodeableConcept>
        <coding>
          <system value="http://example.org/fhir/CodeSystem/pupil" />
          <code value="pupil-size-left-eye" />
          <display value="Pupil size (left eye)" />
        </coding>
      </patternCodeableConcept>
    </element>
    <element id="Observation.component:pupil-size-left-eye.value[x]">
      <path value="Observation.component.value[x]" />
      <min value="0" />
      <max value="1" />
      <type>
        <code value="CodeableConcept" />
      </type>
      <mustSupport value="true" />
      <binding>
        <strength value="required" />
        <valueSet value="http://example.org/fhir/ValueSet/MII-PR-VS-PupilSizeQuantitative" />
      </binding>
    </element>
    <element id="Observation.component:pupil-size-left-eye.dataAbsentReason">
      <path value="Observation.component.dataAbsentReason" />
      <min value="0" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Observation.component:pupil-shape-right-eye">
      <path value="Observation.component" />
      <sliceName value="pupil-shape-right-eye" />
      <min value="0" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Observation.component:pupil-shape-right-eye.code">
      <path value="Observation.component.code" />
      <patternCodeableConcept>
        <coding>
          <system value="http://example.org/fhir/CodeSystem/pupil" />
          <code value="pupil-shape-right-eye" />
          <display value="Pupil shape (right eye)" />
        </coding>
      </patternCodeableConcept>
    </element>
    <element id="Observation.component:pupil-shape-right-eye.value[x]">
      <path value="Observation.component.value[x]" />
      <min value="0" />
      <max value="1" />
      <type>
        <code value="CodeableConcept" />
      </type>
      <mustSupport value="true" />
      <binding>
        <strength value="required" />
        <valueSet value="http://example.org/fhir/ValueSet/MII-PR-VS-PupillaryShape" />
      </binding>
    </element>
    <element id="Observation.component:pupil-shape-right-eye.dataAbsentReason">
      <path value="Observation.component.dataAbsentReason" />
      <min value="0" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Observation.component:pupil-shape-left-eye">
      <path value="Observation.component" />
      <sliceName value="pupil-shape-left-eye" />
      <min value="0" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Observation.component:pupil-shape-left-eye.code">
      <path value="Observation.component.code" />
      <patternCodeableConcept>
        <coding>
          <system value="http://example.org/fhir/CodeSystem/pupil" />
          <code value="pupil-shape-left-eye" />
          <display value="Pupil shape (left eye)" />
        </coding>
      </patternCodeableConcept>
    </element>
    <element id="Observation.component:pupil-shape-left-eye.value[x]">
      <path value="Observation.component.value[x]" />
      <min value="0" />
      <max value="1" />
      <type>
        <code value="CodeableConcept" />
      </type>
      <mustSupport value="true" />
      <binding>
        <strength value="required" />
        <valueSet value="http://example.org/fhir/ValueSet/MII-PR-VS-PupillaryShape" />
      </binding>
    </element>
    <element id="Observation.component:pupil-shape-left-eye.dataAbsentReason">
      <path value="Observation.component.dataAbsentReason" />
      <min value="0" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Observation.component:direct-light-reflex-right-eye">
      <path value="Observation.component" />
      <sliceName value="direct-light-reflex-right-eye" />
      <min value="0" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Observation.component:direct-light-reflex-right-eye.code">
      <path value="Observation.component.code" />
      <patternCodeableConcept>
        <coding>
          <system value="http://example.org/fhir/CodeSystem/pupil" />
          <code value="direct-light-reflex-right-eye" />
          <display value="Direct light reflex (right eye)" />
        </coding>
      </patternCodeableConcept>
    </element>
    <element id="Observation.component:direct-light-reflex-right-eye.value[x]">
      <path value="Observation.component.value[x]" />
      <min value="0" />
      <max value="1" />
      <type>
        <code value="boolean" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="Observation.component:direct-light-reflex-right-eye.dataAbsentReason">
      <path value="Observation.component.dataAbsentReason" />
      <min value="0" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Observation.component:direct-light-reflex-left-eye">
      <path value="Observation.component" />
      <sliceName value="direct-light-reflex-left-eye" />
      <min value="0" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Observation.component:direct-light-reflex-left-eye.code">
      <path value="Observation.component.code" />
      <patternCodeableConcept>
        <coding>
          <system value="http://example.org/fhir/CodeSystem/pupil" />
          <code value="direct-light-reflex-left-eye" />
          <display value="Direct light reflex (left eye)" />
        </coding>
      </patternCodeableConcept>
    </element>
    <element id="Observation.component:direct-light-reflex-left-eye.value[x]">
      <path value="Observation.component.value[x]" />
      <min value="0" />
      <max value="1" />
      <type>
        <code value="boolean" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="Observation.component:direct-light-reflex-left-eye.dataAbsentReason">
      <path value="Observation.component.dataAbsentReason" />
      <min value="0" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Observation.component:consensual-light-reflex-right-eye">
      <path value="Observation.component" />
      <sliceName value="consensual-light-reflex-right-eye" />
      <min value="0" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Observation.component:consensual-light-reflex-right-eye.code">
      <path value="Observation.component.code" />
      <patternCodeableConcept>
        <coding>
          <system value="http://example.org/fhir/CodeSystem/pupil" />
          <code value="consensual-light-reflex-right-eye" />
          <display value="Consensual light reflex (right eye)" />
        </coding>
      </patternCodeableConcept>
    </element>
    <element id="Observation.component:consensual-light-reflex-right-eye.value[x]">
      <path value="Observation.component.value[x]" />
      <min value="0" />
      <max value="1" />
      <type>
        <code value="boolean" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="Observation.component:consensual-light-reflex-right-eye.dataAbsentReason">
      <path value="Observation.component.dataAbsentReason" />
      <min value="0" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Observation.component:consensual-light-reflex-left-eye">
      <path value="Observation.component" />
      <sliceName value="consensual-light-reflex-left-eye" />
      <min value="0" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Observation.component:consensual-light-reflex-left-eye.code">
      <path value="Observation.component.code" />
      <patternCodeableConcept>
        <coding>
          <system value="http://example.org/fhir/CodeSystem/pupil" />
          <code value="consensual-light-reflex-left-eye" />
          <display value="Consensual light reflex (left eye)" />
        </coding>
      </patternCodeableConcept>
    </element>
    <element id="Observation.component:consensual-light-reflex-left-eye.value[x]">
      <path value="Observation.component.value[x]" />
      <min value="0" />
      <max value="1" />
      <type>
        <code value="boolean" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="Observation.component:consensual-light-reflex-left-eye.dataAbsentReason">
      <path value="Observation.component.dataAbsentReason" />
      <min value="0" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
  </differential>
</StructureDefinition>