Quellcode durchsuchen

Merge branch '20200710_xt_api_new_branch' of http://git.shengws.com/csx/XT_New into 20200710_xt_api_new_branch

XMLWAN vor 4 Jahren
Ursprung
Commit
ec4a4b11a6

+ 4 - 4
controllers/base_api_controller.go Datei anzeigen

81
 		userAdmin.ModifyTime = 1530786071
81
 		userAdmin.ModifyTime = 1530786071
82
 		var subscibe models.ServeSubscibe
82
 		var subscibe models.ServeSubscibe
83
 		subscibe.ID = 1
83
 		subscibe.ID = 1
84
-		subscibe.OrgId = 3907
84
+		subscibe.OrgId = 12
85
 		subscibe.PeriodStart = 1538035409
85
 		subscibe.PeriodStart = 1538035409
86
 		subscibe.PeriodEnd = 1569571409
86
 		subscibe.PeriodEnd = 1569571409
87
 		subscibe.State = 1
87
 		subscibe.State = 1
91
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
91
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
92
 		subscibes[4] = &subscibe
92
 		subscibes[4] = &subscibe
93
 		var adminUserInfo service.AdminUserInfo
93
 		var adminUserInfo service.AdminUserInfo
94
-		adminUserInfo.CurrentOrgId = 3907
94
+		adminUserInfo.CurrentOrgId = 12
95
 		adminUserInfo.CurrentAppId = 18
95
 		adminUserInfo.CurrentAppId = 18
96
 		adminUserInfo.AdminUser = &userAdmin
96
 		adminUserInfo.AdminUser = &userAdmin
97
 		adminUserInfo.Subscibes = subscibes
97
 		adminUserInfo.Subscibes = subscibes
326
 		userAdmin.ModifyTime = 1530786071
326
 		userAdmin.ModifyTime = 1530786071
327
 		var subscibe models.ServeSubscibe
327
 		var subscibe models.ServeSubscibe
328
 		subscibe.ID = 1
328
 		subscibe.ID = 1
329
-		subscibe.OrgId = 9538
329
+		subscibe.OrgId = 12
330
 		subscibe.PeriodStart = 1538035409
330
 		subscibe.PeriodStart = 1538035409
331
 		subscibe.PeriodEnd = 1569571409
331
 		subscibe.PeriodEnd = 1569571409
332
 		subscibe.State = 1
332
 		subscibe.State = 1
336
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
336
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
337
 		subscibes[4] = &subscibe
337
 		subscibes[4] = &subscibe
338
 		var adminUserInfo service.AdminUserInfo
338
 		var adminUserInfo service.AdminUserInfo
339
-		adminUserInfo.CurrentOrgId = 9538
339
+		adminUserInfo.CurrentOrgId = 12
340
 		adminUserInfo.CurrentAppId = 18
340
 		adminUserInfo.CurrentAppId = 18
341
 		adminUserInfo.AdminUser = &userAdmin
341
 		adminUserInfo.AdminUser = &userAdmin
342
 		adminUserInfo.Subscibes = subscibes
342
 		adminUserInfo.Subscibes = subscibes

+ 2 - 2
controllers/new_mobile_api_controllers/common_api_controller.go Datei anzeigen

219
 		}
219
 		}
220
 		this.ServeSuccessJSON(map[string]interface{}{
220
 		this.ServeSuccessJSON(map[string]interface{}{
221
 			"configurationdetail": detail,
221
 			"configurationdetail": detail,
222
-			"vid":                 vid,
222
+			"vid": vid,
223
 		})
223
 		})
224
 	} else {
224
 	} else {
225
 		itemId, err := service.GetIdByItemId(detail.InspectionMinor, orgId)
225
 		itemId, err := service.GetIdByItemId(detail.InspectionMinor, orgId)
229
 		}
229
 		}
230
 		this.ServeSuccessJSON(map[string]interface{}{
230
 		this.ServeSuccessJSON(map[string]interface{}{
231
 			"configurationdetail": detail,
231
 			"configurationdetail": detail,
232
-			"vid":                 itemId.ID,
232
+			"vid": itemId.ID,
233
 		})
233
 		})
234
 	}
