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
5e38f04de0

+ 3 - 3
controllers/dialysis_parameter_api_controller.go View File

@@ -40,7 +40,7 @@ func (this *DialysisPrameterApiController) GetDialysisParameters() {
40 40
 	fmt.Println("scheduletype", schedulType, start_time, partitionType, keywords, theTime.Unix())
41 41
 	if len(keywords) > 0 {
42 42
 		dialysisSchedule, err, total := service.GetDialysisParametersByKeyword(adminUserInfo.CurrentOrgId, keywords, schedulType, partitionType, page, limit, theTime.Unix())
43
-		patient, err := service.GetDialysisTodaySchedulePatient(adminUserInfo.CurrentOrgId, theTime.Unix(), page, limit, keywords)
43
+		patient, err := service.GetDialysisTodaySchedulePatient(adminUserInfo.CurrentOrgId, theTime.Unix(), page, limit, keywords, schedulType, partitionType)
44 44
 		var vlist []interface{}
45 45
 		var elist []interface{}
46 46
 		for _, item := range patient {
@@ -64,7 +64,7 @@ func (this *DialysisPrameterApiController) GetDialysisParameters() {
64 64
 		dialysisSchedule, err, total := service.GetDialysisParameter(adminUserInfo.CurrentOrgId, theTime.Unix(), schedulType, partitionType, page, limit)
65 65
 
66 66
 		//查询今日排班的病人
67
-		patient, err := service.GetDialysisTodaySchedulePatient(adminUserInfo.CurrentOrgId, theTime.Unix(), page, limit, keywords)
67
+		patient, err := service.GetDialysisTodaySchedulePatient(adminUserInfo.CurrentOrgId, theTime.Unix(), page, limit, keywords, schedulType, partitionType)
68 68
 
69 69
 		var vlist []interface{}
70 70
 		var elist []interface{}
@@ -219,7 +219,7 @@ func (this *DialysisPrameterApiController) GetCollectList() {
219 219
 	schedule, err, _ := service.GetCollectList(limit, page, partitiontype, scheduletype, startime.Unix(), orgId, keyword)
220 220
 
221 221
 	//查询今日排班的病人
222
-	patient, err := service.GetDialysisTodaySchedulePatient(orgId, startime.Unix(), page, limit, keyword)
222
+	patient, err := service.GetDialysisTodaySchedulePatient(orgId, startime.Unix(), page, limit, keyword, scheduletype, partitiontype)
223 223
 	var vlist []interface{}
224 224
 	var clist []interface{}
225 225
 	for _, item := range patient {

+ 42 - 26
controllers/his_project_api_controller.go View File

@@ -79,6 +79,7 @@ func HisProjectRouters() {
79 79
 
80 80
 	beego.Router("/api/hispatient/getalldepartmentlist", &HisProjectApiController{}, "Get:GetAllDepartmentList")
81 81
 	beego.Router("/api/hispatient/getprescription", &HisProjectApiController{}, "Get:GetPrescription")
82
+	beego.Router("/api/histpatient/getpatientdetail", &HisProjectApiController{}, "Get:GetPatientDetail")
82 83
 }
83 84
 
84 85
 func (this *HisProjectApiController) SaveProject() {
@@ -732,7 +733,6 @@ func (this *HisProjectApiController) SaveHisPatient() {
732 733
 	recordDateStr := time.Now().Format("2006-01-02")
733 734
 	recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
734 735
 	nowtime := recordDate.Unix()
735
-	fmt.Println("nowtime0000000000", nowtime)
736 736
 	phone := this.GetString("phone")
737 737
 	social_type, _ := this.GetInt64("social_type")
738 738
 	bloodPatient, errcode := service.GetBloodPatientByIdCard(idcard, orgId)
@@ -750,19 +750,19 @@ func (this *HisProjectApiController) SaveHisPatient() {
750 750
 			IsNeedCostOfProduction: cost_checked,
751 751
 			TreatmentCost:          medicalExpense_float,
752 752
 			MedicalInsuranceNumber: medicalinsurancecard,
753
-			Name:                name,
754
-			RegisterType:        register,
755
-			RegisterCost:        registrationfees_float,
756
-			BalanceAccountsType: settlementValue,
757
-			Gender:              sex,
758
-			Total:               totals_float,
759
-			UserOrgId:           orgId,
760
-			Status:              1,
761
-			RecordDate:          nowtime,
762
-			IsReturn:            1,
763
-			Ctime:               time.Now().Unix(),
764
-			Phone:               phone,
765
-			SocialType:          social_type,
753
+			Name:                   name,
754
+			RegisterType:           register,
755
+			RegisterCost:           registrationfees_float,
756
+			BalanceAccountsType:    settlementValue,
757
+			Gender:                 sex,
758
+			Total:                  totals_float,
759
+			UserOrgId:              orgId,
760
+			Status:                 1,
761
+			RecordDate:             nowtime,
762
+			IsReturn:               1,
763
+			Ctime:                  time.Now().Unix(),
764
+			Phone:                  phone,
765
+			SocialType:             social_type,
766 766
 		}
767 767
 		err := service.CreateHisPatient(&patient)
768 768
 		lastPatient, err := service.GetLastPatient(orgId)
@@ -795,18 +795,20 @@ func (this *HisProjectApiController) SaveHisPatient() {
795 795
 			IsNeedCostOfProduction: cost_checked,
796 796
 			TreatmentCost:          medicalExpense_float,
797 797
 			MedicalInsuranceNumber: medicalinsurancecard,
798
-			Name:                name,
799
-			RegisterType:        register,
800
-			RegisterCost:        registrationfees_float,
801
-			BalanceAccountsType: settlementValue,
802
-			Gender:              sex,
803
-			Total:               totals_float,
804
-			UserOrgId:           orgId,
805
-			PatientId:           bloodPatient.ID,
806
-			Ctime:               time.Now().Unix(),
807
-			Phone:               phone,
808
-			SocialType:          social_type,
809
-			RecordDate:          nowtime,
798
+			Name:                   name,
799
+			RegisterType:           register,
800
+			RegisterCost:           registrationfees_float,
801
+			BalanceAccountsType:    settlementValue,
802
+			Gender:                 sex,
803
+			Total:                  totals_float,
804
+			UserOrgId:              orgId,
805
+			PatientId:              bloodPatient.ID,
806
+			Ctime:                  time.Now().Unix(),
807
+			Phone:                  phone,
808
+			SocialType:             social_type,
809
+			RecordDate:             nowtime,
810
+			Status:                 1,
811
+			IsReturn:               1,
810 812
 		}
811 813
 		err := service.CreateHisPatient(&patient)
812 814
 		lastPatient, err := service.GetLastPatient(orgId)
@@ -1377,3 +1379,17 @@ func (this *HisProjectApiController) GetPrescription() {
1377 1379
 		"list": list,
1378 1380
 	})
1379 1381
 }
1382
+
1383
+func (this *HisProjectApiController) GetPatientDetail() {
1384
+
1385
+	id, _ := this.GetInt64("id")
1386
+	adminUserInfo := this.GetAdminUserInfo()
1387
+	patient, err := service.GetPatientByID(adminUserInfo.CurrentOrgId, id)
1388
+	if err != nil {
1389
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
1390
+		return
1391
+	}
1392
+	this.ServeSuccessJSON(map[string]interface{}{
1393
+		"patient": patient,
1394
+	})
1395
+}

+ 3 - 3
controllers/new_mobile_api_controllers/dialysis_parameter_api_controller.go View File

@@ -48,7 +48,7 @@ func (this *DialysisParamerterApiController) GetMobileDialysisParameters() {
48 48
 
49 49
 		//dialysisSchedule, err, total := service.GetDialysisParametersByKeyword(orgid, keywords, scheduleType, partitionType, page, limit, theTime.Unix())
50 50
 		//查询今日排班的病人
51
-		patient, err := service.GetDialysisTodaySchedulePatient(orgid, theTime.Unix(), page, limit, keywords)
51
+		patient, err := service.GetDialysisTodaySchedulePatient(orgid, theTime.Unix(), page, limit, keywords, scheduleType, partitionType)
52 52
 		var vlist []interface{}
53 53
 		var elist []interface{}
54 54
 		for _, item := range patient {
@@ -71,7 +71,7 @@ func (this *DialysisParamerterApiController) GetMobileDialysisParameters() {
71 71
 	} else {
72 72
 		dialysisSchedule, err, total := service.GetDialysisParameter(orgid, theTime.Unix(), scheduleType, partitionType, page, limit)
73 73
 		//查询今日排班的病人
74
-		patient, err := service.GetDialysisTodaySchedulePatient(orgid, theTime.Unix(), page, limit, keywords)
74
+		patient, err := service.GetDialysisTodaySchedulePatient(orgid, theTime.Unix(), page, limit, keywords, scheduleType, partitionType)
75 75
 		var vlist []interface{}
76 76
 		var elist []interface{}
77 77
 		for _, item := range patient {
@@ -154,7 +154,7 @@ func (this *DialysisParamerterApiController) GetMobileCollectList() {
154 154
 	//获取透析参数数据
155 155
 	//schedule, err, _ := service.GetCollectList(limit, page, partitiontype, scheduletype, startime.Unix(), orgId, keyword)
156 156
 	//查询今日排班的病人
157
-	patient, err := service.GetDialysisTodaySchedulePatient(orgId, startime.Unix(), page, limit, keyword)
157
+	patient, err := service.GetDialysisTodaySchedulePatient(orgId, startime.Unix(), page, limit, keyword, scheduletype, partitiontype)
158 158
 	var vlist []interface{}
159 159
 	var clist []interface{}
160 160
 	for _, item := range patient {

+ 19 - 2
controllers/schedule_api_controller.go View File

@@ -39,7 +39,7 @@ func ScheduleApiRegistRouters() {
39 39
 	beego.Router("/api/schedule_template/search", &ScheduleApiController{}, "get:SearchTemplateSchedulePatients")
40 40
 
41 41
 	beego.Router("/api/schedule_template/cancel", &ScheduleApiController{}, "post:CancelScheduleTemplate")
42
-
42
+	beego.Router("/api/schedule/getnextscheduleweekday", &ScheduleApiController{}, "Get:GetNextWeekDaySchedule")
43 43
 }
44 44
 
45 45
 func (c *ScheduleApiController) GetWeekPanels() {
@@ -765,7 +765,6 @@ func (this *ScheduleApiController) SearchSchedulePatients() {
765 765
 func (this *ScheduleApiController) GetWeekDaySchedule() {
766 766
 	week_type, _ := this.GetInt64("week_type", -1)
767 767
 	week_time, _ := this.GetInt64("week_time")
768
-	fmt.Println(week_type)
769 768
 	thisTime := time.Now()
770 769
 	weekDay := int(thisTime.Weekday())
771 770
 	if weekDay == 0 {
@@ -816,6 +815,7 @@ func (this *ScheduleApiController) GetWeekDaySchedule() {
816 815
 		break
817 816
 	}
818 817
 	targetDay, parseErr := utils.ParseTimeStringToTime("2006-01-02", targetDayStr)
818
+
819 819
 	if parseErr != nil {
820 820
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
821 821
 		return
@@ -1898,3 +1898,20 @@ func (c *ScheduleApiController) CancelScheduleTemplate() {
1898 1898
 		return
1899 1899
 	}
1900 1900
 }
1901
+
1902
+func (this *ScheduleApiController) GetNextWeekDaySchedule() {
1903
+
1904
+	week_type, _ := this.GetInt64("week_type", -1)
1905
+	week_time, _ := this.GetInt64("week_time")
1906
+	start_time, _ := this.GetInt64("start_time")
1907
+	end_time, _ := this.GetInt64("end_time")
1908
+	adminUserInfo := this.GetAdminUserInfo()
1909
+	schedule, err := service.GetNextWeekDaySchedule(week_type, week_time, start_time, end_time, adminUserInfo.CurrentOrgId)
1910
+	if err != nil {
1911
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1912
+		return
1913
+	}
1914
+	this.ServeSuccessJSON(map[string]interface{}{
1915
+		"schedule": schedule,
1916
+	})
1917
+}

+ 8 - 1
service/dialysis_parameter_service.go View File

@@ -278,7 +278,7 @@ func GetAnticoagulantCount(startime int64, endtime int64, orgid int64) (prescrip
278 278
 	return prescriptionCount, err
279 279
 }
280 280
 
281
-func GetDialysisTodaySchedulePatient(orgid int64, startime int64, page int64, limit int64, keywords string) (schedule []*models.XtScheduleTwo, err error) {
281
+func GetDialysisTodaySchedulePatient(orgid int64, startime int64, page int64, limit int64, keywords string, schedulType int64, partiontype int64) (schedule []*models.XtScheduleTwo, err error) {
282 282
 	//offset := (page - 1) * limit
283 283
 	//err = XTReadDB().Model(&schedule).Where("user_org_id = ? and schedule_date = ? and status = 1", orgid, startime).Offset(offset).Limit(limit).Order("id desc").Find(&schedule).Error
284 284
 	//return schedule, err
@@ -286,6 +286,13 @@ func GetDialysisTodaySchedulePatient(orgid int64, startime int64, page int64, li
286 286
 
287 287
 	offset := (page - 1) * limit
288 288
 	db := XTReadDB().Table("xt_schedule as x").Where("x.status = 1")
289
+	if schedulType > 0 {
290
+		db = db.Where("x.schedule_type = ?", schedulType)
291
+	}
292
+	if partiontype > 0 {
293
+		db = db.Where("x.partition_id = ?", partiontype)
294
+	}
295
+
289 296
 	table := XTReadDB().Table("xt_patients as s")
290 297
 	fmt.Println(table)
291 298
 	if len(keywords) > 0 {

+ 1 - 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.is_return,x.doctor,x.ctime").Count(&total).Offset(offset).Limit(limit).Order("x.id desc").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,x.ctime,x.social_type,x.phone").Count(&total).Offset(offset).Limit(limit).Order("x.id desc").Find(&hisPatient).Error
308 308
 	return hisPatient, total, err
309 309
 }
310 310
 

+ 33 - 0
service/schedule_service.go View File

@@ -305,6 +305,7 @@ func GetSchedualPatientsByKeywords(keywords string, org_id int64) (schedule []*m
305 305
 }
306 306
 
307 307
 func GetWeekDayScheduleTwo(orgID int64, scheduleDate int64, scheduleDates *time.Time, weektime int64) (schedules []*models.WeekSchedule, err error) {
308
+
308 309
 	db := readDb.Table("xt_schedule as s ").Where("s.status =1")
309 310
 	if orgID > 0 {
310 311
 		db = db.Where("s.user_org_id = ?", orgID)
@@ -338,6 +339,7 @@ func GetWeekDayScheduleTwo(orgID int64, scheduleDate int64, scheduleDates *time.
338 339
 				advice.IsCheck = 1
339 340
 				if advice.FrequencyType == 3 {
340 341
 					week := int(scheduleDates.Weekday())
342
+					fmt.Println("week-------", week)
341 343
 					fmt.Println(advice.WeekDay)
342 344
 					switch week {
343 345
 					case 1:
@@ -629,3 +631,34 @@ func UpdateNewScheduleTemplateStatus(id int64, org_id int64) (err error) {
629 631
 	err = readDb.Model(&models.PatientScheduleTemplateItem{}).Where("org_id = ? AND id = ?", org_id, id).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
630 632
 	return
631 633
 }
634
+
635
+func GetNextWeekDaySchedule(weektype int64, weektime int64, startime int64, endtime int64, orgID int64) (schedules []*models.WeekSchedule, err error) {
636
+
637
+	db := readDb.Table("xt_schedule as s ").Where("s.status =1")
638
+	if orgID > 0 {
639
+		db = db.Where("s.user_org_id = ?", orgID)
640
+	}
641
+	if startime > 0 {
642
+		db = db.Where("s.schedule_date >= ?", startime)
643
+	}
644
+	if endtime > 0 {
645
+		db = db.Where("s.schedule_date <= ?", endtime)
646
+	}
647
+	if weektime > 0 {
648
+		db = db.Where("s.schedule_type = ?", weektime)
649
+	}
650
+	if weektype > 0 {
651
+		db = db.Where("s.schedule_week = ?", weektype)
652
+	}
653
+	err = db.
654
+		Preload("DeviceZone", "status = 1 ").
655
+		Preload("DeviceNumber", "status = 1 ").
656
+		Preload("DialysisPrescription", func(db *gorm.DB) *gorm.DB {
657
+			return db.Where("status = 1").Order("id asc")
658
+		}).
659
+		Joins("JOIN xt_patients as p ON p.id = s.patient_id").
660
+		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").
661
+		Order("s.partition_id asc").
662
+		Find(&schedules).Error
663
+	return schedules, err
664
+}