<StructureDefinition xmlns="http://hl7.org/fhir">
  <url value="http://electronichealth.se/fhir/StructureDefinition/NLLPatient" />
  <name value="NLLPatient" />
  <status value="draft" />
  <fhirVersion value="4.0.0" />
  <mapping>
    <identity value="EHM" />
    <name value="E-hälsomyndigheten Information Model" />
  </mapping>
  <kind value="resource" />
  <abstract value="false" />
  <type value="Patient" />
  <baseDefinition value="http://hl7.org/fhir/StructureDefinition/Patient" />
  <derivation value="constraint" />
  <differential>
    <element id="Patient">
      <path value="Patient" />
      <short value="Information about an individual which has, or will have records in the Swedish National Medications List" />
      <definition value="Administrative information, such as name and identification number, about an individual which has or will have records in the Swedish National Medications List" />
    </element>
    <element id="Patient.extension">
      <path value="Patient.extension" />
      <slicing>
        <discriminator>
          <type value="value" />
          <path value="url" />
        </discriminator>
        <rules value="open" />
      </slicing>
    </element>
    <element id="Patient.extension:confidentiality">
      <path value="Patient.extension" />
      <sliceName value="confidentiality" />
      <short value="Indicates that the patient has confidential information, e.g. name and address" />
      <definition value="Indicates that the patient has confidential information, e.g. name and address (sv: skyddade personuppgifter). Confidential information is further explained at https://div.socialstyrelsen.se/juridiskt-stod/skyddade-personuppgifter-och-dokumentation If true, the name will be masked with the text &quot;Personuppgift skyddad&quot; and the address element will not be present." />
      <min value="0" />
      <max value="1" />
      <type>
        <code value="Extension" />
        <profile value="http://electronichealth.se/fhir/StructureDefinition/NLLPatientConfidentiality" />
      </type>
    </element>
    <element id="Patient.identifier">
      <path value="Patient.identifier" />
      <slicing>
        <discriminator>
          <type value="value" />
          <path value="system" />
        </discriminator>
        <rules value="open" />
      </slicing>
      <mustSupport value="true" />
    </element>
    <element id="Patient.identifier:pnr">
      <path value="Patient.identifier" />
      <sliceName value="pnr" />
      <short value="Swedish national identification number" />
      <definition value="Swedish national identification number (sv: personnummer). Expressed in 12 digits without hyphen." />
      <mustSupport value="true" />
    </element>
    <element id="Patient.identifier:pnr.system">
      <path value="Patient.identifier.system" />
      <min value="1" />
      <fixedUri value="http://electronichealth.se/identifier/personnummer" />
    </element>
    <element id="Patient.identifier:pnr.value">
      <path value="Patient.identifier.value" />
      <short value="The value, swedish national identification number" />
      <definition value="Value of the identifier. A swedish national identification number is 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="Patient" />
      </constraint>
    </element>
    <element id="Patient.name">
      <path value="Patient.name" />
      <definition value="Names associated with the patient. Comes in two slices, one for the official name (including all names) and one for the usual name (sv: tilltalsnamn)." />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Patient.name.text">
      <path value="Patient.name.text" />
      <definition value="Specifies the entire name as it should be displayed e.g. on an application UI. This may be provided instead of or as well as the specific parts. Maximum length 36 characters." />
      <maxLength value="36" />
      <mustSupport value="true" />
      <mapping>
        <identity value="EHM" />
        <map value="Redigerat namn" />
      </mapping>
    </element>
    <element id="Patient.name.family">
      <path value="Patient.name.family" />
      <definition value="A surname, family name, or last name is the part of a personal name that indicates a person's family (or community, depending on the culture). Maximum length 60 characters." />
      <maxLength value="60" />
      <mustSupport value="true" />
      <mapping>
        <identity value="EHM" />
        <map value="Efternamn" />
      </mapping>
    </element>
    <element id="Patient.name.given">
      <path value="Patient.name.given" />
      <definition value="Given name. Commonly use first name (sv: tilltalsnamn) is marked with the code &quot;CL&quot; for &quot;Call me&quot;." />
      <mustSupport value="true" />
      <mapping>
        <identity value="EHM" />
        <map value="Förnamn" />
      </mapping>
    </element>
    <element id="Patient.name.given.extension">
      <path value="Patient.name.given.extension" />
      <slicing>
        <discriminator>
          <type value="value" />
          <path value="url" />
        </discriminator>
        <rules value="open" />
      </slicing>
    </element>
    <element id="Patient.name.given.extension:nllNameQualifier">
      <path value="Patient.name.given.extension" />
      <sliceName value="nllNameQualifier" />
      <short value="CL" />
      <definition value="A set of codes each of which specifies a certain subcategory of the name part in addition to the main name part type. Used to describe &quot;tilltalsnamn&quot;." />
      <type>
        <code value="Extension" />
        <profile value="http://hl7.org/fhir/StructureDefinition/iso21090-EN-qualifier" />
      </type>
    </element>
    <element id="Patient.name.given.extension:nllNameQualifier.value[x]:valueCode">
      <path value="Patient.name.given.extension.value[x]" />
      <sliceName value="valueCode" />
      <binding>
        <strength value="required" />
        <valueSet value="http://electronichealth.se/fhir/ValueSet/given-name-types" />
      </binding>
    </element>
    <element id="Patient.gender">
      <path value="Patient.gender" />
      <short value="male | female | unknown" />
      <definition value="Administrative Gender - the gender that the patient is considered to have for administration and record keeping purposes. Only used when patient is created as a contained resource (sv: patient med födelsedatum)." />
      <mustSupport value="true" />
      <mapping>
        <identity value="EHM" />
        <map value="Kön" />
        <comment value="Only used in cases where the patient doesn't have/use the national identification number." />
      </mapping>
    </element>
    <element id="Patient.birthDate">
      <path value="Patient.birthDate" />
      <definition value="The date of birth for the individual. Used only when personal identifier is missing and the patient is a contained resource in e.g. MedicationRequest. Expected format yyyymmdd." />
      <example>
        <label value="Example NLL" />
        <valueDate value="2020-02-01" />
      </example>
      <mustSupport value="true" />
      <mapping>
        <identity value="EHM" />
        <map value="Födelsedatum" />
        <comment value="Only used in cases where the patient doesn't have/use the national identification number." />
      </mapping>
    </element>
    <element id="Patient.deceased[x]">
      <path value="Patient.deceased[x]" />
      <definition value="Indicates if the individual is deceased or not. This flag is in the Swedish National Mediations List a translation from status 4 (sv: Person avliden) in FOLK." />
      <comment value="If there's no value in the instance it means there is no statement on whether or not the individual is deceased, should be interpreted that patient is NOT deceased.&#xA;&#xA;NLL: translated from FOLK status 4 = Person avliden to this flag on FHIR service" />
      <type>
        <code value="boolean" />
      </type>
      <meaningWhenMissing value="Person is not deceased" />
      <mustSupport value="true" />
      <mapping>
        <identity value="EHM" />
        <map value="Avliden" />
      </mapping>
    </element>
    <element id="Patient.address">
      <path value="Patient.address" />
      <definition value="An address for the individual. The Swedish National Medications List only returns city and postal code." />
      <max value="1" />
      <mapping>
        <identity value="EHM" />
        <map value="Personadress" />
      </mapping>
    </element>
    <element id="Patient.address.extension">
      <path value="Patient.address.extension" />
      <slicing>
        <discriminator>
          <type value="value" />
          <path value="url" />
        </discriminator>
        <rules value="open" />
      </slicing>
    </element>
    <element id="Patient.address.extension:nllMunicipalityCode">
      <path value="Patient.address.extension" />
      <sliceName value="nllMunicipalityCode" />
      <short value="Municipality code (sv. kommunkod)" />
      <definition value="Municipality code, also called Official Municipality Key (sv: kommunkod) are four letter numeric codes which identfies a municipality (sv: kommun) in Sweden. Codes are decided by SCB.&#xD;&#xA;Example: Kalmar 0880" />
      <type>
        <code value="Extension" />
        <profile value="http://electronichealth.se/fhir/StructureDefinition/NLLMunicipalityCode" />
      </type>
      <binding>
        <strength value="required" />
        <description value="Statistics in Sweden (SCB)" />
        <valueSet value="http://scb.se" />
      </binding>
    </element>
    <element id="Patient.address.extension:nllRegionCode">
      <path value="Patient.address.extension" />
      <sliceName value="nllRegionCode" />
      <short value="Region code (sv: region/länskod)" />
      <definition value="Region code is a two letter numeric code for regions (sv: region/län) in Sweden" />
      <type>
        <code value="Extension" />
        <profile value="http://electronichealth.se/fhir/StructureDefinition/NLLRegionCode" />
      </type>
      <binding>
        <strength value="required" />
        <description value="Statistics in Sweden (SCB)" />
        <valueSet value="http://scb.se" />
      </binding>
    </element>
    <element id="Patient.address.postalCode">
      <path value="Patient.address.postalCode" />
      <definition value="A postal code designating a region defined by the postal service. Maximum string length 5 characters." />
      <example>
        <label value="Example NLL" />
        <valueString value="39231" />
      </example>
      <maxLength value="5" />
      <mustSupport value="true" />
      <mapping>
        <identity value="EHM" />
        <map value="Postnummer" />
      </mapping>
    </element>
  </differential>
</StructureDefinition>