XMLWAN 4 anos atrás
pai
commit
50e91b6419

+ 61 - 0
controllers/new_mobile_api_controllers/new_dialysis_api_controller.go Ver arquivo

@@ -1042,3 +1042,64 @@ func (this *NewDialysisApiController) GetMemberSearchPatent() {
1042 1042
 		"memberPatient": memberPatient,
1043 1043
 	})
1044 1044
 }
1045
+
1046
+func (this *NewDialysisApiController) GetLongDialysisDetail() {
1047
+	id, err := this.GetInt64("id")
1048
+	longDialysisDetail, err := service.GetLongDialysisDetail(id)
1049
+	patient, err := service.GetPatientName(longDialysisDetail.PatientId)
1050
+	if err != nil {
1051
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
1052
+		return
1053
+	}
1054
+	this.ServeSuccessJSON(map[string]interface{}{
1055
+		"longDialysisDetail": longDialysisDetail,
1056
+		"patient":            patient,
1057
+	})
1058
+}
1059
+
1060
+func (this *NewDialysisApiController) DeleteLongDialysis() {
1061
+	id, _ := this.GetInt64("id")
1062
+	fmt.Print("id", id)
1063
+	err := service.DeleteLongDialysis(id)
1064
+	fmt.Println("错误是什么", err)
1065
+	returnData := make(map[string]interface{}, 0)
1066
+	returnData["msg"] = "ok"
1067
+	this.ServeSuccessJSON(returnData)
1068
+	return
1069
+}
1070
+
1071
+func (this *NewDialysisApiController) GetDialysisrecord() {
1072
+	timeLayout := "2006-01-02"
1073
+	loc, _ := time.LoadLocation("Local")
1074
+	id, _ := this.GetInt64("id")
1075
+	fmt.Print("id", id)
1076
+	patient, _ := service.GetPatientDetailTwo(id)
1077
+	start := this.GetString("startime")
1078
+	startTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", start+" 00:00:00", loc)
1079
+	startime := startTimes.Unix()
1080
+	fmt.Print("startime", startime)
1081
+	end := this.GetString("endtime")
1082
+	endTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", end+" 00:00:00", loc)
1083
+	endtime := endTimes.Unix()
1084
+	fmt.Print("endtime", endtime)
1085
+	limit, _ := this.GetInt64("limit")
1086
+	fmt.Print("limit", limit)
1087
+	page, _ := this.GetInt64("page")
1088
+	fmt.Print("page", page)
1089
+	adminInfo := this.GetMobileAdminUserInfo()
1090
+	orgid := adminInfo.Org.Id
1091
+	appid := adminInfo.App.Id
1092
+	dislystype, _ := this.GetInt64("dislysType")
1093
+	fmt.Print("透析模式", dislystype)
1094
+	dialysisrecord, total, err := service.GetDialysisrecord(patient.BloodId, startime, endtime, limit, page, orgid, dislystype)
1095
+	doctor, err := service.GetAllDoctorTwo(orgid, appid)
1096
+	if err != nil {
1097
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
1098
+		return
1099
+	}
1100
+	this.ServeSuccessJSON(map[string]interface{}{
1101
+		"dialysisrecord": dialysisrecord,
1102
+		"total":          total,
1103
+		"doctor":         doctor,
1104
+	})
1105
+}

+ 3 - 0
controllers/new_mobile_api_controllers/new_mobile_api_router_register.go Ver arquivo

@@ -61,4 +61,7 @@ func NewMobileAPIControllersRegisterRouters() {
61 61
 	beego.Router("/m/api/patient/searchallblood", &NewDialysisApiController{}, "Get:GetSearchallBlood")
62 62
 	beego.Router("/m/api/patient/getslowsearchepatient", &NewDialysisApiController{}, "Get:GetSlowSearchePatient")
63 63
 	beego.Router("/m/api/patient/getmembersearchpatient", &NewDialysisApiController{}, "Get:GetMemberSearchPatent")
64
+	beego.Router("/m/api/patient/getlongdialysisdetail", &NewDialysisApiController{}, "Get:GetLongDialysisDetail")
65
+	beego.Router("/m/api/patient/deletelongdialysis", &NewDialysisApiController{}, "Delete:DeleteLongDialysis")
66
+	beego.Router("/m/api/patient/getdialysisrecord", &NewDialysisApiController{}, "Get:GetDialysisrecord")
64 67
 }

+ 1 - 1
models/user_models.go Ver arquivo

