Browse Source

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

csx 4 years ago
parent
commit
fdc0c783a9

+ 4 - 4
controllers/dialysis_api_controller.go View File

@@ -2609,8 +2609,8 @@ func (c *DialysisApiController) CreateRemindDoctorAdvice() {
2609 2609
 		}
2610 2610
 
2611 2611
 		//if adviceNameM["single_dose"] != nil && reflect.TypeOf(adviceNameM["single_dose"]).String() == "string" {
2612
-		//	singleDose, _ := strconv.ParseFloat(adviceNameM["single_dose"].(string), 64)
2613
-		//	advice.SingleDose = singleDose
2612
+		// singleDose, _ := strconv.ParseFloat(adviceNameM["single_dose"].(string), 64)
2613
+		// advice.SingleDose = singleDose
2614 2614
 		//}
2615 2615
 
2616 2616
 		if adviceNameM["single_dose"] != nil || reflect.TypeOf(adviceNameM["single_dose"]).String() == "float64" {
@@ -2624,8 +2624,8 @@ func (c *DialysisApiController) CreateRemindDoctorAdvice() {
2624 2624
 		}
2625 2625
 
2626 2626
 		//if adviceNameM["prescribing_number"] != nil && reflect.TypeOf(adviceNameM["prescribing_number"]).String() == "string" {
2627
-		//	prescribingNumber, _ := strconv.ParseFloat(adviceNameM["prescribing_number"].(string), 64)
2628
-		//	advice.PrescribingNumber = prescribingNumber
2627
+		// prescribingNumber, _ := strconv.ParseFloat(adviceNameM["prescribing_number"].(string), 64)
2628
+		// advice.PrescribingNumber = prescribingNumber
2629 2629
 		//}
2630 2630
 
2631 2631
 		if adviceNameM["prescribing_number"] != nil || reflect.TypeOf(adviceNameM["prescribing_number"]).String() == "float64" {

+ 2 - 4
controllers/doctors_api_controller.go View File

@@ -229,10 +229,8 @@ func (c *DoctorsApiController) GetAllData() {
229 229
 	fmt.Println("id", id)
230 230
 	adminUserInfo := c.GetAdminUserInfo()
231 231
 	orgid := adminUserInfo.CurrentOrgId
232
-	dry, total, err := service.GetAllData(orgid, id, page, limit)
233
-	fmt.Println("total是是多少", total)
234
-	fmt.Println("错误是什么", err)
235
-	fmt.Println("dry", err)
232
+	dry, total, _ := service.GetAllData(orgid, id, page, limit)
233
+
236 234
 	c.ServeSuccessJSON(map[string]interface{}{
237 235
 		"dry":   dry,
238 236
 		"total": total,

+ 21 - 15
controllers/his_api_controller.go View File

@@ -9,7 +9,6 @@ import (
9 9
 	"encoding/json"
10 10
 	"fmt"
11 11
 	"github.com/astaxie/beego"
12
-	"github.com/jinzhu/gorm"
13 12
 	"io/ioutil"
14 13
 	"math/rand"
15 14
 	"net/http"
@@ -570,20 +569,27 @@ func (c *HisApiController) CreateHisPatientCaseHistory() {
570 569
 		Remark:                  remark,
571 570
 	}
572 571
 
573
-	//查询该患者是否有病历
574
-	_, errcode := service.GetHisPatientCaseHistoryById(his_patient_id)
575
-	if errcode == gorm.ErrRecordNotFound {
576
-		err = service.SaveHisPatientCaseHistory(caseHistory)
577
-		if err != nil {
578
-			c.ServeSuccessJSON(map[string]interface{}{
579
-				"msg": "保存成功",
580
-			})
581
-		}
582
-	} else if errcode == nil {
583
-		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
584
-		return
572
+	err = service.SaveHisPatientCaseHistory(caseHistory)
573
+	if err != nil {
574
+		c.ServeSuccessJSON(map[string]interface{}{
575
+			"msg": "保存成功",
576
+		})
585 577
 	}
586 578
 
579
+	//查询该患者是否有病历
580
+	//_, errcode := service.GetHisPatientCaseHistoryById(his_patient_id)
581
+	//if errcode == gorm.ErrRecordNotFound {
582
+	//	err = service.SaveHisPatientCaseHistory(caseHistory)
583
+	//	if err != nil {
584
+	//		c.ServeSuccessJSON(map[string]interface{}{
585
+	//			"msg": "保存成功",
586
+	//		})
587
+	//	}
588
+	//} else if errcode == nil {
589
+	//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
590
+	//	return
591
+	//}
592
+
587 593
 }
588 594
 func (c *HisApiController) GetHisPatientCaseHistoryList() {
589 595
 	patient_id, _ := c.GetInt64("patient_id", 0)
@@ -674,10 +680,10 @@ func (c *HisApiController) GetCaseHistoryTemplate() {
674 680
 	endTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
675 681
 	admin := c.GetAdminUserInfo()
676 682
 	template, _ := service.GetHisPatientCaseHistoryTemplate(admin.CurrentOrgId, startTime.Unix(), endTime.Unix(), keyword)
677
-	history, _ := service.GetHisPatientCaseHistory(admin.CurrentOrgId)
683
+	//history, _ := service.GetHisPatientCaseHistory(admin.CurrentOrgId)
678 684
 	c.ServeSuccessJSON(map[string]interface{}{
679 685
 		"template": template,
680
-		"history":  history,
686
+		//"history":  history,
681 687
 	})
682 688
 
683 689
 }

+ 19 - 16
controllers/his_project_api_controller.go View File

@@ -59,6 +59,7 @@ func HisProjectRouters() {
59 59
 	beego.Router("/api/patient/getpatientcasehistory", &HisProjectApiController{}, "Get:GetPatientcaseHistory")
60 60
 	beego.Router("/api/doctorworkstation/gettemplatedetail", &HisProjectApiController{}, "Get:GetTemplateDetail")
61 61
 	beego.Router("/api/doctorworkstation/updaterecordtemplate", &HisProjectApiController{}, "Get:UpdateRecordTemplate")
62
+	beego.Router("/api/hispatient/gehispatient", &HisProjectApiController{}, "Get:GetHisPatient")
62 63
 }
63 64
 
64 65
 func (this *HisProjectApiController) SaveProject() {
@@ -129,9 +130,7 @@ func (this *HisProjectApiController) SaveProject() {
129 130
 	}
130 131
 	//查询项目名称是否存在
131 132
 	_, errcode := service.GetHisProjectIsExist(project_name, orgId)
132
-	fmt.Println("9999999999999", errcode)
133 133
 	if errcode == gorm.ErrRecordNotFound {
134
-		fmt.Println("222")
135 134
 		err = service.CreateHisProject(&hisProject)
136 135
 		if err != nil {
137 136
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
@@ -160,7 +159,6 @@ func (this *HisProjectApiController) GetProjectList() {
160 159
 
161 160
 	keyword := this.GetString("keyword")
162 161
 	projecList, total, err := service.GetHisProjectList(orgId, limit, page, is_charge, is_start, keyword)
163
-	fmt.Println("err", err)
164 162
 	if err != nil {
165 163
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
166 164
 		return
@@ -498,10 +496,8 @@ func (this *HisProjectApiController) GetBloodPatientList() {
498 496
 
499 497
 	adminUserInfo := this.GetAdminUserInfo()
500 498
 	orgId := adminUserInfo.CurrentOrgId
501
-	fmt.Println("org", orgId)
502 499
 	timeStr := time.Now().Format("2006-01-02")
503 500
 	timeLayout := "2006-01-02 15:04:05"
504
-	fmt.Println("timeStr:", timeStr)
505 501
 	timeStringToTime, _ := utils.ParseTimeStringToTime(timeLayout, timeStr+" 00:00:00")
506 502
 	timenow := timeStringToTime.Unix()
507 503
 
@@ -528,7 +524,6 @@ func (this *HisProjectApiController) GetHisPrescription() {
528 524
 	id, _ := this.GetInt64("id")
529 525
 	timeStr := time.Now().Format("2006-01-02")
530 526
 	timeLayout := "2006-01-02 15:04:05"
531
-	fmt.Println("timeStr:", timeStr)
532 527
 	timeStringToTime, _ := utils.ParseTimeStringToTime(timeLayout, timeStr+" 00:00:00")
533 528
 	timenow := timeStringToTime.Unix()
534 529
 	prescriptionList, err := service.GetHisPrescriptionByPatientId(id, timenow)
@@ -549,14 +544,12 @@ func (this *HisProjectApiController) AdditionalCharge() {
549 544
 	fmt.Println(err)
550 545
 	his_patient_id := int64(dataBody["his_patient_id"].(float64))
551 546
 	patient_id := int64(dataBody["patient_id"].(float64))
552
-	fmt.Println("patient_id2222222222", patient_id)
553 547
 	medicineData, _ := dataBody["medicineData"].([]interface{})
554 548
 	adminUserInfo := this.GetAdminUserInfo()
555 549
 	orgId := adminUserInfo.CurrentOrgId
556 550
 	admin_user_id := adminUserInfo.AdminUser.Id
557 551
 	timeStr := time.Now().Format("2006-01-02")
558 552
 	timeLayout := "2006-01-02 15:04:05"
559
-	fmt.Println("timeStr:", timeStr)
560 553
 	timeStringToTime, _ := utils.ParseTimeStringToTime(timeLayout, timeStr+" 00:00:00")
561 554
 	timenow := timeStringToTime.Unix()
562 555
 	for _, item := range medicineData {
@@ -594,7 +587,6 @@ func (this *HisProjectApiController) GetTreatmentList() {
594 587
 	patient_id, _ := this.GetInt64("patient_id")
595 588
 	timeStr := time.Now().Format("2006-01-02")
596 589
 	timeLayout := "2006-01-02 15:04:05"
597
-	fmt.Println("timeStr:", timeStr)
598 590
 	timeStringToTime, _ := utils.ParseTimeStringToTime(timeLayout, timeStr+" 00:00:00")
599 591
 	timenow := timeStringToTime.Unix()
600 592
 	treatmentList, err := service.GetTreatmentList(patient_id, timenow)
@@ -764,8 +756,7 @@ func (this *HisProjectApiController) SaveHisPatient() {
764 756
 	adminUserInfo := this.GetAdminUserInfo()
765 757
 	orgId := adminUserInfo.CurrentOrgId
766 758
 	recordDateStr := time.Now().Format("2006-01-02")
767
-	recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
768
-	fmt.Println("parseDateErr", parseDateErr)
759
+	recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
769 760
 	nowtime := recordDate.Unix()
770 761
 
771 762
 	bloodPatient, errcode := service.GetBloodPatientByIdCard(idcard, orgId)
@@ -839,7 +830,6 @@ func (this *HisProjectApiController) GetAllProjectTeam() {
839 830
 
840 831
 	adminUserInfo := this.GetAdminUserInfo()
841 832
 	orgId := adminUserInfo.CurrentOrgId
842
-	fmt.Println("aaa")
843 833
 	team, err := service.GetAllProjectTeam(orgId)
844 834
 	if err != nil {
845 835
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
@@ -875,7 +865,6 @@ func (this *HisProjectApiController) GetHisPatientHistory() {
875 865
 	register_type, _ := this.GetInt64("register_type")
876 866
 	limit, _ := this.GetInt64("limit")
877 867
 	page, _ := this.GetInt64("page")
878
-	fmt.Println(keyword, start_time, end_time, register_type, limit, page)
879 868
 	startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
880 869
 	endTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
881 870
 	adminUserInfo := this.GetAdminUserInfo()
@@ -902,8 +891,8 @@ func (this *HisProjectApiController) ChangePatient() {
902 891
 	id, _ := this.GetInt64("id")
903 892
 	//查询该患者今日是否已经就诊
904 893
 	recordDateStr := time.Now().Format("2006-01-02")
905
-	recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
906
-	fmt.Println("parseDateErr", parseDateErr)
894
+	recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
895
+
907 896
 	nowtime := recordDate.Unix()
908 897
 	adminUserInfo := this.GetAdminUserInfo()
909 898
 	orgId := adminUserInfo.CurrentOrgId
@@ -960,7 +949,6 @@ func (this *HisProjectApiController) GetTemplateDetail() {
960 949
 func (this *HisProjectApiController) UpdateRecordTemplate() {
961 950
 	id, _ := this.GetInt64("id")
962 951
 	template_name := this.GetString("template_name")
963
-	fmt.Println("template_name22222222222222", template_name)
964 952
 	template_remark := this.GetString("template_remark")
965 953
 
966 954
 	diagnostic := this.GetString("diagnostic")
@@ -994,3 +982,18 @@ func (this *HisProjectApiController) UpdateRecordTemplate() {
994 982
 		"templateDetail": historyTemplate,
995 983
 	})
996 984
 }
985
+
986
+func (this *HisProjectApiController) GetHisPatient() {
987
+
988
+	adminUserInfo := this.GetAdminUserInfo()
989
+	orgId := adminUserInfo.CurrentOrgId
990
+	keyword := this.GetString("keyword")
991
+	patient, err := service.GetHistPatient(orgId, keyword)
992
+	if err != nil {
993
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
994
+		return
995
+	}
996
+	this.ServeSuccessJSON(map[string]interface{}{
997
+		"patient": patient,
998
+	})
999
+}

+ 36 - 38
controllers/mobile_api_controllers/check_weight_api_controller.go View File

@@ -723,7 +723,7 @@ func (c *CheckWeightApiController) GetPatientListForSchedules() {
723 723
 	syncTime := theStartTime.Unix()
724 724
 	adminUserInfo := c.GetMobileAdminUserInfo()
725 725
 	patientList, total, error := service.GetPatientListBySchedules(adminUserInfo.Org.Id, syncTime)
726
-	patientSchedule := make([]map[string]interface{},0)
726
+	patientSchedule := make([]map[string]interface{}, 0)
727 727
 	for _, item := range patientList {
728 728
 		patientTemp := make(map[string]interface{})
729 729
 		patientTemp["patient_id"] = item.PatientId
@@ -745,43 +745,41 @@ 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
-	
758
-	patientList, total, error := service.GetPatientListBySchedulesFind(adminUserInfo.Org.Id, syncTime,patient_name)
759
-	
760
-	patientSchedule := make([]map[string]interface{},0)
761
-	for _, item := range patientList {
762
-		if len(item.Patient.Name) > 0 {
763
-			patientTemp := make(map[string]interface{})
764
-			patientTemp["patient_id"] = item.PatientId
765
-			patientTemp["patient_name"] = item.Patient.Name
766
-			patientTemp["schedule_type"] = item.ScheduleType
767
-			patientSchedule = append(patientSchedule, patientTemp)
768
-		}
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
+//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
+//}
785 783
 
786 784
 func (c *CheckWeightApiController) GetPatientListById() {
787 785
 	patientId, _ := c.GetInt64("patient_id", 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")

+ 2 - 1
controllers/schedule_api_controller.go View File

@@ -765,6 +765,7 @@ func (this *ScheduleApiController) SearchSchedulePatients() {
765 765
 
766 766
 func (this *ScheduleApiController) GetWeekDaySchedule() {
767 767
 	week_type, _ := this.GetInt64("week_type", -1)
768
+	week_time, _ := this.GetInt64("week_time")
768 769
 	fmt.Println(week_type)
769 770
 	thisTime := time.Now()
770 771
 	weekDay := int(thisTime.Weekday())
@@ -822,7 +823,7 @@ func (this *ScheduleApiController) GetWeekDaySchedule() {
822 823
 	}
823 824
 
824 825
 	adminUserInfo := this.GetAdminUserInfo()
825
-	list, _ := service.GetWeekDaySchedule(adminUserInfo.CurrentOrgId, targetDay.Unix(), targetDay)
826
+	list, _ := service.GetWeekDayScheduleTwo(adminUserInfo.CurrentOrgId, targetDay.Unix(), targetDay, week_time)
826 827
 
827 828
 	this.ServeSuccessJSON(map[string]interface{}{
828 829
 		"schdules": list,

+ 1 - 0
models/stock_query_models.go View File

@@ -3,6 +3,7 @@ package models
3 3
 type StockInfo struct {
4 4
 	ID                int64  `gorm:"column:id" json:"id"`
5 5
 	GoodCode          string `gorm:"column:good_code" json:"good_code"`
6
+	GoodName          string `gorm:"column:good_name" json:"good_name"`
6 7
 	SpecificationName string `gorm:"column:specification_name" json:"specification_name"`
7 8
 	GoodTypeId        int64  `gorm:"column:good_type_id" json:"good_type_id"`
8 9
 	GoodUnit          int64  `gorm:"column:good_unit" json:"good_unit"`

+ 7 - 1
service/his_project_service.go View File

@@ -304,7 +304,7 @@ func GetHisPatientHistory(keyword string, startime int64, endtime int64, registt
304 304
 	if orgid > 0 {
305 305
 		db = db.Where("x.user_org_id = ?", orgid)
306 306
 	}
307
-	err = db.Select("x.id,x.balance_accounts_type,x.medical_insurance_number,x.name,x.gender,x.id_type,x.medical_treatment_type,x.birthday,x.record_date,x.age,x.phone_number,x.id_card_no,x.register_type,x.admin_user_id,x.departments,x.is_need_cost_of_production,x.register_cost,x.treatment_cost,x.cost_of_production,x.total,x.user_org_id,x.patient_id,x.number,x.doctor,x.is_return").Count(&total).Offset(offset).Limit(limit).Find(&hisPatient).Error
307
+	err = db.Select("x.id,x.balance_accounts_type,x.medical_insurance_number,x.name,x.gender,x.id_type,x.medical_treatment_type,x.birthday,x.record_date,x.age,x.phone_number,x.id_card_no,x.register_type,x.admin_user_id,x.departments,x.is_need_cost_of_production,x.register_cost,x.treatment_cost,x.cost_of_production,x.total,x.user_org_id,x.patient_id,x.number,x.is_return,x.doctor").Count(&total).Offset(offset).Limit(limit).Find(&hisPatient).Error
308 308
 	return hisPatient, total, err
309 309
 }
310 310
 
@@ -366,3 +366,9 @@ func UpdateCaseHistoryTemplate(tem *models.HisCaseHistoryTemplate, id int64) err
366 366
 	err := XTWriteDB().Model(&tem).Where("id = ? ", id).Updates(map[string]interface{}{"history_of_present_illness": tem.HistoryOfPresentIllness, "past_history": tem.PastHistory, "chief_conplaint": tem.ChiefConplaint, "personal_history": tem.PersonalHistory, "family_history": tem.FamilyHistory, "diagnostic": tem.Diagnostic, "template_name": tem.TemplateName, "template_remark": tem.TemplateRemark, "modifier": tem.Modifier}).Error
367 367
 	return err
368 368
 }
369
+
370
+func GetHistPatient(orgid int64, keyword string) (hisPatient []*models.HisPatient, err error) {
371
+	likeKey := "%" + keyword + "%"
372
+	err = XTReadDB().Model(&hisPatient).Where("user_org_id = ? and name like ?", orgid, likeKey).Find(&hisPatient).Error
373
+	return hisPatient, err
374
+}

+ 95 - 0
service/schedule_service.go View File

@@ -304,6 +304,101 @@ func GetSchedualPatientsByKeywords(keywords string, org_id int64) (schedule []*m
304 304
 
305 305
 }
306 306
 
307
+func GetWeekDayScheduleTwo(orgID int64, scheduleDate int64, scheduleDates *time.Time, weektime int64) (schedules []*models.WeekSchedule, err error) {
308
+	db := readDb.Table("xt_schedule as s ").Where("s.status =1")
309
+	if orgID > 0 {
310
+		db = db.Where("s.user_org_id = ?", orgID)
311
+	}
312
+	if scheduleDate > 0 {
313
+		db = db.Where("s.schedule_date = ?", scheduleDate)
314
+
315
+	}
316
+	if weektime > 0 {
317
+		db = db.Where("s.schedule_type = ?", weektime)
318
+	}
319
+	err = db.
320
+		Preload("DeviceZone", "status = 1 ").
321
+		Preload("DeviceNumber", "status = 1 ").
322
+		Preload("DialysisPrescription", func(db *gorm.DB) *gorm.DB {
323
+			return db.Where("status = 1").Order("id asc")
324
+		}).
325
+		Joins("JOIN xt_patients as p ON p.id = s.patient_id").
326
+		Select("s.id, s.user_org_id, s.partition_id, s.bed_id, s.patient_id, s.schedule_date, s.schedule_type, s.schedule_week, s.mode_id, s.status, s.created_time, s.updated_time, p.name as patient").
327
+		Order("s.partition_id asc").
328
+		Find(&schedules).Error
329
+
330
+	for _, item := range schedules {
331
+		_, config := FindDoctorAdviceRecordByOrgId(item.UserOrgId)
332
+		if config.IsOpenRemind > 0 {
333
+			//开启推送提醒逻辑    提交长期处方的时候,弹起长期医嘱推送
334
+			var advice_three []*models.DoctorAdvice
335
+			advices, _ := GetLastLongAdviceByGroupNoOther(item.UserOrgId, item.PatientId)
336
+			advices_two, _ := GetLastLongAdviceByGroupNoThreeOther(item.UserOrgId, item.PatientId)
337
+			for _, advice := range advices {
338
+				advice.IsCheck = 1
339
+				if advice.FrequencyType == 3 {
340
+					week := int(scheduleDates.Weekday())
341
+					fmt.Println(advice.WeekDay)
342
+					switch week {
343
+					case 1:
344
+						if strings.Index(advice.WeekDay, "周一") > -1 {
345
+							advice_three = append(advice_three, advice)
346
+						}
347
+						break
348
+					case 2:
349
+						if strings.Index(advice.WeekDay, "周二") > -1 {
350
+							advice_three = append(advice_three, advice)
351
+						}
352
+						break
353
+					case 3:
354
+						if strings.Index(advice.WeekDay, "周三") > -1 {
355
+							advice_three = append(advice_three, advice)
356
+						}
357
+						break
358
+					case 4:
359
+						if strings.Index(advice.WeekDay, "周四") > -1 {
360
+							advice_three = append(advice_three, advice)
361
+						}
362
+						break
363
+					case 5:
364
+						if strings.Index(advice.WeekDay, "周五") > -1 {
365
+							advice_three = append(advice_three, advice)
366
+						}
367
+						break
368
+					case 6:
369
+						if strings.Index(advice.WeekDay, "周六") > -1 {
370
+							advice_three = append(advice_three, advice)
371
+						}
372
+						break
373
+					case 0:
374
+						if strings.Index(advice.WeekDay, "周日") > -1 {
375
+							advice_three = append(advice_three, advice)
376
+						}
377
+						break
378
+					}
379
+				} else if advice.FrequencyType == 1 {
380
+					advice_three = append(advice_three, advice)
381
+				}
382
+			}
383
+
384
+			for _, advice := range advices_two {
385
+				now := scheduleDates.Unix()
386
+				dayStr := strconv.FormatInt(advice.DayCount, 10)
387
+				dayStr2 := "-" + dayStr
388
+				count, _ := strconv.ParseInt(dayStr2, 10, 64)
389
+				oldTime := scheduleDates.AddDate(0, 0, int(count)).Unix()
390
+				advices, _ := FindAllDoctorAdviceByTimeOther(now, oldTime, item.PatientId, item.UserOrgId, advice.TemplateId)
391
+				if len(advices) == 0 {
392
+					advice_three = append(advice_three, advice)
393
+				}
394
+			}
395
+
396
+			item.DoctorAdvice = append(item.DoctorAdvice, advice_three...)
397
+		}
398
+	}
399
+	return
400
+}
401
+
307 402
 func GetWeekDaySchedule(orgID int64, scheduleDate int64, scheduleDates *time.Time) (schedules []*models.WeekSchedule, err error) {
308 403
 
309 404
 	err = readDb.