Page Status: Outdated

Patient - Fetch

Page index

Introduction

Sv: användningsfall - hämta patientinformation

This and the next few sections describe possible operations for the Patient resource, as well as common scenarios you might invoke the operations with, and the error messages you might see.

The first section is about fetching a Patient based on the Swedish personal identification number (personnummer). Fetching patient information is used to verify the identity of the person you're working with is the right one, or to verify certain claims about the person: such as whenever they're a Swedish citizen.

It is not supported to fetch all patients:

GET [base]/fhir/Patient

Instead, a request for patient information must specify one and only one patient.

Note: the personal identification numbers used in examples are "test identity numbers" defined by the Swedish Tax Agency and not associated with a real person. These test persons could, but normally are not available in our test environment.

Sequence diagram

This interactions shows a sequence where the client is fetching a patient resource. The interaction requires a valid authorization token as an initial step, which is not shown in the diagram.

Note that the requests shown in the diagram doesn't include the full basepath. It only shows the last part of the http request including resource and possible search/query parameters.

See the generic example for other type of responses.

Examples

HTTP Header

Parameter Mandatory Comment
Authorization Yes Bearer [valid OAuth2 token]
X-Access Yes Applicable access type, e.g. EGNA_UPPGIFTER
X-Purpose Yes Applicable access type, e.g. LASA_EGNA_UPPGIFTER
X-Provenance N/A
X-Request-ID Yes UUID
X-User-Agent Yes
X-OrgInfo Yes Only applicable for health care organizations

Full list of access and purpose types will be enclosed in the developer portal Confluence, EHM

Example 1

Client performs a search for a patient, based on the Swedish personal identity number to use for further queries on e.g. MedicationRequests.

Search-query: GET [base]/fhir/Patient?identifier=199003222396

Response

Status: 200 OK

Body:
{
   "resourceType" : "Bundle",
   "id" : "4956a72d-3e59-41ec-b69f-4c465376f81b",
   "meta" : {
      "lastUpdated" : "2020-05-28T09:24:39.179+02:00"
   },
   "type" : "searchset",
   "total" : 1,
   "link" : [
      {
         "relation" : "self",
         "url" : "https://[base]fhir/Patient?identifier=199003222396"
      }
   ],
   "entry" : [
      {
         "fullUrl" : "https://[base]/fhir/Patient/0bbc823a-245e-40e0-9052-81e9fc7d4488",
         "resource" : {
            "resourceType" : "Patient",
            "id" : "0bbc823a-245e-40e0-9052-81e9fc7d4488",
            "meta" : {
               "profile" : [
                  "http://electronichealth.se/fhir/StructureDefinition/NLLPatient"
               ],
               "security" : [
                  {
                     "system" : "http://terminology.hl7.org/CodeSystem/v3-ObservationValue",
                     "code" : "SUBSETTED",
                     "display" : "subsetted"
                  }
               ]
            },
            "text" : {
               "status" : "generated",
               "div" : "<div xmlns=\"http://www.w3.org/1999/xhtml\"><div class=\"hapiHeaderText\">AFF <b>AFFSSON </b></div><table class=\"hapiPropertyTable\"><tbody><tr><td>Identifier</td><td>199003222396</td></tr></tbody></table></div>"
            },
            "identifier" : [
               {
                  "system" : "http://electronichealth.se/identifier/personnummer",
                  "value" : "199003222396"
               }
            ],
            "name" : [
               {
                  "family" : "Testsson",
                  "given" : [
                     "TestNamnet"
                  ],
                  "_given" : [
                     {
                        "extension" : [
                           {
                              "url" : "http://hl7.org/fhir/StructureDefinition/iso21090-EN-qualifier",
                              "valueString" : "CL"
                           }
                        ]
                     }
                  ]
               }
            ],
            "deceasedBoolean" : false
         }
      }
   ]
}

Comment: A search query will always return a bundle with an array of entries of the matching results. The personal identification number is a unique identifier, meaning that only one result will be returned in the bundle.

Example 2

Client initiates a search for a patient, based on the Swedish personal identity number - but there is a typo; the identification number is in the wrong format:

Search-query: GET [base]/fhir/Patient?identifier=199811162355

Response

Status: 200 

Body:
...
{
  "resourceType": "OperationOutcome",
  "text": {
    "status": "generated",
    "div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><h1>Operation Outcome</h1>..."
  },
  "issue": [
    {
      "severity": "error",
      "code": "invalid",
      "details": {
        "coding": [
          {
            "system": "http://nll.ehm.se",
            "code": "2-25-5",
            "display": "Valideringsfel"
          }
        ]
      },
      "diagnostics": "[uehm1eta01] [96DF] SbtpValidationApplicationException: validation errors occurred [personnummer: '199811162355' modulus 10 check failed]"
    }
  ]
}

Comment: A failed search for a patient can result in a status 400 if the personnummer format is faulty. If the format is correct but the patient doesn't exist, a status 200 is returned with an empty searchset.

Example 3

Client initiates a search for a patient, based on the Swedish personal identity number. The identity of the patient is protected, meaning that some information is masked.

Search-query: GET [base]/fhir/Patient?identifier=199811162396

Response

Status: 200 OK

Body:
{
   "resourceType" : "Bundle",
   "id" : "d4384c31-b827-496c-ba88-1ff8f1d36927",
   "meta" : {
      "lastUpdated" : "2020-05-28T09:24:39.531+02:00"
   },
   "type" : "searchset",
   "total" : 1,
   "link" : [
      {
         "relation" : "self",
         "url" : "https://[base]/fhir/Patient?identifier=199811162396"
      }
   ],
   "entry" : [
      {
         "fullUrl" : "https://[base]/fhir/Patient/22f06e10-1cf6-47a2-a7cc-e26bf0b95a21",
         "resource" : {
            "resourceType" : "Patient",
            "id" : "22f06e10-1cf6-47a2-a7cc-e26bf0b95a21",
            "meta" : {
               "profile" : [
                  "http://electronichealth.se/fhir/StructureDefinition/NLLPatient"
               ],
               "security" : [
                  {
                     "system" : "http://terminology.hl7.org/CodeSystem/v3-ObservationValue",
                     "code" : "SUBSETTED",
                     "display" : "subsetted"
                  }
               ]
            },
            "text" : {
               "status" : "generated",
               "div" : "<div xmlns=\"http://www.w3.org/1999/xhtml\"><div class=\"hapiHeaderText\">Personuppgift skyddad <b>PERSONUPPGIFT SKYDDAD </b></div><table class=\"hapiPropertyTable\"><tbody><tr><td>Identifier</td><td>199811162396</td></tr></tbody></table></div>"
            },
            "identifier" : [
               {
                  "system" : "http://electronichealth.se/identifier/personnummer",
                  "value" : "199811162396"
               }
            ],
            "name" : [
               {
                  "family" : "Personuppgift skyddad",
                  "given" : [
                     "Personuppgift skyddad"
                  ]
               }
            ],
            "deceasedBoolean" : false
         }
      }
   ]
}

Example 4

Client using an absolute uri to fetch a patient, e.g. as a result of a chain of requests where patient uri has previously been found through a search.

Request: GET https://[base]/fhir/Patient/80265756-2d37-42e0-9fe7-bd2627db0301

Response

Status: 200 OK

Body
{
   "resourceType" : "Patient",
   "id" : "0bbc823a-245e-40e0-9052-81e9fc7d4488",
   "meta" : {
      "profile" : [
         "http://electronichealth.se/fhir/StructureDefinition/NLLPatient"
      ],
      "security" : [
         {
            "system" : "http://terminology.hl7.org/CodeSystem/v3-ObservationValue",
            "code" : "SUBSETTED",
            "display" : "subsetted"
         }
      ]
   },
   "text" : {
      "status" : "generated",
      "div" : "<div xmlns=\"http://www.w3.org/1999/xhtml\"><div class=\"hapiHeaderText\">AFF <b>AFFSSON </b></div><table class=\"hapiPropertyTable\"><tbody><tr><td>Identifier</td><td>198008209275</td></tr></tbody></table></div>"
   },
   "identifier" : [
      {
         "system" : "http://electronichealth.se/identifier/personnummer",
         "value" : "198008209275"
      }
   ],
   "name" : [
      {
         "family" : "Testsson",
         "given" : [
            "Testnamn"
         ],
         "_given" : [
            {
               "extension" : [
                  {
                     "url" : "http://hl7.org/fhir/StructureDefinition/iso21090-EN-qualifier",
                     "valueString" : "CL"
                  }
               ]
            }
         ]
      }
   ],
   "deceasedBoolean" : false
}

Comment: Compared to example 1, resource (Patient) is returned the plain resource structure rather than a searchset bundle - since a specific resource is requested by ID instead of performing a search.