<StructureDefinition xmlns="http://hl7.org/fhir">
  <id value="fiphr-sd-bloodglucose" />
  <meta>
    <versionId value="2" />
    <lastUpdated value="2023-03-02T10:22:22.4520081+00:00" />
  </meta>
  <url value="http://phr.kanta.fi/StructureDefinition/fiphr-sd-bloodglucose" />
  <version value="1.0.0" />
  <name value="FIPHRSDBloodglucose" />
  <title value="Finnish PHR Blood Glucose profile" />
  <status value="active" />
  <experimental value="false" />
  <description value="Finnish PHR profile for blood glucose measurement." />
  <purpose value="Finnish PHR profile for Observation used in blood glucose measurements. The profile is based on the Finnish PHR observation profile." />
  <fhirVersion value="4.0.1" />
  <kind value="resource" />
  <abstract value="false" />
  <type value="Observation" />
  <baseDefinition value="http://phr.kanta.fi/StructureDefinition/fiphr-sd-vitalsigns" />
  <derivation value="constraint" />
  <snapshot />
  <differential>
    <element id="Observation">
      <path value="Observation" />
      <short value="Finnish PHR Blood Glucose profile" />
      <definition value="Finnish PHR profile for Observation used in blood glucose measurements. The profile is based on the Finnish PHR observation profile." />
      <comment value="." />
      <constraint>
        <key value="PHR-1" />
        <severity value="error" />
        <human value="Resource SHALL contain code '15074-8' or '14743-9' or '14745-4'" />
        <expression value="(code.coding.where(code='15074-8').exists()) or (code.coding.where(code='14743-9').exists()) or (code.coding.where(code='14745-4').exists())" />
      </constraint>
      <constraint>
        <key value="PHR-2" />
        <severity value="error" />
        <human value="When using code '15074-8' also code '14743-9' SHALL be used" />
        <expression value="code.coding.where(code='15074-8').exists() implies code.coding.where(code='14743-9').exists()" />
      </constraint>
      <constraint>
        <key value="PHR-3" />
        <severity value="error" />
        <human value="When using code '14743-9' also code '15074-8' SHALL be used" />
        <expression value="code.coding.where(code='14743-9').exists() implies code.coding.where(code='15074-8').exists()" />
      </constraint>
    </element>
    <element id="Observation.meta">
      <path value="Observation.meta" />
    </element>
    <element id="Observation.meta.profile">
      <path value="Observation.meta.profile" />
    </element>
    <element id="Observation.meta.profile:fiphrProfile">
      <path value="Observation.meta.profile" />
      <sliceName value="fiphrProfile" />
      <fixedCanonical value="http://phr.kanta.fi/StructureDefinition/fiphr-sd-bloodglucose" />
    </element>
    <element id="Observation.extension">
      <path value="Observation.extension" />
      <slicing>
        <discriminator>
          <type value="value" />
          <path value="url" />
        </discriminator>
        <rules value="open" />
      </slicing>
      <min value="0" />
    </element>
    <element id="Observation.extension:hoursAfterMeal">
      <path value="Observation.extension" />
      <sliceName value="hoursAfterMeal" />
      <short value="Meal context" />
      <definition value="Meal context, how many hours after meal measurement is done." />
      <requirements value="Meal context needed for result interpretation." />
      <min value="0" />
      <max value="1" />
      <type>
        <code value="Extension" />
        <profile value="http://phr.kanta.fi/StructureDefinition/fiphr-unsignedint" />
      </type>
    </element>
    <element id="Observation.code.coding">
      <path value="Observation.code.coding" />
      <slicing>
        <discriminator>
          <type value="value" />
          <path value="code" />
        </discriminator>
        <discriminator>
          <type value="value" />
          <path value="system" />
        </discriminator>
        <rules value="open" />
      </slicing>
      <short value="Code to be used with CGM readings" />
      <definition value="This code SHALL be used with CGM readings." />
      <comment value="This code SHALL be used with CGM readings. Ordering of codings is undefined and SHALL NOT be used to infer meaning." />
      <min value="1" />
      <constraint>
        <key value="PHR-1" />
        <severity value="error" />
        <human value="When using code '15074-8' or '14743-9' or '14745-4' system http://loinc.org SHALL be used" />
        <expression value="(where(code='15074-8').exists()) or (where(code='14743-9').exists()) or (where(code='14745-4').exists()) implies where(system=&quot;http://loinc.org&quot;).exists()" />
      </constraint>
    </element>
    <element id="Observation.code.coding:GlucoseInBlood">
      <path value="Observation.code.coding" />
      <sliceName value="GlucoseInBlood" />
      <max value="1" />
    </element>
    <element id="Observation.code.coding:GlucoseInBlood.system">
      <path value="Observation.code.coding.system" />
      <min value="1" />
      <fixedUri value="http://loinc.org" />
    </element>
    <element id="Observation.code.coding:GlucoseInBlood.code">
      <path value="Observation.code.coding.code" />
      <min value="1" />
      <fixedCode value="15074-8" />
    </element>
    <element id="Observation.code.coding:GlucoseInBlood.display">
      <path value="Observation.code.coding.display" />
      <min value="1" />
    </element>
    <element id="Observation.code.coding:GlucoseInCapillaryBloodByGlucometer">
      <path value="Observation.code.coding" />
      <sliceName value="GlucoseInCapillaryBloodByGlucometer" />
      <max value="1" />
    </element>
    <element id="Observation.code.coding:GlucoseInCapillaryBloodByGlucometer.system">
      <path value="Observation.code.coding.system" />
      <min value="1" />
      <fixedUri value="http://loinc.org" />
    </element>
    <element id="Observation.code.coding:GlucoseInCapillaryBloodByGlucometer.code">
      <path value="Observation.code.coding.code" />
      <min value="1" />
      <fixedCode value="14743-9" />
    </element>
    <element id="Observation.code.coding:GlucoseInCapillaryBloodByGlucometer.display">
      <path value="Observation.code.coding.display" />
      <min value="1" />
    </element>
    <element id="Observation.code.coding:GlucoseInBodyFluid">
      <path value="Observation.code.coding" />
      <sliceName value="GlucoseInBodyFluid" />
      <max value="1" />
    </element>
    <element id="Observation.code.coding:GlucoseInBodyFluid.system">
      <path value="Observation.code.coding.system" />
      <min value="1" />
      <fixedUri value="http://loinc.org" />
    </element>
    <element id="Observation.code.coding:GlucoseInBodyFluid.code">
      <path value="Observation.code.coding.code" />
      <min value="1" />
      <fixedCode value="14745-4" />
    </element>
    <element id="Observation.code.coding:GlucoseInBodyFluid.display">
      <path value="Observation.code.coding.display" />
      <min value="1" />
    </element>
    <element id="Observation.effective[x]">
      <path value="Observation.effective[x]" />
      <slicing>
        <discriminator>
          <type value="type" />
          <path value="$this" />
        </discriminator>
        <rules value="open" />
      </slicing>
    </element>
    <element id="Observation.effective[x]:effectiveDateTime">
      <path value="Observation.effective[x]" />
      <sliceName value="effectiveDateTime" />
    </element>
    <element id="Observation.value[x]">
      <path value="Observation.value[x]" />
      <short value="FinnishPHR: Glucose in blood" />
      <definition value="FinnishPHR: Glucose in blood" />
      <type>
        <code value="Quantity" />
      </type>
    </element>
    <element id="Observation.value[x].extension">
      <path value="Observation.value[x].extension" />
      <slicing>
        <discriminator>
          <type value="value" />
          <path value="url" />
        </discriminator>
        <rules value="open" />
      </slicing>
      <min value="0" />
    </element>
    <element id="Observation.value[x].extension:alternativeQuantity">
      <path value="Observation.value[x].extension" />
      <sliceName value="alternativeQuantity" />
      <min value="0" />
      <max value="1" />
      <type>
        <code value="Extension" />
        <profile value="http://phr.kanta.fi/StructureDefinition/fiphr-ext-pq-translation" />
      </type>
    </element>
    <element id="Observation.value[x].extension:alternativeQuantity.value[x].system">
      <path value="Observation.value[x].extension.value[x].system" />
      <fixedUri value="http://unitsofmeasure.org" />
    </element>
    <element id="Observation.value[x].value">
      <path value="Observation.value[x].value" />
      <min value="1" />
    </element>
    <element id="Observation.value[x].unit">
      <path value="Observation.value[x].unit" />
      <min value="1" />
      <fixedString value="mmol/l" />
    </element>
    <element id="Observation.value[x].system">
      <path value="Observation.value[x].system" />
      <min value="1" />
      <fixedUri value="http://unitsofmeasure.org" />
    </element>
    <element id="Observation.value[x].code">
      <path value="Observation.value[x].code" />
      <min value="1" />
      <fixedCode value="mmol/L" />
    </element>
    <element id="Observation.dataAbsentReason">
      <path value="Observation.dataAbsentReason" />
      <definition value="Provides a reason why the expected value in the element Observation.value[x] is missing. &#xD;&#xA;Finnish PHR: Codes 'astext' and 'error' are allowed, no other codes." />
      <comment value="Finnish PHR: Code 'error' SHALL be used when a device has been actively trying to measure the blood glucose but has failed for some reason. Code 'astext' SHALL be used when the measured value cannot be stored using the valueQuantity structure (with the comparator). In this case, the value SHALL be presented in the resource narrative. No other codes are allowed." />
    </element>
    <element id="Observation.dataAbsentReason.coding">
      <path value="Observation.dataAbsentReason.coding" />
      <min value="1" />
    </element>
    <element id="Observation.dataAbsentReason.coding.code">
      <path value="Observation.dataAbsentReason.coding.code" />
      <comment value="Note that FHIR strings may not exceed 1MB in size. &#xD;&#xA;Finnish PHR: Code 'error' SHALL be used when a device has been actively trying to measure the blood glucose but has failed for some reason. Code 'astext' SHALL be used when the measured value cannot be stored using the valueQuantity structure (with the comparator). In this case, the value SHALL be presented in the resource narrative. No other codes are allowed." />
    </element>
    <element id="Observation.component">
      <path value="Observation.component" />
      <max value="0" />
    </element>
  </differential>
</StructureDefinition>