28169 преди 1 година
родител
ревизия
ce76f2e289

+ 59 - 2
controllers/new_mobile_api_controllers/new_dialysis_api_controller.go Целия файл

1715
 func (this *NewDialysisApiController) GetInspectionDetail() {
1715
 func (this *NewDialysisApiController) GetInspectionDetail() {
1716
 
1716
 
1717
 	patientid, _ := this.GetInt64("patientid")
1717
 	patientid, _ := this.GetInt64("patientid")
1718
-	fmt.Print("patientid", patientid)
1719
 	patients, _ := service.GetPatientDetailTwo(patientid)
1718
 	patients, _ := service.GetPatientDetailTwo(patientid)
1720
 	date, _ := this.GetInt64("date")
1719
 	date, _ := this.GetInt64("date")
1721
-	fmt.Print("date", date)
1722
 	projectid, _ := this.GetInt64("projectid")
1720
 	projectid, _ := this.GetInt64("projectid")
1723
 	adminUser := this.GetMobileAdminUserInfo()
1721
 	adminUser := this.GetMobileAdminUserInfo()
1724
 	orgid := adminUser.Org.Id
1722
 	orgid := adminUser.Org.Id
2908
 	}
2906
 	}
2909
 
2907
 
2910
 }
2908
 }
2909
+
2910
+func (this *NewDialysisApiController) GetLastInspectionDetail() {
2911
+
2912
+	patient_id, _ := this.GetInt64("patient_id")
2913
+	patients, _ := service.GetPatientDetailTwo(patient_id)
2914
+	date, _ := this.GetInt64("date")
2915
+	project_id, _ := this.GetInt64("project_id")
2916
+
2917
+	org_id := this.GetMobileAdminUserInfo().Org.Id
2918
+
2919
+	inspection, _ := service.GetLastInspection(patients.BloodId, date, project_id, org_id)
2920
+
2921
+	if inspection.InspectDate > 0 {
2922
+		InspectionDetail, err := service.GetLastInspectionDetail(patients.BloodId, inspection.InspectDate, project_id, org_id)
2923
+		if err != nil {
2924
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
2925
+			return
2926
+		}
2927
+		this.ServeSuccessJSON(map[string]interface{}{
2928
+			"InspectionDetail": InspectionDetail,
2929
+			"inspectdate":      inspection.InspectDate,
2930
+		})
2931
+	} else {
2932
+		this.ServeSuccessJSON(map[string]interface{}{
2933
+			"InspectionDetail": "",
2934
+			"inspectdate":      date,
2935
+		})
2936
+	}
2937
+
2938
+}
2939
+
2940
+func (this *NewDialysisApiController) GetNextInspectionDetail() {
2941
+
2942
+	patient_id, _ := this.GetInt64("patient_id")
2943
+	patients, _ := service.GetPatientDetailTwo(patient_id)
2944
+	date, _ := this.GetInt64("date")
2945
+	project_id, _ := this.GetInt64("project_id")
2946
+
2947
+	org_id := this.GetMobileAdminUserInfo().Org.Id
2948
+
2949
+	inspection, _ := service.GetNextInspection(patients.BloodId, date, project_id, org_id)
2950
+	fmt.Println("inspection", inspection.InspectDate)
2951
+	if inspection.InspectDate > 0 {
2952
+		InspectionDetail, err := service.GetLastInspectionDetail(patients.BloodId, inspection.InspectDate, project_id, org_id)
2953
+		if err != nil {
2954
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
2955
+			return
2956
+		}
2957
+		this.ServeSuccessJSON(map[string]interface{}{
2958
+			"InspectionDetail": InspectionDetail,
2959
+			"inspectdate":      inspection.InspectDate,
2960
+		})
2961
+	} else {
2962
+		this.ServeSuccessJSON(map[string]interface{}{
2963
+			"InspectionDetail": "",
2964
+			"inspectdate":      date,
2965
+		})
2966
+	}
2967
+}

+ 3 - 0
controllers/new_mobile_api_controllers/new_mobile_api_router_register.go Целия файл

185
 
185
 
186
 	beego.Router("m/api/patient/inspection_reminds", &NewDialysisApiController{}, "Get:GetAllInspectionReminds")
