Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 6 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@
namespaces is available, then the return from `comorbidities()` will be a
`tibble` (or list of `tibble`s when `subconditions = TRUE`).

The tests were extended to consider the cases of passing in a data.table or
tibble to comorbidities when the associated namespaces are not available.
The tests were extended to consider the cases of passing in a `data.table` or
`tibble` to comorbidities when the associated namespaces are not available.

## Other Changes

* Improve formatting of vignettes/articles.

# medicalcoder 0.6.0

Expand Down
7 changes: 3 additions & 4 deletions vignettes/charlson.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,10 @@ Call `summary()` on the return object for a list of summary objects. These can
used to generate output tables to the end user's liking.

```{r}
str(
summary(mdcr_results)
)
str(summary(mdcr_results))
```

```{r, results = "asis"}
```{r echo = FALSE, results = "asis"}
x <- summary(mdcr_results)$conditions[, c("condition_description", "count", "percent")]
tab <-
kableExtra::kbl(
Expand All @@ -99,6 +97,7 @@ tab <-
col.names = c("", "Count", "Percentage"),
digits = 3
)
tab <- kableExtra::kable_styling(tab, bootstrap_options = c("striped"), font_size = 10)
tab <- kableExtra::pack_rows(tab, group_label = "Comorbidity", start_row = 1, end_row = 17)
tab <- kableExtra::pack_rows(tab, group_label = "Total Comorbidities", start_row = 18, end_row = nrow(x))
tab
Expand Down
63 changes: 36 additions & 27 deletions vignettes/comorbidities.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,7 @@ head(mdcr_longitudinal)
```

A great level of detail for each of the comorbidity algorithms are provided in
dedicated vignettes:

```{r label = "other-vignettes", eval = FALSE}
vignette(package = "medicalcoder")$results
```
dedicated vignettes.

# When are conditions flag?

Expand All @@ -142,7 +138,7 @@ hospitalization.
Implementation of Elixhauser comorbidities for 2022 and beyond [@ahrq2025]
explicitly define the use of present on admission flags for specific conditions
(see the `poa_required` flag reported in the data set returned by
`get_elixhauser_poa`).
`get_elixhauser_poa()`).
```{r}
str(get_elixhauser_poa())
```
Expand Down Expand Up @@ -196,35 +192,45 @@ I50.40 intentionally marked as not present on admission.
```{r, label = "example-setup"}
lookup_icd_codes(c("C78.4", "I50.40"))

subset(get_pccc_codes(),
subset = full_code %in% c("C78.4", "I50.40"),
select = c("icdv", "dx", "code", "full_code", "condition", "pccc_v3.0"))
codes <- c("C78.4", "I50.40")
cols <- c("icdv", "dx", "code", "full_code", "condition")

subset(get_charlson_codes(),
subset = full_code %in% c("C78.4", "I50.40"),
select = c("icdv", "dx", "code", "full_code", "condition", "charlson_quan2011"))
subset(
get_pccc_codes(),
subset = full_code %in% codes,
select = c(cols, "pccc_v3.0")
)

subset(get_elixhauser_codes(),
subset = full_code %in% c("C78.4", "I50.40") & elixhauser_ahrq2025 == 1L,
select = c("icdv", "dx", "code", "full_code", "condition", "elixhauser_ahrq2025"))
subset(
get_charlson_codes(),
subset = full_code %in% codes,
select = c(cols, "charlson_quan2011")
)

subset(
get_elixhauser_codes(),
subset = full_code %in% codes & elixhauser_ahrq2025 == 1L,
select = c(cols, "elixhauser_ahrq2025")
)

record <-
data.table::fread(text = "
patid | encid | code | poa
A | 1 | NA | NA
A | 2 | C78.4 | 0
A | 3 | I50.40 | 1
A | 4 | NA | NA
A | 5 | C78.4 | 1
A | 5 | I50.40 | 0
A | 6 | NA | NA
")
structure(
list(
patid = c("A", "A", "A", "A", "A", "A", "A"),
encid = c(1L, 2L, 3L, 4L, 5L, 5L, 6L),
code = c(NA, "C78.4", "I50.40", NA, "C78.4", "I50.40", NA),
poa = c(NA, 0L, 1L, NA, 1L, 0L, NA)),
row.names = c(NA, -7L),
class = "data.frame"
)
```

We will call `comorbidities` for the three methods using static POA flags and
dynamic POA flags, and both flag methods.
We will call `comorbidities()` for the three methods using static POA flags and
dynamic POA flags, and both flag methods. Results are shown in the following
table.

```{r, include = FALSE}
data.table::setDT(record)
args <-
list(data = record,
icd.codes = "code",
Expand Down Expand Up @@ -283,6 +289,7 @@ tab <-
rtn,
row.names = FALSE,
escape = FALSE,
align = rep("c", nrow(rtn)),
caption = "Indicators for when a comorbidity is flagged based on the algorithm, present on admission (poa), and flag.method. The two ICD codes,C78.4 and I50.40, map to cancer and cardiovascular disease respectively."
)
tab <-
Expand All @@ -292,6 +299,8 @@ tab <-
general = "C78.4 does not need to be POA to count for Elixhauser. I50.40 does need to be POA to count for Elixhauser."
)

