Package 'codigo'

Title: Interface to the International Classification of Diseases (ICD) API
Description: The International Classification of Diseases (ICD) serves a broad range of uses globally and provides critical knowledge on the extent, causes and consequences of human disease and death worldwide via data that is reported and coded with the ICD. ICD API allows programmatic access to the ICD. It is an HTTP based REST API. This package provides functions that interface with the ICD API.
Authors: Anita Makori [aut, cph], Ernest Guevarra [aut, cre, cph] , Sanjeev Pugazhendhi [ths, rev], Williams Udoh Ituen-Umanah [rev], Proochista Ariana [rev, cph]
Maintainer: Ernest Guevarra <[email protected]>
License: GPL (>= 3)
Version: 0.0.0.9000
Built: 2025-02-28 04:17:00 UTC
Source: https://github.com/OxfordIHTM/codigo

Help Index


ICD 11 code or categories mapped to one ICD 10 category

Description

ICD 11 code or categories mapped to one ICD 10 category

Usage

eleven_map_to_one_ten

Format

A data.frame with 17908 rows and 7 columns:

Variable Description
icd11_linearization_uri ICD 11 linearization URI
icd11_code ICD 11 code
icd11_chapter ICD 11 chapter
icd11_title ICD 11 title
icd10_code ICD 10 code (for class chapter) or block of codes (for class block)
icd10_chapter ICD 10 chapter
icd10_title ICD 10 class or kind: either category or code

Source

https://icdcdn.who.int/static/releasefiles/2024-01/mapping.zip

Examples

eleven_map_to_one_ten

Get available ICD-10 releases

Description

Get available ICD-10 releases

Usage

icd_10_get_releases(
  api_version = c("v2", "v1"),
  base_url = "https://id.who.int",
  client = icd_oauth_client(),
  scope = "icdapi_access"
)

icd_10_get_chapters(
  release = NULL,
  api_version = c("v2", "v1"),
  language = "en",
  verbose = TRUE,
  base_url = "https://id.who.int",
  client = icd_oauth_client(),
  scope = "icdapi_access"
)

icd_10_get_release_by_category(
  category,
  api_version = c("v2", "v1"),
  base_url = "https://id.who.int",
  client = icd_oauth_client(),
  scope = "icdapi_access"
)

icd_10_get_info(
  category,
  release = NULL,
  api_version = c("v2", "v1"),
  language = "en",
  verbose = TRUE,
  base_url = "https://id.who.int",
  client = icd_oauth_client(),
  scope = "icdapi_access"
)

Arguments

api_version

Version of the API. Possible values are v1 or v2. For example, if you provide value v2, the API will respond in the format of the version 2 of the API. Default is v2.

base_url

The base URL of the API. Default uses the WHO API server at https://id.who.int. If you are using a locally deployed server or hosting your own ICD API server, you should specify the URL of your instance here.

client

The OAuth2 client produced through a call to icd_oauth_client().

scope

Scopes to be requested from the resource owner. Default is "icdapi_access" as specified in the ICD API documentation.

release

A string specifying the release version of ICD-10 to search from. If not specified, defaults to the latest release version. See the available versions with icd_versions.

language

ICD-API is multi-lingual. By changing this header, you may make the API respond in different languages. Languages will be available as the translations of ICD-11 completes. The values are language codes such as en, es, zh, etc. Depending on the release_id specified, the available languages will vary. Default is English ("en"). Note that language support for ICD-10 is limited to English (en).

verbose

Logical. Should non-warning and non-error messages be printed? Default is TRUE.

category

ICD-10 category code or for blocks, the code range.

Value

A list with information on specified ICD 10 parameters

Examples

icd_10_get_releases()
icd_10_get_chapters()
icd_10_get_release_by_category(category = "A00")
icd_10_get_release_by_category(category = "A00-A09")
icd_10_get_info(category = "A00")
icd_10_get_info(category = "A00-A09")

Autocode against the foundation component or linearizations of the ICD-11

Description

Autocode against the foundation component or linearizations of the ICD-11

Usage

icd_autocode_foundation(
  q,
  subtree = NULL,
  release = NULL,
  threshold = NULL,
  api_version = c("v2", "v1"),
  language = "en",
  tabular = TRUE,
  verbose = TRUE,
  base_url = "https://id.who.int",
  client = icd_oauth_client(),
  scope = "icdapi_access"
)

