|
@@ -10,8 +10,8 @@ import (
|
10
|
10
|
"strings"
|
11
|
11
|
)
|
12
|
12
|
|
13
|
|
-func GetSyncTimeByOrgId(org_id int64,sync_type int64) (sync_info models.XTSyncInfo,err error) {
|
14
|
|
- err = readDb.Model(&models.XTSyncInfo{}).Where("org_id = ? and sync_type = ? ", org_id,sync_type).Last(&sync_info).Error
|
|
13
|
+func GetSyncTimeByOrgId(org_id int64, sync_type int64) (sync_info models.XTSyncInfo, err error) {
|
|
14
|
+ err = readDb.Model(&models.XTSyncInfo{}).Where("org_id = ? and sync_type = ? ", org_id, sync_type).Last(&sync_info).Error
|
15
|
15
|
return
|
16
|
16
|
}
|
17
|
17
|
|
|
@@ -25,25 +25,21 @@ func FindDataUploadOrgInfo(org_id int64, module_type int64) (data sz.DataUpload,
|
25
|
25
|
return
|
26
|
26
|
}
|
27
|
27
|
|
28
|
|
-func FindOrgData(org_id int64,sync_time int64) (org models.UserOrg, err error) {
|
29
|
|
- err = readUserDb.Model(&models.UserOrg{}).Where("status = 1 AND id = ? AND ctime > ?", org_id,sync_time).Preload("DeviceNumber", func(db *gorm.DB) *gorm.DB {
|
|
28
|
+func FindOrgData(org_id int64, sync_time int64) (org models.UserOrg, err error) {
|
|
29
|
+ err = readUserDb.Model(&models.UserOrg{}).Where("status = 1 AND id = ? AND ctime > ?", org_id, sync_time).Preload("DeviceNumber", func(db *gorm.DB) *gorm.DB {
|
30
|
30
|
return readDb.Where("status = 1")
|
31
|
31
|
}).Find(&org).Error
|
32
|
32
|
return
|
33
|
33
|
}
|
34
|
34
|
func FindOrgRolesData(org_id int64, lastUploadTime int64, nowTime int64) (role []*models.UserAdminRole, err error) {
|
35
|
35
|
db := readUserDb.Model(&models.UserAdminRole{}).Where("status = 1 AND org_id = ? ", org_id)
|
36
|
|
- if lastUploadTime != 0 && nowTime != 0 {
|
37
|
|
- db.Where("ctime >= ? AND ctime <= ?", lastUploadTime, nowTime)
|
38
|
|
- }
|
|
36
|
+ db.Where("ctime >= ? AND ctime <= ?", lastUploadTime, nowTime)
|
39
|
37
|
err = db.Find(&role).Error
|
40
|
38
|
return
|
41
|
39
|
}
|
42
|
40
|
func FindOrgPatientData(org_id int64, lastUploadTime int64, nowTime int64) (patient []*models.Patients, err error) {
|
43
|
41
|
db := readDb.Model(&models.Patients{}).Where("status = 1 AND user_org_id = ?", org_id)
|
44
|
|
- if lastUploadTime != 0 && nowTime != 0 {
|
45
|
|
- db = db.Where("created_time >= ? AND created_time <= ?", lastUploadTime, nowTime)
|
46
|
|
- }
|
|
42
|
+ db = db.Where("created_time >= ? AND created_time <= ?", lastUploadTime, nowTime)
|
47
|
43
|
err = db.Find(&patient).Error
|
48
|
44
|
|
49
|
45
|
return
|
|
@@ -51,9 +47,7 @@ func FindOrgPatientData(org_id int64, lastUploadTime int64, nowTime int64) (pati
|
51
|
47
|
|
52
|
48
|
func FindOrgPatientOutData(org_id int64, lastUploadTime int64, nowTime int64) (patient []*models.Patients, err error) {
|
53
|
49
|
db := readDb.Model(&models.Patients{}).Where("status = 1 AND user_org_id = ? AND lapseto = 2 ", org_id).Preload("PatientLapseto", "status = 1")
|
54
|
|
- if lastUploadTime != 0 && nowTime != 0 {
|
55
|
|
- db = db.Where("created_time >= ? AND created_time <= ?", lastUploadTime, nowTime)
|
56
|
|
- }
|
|
50
|
+ db = db.Where("created_time >= ? AND created_time <= ?", lastUploadTime, nowTime)
|
57
|
51
|
err = db.Find(&patient).Error
|
58
|
52
|
return
|
59
|
53
|
}
|
|
@@ -70,9 +64,7 @@ func FindOrgScheduleData(org_id int64, lastUploadTime int64, nowTime int64) (sch
|
70
|
64
|
|
71
|
65
|
func FindOrgDialysisPrescriptionData(org_id int64, lastUploadTime int64, nowTime int64) (ps []*models.DialysisPrescription, err error) {
|
72
|
66
|
db := readDb.Model(&models.DialysisPrescription{}).Where("status = 1 AND user_org_id = ?", org_id).Preload("AssessmentBeforeDislysis", "status = 1").Preload("DialysisOrder", "status = 1")
|
73
|
|
- if lastUploadTime != 0 && nowTime != 0 {
|
74
|
|
- db = db.Where("created_time >= ? AND created_time <= ?", lastUploadTime, nowTime)
|
75
|
|
- }
|
|
67
|
+ db = db.Where("created_time >= ? AND created_time <= ?", lastUploadTime, nowTime)
|
76
|
68
|
err = db.Find(&ps).Error
|
77
|
69
|
return
|
78
|
70
|
}
|
|
@@ -80,9 +72,7 @@ func FindOrgDialysisPrescriptionData(org_id int64, lastUploadTime int64, nowTime
|
80
|
72
|
func FindOrgMonitorRecordData(org_id int64, lastUploadTime int64, nowTime int64) (monitor []*models.MonitoringRecord, err error) {
|
81
|
73
|
db := readDb.Model(&models.MonitoringRecord{}).Where("status = 1 AND user_org_id = ?", org_id)
|
82
|
74
|
|
83
|
|
- if lastUploadTime != 0 && nowTime != 0 {
|
84
|
|
- db = db.Where("created_time >= ? AND created_time <= ?", lastUploadTime, nowTime)
|
85
|
|
- }
|
|
75
|
+ db = db.Where("created_time >= ? AND created_time <= ?", lastUploadTime, nowTime)
|
86
|
76
|
err = db.Find(&monitor).Error
|
87
|
77
|
|
88
|
78
|
return
|
|
@@ -98,11 +88,81 @@ func CreateUploadRecord(upload *sz.DataUpload) (err error) {
|
98
|
88
|
return
|
99
|
89
|
}
|
100
|
90
|
|
101
|
|
-func BatchCreateStaffRecord(staffs []*sz.TempHdStaff) (err error) {
|
|
91
|
+func FindOrgDialysisData(org_id int64, lastUploadTime int64, nowTime int64) (ps []*models.VMSchedule, err error) {
|
|
92
|
+ db := readDb.Model(&models.VMSchedule{}).Where("status = 1 AND user_org_id = ? ", org_id).
|
|
93
|
+ Preload("DeviceNumber", "status = 1").
|
|
94
|
+ Preload("VMDialysisPrescription", "status = 1").
|
|
95
|
+ Preload("AssessmentBeforeDislysis", "status = 1").
|
|
96
|
+ Preload("AssessmentAfterDislysis", "status = 1").
|
|
97
|
+ Preload("DialysisOrder", "status = 1").
|
|
98
|
+ Preload("MonitoringRecord", "status = 1")
|
|
99
|
+
|
|
100
|
+ if lastUploadTime != 0 && nowTime != 0 {
|
|
101
|
+ db = db.Where("created_time >= ? AND created_time <= ?", lastUploadTime, nowTime)
|
|
102
|
+ }
|
|
103
|
+ err = db.Find(&ps).Error
|
|
104
|
+ return
|
|
105
|
+}
|
|
106
|
+func FindOrgDeviceZoneRecordData(org_id int64, lastUploadTime int64, nowTime int64) (zone []*models.DeviceZone, err error) {
|
|
107
|
+ db := readDb.Model(&models.DeviceZone{}).Where("status = 1 AND org_id = ?", org_id)
|
|
108
|
+ if lastUploadTime != 0 && nowTime != 0 {
|
|
109
|
+ db = db.Where("ctime >= ? AND ctime <= ?", lastUploadTime, nowTime)
|
|
110
|
+ }
|
|
111
|
+ err = db.Find(&zone).Error
|
|
112
|
+
|
|
113
|
+ return
|
|
114
|
+}
|
|
115
|
+
|
|
116
|
+func FindOrgWaterMachineData(org_id int64, lastUploadTime int64, nowTime int64) (waterMachine []*models.VMDeviceAddmacher, err error) {
|
|
117
|
+
|
|
118
|
+ db := readDb.Model(&models.VMDeviceAddmacher{}).Where("status = 1 AND user_org_id = ?", org_id)
|
|
119
|
+
|
|
120
|
+ db = db.Where("ctime >= ? AND ctime <= ?", lastUploadTime, nowTime)
|
|
121
|
+
|
|
122
|
+ err = db.Find(&waterMachine).Error
|
|
123
|
+
|
|
124
|
+ return
|
|
125
|
+}
|
|
126
|
+
|
|
127
|
+func BatchCreateWMsRecord(wms []*sz.TempHdWm, rdb *gorm.DB) (err error) {
|
|
128
|
+ if len(wms) > 0 {
|
|
129
|
+ utx := rdb.Begin()
|
|
130
|
+ if len(wms) > 0 {
|
|
131
|
+ thisSQL := "INSERT INTO t_hd_wm (HOSPITAL_ID, EQUIPMENT_ID, EQUIPMENT_BRAND, EQUIPMENT_MODEL, ENABLE_TIME,DISCARDED_TIME,EQUIPMENT_TYPE,XGBZ,CREATE_TIME,UPDATE_TIME,SJSCSJ) VALUES "
|
|
132
|
+ insertParams := make([]string, 0)
|
|
133
|
+ insertData := make([]interface{}, 0)
|
|
134
|
+ for _, wm := range wms {
|
|
135
|
+ insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?)")
|
|
136
|
+ insertData = append(insertData, wm.HospitalId)
|
|
137
|
+ insertData = append(insertData, wm.EquipmentId)
|
|
138
|
+ insertData = append(insertData, wm.EquipmentBrand)
|
|
139
|
+ insertData = append(insertData, wm.EquipmentModel)
|
|
140
|
+ insertData = append(insertData, wm.EnableTime)
|
|
141
|
+ insertData = append(insertData, wm.DiscardedTime)
|
|
142
|
+ insertData = append(insertData, wm.EquipmentType)
|
|
143
|
+ insertData = append(insertData, wm.Xgbz)
|
|
144
|
+ insertData = append(insertData, wm.CreateTime)
|
|
145
|
+ insertData = append(insertData, wm.UpdateTime)
|
|
146
|
+ insertData = append(insertData, wm.Sjscsj)
|
|
147
|
+
|
|
148
|
+ }
|
|
149
|
+ thisSQL += strings.Join(insertParams, ", ")
|
|
150
|
+ err = utx.Exec(thisSQL, insertData...).Error
|
|
151
|
+ if err != nil {
|
|
152
|
+ utx.Rollback()
|
|
153
|
+ return
|
|
154
|
+ }
|
|
155
|
+ }
|
|
156
|
+ utx.Commit()
|
|
157
|
+ }
|
|
158
|
+ return
|
|
159
|
+}
|
|
160
|
+
|
|
161
|
+func BatchCreateStaffRecord(staffs []*sz.TempHdStaff, rdb *gorm.DB) (err error) {
|
102
|
162
|
if len(staffs) > 0 {
|
103
|
|
- utx := writeDb.Begin()
|
|
163
|
+ utx := rdb.Begin()
|
104
|
164
|
if len(staffs) > 0 {
|
105
|
|
- thisSQL := "INSERT INTO temp_hd_staff (hospital_id, staff_id, staff_name, position, permanent_type,create_time,update_time,sjscsj,mj) VALUES "
|
|
165
|
+ thisSQL := "INSERT INTO t_hd_staff (HOSPITAL_ID, STAFF_ID, STAFF_NAME, POSITION, PERMANENT_TYPE,CREATE_TIME,UPDATE_TIME,SJSCSJ,MJ) VALUES "
|
106
|
166
|
insertParams := make([]string, 0)
|
107
|
167
|
insertData := make([]interface{}, 0)
|
108
|
168
|
for _, info := range staffs {
|
|
@@ -128,27 +188,241 @@ func BatchCreateStaffRecord(staffs []*sz.TempHdStaff) (err error) {
|
128
|
188
|
}
|
129
|
189
|
return
|
130
|
190
|
}
|
131
|
|
-func FindOrgDialysisData(org_id int64, lastUploadTime int64, nowTime int64) (ps []*models.VMSchedule, err error) {
|
132
|
|
- db := readDb.Model(&models.VMSchedule{}).Where("status = 1 AND user_org_id = ? ", org_id).
|
133
|
|
- Preload("DeviceNumber", "status = 1").
|
134
|
|
- Preload("VMDialysisPrescription", "status = 1").
|
135
|
|
- Preload("AssessmentBeforeDislysis", "status = 1").
|
136
|
|
- Preload("AssessmentAfterDislysis", "status = 1").
|
137
|
|
- Preload("DialysisOrder", "status = 1").
|
138
|
|
- Preload("MonitoringRecord", "status = 1")
|
139
|
191
|
|
140
|
|
- if lastUploadTime != 0 && nowTime != 0 {
|
141
|
|
- db = db.Where("created_time >= ? AND created_time <= ?", lastUploadTime, nowTime)
|
|
192
|
+func BatchCreatePatinet(patients []*sz.TempHdPatient, rdb *gorm.DB) (err error) {
|
|
193
|
+ if len(patients) > 0 {
|
|
194
|
+ utx := rdb.Begin()
|
|
195
|
+ if len(patients) > 0 {
|
|
196
|
+ thisSQL := "INSERT INTO t_hd_patient (HOSPITAL_ID, PATIENT_NK, CARD_NO, CARD_TYPE, ID_NO,ID_TYPE,PATIENT_NAME,GENDER,BORN_DATE,DIAGNOSIS_SUMMARY,IS_CRF,CREATE_TIME,UPDATE_TIME,SJSCSJ,XGBZ) VALUES "
|
|
197
|
+ insertParams := make([]string, 0)
|
|
198
|
+ insertData := make([]interface{}, 0)
|
|
199
|
+ for _, info := range patients {
|
|
200
|
+ insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)")
|
|
201
|
+ insertData = append(insertData, info.HospitalId)
|
|
202
|
+ insertData = append(insertData, info.PatientNk)
|
|
203
|
+ insertData = append(insertData, info.CardNo)
|
|
204
|
+ insertData = append(insertData, info.CardType)
|
|
205
|
+ insertData = append(insertData, info.IdNo)
|
|
206
|
+ insertData = append(insertData, info.IdType)
|
|
207
|
+ insertData = append(insertData, info.PatientName)
|
|
208
|
+ insertData = append(insertData, info.Gender)
|
|
209
|
+ insertData = append(insertData, info.BornDate)
|
|
210
|
+ insertData = append(insertData, info.DiagnosisSummary)
|
|
211
|
+ insertData = append(insertData, info.IsCrf)
|
|
212
|
+ insertData = append(insertData, info.CreatedTime)
|
|
213
|
+ insertData = append(insertData, info.UpdateTime)
|
|
214
|
+ insertData = append(insertData, info.Sjscsj)
|
|
215
|
+ insertData = append(insertData, info.Xgbz)
|
|
216
|
+
|
|
217
|
+ }
|
|
218
|
+ thisSQL += strings.Join(insertParams, ", ")
|
|
219
|
+ err = utx.Exec(thisSQL, insertData...).Error
|
|
220
|
+ if err != nil {
|
|
221
|
+ utx.Rollback()
|
|
222
|
+ return
|
|
223
|
+ }
|
|
224
|
+ }
|
|
225
|
+ utx.Commit()
|
142
|
226
|
}
|
143
|
|
- err = db.Find(&ps).Error
|
144
|
227
|
return
|
145
|
228
|
}
|
146
|
|
-func FindOrgDeviceZoneRecordData(org_id int64, lastUploadTime int64, nowTime int64) (zone []*models.DeviceZone, err error) {
|
147
|
|
- db := readDb.Model(&models.DeviceZone{}).Where("status = 1 AND org_id = ?", org_id)
|
148
|
|
- if lastUploadTime != 0 && nowTime != 0 {
|
149
|
|
- db = db.Where("ctime >= ? AND ctime <= ?", lastUploadTime, nowTime)
|
|
229
|
+
|
|
230
|
+func BatchCreateSchedual(patients []*sz.TempHdShift, rdb *gorm.DB) (err error) {
|
|
231
|
+ if len(patients) > 0 {
|
|
232
|
+ utx := rdb.Begin()
|
|
233
|
+ if len(patients) > 0 {
|
|
234
|
+ thisSQL := "INSERT INTO t_hd_shift (PS_ID, HOSPITAL_ID, PATIENT_NK, SCHEDULE_DATE, SHIFT_TYPE,SICKBED_NO,SCHEDULE_STATUS,CREATE_TIME,SJSCSJ,XGBZ) VALUES "
|
|
235
|
+ insertParams := make([]string, 0)
|
|
236
|
+ insertData := make([]interface{}, 0)
|
|
237
|
+ for _, info := range patients {
|
|
238
|
+ insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?)")
|
|
239
|
+ insertData = append(insertData, info.PsId)
|
|
240
|
+ insertData = append(insertData, info.HospitalId)
|
|
241
|
+ insertData = append(insertData, info.PatientNk)
|
|
242
|
+ insertData = append(insertData, info.ScheduleDate)
|
|
243
|
+ insertData = append(insertData, info.ShiftType)
|
|
244
|
+ insertData = append(insertData, info.SickbedNo)
|
|
245
|
+ insertData = append(insertData, info.ScheduleStatus)
|
|
246
|
+ insertData = append(insertData, info.CreateTime)
|
|
247
|
+ insertData = append(insertData, info.Sjscsj)
|
|
248
|
+ insertData = append(insertData, info.Xgbz)
|
|
249
|
+
|
|
250
|
+ }
|
|
251
|
+ thisSQL += strings.Join(insertParams, ", ")
|
|
252
|
+ err = utx.Exec(thisSQL, insertData...).Error
|
|
253
|
+ if err != nil {
|
|
254
|
+ utx.Rollback()
|
|
255
|
+ return
|
|
256
|
+ }
|
|
257
|
+ }
|
|
258
|
+ utx.Commit()
|
150
|
259
|
}
|
151
|
|
- err = db.Find(&zone).Error
|
|
260
|
+ return
|
|
261
|
+}
|
|
262
|
+
|
|
263
|
+func BatchCreatePs(patients []*sz.TempHdPs, rdb *gorm.DB) (err error) {
|
|
264
|
+ if len(patients) > 0 {
|
|
265
|
+ utx := rdb.Begin()
|
|
266
|
+ if len(patients) > 0 {
|
|
267
|
+ thisSQL := "INSERT INTO t_hd_shift (PRESCRIBE_ID, HOSPITAL_ID, PATIENT_NK, K, CA,NA,DIALYSIS_FREQUENCY,FREQUENCY_UNIT,DIALYSIS_DURATION,HDF,HP,HP_FREQUENCY,HP_FREQUENCY_UNIT,HP_DURATION,HDF_FREQUENCY_UNIT,HDF_FREQUENCY,HDF_DURATION,CREATE_TIME,SJSCSJ,XGBZ) VALUES "
|
|
268
|
+ insertParams := make([]string, 0)
|
|
269
|
+ insertData := make([]interface{}, 0)
|
|
270
|
+ for _, info := range patients {
|
|
271
|
+ insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)")
|
|
272
|
+ insertData = append(insertData, info.PrescribeId)
|
|
273
|
+ insertData = append(insertData, info.HospitalId)
|
|
274
|
+ insertData = append(insertData, info.PatientNk)
|
|
275
|
+ insertData = append(insertData, info.K)
|
|
276
|
+ insertData = append(insertData, info.Ca)
|
|
277
|
+ insertData = append(insertData, info.Na)
|
|
278
|
+ insertData = append(insertData, info.DialysisFrequency)
|
|
279
|
+ insertData = append(insertData, info.FrequencyUnit)
|
|
280
|
+ insertData = append(insertData, info.DialysisDuration)
|
|
281
|
+ insertData = append(insertData, info.Hdf)
|
|
282
|
+ insertData = append(insertData, info.Hp)
|
|
283
|
+ insertData = append(insertData, info.HpFrequency)
|
|
284
|
+ insertData = append(insertData, info.HpFrequencyUnit)
|
|
285
|
+ insertData = append(insertData, info.HpDuration)
|
|
286
|
+ insertData = append(insertData, info.HdfFrequencyUnit)
|
|
287
|
+ insertData = append(insertData, info.HdfFrequency)
|
|
288
|
+ insertData = append(insertData, info.HdfDuration)
|
|
289
|
+ insertData = append(insertData, info.CreateTime)
|
|
290
|
+ insertData = append(insertData, info.Sjscsj)
|
|
291
|
+ insertData = append(insertData, info.Xgbz)
|
|
292
|
+
|
|
293
|
+ }
|
|
294
|
+ thisSQL += strings.Join(insertParams, ", ")
|
|
295
|
+ err = utx.Exec(thisSQL, insertData...).Error
|
|
296
|
+ if err != nil {
|
|
297
|
+ utx.Rollback()
|
|
298
|
+ return
|
|
299
|
+ }
|
|
300
|
+ }
|
|
301
|
+ utx.Commit()
|
|
302
|
+ }
|
|
303
|
+ return
|
|
304
|
+}
|
|
305
|
+
|
|
306
|
+func BatchCreatePsm(psms []*sz.TempHdPsMedicine, rdb *gorm.DB) (err error) {
|
|
307
|
+ if len(psms) > 0 {
|
|
308
|
+ utx := rdb.Begin()
|
|
309
|
+ if len(psms) > 0 {
|
|
310
|
+ thisSQL := "INSERT INTO t_hd_shift (PRESCRIBE_ID, HOSPITAL_ID, MEDICINE_TYPE_ID,MEDICINE_ID,CREATE_TIME,SJSCSJ,XGBZ) VALUES "
|
|
311
|
+ insertParams := make([]string, 0)
|
|
312
|
+ insertData := make([]interface{}, 0)
|
|
313
|
+ for _, psm := range psms {
|
|
314
|
+ insertParams = append(insertParams, "(?,?,?,?,?,?,?)")
|
|
315
|
+ insertData = append(insertData, psm.PrescribeId)
|
|
316
|
+ insertData = append(insertData, psm.HospitalId)
|
|
317
|
+ insertData = append(insertData, psm.MedicineTypeId)
|
|
318
|
+ insertData = append(insertData, psm.MedicineId)
|
|
319
|
+ insertData = append(insertData, psm.CreatedTime)
|
|
320
|
+ insertData = append(insertData, psm.Sjscsj)
|
|
321
|
+ insertData = append(insertData, psm.Xgbz)
|
|
322
|
+
|
|
323
|
+ }
|
|
324
|
+ thisSQL += strings.Join(insertParams, ", ")
|
|
325
|
+ err = utx.Exec(thisSQL, insertData...).Error
|
|
326
|
+ if err != nil {
|
|
327
|
+ utx.Rollback()
|
|
328
|
+ return
|
|
329
|
+ }
|
|
330
|
+ }
|
|
331
|
+ utx.Commit()
|
|
332
|
+ }
|
|
333
|
+ return
|
|
334
|
+}
|
|
335
|
+
|
|
336
|
+func BatchCreatePatientOut(patientOuts []*sz.TempHdPatientOut, rdb *gorm.DB) (err error) {
|
|
337
|
+ if len(patientOuts) > 0 {
|
|
338
|
+ utx := rdb.Begin()
|
|
339
|
+ if len(patientOuts) > 0 {
|
|
340
|
+ thisSQL := "INSERT INTO t_hd_patient_out (HOSPITAL_ID, PATIENT_NK,SEQUELAE_DATE,SEQUELAE_TYPE,CREATE_TIME,SJSCSJ,XGBZ) VALUES "
|
|
341
|
+ insertParams := make([]string, 0)
|
|
342
|
+ insertData := make([]interface{}, 0)
|
|
343
|
+ for _, out := range patientOuts {
|
|
344
|
+ insertParams = append(insertParams, "(?,?,?,?,?,?,?)")
|
|
345
|
+ insertData = append(insertData, out.HospitalId)
|
|
346
|
+ insertData = append(insertData, out.PatientNk)
|
|
347
|
+ insertData = append(insertData, out.SequelaeDate)
|
|
348
|
+ insertData = append(insertData, out.SequelaeType)
|
|
349
|
+ insertData = append(insertData, out.CreateTime)
|
|
350
|
+ insertData = append(insertData, out.Sjscsj)
|
|
351
|
+ insertData = append(insertData, out.Xgbz)
|
|
352
|
+
|
|
353
|
+ }
|
|
354
|
+ thisSQL += strings.Join(insertParams, ", ")
|
|
355
|
+ err = utx.Exec(thisSQL, insertData...).Error
|
|
356
|
+ if err != nil {
|
|
357
|
+ utx.Rollback()
|
|
358
|
+ return
|
|
359
|
+ }
|
|
360
|
+ }
|
|
361
|
+ utx.Commit()
|
|
362
|
+ }
|
|
363
|
+ return
|
|
364
|
+}
|
|
365
|
+
|
|
366
|
+func BatchCreateDoctorsAdvice(advices []*sz.TempHdDoctorsAdvice, rdb *gorm.DB) (err error) {
|
|
367
|
+ if len(advices) > 0 {
|
|
368
|
+ utx := rdb.Begin()
|
|
369
|
+ if len(advices) > 0 {
|
|
370
|
+ thisSQL := "INSERT INTO t_hd_doctors_advice (MEDICAL_ORDER_ID, HOSPITAL_ID,DIALYSIS_ID,ORDER_TYPE,PATIENT_NK,DIALYSIS_DURATION,BLOOD_VOL,CREATE_TIME,SJSCSJ,XGBZ) VALUES "
|
|
371
|
+ insertParams := make([]string, 0)
|
|
372
|
+ insertData := make([]interface{}, 0)
|
|
373
|
+ for _, advice := range advices {
|
|
374
|
+ insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?)")
|
|
375
|
+ insertData = append(insertData, advice.MedicalOrDerId)
|
|
376
|
+ insertData = append(insertData, advice.HospitalId)
|
|
377
|
+ insertData = append(insertData, advice.DialysisId)
|
|
378
|
+ insertData = append(insertData, advice.OrderType)
|
|
379
|
+ insertData = append(insertData, advice.PatientNk)
|
|
380
|
+ insertData = append(insertData, advice.DialysisDuration)
|
|
381
|
+ insertData = append(insertData, advice.BloodVol)
|
|
382
|
+ insertData = append(insertData, advice.CreateTime)
|
|
383
|
+ insertData = append(insertData, advice.Sjscsj)
|
|
384
|
+ insertData = append(insertData, advice.Xgbz)
|
|
385
|
+
|
|
386
|
+ }
|
|
387
|
+ thisSQL += strings.Join(insertParams, ", ")
|
|
388
|
+ err = utx.Exec(thisSQL, insertData...).Error
|
|
389
|
+ if err != nil {
|
|
390
|
+ utx.Rollback()
|
|
391
|
+ return
|
|
392
|
+ }
|
|
393
|
+ }
|
|
394
|
+ utx.Commit()
|
|
395
|
+ }
|
|
396
|
+ return
|
|
397
|
+}
|
152
|
398
|
|
|
399
|
+func BatchCreateMonitor(advices []*sz.TempHdMiddle, rdb *gorm.DB) (err error) {
|
|
400
|
+ if len(advices) > 0 {
|
|
401
|
+ utx := rdb.Begin()
|
|
402
|
+ if len(advices) > 0 {
|
|
403
|
+ thisSQL := "INSERT INTO t_hd_doctors_advice (HOSPITAL_ID, PATIENT_NK,DIALYSIS_ID,MONITOR_TIME,SBP,DBP,CREATE_TIME,SJSCSJ,XGBZ) VALUES "
|
|
404
|
+ insertParams := make([]string, 0)
|
|
405
|
+ insertData := make([]interface{}, 0)
|
|
406
|
+ for _, advice := range advices {
|
|
407
|
+ insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?)")
|
|
408
|
+ insertData = append(insertData, advice.HospitalId)
|
|
409
|
+ insertData = append(insertData, advice.PatientNk)
|
|
410
|
+ insertData = append(insertData, advice.DialysisId)
|
|
411
|
+ insertData = append(insertData, advice.MonitorTime)
|
|
412
|
+ insertData = append(insertData, advice.Sbp)
|
|
413
|
+ insertData = append(insertData, advice.Dbp)
|
|
414
|
+ insertData = append(insertData, advice.CreateTime)
|
|
415
|
+ insertData = append(insertData, advice.Sjscsj)
|
|
416
|
+ insertData = append(insertData, advice.Xgbz)
|
|
417
|
+ }
|
|
418
|
+ thisSQL += strings.Join(insertParams, ", ")
|
|
419
|
+ err = utx.Exec(thisSQL, insertData...).Error
|
|
420
|
+ if err != nil {
|
|
421
|
+ utx.Rollback()
|
|
422
|
+ return
|
|
423
|
+ }
|
|
424
|
+ }
|
|
425
|
+ utx.Commit()
|
|
426
|
+ }
|
153
|
427
|
return
|
154
|
428
|
}
|