Skip to content

definitions / devices - missing codes #1

@andrewallenbruce

Description

@andrewallenbruce
library(tidyverse)
def <- pins::pin_read(procedural:::mount_board(), "definitions")
def |> 
  filter(is.na(axis_code)) |> 
  count(section, axis_code, sort = TRUE)

#> # A tibble: 4 × 3
#>   section                                          axis_code     n
#>   <chr>                                            <chr>     <int>
#> 1 Medical and Surgical                             <NA>        129
#> 2 Physical Rehabilitation and Diagnostic Audiology <NA>         54
#> 3 New Technology                                   <NA>         28
#> 4 Administration                                   <NA>         10

def |> 
  count(section, axis_name) |> 
  print(n = 100)

#> # A tibble: 31 × 3
#>    section                                               axis_name             n
#>    <chr>                                                 <chr>             <int>
#>  1 Administration                                        Approach              6
#>  2 Administration                                        Operation             3
#>  3 Administration                                        Substance            17
#>  4 Chiropractic                                          Approach              1
#>  5 Chiropractic                                          Operation             1
#>  6 Extracorporeal or Systemic Assistance and Performance Operation             3
#>  7 Extracorporeal or Systemic Therapies                  Operation            11
#>  8 Imaging                                               Type                  6
#>  9 Measurement and Monitoring                            Approach              6
#> 10 Measurement and Monitoring                            Operation             2
#> 11 Medical and Surgical                                  Approach              7
#> 12 Medical and Surgical                                  Body Part           456
#> 13 Medical and Surgical                                  Device              139
#> 14 Medical and Surgical                                  Operation            31
#> 15 Mental Health                                         Qualifier            15
#> 16 Mental Health                                         Type                 12
#> 17 New Technology                                        Approach              6
#> 18 New Technology                                        Device / Substan…    91
#> 19 New Technology                                        Operation            18
#> 20 Nuclear Medicine                                      Type                  7
#> 21 Obstetrics                                            Approach              6
#> 22 Obstetrics                                            Operation            12
#> 23 Osteopathic                                           Approach              1
#> 24 Osteopathic                                           Operation             1
#> 25 Other Procedures                                      Approach              5
#> 26 Other Procedures                                      Operation             1
#> 27 Physical Rehabilitation and Diagnostic Audiology      Type                 14
#> 28 Physical Rehabilitation and Diagnostic Audiology      Type Qualifier      152
#> 29 Placement                                             Approach              1
#> 30 Placement                                             Operation             7
#> 31 Substance Abuse Treatment                             Type                  7


def |> 
  filter(section == "Medical and Surgical", is.na(axis_code)) |> 
  count(axis_name)

#> # A tibble: 1 × 2
#>   axis_name     n
#>   <chr>     <int>
#> 1 Device      129

system_device <- left_join(procedural::devices(), 
                           procedural::systems(), 
          by = join_by(section, 
                       system == value)) |> 
  select(system, label, operation:includes)

system_device
#> # A tibble: 99 × 6
#>    system label                   operation      device device_name     includes
#>    <chr>  <chr>                   <chr>          <chr>  <chr>           <chr>   
#>  1 2      Heart and Great Vessels All applicable 7      Autologous Tis… Autolog…
#>  2 4      Lower Arteries          All applicable 7      Autologous Tis… Autolog…
#>  3 6      Lower Veins             All applicable 7      Autologous Tis… Autolog…
#>  4 3      Upper Arteries          All applicable 7      Autologous Tis… Autolog…
#>  5 5      Upper Veins             All applicable 7      Autologous Tis… Autolog…
#>  6 2      Heart and Great Vessels All applicable 7      Autologous Tis… Autolog…
#>  7 4      Lower Arteries          All applicable 7      Autologous Tis… Autolog…
#>  8 6      Lower Veins             All applicable 7      Autologous Tis… Autolog…
#>  9 3      Upper Arteries          All applicable 7      Autologous Tis… Autolog…
#> 10 5      Upper Veins             All applicable 7      Autologous Tis… Autolog…
#> # ℹ 89 more rows

set <- pins::pin_read(procedural:::mount_board(), "tables_rows") |>
  dplyr::mutate(system = paste0(code_1, code_2),
                .before = name_3)

set |> 
  filter(code_1 == "0", 
         code_2 %in% c(2:6, 8:9, 
                       "B", "C", "D", 
                       "J", "P", "Q", 
                       "R", "S", "U")) |>
  unnest(rows) |> 
  filter(axis == "6", code %in% c(2, 4:7, 
                                  "D", "J", 
                                  "M", "P", "S")) |> 
  select(code_2, label_2, name, code, label) |>
  distinct() |> 
  left_join(system_device, 
            by = join_by(code_2 == system, 
                         label_2 == label, 
                         code == device),
            relationship = "many-to-many") |> 
  select(system = label_2, 
         operation, 
         device = code, 
         label, 
         device_name) |> 
  mutate(equal = if_else(label == device_name, TRUE, FALSE)) |>
  filter(!is.na(device_name), 
         operation != "All applicable", 
         equal == FALSE) |>
  print(n = Inf)

#> # A tibble: 5 × 6
#>   system                  operation device label               device_name equal
#>   <chr>                   <chr>     <chr>  <chr>               <chr>       <lgl>
#> 1 Heart and Great Vessels H         M      Synthetic Substitu… Cardiac Le… FALSE
#> 2 Heart and Great Vessels H         M      Synthetic Substitu… Cardiac Le… FALSE
#> 3 Lower Joints            H         4      Synthetic Substitu… Internal F… FALSE
#> 4 Lower Joints            H         4      Synthetic Substitu… Internal F… FALSE
#> 5 Lower Joints            H         4      Synthetic Substitu… Internal F… FALSE

Created on 2024-01-27 with reprex v2.1.0

Metadata

Metadata

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions