Skip to content
Open
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
7 changes: 7 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ S3method(icd_conflicts,icd9)
S3method(icd_conflicts,icd9cm)
S3method(icd_conflicts,icd9cm_pc)
S3method(icd_conflicts,icd9who)
S3method(icd_gem,default)
S3method(icd_gem,icd10)
S3method(icd_gem,icd10cm_pc)
S3method(icd_gem,icd9)
S3method(icd_gem,icd9cm_pc)
S3method(is_billable,default)
S3method(is_billable,icd10)
S3method(is_billable,icd10cm)
Expand Down Expand Up @@ -131,6 +136,7 @@ S3method(short_to_decimal,default)
S3method(short_to_decimal,icd10)
S3method(short_to_decimal,icd10cm)
S3method(short_to_decimal,icd9)
S3method(short_to_decimal,icd9cm_pc)
S3method(short_to_parts,character)
S3method(short_to_parts,icd10)
S3method(short_to_parts,icd10cm)
Expand Down Expand Up @@ -271,6 +277,7 @@ export(icd9_comorbid_quan_deyo)
export(icd9_comorbid_quan_elix)
export(icd9_filter_invalid)
export(icd9_filter_valid)
export(icd_gem)
export(icd_long_data)
export(icd_wide_data)
export(is.comorbidity_map)
Expand Down
2 changes: 1 addition & 1 deletion R/cim-10-fr.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"https://www.atih.sante.fr",
"plateformes-de-transmission-et-logiciels",
"logiciels-espace-de-telechargement",
"telecharger/gratuit/11616/456"
"telecharger/gratuit/12713/456"
),
file_name = "LIBCIM10MULTI.TXT",
dl_msg = "Working on ICD-10-FR (CIM-10-FR)",
Expand Down
8 changes: 8 additions & 0 deletions R/convert.R
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,14 @@ short_to_decimal.icd9 <- function(x) {
icd9(as.decimal_diag(icd9_short_to_decimal_rcpp(x)))
}

#' @describeIn short_to_decimal convert ICD-9 codes from short to decimal
#' format
#' @export
#' @keywords internal manip
short_to_decimal.icd9cm_pc <- function(x) {
icd10cm_pc(as.decimal_diag(paste0(substr(x, 1L, 2L), ".", substr(x, 3L, 4L))))
}

#' @describeIn short_to_decimal convert ICD-10 codes from short to decimal
#' format
#' @export
Expand Down
111 changes: 111 additions & 0 deletions R/datadocs.R
Original file line number Diff line number Diff line change
Expand Up @@ -542,3 +542,114 @@ NULL
#' @docType data
#' @keywords datasets
NULL

