Browse Source

历史排班

28169 1 year ago
parent
commit
4ebc851ae7

+ 52 - 1
controllers/patient_dataconfig_api_controller.go View File

@@ -38,6 +38,8 @@ func PatientDataConfigAPIControllerRegistRouters() {
38 38
 
39 39
 	beego.Router("/api/patient/getpatientdialysisinforlist", &PatientDataConfigAPIController{}, "get:GetPatientDialysisInforList")
40 40
 
41
+	beego.Router("/api/patient/getcontextschedulelist", &PatientDataConfigAPIController{}, "Get:GetContextScheduleList")
42
+
41 43
 }
42 44
 
43 45
 type PatientDataConfigAPIController struct {
@@ -1056,7 +1058,6 @@ func (this *PatientDataConfigAPIController) GetPatientDialysisInforList() {
1056 1058
 		}
1057 1059
 		startTime = theTime.Unix()
1058 1060
 	}
1059
-	fmt.Println("startTime0000000000000000", startTime)
1060 1061
 
1061 1062
 	//获取患者姓名
1062 1063
 	patient, _ := service.GetPatientName(patientID)
@@ -1090,3 +1091,53 @@ func (this *PatientDataConfigAPIController) GetPatientDialysisInforList() {
1090 1091
 		"afterDislysis":   afterDislysis,
1091 1092
 	})
1092 1093
 }
1094
+
1095
+func (this *PatientDataConfigAPIController) GetContextScheduleList() {
1096
+
1097
+	limit, _ := this.GetInt64("limit")
1098
+
1099
+	page, _ := this.GetInt64("page")
1100
+
1101
+	start_time := this.GetString("start_time")
1102
+
1103
+	end_time := this.GetString("end_time")
1104
+
1105
+	timeLayout := "2006-01-02"
1106
+	loc, _ := time.LoadLocation("Local")
1107
+	var startTime int64
1108
+	if len(start_time) > 0 {
1109
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
1110
+		if err != nil {
1111
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1112
+			return
1113
+		}
1114
+		startTime = theTime.Unix()
1115
+	}
1116
+
1117
+	var endTime int64
1118
+	if len(end_time) > 0 {
1119
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
1120
+		if err != nil {
1121
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1122
+			return
1123
+		}
1124
+		startTime = theTime.Unix()
1125
+	}
1126
+
1127
+	org_id := this.GetAdminUserInfo().CurrentOrgId
1128
+
1129
+	schedule, total, _ := service.GetContextScheduleListGroupPatientId(limit, page, startTime, endTime, org_id)
1130
+
1131
+	list, _, _ := service.GetContextScheduleListPatientId(startTime, endTime, org_id)
1132
+
1133
+	patients, _ := service.GetAllpatientThirty(org_id)
1134
+
1135
+	devicenumber, _ := service.GetAllBedNumber(org_id)
1136
+	this.ServeSuccessJSON(map[string]interface{}{
1137
+		"schedule":     schedule,
1138
+		"total":        total,
1139
+		"list":         list,
1140
+		"patients":     patients,
1141
+		"devicenumber": devicenumber,
1142
+	})
1143
+}

+ 17 - 0
models/patient_models.go View File

@@ -1959,3 +1959,20 @@ type XtPatientPhysiqueCheck struct {
1959 1959
 func (XtPatientPhysiqueCheck) TableName() string {
1960 1960
 	return "xt_patient_physique_check"
1961 1961
 }
1962
+
1963
+type ConScheduleList struct {
1964
+	UserOrgId    int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1965
+	PartitionId  int64 `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
1966
+	BedId        int64 `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
1967
+	PatientId    int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1968
+	ScheduleDate int64 `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
1969
+	ScheduleType int64 `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
1970
+	ScheduleWeek int64 `gorm:"column:schedule_week" json:"schedule_week" form:"schedule_week"`
1971
+	ModeId       int64 `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
1972
+	IsExport     int64 `gorm:"column:is_export" json:"is_export" form:"is_export"`
1973
+	Status       int64 `gorm:"column:status" json:"status" form:"status"`
1974
+}
1975
+
1976
+func (ConScheduleList) TableName() string {
1977
+	return "xt_schedule"
1978
+}

+ 40 - 0
service/patient_service.go View File

@@ -2898,3 +2898,43 @@ func UpdateScheduleByExport(org_id int64, shcheduledate int64) error {
2898 2898
 	err := XTWriteDB().Model(models.XtSchedule{}).Where("user_org_id = ? and schedule_date > ?", org_id, shcheduledate).Updates(map[string]interface{}{"status": 0}).Error
2899 2899
 	return err
2900 2900
 }
2901
+
2902
+func GetContextScheduleListGroupPatientId(limit int64, page int64, startTime int64, endTime int64, org_id int64) (schedule []*models.ConScheduleList, total int64, err error) {
2903
+
2904
+	db := XTReadDB().Model(&schedule).Where("status=1")
2905
+
2906
+	offset := (page - 1) * limit
2907
+
2908
+	if startTime > 0 {
2909
+		db = db.Where("schedule_date >=?", startTime)
2910
+	}
2911
+	if endTime > 0 {
2912
+		db = db.Where("schedule_date<=?", endTime)
2913
+	}
2914
+
2915
+	if org_id > 0 {
2916
+		db = db.Where("user_org_id = ?", org_id)
2917
+	}
2918
+	err = db.Count(&total).Offset(offset).Limit(limit).Group("patient_id").Find(&schedule).Error
2919
+
2920
+	return schedule, total, err
2921
+}
2922
+
2923
+func GetContextScheduleListPatientId(startTime int64, endTime int64, org_id int64) (schedule []*models.ConScheduleList, total int64, err error) {
2924
+
2925
+	db := XTReadDB().Model(&schedule).Where("status=1")
2926
+
2927
+	if startTime > 0 {
2928
+		db = db.Where("schedule_date >=?", startTime)
2929
+	}
2930
+	if endTime > 0 {
2931
+		db = db.Where("schedule_date<=?", endTime)
2932
+	}
2933
+
2934
+	if org_id > 0 {
2935
+		db = db.Where("user_org_id = ?", org_id)
2936
+	}
2937
+	err = db.Find(&schedule).Error
2938
+
2939
+	return schedule, total, err
2940
+}

+ 1 - 1
service/patientmanage_service.go View File

@@ -1982,7 +1982,7 @@ func GetPatientNotInspectionTotal(startime int64, endtime int64, orgid int64, pr
1982 1982
 }
1983 1983
 
1984 1984
 func GetPatientInspectionByID(startime int64, endtime int64, orgid int64, projectid int64, item_id int64, patient_id int64) (inspections []*models.Inspection, err error) {
1985
-	db := XTReadDB().Table("xt_inspection as x").Select("patient_id,inspect_date,inspect_value").Joins("xt_patient p On p.id = xt_inspection.patient_id and p.status = 1 and p.lapseto = 1").Where("x.status = 1")
1985
+	db := XTReadDB().Table("xt_inspection as x").Select("patient_id,inspect_date,inspect_value").Joins("join xt_patients p On p.id = x.patient_id and p.status = 1 and p.lapseto = 1").Where("x.status = 1")
1986 1986
 	if startime > 0 {
1987 1987
 		db = db.Where("x.inspect_date >= ?", startime)
1988 1988
 	}