186
 	beego.Router("m/api/patient/inspection_reminds", &NewDialysisApiController{}, "Get:GetAllInspectionReminds")
187
 
187
 
188
+	beego.Router("/m/api/patient/getllastinspectiondetail", &NewDialysisApiController{}, "Get:GetLastInspectionDetail")
189
+	beego.Router("/m/api/patient/getnextinspectionDetail", &NewDialysisApiController{}, "Get:GetNextInspectionDetail")
190
+
188
 }
191
 }

+ 8 - 3
controllers/print_data_api_controller.go Целия файл

38
 	adminUserInfo := this.GetAdminUserInfo()
38
 	adminUserInfo := this.GetAdminUserInfo()
39
 
39
 
40
 	if this.GetAdminUserInfo().CurrentOrgId == 10016 || this.GetAdminUserInfo().CurrentOrgId == 9882 || this.GetAdminUserInfo().CurrentOrgId == 10138 || this.GetAdminUserInfo().CurrentOrgId == 10278 || this.GetAdminUserInfo().CurrentOrgId == 9841 || this.GetAdminUserInfo().CurrentOrgId == 9845 || this.GetAdminUserInfo().CurrentOrgId == 10081 || this.GetAdminUserInfo().CurrentOrgId == 10215 || this.GetAdminUserInfo().CurrentOrgId == 10121 || this.GetAdminUserInfo().CurrentOrgId == 10234 || this.GetAdminUserInfo().CurrentOrgId == 10188 || this.GetAdminUserInfo().CurrentOrgId == 10217 || this.GetAdminUserInfo().CurrentOrgId == 10340 || this.GetAdminUserInfo().CurrentOrgId == 9905 || this.GetAdminUserInfo().CurrentOrgId == 10346 || this.GetAdminUserInfo().CurrentOrgId == 10441 || this.GetAdminUserInfo().CurrentOrgId == 9970 || this.GetAdminUserInfo().CurrentOrgId == 10101 || this.GetAdminUserInfo().CurrentOrgId == 10495 || this.GetAdminUserInfo().CurrentOrgId == 10013 || this.GetAdminUserInfo().CurrentOrgId == 10014 {
40
 	if this.GetAdminUserInfo().CurrentOrgId == 10016 || this.GetAdminUserInfo().CurrentOrgId == 9882 || this.GetAdminUserInfo().CurrentOrgId == 10138 || this.GetAdminUserInfo().CurrentOrgId == 10278 || this.GetAdminUserInfo().CurrentOrgId == 9841 || this.GetAdminUserInfo().CurrentOrgId == 9845 || this.GetAdminUserInfo().CurrentOrgId == 10081 || this.GetAdminUserInfo().CurrentOrgId == 10215 || this.GetAdminUserInfo().CurrentOrgId == 10121 || this.GetAdminUserInfo().CurrentOrgId == 10234 || this.GetAdminUserInfo().CurrentOrgId == 10188 || this.GetAdminUserInfo().CurrentOrgId == 10217 || this.GetAdminUserInfo().CurrentOrgId == 10340 || this.GetAdminUserInfo().CurrentOrgId == 9905 || this.GetAdminUserInfo().CurrentOrgId == 10346 || this.GetAdminUserInfo().CurrentOrgId == 10441 || this.GetAdminUserInfo().CurrentOrgId == 9970 || this.GetAdminUserInfo().CurrentOrgId == 10101 || this.GetAdminUserInfo().CurrentOrgId == 10495 || this.GetAdminUserInfo().CurrentOrgId == 10013 || this.GetAdminUserInfo().CurrentOrgId == 10014 {
41
-		fmt.Println("JINALADOOWOWOWOWOWOO")
42
 		schedules, getScheduleErr := service.GetSchedulesSeven(adminUserInfo.CurrentOrgId, idStrs)
41
 		schedules, getScheduleErr := service.GetSchedulesSeven(adminUserInfo.CurrentOrgId, idStrs)
43
 		for _, item := range schedules {
42
 		for _, item := range schedules {
44
 
43
 
160
 					}
159
 					}
161
 
160
 
162
 					if item.ScheduleDate >= 1704038400 {
161
 					if item.ScheduleDate >= 1704038400 {
162
+						fmt.Println("寄哪里地方阿道夫阿道夫")
163
+						//listOrder, _ := service.GetDialysisOrderCountNight(item.PatientID, item.ScheduleDate)
164
+						//fmt.Println("")
165
+						//item.Count = listOrder.DialysisTotal
163
 
166
 
164
-						listOrder, _ := service.GetDialysisOrderCountTen(item.PatientID, item.ScheduleDate)
165
-						item.Count = listOrder.DialysisTotal
167
+						listOne, _ := service.GetDialysisOrderCountNight(adminUserInfo.CurrentOrgId, item.PatientID, item.ScheduleDate)
168
+
169
+						item.Patient.TotalDialysis = listOne.Count
170
+						item.Count = listOne.Count
166
 					}
171
 					}
167
 
172
 
168
 				}
173
 				}

