{
  "resourceType": "StructureDefinition",
  "url": "http://electronichealth.se/fhir/StructureDefinition/NLLPatient",
  "name": "NLLPatient",
  "status": "draft",
  "fhirVersion": "4.0.0",
  "mapping": [
    {
      "identity": "EHM",
      "name": "E-hälsomyndigheten Information Model"
    }
  ],
  "kind": "resource",
  "abstract": false,
  "type": "Patient",
  "baseDefinition": "http://hl7.org/fhir/StructureDefinition/Patient",
  "derivation": "constraint",
  "differential": {
    "element": [
      {
        "id": "Patient",
        "path": "Patient",
        "short": "Information about an individual which has, or will have records in the Swedish National Medications List",
        "definition": "Administrative information, such as name and identification number, about an individual which has or will have records in the Swedish National Medications List"
      },
      {
        "id": "Patient.extension",
        "path": "Patient.extension",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "url"
            }
          ],
          "rules": "open"
        }
      },
      {
        "id": "Patient.extension:confidentiality",
        "path": "Patient.extension",
        "sliceName": "confidentiality",
        "short": "Indicates that the patient has confidential information, e.g. name and address",
        "definition": "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 \"Personuppgift skyddad\" and the address element will not be present.",
        "min": 0,
        "max": "1",
        "type": [
          {
            "code": "Extension",
            "profile": [
              "http://electronichealth.se/fhir/StructureDefinition/NLLPatientConfidentiality"
            ]
          }
        ]
      },
      {
        "id": "Patient.identifier",
        "path": "Patient.identifier",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "system"
            }
          ],
          "rules": "open"
        },
        "mustSupport": true
      },
      {
        "id": "Patient.identifier:pnr",
        "path": "Patient.identifier",
        "sliceName": "pnr",
        "short": "Swedish national identification number",
        "definition": "Swedish national identification number (sv: personnummer). Expressed in 12 digits without hyphen.",
        "mustSupport": true
      },
      {
        "id": "Patient.identifier:pnr.system",
        "path": "Patient.identifier.system",
        "min": 1,
        "fixedUri": "http://electronichealth.se/identifier/personnummer"
      },
      {
        "id": "Patient.identifier:pnr.value",
        "path": "Patient.identifier.value",
        "short": "The value, swedish national identification number",
        "definition": "Value of the identifier. A swedish national identification number is a 12 digit numeric value..",
        "min": 1,
        "constraint": [
          {
            "key": "swe-id-rule",
            "severity": "error",
            "human": "Personal id must have 12 digits",
            "expression": "$this.matches('^\\\\d{12}$')",
            "source": "Patient"
          }
        ]
      },
      {
        "id": "Patient.name",
        "path": "Patient.name",
        "definition": "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": "1",
        "mustSupport": true
      },
      {
        "id": "Patient.name.text",
        "path": "Patient.name.text",
        "definition": "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": 36,
        "mustSupport": true,
        "mapping": [
          {
            "identity": "EHM",
            "map": "Redigerat namn"
          }
        ]
      },
      {
        "id": "Patient.name.family",
        "path": "Patient.name.family",
        "definition": "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": 60,
        "mustSupport": true,
        "mapping": [
          {
            "identity": "EHM",
            "map": "Efternamn"
          }
        ]
      },
      {
        "id": "Patient.name.given",
        "path": "Patient.name.given",
        "definition": "Given name. Commonly use first name (sv: tilltalsnamn) is marked with the code \"CL\" for \"Call me\".",
        "mustSupport": true,
        "mapping": [
          {
            "identity": "EHM",
            "map": "Förnamn"
          }
        ]
      },
      {
        "id": "Patient.name.given.extension",
        "path": "Patient.name.given.extension",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "url"
            }
          ],
          "rules": "open"
        }
      },
      {
        "id": "Patient.name.given.extension:nllNameQualifier",
        "path": "Patient.name.given.extension",
        "sliceName": "nllNameQualifier",
        "short": "CL",
        "definition": "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 \"tilltalsnamn\".",
        "type": [
          {
            "code": "Extension",
            "profile": [
              "http://hl7.org/fhir/StructureDefinition/iso21090-EN-qualifier"
            ]
          }
        ]
      },
      {
        "id": "Patient.name.given.extension:nllNameQualifier.value[x]:valueCode",
        "path": "Patient.name.given.extension.value[x]",
        "sliceName": "valueCode",
        "binding": {
          "strength": "required",
          "valueSet": "http://electronichealth.se/fhir/ValueSet/given-name-types"
        }
      },
      {
        "id": "Patient.gender",
        "path": "Patient.gender",
        "short": "male | female | unknown",
        "definition": "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": true,
        "mapping": [
          {
            "identity": "EHM",
            "map": "Kön",
            "comment": "Only used in cases where the patient doesn't have/use the national identification number."
          }
        ]
      },
      {
        "id": "Patient.birthDate",
        "path": "Patient.birthDate",
        "definition": "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": "Example NLL",
            "valueDate": "2020-02-01"
          }
        ],
        "mustSupport": true,
        "mapping": [
          {
            "identity": "EHM",
            "map": "Födelsedatum",
            "comment": "Only used in cases where the patient doesn't have/use the national identification number."
          }
        ]
      },
      {
        "id": "Patient.deceased[x]",
        "path": "Patient.deceased[x]",
        "definition": "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": "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.\n\nNLL: translated from FOLK status 4 = Person avliden to this flag on FHIR service",
        "type": [
          {
            "code": "boolean"
          }
        ],
        "meaningWhenMissing": "Person is not deceased",
        "mustSupport": true,
        "mapping": [
          {
            "identity": "EHM",
            "map": "Avliden"
          }
        ]
      },
      {
        "id": "Patient.address",
        "path": "Patient.address",
        "definition": "An address for the individual. The Swedish National Medications List only returns city and postal code.",
        "max": "1",
        "mapping": [
          {
            "identity": "EHM",
            "map": "Personadress"
          }
        ]
      },
      {
        "id": "Patient.address.extension",
        "path": "Patient.address.extension",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "url"
            }
          ],
          "rules": "open"
        }
      },
      {
        "id": "Patient.address.extension:nllMunicipalityCode",
        "path": "Patient.address.extension",
        "sliceName": "nllMunicipalityCode",
        "short": "Municipality code (sv. kommunkod)",
        "definition": "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.\r\nExample: Kalmar 0880",
        "type": [
          {
            "code": "Extension",
            "profile": [
              "http://electronichealth.se/fhir/StructureDefinition/NLLMunicipalityCode"
            ]
          }
        ],
        "binding": {
          "strength": "required",
          "description": "Statistics in Sweden (SCB)",
          "valueSet": "http://scb.se"
        }
      },
      {
        "id": "Patient.address.extension:nllRegionCode",
        "path": "Patient.address.extension",
        "sliceName": "nllRegionCode",
        "short": "Region code (sv: region/länskod)",
        "definition": "Region code is a two letter numeric code for regions (sv: region/län) in Sweden",
        "type": [
          {
            "code": "Extension",
            "profile": [
              "http://electronichealth.se/fhir/StructureDefinition/NLLRegionCode"
            ]
          }
        ],
        "binding": {
          "strength": "required",
          "description": "Statistics in Sweden (SCB)",
          "valueSet": "http://scb.se"
        }
      },
      {
        "id": "Patient.address.postalCode",
        "path": "Patient.address.postalCode",
        "definition": "A postal code designating a region defined by the postal service. Maximum string length 5 characters.",
        "example": [
          {
            "label": "Example NLL",
            "valueString": "39231"
          }
        ],
        "maxLength": 5,
        "mustSupport": true,
        "mapping": [
          {
            "identity": "EHM",
            "map": "Postnummer"
          }
        ]
      }
    ]
  }
}