|
@@ -494,12 +494,14 @@ type gzjhyz struct {
|
494
|
494
|
UTime string `json:"u_time"`
|
495
|
495
|
}
|
496
|
496
|
|
497
|
|
-func GetGzjhYz(sync_time string, his_user_id string) (str gzjhResult, checkStr string) {
|
|
497
|
+func GetGzjhYz(sync_time int64, his_user_id string) (str gzjhResult, checkStr string) {
|
498
|
498
|
apiurl := "http://219.135.166.106:8067/WebService.asmx/queryyzxx"
|
499
|
|
- rep := httplib.Post(apiurl)
|
500
|
|
- rep.Param("sync_time", sync_time)
|
501
|
|
- rep.Param("access_token", "")
|
|
499
|
+ rep := httplib.Get(apiurl)
|
|
500
|
+ rep.Param("sync_time", strconv.FormatInt(sync_time,10))
|
|
501
|
+ rep.Param("access_token","0")
|
502
|
502
|
rep.Param("his_user_id", his_user_id)
|
|
503
|
+ utils.InfoLog(strconv.FormatInt(sync_time,10))
|
|
504
|
+ utils.InfoLog(his_user_id)
|
503
|
505
|
// str, _ := rep.String()
|
504
|
506
|
xmlKey := XmlKey{}
|
505
|
507
|
rep.ToXML(&xmlKey)
|
|
@@ -522,38 +524,41 @@ func GetAdviceBySyncAdviceId(orgId int64, sync_advice_id int64) (advice models.X
|
522
|
524
|
// 广州暨华透析中心医嘱同步
|
523
|
525
|
func SyncGzjhyz() (err error) {
|
524
|
526
|
// 第一步:获取上次同步时间
|
525
|
|
- org_id := int64(10016)
|
|
527
|
+ org_id := int64(10015)
|
526
|
528
|
|
527
|
529
|
redisClient := RedisClient()
|
528
|
530
|
defer redisClient.Close()
|
529
|
|
- sync_time, _ := redisClient.Get("gdjh_sync_time").Result()
|
530
|
|
- if len(sync_time) == 0 {
|
531
|
|
- sync_time = time.Now().Format("2006010215:04:05")
|
|
531
|
+ sync_time_tt, _ := redisClient.Get(redisClient.Context(),"gdjh_sync_time").Result()
|
|
532
|
+
|
|
533
|
+ sync_time,_ := strconv.ParseInt(sync_time_tt,10,64)
|
|
534
|
+ if sync_time == 0 {
|
|
535
|
+ sync_time = time.Now().Unix()
|
532
|
536
|
}
|
533
|
|
- new_sync_time := time.Now().Format("2006010215:04:05")
|
|
537
|
+ new_sync_time := time.Now().Unix()
|
534
|
538
|
utils.InfoLog("new_sync_time:%v", new_sync_time)
|
535
|
539
|
// 切换为当前时间
|
536
|
|
- redisClient.Set("gdjh_sync_time", new_sync_time, time.Minute*60*24)
|
|
540
|
+ redisClient.Set(redisClient.Context(),"gdjh_sync_time", new_sync_time, time.Minute*60*24)
|
537
|
541
|
// 第二步: 获取当天排班患者的住院号
|
538
|
542
|
schedulesDateStr := time.Now().Format("2006-01-02")
|
539
|
543
|
schedulesDate, _ := utils.ParseTimeStringToTime("2006-01-02", schedulesDateStr)
|
540
|
544
|
schedulesTime := schedulesDate.Unix()
|
541
|
|
- patient_zy_ids, _ := redisClient.Get("gdjh_patient_zy_ids").Result()
|
542
|
|
- if len(patient_zy_ids) == 0 {
|
|
545
|
+ var patient_zy_ids string
|
|
546
|
+ // patient_zy_ids, _ := redisClient.Get(redisClient.Context(),"gdjh_patient_zy_ids").Result()
|
|
547
|
+ // if len(patient_zy_ids) == 0 {
|
543
|
548
|
schedules, _ := GetPatientGzjhList(org_id, schedulesTime)
|
544
|
549
|
if len(schedules) > 0 {
|
545
|
550
|
for _, item := range schedules {
|
546
|
|
- if len(item.Patients.AdmissionNumber) > 0 {
|
|
551
|
+ // if len(item.Patients.AdmissionNumber) > 0 {
|
547
|
552
|
if len(patient_zy_ids) == 0 {
|
548
|
|
- patient_zy_ids = item.Patients.IdCardNo + "-" + strconv.FormatInt(item.Patients.ID, 10)
|
|
553
|
+ patient_zy_ids = item.Patients.IdCardNo + "-" + strconv.FormatInt(item.Patients.ID, 10) + "-" + item.Patients.AdmissionNumber
|
549
|
554
|
} else {
|
550
|
|
- patient_zy_ids = patient_zy_ids + "," + item.Patients.IdCardNo + "-" + strconv.FormatInt(item.Patients.ID, 10)
|
|
555
|
+ patient_zy_ids = patient_zy_ids + "," + item.Patients.IdCardNo + "-" + strconv.FormatInt(item.Patients.ID, 10) + "-" + item.Patients.AdmissionNumber
|
551
|
556
|
}
|
552
|
|
- }
|
|
557
|
+ // }
|
553
|
558
|
}
|
554
|
|
- redisClient.Set("gdjh_patient_zy_ids", patient_zy_ids, time.Minute*60*2)
|
|
559
|
+ // redisClient.Set(redisClient.Context(),"gdjh_patient_zy_ids", patient_zy_ids, time.Minute*5)
|
555
|
560
|
}
|
556
|
|
- }
|
|
561
|
+ // }
|
557
|
562
|
utils.InfoLog("2gdjh_patient_zy_ids:%v", patient_zy_ids)
|
558
|
563
|
|
559
|
564
|
// 第三步: 根据获取的同步时间,同步人员,去获取医嘱信息
|
|
@@ -562,7 +567,12 @@ func SyncGzjhyz() (err error) {
|
562
|
567
|
temp_id := strings.Split(idStr, "-")
|
563
|
568
|
id := temp_id[0]
|
564
|
569
|
patient_id := temp_id[1]
|
|
570
|
+ admission_number := temp_id[2]
|
565
|
571
|
gzjhyz, yzstr := GetGzjhYz(sync_time, id)
|
|
572
|
+ if len(gzjhyz.Result) == 0 && len(admission_number) > 0{
|
|
573
|
+ utils.InfoLog("admission_number:%v", admission_number)
|
|
574
|
+ gzjhyz, yzstr = GetGzjhYz(sync_time, admission_number)
|
|
575
|
+ }
|
566
|
576
|
utils.InfoLog("sync_time:%v", sync_time)
|
567
|
577
|
utils.InfoLog("yzstr:%v", yzstr)
|
568
|
578
|
if len(gzjhyz.Result) > 0 {
|
|
@@ -571,12 +581,12 @@ func SyncGzjhyz() (err error) {
|
571
|
581
|
for _, yz := range gzjhyz.Result {
|
572
|
582
|
// 根据姓名获取医生ID
|
573
|
583
|
var doctor_id int64
|
574
|
|
- temp_doctor_id, _ := redisClient.Get("gdjh_doctor_id_" + yz.DoctorId).Result()
|
|
584
|
+ temp_doctor_id, _ := redisClient.Get(redisClient.Context(),"gdjh_doctor_id_" + yz.DoctorId).Result()
|
575
|
585
|
if len(temp_doctor_id) == 0 {
|
576
|
586
|
doctor, _ := GetAdminUserId(org_id, yz.DoctorId)
|
577
|
587
|
doctor_id = doctor.AdminUserId
|
578
|
588
|
if doctor_id > 0 {
|
579
|
|
- redisClient.Set("gdjh_doctor_id_"+yz.DoctorId, doctor_id, time.Minute*60*2)
|
|
589
|
+ redisClient.Set(redisClient.Context(),"gdjh_doctor_id_"+yz.DoctorId, doctor_id, time.Minute*60*2)
|
580
|
590
|
} else {
|
581
|
591
|
continue
|
582
|
592
|
}
|
|
@@ -616,6 +626,11 @@ func SyncGzjhyz() (err error) {
|
616
|
626
|
advice_info, _ := GetAdviceBySyncAdviceId(org_id, yz.AdviceId)
|
617
|
627
|
utils.InfoLog("advice_info:%v", advice_info)
|
618
|
628
|
if advice_info.ID > 0 {
|
|
629
|
+ key := strconv.FormatInt(org_id, 10) + ":" + strconv.FormatInt(temp_patient_id, 10) + ":" + strconv.FormatInt(schedulesTime, 10) + ":doctor_advices"
|
|
630
|
+ //清空key 值
|
|
631
|
+ redisClient.Set(redisClient.Context(),key, "", time.Second)
|
|
632
|
+ keyOne := strconv.FormatInt(org_id, 10) + ":" + strconv.FormatInt(schedulesTime, 10) + ":advice_list_all"
|
|
633
|
+ redisClient.Set(redisClient.Context(),keyOne, "", time.Second)
|
619
|
634
|
continue
|
620
|
635
|
} else {
|
621
|
636
|
if len(yz.AdviceName) > 0 {
|
|
@@ -903,7 +918,7 @@ func SyncHbJldyyz() (err error) {
|
903
|
918
|
|
904
|
919
|
redisClient := RedisClient()
|
905
|
920
|
defer redisClient.Close()
|
906
|
|
- sync_time, _ := redisClient.Get("gdjh_sync_time1").Result()
|
|
921
|
+ sync_time, _ := redisClient.Get(redisClient.Context(),"gdjh_sync_time1").Result()
|
907
|
922
|
if len(sync_time) == 0 {
|
908
|
923
|
sync_time = strconv.FormatInt(time.Now().Unix(), 10)
|
909
|
924
|
utils.InfoLog("sync_time:%v", sync_time)
|
|
@@ -914,12 +929,12 @@ func SyncHbJldyyz() (err error) {
|
914
|
929
|
new_sync_time := time.Now().Unix()
|
915
|
930
|
utils.InfoLog("new_sync_time:%v", new_sync_time)
|
916
|
931
|
// 切换为当前时间
|
917
|
|
- redisClient.Set("gdjh_sync_time", new_sync_time, time.Minute*60*24)
|
|
932
|
+ redisClient.Set(redisClient.Context(),"gdjh_sync_time", new_sync_time, time.Minute*60*24)
|
918
|
933
|
// 第二步: 获取当天排班患者的住院号
|
919
|
934
|
schedulesDateStr := time.Now().Format("2006-01-02")
|
920
|
935
|
schedulesDate, _ := utils.ParseTimeStringToTime("2006-01-02", schedulesDateStr)
|
921
|
936
|
schedulesTime := schedulesDate.Unix()
|
922
|
|
- patient_zy_ids, _ := redisClient.Get("gdjh_patient_zy_ids").Result()
|
|
937
|
+ patient_zy_ids, _ := redisClient.Get(redisClient.Context(),"gdjh_patient_zy_ids").Result()
|
923
|
938
|
if len(patient_zy_ids) == 0 {
|
924
|
939
|
schedules, _ := GetPatientGzjhList(org_id, schedulesTime)
|
925
|
940
|
if len(schedules) > 0 {
|
|
@@ -930,7 +945,7 @@ func SyncHbJldyyz() (err error) {
|
930
|
945
|
patient_zy_ids = patient_zy_ids + "," + item.Patients.IdCardNo + "-" + strconv.FormatInt(item.Patients.ID, 10)
|
931
|
946
|
}
|
932
|
947
|
}
|
933
|
|
- redisClient.Set("gdjh_patient_zy_ids", patient_zy_ids, time.Minute*60*2)
|
|
948
|
+ redisClient.Set(redisClient.Context(),"gdjh_patient_zy_ids", patient_zy_ids, time.Minute*60*2)
|
934
|
949
|
}
|
935
|
950
|
}
|
936
|
951
|
utils.InfoLog("2gdjh_patient_zy_ids:%v", patient_zy_ids)
|
|
@@ -947,12 +962,12 @@ func SyncHbJldyyz() (err error) {
|
947
|
962
|
utils.InfoLog("yz:%v", yz)
|
948
|
963
|
// 根据姓名获取医生ID
|
949
|
964
|
var doctor_id int64
|
950
|
|
- temp_doctor_id, _ := redisClient.Get("gdjh_doctor_id_" + strconv.FormatInt(yz.DoctorId, 10)).Result()
|
|
965
|
+ temp_doctor_id, _ := redisClient.Get(redisClient.Context(),"gdjh_doctor_id_" + strconv.FormatInt(yz.DoctorId, 10)).Result()
|
951
|
966
|
if len(temp_doctor_id) == 0 {
|
952
|
967
|
doctor, _ := GetAdminUserId(org_id, yz.DoctorName)
|
953
|
968
|
doctor_id = doctor.AdminUserId
|
954
|
969
|
if doctor_id > 0 {
|
955
|
|
- redisClient.Set("gdjh_doctor_id_"+strconv.FormatInt(yz.DoctorId, 10), doctor_id, time.Minute*60*2)
|
|
970
|
+ redisClient.Set(redisClient.Context(),"gdjh_doctor_id_"+strconv.FormatInt(yz.DoctorId, 10), doctor_id, time.Minute*60*2)
|
956
|
971
|
} else {
|
957
|
972
|
continue
|
958
|
973
|
}
|
|
@@ -1051,7 +1066,7 @@ func GethbdyLis(sync_time string, his_user_id string) (str hbdyLisResult, checkS
|
1051
|
1066
|
return checkJSON, strs
|
1052
|
1067
|
}
|
1053
|
1068
|
|
1054
|
|
-// 广州暨华透析中心Lis同步
|
|
1069
|
+// 湖北监利大院透析中心Lis同步
|
1055
|
1070
|
func SyncHbdyLis() (err error) {
|
1056
|
1071
|
org_id := int64(10101)
|
1057
|
1072
|
|