Skip to content

Commit

Permalink
Merge pull request #56 from OxfordIHTM/dev
Browse files Browse the repository at this point in the history
function for ill-defined ICD 10 codes
  • Loading branch information
ernestguevarra authored Jun 26, 2024
2 parents e75a989 + 2bb05a0 commit b086c7d
Show file tree
Hide file tree
Showing 6 changed files with 1,062 additions and 33 deletions.
36 changes: 34 additions & 2 deletions R/cod_check_code.R
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,40 @@ cod_check_code_structure_icd11 <- function(cod) {
#' @export
#'
cod_check_code_ill_defined_icd10 <- function(cod) {
cod_check <- NA_integer_
cod_check_note <- NA_character_
# I46.1
# I46.9
# I50.-
# I95.9
# I99
# J96.0
# J96.9
# P28.5
# R00-R57.1,
# R57.8-R64,
# R65.2-R65.3,
# R68.0-R94,
# R96-R99

set1 <- ifelse(
cod %in% c("I46.1", "I46.9", "I95.9", "I99", "J96.0", "P28.5"), 1L, 0L
)

set2 <- ifelse(stringr::str_detect(string = cod, pattern = "^I50"), 1L, 0L)

set3 <- ifelse(
stringr::str_detect(
string = cod,
pattern = "^R0|R1|R2|R3|R4|R50|R51|R52|R53|R54|R55|R56|R57|R61|R62|R63|R64|R65.2|R65.3|R68|R69|R7|R8|R91|R92|R93|R94|R96|R97|R98|R99"
),
1L, 0L
)

cod_check <- rowSums(data.frame(set1, set2, set3), na.rm = TRUE)
cod_check_note <- ifelse(
cod_check == 0L,
"No issues found in CoD code",
"CoD code is an ill-defined code"
)

tibble(cod_check, cod_check_note)
}
Expand Down
28 changes: 0 additions & 28 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -134,31 +134,3 @@ list_ill_defined_icd11 <- function() {
## Concatenate ill-defined code vectors ----
c(set1, set2, set3)
}


#'
#' Create vector of ill-defined ICD 11 codes
#'
#' Based on https://icdcdn.who.int/icd11referenceguide/en/html/index.html#list-of-illdefined-conditions
#'

list_ill_defined_icd11 <- function() {
## Create vector of ill-defined heart failure BD10-BD1Z ----
set1 <- codigo::icd11_linearization_mms |>
dplyr::filter(
.data$ChapterNo == 11 & stringr::str_detect(.data$Code, pattern = "BD")
) |>
dplyr::slice(1:11) |>
dplyr::pull(.data$Code)

## Create vector of ill-defined others ----
set2 <- c("BA2Z", "BE2Y", "BE2Z", "CB41.0", "CB41.2", "KB2D", "KB2E")

## Get codes for Chapter 21 except MA15, MG43, MG44.1, MH11, MH15 ----
set3 <- codigo::icd11_linearization_mms |>
dplyr::filter(.data$ChapterNo == 21) |>
dplyr::filter(!.data$Code %in% c("MA15", "MG43", "MG44.1", "MH11", "MH15")) |>
dplyr::pull(.data$Code)

c(set1, set2, set3)
}
Binary file added data-raw/ICD10Volume2_en_2019.pdf
Binary file not shown.
Loading

0 comments on commit b086c7d

Please sign in to comment.