icd_autocode(
  q,
  linearization = c("mms", "icf"),
  subtree = NULL,
  release = NULL,
  threshold = NULL,
  api_version = c("v2", "v1"),
  language = "en",
  tabular = TRUE,
  verbose = TRUE,
  base_url = "https://id.who.int",
  client = icd_oauth_client(),
  scope = "icdapi_access"
)

Arguments

q

String. Text to be searched. Having the character ⁠%⁠ at the end will be regarded as a wild card for that word.

subtree

A string or vector of strings of URIs. If provided, the search will be performed on the entities provided and their descendants.

release

A string specifying the release version of the Foundation to search from. If not specified, defaults to the latest release version. See the available versions with icd_versions.

threshold

A numeric value between 0 and 1 that indicates the similarity between the input text and the matched term. threshold is the minimum score to be included in the output. Default is NULL to use default value specified by API.

api_version

Version of the API. Possible values are v1 or v2. For example, if you provide value v2, the API will respond in the format of the version 2 of the API. Default is v2.

language

ICD-API is multi-lingual. By changing this header, you may make the API respond in different languages. Languages will be available as the translations of ICD-11 completes. The values are language codes such as en, es, zh, etc. Depending on the release_id specified, the available languages will vary. Default is English ("en").

tabular

Logical. Should output be structured into a tibble? Default to TRUE.

verbose

Logical. Should non-warning and non-error messages be printed? Default is TRUE.

base_url

The base URL of the API. Default uses the WHO API server at https://id.who.int. If you are using a locally deployed server or hosting your own ICD API server, you should specify the URL of your instance here.

client

The OAuth2 client produced through a call to icd_oauth_client().

scope

Scopes to be requested from the resource owner. Default is "icdapi_access" as specified in the ICD API documentation.

linearization

A character value for which linearization to search. Currently, the possible values for this are "mms" and "icf".

Value

A tibble of autocode results showing the search text, the matching text, the code, URIs for the foundation and linearization entities, the matching level, the matching score, and the matching type.

Examples

icd_autocode_foundation("cholera")
icd_autocode(q = "cholera")
icd_autocode(q = "impairment", linearization = "icf")

Checks for specified parameters supplied to search, autocode, and get functions

Description

Checks for specified parameters supplied to search, autocode, and get functions

Usage

icd_check_release(release, icd = c("icd11", "icd10"), verbose = TRUE)

icd_check_language(
  release = NULL,
  language,
  icd = c("icd11", "icd10"),
  verbose = TRUE
)

Arguments

release

A string specifying the release version of the ICD-11.

icd

A character string of available ICD classifications. Currently, this can be either "icd10" or "icd11". Default is "icd11".

verbose

Logical. Should non-warning and non-error messages be printed? Default is TRUE.

language

language codes such as en, es, zh, etc.

Value

A message or an error if release provided is recognised or not. A message or a warning if language requested is available or not for release provided. For icd_check_language(), returns a character value or a character vector of acceptable language codes.

Examples

icd_check_release("2024-01")
try(icd_check_release("2025-01"))
icd_check_language("2024-01", "ar")
icd_check_language("2024-01", "rr")
try(icd_check_language("2025-01", "ar"))

Get information on various ICD-11 foundation and linearization entities

Description

Get information on various ICD-11 foundation and linearization entities

Usage

icd_get_foundation(
  release = NULL,
  api_version = c("v2", "v1"),
  language = "en",
  tabular = TRUE,
  verbose = TRUE,
  base_url = "https://id.who.int",
  client = icd_oauth_client(),
  scope = "icdapi_access"
)

icd_get_entity(
  id,
  release = NULL,
  include = NULL,
  api_version = c("v2", "v1"),
  language = "en",
  verbose = TRUE,
  base_url = "https://id.who.int",
  client = icd_oauth_client(),
  scope = "icdapi_access"
)

icd_get_info(
  linearization = c("mms", "icf"),
  api_version = c("v2", "v1"),
  language = "en",
  verbose = TRUE,
  base_url = "https://id.who.int",
  client = icd_oauth_client(),
  scope = "icdapi_access"
)

icd_get_chapter(
  linearization = c("mms", "icf"),
  release = NULL,
  api_version = c("v2", "v1"),
  language = "en",
  verbose = TRUE,
  base_url = "https://id.who.int",
  client = icd_oauth_client(),
  scope = "icdapi_access"
)

