<StructureDefinition xmlns="http://hl7.org/fhir">
  <id value="ie-core-patient-summary-patient" />
  <extension url="http://hl7.org/fhir/StructureDefinition/structuredefinition-imposeProfile">
    <valueCanonical value="https://hl7-ie.github.io/ie-core/fhir/ie/core/StructureDefinition/ie-core-patient" />
  </extension>
  <url value="https://hl7-ie.github.io/ie-core/fhir/ie/core/StructureDefinition/ie-core-patient-summary-patient" />
  <name value="IECorePatientSummaryPatient" />
  <title value="IE Core Patient (Patient Summary)" />
  <status value="draft" />
  <description value="The patient as the subject of an Irish Patient Summary. It carries the HIQA Patient Summary demographic dataset (Section 1), including the Required demographics that are NOT part of the ePrescription dataset (ethnicity, nationality, mother's former surnames, place of birth, country of affiliation), and the nominated contact person (Section 3). Marital status, religion and pronouns are in neither HIQA dataset and are prohibited. Derived from the HL7 Europe Patient Summary patient (which imposes the IPS patient) and imposes IECorePatient." />
  <fhirVersion value="4.0.1" />
  <kind value="resource" />
  <abstract value="false" />
  <type value="Patient" />
  <baseDefinition value="http://hl7.eu/fhir/eps/StructureDefinition/patient-eu-eps" />
  <derivation value="constraint" />
  <differential>
    <element id="Patient.extension">
      <path value="Patient.extension" />
      <min value="1" />
    </element>
    <element id="Patient.extension:birthPlace">
      <path value="Patient.extension" />
      <sliceName value="birthPlace" />
      <comment value="HIQA PS 1.4.3 Place of birth (Required 0..1): the county (in Ireland) or city (elsewhere) of birth, carried in valueAddress.state or valueAddress.city." />
      <mustSupport value="true" />
    </element>
    <element id="Patient.extension:gender-identity">
      <path value="Patient.extension" />
      <sliceName value="gender-identity" />
      <comment value="HIQA PS 1.4.5 Gender cluster (Required 0..1): 1.4.5.1 Gender (coded) and 1.4.5.2 Other gender identity (valueCodeableConcept.text)." />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Patient.extension:pronouns">
      <path value="Patient.extension" />
      <sliceName value="pronouns" />
      <comment value="Prohibited: not in the HIQA PS dataset." />
      <max value="0" />
    </element>
    <element id="Patient.extension:patient-nationality">
      <path value="Patient.extension" />
      <sliceName value="patient-nationality" />
      <comment value="HIQA PS 1.4.7 Nationality (Required 0..*, coded): country of legal citizenship." />
      <mustSupport value="true" />
    </element>
    <element id="Patient.extension:sexAssignedAtBirth">
      <path value="Patient.extension" />
      <sliceName value="sexAssignedAtBirth" />
      <comment value="HIQA PS 1.4.4 Sex (Mandatory 1..1): sex assigned at birth, e.g. male or female." />
      <min value="1" />
      <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" />
      <comment value="HIQA PS 1.4.10 Ethnicity (Required 0..*, coded). GDPR Art. 9 special-category data: send only when recorded with appropriate safeguards and consent. HIQA says it is not used for patient identification." />
      <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>
      <mustSupport value="true" />
    </element>
    <element id="Patient.extension:mothersFormerSurname">
      <path value="Patient.extension" />
      <sliceName value="mothersFormerSurname" />
      <comment value="HIQA PS 1.4.6 Mother's former surnames (Required 0..*). OI-011." />
      <min value="0" />
      <max value="*" />
      <type>
        <code value="Extension" />
        <profile value="https://hl7-ie.github.io/ie-core/fhir/ie/core/StructureDefinition/ie-core-mothers-former-surname" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="Patient.extension:countryOfAffiliation">
      <path value="Patient.extension" />
      <sliceName value="countryOfAffiliation" />
      <comment value="HIQA PS 1.4.8 Country of affiliation (Required 0..1)." />
      <min value="0" />
      <max value="1" />
      <type>
        <code value="Extension" />
        <profile value="https://hl7-ie.github.io/ie-core/fhir/ie/core/StructureDefinition/ie-core-country-of-affiliation" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="Patient.extension:religion">
      <path value="Patient.extension" />
      <sliceName value="religion" />
      <comment value="Prohibited: not in the HIQA PS dataset; GDPR Art. 9 special-category data." />
      <min value="0" />
      <max value="0" />
      <type>
        <code value="Extension" />
        <profile value="http://hl7.org/fhir/StructureDefinition/patient-religion" />
      </type>
    </element>
    <element id="Patient.identifier">
      <path value="Patient.identifier" />
      <slicing>
        <discriminator>
          <type value="value" />
          <path value="system" />
        </discriminator>
        <rules value="open" />
      </slicing>
      <comment value="HIQA PS 1.3.1 IHI (slice imposed by IECorePatient), 1.3.2 PPSN, 1.3.3 other identifiers (type, value, period, issuing organisation; all Required)." />
      <mustSupport value="true" />
    </element>
    <element id="Patient.identifier.type">
      <path value="Patient.identifier.type" />
      <mustSupport value="true" />
    </element>
    <element id="Patient.identifier.value">
      <path value="Patient.identifier.value" />
      <mustSupport value="true" />
    </element>
    <element id="Patient.identifier.period">
      <path value="Patient.identifier.period" />
      <mustSupport value="true" />
    </element>
    <element id="Patient.identifier.assigner">
      <path value="Patient.identifier.assigner" />
      <mustSupport value="true" />
    </element>
    <element id="Patient.identifier:PPSN">
      <path value="Patient.identifier" />
      <sliceName value="PPSN" />
      <short value="Personal Public Service Number (PPSN): Requires Clarification" />
      <comment value="HIQA PS 1.3.2 (Required 0..1). Deliberately NOT MustSupport: the legal basis for using the PPSN as a health identifier is Requires Clarification (OI-008). The IHI (PS 1.3.1) slice is imposed by IECorePatient." />
      <min value="0" />
      <max value="1" />
      <constraint>
        <key value="ie-pat-ppsn-1" />
        <severity value="warning" />
        <human value="PPSN format: seven numbers followed by one or two letters (HIQA EP/PS 1.3.2)" />
        <expression value="value.matches('^[0-9]{7}[A-Za-z]{1,2}$')" />
        <source value="https://hl7-ie.github.io/ie-core/fhir/ie/core/StructureDefinition/ie-core-patient-summary-patient" />
      </constraint>
    </element>
    <element id="Patient.identifier:PPSN.system">
      <path value="Patient.identifier.system" />
      <min value="1" />
      <patternUri value="https://hl7-ie.github.io/ie-core/fhir/ie/core/sid/pps" />
    </element>
    <element id="Patient.identifier:PPSN.value">
      <path value="Patient.identifier.value" />
      <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" />
      <comment value="HIQA PS 1.1.6 Former names (Required 0..*) use 'old'; 1.1.7 Preferred name (Required 0..1) uses 'usual'." />
      <mustSupport value="true" />
    </element>
    <element id="Patient.name.family">
      <path value="Patient.name.family" />
      <comment value="HIQA PS 1.1.4 Surname (Mandatory 1..1)." />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Patient.name.given">
      <path value="Patient.name.given" />
      <comment value="HIQA PS 1.1.2 Forename (Mandatory 1..1); PS 1.1.3 Middle name(s) (Required 0..1) as further given names." />
      <min value="1" />
      <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" />
      <comment value="HIQA PS 1.5.1 Mobile phone, 1.5.2 Email (Required); 1.5.3 Other communication details (Optional); 1.5.4 Preferred communication method (Required), expressed by rank = 1." />
      <mustSupport value="true" />
    </element>
    <element id="Patient.telecom.system">
      <path value="Patient.telecom.system" />
      <mustSupport value="true" />
    </element>
    <element id="Patient.telecom.value">
      <path value="Patient.telecom.value" />
      <mustSupport value="true" />
    </element>
    <element id="Patient.telecom.use">
      <path value="Patient.telecom.use" />
      <mustSupport value="true" />
    </element>
    <element id="Patient.telecom.rank">
      <path value="Patient.telecom.rank" />
      <mustSupport value="true" />
    </element>
    <element id="Patient.gender">
      <path value="Patient.gender" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Patient.birthDate">
      <path value="Patient.birthDate" />
      <comment value="HIQA PS 1.4.1 Date of birth (Mandatory 1..1). HIQA: if unknown, record 1900-01-01 (estimated age, PS 1.4.2, is Optional and not modelled)." />
      <mustSupport value="true" />
    </element>
    <element id="Patient.deceased[x]">
      <path value="Patient.deceased[x]" />
      <comment value="HIQA PS 1.4.11 Date of death (Required 0..1) as deceasedDateTime. PS 1.4.12 Cause of death (Required) has no Patient element: Requires Clarification." />
      <mustSupport value="true" />
    </element>
    <element id="Patient.address">
      <path value="Patient.address" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Patient.address.use">
      <path value="Patient.address.use" />
      <comment value="HIQA PS 1.2.6 Address type (Mandatory 1..1)." />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Patient.address.line">
      <path value="Patient.address.line" />
      <comment value="HIQA PS 1.2.2 Address line(s) (Mandatory 1..1)." />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Patient.address.city">
      <path value="Patient.address.city" />
      <mustSupport value="true" />
    </element>
    <element id="Patient.address.state">
      <path value="Patient.address.state" />
      <comment value="HIQA PS 1.2.4 District/County (Mandatory 1..1)." />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Patient.address.postalCode">
      <path value="Patient.address.postalCode" />
      <mustSupport value="true" />
    </element>
    <element id="Patient.address.country">
      <path value="Patient.address.country" />
      <mustSupport value="true" />
    </element>
    <element id="Patient.maritalStatus">
      <path value="Patient.maritalStatus" />
      <comment value="Prohibited: not in the HIQA PS dataset." />
      <max value="0" />
    </element>
    <element id="Patient.contact">
      <path value="Patient.contact" />
      <short value="Nominated contact person (HIQA PS Section 3)" />
      <mustSupport value="true" />
    </element>
    <element id="Patient.contact.relationship">
      <path value="Patient.contact.relationship" />
      <comment value="HIQA PS 3.3 Role (Required 0..*) and 3.4 Relationship (Required 0..1)." />
      <mustSupport value="true" />
    </element>
    <element id="Patient.contact.name">
      <path value="Patient.contact.name" />
      <mustSupport value="true" />
    </element>
    <element id="Patient.contact.name.family">
      <path value="Patient.contact.name.family" />
      <comment value="HIQA PS 3.2 Surname of nominated contact person (Required 0..1)." />
      <mustSupport value="true" />
    </element>
    <element id="Patient.contact.name.given">
      <path value="Patient.contact.name.given" />
      <comment value="HIQA PS 3.1 Forename of nominated contact person (Required 0..1)." />
      <mustSupport value="true" />
    </element>
    <element id="Patient.contact.telecom">
      <path value="Patient.contact.telecom" />
      <comment value="HIQA PS 3.5 Communication details (Required): 3.5.1 mobile, 3.5.2 landline, 3.5.3 email." />
      <mustSupport value="true" />
    </element>
    <element id="Patient.contact.telecom.rank">
      <path value="Patient.contact.telecom.rank" />
      <comment value="HIQA PS 3.7 Preferred communication type for the nominated contact person (Required): rank = 1." />
      <mustSupport value="true" />
    </element>
    <element id="Patient.contact.address">
      <path value="Patient.contact.address" />
      <comment value="HIQA PS 3.6 Address of nominated contact person (Optional 0..1)." />
    </element>
    <element id="Patient.contact.address.line">
      <path value="Patient.contact.address.line" />
      <comment value="HIQA PS 3.6.2 Address line(s): Mandatory when the contact address is given." />
      <min value="1" />
    </element>
    <element id="Patient.contact.address.city">
      <path value="Patient.contact.address.city" />
      <mustSupport value="true" />
    </element>
    <element id="Patient.contact.address.state">
      <path value="Patient.contact.address.state" />
      <comment value="HIQA PS 3.6.4 District/County/City: Mandatory when the contact address is given." />
      <min value="1" />
    </element>
    <element id="Patient.contact.address.postalCode">
      <path value="Patient.contact.address.postalCode" />
      <mustSupport value="true" />
    </element>
    <element id="Patient.contact.address.country">
      <path value="Patient.contact.address.country" />
      <mustSupport value="true" />
    </element>
    <element id="Patient.communication">
      <path value="Patient.communication" />
      <comment value="HIQA PS 1.4.9 Preferred language (Optional 0..*), including sign language." />
      <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" />
      <comment value="HIQA PS Section 2: General Practitioner details must be captured in all cases." />
      <mustSupport value="true" />
    </element>
  </differential>
</StructureDefinition>