234
 	}
235
 
235
 

+ 37 - 4
controllers/new_mobile_api_controllers/index_evaluation_api_controller.go Datei anzeigen

117
 	}
117
 	}
118
 
118
 
119
 	var range_value string
119
 	var range_value string
120
+	//if range_type == 1 {
121
+	//	qcs, _ := statistics_service.FindOrgConfigRangeTypeValue(adminUserInfo.Org.Id, project_id, item_id)
122
+	//	range_value = qcs.RangeMin + "," + qcs.RangeMax
123
+	//
124
+	//} else {
125
+	//
126
+	//	inspection, _ := statistics_service.FindOrgInspectionReferenceRangeTypeValue(adminUserInfo.Org.Id, project_id, item_id)
127
+	//	for _, item := range inspection {
128
+	//		if len(range_value) == 0 {
129
+	//			range_value = item.InspectValue
130
+	//		} else {
131
+	//			range_value = range_value + "," + item.InspectValue
132
+	//		}
133
+	//	}
134
+	//}
135
+
120
 	if range_type == 1 {
136
 	if range_type == 1 {
121
-		qcs, _ := statistics_service.FindOrgConfigRangeTypeValue(adminUserInfo.Org.Id, project_id, item_id)
122
-		range_value = qcs.RangeMin + "," + qcs.RangeMax
137
+		count, _ := statistics_service.FindOrgInspectionCount(adminUserInfo.Org.Id)
138
+
139
+		if count <= 0 {
140
+			qcs, _ := statistics_service.FindOrgConfigRangeTypeValue(0, project_id, item_id)
141
+			range_value = qcs.RangeMin + "," + qcs.RangeMax
142
+
143
+		} else {
144
+			qcs, _ := statistics_service.FindOrgConfigRangeTypeValue(adminUserInfo.Org.Id, project_id, item_id)
145
+			range_value = qcs.RangeMin + "," + qcs.RangeMax
146
+		}
123
 
147
 
124
 	} else {
148
 	} else {
125
 
149
 
131
 				range_value = range_value + "," + item.InspectValue
155
 				range_value = range_value + "," + item.InspectValue
132
 			}
156
 			}
133
 		}
157
 		}
158
+
134
 	}
159
 	}
135
 
160
 
136
 	data, _ := statistics_service.GetInspectionChartData(adminUserInfo.Org.Id, theStartTIme, theEndtTIme, project_id, item_id, range_type, range_value)
161
 	data, _ := statistics_service.GetInspectionChartData(adminUserInfo.Org.Id, theStartTIme, theEndtTIme, project_id, item_id, range_type, range_value)
251
 
276
 
252
 	var range_value string
277
 	var range_value string
253
 	if range_type == 1 {
278
 	if range_type == 1 {
254
-		qcs, _ := statistics_service.FindOrgConfigRangeTypeValue(adminUserInfo.Org.Id, project_id, item_id)
279
+		count, _ := statistics_service.FindOrgInspectionCount(adminUserInfo.Org.Id)
280
+
281
+		if count <= 0 {
282
+			qcs, _ := statistics_service.FindOrgConfigRangeTypeValue(0, project_id, item_id)
283
+			range_value = qcs.RangeMin + "," + qcs.RangeMax
255
 
284
 
256
-		range_value = qcs.RangeMin + "," + qcs.RangeMax
285
+		} else {
286
+			qcs, _ := statistics_service.FindOrgConfigRangeTypeValue(adminUserInfo.Org.Id, project_id, item_id)
287
+			range_value = qcs.RangeMin + "," + qcs.RangeMax
288
+		}
257
 
289
 
258
 	} else {
290
 	} else {
259
 
291
 
265
 				range_value = range_value + "," + item.InspectValue
297
 				range_value = range_value + "," + item.InspectValue
266
 			}
298
 			}
267
 		}
299
 		}
300
+
268
 	}
301
 	}
269
 
302
 
270
 	data, _ := statistics_service.GetPatientInspectionBarChartData(adminUserInfo.Org.Id, theStartTIme, theEndtTIme, project_id, item_id, range_type, range_value, patient_id)
