<StructureDefinition xmlns="http://hl7.org/fhir">
  <id value="hddt-blood-glucose-measurement" />
  <url value="https://gematik.de/fhir/hddt/StructureDefinition/hddt-blood-glucose-measurement" />
  <version value="1.0.1" />
  <name value="HddtBloodGlucoseMeasurement" />
  <title value="Observation – Blood Glucose Measurement" />
  <status value="active" />
  <date value="2026-04-29" />
  <publisher value="gematik GmbH" />
  <description value="Profile for capturing blood glucose measurements as FHIR Observation resources.&#xA;&#xA;This profile defines the exchange of a single measurement data for the Mandatory Interoperable Value (MIV) \&quot;Blood Glucose Measurement\&quot; which is technically defined &#xA;by the ValueSet _hddt-miv-blood-glucose-measurement_. This MIV is e.g. implemented by blood glucose meter (glucometer) that can connect to &#xA;a Personal Health Gateway (e.g. a mobile app for keeping diabetes diary) through wireless or wired communication.&#xA;&#xA;**Obligations and Conventions:**&#xA;&#xA;Each Blood Glucose Measurement MUST either hold a reference to a _Sensor Type And Calibration Status_ [DeviceMetric](https://hl7.org/fhir/R4/devicemetric.html) resource or to a &#xA;_Personal Health Device_ [Device](https://hl7.org/fhir/R4/device.html) resource (eXclusive OR). A reference to _Sensor Type And Calibration Status_ MUST be provided &#xA;from the Observation resource if the sensor for measuring blood glucose needs to be calibrated (either automatically or by the user) &#xA;or if the sensor may change its calibration status over time. &#xA;&#xA;**Constraints applied:**  &#xA;- `code` is constrained to the ValueSet that represents the MIV _Blood Glucose Measurement_&#xA;- `effective[x]` is restricted to `effectiveDateTime` and constrained as mandatory.&#xA;- `value[x]` is restricted to `valueQuantity`. The elements `valueQuantity.value`, `valueQuantity.system`, and `valueQuantity.code` are constrained in a way that a value MUST be provided and that UCUM MUST be used for encoding the unit of measurement. `Observation.valueQuantity` MAY only be omitted in case of an error that accured with the measurement. In this case, `Observation.dataAbsentReason` MUST be provided.&#xA;- `device` is set to be mandatory in order to provide the DiGA with information about the sensor's calibration status and with information about the static and dynamic attributes of the Personal Health Device." />
  <copyright value="Copyright (c) 2026 gematik GmbH" />
  <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.code">
      <path value="Observation.code" />
      <short value="Measurement type of blood glucose" />
      <binding>
        <strength value="required" />
        <description value="Specifies the type of measurement using codes from the ValueSet for blood glucose measurements." />
        <valueSet value="https://gematik.de/fhir/hddt/ValueSet/hddt-miv-blood-glucose-measurement" />
      </binding>
    </element>
    <element id="Observation.effective[x]">
      <path value="Observation.effective[x]" />
      <short value="Time of measurement" />
      <definition value="The time or period when the blood glucose measurement was taken." />
      <min value="1" />
      <type>
        <code value="dateTime" />
      </type>
    </element>
    <element id="Observation.value[x]">
      <path value="Observation.value[x]" />
      <short value="Measured blood glucose value" />
      <definition value="The quantitative blood glucose value, measured either in mass/volume (mg/dL) or moles/volume (mmol/L), represented as a UCUM Quantity." />
      <type>
        <code value="Quantity" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="Observation.value[x].value">
      <path value="Observation.value[x].value" />
      <min value="1" />
    </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" />
      <definition value="The UCUM code representing the unit of the blood glucose measurement. The UCUM code MUST be compliant with the example unit that is linked with the LOINC code given as `Observation.code`." />
      <min value="1" />
      <binding>
        <strength value="required" />
        <description value="Defines the unit of measurement using codes from the UCUM units ValueSet. The UCUM code MUST be compliant with the unit that is linked with the LOINC code given as `Observation.code`." />
        <valueSet value="http://hl7.org/fhir/ValueSet/ucum-units" />
      </binding>
    </element>
    <element id="Observation.device">
      <path value="Observation.device" />
      <short value="Reference to personal health device or its sensor type and calibration status" />
      <definition value="References a DeviceMetric resource that describes the sensor type and calibration status of the personal health device or reference to the Device resource that describes the personal health device itself." />
      <min value="1" />
      <type>
        <code value="Reference" />
        <targetProfile value="https://gematik.de/fhir/hddt/StructureDefinition/hddt-personal-health-device" />
        <targetProfile value="https://gematik.de/fhir/hddt/StructureDefinition/hddt-sensor-type-and-calibration-status" />
      </type>
    </element>
  </differential>
</StructureDefinition>