-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3508ae9
commit 9cce1ef
Showing
7 changed files
with
143 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ export(gt_style) | |
export(icd10api) | ||
export(icd10cm) | ||
export(is_valid_icd) | ||
export(search_msdrg) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#' Medicare Severity Diagnosis-Related Groups | ||
#' | ||
#' The Medicare Severity Diagnosis-Related Group (MS-DRG) is a classification | ||
#' system used by the Centers for Medicare and Medicaid Services (CMS) to group | ||
#' patients with similar clinical characteristics and resource utilization into | ||
#' a single payment category. | ||
#' | ||
#' The system is primarily used for Medicare reimbursement purposes, but it is | ||
#' also adopted by many other payers as a basis for payment determination. | ||
#' | ||
#' MS-DRGs are based on the principal diagnosis, up to 24 additional diagnoses, | ||
#' and up to 25 procedures performed during the stay. In a small number of | ||
#' MS-DRGs, classification is also based on the age, sex, and discharge status | ||
#' of the patient. | ||
#' | ||
#' Hospitals serving more severely ill patients receive increased | ||
#' reimbursements, while hospitals treating less severely ill patients will | ||
#' receive less reimbursement. | ||
#' | ||
#' @param drg `<chr>` vector of 3-digit DRG codes | ||
#' @param mdc `<chr>` vector of 2-digit Major Diagnostic Category codes | ||
#' @param type `<chr>` DRG type: `Medical` or `Surgical` | ||
#' @param ... Empty | ||
#' @return A [tibble][tibble::tibble-package] | ||
#' @examples | ||
#' search_msdrg(drg = "011") | ||
#' | ||
#' search_msdrg(mdc = "24") | ||
#' @autoglobal | ||
#' @export | ||
search_msdrg <- function(drg = NULL, | ||
mdc = NULL, | ||
type = NULL, | ||
...) { | ||
|
||
ms <- pins::pin_read(mount_board(), "msdrg") | ||
|
||
if (!is.null(type)) { | ||
ms <- vctrs::vec_slice(ms, ms$drg_type == type) | ||
} | ||
|
||
if (!is.null(drg)) { | ||
ms <- vctrs::vec_slice(ms, | ||
vctrs::vec_in(ms$drg, | ||
collapse::funique(drg))) | ||
} | ||
|
||
if (!is.null(mdc)) { | ||
ms <- vctrs::vec_slice(ms, | ||
vctrs::vec_in(ms$mdc, | ||
collapse::funique(mdc))) | ||
} | ||
return(ms) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
library(rvest) | ||
|
||
ms_drg_v36 <- read_html("https://www.hipaaspace.com/medical.coding.library/drgs/") |> | ||
html_element(xpath = '//*[contains(concat( " ", @class, " " ), concat( " ", "table-striped", " " ))]') |> | ||
html_table(na.strings = c("N/A", "N/S"), convert = FALSE) | ||
|
||
ms_drg_v36 <- ms_drg_v36 |> | ||
janitor::clean_names() |> | ||
dplyr::select(-number) |> | ||
dplyr::mutate( | ||
mdc = dplyr::na_if(mdc, "N/A"), | ||
mdc_description = dplyr::na_if(mdc_description, "N/S")) |> | ||
tidyr::separate_wider_delim(drg_type, " ", names = c("drg_type", "drg_abbrev")) |> | ||
dplyr::mutate( | ||
drg_abbrev = stringr::str_remove(drg_abbrev, "\\("), | ||
drg_abbrev = stringr::str_remove(drg_abbrev, "\\)"), | ||
drg_abbrev = dplyr::na_if(drg_abbrev, "") | ||
) | ||
|
||
ms_drg_v36 | ||
ms_drg_v36 <- northstar::search_msdrg() | ||
# Update Pin | ||
board <- pins::board_folder(here::here("inst/extdata/pins")) | ||
|
||
board |> | ||
pins::pin_write(ms_drg_v36, | ||
name = "msdrg", | ||
title = "MS-DRG Version 36.0", | ||
description = "Medicare Severity Diagnosis-Related Groups (MS-DRGs) Version 36.0", | ||
type = "qs") | ||
|
||
board |> pins::write_board_manifest() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
icd10cm: | ||
- icd10cm/20240331T055428Z-905e8/ | ||
msdrg: | ||
- msdrg/20240331T114524Z-c6366/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
file: msdrg.qs | ||
file_size: 10851 | ||
pin_hash: c6366a293c28ff8a | ||
type: qs | ||
title: MS-DRG Version 36.0 | ||
description: Medicare Severity Diagnosis-Related Groups (MS-DRGs) Version 36.0 | ||
tags: ~ | ||
urls: ~ | ||
created: 20240331T114524Z | ||
api_version: 1 |
Binary file not shown.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.