浏览代码

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

XMLWAN 4 年前
父节点
当前提交
ec4a4b11a6

+ 4 - 4
controllers/base_api_controller.go 查看文件

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

+ 2 - 2
controllers/new_mobile_api_controllers/common_api_controller.go 查看文件

@@ -219,7 +219,7 @@ func (this *CommonApiController) GetConfigurationDetail() {
219 219
 		}
220 220
 		this.ServeSuccessJSON(map[string]interface{}{
221 221
 			"configurationdetail": detail,
222
-			"vid":                 vid,
222
+			"vid": vid,
223 223
 		})
224 224
 	} else {
225 225
 		itemId, err := service.GetIdByItemId(detail.InspectionMinor, orgId)
@@ -229,7 +229,7 @@ func (this *CommonApiController) GetConfigurationDetail() {
229 229
 		}
230 230
 		this.ServeSuccessJSON(map[string]interface{}{
231 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 查看文件

@@ -117,9 +117,33 @@ func (this *IndexEvaluationApiController) GetInspectionChartData() {
117 117
 	}
118 118
 
119 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 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 148
 	} else {
125 149
 
@@ -131,6 +155,7 @@ func (this *IndexEvaluationApiController) GetInspectionChartData() {
131 155
 				range_value = range_value + "," + item.InspectValue
132 156
 			}
133 157
 		}
158
+
134 159
 	}
135 160
 
136 161
 	data, _ := statistics_service.GetInspectionChartData(adminUserInfo.Org.Id, theStartTIme, theEndtTIme, project_id, item_id, range_type, range_value)
@@ -251,9 +276,16 @@ func (this *IndexEvaluationApiController) GetPatientInspectionBarChartData() {
251 276
 
252 277
 	var range_value string
253 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 290
 	} else {
259 291
 
@@ -265,6 +297,7 @@ func (this *IndexEvaluationApiController) GetPatientInspectionBarChartData() {
265 297
 				range_value = range_value + "," + item.InspectValue
266 298
 			}
267 299
 		}
300
+
268 301
 	}
269 302
 
270 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 查看文件

@@ -134,11 +134,21 @@ func (this *PCIndexEvaluationApiController) GetInspectionChartData() {
134 134
 	}
135 135
 
136 136
 	var range_value string
137
+
137 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 150
 	} else {
151
+
142 152
 		inspection, _ := statistics_service.FindOrgInspectionReferenceRangeTypeValue(adminUserInfo.CurrentOrgId, project_id, item_id)
143 153
 		for _, item := range inspection {
144 154
 			if len(range_value) == 0 {
@@ -268,10 +278,19 @@ func (this *PCIndexEvaluationApiController) GetPatientInspectionBarChartData() {
268 278
 
269 279
 	var range_value string
270 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 292
 	} else {
293
+
275 294
 		inspection, _ := statistics_service.FindOrgInspectionReferenceRangeTypeValue(adminUserInfo.CurrentOrgId, project_id, item_id)
276 295
 		for _, item := range inspection {
277 296
 			if len(range_value) == 0 {
@@ -282,7 +301,6 @@ func (this *PCIndexEvaluationApiController) GetPatientInspectionBarChartData() {
282 301
 		}
283 302
 
284 303
 	}
285
-
286 304
 	data, _ := statistics_service.GetPatientInspectionBarChartData(adminUserInfo.CurrentOrgId, theStartTIme, theEndtTIme, project_id, item_id, range_type, range_value, patient_id)
287 305
 	this.ServeSuccessJSON(map[string]interface{}{
288 306
 		"data": data,

+ 1 - 0
service/dialysis_service.go 查看文件

@@ -611,6 +611,7 @@ func GetDialysisScheduals(orgID int64, scheduleDate int64) ([]*MDialysisSchedule
611 611
 		Preload("DialysisOrder", "status = 1 AND user_org_id = ?", orgID).
612 612
 		Preload("AssessmentBeforeDislysis", "status = 1 AND user_org_id = ?", orgID).
613 613
 		Preload("Prescription", "status = 1 AND user_org_id = ?", orgID).
614
+		Preload("TreatmentSummary", "status = 1 AND user_org_id = ?", orgID).
614 615
 		// Preload("DialysisOrder.MonitoringRecords", "status = 1 AND user_org_id = ?", orgID).
615 616
 		Where("status = 1 AND user_org_id = ?", orgID)
616 617
 	if scheduleDate != 0 {

+ 9 - 6
service/management_service/management_analyse_service.go 查看文件

@@ -12,12 +12,13 @@ func GetPatientChartData(user_org_id int64, start_time int64, end_time int64, st
12 12
 	db := service.XTReadDB()
13 13
 	switch statistics_type {
14 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 17
 		break
18 18
 	case 2:
19 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 23
 		break
23 24
 	}
@@ -44,14 +45,16 @@ func GetPatientTableData(orgID int64, page, limit, start, end int64, statistics_
44 45
 	var err error
45 46
 	var patients []*PatientTableStruct
46 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 51
 	return patients, total, err
51 52
 }
52 53
 
53 54
 func GetLapsetoPatientTotal(orgID int64, statistics_type int) (Total int64, err error) {
54 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 59
 	return Total, err
57 60
 }

+ 2 - 0
service/mobile_dialysis_service.go 查看文件

@@ -62,6 +62,7 @@ func MobileGetWaitingScheduals(orgID int64, scheduleDate int64) ([]*MDialysisSch
62 62
 		Preload("AssessmentBeforeDislysis", "status = 1 AND user_org_id = ? AND assessment_date = ? ", orgID, scheduleDate).
63 63
 		Preload("DialysisOrder", "status = 1 AND user_org_id = ?", orgID).
64 64
 		Preload("Advices", "status = 1 AND user_org_id = ? AND advice_type = 2 ", orgID).
65
+		Preload("TreatmentMode", "status = 1").
65 66
 		Where("sch.status = 1 AND sch.user_org_id = ?", orgID)
66 67
 	if scheduleDate != 0 {
67 68
 		db = db.Where("schedule_date = ?", scheduleDate)
@@ -88,6 +89,7 @@ type MDialysisScheduleVM struct {
88 89
 	Prescription             *models.DialysisPrescriptionList  `gorm:"ForeignKey:RecordDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"prescription"`
89 90
 	AssessmentBeforeDislysis *models.PredialysisEvaluationList `gorm:"ForeignKey:AssessmentDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"assessment_before_dislysis"`
90 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 95
 func (MDialysisScheduleVM) TableName() string {

+ 1 - 0
service/statistics_service/index_evaluation_service.go 查看文件

@@ -1448,6 +1448,7 @@ func GetInspectionChartData(user_org_id int64, start_time int64, end_time int64,
1448 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 1450
 	if range_type == 1 {
1451
+
1451 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 1453
 			Select("CASE WHEN inspect_value < " + range_value_arr[0] + " THEN " + "'" + "小于" + range_value_arr[0] + "'" +
1453 1454
 				" WHEN inspect_value >= " + range_value_arr[0] + " AND  inspect_value <= " + range_value_arr[1] + " THEN " + "'" + range_value_arr[0] + "~" + range_value_arr[1] + "'" +