Reads a local copy of the CALIBER repository into R. All CALIBER codes are read into a named list containing 3 data frames: primary care Read 2, secondary care ICD10 and secondary care OPCS4 codes.
read_caliber_raw(caliber_dir_path, overlapping_disease_categories = "error")
Path to a locally downloaded copy of the CALIBER github repository.
If 'error' (default), raises an error if any overlapping disease categories are present after mapping. Specify 'warning' to raise a warning instead.
A named list of data frames.
The directory supplied to caliber_dir_path
is expected to contain
subdirectories primary_care
and secondary_care
, each of which contains
csv files with clinical code lists.
Note also that:
Medcodes are dropped
Minimal reformatting is performed so that primary and secondary care codes may be combined into a single data frame
# read local copy of CALIBER repository into a named list. Note that
# (i) Medcodes are dropped and (ii) minimal reformatting is performed so that
# primary and secondary care codes may be combined into a single data frame
caliber_raw <- read_caliber_raw(dummy_caliber_dir_path())
#> Reading CALIBER clinical codes lists into R
#> Primary care Read 2 (1 of 3)
#> Secondary care ICD10 (2 of 3)
#> Secondary care OPCS4 (3 of 3)
caliber_raw
#> $read2
#> # A tibble: 142 × 6
#> disease description category code_type code author
#> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 End stage renal disease End stage renal fail… Diagnos… Readcode K050… calib…
#> 2 End stage renal disease End stage renal fail… Diagnos… Medcode 6712 calib…
#> 3 End stage renal disease End stage renal fail… Diagnos… Readcode K05.… calib…
#> 4 End stage renal disease End stage renal fail… Diagnos… Medcode 53852 calib…
#> 5 End stage renal disease End-stage renal dise… Procedu… Readcode K0D.… calib…
#> 6 End stage renal disease End-stage renal dise… Procedu… Medcode 8330 calib…
#> 7 Diabetes Type 1 diabetes mell… Type I … Readcode C108… calib…
#> 8 Diabetes Type 1 diabetes mell… Type I … Medcode 17858 calib…
#> 9 Diabetes Type I diabetes mell… Type I … Readcode C108… calib…
#> 10 Diabetes Type I diabetes mell… Type I … Medcode 24423 calib…
#> # … with 132 more rows
#>
#> $icd10
#> # A tibble: 7 × 6
#> disease description category code_type code author
#> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 Tuberculosis Tuberculos… Diagnos… icd10 M90.0 calib…
#> 2 Asthma Asthma Diagnos… icd10 J45 calib…
#> 3 Bacterial Diseases (excl TB) Scarlet fe… Diagnos… icd10 A38 calib…
#> 4 Bacterial Diseases (excl TB) Osteomyeli… Diagnos… icd10 M86 calib…
#> 5 Postviral fatigue syndrome, neura… Neurasthen… Diagnos… icd10 F48.0 calib…
#> 6 Diabetes Insulin-de… Insulin… icd10 E10 calib…
#> 7 Diabetes Diabetes m… Seconda… icd10 O242 calib…
#>
#> $opcs4
#> # A tibble: 5 × 6
#> disease description category code_type code author
#> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 Appendicitis Emergency excision of appendix Procedu… opcs4 H01 calib…
#> 2 Appendicitis Emergency excision of abnormal a… Procedu… opcs4 H01.1 calib…
#> 3 Appendicitis Emergency excision of abnormal a… Procedu… opcs4 H01.2 calib…
#> 4 Appendicitis Other specified emergency excisi… Procedu… opcs4 H01.8 calib…
#> 5 Appendicitis Unspecified emergency excision o… Procedu… opcs4 H01.9 calib…
#>
# combine into a single data frame using dplyr
dplyr::bind_rows(caliber_raw)
#> # A tibble: 154 × 6
#> disease description category code_type code author
#> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 End stage renal disease End stage renal fail… Diagnos… Readcode K050… calib…
#> 2 End stage renal disease End stage renal fail… Diagnos… Medcode 6712 calib…
#> 3 End stage renal disease End stage renal fail… Diagnos… Readcode K05.… calib…
#> 4 End stage renal disease End stage renal fail… Diagnos… Medcode 53852 calib…
#> 5 End stage renal disease End-stage renal dise… Procedu… Readcode K0D.… calib…
#> 6 End stage renal disease End-stage renal dise… Procedu… Medcode 8330 calib…
#> 7 Diabetes Type 1 diabetes mell… Type I … Readcode C108… calib…
#> 8 Diabetes Type 1 diabetes mell… Type I … Medcode 17858 calib…
#> 9 Diabetes Type I diabetes mell… Type I … Readcode C108… calib…
#> 10 Diabetes Type I diabetes mell… Type I … Medcode 24423 calib…
#> # … with 144 more rows