Arguments

release

A string specifying the release version of the Foundation to search from. If not specified, defaults to the latest release version. See the available versions with icd_versions.

api_version

Version of the API. Possible values are v1 or v2. For example, if you provide value v2, the API will respond in the format of the version 2 of the API. Default is v2.

language

ICD-API is multi-lingual. By changing this header, you may make the API respond in different languages. Languages will be available as the translations of ICD-11 completes. The values are language codes such as en, es, zh, etc. Depending on the release_id specified, the available languages will vary. Default is English ("en").

tabular

Logical. Should output be structured into a tibble? Default to TRUE.

verbose

Logical. Should non-warning and non-error messages be printed? Default is TRUE.

base_url

The base URL of the API. Default uses the WHO API server at https://id.who.int. If you are using a locally deployed server or hosting your own ICD API server, you should specify the URL of your instance here.

client

The OAuth2 client produced through a call to icd_oauth_client().

scope

Scopes to be requested from the resource owner. Default is "icdapi_access" as specified in the ICD API documentation.

id

Unique numerical identifier for an entity.

include

A string or a vector of strings for optional property values to be included in the response. The property values that can be included are "ancestor", "descendant", or "diagnosticCriteria". If not specified, these properties are not included in the response.

linearization

A character value for which linearization to search. Currently, the possible values for this are "mms" and "icf". Default is "mms".

Value

A list with information on specified ICD 11 Foundation and top level entities.

Examples

icd_get_foundation()
icd_get_entity(id = "1435254666")     ## chapter
icd_get_entity(id = "588616678")      ## block; depth 1
icd_get_entity(id = "1465325727")     ## category; depth 1
icd_get_info()
icd_get_info("icf")
icd_get_chapter()
icd_get_chapter("icf")

Utility functions for retrieving ICD parameters and definitions

Description

Utility functions for retrieving ICD parameters and definitions

Usage

icd_get_releases(icd = c("icd11", "icd10"), latest = FALSE)

icd_get_languages(icd = c("icd11", "icd10"), latest = FALSE)

icd_get_entities(class = NULL)

Arguments

icd

A character string of available ICD classifications. Currently, this can be either "icd10" or "icd11". Default is "icd11". If NULL, all ICD classifications are used (currently both "icd10" and "icd11").

latest

Logical. If TRUE, identifier for latest release is returned. Default is FALSE.

class

A character string of code classes to retrieve. This can be either "chapter", "block", or "category". If NULL (default), all classes are retrieved.

Value

A tibble for ICD classification values and their corresponding release identifiers (for icd_get_releases()). A names list of corresponding languages (for icd_get_languages()). A tibble of entities with their definitions/titles and classes (for icd_get_entitties()).

Examples

icd_get_releases()
icd_get_languages()
icd_get_entities()

Map ICD codes between versions

Description

Map ICD codes between versions

Usage

icd_map(from = c("icd10", "icd11"), to = c("one", "multiple"), code)

Arguments

from

The ICD version to map from. Either icd10 or icd11. Default to icd10.

to

A character value of either multiple or one to map ICD-10 to ICD-11 accordingly. Only relevant if from is icd10. Ignored when from is icd11. Default to one.

code

Corresponding ICD code in version specified in from to map to the other version.

Value

A tibble of information for specified code mapped based on from

Examples

icd_map(code = "A00")

OAuth2 authentication to ICD API

Description

OAuth2 authentication to ICD API

Usage

icd_oauth_client(
  id = Sys.getenv("ICD_CLIENT_ID"),
  token_url = "https://icdaccessmanagement.who.int/connect/token",
  secret = Sys.getenv("ICD_CLIENT_SECRET"),
  name = "icd_client",
  ...
)

icd_authenticate(
  req,
  client = icd_oauth_client(),
  scope = "icdapi_access",
  ...
)

Arguments

id

Consumer key, also sometimes called the client ID.

token_url

url used to exchange unauthenticated for authenticated token.

secret

Consumer secret, also sometimes called the client secret. Despite its name, this does not necessarily need to be protected like a password, i.e. the user still has to authenticate themselves and grant the app permission to access resources on their behalf.

name

Name of the application. This is not used for OAuth, but is used to make it easier to identify different applications.

...

Other parameters/arguments to be passed onto httr2::oauth_client() or to httr2::req_oauth_client_credentials()