#' ICD-9 / ICD-10 GEMs
#'
#' A representation of the ICD-9 / ICD-10 General Equivalence Mappings (GEMs).
#' The \code{icd_gem_9_to_10} dataset provides the mapping from ICD-9 codes to
#' ICD-10 codes, while the \code{icd_gem_10_to_9} dataset provides the mapping
#' from ICD-10 codes to ICD-9 codes.
#'
#' The GEMs denote \emph{source} codes as the ICD codes that you are mapping
#' from, and \emph{target} codes as the codes that you are mapping to. The GEMs
#' also have a concept of what they call an \emph{entry}, which is a mapping
#' between a single source code and one or more target codes. In the raw form
#' of the GEMs, an entry is a collection of one or more rows in the table that
#' all have the same value for \code{source}. It is worth noting that for some
#' codes, there is no reasonable representation of the given code in the target
#' code set.
#'
#' The relationship between the ICD-9 codes and ICD-10 codes is often not
#' straightforward (in general, ICD-10 codes tend to be more specific than ICD-9
#' codes). In the simplest setting, a given source code can be exactly or
#' approximately represented by one or more target codes. In the more
#' complicated (but fortunately less common) setting, the source code is what is
#' denoted in the GEMs as a \emph{combination} code, which means that you need
#' to observe two or more target codes in conjunction to represent the source
#' event. For example, some codes represent bilateral events (i.e. an event
#' that occurs to both sides of the body), so that if the source code represents
#' an event that occurred to both feet, then you could represent this by two
#' target codes, where one code represents that event occurring to the left
#' foot, and the other code represents that event occurring to the right foot.
#' So in in terms of codes, suppose we have a collection of codes that we call
#' set A and a collection of codes that we call set B, then a combination code
#' might require both a code from a set A \strong{and} a code from set B. In
#' some cases, the combinations might require three or more codes in
#' conjunction, so that you would require a code from a set A \strong{and} a
#' code from set B \strong{and} a code from set C, and so on. These different
#' sets are referred to in the GEMs' terminology as \emph{choices}.
#'
#' The GEMs also have a concept of what they call a \emph{scenario}. These are
#' typically used when the source event has multiple ways of being satisfied.
#' For example, a particular symptom occurring as the result of a chemical or
#' biological exposure could be represented with codes for the symptom and the
#' chemical exposure, \emph{or} codes for the symptom and the biological
#' exposure (so this example has two scenarios, each of which is a combination).
#' In terms of logic, scenarios represent OR statements, while combinations
#' represent AND statements.
#'
#' The representation of the GEMs provided by \code{icd_gem_9_to_10} and
#' \code{icd_gem_10_to_9} is the following. Each row in the data corresponds to
#' a single scenario for a given source code. The columns in the data are
#' listed as follows.
#'
#' \itemize{
#'
#' \item \code{source_short}: The source ICD codes in short form.
#'
#' \item \code{source_decimal}: The source ICD codes in decimal form.
#'
#' \item \code{scenario}: The scenario.
#'
#' \item \code{type}: The scenario type.
#'
#' \item \code{approx}: Whether the mapping is an exact or an approximate
#' mapping.
#'
#' \item \code{codes_short}: A list with 0 or more code sets in short form
#' with the semantics that there must be at least one code from the target
#' set in every one of the code sets for the scenario to be satisfied.
#'
#' \item \code{codes_decimal}: A list with the same form as
#' \code{codes_short}, but in decimal rather than short form.
#'
#' }
#'
#' @section Example ICD-9 to ICD-10 mapping:
#'
#' For a concrete example, suppose that we want to map ICD-9 codes to ICD-10
#' codes. Further suppose that for a given row that the value of
#' \code{source_short} (i.e. the short form ICD-9 code) is \code{"24951"}, the
#' value of \code{scenario} is \code{"0"}, and the contents of the value of
#' \code{codes_short} is a single vector \code{c("E0839", "E0939")}. Then one
#' of the ICD-10 codes in our dataset must have a value of \code{E0839} or
#' \code{E0939} for our data to have an event corresponding to the ICD-9 code
#' 24951 by way of scenario 0.
#'
#' Continuing this example, as it happens there are two scenarios for source
#' ICD-9 code 24951, and thus there is another row of the data, and for which
#' the value of \code{source_short} is \code{"24951"}, the value of
#' \code{scenario} is \code{"1"}, and the contents of the value of
#' \code{codes_short} is the vectors \code{c("E08311", "E08319", "E0836",
#' "E09311", "E09319", "E0936")} and \code{"E0865"}. Then one of the ICD-10
#' codes in our dataset must have a value of one of \code{c("E08311", "E08319",
#' "E0836", "E09311", "E09319", "E0936")}, \emph{and} another of the ICD-10
#' codes in our dataset must have value of \code{E0939} for our data to have an
#' event corresponding to the ICD-9 code 24951 by way of scenario 1.
#'
#' Since these are the only two scenarios corresponding to ICD-9 code 24951, we
#' must have ICD-10 codes in our data that satisfy either scenario 0 or scenario
#' 1 for us to conclude that an event corresponding to ICD-9 code 24951
#' occurred.
#'
#' Some input source codes don't have a representation in the target code set or
#' may not exist in the corresponding GEM at all. When either of these events
#' is the case then the corresponding value of \code{codes} is an empty list.
#'
#' @docType data
#' @source \url{https://www.cms.gov/Medicare/Coding/ICD10/2018-ICD-10-CM-and-GEMs.html}
#' @name icd_gem_9_to_10
#' @aliases icd_gem_10_to_9
#' @seealso \code{\link{icd_gem}}
#' @keywords datasets
NULL
Loading