Browse Source

称重接口

张保健 4 years ago
parent
commit
ae4e21960a

+ 76 - 52
controllers/mobile_api_controllers/check_weight_api_controller.go View File

@@ -562,17 +562,17 @@ func (c *CheckWeightApiController) SavePatientInfoDialysis() {
562 562
 			}
563 563
 		}
564 564
 
565
-		if dialysisPrescribe != nil {
566
-			dialysisPrescribe.UpdatedTime = time.Now().Unix()
567
-			dialysisPrescribe.RecordDate = theAssessmentDateTime
568
-			dialysisPrescribe.DewaterAmount = dewater_amount
569
-			dialysisPrescribe.TargetUltrafiltration = dewater_amount
570
-			dialysisPrescribe.Status = 1
571
-			updateErr := service.UpDateDialysisPrescription(dialysisPrescribe)
572
-			if updateErr != nil {
573
-				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
574
-			}
575
-		}
565
+		// if dialysisPrescribe != nil {
566
+		// 	dialysisPrescribe.UpdatedTime = time.Now().Unix()
567
+		// 	dialysisPrescribe.RecordDate = theAssessmentDateTime
568
+		// 	dialysisPrescribe.DewaterAmount = dewater_amount
569
+		// 	dialysisPrescribe.TargetUltrafiltration = dewater_amount
570
+		// 	dialysisPrescribe.Status = 1
571
+		// 	updateErr := service.UpDateDialysisPrescription(dialysisPrescribe)
572
+		// 	if updateErr != nil {
573
+		// 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
574
+		// 	}
575
+		// }
576 576
 
577 577
 		theEvaluation, getPEErr := service.MobileGetPredialysisEvaluation(adminUserInfo.Org.Id, id, theAssessmentDateTime)
578 578
 		if getPEErr != nil {
@@ -745,41 +745,64 @@ func (c *CheckWeightApiController) GetPatientListForSchedules() {
745 745
 	})
746 746
 }
747 747
 
748
-//func (c *CheckWeightApiController) GetPatientListForSchedulesFind() {
749
-//	patient_name := c.GetString("patient_name")                   //脉率
750
-//	thisTime := time.Now()
751
-//	scheduleDateStart := thisTime.Format("2006-01-02") + " 00:00:00"
752
-//	timeLayout := "2006-01-02 15:04:05"
753
-//	loc, _ := time.LoadLocation("Local")
754
-//	theStartTime, _ := time.ParseInLocation(timeLayout, scheduleDateStart, loc)
755
-//	syncTime := theStartTime.Unix()
756
-//	adminUserInfo := c.GetMobileAdminUserInfo()
757
-//	if len(patient_name) == 0 {
758
-//		patientList, total, error := service.GetPatientListBySchedules(adminUserInfo.Org.Id, syncTime)
759
-//	} else {
760
-//		patientList, total, error := service.GetPatientListBySchedulesFind(adminUserInfo.Org.Id, syncTime,patient_name)
761
-//	}
762
-//	patientSchedule := make([]map[string]interface{},0)
763
-//	for _, item := range patientList {
764
-//		patientTemp := make(map[string]interface{})
765
-//		patientTemp["patient_id"] = item.PatientId
766
-//		patientTemp["patient_name"] = item.Patient.Name
767
-//		patientTemp["schedule_type"] = item.ScheduleType
768
-//		patientSchedule = append(patientSchedule, patientTemp)
769
-//	}
770
-//
771
-//	if error != nil {
772
-//		c.ErrorLog("获取病人列表失败:%v", error)
773
-//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
774
-//		return
775
-//	}
776
-//	serviceTime := time.Now().Unix()
777
-//	c.ServeSuccessJSON(map[string]interface{}{
778
-//		"patientlist": patientSchedule,
779
-//		"total":       total,
780
-//		"servicetime": serviceTime,
781
-//	})
782
-//}
748
+func (c *CheckWeightApiController) GetPatientListForSchedulesFind() {
749
+	patient_name := c.GetString("patient_name")                   //脉率
750
+	thisTime := time.Now()
751
+	scheduleDateStart := thisTime.Format("2006-01-02") + " 00:00:00"
752
+	timeLayout := "2006-01-02 15:04:05"
753
+	loc, _ := time.LoadLocation("Local")
754
+	theStartTime, _ := time.ParseInLocation(timeLayout, scheduleDateStart, loc)
755
+	syncTime := theStartTime.Unix()
756
+	adminUserInfo := c.GetMobileAdminUserInfo()
757
+	if len(patient_name) == 0 {
758
+		patientList, total, error := service.GetPatientListBySchedules(adminUserInfo.Org.Id, syncTime)
759
+		patientSchedule := make([]map[string]interface{}, 0)
760
+		for _, item := range patientList {
761
+			patientTemp := make(map[string]interface{})
762
+			patientTemp["patient_id"] = item.PatientId
763
+			patientTemp["patient_name"] = item.Patient.Name
764
+			patientTemp["schedule_type"] = item.ScheduleType
765
+			patientSchedule = append(patientSchedule, patientTemp)
766
+		}
767
+
768
+		if error != nil {
769
+			c.ErrorLog("获取病人列表失败:%v", error)
770
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
771
+			return
772
+		}
773
+		serviceTime := time.Now().Unix()
774
+		c.ServeSuccessJSON(map[string]interface{}{
775
+			"patientlist": patientSchedule,
776
+			"total":       total,
777
+			"servicetime": serviceTime,
778
+		})
779
+	} else {
780
+		patientList, total, error := service.GetPatientListBySchedulesFind(adminUserInfo.Org.Id, syncTime,patient_name)
781
+		patientSchedule := make([]map[string]interface{},0)
782
+		for _, item := range patientList {
783
+			if item.Patient.ID > 0 {
784
+				patientTemp := make(map[string]interface{})
785
+				patientTemp["patient_id"] = item.PatientId
786
+				patientTemp["patient_name"] = item.Patient.Name
787
+				patientTemp["schedule_type"] = item.ScheduleType
788
+				patientSchedule = append(patientSchedule, patientTemp)
789
+			}
790
+		}
791
+
792
+		if error != nil {
793
+			c.ErrorLog("获取病人列表失败:%v", error)
794
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
795
+			return
796
+		}
797
+
798
+		serviceTime := time.Now().Unix()
799
+		c.ServeSuccessJSON(map[string]interface{}{
800
+			"patientlist": patientSchedule,
801
+			"total":       total,
802
+			"servicetime": serviceTime,
803
+		})
804
+	}
805
+}
783 806
 