req

A request

client

An OAuth2 client. Default is a call to icd_oauth_client().

scope

Scopes to be requested from the resource owner. Default is "icdapi_access" as specified in the ICD API documentation.

Value

An httr2_oauth_client class object.

Examples

icd_oauth_client()

Structure ICD list and ICD search outputs

Description

Structure ICD list and ICD search outputs

Usage

icd_structure_foundation(icd_list)

icd_structure_search(icd_search)

icd_structure_autocode(icd_autocode)

Arguments

icd_list

An object produced by a call to any of the icd_get functions

icd_search

An object produced by a call to any of the icd_search functions

icd_autocode

An object produced by a call to any of the icd_autocode functions

Details

These functions are meant to be helper functions and are used within the icd_get, icd_search, and icd_autocode functions to structure the output responses.

Value

A tibble of structured ICD outputs.

Examples

icd_list <- icd_get_foundation(tabular = FALSE)
icd_tbl_foundation <- icd_structure_foundation(icd_list)
icd_structure_search(icd_search_foundation("cholera", tabular = FALSE))
icd_structure_autocode(icd_autocode_foundation("cholera"))

Table of supported classifications and versions by the ICD API

Description

Table of supported classifications and versions by the ICD API

Usage

icd_versions

Format

A data frame with 6 columns and 11 rows:

Variable Description
Classification Version of classification. Either ICD-11 or ICD-10
Release ID Release identifier for specific classification version
Foundation Logical. Does this version include the Foundation?
MMS Logical. Does this version include the MMS information?
ICF Logical. Does this version include the ICF?
Languages Languages in which version and release is available for

For logical fields that specify NA, this indicates that for that particular version and release, the particular field was not applicable or relevant.

Source

https://icd.who.int/docs/icd-api/SupportedClassifications/

Examples

icd_versions

ICD-11 Mortality and Morbidity Linearization Outputs

Description

ICD-11 Mortality and Morbidity Linearization Outputs

Usage

icd11_linearization_mms

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

Source

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

Examples

icd11_linearization_mms

ICD-11 Mortality and Morbidity Simple Table Outputs

Description

ICD-11 Mortality and Morbidity Simple Table Outputs

Usage

icd11_simple_table_mms

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
Version Date and time linearization was produced

Source

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

Examples

icd11_simple_table_mms

ICD 10 code or categories mapped to multiple ICD 11 categories

Description

ICD 10 code or categories mapped to multiple ICD 11 categories

Usage

ten_map_to_multiple_eleven

Format

A data.frame with 15658 rows and 12 columns:

Variable Description
icd10_class_kind ICD 10 class or kind: either chapter, block, category, or modifiedcategory
icd10_depth ICD 10 depth level
icd10_code ICD 10 code (for class chapter) or block of codes (for class block)
icd10_chapter ICD 10 chapter
icd10_title ICD 10 class or kind: either category or code
icd11_class_kind ICD 11 class or kind: either block, category, or chapter
icd11_depth ICD 11 depth level
icd11_foundation_uri ICD 11 foundation URI
icd11_linearization_uri ICD 11 linearization URI
icd11_code ICD 11 code
icd11_chapter ICD 11 chapter
icd11_title ICD 11 title

Source

https://icdcdn.who.int/static/releasefiles/2024-01/mapping.zip

Examples

ten_map_to_multiple_eleven

ICD 10 code or categories mapped to one ICD 11 category

Description

ICD 10 code or categories mapped to one ICD 11 category

Usage

ten_map_to_one_eleven

Format

A data.frame with 12597 rows and 12 columns:

Variable Description
icd10_class_kind ICD 10 class or kind: either chapter, block, category, or modifiedcategory
icd10_depth ICD 10 depth level
icd10_code ICD 10 code (for class chapter) or block of codes (for class block)
icd10_chapter ICD 10 chapter
icd10_title ICD 10 class or kind: either category or code
icd11_class_kind ICD 11 class or kind: either block, category, or chapter
icd11_depth ICD 11 depth level
icd11_foundation_uri ICD 11 foundation URI
icd11_linearization_uri ICD 11 linearization URI
icd11_code ICD 11 code
icd11_chapter ICD 11 chapter
icd11_title ICD 11 title

Source

https://icdcdn.who.int/static/releasefiles/2024-01/mapping.zip

Examples

ten_map_to_one_eleven