forked from IBM/example-health-synthea
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.sh
152 lines (123 loc) · 5.73 KB
/
run.sh
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
#!/bin/bash
##############################################################################
# Copyright 2019 IBM Corp. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
##############################################################################
# -----------------------------------------------------------------
# Generate patient data using Synthea and load into z/OS databases.
# Current directory must be where Synthea is installed.
# -----------------------------------------------------------------
if [ -d output/csv ]; then
printf "\nERROR: The output/csv folder exists from a previous execution. Please delete or rename it first.\n"
exit 1
fi
NUMPATIENTS=$1
STATE=$2
scriptdir=`dirname ${BASH_SOURCE[0]}`
transforms=$scriptdir/sqlite
columndefs=$scriptdir/columndefs
jarfile=$scriptdir/target/loadutils-1.0.jar
if [ "$DATABASE_URL" = "" ]; then
read -p "Enter database URL: " DATABASE_URL
fi
if [ "$DATABASE_USER" = "" ]; then
read -p "Enter database userid: " DATABASE_USER
fi
if [ "$DATABASE_PASSWORD" = "" ]; then
read -s -p "Enter database password: " DATABASE_PASSWORD
printf "\n"
fi
if [ "$DATABASE_SCHEMA" = "" ]; then
read -p "Enter database schema name: " DATABASE_SCHEMA
fi
now=$(date +"%T")
printf "\n$now: Generating data using Synthea\n"
./gradlew run -Params="[ '-p','$NUMPATIENTS', '$STATE' ]"
if [ ! -f output/csv/patients.csv ] || [ ! -f output/csv/medications.csv ] || [ ! -f output/csv/observations.csv ]; then
printf "\nERROR: Synthea run did not create the expected csv files. Check preceding messages.\n"
exit 1
fi
now=$(date +"%T")
printf "\n$now: Getting information from z/OS tables\n"
java -cp $jarfile GetDBData output/csv/sh_variables.csv $DATABASE_URL $DATABASE_USER $DATABASE_PASSWORD $DATABASE_SCHEMA
if [ ! -f output/csv/sh_variables.csv ]; then
printf "\nERROR: Problem obtaining data from database. Check preceding messages.\n"
exit 1
fi
now=$(date +"%T")
printf "\n$now: Transforming csv files\n"
sqlite3 < $transforms/transformPatients.sql
if [ ! -f output/csv/sh_patients.csv ] || [ ! -s output/csv/sh_patients.csv ]; then
printf "\nERROR: Problem transforming patients CSV file. Check preceding messages.\n"
exit 1
fi
sqlite3 < $transforms/transformMedications.sql
if [ ! -f output/csv/sh_medications.csv ] || [ ! -s output/csv/sh_medications.csv ]; then
printf "\nERROR: Problem transforming medications CSV file. Check preceding messages.\n"
exit 1
fi
sqlite3 < $transforms/transformObservations.sql
if [ ! -f output/csv/sh_observations.csv ] || [ ! -s output/csv/sh_observations.csv ]; then
printf "\nERROR: Problem transforming observations CSV file. Check preceding messages.\n"
exit 1
fi
sqlite3 < $transforms/transformConditions.sql
if [ ! -f output/csv/sh_conditions.csv ] || [ ! -s output/csv/sh_conditions.csv ]; then
printf "\nERROR: Problem transforming conditions CSV file. Check preceding messages.\n"
exit 1
fi
sqlite3 < $transforms/createAppointments.sql
if [ ! -f output/csv/sh_appointments.csv ] || [ ! -s output/csv/sh_appointments.csv ]; then
printf "\nERROR: Problem transforming appointments CSV file. Check preceding messages.\n"
exit 1
fi
sqlite3 < $transforms/createUsers.sql
if [ ! -f output/csv/sh_users.csv ] || [ ! -s output/csv/sh_users.csv ]; then
printf "\nERROR: Problem transforming users CSV file. Check preceding messages.\n"
exit 1
fi
now=$(date +"%T")
printf "\n$now: Loading z/OS tables\n"
java -cp $jarfile ZLoadFile output/csv/sh_patients.csv $columndefs/sh-patients-csvcolumns.txt $DATABASE_URL $DATABASE_USER $DATABASE_PASSWORD $DATABASE_SCHEMA.PATIENT
if [ $? -ge 8 ]; then
printf "\nERROR: Problem loading patient data to z/OS database. Check preceding messages.\n"
exit 1
fi
java -cp $jarfile ZLoadFile output/csv/sh_medications.csv $columndefs/sh-medications-csvcolumns.txt $DATABASE_URL $DATABASE_USER $DATABASE_PASSWORD $DATABASE_SCHEMA.MEDICATION
if [ $? -ge 8 ]; then
printf "\nERROR: Problem loading medications data to z/OS database. Check preceding messages.\n"
exit 1
fi
java -cp $jarfile ZLoadFile output/csv/sh_observations.csv $columndefs/sh-observations-csvcolumns.txt $DATABASE_URL $DATABASE_USER $DATABASE_PASSWORD $DATABASE_SCHEMA.OBSERVATIONS
if [ $? -ge 8 ]; then
printf "\nERROR: Problem loading observations data to z/OS database. Check preceding messages.\n"
exit 1
fi
java -cp $jarfile ZLoadFile output/csv/sh_conditions.csv $columndefs/sh-conditions-csvcolumns.txt $DATABASE_URL $DATABASE_USER $DATABASE_PASSWORD $DATABASE_SCHEMA.CONDITIONS
if [ $? -ge 8 ]; then
printf "\nERROR: Problem loading conditions data to z/OS database. Check preceding messages.\n"
exit 1
fi
java -cp $jarfile ZLoadFile output/csv/sh_appointments.csv $columndefs/sh-appointments-csvcolumns.txt $DATABASE_URL $DATABASE_USER $DATABASE_PASSWORD $DATABASE_SCHEMA.APPOINTMENTS
if [ $? -ge 8 ]; then
printf "\nERROR: Problem loading appointments data to z/OS database. Check preceding messages.\n"
exit 1
fi
java -cp $jarfile ZLoadFile output/csv/sh_users.csv $columndefs/sh-users-csvcolumns.txt $DATABASE_URL $DATABASE_USER $DATABASE_PASSWORD $DATABASE_SCHEMA.USER
if [ $? -ge 8 ]; then
printf "\nERROR: Problem loading users data to z/OS database. Check preceding messages.\n"
exit 1
fi
now=$(date +"%T")
printf "\n$now: Finished\n"