The primary objective of the omock package is to generate mock OMOP CDM (Observational Medical Outcomes Partnership Common Data Model) data to facilitating the testing of various packages within the OMOPverse ecosystem.
You can install the development version of omock using:
# install.packages("devtools")
::install_github("oxford-pharmacoepi/omock") devtools
With omock we can quickly make a simple mock of OMOP CDM data.
library(omopgenerics)
library(omock)
library(dplyr)
We first start by making an empty cdm reference. This includes the person and observation tables (as they are required) but they are currently empty.
<- emptyCdmReference(cdmName = "mock")
cdm $person %>%
cdmglimpse()
#> Rows: 0
#> Columns: 18
#> $ person_id <int>
#> $ gender_concept_id <int>
#> $ year_of_birth <int>
#> $ month_of_birth <int>
#> $ day_of_birth <int>
#> $ birth_datetime <date>
#> $ race_concept_id <int>
#> $ ethnicity_concept_id <int>
#> $ location_id <int>
#> $ provider_id <int>
#> $ care_site_id <int>
#> $ person_source_value <chr>
#> $ gender_source_value <chr>
#> $ gender_source_concept_id <int>
#> $ race_source_value <chr>
#> $ race_source_concept_id <int>
#> $ ethnicity_source_value <chr>
#> $ ethnicity_source_concept_id <int>
$observation_period %>%
cdmglimpse()
#> Rows: 0
#> Columns: 5
#> $ observation_period_id <int>
#> $ person_id <int>
#> $ observation_period_start_date <date>
#> $ observation_period_end_date <date>
#> $ period_type_concept_id <int>
Once we have have our empty cdm reference, we can quickly add a person table with a specific number of individuals.
<- cdm %>%
cdm ::mockPerson(nPerson = 1000)
omock
$person %>%
cdmglimpse()
#> Rows: 1,000
#> Columns: 18
#> $ person_id <int> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,…
#> $ gender_concept_id <int> 8507, 8532, 8532, 8532, 8507, 8507, 8532, …
#> $ year_of_birth <int> 1985, 1993, 1955, 1971, 1958, 1983, 1970, …
#> $ month_of_birth <int> 2, 4, 4, 12, 5, 6, 8, 2, 4, 6, 7, 3, 8, 6,…
#> $ day_of_birth <int> 10, 24, 6, 27, 18, 19, 21, 14, 30, 22, 15,…
#> $ race_concept_id <int> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
#> $ ethnicity_concept_id <int> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
#> $ birth_datetime <dttm> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…
#> $ location_id <int> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
#> $ provider_id <int> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
#> $ care_site_id <int> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
#> $ person_source_value <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
#> $ gender_source_value <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
#> $ gender_source_concept_id <int> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
#> $ race_source_value <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
#> $ race_source_concept_id <int> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
#> $ ethnicity_source_value <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
#> $ ethnicity_source_concept_id <int> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
We can then fill in the observation period table for these individuals.
<- cdm %>%
cdm ::mockObservationPeriod()
omock
$observation_period %>%
cdmglimpse()
#> Rows: 1,000
#> Columns: 5
#> $ observation_period_id <int> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 1…
#> $ person_id <int> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 1…
#> $ observation_period_start_date <date> 2008-10-04, 2013-10-29, 1988-03-28, 198…
#> $ observation_period_end_date <date> 2010-01-22, 2018-11-02, 1992-03-06, 198…
#> $ period_type_concept_id <int> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …