-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.gradle
381 lines (325 loc) · 10.5 KB
/
build.gradle
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
buildscript {
repositories {
mavenLocal()
maven {url 'http://developer.marklogic.com/maven2/'}
jcenter()
}
dependencies {
classpath "com.marklogic:ml-data-hub:5.5.1"
classpath "com.marklogic:marklogic-unit-test-client:1.1.0"
}
}
plugins {
id 'java'
id 'eclipse'
id 'idea'
// Gradle Properties plugin
id 'net.saliman.properties' version '1.4.6'
// Data Hub plugin
id 'com.marklogic.ml-data-hub' version '5.5.1'
//Data services needs these
id 'com.marklogic.ml-development-tools' version '5.4.0'
}
repositories {
maven {url "https://plugins.gradle.org/m2/"}
mavenCentral()
jcenter()
maven {url 'http://developer.marklogic.com/maven2/'}
if (project.hasProperty("testing")) {
mavenLocal()
}
}
configurations {
mlcp
}
dependencies {
mlcp "com.marklogic:mlcp:10.0.6.2"
mlcp files("lib")
}
dependencies {
// Ensures that the marklogic-unit-test modules are loaded into the modules database when the application is deployed
mlBundle "com.marklogic:marklogic-unit-test-modules:1.0.0"
testImplementation "com.marklogic:marklogic-data-hub-junit5:5.5.1"
// Adds logging support for tests
testImplementation "ch.qos.logback:logback-classic:1.2.3"
mlcp "com.marklogic:mlcp:10.0.6.2"
mlcp files("lib")
implementation group: 'ca.uhn.hapi.fhir', name: 'hapi-fhir-base', version: '5.3.3'
implementation group: 'ca.uhn.hapi.fhir', name: 'hapi-fhir-structures-r4', version: '5.3.3'
}
test {
useJUnitPlatform()
}
task resetDBs(type: com.marklogic.gradle.task.ServerEvalTask) {
javascript = 'xdmp.invoke("/envision/system/resetSystem.sjs")'
}
task loadReferenceDataStaging(type: com.marklogic.gradle.task.MlcpTask) {
doFirst {
database = mlStagingDbName
port = mlStagingPort.toInteger()
}
classpath = configurations.mlcp
command = "IMPORT"
args = [
"-input_file_path", "$project.projectDir/src/main/ml-data/referenceData/ValueSets",
"-output_collections", "referenceData",
"-output_permissions", "rest-reader,read,rest-writer,update",
"-document_type", "json",
"-output_uri_replace", ".*src/main/ml-data,''",
"-modules_root", "/",
]
}
task loadMetaDataStaging(type: com.marklogic.gradle.task.MlcpTask) {
doFirst {
database = mlStagingDbName
port = mlStagingPort.toInteger()
}
classpath = configurations.mlcp
command = "IMPORT"
args = [
"-input_file_path", "$project.projectDir/src/main/ml-data/meta",
"-output_collections", "metaData",
"-output_permissions", "raw-data-reader,read,mes-writer,update",
"-document_type", "json",
"-output_uri_replace", ".*src/main/ml-data,''",
"-modules_root", "/",
]
}
task loadMetaDataFinal(type: com.marklogic.gradle.task.MlcpTask) {
doFirst {
database = mlFinalDbName
port = mlFinalPort.toInteger()
}
classpath = configurations.mlcp
command = "IMPORT"
args = [
"-input_file_path", "$project.projectDir/src/main/ml-data/meta",
"-output_collections", "metaData",
"-output_permissions", "raw-data-reader,read,mes-writer,update",
"-document_type", "json",
"-output_uri_replace", ".*src/main/ml-data,''",
"-modules_root", "/",
]
}
mlLoadData.dependsOn loadReferenceDataStaging
// In order to load additional reference and metadata, augment the existing mlLoadData task to look
// in these sub-directories and load them appropriately
mlLoadData.dependsOn loadMetaDataStaging
mlLoadData.dependsOn loadMetaDataFinal
ext.getOntologyLoadArgs = { ttlFile, outputGraph ->
// Get custom assertion failure messages: https://stackoverflow.com/a/51447369
assert 'You must provide a filename to load from.' && !ttlFile.equals('')
assert "Invalid file extension for \"$ttlFile\". Expected \".ttl\" extension." && ttlFile.endsWith('.ttl')
assert 'You must provide a graph name to output into.' && !outputGraph.equals('')
return [
'-input_file_path', ttlFile,
'-output_graph', outputGraph,
'-input_file_type', 'rdf'
]
}
task loadIcd10PcsOntology(type: com.marklogic.gradle.task.MlcpTask) {
def ttlFile = "$project.projectDir/src/main/ml-data/ontologies/ICD10PCS.ttl"
def ttlFileExists = file(ttlFile).exists()
if (!ttlFileExists) {
println "WARNING: Unable to find file \"$ttlFile\". Task `loadIcd10PcsOntology` will be a no-op."
}
onlyIf {
ttlFileExists
}
database = mlFinalDbName
port = mlFinalPort.toInteger()
classpath = configurations.mlcp
command = 'IMPORT'
args = getOntologyLoadArgs(ttlFile, 'icd-10-pcs-ontology')
}
task loadIcd10CmOntology(type: com.marklogic.gradle.task.MlcpTask) {
def ttlFile = "$project.projectDir/src/main/ml-data/ontologies/ICD10CM.ttl"
def ttlFileExists = file(ttlFile).exists()
if (!ttlFileExists) {
println "WARNING: Unable to find file \"$ttlFile\". Task `loadIcd10CmOntology` will be a no-op."
}
onlyIf {
ttlFileExists
}
database = mlFinalDbName
port = mlFinalPort.toInteger()
classpath = configurations.mlcp
command = 'IMPORT'
args = getOntologyLoadArgs(ttlFile, 'icd-10-cm-ontology')
}
task normalizeSnomedCTOntology(type: com.marklogic.gradle.task.ServerEvalTask) {
xquery = 'xdmp:invoke("/lib/transformers/addSkosCoreNotationToSnomedOntology.sjs", (), map:entry("database", xdmp:database("' + mlFinalDbName + '")))'
}
task loadSnomedCTOntology(type: com.marklogic.gradle.task.MlcpTask) {
def ttlFile = "$project.projectDir/src/main/ml-data/ontologies/SNOMED-CT.ttl"
def ttlFileExists = file(ttlFile).exists()
if (!ttlFileExists) {
println "WARNING: Unable to find file \"$ttlFile\". Task `loadSnomedCTOntology` will be a no-op."
}
onlyIf {
ttlFileExists
}
database = mlFinalDbName
port = mlFinalPort.toInteger()
classpath = configurations.mlcp
command = 'IMPORT'
args = getOntologyLoadArgs(ttlFile, 'snomed-ct-ontology')
finalizedBy {
normalizeSnomedCTOntology
}
}
task loadOntologies {
dependsOn loadIcd10PcsOntology
dependsOn loadIcd10CmOntology
dependsOn loadSnomedCTOntology
}
task ingestClaims (type: com.marklogic.gradle.task.RunFlowTask) {
description = "Ingest claims raw data"
flowName = "Claim"
steps = ["1"]
inputFilePath="data/synthea/csv/claims/"
inputFileType="csv"
}
task ingestClaimsSmaller (type: com.marklogic.gradle.task.RunFlowTask) {
description = "Ingest smaller claims raw data"
flowName = "Claim"
steps = ["1"]
inputFilePath="data/synthea/csv/claims-smaller/"
inputFileType="csv"
}
task ingestClaimLines(type: com.marklogic.gradle.task.RunFlowTask) {
description = "Ingest claim transactions raw data"
flowName = "ClaimTransaction"
steps = ["1"]
inputFilePath="data/synthea/csv/claims_transactions/"
inputFileType="csv"
}
task ingestClaimLinesSmaller(type: com.marklogic.gradle.task.RunFlowTask) {
description = "Ingest smaller claim transactions raw data"
flowName = "ClaimTransaction"
steps = ["1"]
inputFilePath="data/synthea/csv/claims_transactions-smaller/"
inputFileType="csv"
}
task ingestPatients (type: com.marklogic.gradle.task.RunFlowTask) {
description = "Ingest patient/member raw data"
flowName = "Patient"
steps = ["1"]
inputFilePath="data/synthea/csv/patients/"
inputFileType="csv"
}
task ingestProviders (type: com.marklogic.gradle.task.RunFlowTask) {
description = "Ingest provider raw data"
flowName = "Provider"
steps = ["1"]
inputFilePath="data/synthea/csv/providers/"
inputFileType="csv"
}
task ingestOrganizations (type: com.marklogic.gradle.task.RunFlowTask) {
description = "Ingest organization raw data"
flowName = "Organization"
steps = ["1"]
inputFilePath="data/synthea/csv/organizations/"
inputFileType="csv"
}
task ingestPayers (type: com.marklogic.gradle.task.RunFlowTask) {
description = "Ingest payer raw data"
flowName = "Payor"
steps = ["1"]
inputFilePath="data/synthea/csv/payers/"
inputFileType="csv"
}
task ingestSanctions (type: com.marklogic.gradle.task.RunFlowTask) {
description = "Ingest practitioner sanctions"
flowName = "Provider"
steps = ["2"]
inputFilePath="data/sanctions/"
inputFileType="xml"
}
task ingest {
dependsOn ingestClaims
dependsOn ingestClaimLines
dependsOn ingestPatients
dependsOn ingestProviders
dependsOn ingestOrganizations
dependsOn ingestPayers
dependsOn ingestSanctions
}
task ingestSmaller {
dependsOn ingestClaimsSmaller
dependsOn ingestClaimLinesSmaller
dependsOn ingestPatients
dependsOn ingestProviders
dependsOn ingestOrganizations
dependsOn ingestPayers
dependsOn ingestSanctions
}
task harmonizePatients (type: com.marklogic.gradle.task.RunFlowTask) {
description = "Harmonize patient data"
flowName = "Patient"
steps = ["2","3","4","5","6"]
}
task harmonizeOrganizations (type: com.marklogic.gradle.task.RunFlowTask) {
description = "Harmonize organization data"
flowName = "Organization"
steps = ["2","3"]
}
task harmonizeProviders (type: com.marklogic.gradle.task.RunFlowTask) {
description = "Harmonize provider data"
flowName = "Provider"
steps = ["3","4","5"]
}
task harmonizeClaims (type: com.marklogic.gradle.task.RunFlowTask) {
description = "Harmonize claim data"
flowName = "Claim"
steps = ["2"]
}
task harmonizeAll {
dependsOn harmonizePatients
dependsOn harmonizeOrganizations
dependsOn harmonizeProviders
dependsOn harmonizeClaims
}
ext.getRedactedExportArgs = { directoryFilter, redactions, outputPath ->
return [
'-mode', 'local',
'-output_file_path', outputPath, // Provided via gradle.properties or gradle-local.properties
'-directory_filter', directoryFilter,
'-redaction', redactions,
'-max_split_size', '17500'
]
}
task exportRedactedPatients (type: com.marklogic.gradle.task.MlcpTask) {
if (patientExportOutputDir.equals('')) {
println "WARNING: No `patientExportOutputDir` configured in gradle properties. Task `exportRedactedPatients` will be a no-op."
}
onlyIf {
!patientExportOutputDir.equals('')
}
doFirst {
database = mlFinalDbName
port = mlFinalPort.toInteger()
}
classpath = configurations.mlcp
command = 'EXPORT'
args = getRedactedExportArgs('/patient/', 'member-redaction', patientExportOutputDir)
}
task exportRedactedClaims (type: com.marklogic.gradle.task.MlcpTask) {
if (claimExportOutputDir.equals('')) {
println "WARNING: No `claimExportOutputDir` configured in gradle properties. Task `exportRedactedClaims` will be a no-op."
}
onlyIf {
!claimExportOutputDir.equals('')
}
doFirst {
database = mlFinalDbName
port = mlFinalPort.toInteger()
}
classpath = configurations.mlcp
command = 'EXPORT'
args = getRedactedExportArgs('/claim/', 'claim-redaction', claimExportOutputDir)
}
task exportRedactedData {
dependsOn exportRedactedPatients
dependsOn exportRedactedClaims
}