<StructureDefinition xmlns="http://hl7.org/fhir">
  <id value="vitalsign-bloodglucose" />
  <url value="http://nictiz.nl/fhir/StructureDefinition/vitalsign-bloodglucose" />
  <version value="1.0.6" />
  <name value="Vital Signs BloodGlucose" />
  <title value="VitalSigns BloodGlucose" />
  <status value="active" />
  <publisher value="Nictiz" />
  <contact>
    <name value="Nictiz" />
    <telecom>
      <system value="url" />
      <value value="https://www.nictiz.nl" />
      <use value="work" />
    </telecom>
  </contact>
  <description value="This profile represents a single blood glucose self measurement based on the seven-point scale (SMBG)." />
  <copyright value="CC0" />
  <fhirVersion value="3.0.2" />
  <kind value="resource" />
  <abstract value="false" />
  <type value="Observation" />
  <baseDefinition value="http://nictiz.nl/fhir/StructureDefinition/zib-LaboratoryTestResult-Observation" />
  <derivation value="constraint" />
  <differential>
    <element id="Observation">
      <path value="Observation" />
      <short value="FHIR Blood Glucose Profile" />
    </element>
    <element id="Observation.extension:eventTiming">
      <path value="Observation.extension" />
      <sliceName value="eventTiming" />
      <max value="1" />
      <type>
        <code value="Extension" />
        <profile value="http://hl7.org/fhir/StructureDefinition/observation-eventTiming" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="Observation.code">
      <path value="Observation.code" />
      <constraint>
        <key value="bg-1" />
        <severity value="error" />
        <human value="Observation.code SHALL have at least one coding based on LOINC" />
        <expression value="coding.where(system = 'http://loinc.org').exists()" />
        <xpath value="f:coding[f:system/@value = 'http://loinc.org']" />
      </constraint>
      <constraint>
        <key value="bg-2" />
        <severity value="error" />
        <human value="Observation.code MAY have a maximum of one coding based on NHG Table 45" />
        <expression value="coding.where(system = 'https://referentiemodel.nhg.org/tabellen/nhg-tabel-45-diagnostische-bepalingen').count() &lt;= 1" />
        <xpath value="count(f:coding[f:system/@value = 'https://referentiemodel.nhg.org/tabellen/nhg-tabel-45-diagnostische-bepalingen']) &lt;= 1" />
      </constraint>
    </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:LOINC">
      <path value="Observation.code.coding" />
      <sliceName value="LOINC" />
      <binding>
        <strength value="required" />
        <description value="GlucoseMeetmomentenLOINCCodelijst" />
        <valueSetReference>
          <reference value="http://decor.nictiz.nl/fhir/ValueSet/2.16.840.1.113883.2.4.3.11.60.53.11.1--20200618120422" />
          <display value="GlucoseMeetmomentenLOINCCodelijst" />
        </valueSetReference>
      </binding>
    </element>
    <element id="Observation.code.coding:LOINC.system">
      <path value="Observation.code.coding.system" />
      <fixedUri value="http://loinc.org" />
    </element>
    <element id="Observation.code.coding:NHGTable45">
      <path value="Observation.code.coding" />
      <sliceName value="NHGTable45" />
      <binding>
        <strength value="required" />
        <description value="GlucoseMeetmomentenNhgtable45Codelijst" />
        <valueSetReference>
          <reference value="http://decor.nictiz.nl/fhir/ValueSet/2.16.840.1.113883.2.4.3.11.60.53.11.2--20190813000000" />
          <display value="GlucoseMeetmomentenNhgtable45Codelijst" />
        </valueSetReference>
      </binding>
    </element>
    <element id="Observation.code.coding:NHGTable45.system">
      <path value="Observation.code.coding.system" />
      <fixedUri value="https://referentiemodel.nhg.org/tabellen/nhg-tabel-45-diagnostische-bepalingen" />
    </element>
    <element id="Observation.value[x]">
      <path value="Observation.value[x]" />
      <comment value="Known issue: this profile does not constrain the units allowed in `.valueQuantity`. When exchanging data based on [NHG Table 45](https://referentiemodel.nhg.org/tabellen/nhg-tabel-45-diagnostische-bepalingen), it is expected that `.code` equals 'mmol/L'. See &lt;https://bits.nictiz.nl/browse/MM-2607&gt; for more details." />
      <type>
        <code value="Quantity" />
      </type>
    </element>
  </differential>
</StructureDefinition>