<StructureDefinition xmlns="http://hl7.org/fhir">
  <id value="NPPRPerson" />
  <url value="http://electronichealth.se/fhir/NPPR/StructureDefinition/NPPRPerson" />
  <version value="0.1" />
  <name value="NPPRPerson" />
  <status value="active" />
  <description value="Profile for representing basic data about an individual, comparable to data in the population registry (folkbokföring)." />
  <fhirVersion value="5.0.0" />
  <mapping>
    <identity value="NPPRPersonToNPPRPersonLogical" />
    <uri value="NPPRPersonLogical" />
  </mapping>
  <kind value="resource" />
  <abstract value="false" />
  <type value="Person" />
  <baseDefinition value="http://hl7.org/fhir/StructureDefinition/Person" />
  <derivation value="constraint" />
  <differential>
    <element id="Person.meta">
      <path value="Person.meta" />
      <mustSupport value="true" />
    </element>
    <element id="Person.meta.security">
      <path value="Person.meta.security" />
      <mustSupport value="true" />
      <mapping>
        <identity value="NPPRPersonToNPPRPersonLogical" />
        <map value="sekretessmarkering" />
      </mapping>
      <mapping>
        <identity value="NPPRPersonToNPPRPersonLogical" />
        <map value="skyddadFolkbokforing" />
      </mapping>
    </element>
    <element id="Person.meta.security.code">
      <path value="Person.meta.security.code" />
      <mustSupport value="true" />
    </element>
    <element id="Person.identifier">
      <path value="Person.identifier" />
      <slicing>
        <discriminator>
          <type value="value" />
          <path value="system" />
        </discriminator>
        <description value="Slice on Identifier based on the system value" />
        <ordered value="false" />
        <rules value="open" />
      </slicing>
      <min value="1" />
      <max value="1" />
      <mustSupport value="true" />
      <mapping>
        <identity value="NPPRPersonToNPPRPersonLogical" />
        <map value="person-id" />
      </mapping>
    </element>
    <element id="Person.identifier.system">
      <path value="Person.identifier.system" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Person.identifier.value">
      <path value="Person.identifier.value" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Person.identifier:coordinationNumber">
      <path value="Person.identifier" />
      <sliceName value="coordinationNumber" />
      <min value="0" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Person.identifier:coordinationNumber.system">
      <path value="Person.identifier.system" />
      <patternUri value="http://electronichealth.se/identifier/samordningsnummer" />
    </element>
    <element id="Person.identifier:coordinationNumber.value">
      <path value="Person.identifier.value" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Person.identifier:personalIdentityNumber">
      <path value="Person.identifier" />
      <sliceName value="personalIdentityNumber" />
      <min value="0" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Person.identifier:personalIdentityNumber.system">
      <path value="Person.identifier.system" />
      <patternUri value="http://electronichealth.se/identifier/personnummer" />
    </element>
    <element id="Person.identifier:personalIdentityNumber.value">
      <path value="Person.identifier.value" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Person.name">
      <path value="Person.name" />
      <min value="1" />
      <max value="1" />
      <type>
        <code value="HumanName" />
        <profile value="http://electronichealth.se/fhir/NPPR/StructureDefinition/NPPRHumanName" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="Person.name.family">
      <path value="Person.name.family" />
      <min value="1" />
      <mapping>
        <identity value="NPPRPersonToNPPRPersonLogical" />
        <map value="efternamn" />
      </mapping>
    </element>
    <element id="Person.name.given">
      <path value="Person.name.given" />
      <min value="1" />
      <mapping>
        <identity value="NPPRPersonToNPPRPersonLogical" />
        <map value="fornamn" />
      </mapping>
    </element>
    <element id="Person.name.given.extension:nameQualifier">
      <path value="Person.name.given.extension" />
      <sliceName value="nameQualifier" />
      <mapping>
        <identity value="NPPRPersonToNPPRPersonLogical" />
        <map value="mellannamn" />
      </mapping>
      <mapping>
        <identity value="NPPRPersonToNPPRPersonLogical" />
        <map value="tilltalsnamnsmarkering" />
      </mapping>
    </element>
    <element id="Person.telecom">
      <path value="Person.telecom" />
      <type>
        <code value="ContactPoint" />
        <profile value="http://electronichealth.se/fhir/NPPR/StructureDefinition/NPPRContactPoint" />
      </type>
      <constraint>
        <key value="nppr-telecom-phone-1" />
        <severity value="warning" />
        <human value="If telecom.system = #phone, value should follow format +46123456789" />
        <expression value="value.matches('^\\+[1-9][0-9]+$') or system != 'phone'" />
        <source value="http://electronichealth.se/fhir/NPPR/StructureDefinition/NPPRPerson" />
      </constraint>
      <constraint>
        <key value="nppr-telecom-url-1" />
        <severity value="warning" />
        <human value="If telecom.system = #url, value should follow valid format. Example: https://example.com" />
        <expression value="value.matches('(https?|ftp)://(-\\.)?([^\\s/?\\.#-]+\\.?)+(/[^\\s]*)?$') or system != 'url'" />
        <source value="http://electronichealth.se/fhir/NPPR/StructureDefinition/NPPRPerson" />
      </constraint>
      <constraint>
        <key value="nppr-telecom-email-1" />
        <severity value="warning" />
        <human value="If telecom.system = #email, value should follow valid format Example: test@test.com" />
        <expression value="value.matches('^[\\w.-]{1,64}@(?!.{254})[\\w.-]+\\.[A-Za-z]{2,4}$') or system != 'email'" />
        <source value="http://electronichealth.se/fhir/NPPR/StructureDefinition/NPPRPerson" />
      </constraint>
      <mustSupport value="true" />
    </element>
    <element id="Person.gender">
      <path value="Person.gender" />
      <min value="1" />
      <mustSupport value="true" />
      <binding>
        <strength value="required" />
        <valueSet value="http://electronichealth.se/fhir/NPPR/ValueSet/nppr-administrative-gender" />
      </binding>
      <mapping>
        <identity value="NPPRPersonToNPPRPersonLogical" />
        <map value="kon" />
      </mapping>
    </element>
    <element id="Person.birthDate">
      <path value="Person.birthDate" />
      <min value="1" />
      <mustSupport value="true" />
      <mapping>
        <identity value="NPPRPersonToNPPRPersonLogical" />
        <map value="fodelsedatum" />
      </mapping>
    </element>
    <element id="Person.address">
      <path value="Person.address" />
      <type>
        <code value="Address" />
        <profile value="http://electronichealth.se/fhir/NPPR/StructureDefinition/NPPRAddress" />
      </type>
      <mustSupport value="true" />
      <mapping>
        <identity value="NPPRPersonToNPPRPersonLogical" />
        <map value="harAdressIFormAv(KontaktuppgiftLogical)" />
      </mapping>
    </element>
    <element id="Person.address.extension">
      <path value="Person.address.extension" />
      <min value="1" />
    </element>
    <element id="Person.address.extension:officialAddressType">
      <path value="Person.address.extension" />
      <sliceName value="officialAddressType" />
      <min value="1" />
    </element>
    <element id="Person.maritalStatus">
      <path value="Person.maritalStatus" />
      <min value="1" />
      <mustSupport value="true" />
      <binding>
        <strength value="extensible" />
        <valueSet value="http://electronichealth.se/fhir/NPPR/ValueSet/nppr-marital-status" />
      </binding>
      <mapping>
        <identity value="NPPRPersonToNPPRPersonLogical" />
        <map value="civilstand" />
      </mapping>
    </element>
    <element id="Person.maritalStatus.coding">
      <path value="Person.maritalStatus.coding" />
      <min value="1" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Person.maritalStatus.coding.system">
      <path value="Person.maritalStatus.coding.system" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Person.maritalStatus.coding.code">
      <path value="Person.maritalStatus.coding.code" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Person.link">
      <path value="Person.link" />
      <mustSupport value="true" />
    </element>
    <element id="Person.link.target">
      <path value="Person.link.target" />
      <type>
        <extension url="http://hl7.org/fhir/StructureDefinition/structuredefinition-hierarchy">
          <valueBoolean value="false" />
        </extension>
        <code value="Reference" />
        <targetProfile value="http://electronichealth.se/fhir/NPPR/StructureDefinition/NPPRPatient" />
        <targetProfile value="http://electronichealth.se/fhir/NPPR/StructureDefinition/NPPRPractitioner" />
        <targetProfile value="http://electronichealth.se/fhir/NPPR/StructureDefinition/NPPRRelatedPerson" />
      </type>
      <mustSupport value="true" />
      <mapping>
        <identity value="NPPRPersonToNPPRPersonLogical" />
        <map value="harDetaljeradeUppgifterI(VardOchOmsorgstagareLogical)" />
      </mapping>
    </element>
  </differential>
</StructureDefinition>