extras/TestCode.R

library(ROhdsiWebApi)
library(dplyr)
sourceKey = 'IBM_CCAE'
baseUrl <- Sys.getenv("baseUrl")

# configuration information on WebApi ------------------------------------------
cdmSources <- getCdmSources(baseUrl = baseUrl)
cdmSources

webApiVersion <- getWebApiVersion(baseUrl = baseUrl)
webApiVersion

priorityVocabulary <- getPriorityVocabularyKey(baseUrl = baseUrl)
priorityVocabulary

definitionsMetadata <-
  getDefinitionsMetadata(baseUrl = baseUrl, category = "cohort")

#########################################################################################
# concept set standard --------------------------------------------------------
conceptSet_metaData <-
  getConceptSetDefinitionsMetaData(baseUrl = baseUrl)
conceptSet_isValidId <-
  isValidConceptSetId(conceptSetIds = c(10677, 4242343), baseUrl = baseUrl)
conceptSet_nameExists <-
  existsConceptSetName(conceptSetName = 'Antidepressants other than SSRIs, SNRIs, TCAs,  - OPTIMIZED', baseUrl = baseUrl)
conceptSet_detectByName <-
  detectConceptSetsByName(pattern = '674', baseUrl = baseUrl)
conceptSet_setDefinition <-
  getConceptSetDefinition(conceptSetId = 10677, baseUrl = baseUrl)
postConceptSet <-
  postConceptSetDefinition(
    name = paste0("this is part of a test and may be deleted ", tempfile() %>% basename()),
    conceptSetDefinition = conceptSet_setDefinition,
    baseUrl = baseUrl
  )
deleteConceptSet <-
  deleteConceptSetDefinition(conceptSetId = postConceptSet$id, baseUrl = baseUrl)
#### concept set custom, i.e. not autogenerated
conceptSet_conceptSetDefinitionAsTable <-
  convertConceptSetDefinitionToTable(conceptSet_setDefinition)
conceptSet_conceptIds <-
  resolveConceptSet(conceptSetDefinition = conceptSet_setDefinition, baseUrl = baseUrl)
conceptSet_concepts <-
  getConcepts(conceptIds = conceptSet_conceptIds, baseUrl = baseUrl)
conceptSet_sourceConcepts <-
  getSourceConcepts(conceptIds = conceptSet_conceptIds, baseUrl = baseUrl)
createConceptSetWorkbook(
  conceptSetIds = c(124, 125),
  fileName = "c:/temp/workbook.xlsx",
  baseUrl = baseUrl,
  included = TRUE,
  mapped = TRUE
)

# cohort -------------------------------------------------
cohort_metaData <- getCohortDefinitionsMetaData(baseUrl = baseUrl)
cohort_isValidId <-
  isValidCohortId(cohortIds = c(15997, 4242343), baseUrl = baseUrl)
cohort_nameExists <-
  existsCohortName(cohortName = '[460] Arthropathy of pelvis', baseUrl = baseUrl)
cohort_nameExists2 <-
  existsCohortName(cohortName = 'fdsdsfsdfdsfsdfsdweqjhjiu', baseUrl = baseUrl)
cohort_detectByName <-
  detectCohortsByName(pattern = '674', baseUrl = baseUrl)
cohort_definition <-
  getCohortDefinition(cohortId = 15997, baseUrl = baseUrl)
invokeCohort <-
  invokeCohortGeneration(baseUrl = baseUrl,
                         sourceKey = 'IBM_MDCR',
                         cohortId = 15665)
stopGenerationCohort <-
  ROhdsiWebApi::cancelCohortGeneration(baseUrl = baseUrl,
                                       cohortId = 15665,
                                       sourceKey = 'IBM_MDCR')
cohortGenerationInformation1 <-
  getCohortGenerationInformation(cohortId = 15665, baseUrl = baseUrl)
cohortGenerationInformation2 <-
  getCohortGenerationInformation(cohortId = 10891, baseUrl = baseUrl)
cohortResults <-
  getCohortResults(cohortId = 10891, baseUrl = baseUrl)