+ 40 - 0
service/inspection_service.go Целия файл

3
 import (
3
 import (
4
 	"XT_New/models"
4
 	"XT_New/models"
5
 	"errors"
5
 	"errors"
6
+	"fmt"
6
 	"strings"
7
 	"strings"
7
 	"time"
8
 	"time"
8
 )
9
 )
315
 	err = readDb.Model(&models.XtCheckRemind{}).Preload("InspectionReference", "status = 1").Where("patient_id = ? and status = 1  and user_org_id = ? and DATEDIFF(FROM_UNIXTIME(last_remind_date),NOW()) < 3 and last_remind_date <> 0", patient_id, org_id).Find(&check).Error
316
 	err = readDb.Model(&models.XtCheckRemind{}).Preload("InspectionReference", "status = 1").Where("patient_id = ? and status = 1  and user_org_id = ? and DATEDIFF(FROM_UNIXTIME(last_remind_date),NOW()) < 3 and last_remind_date <> 0", patient_id, org_id).Find(&check).Error
316
 	return
317
 	return
317
 }
318
 }
319
+
320
+func GetLastInspection(patientid int64, date int64, projectid int64, orgid int64) (models.Inspection, error) {
321
+
322
+	inspection := models.Inspection{}
323
+	err := XTReadDB().Group("inspect_date").Order("inspect_date asc").Where("patient_id = ? and inspect_date < ? and project_id =? and status=1 and org_id= ?", patientid, date, projectid, orgid).Limit(1).Find(&inspection).Error
324
+	return inspection, err
325
+
326
+}
327
+
328
+func GetNextInspection(patientid int64, date int64, projectid int64, orgid int64) (models.Inspection, error) {
329
+
330
+	inspection := models.Inspection{}
331
+	err := XTReadDB().Group("inspect_date").Order("inspect_date asc").Where("patient_id = ? and inspect_date > ? and project_id =? and status=1 and org_id= ?", patientid, date, projectid, orgid).Limit(1).Find(&inspection).Error
332
+	return inspection, err
333
+}
334
+
335
+func GetLastInspectionDetail(patientid int64, date int64, projectid int64, orgid int64) (inspection []*models.Inspections, err error) {
336
+
337
+	db := XTReadDB().Table("xt_inspection as x").Where("x.status =1")
338
+	table := XTReadDB().Table("xt_inspection_reference as r")
339
+	fmt.Print("table", table)
340
+	if patientid > 0 {
341
+		db = db.Where("x.patient_id = ?", patientid)
342
+	}
343
+
344
+	if date > 0 {
345
+		db = db.Where("x.inspect_date = ?", date)
346
+	}
347
+	if orgid > 0 {
348
+
349
+		db = db.Where("x.org_id = ?", orgid)
350
+
351
+	}
352
+	if projectid > 0 {
353
+		db = db.Where("x.project_id = ?", projectid)
354
+	}
355
+	err = db.Order("inspect_date asc").Group("x.id").Select("x.id,x.patient_id,x.org_id,x.project_id,x.item_id,x.item_name,x.project_name,x.inspect_type,x.inspect_value,x.inspect_date,x.status,x.created_time,x.updated_time,r.range_type,r.range_min,r.range_max,r.range_value,r.range_options,r.unit").Joins("left join xt_inspection_reference as r on (r.item_id = x.item_id AND r.org_id = x.org_id) OR ( x.item_id = r.id AND r.org_id = 0)   ").Scan(&inspection).Error
356
+	return inspection, err
357
+}