forked from ohdsi-studies/ExampleStrategusStudy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DownloadAssets.R
73 lines (65 loc) · 2.32 KB
/
DownloadAssets.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
################################################################################
# INSTRUCTIONS: This script assumes you have cohorts you would like to use in an
# ATLAS instance. It also allows loading concepts to exclude and negative
# control concepts from ATLAS. You will need to update the baseUrl to match
# the settings for your environment.
# ##############################################################################
# remotes::install_github("OHDSI/ROhdsiWebApi")
library(dplyr)
# baseUrl <- "https://atlas-demo.ohdsi.org/WebAPI"
baseUrl <- Sys.getenv("baseUrl")
# Use this if your WebAPI instance has security enabled
ROhdsiWebApi::authorizeWebApi(
baseUrl = baseUrl,
authMethod = "windows"
)
# Download and save the cohort definitions ---------------------------------------------------------
cohortDefinitionSet <- ROhdsiWebApi::exportCohortDefinitionSet(
baseUrl = baseUrl,
cohortIds = c(
19137, # GLP-1
19021, # DPP-4
19022, # Type 2 diabetes
19023, # Acute myocardial infarction inpatient setting
19024, # Acute myocardial infarction any setting
19059 # Diarrhea
),
generateStats = TRUE
)
readr::write_csv(cohortDefinitionSet, "inst/Cohorts.csv")
# Download and save the covariates to exclude ------------------------------------------------------
covariatesToExcludeConceptSet <- ROhdsiWebApi::getConceptSetDefinition(
conceptSetId = 436,
baseUrl = baseUrl
) %>%
ROhdsiWebApi::resolveConceptSet(
baseUrl = baseUrl
) %>%
ROhdsiWebApi::getConcepts(
baseUrl = baseUrl
)
CohortGenerator::writeCsv(
x = covariatesToExcludeConceptSet,
file = "inst/excludedCovariateConcepts.csv",
warnOnFileNameCaseMismatch = F
)
# Download and save the negative control outcomes --------------------------------------------------
negativeControlOutcomeCohortSet <- ROhdsiWebApi::getConceptSetDefinition(
conceptSetId = 9025,
baseUrl = baseUrl
) %>%
ROhdsiWebApi::resolveConceptSet(
baseUrl = baseUrl
) %>%
ROhdsiWebApi::getConcepts(
baseUrl = baseUrl
) %>%
rename(outcomeConceptId = "conceptId",
cohortName = "conceptName") %>%
mutate(cohortId = row_number() + 10000) %>%
select(cohortId, cohortName, outcomeConceptId)
CohortGenerator::writeCsv(
x = negativeControlOutcomeCohortSet,
file = "inst/negativeControlOutcomes.csv",
warnOnFileNameCaseMismatch = F
)