Skip to content

Commit

Permalink
added appendices G and H1 (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewallenbruce committed Apr 17, 2024
1 parent 90b8bec commit 5802e79
Show file tree
Hide file tree
Showing 13 changed files with 195 additions and 10 deletions.
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ export(appendix_A)
export(appendix_B)
export(appendix_C)
export(appendix_D)
export(appendix_G)
export(appendix_H)
export(apply_age_edits)
export(case_chapter_icd10)
export(ex_data)
Expand Down
41 changes: 40 additions & 1 deletion R/appendices.R
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ appendix_C <- function(icd = NULL,


#' Appendix D MS-DRG Surgical Hierarchy by MDC and MS-DRG

#'
#' Since patients can have multiple procedures related to their principal
#' diagnosis during a particular hospital stay, and a patient can be assigned to
#' only one surgical class, the surgical classes in each MDC are defined in a
Expand Down Expand Up @@ -160,3 +160,42 @@ appendix_C <- function(icd = NULL,
appendix_D <- function() {
pins::pin_read(mount_board(), "msdrg_drg_groups_41.1")
}

#' Appendix G Diagnoses Defined as Complications or Comorbidities
#'
#' Diagnoses in Appendix G are considered complications or comorbidities (CC)
#' except when used in conjunction with the principal diagnosis in the
#' corresponding CC Exclusion List in Appendix C.
#'
#' @template returns
#'
#' @examples
#' head(appendix_G())
#'
#' @autoglobal
#'
#' @export
appendix_G <- function() {
pins::pin_read(mount_board(), "msdrg_icd_ccs_41.1")
}

#' Appendix H Diagnoses Defined as Major Complications or Comorbidities
#'
#' Diagnoses in Appendix H Part I are considered major complications or
#' comorbidities (MCC) except when used in conjunction with the principal
#' diagnosis in the corresponding CC Exclusion List in Appendix C. In addition to
#' the CC exclusion list, the diagnoses in Part II are assigned as a major CC
#' only for patients discharged alive, otherwise they will be assigned as a non
#' CC.
#'
#' @template returns
#'
#' @examples
#' head(appendix_H())
#'
#' @autoglobal
#'
#' @export
appendix_H <- function() {
pins::pin_read(mount_board(), "msdrg_icd_mccs_41.1")
}
3 changes: 1 addition & 2 deletions R/icd_10_cm.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
#' @autoglobal
#'
#' @export
icd10cm <- function(icd = NULL,
...) {
icd10cm <- function(icd = NULL, ...) {

icd10 <- pins::pin_read(mount_board(), "icd10cm")

Expand Down
34 changes: 34 additions & 0 deletions data-raw/appendix_G.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Appendix G Diagnoses Defined as Complications or Comorbidities
#
# Diagnoses in Appendix G are considered complications or comorbidities (CC)
# except when used in conjunction with the principal diagnosis in the
# corresponding CC Exclusion List in Appendix C.


library(tidyverse)

path_G <- "C:/Users/Andrew/Desktop/payer_guidelines/data/MSDRG/MSDRGv41.1ICD10_R0_DefinitionsManual_TEXT_0/appendix_G.txt"

g_file <- readr::read_table(
path_G,
skip = 0,
col_names = FALSE) |>
dplyr::mutate(dx_type = "CC",
X1 = pathologie::add_dot(X1)) |>
tidyr::unite("icd_description", X2:X9, na.rm = TRUE, sep = " ") |>
dplyr::rename(icd_code = X1)

# Update Pin
board <- pins::board_folder(here::here("inst/extdata/pins"))

board |> pins::pin_write(
g_file,
name = "msdrg_icd_ccs_41.1",
title = "Appendix G Diagnoses Defined as Complications or Comorbidities 41.1",
description = c(
"Diagnoses in Appendix G are considered complications or comorbidities (CC) except when used in conjunction with the principal diagnosis in the corresponding CC Exclusion List in Appendix C."
),
type = "qs"
)

board |> pins::write_board_manifest()
37 changes: 37 additions & 0 deletions data-raw/appendix_H_1.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Appendix H Diagnoses Defined as Major Complications or Comorbidities
#
# Diagnoses in Appendix H Part I are considered major complications or
# comorbidities (MCC) except when used in conjunction with the principal
# diagnosis in the corresponding CC Exclusion List in Appendix C. In addition to
# the CC exclusion list, the diagnoses in Part II are assigned as a major CC
# only for patients discharged alive, otherwise they will be assigned as a non
# CC.


library(tidyverse)

path_h1 <- "C:/Users/Andrew/Desktop/payer_guidelines/data/MSDRG/MSDRGv41.1ICD10_R0_DefinitionsManual_TEXT_0/appendix_H_1.txt"

h1_file <- readr::read_table(
path_h1,
skip = 0,
col_names = FALSE) |>
dplyr::mutate(dx_type = "MCC",
X1 = pathologie::add_dot(X1)) |>
tidyr::unite("icd_description", X2:X3, na.rm = TRUE, sep = " ") |>
dplyr::rename(icd_code = X1)

# Update Pin
board <- pins::board_folder(here::here("inst/extdata/pins"))

board |> pins::pin_write(
h1_file,
name = "msdrg_icd_mccs_41.1",
title = "Appendix H Diagnoses Defined as Major Complications or Comorbidities 41.1",
description = c(
"Diagnoses in Appendix H Part I are considered major complications or comorbidities (MCC) except when used in conjunction with the principal diagnosis in the corresponding CC Exclusion List in Appendix C. In addition to the CC exclusion list, the diagnoses in Part II are assigned as a major CC only for patients discharged alive, otherwise they will be assigned as a non CC."
),
type = "qs"
)

board |> pins::write_board_manifest()
4 changes: 4 additions & 0 deletions inst/extdata/pins/_pins.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,9 @@ msdrg_ccmcc_41.1:
- msdrg_ccmcc_41.1/20240415T024824Z-61fa0/
msdrg_drg_groups_41.1:
- msdrg_drg_groups_41.1/20240417T055023Z-5ae76/
msdrg_icd_ccs_41.1:
- msdrg_icd_ccs_41.1/20240417T083635Z-0c4a4/
msdrg_icd_mccs_41.1:
- msdrg_icd_mccs_41.1/20240417T082757Z-dc7a7/
msdrg_index_41.1:
- msdrg_index_41.1/20240405T103150Z-3ca9d/
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
file: msdrg_icd_ccs_41.qs
file_size: 102992
pin_hash: 0c4a423d52bd6b86
type: qs
title: Appendix G Diagnoses Defined as Complications or Comorbidities 41.1
description: Diagnoses in Appendix G are considered complications or comorbidities
(CC) except when used in conjunction with the principal diagnosis in the corresponding
CC Exclusion List in Appendix C.
tags: ~
urls: ~
created: 20240417T083635Z
api_version: 1
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
file: msdrg_icd_mccs_41.qs
file_size: 13433
pin_hash: dc7a76ff31084a35
type: qs
title: Appendix H Diagnoses Defined as Major Complications or Comorbidities 41.1
description: Diagnoses in Appendix H Part I are considered major complications or
comorbidities (MCC) except when used in conjunction with the principal diagnosis
in the corresponding CC Exclusion List in Appendix C. In addition to the CC exclusion
list, the diagnoses in Part II are assigned as a major CC only for patients discharged
alive, otherwise they will be assigned as a non CC.
tags: ~
urls: ~
created: 20240417T082757Z
api_version: 1
Binary file not shown.
15 changes: 8 additions & 7 deletions man/appendix_D.Rd

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

20 changes: 20 additions & 0 deletions man/appendix_G.Rd

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

23 changes: 23 additions & 0 deletions man/appendix_H.Rd

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

0 comments on commit 5802e79

Please sign in to comment.