|
@@ -40,7 +40,7 @@ func SyncLisLgty() (err error) {
|
40
|
40
|
if inspectionLastInfo.ID > 0 {
|
41
|
41
|
sync_time = inspectionLastInfo.CreatedTime
|
42
|
42
|
} else {
|
43
|
|
- sync_time = 1672502400
|
|
43
|
+ sync_time = 1704038400
|
44
|
44
|
}
|
45
|
45
|
}
|
46
|
46
|
|
|
@@ -170,7 +170,7 @@ func ReportInfoHandle(org_id int64) {
|
170
|
170
|
//return
|
171
|
171
|
}
|
172
|
172
|
report_handle.ReportInfoItemNum = int64(report_info_item_num)
|
173
|
|
- project_id, _ := GetProjectID(org_id, report_handle.Item)
|
|
173
|
+ //project_id, _ := GetProjectID(org_id, report_handle.Item)
|
174
|
174
|
patient, perr := GetUserInfoByAdmission(report_handle.PatientId, org_id)
|
175
|
175
|
if perr != nil {
|
176
|
176
|
utils.ErrorLog("查询病人信息失败:%v", perr)
|
|
@@ -183,8 +183,8 @@ func ReportInfoHandle(org_id int64) {
|
183
|
183
|
continue
|
184
|
184
|
}
|
185
|
185
|
// 获取该小项的检验检查item_id,如果没有,则创建一个
|
186
|
|
- item_id, _ := GetItemID(org_id, report_handle.Item, reportInfo.ItemName, project_id)
|
187
|
|
- _, _, syerr := LgthSync(&report_handle, reportInfo, project_id, item_id, org_id, patient.ID, patient.AdmissionNumber)
|
|
186
|
+ //item_id, _ := GetItemID(org_id, report_handle.Item, reportInfo.ItemName, project_id)
|
|
187
|
+ _, _, syerr := LgthSync(&report_handle, reportInfo, org_id, patient.ID, patient.AdmissionNumber)
|
188
|
188
|
if syerr != nil {
|
189
|
189
|
utils.ErrorLog("创建同步信息失败:%v", syerr)
|
190
|
190
|
return
|
|
@@ -194,7 +194,7 @@ func ReportInfoHandle(org_id int64) {
|
194
|
194
|
}
|
195
|
195
|
}
|
196
|
196
|
}
|
197
|
|
- SyncToLgey()
|
|
197
|
+ //SyncToLgey()
|
198
|
198
|
}
|
199
|
199
|
|
200
|
200
|
func SyncToLgey() {
|
|
@@ -221,10 +221,12 @@ func SyncToLgey() {
|
221
|
221
|
}
|
222
|
222
|
|
223
|
223
|
// 从机构将数据同步到中间库
|
224
|
|
-func LgthSync(Head *models.MiddleReportHandle, report ReportInfo, project_id int64, item_id int64, org_id int64, patient_id int64, his_user_id string) (*models.MiddleInspectionReference, *models.MiddleInspection, error) {
|
|
224
|
+func LgthSync(Head *models.MiddleReportHandle, report ReportInfo, org_id int64, patient_id int64, his_user_id string) (*models.MiddleInspectionReference, *models.MiddleInspection, error) {
|
225
|
225
|
tx := writeMiddleDb.Begin()
|
226
|
226
|
var inspection models.MiddleInspection
|
227
|
227
|
var inspection_reference models.MiddleInspectionReference
|
|
228
|
+ //var project_id int64
|
|
229
|
+ //var item_id int64
|
228
|
230
|
recordDateStr := Head.CheckTime
|
229
|
231
|
utils.InfoLog("打印测试: %v", recordDateStr)
|
230
|
232
|
|
|
@@ -259,21 +261,26 @@ func LgthSync(Head *models.MiddleReportHandle, report ReportInfo, project_id int
|
259
|
261
|
RangeOptions = report.Reference
|
260
|
262
|
}
|
261
|
263
|
|
262
|
|
- err = readMiddleDb.Model(&models.MiddleInspectionReference{}).Where("org_id = ? and project_id = ? and item_id = ? and status = 1", org_id, project_id, item_id).Find(&inspection_reference).Count(&total).Error
|
|
264
|
+ err = readMiddleDb.Model(&models.MiddleInspectionReference{}).Where("org_id = ? and item_name = ? and range_value = ? and status = 1", org_id, report.ItemName, report.Reference).Find(&inspection_reference).Count(&total).Error
|
263
|
265
|
if inspection_reference.ID > 0 {
|
264
|
266
|
ItemType = inspection_reference.RangeType
|
|
267
|
+ //project_id = inspection_reference.ProjectId
|
|
268
|
+ //item_id = inspection_reference.ItemId
|
265
|
269
|
}
|
266
|
270
|
if total <= 0 && len(Head.Item) > 0 {
|
|
271
|
+ projectId, _ := GetProjectID(org_id, Head.Item)
|
|
272
|
+ itemId, _ := GetItemID(org_id, Head.Item, report.ItemName, projectId)
|
|
273
|
+
|
267
|
274
|
inspection_reference.OrgId = org_id
|
268
|
275
|
inspection_reference.ProjectName = Head.Item
|
269
|
276
|
inspection_reference.Project = Head.Item
|
270
|
|
- inspection_reference.ProjectId = project_id
|
|
277
|
+ inspection_reference.ProjectId = projectId
|
271
|
278
|
inspection_reference.ItemName = report.ItemName
|
272
|
|
- inspection_reference.ItemId = item_id
|
|
279
|
+ inspection_reference.ItemId = itemId
|
273
|
280
|
inspection_reference.RangeType = ItemType
|
274
|
281
|
inspection_reference.RangeMin = RangeMin
|
275
|
282
|
inspection_reference.RangeMax = RangeMax
|
276
|
|
- // inspection_reference.RangeValue = RangeValue
|
|
283
|
+ inspection_reference.RangeValue = report.Reference
|
277
|
284
|
inspection_reference.RangeOptions = RangeOptions
|
278
|
285
|
inspection_reference.Unit = report.Unit
|
279
|
286
|
inspection_reference.Status = 1
|
|
@@ -287,15 +294,15 @@ func LgthSync(Head *models.MiddleReportHandle, report ReportInfo, project_id int
|
287
|
294
|
}
|
288
|
295
|
}
|
289
|
296
|
|
290
|
|
- err = readMiddleDb.Model(&models.MiddleInspection{}).Where("org_id = ? and project_id = ? and item_id = ? and record_date = ? and patient_id = ? and status = 1", org_id, project_id, item_id, record_date, patient_id).Find(&inspection).Count(&itotal).Error
|
|
297
|
+ err = readMiddleDb.Model(&models.MiddleInspection{}).Where("org_id = ? and project_id = ? and item_id = ? and record_date = ? and patient_id = ? and status = 1", org_id, inspection_reference.ProjectId, inspection_reference.ItemId, record_date, patient_id).Find(&inspection).Count(&itotal).Error
|
291
|
298
|
if itotal <= 0 {
|
292
|
299
|
inspection.PatientId = patient_id
|
293
|
300
|
inspection.OrgId = org_id
|
294
|
|
- inspection.ProjectId = project_id
|
|
301
|
+ inspection.ProjectId = inspection_reference.ProjectId
|
295
|
302
|
inspection.ItemName = report.ItemName
|
296
|
303
|
inspection.ProjectName = Head.Item
|
297
|
304
|
inspection.InspectType = ItemType
|
298
|
|
- inspection.ItemId = item_id
|
|
305
|
+ inspection.ItemId = inspection_reference.ItemId
|
299
|
306
|
inspection.InspectValue = report.Result
|
300
|
307
|
inspection.InspectDate = inspect_date
|
301
|
308
|
inspection.RecordDate = record_date
|
|
@@ -335,7 +342,7 @@ func LgthSync(Head *models.MiddleReportHandle, report ReportInfo, project_id int
|
335
|
342
|
// 根据机构ID和检验检查小项名称获取该检查的item_id,如没有,则创建一个
|
336
|
343
|
func GetItemID(org_id int64, project_name string, item_name string, project_id int64) (item_id int64, err error) {
|
337
|
344
|
var inspection_reference models.MiddleInspectionReference
|
338
|
|
- err = readMiddleDb.Model(&models.MiddleInspectionReference{}).Where("org_id = ? and status = 1 and project_name = ? and item_name = ?", org_id, project_name, item_name).First(&inspection_reference).Error
|
|
345
|
+ err = readMiddleDb.Model(&models.MiddleInspectionReference{}).Where("org_id = ? and status = 1 and project = ? and item_name = ?", org_id, project_name, item_name).First(&inspection_reference).Error
|
339
|
346
|
if inspection_reference.ID > 0 {
|
340
|
347
|
return inspection_reference.ItemId, err
|
341
|
348
|
} else {
|
|
@@ -352,7 +359,7 @@ func GetItemID(org_id int64, project_name string, item_name string, project_id i
|
352
|
359
|
// 根据机构ID和检验检查名称获取该检查的project_id,如没有,则创建一个
|
353
|
360
|
func GetProjectID(org_id int64, project_name string) (project_id int64, err error) {
|
354
|
361
|
var inspection_reference models.MiddleInspectionReference
|
355
|
|
- err = readMiddleDb.Model(&models.MiddleInspectionReference{}).Where("org_id = ? and status = 1 and project_name = ?", org_id, project_name).First(&inspection_reference).Error
|
|
362
|
+ err = readMiddleDb.Model(&models.MiddleInspectionReference{}).Where("org_id = ? and status = 1 and project = ? ", org_id, project_name).First(&inspection_reference).Error
|
356
|
363
|
if inspection_reference.ID > 0 {
|
357
|
364
|
return inspection_reference.ProjectId, err
|
358
|
365
|
} else {
|