<StructureDefinition xmlns="http://hl7.org/fhir">
  <id value="hddt-lung-reference-value" />
  <url value="https://gematik.de/fhir/hddt/StructureDefinition/hddt-lung-reference-value" />
  <version value="1.0.1" />
  <name value="HddtLungFunctionReferenceValue" />
  <title value="Observation – Lung Function Reference Value" />
  <status value="active" />
  <date value="2026-04-29" />
  <publisher value="gematik GmbH" />
  <description value="Profile for capturing the refence values as a FHIR Observation resource when evaluating lung function testings.&#xA;&#xA;This profile defines the exchange of a single reference value for the Mandatory Interoperable Value (MIV) \&quot;Lung Function Testing\&quot; which is technically defined &#xA;by the ValueSet _hddt-miv-lung-function-testing_. This MIV is e.g. implemented by peak flow meter that can connect to &#xA;a Personal Health Gateway (e.g. a mobile app for tracking lung function values) through wireless or wired communication.&#xA;&#xA;**Obligations and Conventions:**&#xA;&#xA;Each Lung Function Testing MAY 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). Typically the reference will be &#xA;to a [Device](https://hl7.org/fhir/R4/device.html) resource, but the option to reference a [DeviceMetric](https://hl7.org/fhir/R4/devicemetric.html) &#xA;resource is provided for compatibility with the overarching HDDT specification.&#xA;&#xA;**Constraints applied:**  &#xA;- `code` is constrained to a subset of the _MIV Lung Function Reference Values_ ValueSet, defined by the _HddtLungFunctionReferenceValues_ ValueSet.&#xA;- `effective[x]` is restricted to `effectivePeriod` 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;- `method` is considered mandatory in order to provide information about the method used to determine the reference value. It can be either a code from the _HddtLungFunctionReferenceValueMethod_ ValueSet or a text description." />
  <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="Reference measurement type for lung function" />
      <binding>
        <strength value="required" />
        <description value="Specifies for which measurement type the reference value is, using codes from the ValueSet for lung function testings. Constrained via invariant to either PEF or FEV1." />
        <valueSet value="https://gematik.de/fhir/hddt/ValueSet/hddt-lung-function-reference-values" />
      </binding>
    </element>
    <element id="Observation.effective[x]">
      <path value="Observation.effective[x]" />
      <short value="Time period for which reference value is valid" />
      <definition value="The time period for which the lung function reference value is valid. If the reference value is still active, then only the start of the period is provided." />
      <type>
        <code value="Period" />
      </type>
    </element>
    <element id="Observation.value[x]">
      <path value="Observation.value[x]" />
      <short value="Reference lung function value" />
      <definition value="The quantitative reference value, measured either in liters (L) for FEV1 or liters per minute (L/min) for PEF, 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 lung function testing. 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.method">
      <path value="Observation.method" />
      <short value="Method for determining the reference value" />
      <definition value="The method used to determine the lung function reference value. Preferred is the usage of a code from the Lung Function Reference Value Method ValueSet, but as an alternative a text description of the used formula for calculating the reference value can be provided." />
      <mustSupport value="true" />
    </element>
    <element id="Observation.method.coding">
      <path value="Observation.method.coding" />
      <max value="1" />
      <binding>
        <strength value="required" />
        <description value="Specifies the method used to determine the lung function reference value using codes from the Lung Function Reference Value Method ValueSet." />
        <valueSet value="https://gematik.de/fhir/hddt/ValueSet/hddt-lung-function-reference-value-method-codes" />
      </binding>
    </element>
    <element id="Observation.method.text">
      <path value="Observation.method.text" />
      <definition value="In case no code is provided, specify whether the value is a personal best or predicted or calculated based on some formula." />
    </element>
    <element id="Observation.device">
      <path value="Observation.device" />
      <short value="Reference to personal health device" />
      <definition value="References a Device resource that describes the personal health device." />
      <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>