R/validate_data.R
validate_inpatient_episodes.Rd
This function performs a series of checks for mandatory and optional requirements on episodes of care records. The data definitions closely follow those of the English NHS Admitted Patient Care Commissioning Datasets.
validate_inpatient_episodes(patients, episodes, wards = NULL)
data frame containing one row per patient
data frame containing one row per episode of care
(optional) data frame containing one row per ward stay.
Default is NULL
.
A logical value indicating success
patient_id
a patient identifier with no missing value
forename
the patient's forename
surname
the patient's surname
date_of_birth
a Date
for the birth date
date_of_death
a missing value or a Date
of death
sex
the following values are valid:
"male"
"female"
"other"
"unknown"
Must not be missing.
ethnic_category_UK
reserved for UK users for Ramses
to compute
the empirical glomerular filtration rate (eGFR). The following codes are valid:
White
"A"
British
"B"
Irish
"C"
Any other White background
Mixed
"D"
White and Black Caribbean
"E"
White and Black African
"F"
White and Asian
"G"
Any other mixed background
Asian or Asian British
"H"
Indian
"J"
Pakistani
"K"
Bangladeshi
"L"
Any other Asian background
Black or Black British
"M"
Caribbean
"N"
African
"P"
Any other Black background
Other Ethnic Groups
"R"
Chinese
"S"
Any other ethnic group
Not stated
"Z"
Not stated
patient_id
a patient identifier with no missing value
encounter_id
a hospital encounter (admission or spell) identifier with no missing value
admission_method
a non-missing character code:
"1"
elective admission
"2"
emergency admission
"3"
transfer/other admission
Note: "1"
and "2"
corresponds to the first character
of the
NHS admission method value set;
"3"
corresponds to the remaining values starting with
3
or 8
.
admission_date
a POSIXct
timestamp for
the hospital admission. Must not be missing.
discharge_date
a POSIXct
timestamp for
the hospital discharge. Must not be missing.
episode_number
a strictly positive integer indicating the number of the episode within an admission. Must not be missing.
last_episode_in_encounter
a character indicating whether the patient is discharged at the end of the episode:
"1"
the episode is the last episode in the encounter
"2"
the episode is not the last episode in the encounter
Must not be missing.
episode_start
a POSIXct
timestamp for
the hospital start. Must not be missing.
episode_end
a POSIXct
timestamp for
the hospital end Must not be missing.
consultant_code
a code uniquely identifying the medical professional responsible for the episode of care. Must not be missing.
main_specialty_code
a code identifying the main specialty of the medical professional responsible for the episode of care. Must not be missing.
patient_id
a patient identifier with no missing value
encounter_id
a hospital encounter identifier with no missing value
ward_code
character vector of ward codes
ward_display_name
character vector of expanded ward designations
ward_description
full text description of service/unit/specialty
ward_start
a POSIXct
timestamp for
the arrival time on the ward
ward_end
a POSIXct
timestamp for
the ward departure time