Identifiers & matching


PKB supports 4 types of identifier in the HL7 API:

  • System. PKB assigns each patient a UUID. This is unique across the entire PKB system, and can be used to identify a patient independently of their links to any country, organisation or team.

  • Email address. PKB permits an email address to be used to target a medical record.

  • National. A national identifier is an identifier that identifies a patient within a given country, such as an NHS number.

  • Local. A local identifier is an identifier which identifies a patient uniquely for a sender, but not outside that sender. An example would be a hospital number. A local identifier can be associated with either a PKB Organisation or a PKB Team.

See also the Identifiers section of our Data Model for more information.

Identifier type assignment

An HL7 identifier consists of several components. PKB is only interested in the following components:

  • [1] ID

  • [4] Assigning Authority

  • [5] Identifier Type Code

An identifier can appear in either PID-2 or PID-3. The field that the identifier appears in (or its position within the list of identifiers if PID-3), is not important to PKB.

We determine which type of identifier has been provided by matching the Assigning Authority (AA) and the Identifier Type Code (TC) to known types. To provide a national ID you must provide the AA and TC corresponding to the relevant identifier. These are given in the following section. To provide a local ID, you need to first agree with us what AA and TC values you use for each of your identifier types. We need to configure these for you before the IDs will be processed by our HL7 API.

Any supplied identifier that does not match a known type will be silently ignored.

System identifiers

In order to send through the PKB ID, you need to provide:

  • an Assigning Authority of: PKB

  • an Identifier Type Code of: PI

Email address identifiers

In order to use an email address as an identifier, you must provide it as an identifier (e.g. PID-3) rather than a contact point (e.g. PID-13). This is to ensure an unconfirmed email address is not accidentally included in a matching workflow. In order for an email address value to be recognised as an identifier, you must provide:

  • an Assigning Authority of: EMAIL

  • an Identifier Type Code of: EMAIL

An email address identifier will only match a medical record if the email address is either a) the primary address on the record, or b) a secondary address but which has been confirmed.

No more than one email address identifier can be included.

See our dedicated email addresses page for additional information and business logic rules.

National identifiers

In order to send through a national ID, you need to supply the Assigning Authority and Identifier Type Code as detailed in the table below.

Identifier Name


Assigning Authority

Identifier Type Code

Status Code

NHS Number *




In addition, note that the NHS number can optionally include a status code, as defined in the NHS Data Dictionary . If present, the status code is supplied with the identifier type code, in the format NH{status:XX} where XX is the status code. There must be no space between “NH” and the status code. Since the status code is optional, “NH” remains a valid identifier type code. For example: NH{status:01}

CHI Number *


NHS Scotland



Health and Care Number *





Individual Health Identifier





























Civil ID





*A note about NHS-Type Numbers. The following 3 National ID Types are drawn from the same numbering scheme, but with non-overlapping ranges. PKB considers them to be separate types. It is the responsibility of the sender to ensure the correct AA/TC values are sent.

  • CHI Number (Scotland): 010 101 0000 to 311 299 9999

  • Health and Care Number (Northern Ireland): 320 000 0010 to 399 999 9999

  • NHS Number (England and Wales): 400 000 0000 to 999 999 9999


PKB sandbox ( will only accept NHS numbers starting with 9 or a 5 and CHI and H&C numbers where the 7th and 8th digits are both set to 9. This is to help prevent accidental submission of real patient data to the sandbox environment.

Local identifiers

You will need to agree with PKB what local identifiers you would like to send through.

Each PKB Organisation or PKB Team can be associated with multiple local identifier types, and each patient can be associated with multiple ID values for each local identifier type.

Restrictions & scope

The scope of AA/TC pairs for local IDs is the whole PKB Organisation. All AA/TC pairs for a PKB Organisation (and for all PKB Teams within that PKB Organisation) must be unique across the PKB Organisation.

A local ID AA/TC pair must not match the AA/TC pair for any national ID.

The scope of a local ID is always the entire PKB Organisation which contains it. As such, a team-level HL7 connection can read and write local IDs of a type associated with another PKB Team (providing it is within the same PKB Organisation).


Once all the provided identifiers have been assigned to their corresponding types, PKB will attempt to match them to an existing medical record.

Hard matching

Hard matching refers to the process of identifying a medical record based on the values of the identifiers provided.

National and Local Identifiers are case sensitive.

Soft matching

Soft matching is an optional process allowing for stricter patient matching based on demographic fields in addition to any identifiers, such as an NHS number. If soft matching is enabled, then when an HL7 message is successfully matched to a patient record based on the provided identifiers (hard matching) then PKB will also check that the demographics in the HL7 message match those that we have in the record. If they do not match, then the message will be quarantined for review by an Organisation Administrator.

There is an exception to this - soft matching will be bypassed if PKB detects that a previous accept/reject decision has already been made for the same data point. In that scenario the same decision will be applied to the HL7 message, regardless of whether the configured demographics fields match. For example, if a lab result is added into a patient's record on Monday, but a correction is sent on Tuesday with incorrect demographics, then the message will still be accepted because the Filler Order Number will match the initial data sent on Monday. This also applies retrospectively. For example, if a lab result is quarantined for Organisation Administrator review on Monday, but a correction is sent on Tuesday with correct demographics, then the message from Monday will be automatically accepted along with the message from Tuesday. This logic helps to ensure that a data point is accepted/rejected consistently; this is safer, and also reduces false-positives, freeing Organisation Administrators to look at messages containing data points that have consistently failed to match the target patient.

Note: Demographic-based soft matching is not applicable to messages which create a new patient record or update the demographics of an existing patient record (i.e. ADT A28/A31) - see the NHS number status checking section below.

Supported fields

  • Date of birth is the only supported field for new soft matching configuration requests

End of life support

The following fields are no longer supported for new customers.

  • Surname

    • The soft matching process ignores case sensitivity and the use of whitespace, e.g Smith will match to smith .

  • Forename

    • Forename (full): The provided and known forename values are matched in their entirety, e.g. jo does not match joanne

    • Forename (short): The provided and known forename values are matched up to the length of the shorter of the two, e.g. jo does match joanne

    • Forename (initial): The provided and known forename values are matched just on the initial letter, e.g. jo does match janet

    • In all cases the soft matching process ignores case sensitivity and strips whitespace from the start or end.

  • Gender

  • Postal Code

    • The soft matching process ignores case sensitivity and the use of whitespace, e.g TS1TER will match to tS 1 T er.

NHS number status checking

Some messages cannot be soft-matched based on demographics.

  • When creating a new medical record there is no prior demographic information to match against.

  • When updating the demographic information on an existing medical record we must allow the message to change the existing demographic data, rather than match what is already stored.

Instead, PKB can optionally configure an interface to soft-match these messages based on the NHS number status. If this option is enabled, and an NHS number is provided, then PKB will check that the status is present and equal to “01” before creating or updating the medical record. If the check fails, then:

  • If the target medical record does not exist, PKB will ignore the NHS number and behave as if it had not been provided.

  • If the target medical record does exist, PKB will queue the message as needing manual review. A human must then manually confirm that the unverified demographic changes are correct.

In addition, if this option is enabled then an NHS number must be provided to update the demographics information of a medical record that already has an NHS number associated with it.

Auto create

By default, medical records for new patients are created upon receipt of an A28 or A31 message only. PID segments for other message types that do not match a medical record will return an error. If you would like to disable this strict record checking, such that a new medical record is created whenever an unmatched PID is received (in any message) then we can configure this for you. However, you will still need to send an A28 or A31 to update the demographic details about each patient.


The diagram below demonstrates our matching workflow.