Browse Source

体积小

XMLWAN 3 years ago
parent
commit
6f6e992893
1 changed files with 196 additions and 2 deletions
  1. 196 2
      controllers/xcx_mobile_api_controller.go/xcx_api_controller.go

+ 196 - 2
controllers/xcx_mobile_api_controller.go/xcx_api_controller.go View File

@@ -31,8 +31,8 @@ func XcxApiControllersRegisterRouters() {
31 31
 	//获取排班数据
32 32
 	beego.Router("/xcx/api/mobile/schedule", &XcxApiController{}, "Get:GetScheduleInfo")
33 33
 
34
-	//获取病历信息
35
-	//beego.Router("/xcx/api/mobile/")
34
+	//获取透析记录
35
+	beego.Router("/xcx/api/mobile/dialysis", &XcxApiController{}, "Get:GetMobileSchedule")
36 36
 }
37 37
 
38 38
 type XcxApiController struct {
@@ -325,3 +325,197 @@ func (this *XcxApiController) GetScheduleInfo() {
325 325
 		"array": array,
326 326
 	})
327 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
+
521
+}