Skip to content

Commit

Permalink
refactor: %chin% replaces purrr::map()
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewallenbruce committed Mar 6, 2024
1 parent 299e744 commit bcd5834
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 27 deletions.
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ BugReports: https://github.com/andrewallenbruce/northstar/issues
Depends:
R (>= 4.1.0)
Imports:
data.table,
dplyr,
pins,
rlang,
Expand Down
3 changes: 2 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export(calc_limiting_charge)
export(calc_nonpar_amount)
export(cpt_descriptors)
export(gpci)
export(hcpcs)
export(hcpcs_lv2)
export(pfs)
export(rvu)
importFrom(data.table,"%chin%")
50 changes: 33 additions & 17 deletions R/databases.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
#' @export
rvu <- function(hcpcs = NULL) {

rvu <- pins::pin_read(mount_board(), "rvu")
rv <- pins::pin_read(mount_board(), "rvu")

if (!is.null(hcpcs)) {rvu <- vctrs::vec_slice(rvu, rvu$hcpcs == hcpcs)}
if (!is.null(hcpcs)) rv <- dplyr::filter(rv, hcpcs %chin% hcpcs)

return(rvu)
return(rv)
}

#' 2024 Physician Fee Schedule Payment Amount File
Expand All @@ -19,17 +19,19 @@ rvu <- function(hcpcs = NULL) {
#' @param locality description
#' @return a [dplyr::tibble()]
#' @examplesIf interactive()
#' pfs(hcpcs = "11646", locality = "01", mac = "10212")
#' pfs(hcpcs = c("39503", "43116", "33935", "11646"),
#' locality = "01",
#' mac = "10212")
#' @export
pfs <- function(hcpcs = NULL,
mac = NULL,
locality = NULL) {

pmt <- pins::pin_read(mount_board(), "pymt")

if (!is.null(hcpcs)) {pmt <- vctrs::vec_slice(pmt, pmt$hcpcs == hcpcs)}
if (!is.null(mac)) {pmt <- vctrs::vec_slice(pmt, pmt$mac == mac)}
if (!is.null(locality)) {pmt <- vctrs::vec_slice(pmt, pmt$locality == locality)}
if (!is.null(locality)) pmt <- dplyr::filter(pmt, locality %chin% locality)
if (!is.null(mac)) pmt <- dplyr::filter(pmt, mac %chin% mac)
if (!is.null(hcpcs)) pmt <- dplyr::filter(pmt, hcpcs %chin% hcpcs)

return(pmt)

Expand All @@ -47,29 +49,43 @@ gpci <- function(mac = NULL,
state = NULL,
locality = NULL) {

gpci <- pins::pin_read(mount_board(), "gpci")
gp <- pins::pin_read(mount_board(), "gpci")

if (!is.null(mac)) {gpci <- vctrs::vec_slice(gpci, gpci$mac == mac)}
if (!is.null(state)) {gpci <- vctrs::vec_slice(gpci, gpci$state == state)}
if (!is.null(locality)) {gpci <- vctrs::vec_slice(gpci, gpci$locality == locality)}
if (!is.null(locality)) gp <- dplyr::filter(gp, locality %chin% locality)
if (!is.null(mac)) gp <- dplyr::filter(gp, mac %chin% mac)
if (!is.null(state)) gp <- dplyr::filter(gp, state %chin% state)

return(gpci)
return(gp)
}

#' 2024 Healthcare Common Procedure Coding System (HCPCS)
#' @param hcpcs description
#' @return a [dplyr::tibble()]
#' @examplesIf interactive()
#' hcpcs()
#' hcpcs_lv2(hcpcs = c("39503", "43116", "33935", "11646"))
#' @export
hcpcs <- function() {
pins::pin_read(mount_board(), "hcpcs")
hcpcs_lv2 <- function(hcpcs = NULL) {

L2 <- pins::pin_read(mount_board(), "hcpcs")

if (!is.null(hcpcs)) L2 <- dplyr::filter(L2, hcpcs %chin% hcpcs)

return(L2)

}

#' 2023 CPT Descriptors (Clinician & Consumer-Friendly)
#' @param hcpcs description
#' @return a [dplyr::tibble()]
#' @examplesIf interactive()
#' cpt_descriptors()
#' @export
cpt_descriptors <- function() {
pins::pin_read(mount_board(), "cpt_descriptors")
cpt_descriptors <- function(hcpcs = NULL) {

cpt <- pins::pin_read(mount_board(), "cpt_descriptors")

if (!is.null(hcpcs)) cpt <- dplyr::filter(cpt, hcpcs %chin% hcpcs)

return(cpt)

}
2 changes: 1 addition & 1 deletion R/northstar-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
## usethis namespace: start
# @importFrom zeallot %<-%
# @importFrom stringi %s+%
# @importFrom rlang %||%
#' @importFrom data.table %chin%
## usethis namespace: end
NULL
3 changes: 1 addition & 2 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ gh_raw <- function(x) {
#' Wrapper to mount package's [pins::board_url()]
#' @noRd
mount_board <- function() {
pins::board_url(gh_raw(
"andrewallenbruce/northstar/master/pins/"))
pins::board_url(gh_raw("andrewallenbruce/northstar/master/pins/"))
}

#' Search a data frame's column by string
Expand Down
5 changes: 4 additions & 1 deletion man/cpt_descriptors.Rd

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

11 changes: 7 additions & 4 deletions man/hcpcs.Rd → man/hcpcs_lv2.Rd

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

4 changes: 3 additions & 1 deletion man/pfs.Rd

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

0 comments on commit bcd5834

Please sign in to comment.