Skip to content

adjustments() Implementation #18

Open
@andrewallenbruce

Description

@andrewallenbruce

Using {triebeard}

library(tidyverse)
library(northstar)
library(triebeard)

carc_group <- search_adjustments()$group

carc_group_trie <- triebeard::trie(
  keys = carc_group$code,
  values = carc_group$description
)

carc_code <- search_adjustments()$carc |> 
  select(code, description)

carc_code_trie <- triebeard::trie(
  keys = carc_code$code,
  values = carc_code$description
)

rpt |>
  select(pid, eid, adj_code_1, adj_code_2, adj_code_3) |>
  distinct() |> 
  pivot_longer(
    cols = starts_with("adj_code_"), 
    values_drop_na = TRUE,
    names_to = "adj_ord",
    names_prefix = "adj_code_",
    names_transform = list(adj_ord = as.integer),
    values_to = "adj_code"
    ) |>
  mutate(
    adj_code = if_else(str_detect(adj_code, regex("^-\\d+")), paste0("ZZ", adj_code), adj_code),
    adj_group_desc = triebeard::longest_match(carc_group_trie, substr(adj_code, 1, 2)),
    adj_code_desc = triebeard::longest_match(carc_code_trie, substr(adj_code, 4, 8))
  ) |> 
  count(adj_code, adj_group_desc, adj_code_desc, sort = TRUE)

#> # A tibble: 41 × 4
#>    adj_code adj_group_desc             adj_code_desc                           n
#>    <chr>    <chr>                      <chr>                               <int>
#>  1 CO-45    Contractual Obligations    Charge exceeds fee schedule/maximu… 28906
#>  2 CO-253   Contractual Obligations    Sequestration - reduction in feder…  1959
#>  3 CO-96    Contractual Obligations    Non-covered charge(s). At least on…   126
#>  4 CO-197   Contractual Obligations    Precertification/authorization/not…    95
#>  5 CO-29    Contractual Obligations    The time limit for filing has expi…    84
#>  6 OA-23    Other Adjustments          The impact of prior payer(s) adjud…    75
#>  7 PR-45    Patient Responsibility     Charge exceeds fee schedule/maximu…    42
#>  8 CO-23    Contractual Obligations    The impact of prior payer(s) adjud…    39
#>  9 OA-45    Other Adjustments          Charge exceeds fee schedule/maximu…    37
#> 10 CO-97    Contractual Obligations    The benefit for this service is in…    13
#> 11 PI-185   Payer Initiated Reductions The rendering provider is not elig…    10
#> 12 CO-18    Contractual Obligations    Exact duplicate claim/service (Use…     9
#> 13 CO-131   Contractual Obligations    Claim specific negotiated discount.     8
#> 14 PI-131   Payer Initiated Reductions Claim specific negotiated discount.     7
#> 15 PR-187   Patient Responsibility     Consumer Spending Account payments…     7
#> 16 CO-170   Contractual Obligations    Payment is denied when performed/b…     5
#> 17 PR-A1    Patient Responsibility     Claim/Service denied. At least one…     4
#> 18 CO-16    Contractual Obligations    Claim/service lacks information or…     3
#> 19 CO-198   Contractual Obligations    Precertification/notification/auth…     3
#> 20 CO-242   Contractual Obligations    Services not provided by network/p…     3
#> 21 ZZ-45    <NA>                       Charge exceeds fee schedule/maximu…     3
#> 22 CO-208   Contractual Obligations    National Provider Identifier - Not…     2
#> 23 CO-62    Contractual Obligations    Payment denied/reduced for absence…     2
#> 24 CO-B7    Contractual Obligations    This provider was not certified/el…     2
#> 25 PI-253   Payer Initiated Reductions Sequestration - reduction in feder…     2
#> 26 CO-151   Contractual Obligations    Payment adjusted because the payer…     1
#> 27 CO-187   Contractual Obligations    Consumer Spending Account payments…     1
#> 28 CO-21    Contractual Obligations    This injury/illness is the liabili…     1
#> 29 CO-22    Contractual Obligations    This care may be covered by anothe…     1
#> 30 CO-234   Contractual Obligations    This procedure is not paid separat…     1
#> 31 CO-B13   Contractual Obligations    Previously paid. Payment for this …     1
#> 32 CR       Corrections and Reversals  <NA>                                    1
#> 33 OA-187   Other Adjustments          Consumer Spending Account payments…     1
#> 34 OA-29    Other Adjustments          The time limit for filing has expi…     1
#> 35 PI-18    Payer Initiated Reductions Exact duplicate claim/service (Use…     1
#> 36 PI-45    Payer Initiated Reductions Charge exceeds fee schedule/maximu…     1
#> 37 PI-96    Payer Initiated Reductions Non-covered charge(s). At least on…     1
#> 38 PR-204   Patient Responsibility     This service/equipment/drug is not…     1
#> 39 PR-242   Patient Responsibility     Services not provided by network/p…     1
#> 40 PR-8     Patient Responsibility     The procedure code is inconsistent…     1
#> 41 PR-96    Patient Responsibility     Non-covered charge(s). At least on…     1

Created on 2024-06-11 with reprex v2.1.0

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions