Browse Source

no message

张保健 3 years ago
parent
commit
405d5f1c2b

+ 41 - 41
controllers/sync.go View File

@@ -58,49 +58,49 @@ func (c *SyncController) SyncToLg2h() {
58 58
 			}
59 59
 			// 第三步:开始同步数据
60 60
 			// 同步医院信息  t_hd_hospital
61
-			city.SyncHospital(orgDb, org.OrgId, org.HospitalId, org.InstType, org.DepartmentName)
62
-			// 同步水处理器  t_hd_wm
63
-			city.SyncWMS(orgDb, org.OrgId, org.HospitalId)
64
-			// // 同步员工 t_hd_staff
65
-			city.SyncStaff(orgDb, org.OrgId, org.HospitalId)
66
-			// // 同步病人 t_hd_patient
67
-			city.SyncPatient(orgDb, org.OrgId, org.HospitalId)
68
-			// // 同步排班  t_hd_shift
69
-			city.SyncShift(orgDb, org.OrgId, org.HospitalId)
70
-			// 同步处方 t_hd_ps
71
-			city.SyncPs(orgDb, org.OrgId, org.HospitalId)
72
-			// 同步处方药品 t_hd_ps
73
-			city.SyncPsMedicine(orgDb, org.OrgId, org.HospitalId)
74
-			// // 同步转院信息 t_hd_patient_out
75
-			city.SyncPatientOut(orgDb, org.OrgId, org.HospitalId)
76
-			// 同步处方信息 t_hd_doctors_advice
77
-			city.SyncDoctorAdvice(orgDb, org.OrgId, org.HospitalId)
78
-			// 同步透中信息 t_hd_middle
79
-			city.SyncMiddle(orgDb, org.OrgId, org.HospitalId)
80
-			// // 同步设备 t_hd_other_machine
81
-			city.SyncOtherMachine(orgDb, org.OrgId, org.HospitalId)
82
-			// // 同步维修 t_hd_maintain
83
-			city.SyncMachineRepair(orgDb, org.OrgId, org.HospitalId)
84
-			// // 同步设备 t_hd_dm
85
-			city.SyncDM(orgDb, org.OrgId, org.HospitalId)
86
-			// // 同步患者透析记录 t_hd_dialysis
87
-			city.SyncDialysis(orgDb, org.OrgId, org.HospitalId)
88
-			// 同步透析床位分区 t_hd_division
89
-			city.SyncDivision(orgDb, org.OrgId, org.HospitalId)
90
-			// 患者通路信息表(T_HD_ACCESS)
91
-			city.SyncAccess(orgDb, org.OrgId, org.HospitalId)
92
-			// 透析床位表(T_HD_SICKBED)
93
-			city.SyncSickbed(orgDb, org.OrgId, org.HospitalId)
94
-			// 患者诊断信息表(T_HD_DIAGNOSIS)
95
-			city.SyncDiagnosis(orgDb, org.OrgId, org.HospitalId)
61
+			// city.SyncHospital(orgDb, org.OrgId, org.HospitalId, org.InstType, org.DepartmentName)
62
+			// // 同步水处理器  t_hd_wm
63
+			// city.SyncWMS(orgDb, org.OrgId, org.HospitalId)
64
+			// // // 同步员工 t_hd_staff
65
+			// city.SyncStaff(orgDb, org.OrgId, org.HospitalId)
66
+			// // // 同步病人 t_hd_patient
67
+			// city.SyncPatient(orgDb, org.OrgId, org.HospitalId)
68
+			// // // 同步排班  t_hd_shift
69
+			// city.SyncShift(orgDb, org.OrgId, org.HospitalId)
70
+			// // 同步处方 t_hd_ps
71
+			// city.SyncPs(orgDb, org.OrgId, org.HospitalId)
72
+			// // 同步处方药品 t_hd_ps
73
+			// city.SyncPsMedicine(orgDb, org.OrgId, org.HospitalId)
74
+			// // // 同步转院信息 t_hd_patient_out
75
+			// city.SyncPatientOut(orgDb, org.OrgId, org.HospitalId)
76
+			// // 同步处方信息 t_hd_doctors_advice
77
+			// city.SyncDoctorAdvice(orgDb, org.OrgId, org.HospitalId)
78
+			// // 同步透中信息 t_hd_middle
79
+			// city.SyncMiddle(orgDb, org.OrgId, org.HospitalId)
80
+			// // // 同步设备 t_hd_other_machine
81
+			// city.SyncOtherMachine(orgDb, org.OrgId, org.HospitalId)
82
+			// // // 同步维修 t_hd_maintain
83
+			// city.SyncMachineRepair(orgDb, org.OrgId, org.HospitalId)
84
+			// // // 同步设备 t_hd_dm
85
+			// city.SyncDM(orgDb, org.OrgId, org.HospitalId)
86
+			// // // 同步患者透析记录 t_hd_dialysis
87
+			// city.SyncDialysis(orgDb, org.OrgId, org.HospitalId)
88
+			// // 同步透析床位分区 t_hd_division
89
+			// city.SyncDivision(orgDb, org.OrgId, org.HospitalId)
90
+			// // 患者通路信息表(T_HD_ACCESS)
91
+			// city.SyncAccess(orgDb, org.OrgId, org.HospitalId)
92
+			// // 透析床位表(T_HD_SICKBED)
93
+			// city.SyncSickbed(orgDb, org.OrgId, org.HospitalId)
94
+			// // 患者诊断信息表(T_HD_DIAGNOSIS)
95
+			// city.SyncDiagnosis(orgDb, org.OrgId, org.HospitalId)
96 96
 			//  患者传染病检查记录表(T_HD_INFECTION
97 97
 			city.SyncInfection(orgDb, org.OrgId, org.HospitalId)
98
-			//  透析并发症记录表(T_HD_COMPLICATION)
99
-			city.SyncComplication(orgDb, org.OrgId, org.HospitalId)
100
-			//  血透患者检测结果表(T_HD_LIS_REPORT)
101
-			city.SyncLisReport(orgDb, org.OrgId, org.HospitalId)
102
-			//  血透患者检验结果指标表(T_HD_LIS_INDICATORS)
103
-			city.SyncLisIndicators(orgDb, org.OrgId, org.HospitalId)
98
+			// //  透析并发症记录表(T_HD_COMPLICATION)
99
+			// city.SyncComplication(orgDb, org.OrgId, org.HospitalId)
100
+			// //  血透患者检测结果表(T_HD_LIS_REPORT)
101
+			// city.SyncLisReport(orgDb, org.OrgId, org.HospitalId)
102
+			// //  血透患者检验结果指标表(T_HD_LIS_INDICATORS)
103
+			// city.SyncLisIndicators(orgDb, org.OrgId, org.HospitalId)
104 104
 
105 105
 			// 第四步:关闭数据库连接
106 106
 			service.CloseDB(orgDb)

+ 100 - 35
service/city/auto_create_week_schedules_service.go View File

@@ -1489,45 +1489,110 @@ func SyncInfection(rdb *gorm.DB, org_id int64, hospital_id string) {
1489 1489
 	}
1490 1490
 
1491 1491
 	//同步患者
1492
-	patients, _ := service.FindOrgPatientInfectious(org_id, sync_time, time.Now().Unix())
1492
+	patients, _ := service.FindOrgPatientDataOne(org_id)
1493 1493
 	var infectionList []*sz.TempHdInfection
1494 1494
 	for _, patient := range patients {
1495
-		if len(patient.InfectiousDiseases) > 0 {
1496
-			infection := &sz.TempHdInfection{
1497
-				Sn : strconv.FormatInt(patient.ID,10),
1498
-				HospitalId: hospital_id,
1499
-				PatientNk:  strconv.FormatInt(patient.ID, 10),
1500
-				Hbv: 0,
1501
-				Hcv: 0,
1502
-				Rpr: 0,
1503
-				Hiv: 0,
1504
-				Hbsag:	9,
1505
-				Hbsab: 9,
1506
-				Hbeag: 9,
1507
-				Hbeab: 9,
1508
-				Hbcab: 9,
1509
-				CheckDate: time.Unix(patient.CreatedTime, 0),
1510
-				DoctorId: strconv.FormatInt(patient.RegistrarsId,10),
1511
-				CreateTime:     time.Now(),
1512
-				Sjscsj:         time.Now(),
1513
-				Xgbz:           0,
1514
-			}
1515
-			
1516
-			for _ , infectionDiseases := range patient.InfectiousDiseases{
1517
-				if infectionDiseases.DiseaseId == 2 {
1518
-					infection.Hbv = 1
1519
-				}
1520
-				if infectionDiseases.DiseaseId == 3 {
1521
-					infection.Hcv = 1
1522
-				}
1523
-				if infectionDiseases.DiseaseId == 4 {
1524
-					infection.Hiv = 1
1525
-				}
1526
-				if infectionDiseases.DiseaseId == 6 {
1527
-					infection.Rpr = 1
1495
+		//	查询有没有做传染病检查并返回检验检查时间
1496
+		inspections, _ := service.FindOrgInspectionGroupOne(org_id, sync_time, time.Now().Unix(),patient.ID)
1497
+		if len(inspections) > 0 {
1498
+			for _, insp := range inspections {
1499
+				inspection_arr ,_:= service.FindOrgInspectionGroupTwo(org_id,insp.InspectDate,patient.ID)
1500
+				if len(inspection_arr) > 0 {
1501
+					infection := &sz.TempHdInfection{
1502
+						Sn : strconv.FormatInt(patient.ID,10),
1503
+						HospitalId: hospital_id,
1504
+						PatientNk:  strconv.FormatInt(patient.ID, 10),
1505
+						Hbv: 0,
1506
+						Hcv: 0,
1507
+						Rpr: 0,
1508
+						Hiv: 0,
1509
+						Hbsag:	9,
1510
+						Hbsab: 9,
1511
+						Hbeag: 9,
1512
+						Hbeab: 9,
1513
+						Hbcab: 9,
1514
+						CheckDate: time.Unix(patient.CreatedTime, 0),
1515
+						DoctorId: strconv.FormatInt(patient.RegistrarsId,10),
1516
+						CreateTime:     time.Now(),
1517
+						Sjscsj:         time.Now(),
1518
+						Xgbz:           0,
1519
+					}
1520
+
1521
+					
1522
+					for _ , infectionDiseases := range inspection_arr{
1523
+						if infectionDiseases.ItemId == 60 {
1524
+							infection.Hcv = 0 
1525
+							if infectionDiseases.InspectValue == "阳性" {
1526
+								infection.Hcv = 1 
1527
+							}
1528
+						}
1529
+						if infectionDiseases.ItemId == 62 {
1530
+							infection.Hbsag = 0 
1531
+							if infectionDiseases.InspectValue == "阳性" {
1532
+								infection.Hbsag = 1 
1533
+							}
1534
+						}
1535
+
1536
+						if infectionDiseases.ItemId == 63 {
1537
+							infection.Hbsab = 0 
1538
+							if infectionDiseases.InspectValue == "阳性" {
1539
+								infection.Hbsab = 1 
1540
+							}
1541
+						}
1542
+
1543
+						if infectionDiseases.ItemId == 64 {
1544
+							infection.Hbeag = 0 
1545
+							if infectionDiseases.InspectValue == "阳性" {
1546
+								infection.Hbeag = 1 
1547
+							}
1548
+						}
1549
+
1550
+						if infectionDiseases.ItemId == 65 {
1551
+							infection.Hbeab = 0 
1552
+							if infectionDiseases.InspectValue == "阳性" {
1553
+								infection.Hbeab = 1 
1554
+							}
1555
+						}
1556
+
1557
+						if infectionDiseases.ItemId == 66 {
1558
+							infection.Hbcab = 0 
1559
+							if infectionDiseases.InspectValue == "阳性" {
1560
+								infection.Hbcab = 1 
1561
+							}
1562
+						}
1563
+
1564
+						if infectionDiseases.ItemId == 111 {
1565
+							infection.Hiv = 0 
1566
+							if infectionDiseases.InspectValue == "阳性" {
1567
+								infection.Hiv = 1 
1568
+							}
1569
+						}
1570
+
1571
+						if infectionDiseases.ItemId == 112 {
1572
+							infection.Rpr = 0 
1573
+							if infectionDiseases.InspectValue == "阳性" {
1574
+								infection.Rpr = 1 
1575
+							}
1576
+						}
1577
+
1578
+						if infectionDiseases.ItemId == 178 {
1579
+							infection.Hbv = 0 
1580
+							if infectionDiseases.InspectValue == "阳性" {
1581
+								infection.Hbv = 1 
1582
+							}
1583
+						}
1584
+
1585
+						if infectionDiseases.ItemId == 179 {
1586
+							infection.Hcv = 0 
1587
+							if infectionDiseases.InspectValue == "阳性" {
1588
+								infection.Hcv = 1 
1589
+							}
1590
+						}
1591
+						
1592
+					}
1593
+					infectionList = append(infectionList,infection)
1528 1594
 				}
1529 1595
 			}
1530
-			infectionList = append(infectionList,infection)
1531 1596
 		}
1532 1597
 	}
1533 1598
 

+ 22 - 1
service/city_data_uoload_service.go View File

@@ -45,8 +45,14 @@ func FindOrgPatientData(org_id int64, lastUploadTime int64, nowTime int64) (pati
45 45
 	return
46 46
 }
47 47
 
48
+func FindOrgPatientDataOne(org_id int64) (patient []*models.Patients, err error) {
49
+	db := readDb.Model(&models.Patients{}).Where("status = 1 AND user_org_id = ?", org_id)
50
+	err = db.Find(&patient).Error
51
+	return
52
+}
53
+
48 54
 func FindOrgPatientInfectious(org_id int64, lastUploadTime int64, nowTime int64) (patient []*models.Patients, err error) {
49
-	db := readDb.Model(&models.Patients{}).Where("status = 1 AND user_org_id = ? AND lapseto = 2 ", org_id).Preload("InfectiousDiseases", "status = 1")
55
+	db := readDb.Model(&models.Patients{}).Where("status = 1 AND user_org_id = ? AND lapseto = 2 ", org_id)
50 56
 	db = db.Where("created_time >= ? AND created_time <= ?", lastUploadTime, nowTime)
51 57
 	err = db.Find(&patient).Error
52 58
 	return
@@ -118,6 +124,21 @@ func FindOrgInspection(org_id int64,  lastUploadTime int64, nowTime int64) (insp
118 124
 	return
119 125
 }
120 126
 
127
+// 传染病查询
128
+func FindOrgInspectionGroupOne(org_id int64,  lastUploadTime int64, nowTime int64,patient_id int64) (inspection []*models.XtInspection, err error) {
129
+	db := readDb.Model(&models.XtInspection{}).Where("status = 1 AND org_id = ? and project_id = 14 and patient_id = ?", org_id,patient_id)
130
+	db = db.Where("created_time >= ? AND created_time <= ?", lastUploadTime, nowTime).Group("inspect_date")
131
+	err = db.Find(&inspection).Error
132
+	return
133
+}
134
+
135
+// 传染病查询
136
+func FindOrgInspectionGroupTwo(org_id int64, inspect_date int64,patient_id int64) (inspection []*models.XtInspection, err error) {
137
+	db := readDb.Model(&models.XtInspection{}).Where("status = 1 AND org_id = ? and project_id = 14 and patient_id = ? and inspect_date = ?", org_id,patient_id,inspect_date)
138
+	err = db.Find(&inspection).Error
139
+	return
140
+}
141
+
121 142
 func FindOrgInspectionReference(org_id int64,  lastUploadTime int64, nowTime int64) (inspection []*models.XtInspection, err error) {
122 143
 	db := readDb.Model(&models.XtInspection{}).Where("status = 1 AND org_id = ? ", org_id).Preload("XtInspectionReference", "status = 1")
123 144
 	db = db.Where("created_time >= ? AND created_time <= ?", lastUploadTime, nowTime)