-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcmea10.rmd
67 lines (47 loc) · 1.57 KB
/
cmea10.rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
---
title: "Central Medical Evaluation (CME) ICD-10 Agreement"
output: rmarkdown::github_document
---
During the physician coding for Verbal Autopsies (VA), ICD-10 codes can be considered in agreement if they are within a certain ICD-10 code range.
This script processes data for ICD-10 blocks that determine the agreement between physician assigned ICD-10 codes from VAs.
## Libraries
```{r}
library(tidyverse)
library(cghrCodes)
```
## Read Data
Read data from `../data` folder:
* `icd10-equivalent-1.csv`: original ICD-10 equivalency file for reconciliation and adjudication provided by Rajeev Kamadod
```{r}
raw_file <- "../data/icd10-equivalent-1.csv"
cmea_raw <- read_csv(raw_file, show_col_types = FALSE)
cmea_raw
```
## Preprocess
Preprocesses the data by lowercasing all column names
```{r}
cmea <- cmea_raw %>% rename_all(tolower)
cmea
```
## Expand ICD-10 Ranges
Expands the ICD-10 codes from the `icdequivalence` column to create an ICD-10 code for each code block:
```{r}
icd10tocmea <- expandICD10Data(
cmea,
icd10Column="icdequivalence",
expandColumn="icd10_code"
)
icd10tocmea
```
## Collapse ICD-10 Ranges
Collapse the individual ICD-10 ranges to add a short form column with consecutive ranges defined by `-`:
```{r}
cmea$icdequivalence_short <- apply(cmea, 1, function(x) paste(collapseICD10(x["icdequivalence"]), collapse=","))
cmea
```
## Save Data
Writes the collapsed and expanded CME ICD-10 agreement codes to the `../data` folder.
```{r}
write_csv(cmea, "../data/cmea10_raw.csv", na="")
write_csv(icd10tocmea, "../data/icd10tocmea10_raw.csv", na="")
```