﻿<?xml version="1.0" encoding="utf-8"?>
<StructureDefinition xmlns="http://hl7.org/fhir">
  <id value="apgar-score" />
  <url value="http://hl7.org.au/fhir/ch/StructureDefinition/apgar-score" />
  <name value="APGARScore" />
  <title value="APGAR Score" />
  <status value="draft" />
  <date value="2018-09-15" />
  <fhirVersion value="3.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="APGAR Score Observation" />
      <constraint>
        <key value="inv-apgar01" />
        <severity value="error" />
        <human value="APGAR 1 minute component codes must match observation type" />
        <expression value="(component.where(code.coding.where(code='32406-1').exists()).exists() or component.where(code.coding.where(code='32407-9').exists()).exists() or component.where(code.coding.where(code='32408-7').exists()).exists() or component.where(code.coding.where(code='32410-3').exists()).exists() or component.where(code.coding.where(code='32409-5').exists()).exists()) implies code.coding.where(code='9272-6').exists() " />
      </constraint>
      <constraint>
        <key value="inv-apgar02" />
        <severity value="error" />
        <human value="APGAR 5 minute component codes must match observation type" />
        <expression value="(component.where(code.coding.where(code='32406-1').exists()).exists() or component.where(code.coding.where(code='32407-9').exists()).exists() or component.where(code.coding.where(code='32408-7').exists()).exists() or component.where(code.coding.where(code='32410-3').exists()).exists() or component.where(code.coding.where(code='32409-5').exists()).exists()) implies code.coding.where(code='9272-6').exists() " />
      </constraint>
      <constraint>
        <key value="inv-apgar03" />
        <severity value="error" />
        <human value="APGAR 10 minute component codes must match observation type" />
        <expression value="(component.where(code.coding.where(code='32401-2').exists()).exists() or component.where(code.coding.where(code='32402-0').exists()).exists() or component.where(code.coding.where(code='32403-8').exists()).exists() or component.where(code.coding.where(code='32405-3').exists()).exists() or component.where(code.coding.where(code='32404-6').exists()).exists()) implies code.coding.where(code='9271-8').exists() " />
      </constraint>
    </element>
    <element id="Observation.code">
      <path value="Observation.code" />
      <short value="APGAR score observation type" />
    </element>
    <element id="Observation.code.coding">
      <path value="Observation.code.coding" />
      <slicing>
        <discriminator>
          <type value="value" />
          <path value="system" />
        </discriminator>
        <rules value="open" />
      </slicing>
      <min value="1" />
    </element>
    <element id="Observation.code.coding:loincScoreType">
      <path value="Observation.code.coding" />
      <sliceName value="loincScoreType" />
      <min value="1" />
      <max value="1" />
      <binding>
        <strength value="required" />
        <description value="APGAR score type" />
        <valueSetReference>
          <reference value="http://hl7.org.au/fhir/ch/v1/ValueSet/apgar-score-type" />
        </valueSetReference>
      </binding>
    </element>
    <element id="Observation.code.coding:snomedScoreType">
      <path value="Observation.code.coding" />
      <sliceName value="snomedScoreType" />
      <max value="1" />
      <binding>
        <strength value="example" />
        <description value="APGAR score observation type (SNOMED CT)" />
        <valueSetReference>
          <reference value="http://hl7.org.au/fhir/ch/v1/ValueSet/apgar-score-type-snomedct" />
        </valueSetReference>
      </binding>
    </element>
    <element id="Observation.subject">
      <path value="Observation.subject" />
      <min value="1" />
      <type>
        <code value="Reference" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/Patient" />
      </type>
    </element>
    <element id="Observation.effective[x]:effectiveDateTime">
      <path value="Observation.effectiveDateTime" />
      <sliceName value="effectiveDateTime" />
      <type>
        <code value="dateTime" />
      </type>
    </element>
    <element id="Observation.value[x]:valueQuantity">
      <path value="Observation.valueQuantity" />
      <sliceName value="valueQuantity" />
      <type>
        <code value="Quantity" />
      </type>
    </element>
    <element id="Observation.value[x]:valueQuantity.value">
      <path value="Observation.valueQuantity.value" />
      <min value="1" />
    </element>
    <element id="Observation.value[x]:valueQuantity.system">
      <path value="Observation.valueQuantity.system" />
      <min value="1" />
      <fixedUri value="http://unitsofmeasure.org" />
    </element>
    <element id="Observation.value[x]:valueQuantity.code">
      <path value="Observation.valueQuantity.code" />
      <min value="1" />
      <fixedCode value="{score}" />
    </element>
    <element id="Observation.component">
      <path value="Observation.component" />
      <slicing>
        <discriminator>
          <type value="value" />
          <path value="code" />
        </discriminator>
        <rules value="open" />
      </slicing>
      <max value="5" />
    </element>
    <element id="Observation.component:colourScore">
      <path value="Observation.component" />
      <sliceName value="colourScore" />
      <short value="APGAR colour" />
      <max value="1" />
    </element>
    <element id="Observation.component:colourScore.code">
      <path value="Observation.component.code" />
      <binding>
        <extension url="http://hl7.org/fhir/StructureDefinition/elementdefinition-bindingName">
          <valueString value="ObservationCode" />
        </extension>
        <strength value="required" />
        <description value="Colour observation" />
        <valueSetReference>
          <reference value="http://hl7.org.au/fhir/ch/v1/ValueSet/apgar-colour" />
        </valueSetReference>
      </binding>
    </element>
    <element id="Observation.component:colourScore.value[x]:valueCodeableConcept">
      <path value="Observation.component.valueCodeableConcept" />
      <sliceName value="valueCodeableConcept" />
      <min value="1" />
      <type>
        <code value="CodeableConcept" />
      </type>
      <binding>
        <strength value="required" />
        <description value="Colour finding values" />
        <valueSetReference>
          <reference value="http://hl7.org.au/fhir/ch/v1/ValueSet/apgar-colour-finding" />
        </valueSetReference>
      </binding>
    </element>
    <element id="Observation.component:heartRateScore">
      <path value="Observation.component" />
      <sliceName value="heartRateScore" />
      <short value="APGAR heart rate" />
      <max value="1" />
    </element>
    <element id="Observation.component:heartRateScore.code">
      <path value="Observation.component.code" />
      <binding>
        <extension url="http://hl7.org/fhir/StructureDefinition/elementdefinition-bindingName">
          <valueString value="ObservationCode" />
        </extension>
        <strength value="required" />
        <description value="Heart rate observation" />
        <valueSetReference>
          <reference value="http://hl7.org.au/fhir/ch/v1/ValueSet/apgar-heart-rate" />
        </valueSetReference>
      </binding>
    </element>
    <element id="Observation.component:heartRateScore.value[x]:valueCodeableConcept">
      <path value="Observation.component.valueCodeableConcept" />
      <sliceName value="valueCodeableConcept" />
      <min value="1" />
      <type>
        <code value="CodeableConcept" />
      </type>
      <binding>
        <strength value="required" />
        <description value="Heart rate finding values" />
        <valueSetReference>
          <reference value="http://hl7.org.au/fhir/ch/v1/ValueSet/apgar-heart-rate-finding" />
        </valueSetReference>
      </binding>
    </element>
    <element id="Observation.component:muscleToneScore">
      <path value="Observation.component" />
      <sliceName value="muscleToneScore" />
      <short value="APGAR muscle tone" />
      <max value="1" />
    </element>
    <element id="Observation.component:muscleToneScore.code">
      <path value="Observation.component.code" />
      <binding>
        <extension url="http://hl7.org/fhir/StructureDefinition/elementdefinition-bindingName">
          <valueString value="ObservationCode" />
        </extension>
        <strength value="required" />
        <description value="Muscle tone observation" />
        <valueSetReference>
          <reference value="http://hl7.org.au/fhir/ch/v1/ValueSet/apgar-muscle-tone" />
        </valueSetReference>
      </binding>
    </element>
    <element id="Observation.component:muscleToneScore.value[x]:valueCodeableConcept">
      <path value="Observation.component.valueCodeableConcept" />
      <sliceName value="valueCodeableConcept" />
      <min value="1" />
      <type>
        <code value="CodeableConcept" />
      </type>
      <binding>
        <strength value="required" />
        <description value="Muscle tone finding values" />
        <valueSetReference>
          <reference value="http://hl7.org.au/fhir/ch/v1/ValueSet/apgar-muscle-tone-finding" />
        </valueSetReference>
      </binding>
    </element>
    <element id="Observation.component:respiratoryEffortScore">
      <path value="Observation.component" />
      <sliceName value="respiratoryEffortScore" />
      <short value="APGAR respiratory effort" />
      <max value="1" />
    </element>
    <element id="Observation.component:respiratoryEffortScore.code">
      <path value="Observation.component.code" />
      <binding>
        <extension url="http://hl7.org/fhir/StructureDefinition/elementdefinition-bindingName">
          <valueString value="ObservationCode" />
        </extension>
        <strength value="required" />
        <description value="Respiratory effort observation" />
        <valueSetReference>
          <reference value="http://hl7.org.au/fhir/ch/v1/ValueSet/apgar-respiratory-effort" />
        </valueSetReference>
      </binding>
    </element>
    <element id="Observation.component:respiratoryEffortScore.value[x]:valueCodeableConcept">
      <path value="Observation.component.valueCodeableConcept" />
      <sliceName value="valueCodeableConcept" />
      <min value="1" />
      <type>
        <code value="CodeableConcept" />
      </type>
      <binding>
        <strength value="required" />
        <description value="Respiratory effort finding values" />
        <valueSetReference>
          <reference value="http://hl7.org.au/fhir/ch/v1/ValueSet/apgar-respiratory-effort-finding" />
        </valueSetReference>
      </binding>
    </element>
    <element id="Observation.component:reflexIrritability">
      <path value="Observation.component" />
      <sliceName value="reflexIrritability" />
      <short value="APGAR reflex irritability" />
      <max value="1" />
    </element>
    <element id="Observation.component:reflexIrritability.code">
      <path value="Observation.component.code" />
      <binding>
        <extension url="http://hl7.org/fhir/StructureDefinition/elementdefinition-bindingName">
          <valueString value="ObservationCode" />
        </extension>
        <strength value="required" />
        <description value="Reflex irritability observation" />
        <valueSetReference>
          <reference value="http://hl7.org.au/fhir/ch/v1/ValueSet/apgar-reflex-irritability" />
        </valueSetReference>
      </binding>
    </element>
    <element id="Observation.component:reflexIrritability.value[x]:valueCodeableConcept">
      <path value="Observation.component.valueCodeableConcept" />
      <sliceName value="valueCodeableConcept" />
      <min value="1" />
      <type>
        <code value="CodeableConcept" />
      </type>
      <binding>
        <strength value="required" />
        <description value="Reflex irritability finding values" />
        <valueSetReference>
          <reference value="http://hl7.org.au/fhir/ch/v1/ValueSet/apgar-reflex-irritability-finding" />
        </valueSetReference>
      </binding>
    </element>
  </differential>
</StructureDefinition>