
Generates a mock measurement table and integrates it into an existing CDM object.
Source:R/mockMeasurement.R
mockMeasurement.RdThis function simulates measurement records for individuals within a specified cohort. It creates a realistic dataset by generating measurement records based on the specified number of records per person. Each measurement record is correctly associated with an individual within valid observation periods, ensuring the integrity of the data.
Arguments
- cdm
A local
cdm_referenceobject used as the base structure to update.- recordPerson
An integer specifying the expected number of measurement records to generate per person. This parameter allows for the simulation of varying frequencies of health measurements among individuals in the cohort, reflecting real-world variability in patient monitoring and diagnostic testing.
- seed
An optional integer used to set the random seed for reproducibility. If
NULL, the seed is not set.
Examples
library(omock)
library(dplyr)
# Create a mock CDM reference and add measurement records
cdm <- mockCdmReference() |>
mockPerson() |>
mockObservationPeriod() |>
mockMeasurement(recordPerson = 5)
# View the generated measurement data
cdm$measurement |>
glimpse()
#> Rows: 1,000
#> Columns: 20
#> $ measurement_concept_id <int> 3001467, 3001467, 3001467, 3001467, 3001…
#> $ person_id <int> 1, 4, 3, 7, 1, 4, 5, 9, 3, 10, 4, 8, 8, …
#> $ measurement_date <date> 2017-08-21, 1998-06-17, 2005-08-05, 201…
#> $ measurement_id <int> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 1…
#> $ measurement_type_concept_id <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0…
#> $ measurement_datetime <dttm> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,…
#> $ measurement_time <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …
#> $ operator_concept_id <int> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …
#> $ value_as_number <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …
#> $ value_as_concept_id <int> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …
#> $ unit_concept_id <int> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …
#> $ range_low <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …
#> $ range_high <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …
#> $ provider_id <int> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …
#> $ visit_occurrence_id <int> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …
#> $ visit_detail_id <int> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …
#> $ measurement_source_value <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …
#> $ measurement_source_concept_id <int> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …
#> $ unit_source_value <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …
#> $ value_source_value <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …