Learn R Programming

omock

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.

Introduction

You can install the development version of omock using:

# install.packages("devtools")
devtools::install_github("OHDSI/omock")

Example

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.

cdm <- emptyCdmReference(cdmName = "mock")
cdm$person %>%
  glimpse()
#> 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>
cdm$observation_period %>%
  glimpse()
#> 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 %>%
  omock::mockPerson(nPerson = 1000)

cdm$person %>%
  glimpse()
#> 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> 8532, 8532, 8532, 8532, 8507, 8532, 8507, …
#> $ year_of_birth               <int> 1982, 1981, 1962, 1963, 1996, 1972, 1951, …
#> $ month_of_birth              <int> 5, 4, 5, 1, 10, 4, 11, 1, 7, 12, 10, 5, 1,…
#> $ day_of_birth                <int> 3, 8, 18, 25, 17, 7, 12, 5, 7, 7, 1, 28, 8…
#> $ 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 %>%
  omock::mockObservationPeriod()

cdm$observation_period %>%
  glimpse()
#> 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> 1985-10-17, 2004-06-19, 1988-06-21, 201…
#> $ observation_period_end_date   <date> 2002-10-01, 2006-01-25, 2017-08-08, 201…
#> $ period_type_concept_id        <int> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …

Copy Link

Version

Install

install.packages('omock')

Monthly Downloads

182

Version

0.4.0

License

Apache License (>= 2)

Issues

Pull Requests

Stars

Forks

Maintainer

Mike Du

Last Published

June 12th, 2025

Functions in omock (0.4.0)

reexports

Objects exported from other packages
mockVocabularyTables

Creates a mock CDM database populated with various vocabulary tables.
mockPerson

Generates a mock person table and integrates it into an existing CDM object.
omock-package

omock: Creation of Mock Observational Medical Outcomes Partnership Common Data Model
mockCdmReference

Creates an empty CDM (Common Data Model) reference for a mock database.
isMockDatasetDownloaded

Check if a certain dataset is downloaded.
downloadMockDataset

Download an OMOP Synthetic dataset.
mockCdmFromTables

Generates a mock CDM (Common Data Model) object based on existing CDM structures and additional tables.
mockCdmFromDataset

Create a `local` cdm_reference from a dataset.
mockCohort

Generate Synthetic Cohort
availableMockDatasets

List the available datasets
mockConditionOccurrence

Generates a mock condition occurrence table and integrates it into an existing CDM object.
mockConcepts

Adds mock concept data to a concept table within a Common Data Model (CDM) object.
mockDatasets

Available mock OMOP CDM Synthetic Datasets
mockDeath

Generates a mock death table and integrates it into an existing CDM object.
mockDrugExposure

Generates a mock drug exposure table and integrates it into an existing CDM object.
mockVisitOccurrence

Function to generate visit occurrence table
mockObservationPeriod

Generates a mock observation period table and integrates it into an existing CDM object.
mockDatasetsFolder

Check or set the datasets Folder
mockProcedureOccurrence

Generates a mock procedure occurrence table and integrates it into an existing CDM object.
mockObservation

Generates a mock observation table and integrates it into an existing CDM object.
mockMeasurement

Generates a mock measurement table and integrates it into an existing CDM object.
mockDatasetsStatus

Check the availability of the OMOP CDM datasets.