---
title: "Patient Identifier and Demographic Retrieval"
canonical: "https://wiki.patientsknowbest.com/space/api/4504551428/Patient%20Identifier%20and%20Demographic%20Retrieval"
format: markdown
---
> Macro (toc)

# What

Enables you to pull back a patient’s PKB public ID and / or a patient’s demographic details, including national identifiers held in PKB.

# Prerequisites

- [A patient scoped access token](https://wiki.hub.patientsknowbest.com/wiki/spaces/api/pages/4474830855).

# How To

Using a valid [Patient scoped access token](https://wiki.hub.patientsknowbest.com/wiki/spaces/api/pages/4474830855), the partner application pulls the patient’s details.  There are a few options, two of which are outlined below, and the best option depends on what the partner use case is.

- PKB **public id** using the <u>[FHIR Purview operation](https://wiki.patientsknowbest.com/space/api/3364946545/Purview)</u> on PKB’s <u>[Facade FHIR API](https://wiki.patientsknowbest.com/space/api/3364618357/Facade)</u>.  Example request is <u>[here](https://wiki.patientsknowbest.com/space/api/3364061249/Facade%253A+Examples+(operations)#Check-the-current-user's-purview)</u>, and an example response is below.

```
{
    "resourceType": "Parameters",
    "parameter": [
        {
            "name": "purview",
            "valueReference": {
                "reference": "Patient/1d4a8b2d-f885-499f-ba51-50600312f316"
            }
        }
    ]
}
```


- Demographic details, including any identifiers (national/local) in the PKB record, using PKB’s REST API.  Example response is [here (/users/self)](https://sandbox.patientsknowbest.com/swagger-ui/index.html#/Users/getUser).  Example request / response below.

```
curl --location 'https://sandbox.patientsknowbest.com/json/users/self' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer LtftuUgRkYTl3QC9-DpQ3rDvZN09i3s0'
```

Response:

```
{
    "id": "7329844",
    "userType": null,
    "heightCm": "2",
    "heightFeet": "0",
    "heightInches": "1",
    "heightInchesTotal": "1",
    "weightKg": "87",
    "weightLbs": "191.8",
    "title": "Dr.",
    "firstName": "Bobby",
    "lastName": "Barton",
    "dob": "2000-01-01",
    "dateDeceased": null,
    "genderMF": "m",
    "gender": "M",
    "email": "bobbybarton@pkbtest.com",
    "phone": "",
    "address1": "Michael Springs",
    "address2": "",
    "city": "Lake Mary",
    "state": "COUNTY",
    "postalCode": "BS10 5NB",
    "country": "GB-ENG",
    "jobTitle": null,
    "organizationName": null,
    "teamName": null,
    "nationalIds": [
        {
            "value": "9991566171",
            "name": "NHS number",
            "countryCodes": [
                "GB-ENG",
                "GB-WLS"
            ]
        }
    ],
    "orgLevelIds": null,
    "teamLevelIds": null,
    "contacts": [
        {
            "id": "10728020",
            "contactType": "EMAIL",
            "contactValue": "bobbybarton@pkbtest.com",
            "phoneUseType": null,
            "primary": true,
            "confirmed": true
        }
    ],
    "patient": true
}
```


> 📝 For the patient’s gender, use the "gender" field (not the “genderMF” field).  
> 📝 
> 📝 The “gender” field is the "Sex assigned at birth".  The options will be: I, F, U, or M.  To create the patient using the FHIR API, use the following case sensitive mappings. 
> 📝 
> 📝 REST ➡️ FHIR ➡️ PKB UI:
> 📝 
> 📝 - U ➡️ unknown ➡️ Unknown
> 📝 - M ➡️ male ➡️ Male
> 📝 - F ➡️ female ➡️ Female
> 📝 - I ➡️ other ➡️ Indeterminate