This repository has been archived by the owner on Jul 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathrun.bat
113 lines (81 loc) · 4.59 KB
/
run.bat
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
@REM Copyright 2019 IBM Corp. All Rights Reserved.
@REM
@REM Licensed under the Apache License, Version 2.0 (the "License");
@REM you may not use this file except in compliance with the License.
@REM You may obtain a copy of the License at
@REM
@REM http://www.apache.org/licenses/LICENSE-2.0
@REM
@REM Unless required by applicable law or agreed to in writing, software
@REM distributed under the License is distributed on an "AS IS" BASIS,
@REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@REM See the License for the specific language governing permissions and
@REM limitations under the License.
@REM -----------------------------------------------------------------
@REM Generate patient data using Synthea and load into z/OS databases.
@REM Current directory must be where Synthea is installed.
@REM -----------------------------------------------------------------
@if exist output\csv goto existingOutputERROR
@SETLOCAL
@SET NUMPATIENTS=%1
@SET STATE=%~2
@SET scriptdir=%~dp0
@SET transforms=%scriptdir%sqlite
@SET columndefs=%scriptdir%columndefs
@SET jarfile=%scriptdir%target\loadutils-1.0.jar
@if "%DATABASE_URL%"=="" @set /p DATABASE_URL="Enter database URL: "
@if "%DATABASE_USER%"=="" @set /p DATABASE_USER="Enter database userid: "
@if "%DATABASE_PASSWORD%"=="" @set /p DATABASE_PASSWORD="Enter database password: "
@if "%DATABASE_SCHEMA%"=="" @set /p DATABASE_SCHEMA="Enter database schema name: "
@echo. && @echo %TIME%: Generating data using Synthea && @echo.
call ./gradlew.bat run -Params="[ '-p','%NUMPATIENTS%', '%STATE%' ]"
if not exist output\csv\patients.csv goto syntheaERROR
if not exist output\csv\medications.csv goto syntheaERROR
if not exist output\csv\observations.csv goto syntheaERROR
@echo. && @echo %TIME%: Getting information from z/OS tables && @echo.
java -cp %jarfile% GetDBData output/csv/sh_variables.csv %DATABASE_URL% %DATABASE_USER% %DATABASE_PASSWORD% %DATABASE_SCHEMA%
if not exist output\csv\sh_variables.csv goto getDBDataERROR
@echo. && @echo %TIME%: Transforming csv files && @echo.
sqlite3 < %transforms%\transformPatients.sql
if not exist output\csv\sh_patients.csv goto sqliteERROR
sqlite3 < %transforms%\transformMedications.sql
if not exist output\csv\sh_medications.csv goto sqliteERROR
sqlite3 < %transforms%\transformObservations.sql
if not exist output\csv\sh_observations.csv goto sqliteERROR
sqlite3 < %transforms%\transformConditions.sql
if not exist output\csv\sh_conditions.csv goto sqliteERROR
sqlite3 < %transforms%\createAppointments.sql
if not exist output\csv\sh_appointments.csv goto sqliteERROR
sqlite3 < %transforms%\createUsers.sql
if not exist output\csv\sh_users.csv goto sqliteERROR
@echo. && @echo %TIME%: Loading z/OS tables && @echo.
java -cp %jarfile% ZLoadFile output/csv/sh_patients.csv %columndefs%/sh-patients-csvcolumns.txt %DATABASE_URL% %DATABASE_USER% %DATABASE_PASSWORD% %DATABASE_SCHEMA%.PATIENT
if errorlevel 8 goto zloadERROR
java -cp %jarfile% ZLoadFile output/csv/sh_medications.csv %columndefs%/sh-medications-csvcolumns.txt %DATABASE_URL% %DATABASE_USER% %DATABASE_PASSWORD% %DATABASE_SCHEMA%.MEDICATION
if errorlevel 8 goto zloadERROR
java -cp %jarfile% ZLoadFile output/csv/sh_observations.csv %columndefs%/sh-observations-csvcolumns.txt %DATABASE_URL% %DATABASE_USER% %DATABASE_PASSWORD% %DATABASE_SCHEMA%.OBSERVATIONS
if errorlevel 8 goto zloadERROR
java -cp %jarfile% ZLoadFile output/csv/sh_conditions.csv %columndefs%/sh-conditions-csvcolumns.txt %DATABASE_URL% %DATABASE_USER% %DATABASE_PASSWORD% %DATABASE_SCHEMA%.CONDITIONS
if errorlevel 8 goto zloadERROR
java -cp %jarfile% ZLoadFile output/csv/sh_appointments.csv %columndefs%/sh-appointments-csvcolumns.txt %DATABASE_URL% %DATABASE_USER% %DATABASE_PASSWORD% %DATABASE_SCHEMA%.APPOINTMENTS
if errorlevel 8 goto zloadERROR
java -cp %jarfile% ZLoadFile output/csv/sh_users.csv %columndefs%/sh-users-csvcolumns.txt %DATABASE_URL% %DATABASE_USER% %DATABASE_PASSWORD% %DATABASE_SCHEMA%.USER
if errorlevel 8 goto zloadERROR
@echo. && @echo %TIME%: Finished && @echo.
goto end
:existingOutputERROR
@echo. && echo ERROR: The output/csv folder exists from a previous execution. Please delete or rename it first.
goto end
:syntheaERROR
@echo. && echo ERROR: Synthea run did not create the expected csv files. Check preceding messages.
goto end
:getDBDataERROR
@echo. && echo ERROR: Problem obtaining data from database. Check preceding messages.
goto end
:sqliteERROR
@echo. && echo ERROR: Problem transforming CSV files. Check preceding messages.
goto end
:zloadERROR
@echo. && echo ERROR: Problem loading data to z/OS database. Check preceding messages.
goto end
:end