Sfoglia il codice sorgente

Merge branch '20201014_xt_api_new_branch' of http://git.shengws.com/csx/XT_New into 20201014_xt_api_new_branch

XMLWAN 4 anni fa
parent
commit
08bc13e1a9

+ 37 - 0
controllers/mobile_api_controllers/check_weight_api_controller.go Vedi File

@@ -745,6 +745,43 @@ 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
+}
783
+
784
+
748 785
 
749 786
 func (c *CheckWeightApiController) GetPatientListById() {
750 787
 	patientId, _ := c.GetInt64("patient_id", 0)

+ 6 - 0
service/patient_service.go Vedi File

@@ -95,6 +95,12 @@ func GetPatientListBySchedules(orgID int64, syncTime int64) (patients []*models.
95 95
 	return
96 96
 }
97 97
 
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)
100
+	err = db.Count(&total).Find(&patients).Error
101
+	return
102
+}
103
+
98 104
 func GetPatientListById(orgID int64, patientId int64) (patients models.PatientListForFace, err error) {
99 105
 	err = readDb.Model(&models.PatientListForFaceList{}).Where("user_org_id=? and id = ? and status=1", orgID, patientId).First(&patients).Error
100 106
 	return