<StructureDefinition xmlns="http://hl7.org/fhir">
  <id value="NHSHC-Observation-Laboratory" />
  <url value="https://fhir.nhs.uk/StructureDefinition/NHSHC-Observation-Laboratory" />
  <version value="0.1.0" />
  <name value="NHSHCObservationLaboratory" />
  <title value="NHSHC Observation - Laboratory" />
  <status value="draft" />
  <date value="2026-07-30" />
  <publisher value="NHS England" />
  <description value="Derived profile from NHSHC-Observation for laboratory results in NHS Health Check Online. Constrains category to laboratory and provides code slices for cholesterol panel, serum cholesterol, HDL cholesterol, cholesterol ratio, and HbA1c with its component." />
  <fhirVersion value="4.0.1" />
  <kind value="resource" />
  <abstract value="false" />
  <type value="Observation" />
  <baseDefinition value="https://fhir.nhs.uk/StructureDefinition/NHSHC-Observation" />
  <derivation value="constraint" />
  <differential>
    <element id="Observation">
      <path value="Observation" />
      <constraint>
        <key value="nhshc-lab-1" />
        <severity value="error" />
        <human value="At least one of value[x], dataAbsentReason, component, or hasMember must be present." />
        <expression value="value.exists() or dataAbsentReason.exists() or component.exists() or hasMember.exists()" />
      </constraint>
    </element>
    <element id="Observation.status">
      <path value="Observation.status" />
      <min value="1" />
      <fixedCode value="final" />
    </element>
    <element id="Observation.category">
      <path value="Observation.category" />
      <min value="1" />
      <patternCodeableConcept>
        <coding>
          <system value="http://terminology.hl7.org/CodeSystem/observation-category" />
          <code value="laboratory" />
        </coding>
      </patternCodeableConcept>
    </element>
    <element id="Observation.code">
      <path value="Observation.code" />
      <min value="1" />
      <binding>
        <strength value="required" />
        <valueSet value="https://fhir.nhs.uk/ValueSet/NHSHC-LaboratoryCode" />
      </binding>
    </element>
    <element id="Observation.subject">
      <path value="Observation.subject" />
      <min value="1" />
      <type>
        <code value="Reference" />
        <targetProfile value="https://fhir.hl7.org.uk/StructureDefinition/UKCore-Patient" />
      </type>
    </element>
    <element id="Observation.encounter">
      <path value="Observation.encounter" />
      <min value="1" />
      <type>
        <code value="Reference" />
        <targetProfile value="https://fhir.nhs.uk/StructureDefinition/NHSHC-Encounter" />
      </type>
    </element>
    <element id="Observation.effective[x]">
      <path value="Observation.effective[x]" />
      <min value="1" />
    </element>
    <element id="Observation.performer">
      <path value="Observation.performer" />
      <min value="1" />
      <type>
        <code value="Reference" />
        <targetProfile value="https://fhir.hl7.org.uk/StructureDefinition/UKCore-Organization" />
        <targetProfile value="https://fhir.hl7.org.uk/StructureDefinition/UKCore-Practitioner" />
      </type>
    </element>
    <element id="Observation.component">
      <path value="Observation.component" />
      <slicing>
        <discriminator>
          <type value="pattern" />
          <path value="code" />
        </discriminator>
        <description value="Slice by HbA1c component" />
        <rules value="open" />
      </slicing>
    </element>
    <element id="Observation.component:hba1cLevel">
      <path value="Observation.component" />
      <sliceName value="hba1cLevel" />
      <min value="0" />
      <max value="1" />
    </element>
    <element id="Observation.component:hba1cLevel.code">
      <path value="Observation.component.code" />
      <binding>
        <strength value="required" />
        <valueSet value="https://fhir.nhs.uk/ValueSet/NHSHC-HbA1cComponentCode" />
      </binding>
    </element>
  </differential>
</StructureDefinition>