303
 	data, _ := statistics_service.GetPatientInspectionBarChartData(adminUserInfo.Org.Id, theStartTIme, theEndtTIme, project_id, item_id, range_type, range_value, patient_id)

+ 23 - 5
controllers/pc_index_evaluation_api_controller.go Datei anzeigen

134
 	}
134
 	}
135
 
135
 
136
 	var range_value string
136
 	var range_value string
137
+
137
 	if range_type == 1 {
138
 	if range_type == 1 {
138
-		qcs, _ := statistics_service.FindOrgConfigRangeTypeValue(adminUserInfo.CurrentOrgId, project_id, item_id)
139
-		range_value = qcs.RangeMin + "," + qcs.RangeMax
139
+		count, _ := statistics_service.FindOrgInspectionCount(adminUserInfo.CurrentOrgId)
140
+
141
+		if count <= 0 {
142
+			qcs, _ := statistics_service.FindOrgConfigRangeTypeValue(0, project_id, item_id)
143
+			range_value = qcs.RangeMin + "," + qcs.RangeMax
144
+
145
+		} else {
146
+			qcs, _ := statistics_service.FindOrgConfigRangeTypeValue(adminUserInfo.CurrentOrgId, project_id, item_id)
147
+			range_value = qcs.RangeMin + "," + qcs.RangeMax
148
+		}
140
 
149
 
141
 	} else {
150
 	} else {
151
+
142
 		inspection, _ := statistics_service.FindOrgInspectionReferenceRangeTypeValue(adminUserInfo.CurrentOrgId, project_id, item_id)
152
 		inspection, _ := statistics_service.FindOrgInspectionReferenceRangeTypeValue(adminUserInfo.CurrentOrgId, project_id, item_id)
143
 		for _, item := range inspection {
153
 		for _, item := range inspection {
144
 			if len(range_value) == 0 {
154
 			if len(range_value) == 0 {
268
 
278
 
269
 	var range_value string
279
 	var range_value string
270
 	if range_type == 1 {
280
 	if range_type == 1 {
271
-		qcs, _ := statistics_service.FindOrgConfigRangeTypeValue(adminUserInfo.CurrentOrgId, project_id, item_id)
272
-		range_value = qcs.RangeMin + "," + qcs.RangeMax
281
+		count, _ := statistics_service.FindOrgInspectionCount(adminUserInfo.CurrentOrgId)
282
+
283
+		if count <= 0 {
284
+			qcs, _ := statistics_service.FindOrgConfigRangeTypeValue(0, project_id, item_id)
285
+			range_value = qcs.RangeMin + "," + qcs.RangeMax
286
+
287
+		} else {
288
+			qcs, _ := statistics_service.FindOrgConfigRangeTypeValue(adminUserInfo.CurrentOrgId, project_id, item_id)
289
+			range_value = qcs.RangeMin + "," + qcs.RangeMax
290
+		}
273
 
291
 
274
 	} else {
292
 	} else {
293
+
275
 		inspection, _ := statistics_service.FindOrgInspectionReferenceRangeTypeValue(adminUserInfo.CurrentOrgId, project_id, item_id)
294
 		inspection, _ := statistics_service.FindOrgInspectionReferenceRangeTypeValue(adminUserInfo.CurrentOrgId, project_id, item_id)
276
 		for _, item := range inspection {
295
 		for _, item := range inspection {
277
 			if len(range_value) == 0 {
296
 			if len(range_value) == 0 {
282
 		}
301
 		}
283
 
302
 
284
 	}
303
 	}
285
-
286
 	data, _ := statistics_service.GetPatientInspectionBarChartData(adminUserInfo.CurrentOrgId, theStartTIme, theEndtTIme, project_id, item_id, range_type, range_value, patient_id)
304
 	data, _ := statistics_service.GetPatientInspectionBarChartData(adminUserInfo.CurrentOrgId, theStartTIme, theEndtTIme, project_id, item_id, range_type, range_value, patient_id)
287
 	this.ServeSuccessJSON(map[string]interface{}{
305
 	this.ServeSuccessJSON(map[string]interface{}{
288
 		"data": data,
306
 		"data": data,

+ 1 - 0
service/dialysis_service.go Datei anzeigen

611
 		Preload("DialysisOrder", "status = 1 AND user_org_id = ?", orgID).
611
 		Preload("DialysisOrder", "status = 1 AND user_org_id = ?", orgID).
612
 		Preload("AssessmentBeforeDislysis", "status = 1 AND user_org_id = ?", orgID).
612
 		Preload("AssessmentBeforeDislysis", "status = 1 AND user_org_id = ?", orgID).
613
 		Preload("Prescription", "status = 1 AND user_org_id = ?", orgID).
613
 		Preload("Prescription", "status = 1 AND user_org_id = ?", orgID).
614
+		Preload("TreatmentSummary", "status = 1 AND user_org_id = ?", orgID).
614
 		// Preload("DialysisOrder.MonitoringRecords", "status = 1 AND user_org_id = ?", orgID).
615
 		// Preload("DialysisOrder.MonitoringRecords", "status = 1 AND user_org_id = ?", orgID).
615
 		Where("status = 1 AND user_org_id = ?", orgID)
616
 		Where("status = 1 AND user_org_id = ?", orgID)
616
 	if scheduleDate != 0 {
617
 	if scheduleDate != 0 {

+ 9 - 6
service/management_service/management_analyse_service.go Datei anzeigen

12
 	db := service.XTReadDB()
12
 	db := service.XTReadDB()
13
 	switch statistics_type {
13
 	switch statistics_type {
14
 	case 1:
14
 	case 1:
15
-		err = db.Raw("select from_unixtime(lapseto_time,'%m-%d') as date, count(distinct patient_id) as value  from xt_patient_lapseto lapseto JOIN `xt_patients` patient ON lapseto.`patient_id` = patient.id AND patient.user_org_id = ? Where lapseto.status = 1 AND lapseto.lapseto_type = 1 AND lapseto.lapseto_time >= ? AND lapseto.lapseto_time <= ?   Group by date", user_org_id, start_time, end_time).Scan(&datas).Error
15
+		err = db.Raw("select from_unixtime(created_time,'%m-%d') as date, count(distinct id) as value  from xt_patients patient   Where  patient.user_org_id = ? AND patient.created_time >=? AND patient.created_time <=? AND patient.status = 1   AND patient.lapseto = 1  Group by date", user_org_id, start_time, end_time).Scan(&datas).Error
16
 
16
 
17
 		break
17
 		break
18
 	case 2:
18
 	case 2:
19
 		//err = db.Raw("select from_unixtime(assessment_date,'%Y-%m-%d') as date, weight_after as value from xt_assessment_after_dislysis  Where status = 1 AND user_org_id = ? AND patient_id = ?  AND assessment_date <= ? AND  assessment_date >= ? ", user_org_id, patient_id, end_time, start_time).Scan(&datas).Error
19
 		//err = db.Raw("select from_unixtime(assessment_date,'%Y-%m-%d') as date, weight_after as value from xt_assessment_after_dislysis  Where status = 1 AND user_org_id = ? AND patient_id = ?  AND assessment_date <= ? AND  assessment_date >= ? ", user_org_id, patient_id, end_time, start_time).Scan(&datas).Error
20
-		err = db.Raw("select from_unixtime(lapseto_time,'%m-%d') as date, count(distinct patient_id) as value  from xt_patient_lapseto lapseto JOIN `xt_patients` patient ON lapseto.`patient_id` = patient.id AND patient.user_org_id = ? Where lapseto.status = 1 AND lapseto.lapseto_type = 2 AND lapseto.lapseto_time >= ? AND lapseto.lapseto_time <= ?   Group by date", user_org_id, start_time, end_time).Scan(&datas).Error
20
+		//err = db.Raw("select from_unixtime(lapseto_time,'%m-%d') as date, count(distinct patient_id) as value  from xt_patient_lapseto lapseto JOIN `xt_patients` patient ON lapseto.`patient_id` = patient.id AND patient.user_org_id = ? Where lapseto.status = 1 AND lapseto.lapseto_type = 2 AND lapseto.lapseto_time >= ? AND lapseto.lapseto_time <= ?   Group by date", user_org_id, start_time, end_time).Scan(&datas).Error
21
+		err = db.Raw("select from_unixtime(created_time,'%m-%d') as date, count(distinct id) as value  from xt_patients patient   Where  patient.user_org_id = ? AND patient.created_time >=? AND patient.created_time <=? AND patient.status = 1   AND patient.lapseto = 2  Group by date", user_org_id, start_time, end_time).Scan(&datas).Error
21
 
22
 
22
 		break
23
 		break
23
 	}
24
 	}
44
 	var err error
45
 	var err error
45
 	var patients []*PatientTableStruct
46
 	var patients []*PatientTableStruct
46
 	readDb := service.XTReadDB()
47
 	readDb := service.XTReadDB()
47
-	db := readDb.Raw("select from_unixtime(lapseto.`lapseto_time`,'%Y-%m-%d %H:%m') as date , patient.name as name, patient.`id_card_no` as id_card_no, patient.`gender` as gender  from xt_patient_lapseto lapseto JOIN `xt_patients` patient ON lapseto.`patient_id` = patient.id AND patient.user_org_id = ? Where lapseto.status = 1 AND lapseto.lapseto_type = ? AND lapseto.lapseto_time >= ? AND lapseto.lapseto_time <= ?  ", orgID, statistics_type, start, end)
48
-	err = db.Order("lapseto.lapseto_time desc").Scan(&patients).Error
49
-	//.Offset(offset).Limit(limit)
48
+	//db := readDb.Raw("select from_unixtime(lapseto.`lapseto_time`,'%Y-%m-%d %H:%m') as date , patient.name as name, patient.`id_card_no` as id_card_no, patient.`gender` as gender  from xt_patient_lapseto lapseto JOIN `xt_patients` patient ON lapseto.`patient_id` = patient.id AND patient.user_org_id = ? Where lapseto.status = 1 AND lapseto.lapseto_type = ? AND lapseto.lapseto_time >= ? AND lapseto.lapseto_time <= ?  ", orgID, statistics_type, start, end)
49
+	db := readDb.Raw("select from_unixtime(patient.`created_time`,'%Y-%m-%d %H:%m') as date , patient.name as name, patient.`id_card_no` as id_card_no, patient.`gender` as gender  from `xt_patients` patient Where patient.user_org_id = ? AND patient.status = 1 AND patient.lapseto = ?  AND patient.created_time >= ? AND patient.created_time <= ?  ", orgID, statistics_type, start, end)
50
+	err = db.Order("patient.created_time desc").Scan(&patients).Error
50
 	return patients, total, err
51
 	return patients, total, err
51
 }
52
 }
52
 
53
 
53
 func GetLapsetoPatientTotal(orgID int64, statistics_type int) (Total int64, err error) {
54
 func GetLapsetoPatientTotal(orgID int64, statistics_type int) (Total int64, err error) {
54
 	readDb := service.XTReadDB()
55
 	readDb := service.XTReadDB()
55
-	err = readDb.Raw("select count(*) as total from xt_patient_lapseto lapseto JOIN `xt_patients` patient ON lapseto.`patient_id` = patient.id AND patient.user_org_id = ? Where lapseto.status = 1 AND lapseto.lapseto_type =?", orgID, statistics_type).Count(&Total).Error
56
+	//err = readDb.Raw("select count(*) as total from xt_patient_lapseto lapseto JOIN `xt_patients` patient ON lapseto.`patient_id` = patient.id AND patient.user_org_id = ? Where lapseto.status = 1 AND lapseto.lapseto_type =?", orgID, statistics_type).Count(&Total).Error
57
+	err = readDb.Raw("select count(*) as total from `xt_patients` patient Where patient.user_org_id = ? AND patient.status = 1 AND patient.lapseto = ?", orgID, statistics_type).Count(&Total).Error
58
+
56
 	return Total, err
59
 	return Total, err
57
 }
60
 }

+ 2 - 0
service/mobile_dialysis_service.go Datei anzeigen

62
 		Preload("AssessmentBeforeDislysis", "status = 1 AND user_org_id = ? AND assessment_date = ? ", orgID, scheduleDate).
62
 		Preload("AssessmentBeforeDislysis", "status = 1 AND user_org_id = ? AND assessment_date = ? ", orgID, scheduleDate).
63
 		Preload("DialysisOrder", "status = 1 AND user_org_id = ?", orgID).
63
 		Preload("DialysisOrder", "status = 1 AND user_org_id = ?", orgID).
64
 		Preload("Advices", "status = 1 AND user_org_id = ? AND advice_type = 2 ", orgID).
64
 		Preload("Advices", "status = 1 AND user_org_id = ? AND advice_type = 2 ", orgID).
65
+		Preload("TreatmentMode", "status = 1").
65
 		Where("sch.status = 1 AND sch.user_org_id = ?", orgID)
66
 		Where("sch.status = 1 AND sch.user_org_id = ?", orgID)
66
 	if scheduleDate != 0 {
67
 	if scheduleDate != 0 {
67
 		db = db.Where("schedule_date = ?", scheduleDate)
68
 		db = db.Where("schedule_date = ?", scheduleDate)
88
 	Prescription             *models.DialysisPrescriptionList  `gorm:"ForeignKey:RecordDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"prescription"`
89
 	Prescription             *models.DialysisPrescriptionList  `gorm:"ForeignKey:RecordDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"prescription"`
89
 	AssessmentBeforeDislysis *models.PredialysisEvaluationList `gorm:"ForeignKey:AssessmentDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"assessment_before_dislysis"`
90
 	AssessmentBeforeDislysis *models.PredialysisEvaluationList `gorm:"ForeignKey:AssessmentDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"assessment_before_dislysis"`
90
 	Advices                  []*VMDoctorAdvice                 `gorm:"ForeignKey:AdviceDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"doctor_advice"`
91
 	Advices                  []*VMDoctorAdvice                 `gorm:"ForeignKey:AdviceDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"doctor_advice"`
92
+	TreatmentSummary         *models.TreatmentSummary          `gorm:"ForeignKey:AssessmentDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"treatment_summary"`
91
 }
93
 }
92
 
94
 
93
 func (MDialysisScheduleVM) TableName() string {
95
 func (MDialysisScheduleVM) TableName() string {

+ 1 - 0
service/statistics_service/index_evaluation_service.go Datei anzeigen

1448
 	db.Table("xt_inspection").Where("org_id=? and status=1 and  inspect_date >= ? and inspect_date <= ? AND project_id = ? AND item_id = ? AND inspect_value <> '' ", user_org_id, start_time, end_time, project_id, item_id).Count(&Total)
1448
 	db.Table("xt_inspection").Where("org_id=? and status=1 and  inspect_date >= ? and inspect_date <= ? AND project_id = ? AND item_id = ? AND inspect_value <> '' ", user_org_id, start_time, end_time, project_id, item_id).Count(&Total)
1449
 
1449
 
1450
 	if range_type == 1 {
1450
 	if range_type == 1 {
1451
+
1451
 		tempErr = db.Table("xt_inspection").Where("org_id=? and status=1 and  inspect_date >= ? and inspect_date <= ? AND project_id = ? AND item_id = ? AND inspect_value <> ''", user_org_id, start_time, end_time, project_id, item_id).
1452
 		tempErr = db.Table("xt_inspection").Where("org_id=? and status=1 and  inspect_date >= ? and inspect_date <= ? AND project_id = ? AND item_id = ? AND inspect_value <> ''", user_org_id, start_time, end_time, project_id, item_id).
1452
 			Select("CASE WHEN inspect_value < " + range_value_arr[0] + " THEN " + "'" + "小于" + range_value_arr[0] + "'" +
1453
 			Select("CASE WHEN inspect_value < " + range_value_arr[0] + " THEN " + "'" + "小于" + range_value_arr[0] + "'" +
1453
 				" WHEN inspect_value >= " + range_value_arr[0] + " AND  inspect_value <= " + range_value_arr[1] + " THEN " + "'" + range_value_arr[0] + "~" + range_value_arr[1] + "'" +
1454
 				" WHEN inspect_value >= " + range_value_arr[0] + " AND  inspect_value <= " + range_value_arr[1] + " THEN " + "'" + range_value_arr[0] + "~" + range_value_arr[1] + "'" +