cohortResults2 <-
  getResults(id = 10891,
             baseUrl = baseUrl,
             category = 'cohort')
postCohort <-
  postCohortDefinition(
    name = paste0("this is part of a test and may be deleted ", tempfile() %>% basename()),
    CohortDefinition = cohort_definition,
    baseUrl = baseUrl
  )
deleteCohort <-
  deleteCohortDefinition(cohortId = 16623, baseUrl = baseUrl)
sql <-
  getCohortSql(cohortDefinition = cohort_definition, baseUrl = baseUrl)
#### cohort custom, i.e. not autogenerated
insertCohort <-
  insertCohortDefinitionInPackage(cohortId = 15997,
                                  name = "Covid19",
                                  baseUrl = baseUrl)
# insertCohortDefinitionSetInPackage

# characterization -----------------------------------------------
characterization_metaData <-
  getCharacterizationDefinitionsMetaData(baseUrl = baseUrl)
characterization_isValidId <-
  isValidCharacterizationId(characterizationIds = c(927, 4242343),
                            baseUrl = baseUrl)
characterization_nameExists <-
  existsCharacterizationName(characterizationName = '[RWE CTF] 40411813EPY2001 exploration of focal onset epilepsy - diagnosis recorded twice', baseUrl = baseUrl)
characterization_nameExists2 <-
  existsCharacterizationName(characterizationName = 'fdsdsfsdfdsfsdfsdweqjhjiu', baseUrl = baseUrl)
characterization_detectByName <-
  detectCharacterizationsByName(pattern = '674', baseUrl = baseUrl)
characterizationDefinition <-
  getCharacterizationDefinition(characterizationId = 927, baseUrl = baseUrl)
deleteCharacteriation <-
  deleteCharacterizationDefinition(characterizationId = 929, baseUrl = baseUrl)
invokeCharacterization <-
  invokeCharacterizationGeneration(
    characterizationId = 927,
    baseUrl = baseUrl,
    sourceKey = 'IBM_CCAE'
  )
stopGenerationCharacterization <-
  ROhdsiWebApi::cancelCharacterizationGeneration(
    baseUrl = baseUrl,
    characterizationId = 927,
    sourceKey = 'IBM_CCAE'
  )
characterizationGenerationInformation <-
  getCharacterizationGenerationInformation(characterizationId = 927, baseUrl = baseUrl)
characterizationGenerationInformation2 <-
  getCharacterizationGenerationInformation(characterizationId = 36, baseUrl = baseUrl)
characterizationResults <-
  getCharacterizationResults(characterizationId = 36, baseUrl = baseUrl)
characterizationResults2 <-
  getResults(id = 36,
             baseUrl = baseUrl,
             category = 'characterization')
# post



# incidence rate -------------------------------------------------------------
incidenceRate_metaData <-
  getIncidenceRateDefinitionsMetaData(baseUrl = baseUrl)
incidenceRate_isValidId <-
  isValidIncidenceRateId(incidenceRateIds = c(447, 4242343),
                         baseUrl = baseUrl)
incidenceRate_nameExists <-
  existsIncidenceRateName(incidenceRateName = '[EPI775] IR check', baseUrl = baseUrl)
incidenceRate_nameExists2 <-
  existsIncidenceRateName(incidenceRateName = 'fdsdsfsdfdsfsdfsdweqjhjiu', baseUrl = baseUrl)
incidenceRateDefinition <-
  getIncidenceRateDefinition(incidenceRateId = 447,
                             baseUrl = baseUrl)
incidenceRateDefinition2 <-
  getIncidenceRateDefinition(baseUrl = baseUrl, incidenceRateId = 4242343)
cohortDefinitionIr <-
  incidenceRateDefinition$expression$targetCohorts[[1]]$expression
invokeIncidenceRate <-
  invokeIncidenceRateGeneration(incidenceRateId = 447,
                                baseUrl = baseUrl,
                                sourceKey = 'IBM_CCAE')
