28169 1 year ago
parent
commit
5466c72d88

+ 12 - 0
controllers/new_mobile_api_controllers/mobile_his_api_controller.go View File

@@ -1269,3 +1269,15 @@ func (c *MobileHisApiController) GetPatientPlan() {
1269 1269
 	})
1270 1270
 	return
1271 1271
 }
1272
+
1273
+func (c *MobileHisApiController) ToGetPatient() {
1274
+
1275
+	order, _ := service.GetDialysisOrderList(10340)
1276
+	for _, item := range order {
1277
+		service.UpdatePatientDialysisOrder(item.PatientId, item.Url)
1278
+	}
1279
+	c.ServeSuccessJSON(map[string]interface{}{
1280
+		"msg": "ok",
1281
+	})
1282
+	return
1283
+}

+ 1 - 0
controllers/new_mobile_api_controllers/new_mobile_api_router_register.go View File

@@ -181,5 +181,6 @@ func NewMobileAPIControllersRegisterRouters() {
181 181
 	beego.Router("/m/api/prescription/create", &MobileHisApiController{}, "Post:CreateHisPrescription")
182 182
 
183 183
 	beego.Router("/m/api/patient/getpatientplan", &MobileHisApiController{}, "Get:GetPatientPlan")
184
+	beego.Router("/m/api/patient/togetpatient", &MobileHisApiController{}, "Get:ToGetPatient")
184 185
 
185 186
 }

+ 115 - 14
controllers/new_mobile_api_controllers/staff_schedule_api_controller.go View File

@@ -49,10 +49,40 @@ func (this *StaffScheduleApiController) GetMobileDoctorList() {
49 49
 func (this *StaffScheduleApiController) GetMobileStaffScheduleList() {
50 50
 
51 51
 	orgId := this.GetMobileAdminUserInfo().Org.Id
52
-	start_time, _ := this.GetInt64("start_time")
53
-	fmt.Println("staft_time", start_time)
54
-	end_time, _ := this.GetInt64("end_time")
55
-	staffList, err := service.GetStaffScheduleList(orgId, start_time, end_time)
52
+	//start_time, _ := this.GetInt64("start_time")
53
+	//fmt.Println("staft_time", start_time)
54
+	//end_time, _ := this.GetInt64("end_time")
55
+	//fmt.Println("start_time",start_time)
56
+	//fmt.Println("end_time",end_time)
57
+	start_time_one := this.GetString("start_time_one")
58
+	end_time_one := this.GetString("end_time_one")
59
+	fmt.Println("start_time_one--------", len(start_time_one))
60
+	fmt.Println("end_time_one-------", end_time_one)
61
+	timeLayout := "2006-01-02"
62
+	loc, _ := time.LoadLocation("Local")
63
+	var startTime int64
64
+	if len(start_time_one) > 0 {
65
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_one+" 00:00:00", loc)
66
+		fmt.Println("err-----------", err)
67
+		if err != nil {
68
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
69
+			return
70
+		}
71
+		startTime = theTime.Unix()
72
+	}
73
+	var endTime int64
74
+	if len(end_time_one) > 0 {
75
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_one+" 23:59:59", loc)
76
+		if err != nil {
77
+			utils.ErrorLog(err.Error())
78
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
79
+			return
80
+		}
81
+		endTime = theTime.Unix()
82
+	}
83
+	fmt.Println("starti_time233232323232", startTime)
84
+	fmt.Println("end_time2323223232323", endTime)
85
+	staffList, err := service.GetStaffScheduleList(orgId, startTime, endTime)
56 86
 	if err != nil {
57 87
 		this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
58 88
 		return
@@ -66,10 +96,33 @@ func (this *StaffScheduleApiController) GetMobileStaffScheduleList() {
66 96
 func (this *StaffScheduleApiController) GetMobileNextWeekScheduleLIst() {
67 97
 
68 98
 	orgId := this.GetMobileAdminUserInfo().Org.Id
69
-	start_time, _ := this.GetInt64("start_time")
70
-	end_time, _ := this.GetInt64("end_time")
99
+	//start_time, _ := this.GetInt64("start_time")
100
+	//end_time, _ := this.GetInt64("end_time")
101
+	start_time_one := this.GetString("start_time_one")
102
+	end_time_one := this.GetString("end_time_one")
103
+	timeLayout := "2006-01-02"
104
+	loc, _ := time.LoadLocation("Local")
105
+	var startTime int64
106
+	if len(start_time_one) > 0 {
107
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_one+" 00:00:00", loc)
108
+		if err != nil {
109
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
110
+			return
111
+		}
112
+		startTime = theTime.Unix()
113
+	}
114
+	var endTime int64
115
+	if len(end_time_one) > 0 {
116
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_one+" 23:59:59", loc)
117
+		if err != nil {
118
+			utils.ErrorLog(err.Error())
119
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
120
+			return
121
+		}
122
+		endTime = theTime.Unix()
123
+	}
71 124
 
72
-	staffList, err := service.GetStaffScheduleList(orgId, start_time, end_time)
125
+	staffList, err := service.GetStaffScheduleList(orgId, startTime, endTime)
73 126
 	if err != nil {
74 127
 		this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
75 128
 		return
@@ -82,10 +135,33 @@ func (this *StaffScheduleApiController) GetMobileNextWeekScheduleLIst() {
82 135
 
83 136
 func (this *StaffScheduleApiController) GetScheduleByUserType() {
84 137
 	doctor_id, _ := this.GetInt64("doctor_id")
85
-	start_time, _ := this.GetInt64("start_time")
86
-	end_time, _ := this.GetInt64("end_time")
138
+	//start_time, _ := this.GetInt64("start_time")
139
+	//end_time, _ := this.GetInt64("end_time")
140
+	start_time_one := this.GetString("start_time_one")
141
+	end_time_one := this.GetString("end_time_one")
142
+	timeLayout := "2006-01-02"
143
+	loc, _ := time.LoadLocation("Local")
144
+	var startTime int64
145
+	if len(start_time_one) > 0 {
146
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_one+" 00:00:00", loc)
147
+		if err != nil {
148
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
149
+			return
150
+		}
151
+		startTime = theTime.Unix()
152
+	}
153
+	var endTime int64
154
+	if len(end_time_one) > 0 {
155
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_one+" 23:59:59", loc)
156
+		if err != nil {
157
+			utils.ErrorLog(err.Error())
158
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
159
+			return
160
+		}
161
+		endTime = theTime.Unix()
162
+	}
87 163
 	orgId := this.GetMobileAdminUserInfo().Org.Id
88
-	staffList, err := service.GetScheduleByDoctorId(doctor_id, start_time, end_time, orgId)
164
+	staffList, err := service.GetScheduleByDoctorId(doctor_id, startTime, endTime, orgId)
89 165
 	if err != nil {
90 166
 		this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
91 167
 		return
@@ -100,9 +176,34 @@ func (this *StaffScheduleApiController) GetSearchPatientByDoctorId() {
100 176
 
101 177
 	orgId := this.GetMobileAdminUserInfo().Org.Id
102 178
 	user_name := this.GetString("user_name")
103
-	start_time, _ := this.GetInt64("start_time")
104
-	end_time, _ := this.GetInt64("end_time")
105
-	staffList, err := service.ToSearchSeacheduleList(user_name, start_time, end_time, orgId)
179
+	//start_time, _ := this.GetInt64("start_time")
180
+	//end_time, _ := this.GetInt64("end_time")
181
+
182
+	start_time_one := this.GetString("start_time_one")
183
+	end_time_one := this.GetString("end_time_one")
184
+	timeLayout := "2006-01-02"
185
+	loc, _ := time.LoadLocation("Local")
186
+	var startTime int64
187
+	if len(start_time_one) > 0 {
188
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_one+" 00:00:00", loc)
189
+		if err != nil {
190
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
191
+			return
192
+		}
193
+		startTime = theTime.Unix()
194
+	}
195
+	var endTime int64
196
+	if len(end_time_one) > 0 {
197
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_one+" 23:59:59", loc)
198
+		if err != nil {
199
+			utils.ErrorLog(err.Error())
200
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
201
+			return
202
+		}
203
+		endTime = theTime.Unix()
204
+	}
205
+	//
206
+	staffList, err := service.ToSearchSeacheduleList(user_name, startTime, endTime, orgId)
106 207
 	if err != nil {
107 208
 		this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
108 209
 		return
@@ -812,7 +913,7 @@ func (c *StaffScheduleApiController) ChangeScheduleById() {
812 913
 	patient_id, _ := c.GetInt64("patient_id")
813 914
 	org_id := c.GetMobileAdminUserInfo().Org.Id
814 915
 	err := service.ChangeScheduleById(id, mode_id)
815
-	fmt.Println("9999999999999999", err)
916
+	fmt.Println("err", err)
816 917
 	err = service.ChangeDialysisSolution(patient_id, schedule_date, org_id, mode_id)
817 918
 	c.ServeSuccessJSON(map[string]interface{}{
818 919
 		"msg": "ok",

+ 29 - 13
controllers/pharmacy_controller.go View File

@@ -35,7 +35,7 @@ func PharmacyApiRegistRouters() {
35 35
 	beego.Router("/api/pharmacy/routeofadministration", &PharmacyController{}, "get:RouteOfAdministration") //获取当前机构的给药途径
36 36
 }
37 37
 
38
-//测试
38
+// 测试
39 39
 func (this *PharmacyController) Tlili() {
40 40
 	var err error
41 41
 	defer func() {
@@ -65,7 +65,7 @@ func (this *PharmacyController) GetCurrentName() {
65 65
 	return
66 66
 }
67 67
 
68
-//查询今天的待发药,已发药人数
68
+// 查询今天的待发药,已发药人数
69 69
 func (this *PharmacyController) TodayNumber() {
70 70
 	var err error
71 71
 	defer func() {
@@ -166,7 +166,15 @@ func (this *PharmacyController) IssuedDrug() {
166 166
 	}
167 167
 
168 168
 	if orgid == 10164 || orgid == 3877 || orgid == 10188 || orgid == 10217 || orgid == 9671 {
169
-		list, _ := service.GetTodayAdviceCountOne(stime, etime, orgid, 1)
169
+
170
+		//获取排班班次
171
+		schedule, _ := service.GetSchedulePatientId(stime, etime, orgid, shift, partition)
172
+		var ids []int64
173
+		for _, item := range schedule {
174
+			ids = append(ids, item.PatientId)
175
+		}
176
+
177
+		list, _ := service.GetTodayAdviceCountOne(stime, etime, orgid, 1, ids)
170 178
 		fmt.Println("list23323232323232", list)
171 179
 		var flist []models.TmpPatientOne
172 180
 		if len(list) > 0 {
@@ -247,6 +255,7 @@ func (this *PharmacyController) WaitingDrug() {
247 255
 			return
248 256
 		}
249 257
 		listt, err := service.PartitionAndLayout(stime, etime, orgid, shift, partition, flist)
258
+
250 259
 		if err != nil {
251 260
 			utils.ErrorLog(err.Error())
252 261
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
@@ -261,7 +270,15 @@ func (this *PharmacyController) WaitingDrug() {
261 270
 	//当天已发药的人数
262 271
 	if orgid == 9671 || orgid == 10188 || orgid == 10217 || orgid == 3877 || orgid == 10164 {
263 272
 
264
-		list, _ := service.GetTodayAdviceCountOne(stime, etime, orgid, 0)
273
+		//获取排班班次
274
+		schedule, _ := service.GetSchedulePatientId(stime, etime, orgid, shift, partition)
275
+		fmt.Println("schedule--------", schedule)
276
+		var ids []int64
277
+		for _, item := range schedule {
278
+			ids = append(ids, item.PatientId)
279
+		}
280
+
281
+		list, _ := service.GetTodayAdviceCountOne(stime, etime, orgid, 0, ids)
265 282
 
266 283
 		var flist []models.TmpPatientOne
267 284
 		if len(list) > 0 {
@@ -278,7 +295,6 @@ func (this *PharmacyController) WaitingDrug() {
278 295
 
279 296
 }
280 297
 
281
-//
282 298
 func (this *PharmacyController) GetPharmacyContent() {
283 299
 	var err error
284 300
 	defer func() {
@@ -320,7 +336,7 @@ func (this *PharmacyController) GetPharmacyContent() {
320 336
 
321 337
 }
322 338
 
323
-//发药按钮点击
339
+// 发药按钮点击
324 340
 func (this *PharmacyController) DispensingMedicine() {
325 341
 	var err error
326 342
 	defer func() {
@@ -399,7 +415,7 @@ func (this *PharmacyController) DispensingMedicine() {
399 415
 	return
400 416
 }
401 417
 
402
-//退药按钮点击
418
+// 退药按钮点击
403 419
 func (this *PharmacyController) DrugWithdrawal() {
404 420
 	var err error
405 421
 	defer func() {
@@ -437,7 +453,7 @@ func (this *PharmacyController) DrugWithdrawal() {
437 453
 
438 454
 }
439 455
 
440
-//发药明细列表
456
+// 发药明细列表
441 457
 func (this *PharmacyController) DispensingDetails() {
442 458
 	var err error
443 459
 	defer func() {
@@ -485,7 +501,7 @@ func (this *PharmacyController) DispensingDetails() {
485 501
 	return
486 502
 }
487 503
 
488
-//处方详情
504
+// 处方详情
489 505
 func (this *PharmacyController) PrescriptionDetails() {
490 506
 	var err error
491 507
 	defer func() {
@@ -518,7 +534,7 @@ func (this *PharmacyController) PrescriptionDetails() {
518 534
 	return
519 535
 }
520 536
 
521
-//已发药品的信息
537
+// 已发药品的信息
522 538
 func (this *PharmacyController) DispenseMedicine() {
523 539
 	var err error
524 540
 	defer func() {
@@ -563,7 +579,7 @@ func (this *PharmacyController) DispenseMedicine() {
563 579
 	return
564 580
 }
565 581
 
566
-//待发药的药品信息
582
+// 待发药的药品信息
567 583
 func (this *PharmacyController) WaitingMedicine() {
568 584
 	var err error
569 585
 	defer func() {
@@ -608,7 +624,7 @@ func (this *PharmacyController) WaitingMedicine() {
608 624
 	return
609 625
 }
610 626
 
611
-//获取药品的所有患者信息
627
+// 获取药品的所有患者信息
612 628
 func (this *PharmacyController) GetPatientsWithDrugs() {
613 629
 	var err error
614 630
 	defer func() {
@@ -675,7 +691,7 @@ func (this *PharmacyController) GetPatientsWithDrugs() {
675 691
 	return
676 692
 }
677 693
 
678
-//药品管理发药按钮点击
694
+// 药品管理发药按钮点击
679 695
 func (this *PharmacyController) MedicineDeparture() {
680 696
 	var err error
681 697
 	defer func() {

+ 1 - 0
models/dialysis.go View File

@@ -888,6 +888,7 @@ type XtDialysisOrder struct {
888 888
 	Number         int64  `gorm:"column:number" json:"number" form:"number"`
889 889
 	UserName       int64  `gorm:"column:user_name" json:"user_name" form:"user_name"`
890 890
 	WashpipeNurse  int64  `gorm:"column:washpipe_nurse" json:"washpipe_nurse" form:"washpipe_nurse"`
891
+	Url            string `gorm:"column:url" json:"url" form:"url"`
891 892
 }
892 893
 
893 894
 func (XtDialysisOrder) TableName() string {

+ 1 - 0
models/patient_models.go View File

@@ -1177,6 +1177,7 @@ type XtPatients struct {
1177 1177
 	SchRemark                    string  `gorm:"column:sch_remark" json:"sch_remark" form:"sch_remark"`
1178 1178
 	ScheduleRemark               string  `gorm:"column:schedule_remark" json:"schedule_remark" form:"schedule_remark"`
1179 1179
 	TreatmentPlan                string  `gorm:"column:treatment_plan" json:"treatment_plan" form:"treatment_plan"`
1180
+	Url                          string  `gorm:"column:url" json:"url" form:"url"`
1180 1181
 }
1181 1182
 
1182 1183
 func (XtPatients) TableName() string {

+ 16 - 4
service/his_service.go View File

@@ -618,7 +618,7 @@ func GetMonthHisPrescriptionThree(org_id int64, patient_id int64, start_date int
618 618
 	return
619 619
 }
620 620
 
621
-//未收费
621
+// 未收费
622 622
 func GetUnChargeMonthHisPrescriptionThree(org_id int64, patient_id int64, start_date int64, end_date int64, p_type int64) (prescription []*models.HisPrescription, err error) {
623 623
 	err = readDb.Model(&models.HisPrescription{}).
624 624
 		Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
@@ -637,7 +637,7 @@ func GetUnChargeMonthHisPrescriptionThree(org_id int64, patient_id int64, start_
637 637
 	return
638 638
 }
639 639
 
640
-//已收费
640
+// 已收费
641 641
 func GetChargeMonthHisPrescriptionFour(org_id int64, patient_id int64, start_date int64, end_date int64, p_type int64) (prescription []*models.HisPrescription, err error) {
642 642
 	err = readDb.Model(&models.HisPrescription{}).
643 643
 		Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
@@ -2235,7 +2235,7 @@ func GetHisPrescriptionTemplate(template_id int64, org_id int64) (prescription [
2235 2235
 	return
2236 2236
 }
2237 2237
 
2238
-//组
2238
+// 
2239 2239
 func GetHisPrescriptionTemplateL(template_id int64, org_id int64) (prescription []*models.HisPrescriptionInfoTemplateL, err error) {
2240 2240
 	err = readDb.Model(&models.HisPrescriptionInfoTemplateL{}).
2241 2241
 		Preload("HisPrescriptionAdviceTemplate", func(db *gorm.DB) *gorm.DB {
@@ -2343,7 +2343,7 @@ func GetChargeHisPrescriptionSeven(org_id int64, patient_id int64, order_number
2343 2343
 	return
2344 2344
 }
2345 2345
 
2346
-//已收费
2346
+// 已收费
2347 2347
 func GetChargeMonthHisPrescriptionFive(org_id int64, patient_id int64, order_number string, p_type int64) (prescription []*models.HisPrescription, err error) {
2348 2348
 	err = readDb.Model(&models.HisPrescription{}).
2349 2349
 		Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
@@ -2714,3 +2714,15 @@ func UpdatePatienPlan(id int64, trement_plan string) error {
2714 2714
 	err := XTWriteDB().Model(&models.XtPatientsNew{}).Where("blood_id = ? and status = 1", id).Update(map[string]interface{}{"treatment_plan": trement_plan}).Error
2715 2715
 	return err
2716 2716
 }
2717
+
2718
+func GetDialysisOrderList(orgid int64) (order []*models.XtDialysisOrder, err error) {
2719
+
2720
+	err = XTReadDB().Where("user_org_id = ? and status= 1 and url<>''", orgid).Group("patient_id").Find(&order).Error
2721
+	return order, err
2722
+}
2723
+
2724
+func UpdatePatientDialysisOrder(patient_id int64, url string) error {
2725
+
2726
+	err := XTWriteDB().Model(&models.XtPatients{}).Where("id =? and status=1", patient_id).Updates(map[string]interface{}{"url": url}).Error
2727
+	return err
2728
+}

+ 32 - 2
service/pharmacy_service.go View File

@@ -96,7 +96,33 @@ func GetTodayAdviceCount(stime, etime, orgid, is_medicine int64) (num int, err e
96 96
 	return len(tmp), err
97 97
 }
98 98
 
99
-func GetTodayAdviceCountOne(stime int64, etime int64, orgid int64, is_medicine int64) (advice []*models.HisDoctorAdviceInfo, err error) {
99
+func GetSchedulePatientId(start_time int64, end_time int64, org_id int64, class_type int64, partion_type int64) (schedule []*models.XtSchedules, err error) {
100
+
101
+	db := XTReadDB().Model(&schedule).Where("status = 1")
102
+
103
+	if start_time > 0 {
104
+		db = db.Where("schedule_date >=?", start_time)
105
+	}
106
+
107
+	if end_time > 0 {
108
+		db = db.Where("schedule_date <=?", end_time)
109
+	}
110
+
111
+	if org_id > 0 {
112
+		db = db.Where("user_org_id = ?", org_id)
113
+	}
114
+	if class_type > 0 {
115
+		db = db.Where("schedule_type =?", class_type)
116
+	}
117
+	if partion_type > 0 {
118
+		db = db.Where("partition_id = ?", partion_type)
119
+	}
120
+	err = db.Find(&schedule).Error
121
+
122
+	return schedule, err
123
+}
124
+
125
+func GetTodayAdviceCountOne(stime int64, etime int64, orgid int64, is_medicine int64, ids []int64) (advice []*models.HisDoctorAdviceInfo, err error) {
100 126
 
101 127
 	db := XTReadDB().Model(&advice).Where("status=1 and is_medicine = ?", is_medicine)
102 128
 	if stime > 0 {
@@ -108,6 +134,9 @@ func GetTodayAdviceCountOne(stime int64, etime int64, orgid int64, is_medicine i
108 134
 	if orgid > 0 {
109 135
 		db = db.Where("user_org_id = ?", orgid)
110 136
 	}
137
+	if len(ids) > 0 {
138
+		db = db.Where("patient_id in(?)", ids)
139
+	}
111 140
 
112 141
 	err = db.Group("patient_id").Find(&advice).Error
113 142
 	return advice, err
@@ -1828,7 +1857,8 @@ func PartitionAndLayout(stime, etime, orgid, shift, partition int64, flist []*mo
1828 1857
 	if shift == 0 && partition == 0 {
1829 1858
 		return flist, nil
1830 1859
 	}
1831
-	err = XTWriteDB().Model(&models.XtScheduleTwo{}).Where(s, orgid, stime, etime).Find(&sch).Error
1860
+	err = XTReadDB().Model(&models.XtScheduleTwo{}).Where(s, orgid, stime, etime).Find(&sch).Error
1861
+
1832 1862
 	if err != nil {
1833 1863
 		return
1834 1864
 	}