784 807
 func (c *CheckWeightApiController) GetPatientListById() {
785 808
 	patientId, _ := c.GetInt64("patient_id", 0)
@@ -799,6 +822,7 @@ func (c *CheckWeightApiController) GetPatientListById() {
799 822
 		"patientinfo": patient,
800 823
 	})
801 824
 }
825
+
802 826
 func (c *CheckWeightApiController) GetPatientInfoDialysis() {
803 827
 	id, _ := c.GetInt64("patient", 0)
804 828
 	if id <= 0 {
@@ -865,12 +889,12 @@ func (c *CheckWeightApiController) GetPatientInfoDialysis() {
865 889
 		}
866 890
 
867 891
 		// 排队叫号的签到
868
-		ssoDomain := beego.AppConfig.String("call_domain")
869
-		api := ssoDomain + "/index/patientsign/" + strconv.FormatInt(adminUserInfo.Org.Id, 10) + "/" + strconv.FormatInt(id, 10)
870
-		values := make(url.Values)
871
-
872
-		http.PostForm(api, values)
873
-
892
+		go func (){
893
+			ssoDomain := beego.AppConfig.String("call_domain")
894
+			api := ssoDomain + "/index/patientsign/" + strconv.FormatInt(adminUserInfo.Org.Id, 10) + "/" + strconv.FormatInt(id, 10)
895
+			values := make(url.Values)
896
+			http.PostForm(api, values)
897
+		} ()
874 898
 	} else {
875 899
 		nextSchedule, _ := service.GetNextSchedule(adminUserInfo.Org.Id, endTime, id)
876 900
 		if len(nextSchedule) <= 0 {

+ 1 - 1
controllers/mobile_api_controllers/mobile_api_router_register.go View File

@@ -13,7 +13,7 @@ func MobileAPIControllersRegisterRouters() {
13 13
 	beego.Router("/m/api/checkbeforedialysis", &CheckWeightApiController{}, "get:GetPatientInfoBeforeDialysis")
14 14
 	beego.Router("/m/api/getpatientlist", &CheckWeightApiController{}, "get:GetPatientList")
15 15
 	beego.Router("/m/api/getschedulepatient", &CheckWeightApiController{}, "get:GetPatientListForSchedules")
16
-	//beego.Router("/m/api/getschedulepatientfind", &CheckWeightApiController{}, "get:GetPatientListForSchedulesFind")
16
+	beego.Router("/m/api/getschedulepatientfind", &CheckWeightApiController{}, "get:GetPatientListForSchedulesFind")
17 17
 	beego.Router("/m/api/getpatientinfo", &CheckWeightApiController{}, "get:GetPatientListById")
18 18
 	beego.Router("/m/api/checkdialysis", &CheckWeightApiController{}, "get:GetPatientInfoDialysis")
19 19
 	beego.Router("/m/api/savecheckdialysis", &CheckWeightApiController{}, "Post:SavePatientInfoDialysis")

+ 1 - 1
service/patient_service.go View File

@@ -96,7 +96,7 @@ func GetPatientListBySchedules(orgID int64, syncTime int64) (patients []*models.
96 96
 }
97 97
 
98 98
 func GetPatientListBySchedulesFind(orgID int64, syncTime int64, patient_name string) (patients []*models.SchedulePatients, total int64, err error) {
99
-	db := readDb.Model(&models.SchedulePatients{}).Where("user_org_id=?  AND  status=1  AND  schedule_date = ?", orgID, syncTime).Preload("Patient", "status = 1 AND user_org_id = ? and name like '%?%' ", orgID, patient_name)
99
+	db := readDb.Model(&models.SchedulePatients{}).Where("user_org_id=?  AND  status=1  AND  schedule_date = ?", orgID, syncTime).Preload("Patient", "status = 1 AND user_org_id = ? and name like ? ", orgID, "%"+patient_name+"%")
100 100
 	err = db.Count(&total).Find(&patients).Error
101 101
 	return
102 102
 }