<StructureDefinition xmlns="http://hl7.org/fhir">
  <url value="http://electronichealth.se/fhir/StructureDefinition/NLLRelatedPerson" />
  <version value="1.0.0" />
  <name value="NLLRelatedPerson" />
  <status value="active" />
  <date value="2022-02-02" />
  <publisher value="Swedish eHealth Agency" />
  <description value="Information about a person that is related to a patient. Used in NLL primarily to represent the guardian of a child." />
  <fhirVersion value="4.0.1" />
  <mapping>
    <identity value="EHM" />
    <name value="E-hälsomyndigheten concept" />
  </mapping>
  <kind value="resource" />
  <abstract value="false" />
  <type value="RelatedPerson" />
  <baseDefinition value="http://hl7.org/fhir/StructureDefinition/RelatedPerson" />
  <derivation value="constraint" />
  <differential>
    <element id="RelatedPerson">
      <path value="RelatedPerson" />
      <short value="A person that is related to a patient in the form of guardian (sv: vårdnadshavare)" />
      <definition value="Represents the relation between a person acting as a guardian (sv: vårdnadshavare) and a patient (child). Only represents a one to one mapping - meaning one care taker and one child." />
      <mapping>
        <identity value="EHM" />
        <map value="Vårdnadshavare" />
      </mapping>
    </element>
    <element id="RelatedPerson.id">
      <path value="RelatedPerson.id" />
      <mustSupport value="true" />
      <mapping>
        <identity value="EHM" />
        <map value="Vårdnadshavarrelations-id" />
      </mapping>
    </element>
    <element id="RelatedPerson.identifier">
      <path value="RelatedPerson.identifier" />
      <slicing>
        <discriminator>
          <type value="value" />
          <path value="system" />
        </discriminator>
        <rules value="open" />
      </slicing>
      <mustSupport value="true" />
    </element>
    <element id="RelatedPerson.identifier:pnr">
      <path value="RelatedPerson.identifier" />
      <sliceName value="pnr" />
      <short value="Identifier of related person" />
      <definition value="Identifies the related person of the patient, e.g. the guardian." />
      <mustSupport value="true" />
      <mapping>
        <identity value="EHM" />
        <map value="Personnummer" />
      </mapping>
    </element>
    <element id="RelatedPerson.identifier:pnr.system">
      <path value="RelatedPerson.identifier.system" />
      <min value="1" />
      <fixedUri value="http://electronichealth.se/identifier/personnummer" />
      <mustSupport value="true" />
    </element>
    <element id="RelatedPerson.identifier:pnr.value">
      <path value="RelatedPerson.identifier.value" />
      <short value="The value, swedish national identification number" />
      <definition value="Value of the identifier, a swedish national identification number which must be a 12 digit numeric value." />
      <min value="1" />
      <constraint>
        <key value="swe-id-rule" />
        <severity value="error" />
        <human value="Personal id must have 12 digits" />
        <expression value="$this.matches('^\\d{12}$')" />
        <source value="RelatedPerson" />
      </constraint>
      <mustSupport value="true" />
    </element>
    <element id="RelatedPerson.patient">
      <path value="RelatedPerson.patient" />
      <definition value="The patient (a child) this person (the guardian) is related to." />
      <type>
        <code value="Reference" />
        <targetProfile value="http://electronichealth.se/fhir/StructureDefinition/NLLPatient" />
        <aggregation value="referenced" />
      </type>
      <mustSupport value="true" />
      <mapping>
        <identity value="EHM" />
        <map value="Patientreferens" />
      </mapping>
    </element>
    <element id="RelatedPerson.relationship">
      <path value="RelatedPerson.relationship" />
      <definition value="The nature of the relationship, fixed to GUARD (guardian) sv: vårdnadshavare since NLL currently only supports related person of this type." />
      <min value="1" />
      <max value="1" />
      <fixedCodeableConcept>
        <coding>
          <system value="http://terminology.hl7.org/CodeSystem/v3-RoleCode" />
          <code value="GUARD" />
        </coding>
      </fixedCodeableConcept>
      <mustSupport value="true" />
      <binding>
        <strength value="required" />
        <valueSet value="http://electronichealth.se/fhir/ValueSet/relationship-types" />
      </binding>
    </element>
    <element id="RelatedPerson.relationship.coding">
      <path value="RelatedPerson.relationship.coding" />
      <min value="1" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="RelatedPerson.relationship.coding.system">
      <path value="RelatedPerson.relationship.coding.system" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="RelatedPerson.relationship.coding.code">
      <path value="RelatedPerson.relationship.coding.code" />
      <min value="1" />
      <mustSupport value="true" />
      <mapping>
        <identity value="EHM" />
        <map value="Relation" />
      </mapping>
    </element>
  </differential>
</StructureDefinition>