Skip to content

Commit

Permalink
update regex
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewallenbruce committed Jul 7, 2024
1 parent 296aa96 commit 2efa041
Show file tree
Hide file tree
Showing 12 changed files with 337 additions and 116 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Generated by roxygen2: do not edit by hand

S3method(print,northstar)
export(.as)
export(assign_adjustments)
export(calculate_amounts)
export(carc_add_dash)
Expand Down
33 changes: 6 additions & 27 deletions R/aaa.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@

#' @keywords internal
#'
#' @autoglobal
#'
#' @export
.as <- list(
chr = \(...) as.character(...),
int = \(...) as.integer(...),
Expand All @@ -7,30 +13,3 @@
dte = \(...) as.Date(...),
vct = \(...) as.vector(...)
)


# .sets <- new.env()
#
# .sets$ncci <- list(
# aoc = get_pin("ncci_aoc_nested"),
# mue = get_pin("ncci_mue_prac"),
# ptp = get_pin("ncci_ptp_prac")
# )

# .sets$ncci$aoc
#
# .pin <- list(
# adj = get_pin("adj_codes"),
# aoc = get_pin("ncci_aoc_nested"),
# mue = get_pin("ncci_mue_prac"),
# ptp = get_pin("ncci_ptp_prac"),
# rvu = \(type) switch(type,
# amt = get_pin("pfs_rvu_amt"),
# ind = get_pin("pfs_rvu_ind")),
# gpci = get_pin("pfs_gpci"),
# desc = get_pin("hcpcs_descriptions"),
# mod = get_pin("modifiers"),
# hcpcs = get_pin("hcpcs_lvl2"),
# pos = get_pin("pos_codes"),
# rbcs = get_pin("rbcs")
# )
18 changes: 8 additions & 10 deletions R/adjustments.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#' Search Adjustment Codes
#'
#' CARC and RARC Codes
#' Search Claim Adjustment Codes
#'
#' @details Claim Adjustment Reason Codes:
#'
Expand All @@ -12,11 +10,12 @@
#'
#' The Claim Adjustment *Group Codes* are internal to the X12 standard. The
#' format is always two alpha characters:
#' - **CO**: Contractual Obligations
#' - **CR**: Corrections and Reversals
#' - **OA**: Other Adjustments
#' - **PI**: Payer Initiated Reductions
#' - **PR**: Patient Responsibility
#'
#' - **CO** (Contractual Obligations): Indicates patient is responsible for remaining balance
#' - **CR** (Corrections and Reversals)
#' - **OA** (Other Adjustments): Indicates denial is related to other insurance coverage
#' - **PI** (Payer-Initiated Reductions)
#' - **PR** (Patient Responsibility): Indicates patient responsibility has been adjusted
#'
#' @details Remittance Advice Remark Codes:
#'
Expand Down Expand Up @@ -61,8 +60,7 @@
#' @export
search_adjustments <- function(adj_code = NULL, adj_type = NULL, ...) {

adj_type <- if (!is.null(adj_type)) match.arg(
adj_type,
adj_type <- if (!is.null(adj_type)) match.arg(adj_type,
c("Group", "CARC", "RARC"))

adj <- get_pin("adj_codes")
Expand Down
11 changes: 8 additions & 3 deletions R/regex.R
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,13 @@ construct_regex2 <- function(x) {
purrr::list_c() |>
paste0(collapse = "")

paste0("^", to_vec, "$")
x <- paste0("^", to_vec, "$")

x <- gsub(paste0(0:9, collapse = ""), "0-9", x)

x <- gsub(paste0(LETTERS, collapse = ""), "A-Z", x)

return(x)
}

#' Internal function for `construct_regex2()`
Expand All @@ -131,8 +137,7 @@ pos_re2 <- function(x) {
paste0("[",
fuimus::collapser(alphabet),
fuimus::collapser(numbers),
"]",
"{1}"
"]"
)

}
Expand Down
88 changes: 88 additions & 0 deletions R/standards.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
#' code = c("A0021", "V5362", "J9264", "G8916")) |>
#' search_descriptions(column = "code")
#'
#' search_descriptions() |>
#' dplyr::filter(is_cpt_category_III(hcpcs_code))
#'
#' @autoglobal
#'
#' @family HIPAA Standards
Expand Down Expand Up @@ -203,6 +206,91 @@ search_plas <- function(hcpcs_code = NULL, ...) {
#' of Medicare, Medicaid and private insurance services provided by a given
#' provider.
#'
#' ## Code Structure
#'
#' The first digit denotes service category and the second specifies location or
#' service type.
#'
#' POS code 11 represents an Office for direct patient services.
#'
#' For instance, code 11 designates an Office, encompassing
#' physician offices, clinics, group practices, and standalone facilities
#' providing direct patient services.
#'
#' Conversely, place of service code 22
#' denotes an On Campus-Outpatient Hospital, covering services in a
#' hospital-based outpatient department where the patient is admitted as an
#' outpatient.
#'
#' * Structure: First digit for category, second for location/type
#' * Choose POS based on the majority of services in a specific encounter
#' * Modify POS codes if the location changes during a single encounter
#'
#' ## Location Types
#'
#' Based on the location of service, POS codes can be grouped into four
#' categories: Facility, Non-Facility, Telehealth, and Other.
#'
#' ### Facility Codes
#'
#' Facility POS codes are used to indicate services provided in a facility
#' setting such as hospitals, nursing homes, or skilled nursing facilities.
#' These include:
#'
#' * Urgent Care Facility (20)
#' * Inpatient Hospital (21)
#' * Outpatient Hospital (22)
#' * Emergency Room-Hospital (23)
#' * Ambulatory Surgical Center (24)
#' * Skilled Nursing Facility (31)
#' * Hospice Facility (32)
#'
#' These codes indicate that the services were provided in a facility that is
#' owned and operated by a healthcare provider.
#'
#' ### Non-Facility Codes
#'
#' Non-facility POS codes are used for services provided in non-facility
#' settings such as physician offices or independent clinics. These include:
#'
#' * School (03)
#' * Office (11)
#' * Home (12)
#' * Independent Clinic (49)
#'
#' The above codes indicate that the services were provided in a setting not
#' owned or operated by a healthcare provider.
#'
#' ### Telehealth POS Codes
#'
#' Telehealth place-of-service codes are used to indicate services provided
#' through telecommunication technology. These include:
#'
#' * Telehealth (02)
#' * Store and Forward Telemedicine Services (18)
#'
#' This category of POS codes was introduced due to the increasing use of
#' telehealth services in healthcare, and to differentiate them from traditional
#' in-person services.
#'
#' ### Other POS Codes
#'
#' In addition to facility-specific POS codes, there are other codes that play a
#' vital role in accurately describing healthcare encounters. These codes are
#' designed for specific scenarios, such as visits to retail clinics, public
#' health clinics, or rural health clinics. Each code serves a distinct purpose
#' in the healthcare landscape.
#'
#' * Homeless Shelter (04)
#' * Retail Clinic (17)
#' * Rural Health Clinic (72)
#'
#' These codes, including Retail Clinic (17), Home Shelter (04), and Rural
#' Health Clinic (72), cater to unique healthcare settings, ensuring
#' comprehensive coverage in billing and reporting. Understanding and applying
#' these codes appropriately contributes to the precision of healthcare
#' documentation and facilitates effective reimbursement processes.
#'
#' @param pos_code `<chr>` vector of 2-character Place of Service codes; default
#' is `NULL`
#'
Expand Down
45 changes: 27 additions & 18 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,62 +2,72 @@
#'
#' @param source `<chr>` `"local"` or `"remote"`
#'
#' @template args-dots
#'
#' @returns `<pins_board_folder>` or `<pins_board_url>`
#'
#' @autoglobal
#'
#' @keywords internal
#'
#' @export
mount_board <- function(source = c("local", "remote")) {
mount_board <- function(source = c("local", "remote"), ...) {

source <- match.arg(source)

switch(
source,
local = pins::board_folder(fs::path_package("extdata/pins", package = "northstar")),
remote = pins::board_url("https://raw.githubusercontent.com/andrewallenbruce/northstar/master/inst/extdata/pins/"))
local = pins::board_folder(
fs::path_package(
"extdata/pins",
package = "northstar"
)
),
remote = pins::board_url(
"https://raw.githubusercontent.com/andrewallenbruce/northstar/master/inst/extdata/pins/"
)
)
}

#' Get a pinned dataset from a [pins][pins::pins-package] board
#'
#' @param pin `<chr>` string name of pinned dataset
#' List pins from a [pins][pins::pins-package] board
#'
#' @template args-dots
#' @param ... arguments to pass to [mount_board()]
#'
#' @returns `<tibble>`
#' @returns `<list>` of [pins][pins::pins-package]
#'
#' @autoglobal
#'
#' @keywords internal
#'
#' @export
get_pin <- function(pin, ...) {
list_pins <- function(...) {

board <- mount_board(...)

pin <- rlang::arg_match0(pin, list_pins())

pins::pin_read(board, pin)
pins::pin_list(board)

}

#' List pins from a [pins][pins::pins-package] board
#' Get a pinned dataset from a [pins][pins::pins-package] board
#'
#' @param ... arguments to pass to [mount_board()]
#' @param pin `<chr>` string name of pinned dataset
#'
#' @returns `<list>` of [pins][pins::pins-package]
#' @template args-dots
#'
#' @returns `<tibble>`
#'
#' @autoglobal
#'
#' @keywords internal
#'
#' @export
list_pins <- function(...) {
get_pin <- function(pin, ...) {

board <- mount_board(...)

pins::pin_list(board)
pin <- rlang::arg_match0(pin, list_pins())

pins::pin_read(board, pin)

}

Expand All @@ -80,7 +90,6 @@ get_example <- function(name = c("report", "practicum")) {

}


#' Apply {gt} Theme
#'
#' @param gt_object `<gt_tbl>` A [gt][gt::gt-package] table object
Expand Down
4 changes: 3 additions & 1 deletion man/mount_board.Rd

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

14 changes: 7 additions & 7 deletions man/search_adjustments.Rd

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

3 changes: 3 additions & 0 deletions man/search_descriptions.Rd

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

Loading

0 comments on commit 2efa041

Please sign in to comment.