see999 3 years ago
parent
commit
0a6e1c4066

+ 1 - 1
conf/app.conf View File

@@ -1,5 +1,5 @@
1 1
 appname = 小程序
2
-httpport = 9539
2
+httpport = 9529
3 3
 runmode = dev
4 4
 
5 5
 #

+ 292 - 7
controllers/xcx_mobile_api_controller.go/xcx_api_controller.go View File

@@ -30,6 +30,9 @@ func XcxApiControllersRegisterRouters() {
30 30
 
31 31
 	//获取排班数据
32 32
 	beego.Router("/xcx/api/mobile/schedule", &XcxApiController{}, "Get:GetScheduleInfo")
33
+
34
+	//获取透析记录
35
+	beego.Router("/xcx/api/mobile/dialysis", &XcxApiController{}, "Get:GetMobileSchedule")
33 36
 }
34 37
 
35 38
 type XcxApiController struct {
@@ -138,7 +141,7 @@ func (this *XcxApiController) GetLoginInfor() {
138 141
 	fmt.Println(mobile)
139 142
 	info, err := service.GetMobilePatientInfo(mobile)
140 143
 	if info.ID == 0 {
141
-		if err == nil {
144
+		if err != nil {
142 145
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
143 146
 			return
144 147
 		}
@@ -181,10 +184,18 @@ func (this *XcxApiController) GetLoginInfor() {
181 184
 }
182 185
 
183 186
 func (this *XcxApiController) GetPatientList() {
184
-	var appid = "wx20b60369111b063a"
185
-	var key = "HobHcmPatZ0O5emMYcFo1Q=="
186
-	var iv = "wJjr8o47Jv8zBoZF5la+jw=="
187
-	var strs = "DKj+ZzSKd77D2X84UqySTfTOxcZ9W5yAArqt74g3Fek+/8N97XI3nKzLO4QadJxwl9f8BDqrpl2dauqNBC4HbkggFcEB9j1zsYDKAm5cM0NPOkjcHeGF8dxpuJGdXWFKZErD957XEPtyODbE3IUMIx/n8haGtCa3W9v5Gqosqxrb6eNY9ogf8V1dy2guuxVAxWojuZ2DLyYovksFLccD5Q=="
187
+	//var appid = "wx4f4bc4dec97d474b"
188
+	//var key = "tiihtNczf5v6AKRyjwEUhQ=="
189
+	//var iv = "r7BXXKkLb8qrSNn05n0qiA=="
190
+	//var strs = "CiyLU1Aw2KjvrjMdj8YKliAjtP4gsMZMQmRzooG2xrDcvSnxIMXFufNstNGTyaGS9uT5geRa0W4oTOb1WT7fJlAC+oNPdbB+3hVbJSRgv+4lGOETKUQz6OYStslQ142dNCuabNPGBzlooOmB231qMM85d2/fV6ChevvXvQP8Hkue1poOFtnEtpyxVLW1zAo6/1Xx1COxFvrc2d7UL/lmHInNlxuacJXwu0fjpXfz/YqYzBIBzD6WUfTIF9GRHpOn/Hz7saL8xz+W//FRAUid1OksQaQx4CMs8LOddcQhULW4ucetDf96JcR3g0gfRK4PC7E/r7Z6xNrXd2UIeorGj5Ef7b1pJAYB6Y5anaHqZ9J6nKEBvB4DnNLIVWSgARns/8wR2SiRS7MNACwTyrGvt9ts8p12PKFdlqYTopNHR1Vf7XjfhQlVsAJdNiKdYmYVoKlaRv85IfVunYzO0IKXsyl7JCUjCpoG20f0a04COwfneQAGGwd5oa+T8yO5hzuyDb/XcxxmK01EpqOyuxINew=="
191
+
192
+	appid := "wx4f4bc4dec97d474b"
193
+	key := "4BactRvIKCBXzvpyl2SQyQ=="
194
+	strs := "Gr5gmKz9OjWGipAxt3ujQtHBBXV/Uvhsm+qvvZy6gF+HBc8c6gZhZkqIqLbs8nHkId5zm/mGVNpghvM/egYTLOOI7LxhvjRsPE1691j+jltU9OIavGIWFp3I4m3OdP9CuPohhrpZPgwsGajJmtGNNjPvGA61ssErVZ7SBceq+leag532zCmgEXN3NpZP0TRgpIpwpegCAEW07oyI0LiRYA=="
195
+	iv := "aXiAcKIWKfseTyzelqcZ0w=="
196
+	//data, err := service.Dncrypt(strs, key, iv)
197
+	//fmt.Println(err)
198
+
188 199
 	data, err := service.DecryptData(appid, key, iv, strs)
189 200
 	patient_id, _ := this.GetInt64("patient_id")
190 201
 	patient, err := service.GetPatientListByPatientId(patient_id)
@@ -203,17 +214,20 @@ func (this *XcxApiController) GetPatientList() {
203 214
 func (this *XcxApiController) GetDataInfo() {
204 215
 	
205 216
 	appid := this.GetString("appid")
217
+	fmt.Println(appid)
206 218
 	key := this.GetString("key")
207 219
 	iv := this.GetString("iv")
208 220
 	encryptedData := this.GetString("encryptedData")
209 221
 	list, _ := service.DecryptData(appid, key, iv, encryptedData)
210
-	fmt.Println(list)
222
+	//list, err := service.Dncrypt(encryptedData, key, iv)
223
+
211 224
 	this.ServeSuccessJSON(map[string]interface{}{
212 225
 		"list": list,
213 226
 	})
214 227
 }
215 228
 
216 229
 func (this *XcxApiController) GetScheduleInfo() {
230
+	patient_id, _ := this.GetInt64("patient_id")
217 231
 	thisWeekMonday := service.GetFirstDateOfWeek()
218 232
 	weekDayWeek := service.GetWeekDayOfWeek()
219 233
 	TimeMonday, _ := time.Parse("2006-01-02", thisWeekMonday)
@@ -229,8 +243,279 @@ func (this *XcxApiController) GetScheduleInfo() {
229 243
 	loc, _ := time.LoadLocation("Local")
230 244
 
231 245
 	startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", weekMonday+" 00:00:00", loc)
232
-
246
+	fmt.Println("startiem", startTime)
233 247
 	endTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", weekDay+" 00:00:00", loc)
234 248
 
235 249
 	fmt.Println(startTime.Unix(), endTime.Unix())
250
+
251
+	schedule, err := service.GetScheduleInfo(1630252800, 1631980800, patient_id)
252
+	if err != nil {
253
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
254
+		return
255
+	}
256
+	array := []interface{}{
257
+		map[string]string{"schedule_type": "1", "schedule_date": "1630252800", "schedule_week": "1", "mode_id": "", "name": ""},
258
+		map[string]string{"schedule_type": "2", "schedule_date": "1630252800", "schedule_week": "1", "mode_id": "", "name": ""},
259
+		map[string]string{"schedule_type": "3", "schedule_date": "1630252800", "schedule_week": "1", "mode_id": "", "name": ""},
260
+		map[string]string{"schedule_type": "1", "schedule_date": "1630339200", "schedule_week": "2", "mode_id": "", "name": ""},
261
+		map[string]string{"schedule_type": "2", "schedule_date": "1630339200", "schedule_week": "2", "mode_id": "", "name": ""},
262
+		map[string]string{"schedule_type": "3", "schedule_date": "1630339200", "schedule_week": "2", "mode_id": "", "name": ""},
263
+		map[string]string{"schedule_type": "1", "schedule_date": "1630425600", "schedule_week": "3", "mode_id": "", "name": ""},
264
+		map[string]string{"schedule_type": "2", "schedule_date": "1630425600", "schedule_week": "3", "mode_id": "", "name": ""},
265
+		map[string]string{"schedule_type": "3", "schedule_date": "1630425600", "schedule_week": "3", "mode_id": "", "name": ""},
266
+		map[string]string{"schedule_type": "1", "schedule_date": "1630512000", "schedule_week": "4", "mode_id": "", "name": ""},
267
+		map[string]string{"schedule_type": "2", "schedule_date": "1630512000", "schedule_week": "4", "mode_id": "", "name": ""},
268
+		map[string]string{"schedule_type": "3", "schedule_date": "1630512000", "schedule_week": "4", "mode_id": "", "name": ""},
269
+		map[string]string{"schedule_type": "1", "schedule_date": "1630598400", "schedule_week": "5", "mode_id": "", "name": ""},
270
+		map[string]string{"schedule_type": "2", "schedule_date": "1630598400", "schedule_week": "5", "mode_id": "", "name": ""},
271
+		map[string]string{"schedule_type": "3", "schedule_date": "1630598400", "schedule_week": "5", "mode_id": "", "name": ""},
272
+		map[string]string{"schedule_type": "1", "schedule_date": "1630684800", "schedule_week": "6", "mode_id": "", "name": ""},
273
+		map[string]string{"schedule_type": "2", "schedule_date": "1630684800", "schedule_week": "6", "mode_id": "", "name": ""},
274
+		map[string]string{"schedule_type": "3", "schedule_date": "1630684800", "schedule_week": "6", "mode_id": "", "name": ""},
275
+		map[string]string{"schedule_type": "1", "schedule_date": "1630771200", "schedule_week": "7", "mode_id": "", "name": ""},
276
+		map[string]string{"schedule_type": "2", "schedule_date": "1630771200", "schedule_week": "7", "mode_id": "", "name": ""},
277
+		map[string]string{"schedule_type": "3", "schedule_date": "1630771200", "schedule_week": "7", "mode_id": "", "name": ""},
278
+
279
+		map[string]string{"schedule_type": "1", "schedule_date": "1630857600", "schedule_week": "1", "mode_id": "", "name": ""},
280
+		map[string]string{"schedule_type": "2", "schedule_date": "1630857600", "schedule_week": "1", "mode_id": "", "name": ""},
281
+		map[string]string{"schedule_type": "3", "schedule_date": "1630857600", "schedule_week": "1", "mode_id": "", "name": ""},
282
+		map[string]string{"schedule_type": "1", "schedule_date": "1630944000", "schedule_week": "2", "mode_id": "", "name": ""},
283
+		map[string]string{"schedule_type": "2", "schedule_date": "1630944000", "schedule_week": "2", "mode_id": "", "name": ""},
284
+		map[string]string{"schedule_type": "3", "schedule_date": "1630944000", "schedule_week": "2", "mode_id": "", "name": ""},
285
+		map[string]string{"schedule_type": "1", "schedule_date": "1631030400", "schedule_week": "3", "mode_id": "", "name": ""},
286
+		map[string]string{"schedule_type": "2", "schedule_date": "1631030400", "schedule_week": "3", "mode_id": "", "name": ""},
287
+		map[string]string{"schedule_type": "3", "schedule_date": "1631030400", "schedule_week": "3", "mode_id": "", "name": ""},
288
+		map[string]string{"schedule_type": "1", "schedule_date": "1631116800", "schedule_week": "4", "mode_id": "", "name": ""},
289
+		map[string]string{"schedule_type": "2", "schedule_date": "1631116800", "schedule_week": "4", "mode_id": "", "name": ""},
290
+		map[string]string{"schedule_type": "3", "schedule_date": "1631116800", "schedule_week": "4", "mode_id": "", "name": ""},
291
+		map[string]string{"schedule_type": "1", "schedule_date": "1631203200", "schedule_week": "5", "mode_id": "", "name": ""},
292
+		map[string]string{"schedule_type": "2", "schedule_date": "1631203200", "schedule_week": "5", "mode_id": "", "name": ""},
293
+		map[string]string{"schedule_type": "3", "schedule_date": "1631203200", "schedule_week": "5", "mode_id": "", "name": ""},
294
+		map[string]string{"schedule_type": "1", "schedule_date": "1631289600", "schedule_week": "6", "mode_id": "", "name": ""},
295
+		map[string]string{"schedule_type": "2", "schedule_date": "1631289600", "schedule_week": "6", "mode_id": "", "name": ""},
296
+		map[string]string{"schedule_type": "3", "schedule_date": "1631289600", "schedule_week": "6", "mode_id": "", "name": ""},
297
+		map[string]string{"schedule_type": "1", "schedule_date": "1631376000", "schedule_week": "7", "mode_id": "", "name": ""},
298
+		map[string]string{"schedule_type": "2", "schedule_date": "1631376000", "schedule_week": "7", "mode_id": "", "name": ""},
299
+		map[string]string{"schedule_type": "3", "schedule_date": "1631376000", "schedule_week": "7", "mode_id": "", "name": ""},
300
+
301
+		map[string]string{"schedule_type": "1", "schedule_date": "1631462400", "schedule_week": "1", "mode_id": "", "name": ""},
302
+		map[string]string{"schedule_type": "2", "schedule_date": "1631462400", "schedule_week": "1", "mode_id": "", "name": ""},
303
+		map[string]string{"schedule_type": "3", "schedule_date": "1631462400", "schedule_week": "1", "mode_id": "", "name": ""},
304
+		map[string]string{"schedule_type": "1", "schedule_date": "1631548800", "schedule_week": "2", "mode_id": "", "name": ""},
305
+		map[string]string{"schedule_type": "2", "schedule_date": "1631548800", "schedule_week": "2", "mode_id": "", "name": ""},
306
+		map[string]string{"schedule_type": "3", "schedule_date": "1631548800", "schedule_week": "2", "mode_id": "", "name": ""},
307
+		map[string]string{"schedule_type": "1", "schedule_date": "1631635200", "schedule_week": "3", "mode_id": "", "name": ""},
308
+		map[string]string{"schedule_type": "2", "schedule_date": "1631635200", "schedule_week": "3", "mode_id": "", "name": ""},
309
+		map[string]string{"schedule_type": "3", "schedule_date": "1631635200", "schedule_week": "3", "mode_id": "", "name": ""},
310
+		map[string]string{"schedule_type": "1", "schedule_date": "1631721600", "schedule_week": "4", "mode_id": "", "name": ""},
311
+		map[string]string{"schedule_type": "2", "schedule_date": "1631721600", "schedule_week": "4", "mode_id": "", "name": ""},
312
+		map[string]string{"schedule_type": "3", "schedule_date": "1631721600", "schedule_week": "4", "mode_id": "", "name": ""},
313
+		map[string]string{"schedule_type": "1", "schedule_date": "1631808000", "schedule_week": "5", "mode_id": "", "name": ""},
314
+		map[string]string{"schedule_type": "2", "schedule_date": "1631808000", "schedule_week": "5", "mode_id": "", "name": ""},
315
+		map[string]string{"schedule_type": "3", "schedule_date": "1631808000", "schedule_week": "5", "mode_id": "", "name": ""},
316
+		map[string]string{"schedule_type": "1", "schedule_date": "1631894400", "schedule_week": "6", "mode_id": "", "name": ""},
317
+		map[string]string{"schedule_type": "2", "schedule_date": "1631894400", "schedule_week": "6", "mode_id": "", "name": ""},
318
+		map[string]string{"schedule_type": "3", "schedule_date": "1631894400", "schedule_week": "6", "mode_id": "", "name": ""},
319
+		map[string]string{"schedule_type": "1", "schedule_date": "1631980800", "schedule_week": "7", "mode_id": "", "name": ""},
320
+		map[string]string{"schedule_type": "2", "schedule_date": "1631980800", "schedule_week": "7", "mode_id": "", "name": ""},
321
+		map[string]string{"schedule_type": "3", "schedule_date": "1631980800", "schedule_week": "7", "mode_id": "", "name": ""},
322
+	}
323
+	this.ServeSuccessJSON(map[string]interface{}{
324
+		"list":  schedule,
325
+		"array": array,
326
+	})
327
+}
328
+
329
+func (this *XcxApiController) GetMobileSchedule() {
330
+
331
+	patientID, _ := this.GetInt64("patient_id")
332
+	recordDateStr := this.GetString("date")
333
+	if patientID <= 0 {
334
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
335
+		return
336
+	}
337
+	if len(recordDateStr) == 0 {
338
+		recordDateStr = time.Now().Format("2006-01-02")
339
+	}
340
+	date, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
341
+	if parseDateErr != nil {
342
+		this.ErrorLog("日期(%v)解析错误:%v", recordDateStr, parseDateErr)
343
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
344
+		return
345
+	}
346
+
347
+	adminInfo := this.GetMobileAdminUserInfo()
348
+	patient, getPatientErr := service.MobileGetPatientDetail(adminInfo.Org.Id, patientID)
349
+	if getPatientErr != nil {
350
+		this.ErrorLog("获取患者信息失败:%v", getPatientErr)
351
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
352
+		return
353
+	} else if patient == nil {
354
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
355
+		return
356
+	}
357
+
358
+	schedual, getSchedualErr := service.MobileGetSchedualDetail(adminInfo.Org.Id, patientID, date.Unix())
359
+
360
+	if getSchedualErr != nil {
361
+		this.ErrorLog("获取患者排班信息失败:%v", getSchedualErr)
362
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
363
+		return
364
+	}
365
+
366
+	receiverTreatmentAccess, getRTARErr := service.MobileGetReceiverTreatmentAccessRecord(adminInfo.Org.Id, patientID, date.Unix())
367
+	if getRTARErr != nil {
368
+		this.ErrorLog("获取接诊评估失败:%v", getRTARErr)
369
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
370
+		return
371
+	}
372
+
373
+	predialysisEvaluation, getPEErr := service.MobileGetPredialysisEvaluation(adminInfo.Org.Id, patientID, date.Unix())
374
+	if getPEErr != nil {
375
+		this.ErrorLog("获取透前评估失败:%v", getPEErr)
376
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
377
+		return
378
+	}
379
+
380
+	lastPredialysisEvaluation, getLPEErr := service.MobileGetLastTimePredialysisEvaluation(adminInfo.Org.Id, patientID, date.Unix())
381
+	if getLPEErr != nil {
382
+		this.ErrorLog("获取上一次透前评估失败:%v", getLPEErr)
383
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
384
+		return
385
+	}
386
+
387
+	doctorAdvices, getDoctorAdvicesErr := service.MobileGetDoctorAdvicesByGroups(adminInfo.Org.Id, patientID, date.Unix())
388
+	if getDoctorAdvicesErr != nil {
389
+		this.ErrorLog("获取临时医嘱失败:%v", getDoctorAdvicesErr)
390
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
391
+		return
392
+	}
393
+
394
+	dialysisOrder, getDialysisOrderErr := service.MobileGetSchedualDialysisRecord(adminInfo.Org.Id, patientID, date.Unix())
395
+	if getDialysisOrderErr != nil {
396
+		this.ErrorLog("获取透析记录失败:%v", getDialysisOrderErr)
397
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
398
+		return
399
+	}
400
+
401
+	doubleCheck, getDoubleCheckErr := service.MobileGetDoubleCheck(adminInfo.Org.Id, patientID, date.Unix())
402
+	if getDoubleCheckErr != nil {
403
+		this.ErrorLog("获取双人核对记录失败:%v", getDoubleCheckErr)
404
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
405
+		return
406
+	}
407
+
408
+	monitorRecords, getMonitorRecordsErr := service.MobileGetMonitorRecords(adminInfo.Org.Id, patientID, date.Unix())
409
+	if getMonitorRecordsErr != nil {
410
+		this.ErrorLog("获取透析监测记录失败:%v", getMonitorRecordsErr)
411
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
412
+		return
413
+	}
414
+	var lastMonitorRecord *models.MonitoringRecord
415
+
416
+	lastMonitorRecord, getLastErr := service.MobileGetLastMonitorRecord(adminInfo.Org.Id, patientID, date.Unix())
417
+	if getLastErr != nil {
418
+		this.ErrorLog("获取上一次透析的监测记录失败:%v", getLastErr)
419
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
420
+		return
421
+	}
422
+
423
+	assessmentAfterDislysis, getAADErr := service.MobileGetAssessmentAfterDislysis(adminInfo.Org.Id, patientID, date.Unix())
424
+	if getAADErr != nil {
425
+		this.ErrorLog("获取透后评估失败:%v", getAADErr)
426
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
427
+		return
428
+	}
429
+
430
+	lastAssessmentAfterDislysis, getLAADErr := service.MobileGetLastTimeAssessmentAfterDislysis(adminInfo.Org.Id, patientID, date.Unix())
431
+	if getLAADErr != nil {
432
+		this.ErrorLog("获取上一次透后评估失败:%v", getLAADErr)
433
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
434
+		return
435
+	}
436
+
437
+	treatmentSummary, getTreatmentSummaryErr := service.MobileGetTreatmentSummary(adminInfo.Org.Id, patientID, date.Unix())
438
+	if getTreatmentSummaryErr != nil {
439
+		this.ErrorLog("获取治疗小结失败:%v", getTreatmentSummaryErr)
440
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
441
+		return
442
+	}
443
+
444
+	dialysisPrescribe, _ := service.MobileGetDialysisPrescribeByModeId(adminInfo.Org.Id, patientID, date.Unix(), schedual.ModeId)
445
+
446
+	dialysisSolution, _ := service.MobileGetDialysisSolutionByModeId(adminInfo.Org.Id, patientID, schedual.ModeId)
447
+
448
+	lastDialysisPrescribe, _ := service.MobileGetLastDialysisPrescribeByModeId(adminInfo.Org.Id, patientID, schedual.ModeId)
449
+
450
+	//获取系统透析处方模版
451
+	systemDialysisPrescribe, _ := service.MobileGetSystemDialysisPrescribeByModeId(adminInfo.Org.Id, schedual.ModeId)
452
+
453
+	_, is_open_config := service.FindXTHisRecordByOrgId(adminInfo.Org.Id)
454
+
455
+	_, is_project_open_config := service.FindXTHisProjectByOrgId(adminInfo.Org.Id)
456
+
457
+	projects, _ := service.GetHisPrescriptionProjects(adminInfo.Org.Id, patientID, date.Unix())
458
+
459
+	stockType, _ := service.GetStockType(adminInfo.Org.Id)
460
+
461
+	prepare, _ := service.GetDialyStockOut(adminInfo.Org.Id, date.Unix(), patientID)
462
+
463
+	//获取最后一次血管通路
464
+	lastAssessment, parseDateErr := service.GetLastPassWayAssessment(adminInfo.Org.Id, patientID)
465
+
466
+	prescribeOne, parseDateErr := service.MobileGetDialysisPrescribeByModeIdOne(adminInfo.Org.Id, patientID, date.Unix())
467
+	var his_advices []*models.HisDoctorAdviceInfo
468
+	if is_open_config.IsOpen == 1 {
469
+		his_advices, _ = service.GetAllHisDoctorAdvice(adminInfo.Org.Id, patientID, date.Unix())
470
+	}
471
+
472
+	if getLPEErr != nil {
473
+		this.ErrorLog("获取上一次透前评估失败:%v", getLPEErr)
474
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
475
+		return
476
+	}
477
+
478
+	lastDryWeightDislysis, getDryErr := service.MobileGetLastDryWeight(adminInfo.Org.Id, patientID)
479
+	if getDryErr != nil {
480
+		this.ErrorLog("获取最后一条干体重失败:%v", getDryErr)
481
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
482
+		return
483
+	}
484
+
485
+	_, gobalConfig := service.FindAutomaticReduceRecordByOrgId(adminInfo.Org.Id)
486
+
487
+	operators, _ := service.GetAllStarfEs(adminInfo.Org.Id)
488
+
489
+	returnData := map[string]interface{}{
490
+		"patient":                        patient,
491
+		"schedual":                       schedual,
492
+		"prescription":                   dialysisPrescribe,
493
+		"solution":                       dialysisSolution,
494
+		"last_prescription":              lastDialysisPrescribe,
495
+		"receiver_treatment_access":      receiverTreatmentAccess,
496
+		"predialysis_evaluation":         predialysisEvaluation,
497
+		"doctor_advices":                 doctorAdvices,
498
+		"double_check":                   doubleCheck,
499
+		"assessment_after_dislysis":      assessmentAfterDislysis,
500
+		"treatment_summary":              treatmentSummary,
501
+		"monitor_records":                monitorRecords,
502
+		"dialysis_order":                 dialysisOrder,
503
+		"operators":                      operators,
504
+		"last_predialysis_evaluation":    lastPredialysisEvaluation,
505
+		"last_assessment_after_dislysis": lastAssessmentAfterDislysis,
506
+		"last_monitor_record":            lastMonitorRecord,
507
+		"config":                         gobalConfig,
508
+		"dry_weight":                     lastDryWeightDislysis,
509
+		"system_prescription":            systemDialysisPrescribe,
510
+		"his_advices":                    his_advices,
511
+		"is_open_config":                 is_open_config,
512
+		"stockType":                      stockType,
513
+		"prepare":                        prepare,
514
+		"lastAssessment":                 lastAssessment,
515
+		"prescribeOne":                   prescribeOne,
516
+		"is_project_open_config":         is_project_open_config,
517
+		"project":                        projects,
518
+	}
519
+	this.ServeSuccessJSON(returnData)
520
+
236 521
 }

+ 28 - 0
models/xcx_user_models.go View File

@@ -112,3 +112,31 @@ func (XcxPatients) TableName() string {
112 112
 
113 113
 	return "xt_patients"
114 114
 }
115
+
116
+type VmBloodSchedule struct {
117
+	ScheduleDate int64  `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
118
+	ScheduleType int64  `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
119
+	ScheduleWeek int64  `gorm:"column:schedule_week" json:"schedule_week" form:"schedule_week"`
120
+	ModeId       int64  `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
121
+	Name         string `json:"name" form:"name"`
122
+}
123
+
124
+type BloodSchedule struct {
125
+	ID           int64 `gorm:"column:id" json:"id" form:"id"`
126
+	UserOrgId    int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
127
+	PartitionId  int64 `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
128
+	BedId        int64 `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
129
+	PatientId    int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
130
+	ScheduleDate int64 `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
131
+	ScheduleType int64 `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
132
+	ScheduleWeek int64 `gorm:"column:schedule_week" json:"schedule_week" form:"schedule_week"`
133
+	ModeId       int64 `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
134
+	Status       int64 `gorm:"column:status" json:"status" form:"status"`
135
+	CreatedTime  int64 `gorm:"column:created_time" json:"created_time" form:"created_time"`
136
+	UpdatedTime  int64 `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
137
+}
138
+
139
+func (BloodSchedule) TableName() string {
140
+
141
+	return "xt_schedule"
142
+}

+ 81 - 2
service/xcx_mobile_api_service.go View File

@@ -7,6 +7,7 @@ import (
7 7
 	"encoding/base64"
8 8
 	"encoding/json"
9 9
 	"errors"
10
+	"fmt"
10 11
 	"github.com/jinzhu/gorm"
11 12
 	"strings"
12 13
 	"time"
@@ -53,7 +54,7 @@ func GetPatientListByPatientId(id int64) (models.XcxPatients, error) {
53 54
 }
54 55
 
55 56
 func DecryptData(app_id, session_key, iv, encrypted_data string) (map[string]interface{}, error) {
56
-	if len := strings.Count(session_key, "") - 1; len != 30 {
57
+	if len := strings.Count(session_key, "") - 1; len != 24 {
57 58
 		return nil, errors.New("Invalid value session_key!")
58 59
 	}
59 60
 	aesKey, err := base64.StdEncoding.DecodeString(session_key)
@@ -61,7 +62,7 @@ func DecryptData(app_id, session_key, iv, encrypted_data string) (map[string]int
61 62
 		return nil, err
62 63
 	}
63 64
 
64
-	if len := strings.Count(iv, "") - 1; len != 30 {
65
+	if len := strings.Count(iv, "") - 1; len != 24 {
65 66
 		return nil, errors.New("Invalid value iv!")
66 67
 	}
67 68
 	ivKey, err := base64.StdEncoding.DecodeString(iv)
@@ -69,12 +70,17 @@ func DecryptData(app_id, session_key, iv, encrypted_data string) (map[string]int
69 70
 		return nil, err
70 71
 	}
71 72
 
73
+	if len := strings.Count(encrypted_data, "") - 1; len != 24 {
74
+		return nil, errors.New("Invalid value encrypted_data!")
75
+	}
76
+
72 77
 	decodeData, err := base64.StdEncoding.DecodeString(encrypted_data)
73 78
 	if err != nil {
74 79
 		return nil, err
75 80
 	}
76 81
 
77 82
 	dataBytes, err := AesDecrypt(decodeData, aesKey, ivKey)
83
+	fmt.Println("err232332232332232232323", err)
78 84
 	if err != nil {
79 85
 		return nil, err
80 86
 	}
@@ -88,21 +94,25 @@ func DecryptData(app_id, session_key, iv, encrypted_data string) (map[string]int
88 94
 	}
89 95
 
90 96
 	return result, err
97
+
91 98
 }
92 99
 
93 100
 func AesDecrypt(crypted, key, iv []byte) ([]byte, error) {
94 101
 	block, err := aes.NewCipher(key)
102
+	fmt.Println("w2222", err)
95 103
 	if err != nil {
96 104
 		return nil, err
97 105
 	}
98 106
 
99 107
 	blockMode := cipher.NewCBCDecrypter(block, iv)
100 108
 	origData := make([]byte, len(crypted))
109
+	fmt.Println("4443434344334434334343434", origData)
101 110
 	blockMode.CryptBlocks(origData, crypted)
102 111
 
103 112
 	// 去除填充
104 113
 	length := len(origData)
105 114
 	unp := int(origData[length-1])
115
+	fmt.Println("hhh23h2323232332", origData[:(length-unp)], nil)
106 116
 	return origData[:(length - unp)], nil
107 117
 
108 118
 }
@@ -148,3 +158,72 @@ func GetMobilePatient(mobile string) (*models.XcxPatients, error) {
148 158
 	return &patient, nil
149 159
 
150 160
 }
161
+
162
+func Dncrypt(rawData, key, iv string) (string, error) {
163
+	data, err := base64.StdEncoding.DecodeString(rawData)
164
+	key_b, err_1 := base64.StdEncoding.DecodeString(key)
165
+	iv_b, _ := base64.StdEncoding.DecodeString(iv)
166
+	if err != nil {
167
+		return "", err
168
+	}
169
+	if err_1 != nil {
170
+		return "", err_1
171
+	}
172
+	dnData, err := AesCBCDncrypt(data, key_b, iv_b)
173
+	if err != nil {
174
+		return "", err
175
+	}
176
+	return string(dnData), nil
177
+}
178
+
179
+// 解密
180
+func AesCBCDncrypt(encryptData, key, iv []byte) ([]byte, error) {
181
+	block, err := aes.NewCipher(key)
182
+	if err != nil {
183
+		panic(err)
184
+	}
185
+	blockSize := block.BlockSize()
186
+	if len(encryptData) < blockSize {
187
+		panic("ciphertext too short")
188
+	}
189
+	if len(encryptData)%blockSize != 0 {
190
+		panic("ciphertext is not a multiple of the block size")
191
+	}
192
+	mode := cipher.NewCBCDecrypter(block, iv)
193
+	mode.CryptBlocks(encryptData, encryptData)
194
+	// 解填充
195
+	encryptData = PKCS7UnPadding(encryptData)
196
+	return encryptData, nil
197
+}
198
+
199
+//去除填充
200
+func PKCS7UnPadding(origData []byte) []byte {
201
+	length := len(origData)
202
+	unpadding := int(origData[length-1])
203
+	if length-unpadding < 0 {
204
+		return origData[:0]
205
+	}
206
+	fmt.Println("changdu", length)
207
+	fmt.Println("data", unpadding)
208
+	return origData[:(length - unpadding)]
209
+}
210
+
211
+func GetScheduleInfo(startime int64, endtime int64, patient_id int64) (schedule []*models.VmBloodSchedule, err error) {
212
+
213
+	db := XTReadDB().Table("xt_schedule as x").Where("x.status = 1")
214
+	table := XTReadDB().Table("xt_patients as t").Where("t.status = 1")
215
+	fmt.Println(table)
216
+
217
+	if startime > 0 {
218
+		db = db.Where("x.schedule_date >=?", startime)
219
+	}
220
+	if endtime > 0 {
221
+		db = db.Where("x.schedule_date <=?", endtime)
222
+	}
223
+	if patient_id > 0 {
224
+		db = db.Where("x.patient_id = ?", patient_id)
225
+	}
226
+
227
+	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
228
+	return schedule, err
229
+}