-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
141 lines (99 loc) · 5.6 KB
/
README.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# WHOicd
<!-- badges: start -->
[![CRAN status](https://www.r-pkg.org/badges/version/WHOicd)](https://CRAN.R-project.org/package=WHOicd)
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)
[![Codecov test coverage](https://codecov.io/gh/RodrigoZepeda/WHOicd/branch/main/graph/badge.svg)](https://app.codecov.io/gh/RodrigoZepeda/WHOicd?branch=main)
[![R-CMD-check](https://github.com/RodrigoZepeda/WHOicd/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/RodrigoZepeda/WHOicd/actions/workflows/R-CMD-check.yaml)
<!-- badges: end -->
Access the World Health Organization's (WHO) International Classification of Diseases (ICD) [API](https://icd.who.int/icdapi). This allows you to use ICD-10 and ICD-11 codes, encode text directly into ICD-11, search for diseases in ICD-10, and detect underlying causes of death using the [DORIS system](https://icd.who.int/doris).
## Installation
You can install the development version of WHOicd using the `remotes` package:
``` r
#install.packages("remotes")
remotes::install_github("RodrigoZepeda/WHOicd")
```
## Setup
```{r, echo=FALSE}
CLIENT_ID <- Sys.getenv("CLIENT_ID")
CLIENT_SECRET <- Sys.getenv("CLIENT_SECRET")
```
For the examples we'll assume you already have a `CLIENT_ID` and `CLIENT_SECRET`
for the WHO API as obtained in the [**Generaring your token**](/articles/Generating-your-token.html) article.
To interact with the API you'll need to continuously create a token using the `get_token` function:
```{r}
library(WHOicd)
#Substitute CLIENT_ID and CLIENT_SECRET by your credentials
token <- get_token(CLIENT_ID, CLIENT_SECRET)
```
> **Note** These tokens last for 1 hour and once the hour passes you'll need to generate a new token. The package will try to auto-generate one for you.
There are three main objectives for this package:
1. Use of the DORIS system to obtain underlying cause of death from death certificate information.
2. [Use of ICD-11 to codify causes of death](https://rodrigozepeda.github.io/WHOicd/articles/ICD-11.html).
3. [Use of ICD-10 to search for causes of death](https://rodrigozepeda.github.io/WHOicd/articles/ICD-10.html).
## DORIS (WHO Digital Open Rule Integrated Cause of Death Selection)
The [Digital Open Rule Integrated Cause of Death Selection](https://icd.who.int/doris/en), DORIS,
provides a framework for obtaining the underlying cause of death from a death certificate. DORIS
functionality has been implemented in the `doris()` function.
The following example considers a 60 year old female whose primary cause of death was `2D42`:
`Malignant neoplasms of ill-defined sites` due to `2E03`: `Malignant neoplasm metastasis in bone or bone marrow` due to `CB41.0Z`: `Acute respiratory failure, unspecified`.
```{r}
doris(token, sex = "Female", age = iso_8601(years = 60), cause_of_death_code_a = "2D42",
cause_of_death_code_b = "2E03", cause_of_death_code_c = "CB41.0Z")
```
All of the options are available in the function's help page [`doris()`](https://rodrigozepeda.github.io/WHOicd/reference/doris.html).
## ICD-11 examples
The main functions relating to ICD-11 are `icd11_search()` and `icd11_autocode()`. The first one allows you to search for a specific diagnosis using keywords inside `ICD-11` either in the _Mortality and Morbidity Statistics (MMS)_ or in the _International Classification of Functioning, Disability and Health (ICF)_.
The following example searches for any coding related to Dementia related to HIV stage 4
```{r}
#Look for Dementia and HIV stage 4
search_results <- icd11_search(token, "Dementia HIV stage 4")
#Recover all of the titles matched
search_results |> retrieve("title")
```
Another function of importance is `autocode` which reads plain-text diagnostic text and returns the best matching code either in _MMS_ or _ICF_
```{r}
#Auto code a diagnostic text such as `cerebrovascular accident`
code_results <- icd11_autocode(token, "Patient with cerebrovascular accident")
#Recover the code that matched
code_results |> retrieve("theCode")
```
Additional information on ICD-11 can be found in the [ICD-11 article](https://rodrigozepeda.github.io/WHOicd/articles/ICD-11.html)
## ICD-10 examples
The main function relating to ICD-10 is `icd10_search()` which searches for the titles and parents of codes, blocks of chapters. As an example, we can search for the following vector and obtain a `data.frame`:
```{r}
#| results: false
#Search for code, specific code, chapter and block
codes <- c("D60", "IX", "I10-I15")
icd10_search(token, codes)
```
```{r}
#| echo: false
icd10_search(token, codes) |> tibble::as_tibble()
```
If you only want to get the title of the current code/chapter/block you can use `icd10_title` which is faster as it requires less requests to the API:
```{r}
#| results: false
#Search for code, specific code, chapter and block
codes <- c("D60", "IX", "I10-I15")
icd10_title(token, codes)
```
```{r}
#| echo: false
#Search for code, specific code, chapter and block
icd10_title(token, codes) |> tibble::as_tibble()
```
Additional information on ICD-10 can be found in the [ICD-10 article](https://rodrigozepeda.github.io/WHOicd/articles/ICD-10.html)
## Support
This is not an official product of the WHO. However we are happy to provide support if you [raise an issue](https://docs.github.com/en/issues/tracking-your-work-with-issues/creating-an-issue).