tab <- kable_styling(tab, bootstrap_options = c("striped", "bordered"), full_width = FALSE, font_size = 8)
#tab <- scroll_box(tab, height = "600px")
tab <- pack_rows(tab, "flag.method = 'current'", 1L, 6L)
tab <- pack_rows(tab, "flag.method = 'cumulative'", 7L, 12L)
tab <- add_header_above(tab, c(" " = 2L, rep(c("PCCC" = 2L, "Charlson" = 2L, "Elixhauser" = 2L), 3L)))
Expand Down
5 changes: 3 additions & 2 deletions vignettes/elixhauser.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ tables.
summary(mdcr_results)
```

```{r, results = "asis"}
```{r echo = FALSE, results = "asis"}
x <- summary(mdcr_results)$conditions
tab <-
kableExtra::kbl(
Expand All @@ -139,7 +139,8 @@ tab <-
col.names = c("", "Count", "Percentage"),
digits = 3
)
tab <- kableExtra::pack_rows(tab, group_label = "Comorbidity", start_row = 1, end_row = 39)
tab <- kableExtra::kable_styling(tab, bootstrap_options = c("striped"), font_size = 10)
tab <- kableExtra::pack_rows(tab, group_label = "Comorbidity", start_row = 1, end_row = 38)
tab <- kableExtra::pack_rows(tab, group_label = "Total Comorbidities", start_row = 39, end_row = nrow(x))
tab
```
Expand Down
50 changes: 35 additions & 15 deletions vignettes/icd.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ Centers for Disease Control (CDC) and from the Centers for Medicare & Medicaid
Services (CMS). The specific links to the source data sets can be found in the
source code for the `medicalcoder` package on
[GitHub](https://github.com/dewittpe/medicalcoder).
```{r label = "medicalcoder-url"}
cat(packageDescription('medicalcoder')$URL)
```

End users can get a `data.frame` with
ICD-9 diagnostic, ICD-9 procedure, ICD-10 diagnostic, and ICD-10 procedure codes.
Expand Down Expand Up @@ -96,6 +93,8 @@ d4

* `assignable_end`: The last year the code was assignable.

## with.descriptions

To get the descriptions of the ICD codes call `get_icd_codes()` with
`with.descriptions = TRUE`.
```{r, label = "icd-codes-with-descriptions"}
Expand All @@ -108,28 +107,49 @@ The return has the additional columns:
* `desc_end`: the last fiscal_year that the description was documented

Over time the descriptions for some ICD codes were modified within sources.
There are also many differences between sources. The table below has several
There are also many differences between sources. The tables below have several
examples.

```{r, label = "deltas-in-desc", results = "hide"}
delta_in_desc <-
subset(get_icd_codes(with.descriptions = TRUE),
subset = full_code %in% c("Z88.7", "010.93", "V76.49"),
select = c("full_code", "src", "desc", "desc_start", "desc_end"))
subset(
get_icd_codes(with.descriptions = TRUE),
subset = full_code %in% c("Z88.7", "010.93", "V76.49"),
select = c("full_code", "src", "desc", "desc_start", "desc_end")
)
```

```{r, label = "deltas-in-desc-show", echo = FALSE, results = "asis"}
knitr::kable(delta_in_desc, row.names = FALSE)
The only difference in the description for 010.93 is a comma.

```{r, label = "deltas-in-desc-show-010.93", echo = FALSE, results = "asis"}
knitr::kable(
subset(delta_in_desc, subset = full_code == "010.93"),
row.names = FALSE
)
```

* Z88.7 has differences in the description over time within `cms` source and
between `cms` and `who`.
ICD-10-CM Z88.7 has differences in the description over time within `cms` source
and between `cms` and `who`.

* The only difference in the description for 010.93 is a comma.
```{r, label = "deltas-in-desc-show-Z88.7", echo = FALSE, results = "asis"}
knitr::kable(
subset(delta_in_desc, subset = full_code == "Z88.7"),
row.names = FALSE
)
```

ICD-9-CM V79.49 had the description of 'other' which would require exploration
of the header codes to understand. Even when the most verbose description may
still require consideration of the header codes to fullye understand.

```{r, label = "deltas-in-desc-show-v79.49", echo = FALSE, results = "asis"}
knitr::kable(
subset(delta_in_desc, subset = full_code == "V76.49"),
row.names = FALSE
)
```

* ICD-9-CM V79.49 had the description of 'other' which would require exploration
of the header codes to understand. Even when the most verbose description may
still require consideration of the header codes to fully understand.
## with.hierarchy

Lastly, the `get_icd_codes()` function includes the argument `with.hierarchy`
which will provide additional details for the codes.
Expand Down
Loading