XMLWAN 3 年 前
コミット
add993cfba
共有3 個のファイルを変更した62 個の追加5 個の削除を含む
  1. 21 5
      controllers/xcx_mobile_api_controller.go/xcx_api_controller.go
  2. 28 0
      models/xcx_user_models.go
  3. 13 0
      service/xcx_mobile_api_service.go

+ 21 - 5
controllers/xcx_mobile_api_controller.go/xcx_api_controller.go ファイルの表示

@@ -144,7 +144,7 @@ func (this *XcxApiController) GetLoginInfor() {
144 144
 
145 145
 	mobile := this.GetString("mobile")
146 146
 	fmt.Println(mobile)
147
-	info, _ := service.GetMobilePatientInfo("18179463966")
147
+	info, _ := service.GetMobilePatientInfo(mobile)
148 148
 	if info.ID == 0 {
149 149
 
150 150
 		this.ServeSuccessJSON(map[string]interface{}{
@@ -152,7 +152,7 @@ func (this *XcxApiController) GetLoginInfor() {
152 152
 			"info":    info,
153 153
 		})
154 154
 	} else {
155
-		_, errcode := service.GetLoginInfor("18179463966")
155
+		_, errcode := service.GetLoginInfor(mobile)
156 156
 		if errcode == gorm.ErrRecordNotFound {
157 157
 			role := models.XcxAdminUserRole{
158 158
 				PatientName: info.Name,
@@ -170,6 +170,13 @@ func (this *XcxApiController) GetLoginInfor() {
170 170
 			}
171 171
 			err := service.CreateXcxAdminUser(role)
172 172
 			fmt.Println(err)
173
+			if err == nil {
174
+				this.ServeSuccessJSON(map[string]interface{}{
175
+					"is_bind": true,
176
+					"info":    info,
177
+				})
178
+			}
179
+
173 180
 		} else {
174 181
 			this.ServeSuccessJSON(map[string]interface{}{
175 182
 				"is_bind": true,
@@ -242,12 +249,19 @@ func (this *XcxApiController) GetScheduleInfo() {
242 249
 	fmt.Println("startiem", startTime)
243 250
 	endTime, _ := time.ParseInLocation(timeLayout+"15:04:05", weekDay+"00:00:00", loc)
244 251
 	fmt.Println(startTime.Unix(), endTime.Unix())
245
-	schedule, err := service.GetScheduleInfo(startTime.Unix(), endTime.Unix(), 1)
252
+	schedule, err := service.GetScheduleInfo(startTime.Unix(), endTime.Unix(), patient_id)
246 253
 
247 254
 	//获取当前今日的排班日期
248 255
 	time_now := time.Now().Format("2006-01-02")
249 256
 	fmt.Println("time_now", time_now)
257
+	timeNowUnix, _ := time.ParseInLocation(timeLayout+"15:04:05", time_now+"00:00:00", loc)
258
+	fmt.Println("timeNowUnix", timeNowUnix.Unix())
259
+
260
+	//获取今日下机日期
261
+	order, _ := service.GetTodayDialysis(timeNowUnix.Unix(), patient_id)
250 262
 
263
+	//获取下一次排班信息
264
+	patientSchedule, _ := service.GetNextPatientSchedule(1, timeNowUnix.Unix())
251 265
 	if err != nil {
252 266
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
253 267
 		return
@@ -347,8 +361,10 @@ func (this *XcxApiController) GetScheduleInfo() {
347 361
 		map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(lastseven, 10), "schedule_week": "7", "mode_id": "", "name": ""},
348 362
 	}
349 363
 	this.ServeSuccessJSON(map[string]interface{}{
350
-		"list":  schedule,
351
-		"array": array,
364
+		"list":            schedule,
365
+		"array":           array,
366
+		"order":           order,
367
+		"patientSchedule": patientSchedule,
352 368
 	})
353 369
 }
354 370
 

+ 28 - 0
models/xcx_user_models.go ファイルの表示

@@ -140,3 +140,31 @@ func (BloodSchedule) TableName() string {
140 140
 
141 141
 	return "xt_schedule"
142 142
 }
143
+
144
+type XcXDialysisOrder struct {
145
+	ID                     int64  `gorm:"column:id" json:"id" form:"id"`
146
+	DialysisDate           int64  `gorm:"column:dialysis_date" json:"dialysis_date" form:"dialysis_date"`
147
+	UserOrgId              int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
148
+	PatientId              int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
149
+	PrescriptionId         int64  `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
150
+	Stage                  int64  `gorm:"column:stage" json:"stage" form:"stage"`
151
+	Remark                 string `gorm:"column:remark" json:"remark" form:"remark"`
152
+	BedId                  int64  `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
153
+	StartNurse             int64  `gorm:"column:start_nurse" json:"start_nurse" form:"start_nurse"`
154
+	FinishNurse            int64  `gorm:"column:finish_nurse" json:"finish_nurse" form:"finish_nurse"`
155
+	Status                 int64  `gorm:"column:status" json:"status" form:"status"`
156
+	CreatedTime            int64  `gorm:"column:created_time" json:"created_time" form:"created_time"`
157
+	UpdatedTime            int64  `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
158
+	StartTime              int64  `gorm:"column:start_time" json:"start_time" form:"start_time"`
159
+	EndTime                int64  `gorm:"column:end_time" json:"end_time" form:"end_time"`
160
+	PunctureNurse          int64  `gorm:"column:puncture_nurse" json:"puncture_nurse" form:"puncture_nurse"`
161
+	Creator                int64  `gorm:"column:creator" json:"creator" form:"creator"`
162
+	Modifier               int64  `gorm:"column:modifier" json:"modifier" form:"modifier"`
163
+	FinishCreator          int64  `gorm:"column:finish_creator" json:"finish_creator" form:"finish_creator"`
164
+	FinishModifier         int64  `gorm:"column:finish_modifier" json:"finish_modifier" form:"finish_modifier"`
165
+	SchedualType           int64  `gorm:"column:schedual_type" json:"schedual_type" form:"schedual_type"`
166
+	WashpipeNurse          int64  `gorm:"column:washpipe_nurse" json:"washpipe_nurse" form:"washpipe_nurse"`
167
+	ChangeNurse            int64  `gorm:"column:change_nurse" json:"change_nurse" form:"change_nurse"`
168
+	DifficultPunctureNurse int64  `gorm:"column:difficult_puncture_nurse" json:"difficult_puncture_nurse" form:"difficult_puncture_nurse"`
169
+	NewFistulaNurse        string `gorm:"column:new_fistula_nurse" json:"new_fistula_nurse" form:"new_fistula_nurse"`
170
+}

+ 13 - 0
service/xcx_mobile_api_service.go ファイルの表示

@@ -211,3 +211,16 @@ func GetScheduleInfo(startime int64, endtime int64, patient_id int64) (schedule
211 211
 	err = db.Select("x.schedule_date,x.schedule_type,x.schedule_week,x.mode_id,t.name").Joins("left join xt_patients as t on t.id = x.patient_id").Scan(&schedule).Error
212 212
 	return schedule, err
213 213
 }
214
+
215
+func GetTodayDialysis(recordDate int64, patient_id int64) (models.XcXDialysisOrder, error) {
216
+
217
+	order := models.XcXDialysisOrder{}
218
+	err := XTReadDB().Model(&order).Where("dialysis_date = ? and patient_id = ? and status = 1", recordDate, patient_id).Find(&order).Error
219
+	return order, err
220
+}
221
+
222
+func GetNextPatientSchedule(patient_id int64, dialysis_date int64) (models.BloodSchedule, error) {
223
+	schedule := models.BloodSchedule{}
224
+	err := XTReadDB().Model(&schedule).Where("patient_id = ? and status = 1 and schedule_date>?", patient_id, dialysis_date).Order("schedule_date asc").First(&schedule).Error
225
+	return schedule, err
226
+}