<StructureDefinition xmlns="http://hl7.org/fhir">
  <id value="ie-core-patient" />
  <url value="https://hl7-ie.github.io/ie-core/fhir/ie/core/StructureDefinition/ie-core-patient" />
  <name value="IECorePatient" />
  <title value="IE Core Patient" />
  <status value="draft" />
  <description value="Base Patient profile for the Irish health system, derived from the HL7 Europe Base Patient. It is deliberately permissive: special-category and identity-disambiguation data (for example ethnicity or mother's maiden name) are allowed but NOT MustSupport. Use-case profiles decide what must be sent and what must not be sent: IECorePatientEPrescription for ePrescription and eDispensation, and IECorePatientSummaryPatient for the Patient Summary (ADR-002, GDPR Art. 5(1)(c) data minimisation)." />
  <fhirVersion value="4.0.1" />
  <kind value="resource" />
  <abstract value="false" />
  <type value="Patient" />
  <baseDefinition value="http://hl7.eu/fhir/base/StructureDefinition/patient-eu-core" />
  <derivation value="constraint" />
  <snapshot />
  <differential>
    <element id="Patient.extension:gender-identity">
      <path value="Patient.extension" />
      <sliceName value="gender-identity" />
      <short value="Gender identity (HIQA gender cluster)" />
      <comment value="HIQA EP 1.4.4 / PS 1.4.5 Gender cluster (Required 0..1). 'Other gender identity' free text (EP 1.4.4.2 / PS 1.4.5.2) goes in valueCodeableConcept.text." />
      <mustSupport value="true" />
    </element>
    <element id="Patient.extension:pronouns">
      <path value="Patient.extension" />
      <sliceName value="pronouns" />
      <short value="Personal pronouns (not in either HIQA dataset)" />
    </element>
    <element id="Patient.extension:sexAssignedAtBirth">
      <path value="Patient.extension" />
      <sliceName value="sexAssignedAtBirth" />
      <short value="Sex assigned at birth (recorded sex, type LOINC 76689-9)" />
      <definition value="The patient's sex assigned at birth, recorded with individual-recordedSexOrGender and typed with LOINC 76689-9 'Sex assigned at birth'. This is distinct from Patient.gender (administrative gender) and from gender identity." />
      <comment value="HIQA EP 1.4.3 / PS 1.4.4 Sex (Mandatory 1..1). Mandatory in the use-case profiles (ADR-002). Displaying sex at birth alongside gender identity can disclose a gender reassignment; see the security guidance." />
      <min value="0" />
      <max value="1" />
      <type>
        <code value="Extension" />
        <profile value="http://hl7.org/fhir/StructureDefinition/individual-recordedSexOrGender" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="Patient.extension:sexAssignedAtBirth.extension">
      <path value="Patient.extension.extension" />
      <min value="2" />
    </element>
    <element id="Patient.extension:sexAssignedAtBirth.extension:type">
      <path value="Patient.extension.extension" />
      <sliceName value="type" />
      <min value="1" />
    </element>
    <element id="Patient.extension:sexAssignedAtBirth.extension:type.value[x]">
      <path value="Patient.extension.extension.value[x]" />
      <patternCodeableConcept>
        <coding>
          <system value="http://loinc.org" />
          <code value="76689-9" />
          <display value="Sex assigned at birth" />
        </coding>
      </patternCodeableConcept>
    </element>
    <element id="Patient.extension:ethnicity">
      <path value="Patient.extension" />
      <sliceName value="ethnicity" />
      <short value="Ethnicity (special-category data; Patient Summary only)" />
      <comment value="GDPR Art. 9 special-category data. HIQA PS 1.4.10 (Required 0..*). Not part of the HIQA ePrescription dataset, and prohibited in IECorePatientEPrescription (ADR-002)." />
      <min value="0" />
      <max value="*" />
      <type>
        <code value="Extension" />
        <profile value="https://hl7-ie.github.io/ie-core/fhir/ie/core/StructureDefinition/ie-core-ethnicity" />
      </type>
    </element>
    <element id="Patient.extension:mothersMaidenName">
      <path value="Patient.extension" />
      <sliceName value="mothersMaidenName" />
      <short value="Mother's maiden name (not MustSupport)" />
      <comment value="Not part of the HIQA ePrescription dataset. The Patient Summary uses IECoreMothersFormerSurname (HIQA PS 1.4.6, 0..*)." />
      <min value="0" />
      <max value="1" />
      <type>
        <code value="Extension" />
        <profile value="http://hl7.org/fhir/StructureDefinition/patient-mothersMaidenName" />
      </type>
    </element>
    <element id="Patient.extension:interpreterRequired">
      <path value="Patient.extension" />
      <sliceName value="interpreterRequired" />
      <short value="Whether the patient requires an interpreter" />
      <min value="0" />
      <max value="1" />
      <type>
        <code value="Extension" />
        <profile value="http://hl7.org/fhir/StructureDefinition/patient-interpreterRequired" />
      </type>
    </element>
    <element id="Patient.identifier">
      <path value="Patient.identifier" />
      <slicing>
        <discriminator>
          <type value="value" />
          <path value="system" />
        </discriminator>
        <rules value="open" />
      </slicing>
      <short value="Identifiers for this patient" />
      <comment value="HIQA EP/PS 1.3. Identifiers other than the IHI (and the PPSN in the use-case profiles) are carried as 'other identifiers used in health and social care' (HIQA 1.3.3): type, value, validity period and issuing organisation. Examples from HIQA include PCRS scheme numbers (medical card, GP visit card, DPS, LTI, HAA), GP record number, MRN, NHS number and EHIC." />
      <mustSupport value="true" />
    </element>
    <element id="Patient.identifier.type">
      <path value="Patient.identifier.type" />
      <comment value="HIQA EP/PS 1.3.3.1 (Required)." />
      <mustSupport value="true" />
    </element>
    <element id="Patient.identifier.value">
      <path value="Patient.identifier.value" />
      <comment value="HIQA EP/PS 1.3.3.2 (Required)." />
      <mustSupport value="true" />
    </element>
    <element id="Patient.identifier.period">
      <path value="Patient.identifier.period" />
      <comment value="HIQA EP/PS 1.3.3.3 (Required)." />
      <mustSupport value="true" />
    </element>
    <element id="Patient.identifier.assigner">
      <path value="Patient.identifier.assigner" />
      <comment value="HIQA EP/PS 1.3.3.4 (Required): name of the issuing organisation (assigner.display), for example 'HSE'." />
      <mustSupport value="true" />
    </element>
    <element id="Patient.identifier:IHI">
      <path value="Patient.identifier" />
      <sliceName value="IHI" />
      <short value="Individual Health Identifier (IHI)" />
      <definition value="The Individual Health Identifier assigned by the HSE. HIQA describes it as a unique 18 or 10-digit number." />
      <comment value="HIQA EP/PS 1.3.1 (Required 0..1). The system URI is a placeholder pending an HSE-published URI (OI-003). The relationship between the 18- and 10-digit forms is Requires Clarification (OI-002)." />
      <min value="0" />
      <max value="1" />
      <constraint>
        <key value="ie-pat-1" />
        <severity value="error" />
        <human value="IHI SHALL be 18 or 10 digits (HIQA EP/PS 1.3.1: 'A unique 18 or 10-digit number')" />
        <expression value="value.matches('^([0-9]{18}|[0-9]{10})$')" />
        <source value="https://hl7-ie.github.io/ie-core/fhir/ie/core/StructureDefinition/ie-core-patient" />
      </constraint>
      <mustSupport value="true" />
    </element>
    <element id="Patient.identifier:IHI.type">
      <path value="Patient.identifier.type" />
      <patternCodeableConcept>
        <coding>
          <system value="http://terminology.hl7.org/CodeSystem/v2-0203" />
          <code value="NI" />
          <display value="National unique individual identifier" />
        </coding>
      </patternCodeableConcept>
    </element>
    <element id="Patient.identifier:IHI.system">
      <path value="Patient.identifier.system" />
      <min value="1" />
      <patternUri value="https://hl7-ie.github.io/ie-core/fhir/ie/core/sid/ihi" />
      <mustSupport value="true" />
    </element>
    <element id="Patient.identifier:IHI.value">
      <path value="Patient.identifier.value" />
      <short value="IHI number (18 or 10 digits)" />
      <min value="1" />
    </element>
    <element id="Patient.name">
      <path value="Patient.name" />
      <mustSupport value="true" />
    </element>
    <element id="Patient.name.use">
      <path value="Patient.name.use" />
      <mustSupport value="true" />
    </element>
    <element id="Patient.name.family">
      <path value="Patient.name.family" />
      <short value="Family name (surname)" />
      <mustSupport value="true" />
    </element>
    <element id="Patient.name.given">
      <path value="Patient.name.given" />
      <short value="Given names (first and middle names)" />
      <mustSupport value="true" />
    </element>
    <element id="Patient.name.prefix">
      <path value="Patient.name.prefix" />
      <mustSupport value="true" />
    </element>
    <element id="Patient.name.suffix">
      <path value="Patient.name.suffix" />
      <mustSupport value="true" />
    </element>
    <element id="Patient.telecom">
      <path value="Patient.telecom" />
      <mustSupport value="true" />
    </element>
    <element id="Patient.telecom.system">
      <path value="Patient.telecom.system" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Patient.telecom.value">
      <path value="Patient.telecom.value" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Patient.telecom.use">
      <path value="Patient.telecom.use" />
      <mustSupport value="true" />
    </element>
    <element id="Patient.gender">
      <path value="Patient.gender" />
      <short value="Administrative gender (not sex assigned at birth)" />
      <comment value="Administrative gender for record-keeping. Sex assigned at birth (HIQA EP 1.4.3 / PS 1.4.4) is carried in extension[sexAssignedAtBirth], and gender identity in extension[gender-identity]." />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Patient.birthDate">
      <path value="Patient.birthDate" />
      <short value="The date of birth for the patient" />
      <comment value="HIQA EP/PS 1.4.1 Date of birth (Mandatory 1..1). 1..1 is inherited from HL7 Europe Base patient-eu-core." />
      <mustSupport value="true" />
    </element>
    <element id="Patient.deceased[x]">
      <path value="Patient.deceased[x]" />
      <mustSupport value="true" />
    </element>
    <element id="Patient.address">
      <path value="Patient.address" />
      <short value="An address for the patient (Irish address)" />
      <mustSupport value="true" />
    </element>
    <element id="Patient.address.use">
      <path value="Patient.address.use" />
      <mustSupport value="true" />
    </element>
    <element id="Patient.address.line">
      <path value="Patient.address.line" />
      <mustSupport value="true" />
    </element>
    <element id="Patient.address.city">
      <path value="Patient.address.city" />
      <short value="Suburb, town, townland or locality (Dublin postal district, e.g. 'Dublin 2', goes here)" />
      <mustSupport value="true" />
    </element>
    <element id="Patient.address.state">
      <path value="Patient.address.state" />
      <short value="County" />
      <definition value="The Irish county. Bound to the IE Core County ValueSet." />
      <mustSupport value="true" />
      <binding>
        <strength value="extensible" />
        <valueSet value="https://hl7-ie.github.io/ie-core/fhir/ie/core/ValueSet/ie-core-county" />
      </binding>
    </element>
    <element id="Patient.address.postalCode">
      <path value="Patient.address.postalCode" />
      <short value="Eircode or postal code (Eircode format XXX XXXX)" />
      <mustSupport value="true" />
    </element>
    <element id="Patient.address.country">
      <path value="Patient.address.country" />
      <short value="Country (ISO 3166-1 alpha-2)" />
      <mustSupport value="true" />
    </element>
    <element id="Patient.communication">
      <path value="Patient.communication" />
      <mustSupport value="true" />
    </element>
    <element id="Patient.communication.language">
      <path value="Patient.communication.language" />
      <mustSupport value="true" />
    </element>
    <element id="Patient.generalPractitioner">
      <path value="Patient.generalPractitioner" />
      <type>
        <code value="Reference" />
        <targetProfile value="https://hl7-ie.github.io/ie-core/fhir/ie/core/StructureDefinition/ie-core-organization" />
        <targetProfile value="https://hl7-ie.github.io/ie-core/fhir/ie/core/StructureDefinition/ie-core-practitioner" />
        <targetProfile value="https://hl7-ie.github.io/ie-core/fhir/ie/core/StructureDefinition/ie-core-practitionerrole" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="Patient.managingOrganization">
      <path value="Patient.managingOrganization" />
      <type>
        <code value="Reference" />
        <targetProfile value="https://hl7-ie.github.io/ie-core/fhir/ie/core/StructureDefinition/ie-core-organization" />
      </type>
      <mustSupport value="true" />
    </element>
  </differential>
</StructureDefinition>