stopGenerationIncidenceRate <-
  ROhdsiWebApi::cancelIncidenceRateGeneration(baseUrl = baseUrl,
                                              incidenceRateId = 447,
                                              sourceKey = 'IBM_CCAE')
incidenceRateGenerationInformation <-
  getIncidenceRateGenerationInformation(baseUrl = baseUrl, incidenceRateId = 447)
deleteIncidenceRate <-
  deleteIncidenceRateDefinition(baseUrl = baseUrl, incidenceRateId = 454)
incidenceRateresults <-
  getIncidenceRateResults(incidenceRateId = 447, baseUrl = baseUrl)
incidenceRateresults2 <-
  getResults(id = 447,
             baseUrl = baseUrl,
             category = 'incidenceRate')
getIncidenceSql <-
  getIncidenceRateSql(incidenceRateDefinition = incidenceRateDefinition, baseUrl = baseUrl)
# post


# pathway -------------------------------------------------------------
Pathway_metaData <- getPathwayDefinitionsMetaData(baseUrl = baseUrl)
Pathway_isValid <-
  isValidPathwayId(pathwayIds = c(129, 4242343), baseUrl = baseUrl)
Pathway_nameExists <-
  existsPathwayName(pathwayName = 'MDSI pathway', baseUrl = baseUrl)
Pathway_nameExists2 <-
  existsPathwayName(pathwayName = 'fdsdsfsdfdsfsdfsdweqjhjiu', baseUrl = baseUrl)
pathwayDefinition <-
  getPathwayDefinition(baseUrl = baseUrl, pathwayId = 129)
pathwayGenerationInformation <-
  ROhdsiWebApi::getPathwayGenerationInformation(baseUrl = baseUrl, pathwayId = 129)
deletePathway <-
  ROhdsiWebApi::deletePathwayDefinition(baseUrl = baseUrl, pathwayId = 130)
invokePathway <-
  ROhdsiWebApi::invokePathwayGeneration(baseUrl = baseUrl,
                                        pathwayId = 131,
                                        sourceKey = 'IBM_CCAE')
stopGenerationPathway <-
  ROhdsiWebApi::cancelPathwayGeneration(baseUrl = baseUrl,
                                        pathwayId = 131,
                                        sourceKey = 'IBM_CCAE')
pathwayResults <-
  getPathwayResults(pathwayId = 129, baseUrl = baseUrl)
pathwayResults2 <-
  getResults(id = 129,
             baseUrl = baseUrl,
             category = 'pathway')
# post



# estimation ------------------------------------------------------------
estimation_metaData <-
  getEstimationDefinitionsMetaData(baseUrl = baseUrl)
estimation_isValid <-
  isValidEstimationId(estimationIds = c(1, 4242343), baseUrl = baseUrl)
estimation_nameExists <-
  existsEstimationName(estimationName = 'OHDSI Video Estimation', baseUrl = baseUrl)
estimation_nameExists2 <-
  existsEstimationName(estimationName = 'fdsdsfsdfdsfsdfsdweqjhjiu', baseUrl = baseUrl)
estimationDefinition <-
  getEstimationDefinition(baseUrl = baseUrl, estimationId = 1)
estimationDefDelete <-
  deleteEstimationDefinition(baseUrl = baseUrl, estimationId = 147)
# post


# prediction ------------------------------------------------------------
prediction_metaData <-
  getPredictionDefinitionsMetaData(baseUrl = baseUrl)
prediction_isValid <-
  isValidPredictionId(predictionIds = c(2, 4242343), baseUrl = baseUrl)
prediction_nameExists <-
  existsPredictionName(predictionName = 'OHDSI Video PLP', baseUrl = baseUrl)
prediction_nameExists2 <-
  existsPredictionName(predictionName = 'fdsdsfsdfdsfsdfsdweqjhjiu', baseUrl = baseUrl)
predictionDefinition <-
  getPredictionDefinition(baseUrl = baseUrl, predictionId = 1)
predictionDefDelete <-
  deletePredictionDefinition(baseUrl = baseUrl, predictionId = 182)
# post
OHDSI/ROhdsiWebApi documentation built on March 15, 2023, 1:23 p.m.