Skip to contents

[Stable]

Groups patient records from multiple isolates with a single integer patientID by grouping patient identifiers.

Grouping is based on the following stages:

  1. matching nhs number and date of birth

  2. Hospital number & Date of Birth

  3. NHS number & Hospital Number

  4. NHS number & Name

  5. Hospital number & Name

  6. Sex & Date of Birth & Surname

  7. Sex & Date of Birth & Fuzzy Name

  8. Sex & Year and Month of Birth & Fuzzy Name

  9. Postcode & Name

  10. Name Swaps (when first and last name are the wrong way around)

Identifiers are copied over where they are missing or invalid to the grouped records.

Usage

uk_patient_id(
  data,
  id = list(nhs_number = "nhs_number", hospital_number = "patient_hospital_number",
    date_of_birth = "date_of_birth", sex_mfu = "sex", forename = "forename", surname =
    "surname", postcode = "postcode"),
  .useStages = c(1:11),
  .sortOrder,
  .keepValidNHS = FALSE,
  .forceCopy = FALSE
)

Arguments

data

a data.frame or data.table containing the patient data

id

a named list to provide the column names with identifiers, quoted

nhs_number

the patient NHS number

hospital_number

the patient Hospital numbers also known as the local patient identifier

date_of_birth

the patient date of birth

sex_mfu

the patient sex or gender field as Male/Female/Unknown

forename

the patient forename

surname

the patient surname

postcode

the patient postcode

.useStages

optional, default 1:11; set to 1 if you wish patient ID to be assigned cases with the same DOB and NHS number, set to 2 if you wish patient ID to be assigned to cases with the same hospital number (HOS) and DOB, set to 3 if you wish patient ID to be assigned cases with the same NHS and HOS number, set to 4 if you wish patient ID to be assigned cases with the same NHS number and surname, set to 5 if you wish patient ID to be assigned cases with the same hospital number and surname, set to 6 if you wish patient ID to be assigned cases with the same DOB and surname, set to 7 if you wish patient ID to be assigned cases with the same sex and full name, set to 8 if you wish patient ID to be assigned cases with the same sex, DOB and fuzzy name, set to 9 if you wish patient ID to be assigned cases with the same DOB and fuzzy name, set to 10 if you wish patient ID to be assigned cases with the same name and postcode, set to 11 if you wish patient ID to be assigned cases with the same first name or second name in changing order and date of birth.

.sortOrder

optional; a column as a character to allow a sorting order on the id generation

.keepValidNHS

optional, default FALSE; set TRUE if you wish to retain the column with the NHS checksum result stored as a BOOLEAN

.forceCopy

optional, default FALSE; TRUE will force data.table to take a copy instead of editing the data without reference

Value

A dataframe with one new variable:

id

a unique patient id

valid_nhs

if retained using argument .keepValidNHS=TRUE, a BOOLEAN containing the result of the NHS checksum validation

Examples