Skip to contents

This function inserts new concept entries into a specified domain within the concept table of a CDM object.It supports four domains: Condition, Drug, Measurement, and Observation. Existing entries with the same concept IDs will be overwritten, so caution should be used when adding data to prevent unintended data loss.

Usage

mockConcepts(cdm, conceptSet, domain = "Condition", seed = NULL)

Arguments

cdm

A CDM object that represents a common data model containing at least a concept table.This object will be modified in-place to include the new or updated concept entries.

conceptSet

A numeric vector of concept IDs to be added or updated in the concept table.These IDs should be unique within the context of the provided domain to avoid unintended overwriting unless that is the intended effect.

domain

A character string specifying the domain of the concepts being added.Only accepts "Condition", "Drug", "Measurement", or "Observation". This defines under which category the concepts fall and affects which vocabulary is used for them.

seed

An optional integer value used to set the random seed for generating reproducible concept attributes like `vocabulary_id` and `concept_class_id`. Useful for testing or when consistent output is required.

Value

Returns the modified CDM object with the updated concept table reflecting the newly added concepts.The function directly modifies the provided CDM object.

Examples

library(omock)
library(dplyr)

# Create a mock CDM reference and add concepts in the 'Condition' domain
cdm <- mockCdmReference() |> mockConcepts(
conceptSet = c(100, 200), domain = "Condition")

# View the updated concept entries for the 'Condition' domain
cdm$concept |> filter(domain_id == "Condition")
#> # A tibble: 14 × 10
#>    concept_id concept_name              domain_id vocabulary_id standard_concept
#>         <dbl> <chr>                     <chr>     <chr>         <chr>           
#>  1          1 Musculoskeletal disorder  Condition SNOMED        S               
#>  2          2 Osteoarthrosis            Condition SNOMED        S               
#>  3          3 Arthritis                 Condition SNOMED        S               
#>  4          4 Osteoarthritis of knee    Condition SNOMED        S               
#>  5          5 Osteoarthritis of hip     Condition SNOMED        S               
#>  6          6 Osteonecrosis             Condition SNOMED        S               
#>  7          7 Degenerative arthropathy  Condition Read          NA              
#>  8          8 Knee osteoarthritis       Condition Read          NA              
#>  9         15 Diseases of the musculos… Condition ICD10         NA              
#> 10         16 Arthropathies             Condition ICD10         NA              
#> 11         17 Arthritis                 Condition ICD10         NA              
#> 12         18 OA                        Condition ICD10         NA              
#> 13        100 Condition_100             Condition SNOMED        S               
#> 14        200 Condition_200             Condition SNOMED        S               
#> # ℹ 5 more variables: concept_class_id <chr>, concept_code <chr>,
#> #   valid_start_date <chr>, valid_end_date <chr>, invalid_reason <chr>