<StructureDefinition xmlns="http://hl7.org/fhir">
  <id value="digidot-Patient-no" />
  <text>
    <status value="generated" />
    <div xmlns="http://www.w3.org/1999/xhtml">
      <p>Patient health-group history consists of non-overlapping classification periods. Health-group assignments are optional. A birth date without an assignment produces a validation warning; the application workflow determines when assignment is required. The classification applicable on a date is derived from the period covering that date. Encounter retains its own contact-specific value.</p>
    </div>
  </text>
  <url value="https://novari.no/fhir/digidot/StructureDefinition/digidot-Patient-no" />
  <version value="0.2.3" />
  <name value="DigidotPatientNo" />
  <title value="DigiDOT Patient (NO)" />
  <status value="draft" />
  <experimental value="false" />
  <date value="2026-11-27" />
  <publisher value="Novari AS - DigiDOT" />
  <description value="Readiness: [In development](https://simplifier.net/guide/Visual-overview/Home/Review-status-and-releases.page.md?version=current#readiness-patient).&#xA;&#xA;Profile base: no-basis-Patient (hl7.fhir.no.basis 2.2.2) (http://hl7.no/fhir/StructureDefinition/no-basis-Patient).&#xA;&#xA;Patient identity and health-group history for DigiDOT. Adds selected health-group assignments with non-overlapping validity periods. Health-group assignments are optional. A birth date without an assignment produces a validation warning; the application workflow determines when assignment is required. Other Patient fields follow no-basis Patient." />
  <purpose value="Use when exchanging a Patient and any established health-group assignments, including patients whose birth date and health group are not yet known. Preserve all known periods during updates; a change registered today may apply from a different date. Resource versioning records edits and does not replace assignment validity periods. The receiving service must validate the complete updated Patient, coordinate writes with the MPI, and prevent lost updates between EHRs. Age-based defaults require agreed calendar-year, priority and source rules and must not overwrite a still-applicable special classification. This profile does not calculate eligibility or payment. Other Patient fields retain the no-basis rules. DigiDOT resource profiles use this profile as their Patient reference target. References still identify Patient resources; they do not create a copy of the patient or automatically copy health groups to Encounter. Validation of a referenced Patient requires access to that resource and the applicable definitions." />
  <fhirVersion value="4.0.1" />
  <kind value="resource" />
  <abstract value="false" />
  <type value="Patient" />
  <baseDefinition value="http://hl7.no/fhir/StructureDefinition/no-basis-Patient" />
  <derivation value="constraint" />
  <differential>
    <element id="Patient">
      <path value="Patient" />
      <short value="no-basis Patient with non-overlapping health-group periods" />
      <constraint>
        <key value="patient-health-group-if-birthdate" />
        <severity value="warning" />
        <human value="A Patient with a birth date should have at least one health-group assignment." />
        <expression value="birthDate.where(hasValue()).exists() implies extension.where(url = 'https://novari.no/fhir/digidot/StructureDefinition/digidot-PatientHealthGroup-no').exists()" />
        <source value="https://novari.no/fhir/digidot/StructureDefinition/digidot-Patient-no" />
      </constraint>
    </element>
    <element id="Patient.extension">
      <path value="Patient.extension" />
      <slicing>
        <discriminator>
          <type value="value" />
          <path value="url" />
        </discriminator>
        <rules value="open" />
      </slicing>
      <min value="0" />
    </element>
    <element id="Patient.extension:healthGroup">
      <path value="Patient.extension" />
      <sliceName value="healthGroup" />
      <short value="Selected health-group assignments with non-overlapping validity periods" />
      <definition value="Known health-group periods. Assignments are optional. A Patient with a birth date and no assignment produces a validation warning, not an error. The application workflow determines when assignment is required and handles derivation failures. Known assignments may also be recorded without a birth date. At most one selected classification can apply on any date. Preserve historical periods and select the applicable group by date, not by array order, latest registration or latest Encounter. A gap means that the classification is unknown for that date; do not insert a placeholder code." />
      <comment value="Atomic close-and-add operations and version-aware updates are API responsibilities. Backdated changes must be checked against the whole timeline. Corrections to historical assignments do not automatically rewrite Encounter classifications. A source/provenance record should identify who or which agreed rule produced an assignment." />
      <min value="0" />
      <max value="*" />
      <type>
        <code value="Extension" />
        <profile value="https://novari.no/fhir/digidot/StructureDefinition/digidot-PatientHealthGroup-no" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="Patient.extension:healthGroup.url">
      <path value="Patient.extension.url" />
      <fixedUri value="https://novari.no/fhir/digidot/StructureDefinition/digidot-PatientHealthGroup-no" />
    </element>
  </differential>
</StructureDefinition>