This function filters a column that contains Concept Strips using Concept Table parameters. The target column may contain 1 or more merged concept strip, and the multiple strips must be separated by a new line \"\n\" for the filter to operate correctly. It is important to note that the the filter is applied to the entire Concept Strip cell and will not alter the data content within the cell otherwise. For example, if the filter `vocabulary_id == 'RxNorm'` is used for `ColumnA`, a `ColumnA` cell that contains at least 1 RxNorm concept will be filtered for though there are other non-RxNorm concepts in that same cell.

filter_strip(data, strip_col, ...)

Arguments

data

dataframe with the merged concept column

...

arguments that will be passed to the dplyr filter function using the base Concept Table field names

merge_col

column of merged concepts

Value

A tibble with the same number of columns as the input with the number of rows equal or less than that of the input.

See also

Examples

#> [2021-05-26 16:00:46] Connected to 'athena'
test_data <- queryAthena("SELECT * FROM omop_vocabulary.concept ORDER BY RANDOM() LIMIT 20;", conn = conn)
#> [2021-05-26 16:00:46] Loading Cache... #> [2021-05-26 16:00:46] Cached SQL: SELECT * FROM omop_vocabulary.concept ORDER BY RANDOM() LIMIT 20; #> [2021-05-26 16:00:46] Cached resultset found...
# Merge merge_strip(data = test_data, into = "concept")
#> # A tibble: 20 x 2 #> concept_id concept #> <int> <chr> #> 1 37083718 [V] [N] 37083718 Disorders of autonomic nervous system [ICD10GM G… #> 2 3414550 [V] [N] 3414550 Traumatic brachial plexus lesion [Nebraska Lexico… #> 3 45110479 [V] [N] 45110479 GNP CHLD IBUPROFEN 100 MG/5 ML [NDC 87701030771]… #> 4 45071768 [V] [N] 45071768 metoprolol tartrate 50 MG Oral Tablet [NDC 55289… #> 5 44104843 [V] [S] 44104843 ECHINACEA ANGUSTIFOLIA Extract 1 X [RxNorm Exten… #> 6 44799086 [U] [N] 44799086 [X]Victim of avalanche, landslide and other eart… #> 7 3051772 [V] [S] 3051772 MR Lower extremity joint - right WO and W contras… #> 8 19123243 [U] [N] 19123243 Levobupivacaine 0.625 MG/ML Injectable Solution … #> 9 3652026 [D] [N] 3652026 MIDODRINE HYDROCHLORIDE 2.5mg tablets [SNOMED 126… #> 10 42743213 [V] [N] 42743213 Operations on other bone: bone grafting and -tra… #> 11 4326268 [V] [S] 4326268 Infection by Oesophagostomum apiostomum [SNOMED 7… #> 12 36240133 [V] [C] 36240133 Noctesed Oral Product [RxNorm 1184488] [Drug] [B… #> 13 3234609 [V] [N] 3234609 Finding of movement of uvula [Nebraska Lexicon 36… #> 14 42061633 [V] [S] 42061633 Bogalusa [OSM 132196] [Geography] [8th level] #> 15 37513931 [V] [N] 37513931 oxcarbazepine 150 MG Oral Tablet [NDC 7051808940… #> 16 43569515 [V] [N] 43569515 Ginkgo Sandoz [RxNorm Extension OMOP888148] [Dru… #> 17 46290886 [V] [C] 46290886 LEG CRAMPS PM - oyster shell calcium carbonate, … #> 18 46289483 [V] [C] 46289483 TORK FOAM ANTIBACTERIAL - chloroxylenol soap [SP… #> 19 19118814 [D] [N] 19118814 Mitomycin 0.5 MG/ML [Mutamycin] [RxNorm 569802] … #> 20 21136931 [V] [S] 21136931 5 ML Regular Insulin, Human 100 UNT/ML Prefilled…
# Merge while sparing some original columns such as vocabulary_id and # concept_class_id merge_strip(data = test_data, into = "concept", vocabulary_id, concept_class_id)
#> # A tibble: 20 x 4 #> concept_id concept vocabulary_id concept_class_id #> <int> <chr> <chr> <chr> #> 1 37083718 [V] [N] 37083718 Disorders of au… ICD10GM ICD10 Hierarchy #> 2 3414550 [V] [N] 3414550 Traumatic brachi… Nebraska Lexi… Clinical Finding #> 3 45110479 [V] [N] 45110479 GNP CHLD IBUPRO… NDC 11-digit NDC #> 4 45071768 [V] [N] 45071768 metoprolol tart… NDC 11-digit NDC #> 5 44104843 [V] [S] 44104843 ECHINACEA ANGUS… RxNorm Extens… Clinical Drug Co… #> 6 44799086 [U] [N] 44799086 [X]Victim of av… SNOMED Clinical Finding #> 7 3051772 [V] [S] 3051772 MR Lower extremi… LOINC Clinical Observa… #> 8 19123243 [U] [N] 19123243 Levobupivacaine… RxNorm Clinical Drug #> 9 3652026 [D] [N] 3652026 MIDODRINE HYDROC… SNOMED Context-dependent #> 10 42743213 [V] [N] 42743213 Operations on o… OPS Procedure #> 11 4326268 [V] [S] 4326268 Infection by Oes… SNOMED Clinical Finding #> 12 36240133 [V] [C] 36240133 Noctesed Oral P… RxNorm Branded Dose Gro… #> 13 3234609 [V] [N] 3234609 Finding of movem… Nebraska Lexi… Clinical Finding #> 14 42061633 [V] [S] 42061633 Bogalusa [OSM 1… OSM 8th level #> 15 37513931 [V] [N] 37513931 oxcarbazepine 1… NDC 11-digit NDC #> 16 43569515 [V] [N] 43569515 Ginkgo Sandoz [… RxNorm Extens… Brand Name #> 17 46290886 [V] [C] 46290886 LEG CRAMPS PM -… SPL OTC Drug #> 18 46289483 [V] [C] 46289483 TORK FOAM ANTIB… SPL OTC Drug #> 19 19118814 [D] [N] 19118814 Mitomycin 0.5 M… RxNorm Branded Drug Comp #> 20 21136931 [V] [S] 21136931 5 ML Regular In… RxNorm Extens… Marketed Product
# Test filtering of strip columns test_output <- merge_strip(data = test_data, into = "concept") %>% dplyr::select(-concept_id) # Filter at a Strip Column filter_strip(test_output, strip_col = concept, vocabulary_id %in% c("SNOMED"))
#> # A tibble: 3 x 1 #> concept #> <chr> #> 1 [U] [N] 44799086 [X]Victim of avalanche, landslide and other earth movements … #> 2 [D] [N] 3652026 MIDODRINE HYDROCHLORIDE 2.5mg tablets [SNOMED 126558010000011… #> 3 [V] [S] 4326268 Infection by Oesophagostomum apiostomum [SNOMED 75169006] [Co…
# Filter at more than 1 Strip Column test_data <- dplyr::bind_cols(test_output %>% rubix::randomize() %>% dplyr::select(concept_a = concept), test_output %>% rubix::randomize() %>% dplyr::select(concept_b = concept)) filter_at_all_strip(data = test_data, strip_cols = c("concept_a", "concept_b"), vocabulary_id %in% c("RxNorm"))
#> # A tibble: 1 x 2 #> concept_a concept_b #> <chr> <chr> #> 1 [U] [N] 19123243 Levobupivacaine 0.625… [V] [C] 36240133 Noctesed Oral Produc…
filter_at_any_strip(data = test_data, strip_cols = c("concept_a", "concept_b"), vocabulary_id %in% c("RxNorm"))
#> # A tibble: 7 x 2 #> concept_a concept_b #> <chr> <chr> #> 1 [U] [N] 19123243 Levobupivacaine 0.625… [V] [C] 36240133 Noctesed Oral Produc… #> 2 [V] [S] 44104843 ECHINACEA ANGUSTIFOLI… [V] [C] 46290886 LEG CRAMPS PM - oyst… #> 3 [V] [C] 36240133 Noctesed Oral Product… [V] [N] 3414550 Traumatic brachial pl… #> 4 [V] [N] 43569515 Ginkgo Sandoz [RxNorm… [V] [S] 21136931 5 ML Regular Insulin… #> 5 [D] [N] 19118814 Mitomycin 0.5 MG/ML [… [V] [N] 43569515 Ginkgo Sandoz [RxNor… #> 6 [V] [C] 46290886 LEG CRAMPS PM - oyste… [V] [S] 44104843 ECHINACEA ANGUSTIFOL… #> 7 [V] [N] 3414550 Traumatic brachial ple… [U] [N] 19123243 Levobupivacaine 0.62…
dcAthena(conn = conn)
#> [2021-05-26 16:00:47] Postgres connection to 'athena' closed