Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add reference tables for linearized mms #5

Merged
merged 1 commit into from
Feb 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions R/data.R
Original file line number Diff line number Diff line change
@@ -21,3 +21,64 @@
#' @source https://icd.who.int/docs/icd-api/SupportedClassifications/
#'
"icd_versions"


#'
#' ICD-11 Mortality and Morbidity Linearization Outputs
#'
#' @format A data frame with 21 columns and 36753 rows:
#'
#' | **Variable** | **Description** |
#' | :--- | :--- |
#' | *Foundation URI* | Foundation URI |
#' | *Linearization (release) URI* | Linearization release URI |
#' | *Code* | ICD-11 Code |
#' | *BlockId* | Block identifier |
#' | *Title* | Title |
#' | *ClassKind* | Class |
#' | *DepthInKind* | Depth |
#' | *IsResidual* | Is residual? |
#' | *PrimaryLocation* | Primary location |
#' | *ChapterNo* | Chapter number |
#' | *BrowserLink* | Browser link |
#' | *iCatLink* | Category link |
#' | *isLeaf* | Is leaf? |
#' | *noOfNonResidualChildren* | Number of non-residual children |
#' | *Primary tabulation* | Primary tabulation |
#' | *Version* | Date and time linearization was produced |
#'
#' @examples
#' icd11_linearization_mms
#'
#' @source https://icd.who.int/dev11/Downloads/Download?fileName=LinearizationMiniOutput-MMS-en.zip
#'
"icd11_linearization_mms"


#'
#' ICD-11 Mortality and Morbidity Simple Table Outputs
#'
#' @format A data frame with 18 columns and 36044 rows:
#'
#' | **Variable** | **Description** |
#' | :--- | :--- |
#' | *Foundation URI* | Unique identifier for the entity that will not change |
#' | *Linearization (release) URI* | Unique identifier for this version of the classification. It includes the linearization name such as MMS and minor version identifier such as 2018 in it |
#' | *Code* | ICD-11 code for the entity. Note that the groupings do not have a code. |
#' | *BlockId* | Identifier for high level groupings that do not bear a code |
#' | *Title* | Title of the entity |
#' | *ClassKind* | One of the three (chapter, block, category); Chapter is top level classification entities; Blocks are high level groupings that do not bear a code; Categories are entities that has a code |
#' | *DepthInKind* | Depth of within the Class Kind. For example, a category with depthinkind=2 means it is category whose parent is also a category but grand parent is not |
#' | *IsResidual* | true if the entity is a residual category (i.e. other specified or unspecified categories) |
#' | *ChapterNo* | The chapter that the entity is in |
#' | *BrowserLink* | Direct link to this entity in ICD-11 browser |
#' | *IsLeaf* | true if this entity does not have any children |
#' | *Primary Tabulation* | |
#' | *GroupingX* | Groupings that the entity is included in |
#'
#' @examples
#' icd11_simple_table_mms
#'
#' @source https://icdcdn.who.int/static/releasefiles/2024-01/SimpleTabulation-ICD-11-MMS-en.zip
#'
"icd11_simple_table_mms"
File renamed without changes.
62 changes: 62 additions & 0 deletions data-raw/icd_linearization_tables.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Download and process ICD-11 linearizations -----------------------------------

## Load libraries ----
library(openxlsx2)


## Download data ----

### Linearization MMS from ICD-11 download page ----
### https://icd.who.int/dev11/downloads

download_url <- "https://icd.who.int/dev11/Downloads/Download?fileName=LinearizationMiniOutput-MMS-en.zip"

download.file(
url = download_url,
destfile = "data-raw/linear-mms.zip"
)

unzip(
zipfile = "data-raw/linear-mms.zip",
overwrite = TRUE,
exdir = "data-raw/linear-mms"
)

icd11_linearization_mms <- read_xlsx(
file = "data-raw/linear-mms/LinearizationMiniOutput-MMS-en.xlsx",
sheet = 1, data_only = TRUE
)

header_values <- names(icd11_linearization_mms)[ncol(icd11_linearization_mms)] |>
stringr::str_split(pattern = ":", simplify = TRUE)

names(icd11_linearization_mms)[ncol(icd11_linearization_mms)] <- header_values |>
(\(x) x[1])()

icd11_linearization_mms$Version <- header_values |>
(\(x) x[2:3])() |>
paste(collapse = ":")

usethis::use_data(icd11_linearization_mms, overwrite = TRUE, compress = "xz")

### Simple Table MMS ----

download_url <- "https://icdcdn.who.int/static/releasefiles/2024-01/SimpleTabulation-ICD-11-MMS-en.zip"

download.file(
url = download_url,
destfile = "data-raw/simple-tab-icd11-mms.zip"
)

unzip(
zipfile = "data-raw/simple-tab-icd11-mms.zip",
overwrite = TRUE,
exdir = "data-raw/simple-tab-icd11-mms"
)

