<StructureDefinition xmlns="http://hl7.org/fhir">
  <id value="ie-core-patient-eprescription" />
  <url value="https://hl7-ie.github.io/ie-core/fhir/ie/core/StructureDefinition/ie-core-patient-eprescription" />
  <name value="IECorePatientEPrescription" />
  <title value="IE Core Patient (ePrescription/eDispensation)" />
  <status value="draft" />
  <description value="The patient as the subject of an ePrescription or eDispensation. It carries the HIQA ePrescription/eDispensation patient dataset (Section 1) and nothing more. Ethnicity, mother's maiden name, nationality, citizenship, place of birth, religion, marital status, pronouns, photo and contact persons are not part of that dataset, so they are prohibited (GDPR Art. 5(1)(c) data minimisation; ethnicity and religion are Art. 9 special-category data). Patient identity is established by the IHI (when available) together with name, date of birth and address (see the clinical-safety log, HZ-06)." />
  <fhirVersion value="4.0.1" />
  <kind value="resource" />
  <abstract value="false" />
  <type value="Patient" />
  <baseDefinition value="https://hl7-ie.github.io/ie-core/fhir/ie/core/StructureDefinition/ie-core-patient" />
  <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="Prohibited: not in the HIQA EP dataset (it is PS 1.4.3)." />
      <max value="0" />
    </element>
    <element id="Patient.extension:gender-identity">
      <path value="Patient.extension" />
      <sliceName value="gender-identity" />
      <comment value="HIQA EP 1.4.4 Gender cluster (Required 0..1): 1.4.4.1 Gender (coded) and 1.4.4.2 Other gender identity (free text in valueCodeableConcept.text)." />
      <max value="1" />
    </element>
    <element id="Patient.extension:pronouns">
      <path value="Patient.extension" />
      <sliceName value="pronouns" />
      <max value="0" />
    </element>
    <element id="Patient.extension:patient-citizenship">
      <path value="Patient.extension" />
      <sliceName value="patient-citizenship" />
      <max value="0" />
    </element>
    <element id="Patient.extension:patient-nationality">
      <path value="Patient.extension" />
      <sliceName value="patient-nationality" />
      <comment value="Prohibited: not in the HIQA EP dataset (it is PS 1.4.7)." />
      <max value="0" />
    </element>
    <element id="Patient.extension:sexAssignedAtBirth">
      <path value="Patient.extension" />
      <sliceName value="sexAssignedAtBirth" />
      <comment value="HIQA EP 1.4.3 Sex (Mandatory 1..1): the sex of the patient assigned at birth." />
      <min value="1" />
    </element>
    <element id="Patient.extension:ethnicity">
      <path value="Patient.extension" />
      <sliceName value="ethnicity" />
      <comment value="Prohibited: not in the HIQA EP dataset; GDPR Art. 9 special-category data (ADR-002)." />
      <max value="0" />
    </element>
    <element id="Patient.extension:mothersMaidenName">
      <path value="Patient.extension" />
      <sliceName value="mothersMaidenName" />
      <comment value="Prohibited: not in the HIQA EP dataset (ADR-002). Identity: see HZ-06." />
      <max value="0" />
    </element>
    <element id="Patient.extension:interpreterRequired">
      <path value="Patient.extension" />
      <sliceName value="interpreterRequired" />
      <max value="0" />
    </element>
    <element id="Patient.extension:religion">
      <path value="Patient.extension" />
      <sliceName value="religion" />
      <comment value="Prohibited: not in either HIQA 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.extension:mothersFormerSurname">
      <path value="Patient.extension" />
      <sliceName value="mothersFormerSurname" />
      <min value="0" />
      <max value="0" />
      <type>
        <code value="Extension" />
        <profile value="https://hl7-ie.github.io/ie-core/fhir/ie/core/StructureDefinition/ie-core-mothers-former-surname" />
      </type>
    </element>
    <element id="Patient.extension:countryOfAffiliation">
      <path value="Patient.extension" />
      <sliceName value="countryOfAffiliation" />
      <min value="0" />
      <max value="0" />
      <type>
        <code value="Extension" />
        <profile value="https://hl7-ie.github.io/ie-core/fhir/ie/core/StructureDefinition/ie-core-country-of-affiliation" />
      </type>
    </element>
    <element id="Patient.identifier:IHI">
      <path value="Patient.identifier" />
      <sliceName value="IHI" />
      <comment value="HIQA EP 1.3.1 IHI (Required 0..1). For individuals living outside Ireland, record their healthcare ID as an 'other identifier' (EP 1.3.3)." />
    </element>
    <element id="Patient.identifier:PPSN">
      <path value="Patient.identifier" />
      <sliceName value="PPSN" />
      <short value="Personal Public Service Number (PPSN): Requires Clarification" />
      <definition value="HIQA EP 1.3.2 Personal Public Service Number (Required 0..1): seven numbers followed by one or two letters." />
      <comment value="Deliberately NOT MustSupport. The legal basis for using the PPSN as a health identifier is Requires Clarification (OI-008), so a sender is never obliged to send it. The system URI is a placeholder (OI-003)." />
      <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-eprescription" />
      </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.family">
      <path value="Patient.name.family" />
      <comment value="HIQA EP 1.1.3 Surname (Mandatory 1..1): the legal family or marital name." />
      <min value="1" />
    </element>
    <element id="Patient.name.given">
      <path value="Patient.name.given" />
      <comment value="HIQA EP 1.1.2 Forename (Mandatory 1..1): the legal first name." />
      <min value="1" />
    </element>
    <element id="Patient.name.prefix">
      <path value="Patient.name.prefix" />
      <comment value="HIQA EP 1.1.1 Name title (Optional 0..*)." />
    </element>
    <element id="Patient.name.suffix">
      <path value="Patient.name.suffix" />
      <comment value="HIQA EP 1.1.4 Name suffix (Optional 0..*)." />
    </element>
    <element id="Patient.telecom">
      <path value="Patient.telecom" />
      <comment value="HIQA EP 1.5.1 Mobile phone (Required 0..*), 1.5.2 Email (Required 0..*), 1.5.3 Other communication details (Optional 0..*)." />
    </element>
    <element id="Patient.birthDate">
      <path value="Patient.birthDate" />
      <comment value="HIQA EP 1.4.1 Date of birth (Mandatory 1..1). A legal requirement on cross-border prescriptions. Age under 12: see IECorePatientAgeAtPrescribing on the prescription (EP 1.4.2)." />
    </element>
    <element id="Patient.address">
      <path value="Patient.address" />
      <min value="1" />
    </element>
    <element id="Patient.address.use">
      <path value="Patient.address.use" />
      <comment value="HIQA EP 1.2.6 Address type (Mandatory 1..1): type or purpose of the address, e.g. place of residence (home) or temporary accommodation (temp). No HL7 code exists for homelessness; that is Requires Clarification (see open issues)." />
      <min value="1" />
    </element>
    <element id="Patient.address.type">
      <path value="Patient.address.type" />
      <comment value="HIQA EP 1.2.7 Address use (Optional 0..1): whether the address is a postal address." />
    </element>
    <element id="Patient.address.line">
      <path value="Patient.address.line" />
      <comment value="HIQA EP 1.2.2 Address line(s) (Mandatory 1..1). If the address is unknown, HIQA says it may be recorded here." />
      <min value="1" />
    </element>
    <element id="Patient.address.city">
      <path value="Patient.address.city" />
      <comment value="HIQA EP 1.2.3 Suburb/Town/Townland/Locality (Required 0..1)." />
    </element>
    <element id="Patient.address.state">
      <path value="Patient.address.state" />
      <comment value="HIQA EP 1.2.4 District/County (Mandatory 1..1). Outside Ireland: the equivalent district or city." />
      <min value="1" />
    </element>
    <element id="Patient.address.postalCode">
      <path value="Patient.address.postalCode" />
      <comment value="HIQA EP 1.2.1 Postcode (Required 0..1): Eircode in the format XXX XXXX." />
    </element>
    <element id="Patient.address.country">
      <path value="Patient.address.country" />
      <comment value="HIQA EP 1.2.5 Country (Required 0..1)." />
    </element>
    <element id="Patient.maritalStatus">
      <path value="Patient.maritalStatus" />
      <comment value="Prohibited: not in the HIQA EP dataset." />
      <max value="0" />
    </element>
    <element id="Patient.multipleBirth[x]">
      <path value="Patient.multipleBirth[x]" />
      <max value="0" />
    </element>
    <element id="Patient.photo">
      <path value="Patient.photo" />
      <max value="0" />
    </element>
    <element id="Patient.contact">
      <path value="Patient.contact" />
      <comment value="Prohibited: third-party personal data not in the HIQA EP dataset. The person collecting a dispensed medicine is recorded on the dispense (EP 6.4 Receiver)." />
      <max value="0" />
    </element>
    <element id="Patient.communication">
      <path value="Patient.communication" />
      <comment value="Not a HIQA EP element. MustSupport is inherited from IECorePatient; useful for choosing the language of the patient instructions. Not personal special-category data." />
    </element>
  </differential>
</StructureDefinition>