@@ -335,7 +335,7 @@ type XtDialysisSolution struct {
335 335
 
336 336
 func (XtDialysisSolution) TableName() string {
337 337
 
338
-	return "xt_dialysis_prescription"
338
+	return "xt_dialysis_solution"
339 339
 }
340 340
 
341 341
 type XtPatientRescueRecords struct {

+ 88 - 0
service/patientmanage_service.go Ver arquivo

@@ -707,3 +707,91 @@ func GetMemberSearchPatient(keyword string, orgid int64) (patients []*models.XtP
707 707
 	err = XTReadDB().Where("name like ? or dialysis_no = ? and user_org_id = ? and member_patients = 1", likeKey, keyword, orgid).Find(&patients).Error
708 708
 	return patients, err
709 709
 }
710
+
711
+func GetLongDialysisDetail(id int64) (models.XtDialysisSolution, error) {
712
+	solution := models.XtDialysisSolution{}
713
+	err := XTReadDB().Model(&solution).Where("id=? and status =1", id).Find(&solution).Error
714
+	return solution, err
715
+}
716
+
717
+func GetPatientName(id int64) (models.Patients, error) {
718
+	patientsNew := models.Patients{}
719
+	err := XTReadDB().Model(&patientsNew).Where("id=? and status = 1", id).Find(&patientsNew).Error
720
+	return patientsNew, err
721
+}
722
+
723
+func DeleteLongDialysis(id int64) error {
724
+	err := XTWriteDB().Model(models.XtDialysisSolution{}).Where("id=?", id).Update(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
725
+	return err
726
+}
727
+
728
+func GetDialysisrecord(patientID int64, start int64, end int64, limit int64, page int64, orgID int64, mode_id int64) ([]*models.PatientDialysisRecord, int64, error) {
729
+	offset := (page - 1) * limit
730
+	var total int64
731
+	var err error
732
+	var orders []*models.PatientDialysisRecord
733
+
734
+	db := readDb.Table("xt_dialysis_order as do").
735
+		Preload("DialysisPrescription", "patient_id=? and user_org_id=? and status=1", patientID, orgID).
736
+		Preload("PredialysisEvaluation", "patient_id=? and user_org_id=? and status=1", patientID, orgID).
737
+		Preload("DialysisPrescription", func(db *gorm.DB) *gorm.DB {
738
+			return readDb.Where("patient_id=? and user_org_id=? and status=1", patientID, orgID).Preload("UserAdminRole", func(db *gorm.DB) *gorm.DB {
739
+				return readUserDb.Where("status = 1")
740
+			})
741
+		}).
742
+		Preload("AssessmentAfterDislysis", "patient_id=? and user_org_id=? and status=1", patientID, orgID).
743
+		Preload("TreatmentSummary", "patient_id=? and user_org_id=? and status=1", patientID, orgID).
744
+		Preload("Device", "org_id=? and status=1", orgID).
745
+		Preload("UserAdminRole", func(db *gorm.DB) *gorm.DB {
746
+			return readUserDb.Where("org_id=? and status = 1", orgID)
747
+		}).
748
+		Joins("JOIN xt_schedule as s ON s.patient_id=? and FROM_UNIXTIME(s.schedule_date, '%Y-%m-%d')=FROM_UNIXTIME(do.dialysis_date, '%Y-%m-%d')", patientID).
749
+		Joins("JOIN xt_device_zone as dz ON dz.org_id = ? and dz.id=s.partition_id", orgID).
750
+		Where("do.patient_id=? and do.user_org_id=? and do.stage = 2 and do.status=1", patientID, orgID).Group("s.schedule_date")
751
+
752
+	if start != 0 {
753
+		db = db.Where("do.dialysis_date>=?", start)
754
+	}
755
+	if end != 0 {
756
+		db = db.Where("do.dialysis_date<=?", end)
757
+	}
758
+	if mode_id > 0 {
759
+		db = db.Joins("JOIN xt_dialysis_prescription as dp ON dp.record_id=do.id")
760
+		db = db.Where("dp.mode_id=?", mode_id)
761
+	}
762
+
763
+	err = db.Count(&total).Offset(offset).Limit(limit).Order("do.dialysis_date desc").Select("do.bed_id, do.id, do.dialysis_date, do.user_org_id, do.patient_id, do.prescription_id, do.stage, do.remark, do.status, do.created_time, do.updated_time,do.start_nurse,do.finish_nurse ,s.schedule_type, s.partition_id, dz.name as partition_name").Find(&orders).Error
764
+
765
+	if len(orders) > 0 {
766
+		ids := make([]int64, 0)
767
+		for _, order := range orders {
768
+			dialyzer := order.DialysisPrescription.Dialyzer
769
+			ids = append(ids, dialyzer)
770
+		}
771
+		if len(ids) > 0 {
772
+			var dialyzers []*models.DeviceNumber
773
+			err = readDb.Model(&models.DeviceNumber{}).Where("id IN (?) and org_id=? and status=1", ids, orgID).Find(&dialyzers).Error
774
+			if err != nil {
775
+				return nil, 0, err
776
+			}
777
+
778
+			dialyzerMap := make(map[int64]models.DeviceNumber, 0)
779
+			for _, item := range dialyzers {
780
+				dialyzerMap[item.ID] = *item
781
+			}
782
+			for orderIndex, order := range orders {
783
+				if _, exist := dialyzerMap[order.DialysisPrescription.Dialyzer]; exist {
784
+					orders[orderIndex].DeviceNumber = dialyzerMap[order.DialysisPrescription.Dialyzer].Number
785
+				}
786
+			}
787
+		}
788
+	}
789
+
790
+	return orders, total, err
791
+}
792
+
793
+func GetAllDoctorTwo(orgid int64, appid int64) (appRole []*models.App_Role, err error) {
794
+
795
+	err = UserReadDB().Where("org_id = ? AND app_id = ? AND status = ? ", orgid, appid, 1).Find(&appRole).Error
796
+	return appRole, err
797
+}

+ 0 - 1
service/user_service.go Ver arquivo

@@ -93,7 +93,6 @@ func GetDryWeightByPatientId(patientid int64, orgid int64) (pre []*models.SgjPat
93 93
 func GetAllDoctor(orgid int64, appid int64) (appRole []*models.App_Role, err error) {
94 94
 
95 95
 	err = UserReadDB().Where("org_id = ? AND app_id = ? AND status = ? AND  (user_type = ? OR user_type = ?) ", orgid, appid, 1, 2, 1).Find(&appRole).Error
96
-	fmt.Println("errrrrrrrrrrerrrrrrrrrrrrrrrrrrr", err)
97 96
 	return appRole, err
98 97
 }
99 98