icd11_simple_table_mms <- read_xlsx(
file = "data-raw/simple-tab-icd11-mms/SimpleTabulation-ICD-11-MMS-en.xlsx",
sheet = 1, data_only = TRUE
)

usethis::use_data(icd11_simple_table_mms, overwrite = TRUE, compress = "xz")
Binary file added data-raw/linear-mms.zip
Binary file not shown.
36,754 changes: 36,754 additions & 0 deletions data-raw/linear-mms/LinearizationMiniOutput-MMS-en.txt

Large diffs are not rendered by default.

Binary file not shown.
Binary file added data-raw/simple-tab-icd11-mms.zip
Binary file not shown.
36,045 changes: 36,045 additions & 0 deletions data-raw/simple-tab-icd11-mms/SimpleTabulation-ICD-11-MMS-en.txt

Large diffs are not rendered by default.

Binary file not shown.
16 changes: 16 additions & 0 deletions data-raw/simple-tab-icd11-mms/readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Foundation URI :Unique identifier for the entity that will not change
Linearization (release) URI :Unique identifier for this version of the classification. It includes the linearization name such as MMS and minor version idetifier such as 2018 in it
Code :ICD-11 code for the entity. Note that the groupings do not have a code.
BlockId :Identifier for high level groupings that do not bear a code
Title :Title of the entity
ClassKind :One of the three (chapter, block, category)
Chapter is top level classification entities
Blocks are high level groupings that do not bear a code
Categories are entities that has a code
DepthInKind :Depth of within the Class Kind. For example, a category with depthinkind=2 means it is category whose parent is also a category bu grand parent is not
IsResidual :true if the entity is a residual category (i.e. other specified or unspecified categories)
ChapterNo :The chapter that the entity is in
BrowserLink :Direct link to this entity in ICD-11 browser.
IsLeaf :true if this entity does not have any children
Primary Tabulation:
GroupingX :Groupings that the entity is included in
Binary file added data/icd11_linearization_mms.rda
Binary file not shown.
Binary file added data/icd11_simple_table_mms.rda
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/pkgdown.yml
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ pandoc: 3.1.1
pkgdown: 2.0.7
pkgdown_sha: ~
articles: {}
last_built: 2024-02-10T06:32Z
last_built: 2024-02-10T07:39Z
urls:
reference: https://oxford-ihtm.io/icd/reference
article: https://oxford-ihtm.io/icd/articles
10 changes: 9 additions & 1 deletion docs/reference/icd.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33,428 changes: 33,428 additions & 0 deletions docs/reference/icd11_linearization_mms.html

Large diffs are not rendered by default.

38,986 changes: 38,986 additions & 0 deletions docs/reference/icd11_simple_table_mms.html

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions docs/reference/icd_authenticate.html
11 changes: 1 addition & 10 deletions docs/reference/icd_versions.html
10 changes: 10 additions & 0 deletions docs/reference/index.html
2 changes: 1 addition & 1 deletion docs/search.json

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions docs/sitemap.xml
Original file line number Diff line number Diff line change
@@ -21,6 +21,12 @@
<url>
<loc>https://oxford-ihtm.io/icd/reference/icd.html</loc>
</url>
<url>
<loc>https://oxford-ihtm.io/icd/reference/icd11_linearization_mms.html</loc>
</url>
<url>
<loc>https://oxford-ihtm.io/icd/reference/icd11_simple_table_mms.html</loc>
</url>
<url>
<loc>https://oxford-ihtm.io/icd/reference/icd_authenticate.html</loc>
</url>
20 changes: 18 additions & 2 deletions inst/WORDLIST
Original file line number Diff line number Diff line change
@@ -1,18 +1,34 @@
BlockId
BrowserLink
CMD
ChapterNo
ClassKind
CodeFactor
Codecov
DepthInKind
GroupingX
ICF
IsLeaf
IsResidual
Lifecycle
LinearizationMiniOutput
OAuth
ORCID
PrimaryLocation
RC
SimpleTabulation
SupportedClassifications
WIP
api
httr
depthinkind
fileName
iCatLink
icdapi
icdcdn
int
oauth
isLeaf
noOfNonResidualChildren
org
releasefiles
rfc
www
9 changes: 9 additions & 0 deletions man/icd.Rd
41 changes: 41 additions & 0 deletions man/icd11_linearization_mms.Rd
38 changes: 38 additions & 0 deletions man/icd11_simple_table_mms.Rd
8 changes: 4 additions & 4 deletions man/icd_authenticate.Rd
18 changes: 9 additions & 9 deletions man/icd_versions.Rd
3 changes: 3 additions & 0 deletions pkgdown/_pkgdown.yml
Original file line number Diff line number Diff line change
@@ -51,3 +51,6 @@ reference:
- title: Supporting datasets
contents:
- icd_versions
- icd11_linearization_mms
- icd11_simple_table_mms