Browse Source

11月9日库存管理

XMLWAN 2 years ago
parent
commit
e70e91b93d

+ 1 - 1
conf/app.conf View File

@@ -1,5 +1,5 @@
1 1
 appname = 血透
2
-httpport = 9531
2
+httpport = 9529
3 3
 runmode = dev
4 4
 #dev/prod
5 5
 

+ 6 - 3
controllers/dialysis_api_controller.go View File

@@ -4356,14 +4356,17 @@ func (this *DialysisApiController) GetDialysisAdviceTemplateList() {
4356 4356
 	schedule_type, _ := this.GetInt64("schedule_type")
4357 4357
 
4358 4358
 	start_time := this.GetString("schedule_date")
4359
+
4360
+	ids := this.GetString("ids")
4361
+	idArray := strings.Split(ids, ",")
4359 4362
 	timeLayout := "2006-01-02"
4360 4363
 	loc, _ := time.LoadLocation("Local")
4361 4364
 	startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
4362 4365
 
4363 4366
 	orgId := this.GetAdminUserInfo().CurrentOrgId
4364
-
4365
-	list, total, err := service.GetDialysisAdviceTemplateList(keyword, limit, page, partition_id, schedule_type, startTime.Unix(), orgId)
4366
-
4367
+	fmt.Println("idArray", idArray)
4368
+	list, total, err := service.GetDialysisAdviceTemplateList(keyword, limit, page, partition_id, schedule_type, startTime.Unix(), orgId, idArray)
4369
+	fmt.Println("list2323223323223323323223wi", list)
4367 4370
 	//获取长期医嘱
4368 4371
 	adviceList, _ := service.GetAllLongAdviceList(orgId)
4369 4372
 

+ 2 - 0
controllers/dialysis_record_api_controller.go View File

@@ -1131,6 +1131,8 @@ func (this *DialysisRecordAPIController) StartDialysis() {
1131 1131
 				record.Conductivity = 14
1132 1132
 				record.BreathingRate = "20"
1133 1133
 				record.DialysateTemperature = 36.5
1134
+				record.VenousPressure = 80
1135
+				record.TransmembranePressure = 60
1134 1136
 			}
1135 1137
 
1136 1138
 			err := service.CreateMonitor(&record)

+ 1 - 0
controllers/drug_stock_api_contorller.go View File

@@ -1301,6 +1301,7 @@ func (c *StockDrugApiController) CreateDrugWarehouseOut() {
1301 1301
 					AdminUserId:             admin_user_id,
1302 1302
 					StockCount:              stock_count,
1303 1303
 					IsCheck:                 2,
1304
+					SysRecordTime:           warehousingOutDate.Unix(),
1304 1305
 				}
1305 1306
 				warehousingOutInfo = append(warehousingOutInfo, warehouseOutInfo)
1306 1307
 

+ 12 - 6
controllers/mobile_api_controllers/check_weight_api_controller.go View File

@@ -377,7 +377,9 @@ func (c *CheckWeightApiController) SavePatientInfoDialysis() {
377 377
 			newprescribe.TargetUltrafiltration = dewater_amount
378 378
 			newprescribe.Status = 1
379 379
 			newprescribe.Remark = dialysisSolution.Remark
380
-
380
+			if adminUserInfo.Org.Id == 10340 {
381
+				newprescribe.TargetUltrafiltration = 0
382
+			}
381 383
 			//插入透析处方
382 384
 			err := service.AddSigleRecord(&newprescribe)
383 385
 			key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
@@ -446,7 +448,9 @@ func (c *CheckWeightApiController) SavePatientInfoDialysis() {
446 448
 				newprescribe.TargetUltrafiltration = dewater_amount
447 449
 				newprescribe.Status = 1
448 450
 				newprescribe.Remark = lastDialysisPrescribe.Remark
449
-
451
+				if adminUserInfo.Org.Id == 10340 {
452
+					newprescribe.TargetUltrafiltration = 0
453
+				}
450 454
 				err := service.AddSigleRecord(&newprescribe)
451 455
 				key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
452 456
 				redis := service.RedisClient()
@@ -511,9 +515,9 @@ func (c *CheckWeightApiController) SavePatientInfoDialysis() {
511 515
 				newprescribe.TargetUltrafiltration = dewater_amount
512 516
 				newprescribe.Status = 1
513 517
 
514
-				fmt.Println(newprescribe.DewaterAmount)
515
-				fmt.Println(newprescribe.TargetUltrafiltration)
516
-
518
+				if adminUserInfo.Org.Id == 10340 {
519
+					newprescribe.TargetUltrafiltration = 0
520
+				}
517 521
 				err := service.AddSigleRecord(&newprescribe)
518 522
 				key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
519 523
 				redis := service.RedisClient()
@@ -564,7 +568,9 @@ func (c *CheckWeightApiController) SavePatientInfoDialysis() {
564 568
 			dialysisPrescribe.DewaterAmount = dewater_amount
565 569
 			dialysisPrescribe.TargetUltrafiltration = dewater_amount
566 570
 			dialysisPrescribe.Status = 1
567
-
571
+			if adminUserInfo.Org.Id == 10340 {
572
+				dialysisPrescribe.TargetUltrafiltration = 0
573
+			}
568 574
 			updateErr := service.UpDateDialysisPrescription(dialysisPrescribe)
569 575
 			key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
570 576
 			redis := service.RedisClient()

+ 2 - 1
controllers/mobile_api_controllers/dialysis_api_controller.go View File

@@ -2428,7 +2428,8 @@ func (this *DialysisAPIController) StartDialysis() {
2428 2428
 			record.DialysateTemperature = 36.5
2429 2429
 			record.Conductivity = 14
2430 2430
 			record.BreathingRate = "20"
2431
-
2431
+			record.VenousPressure = 80
2432
+			record.TransmembranePressure = 60
2432 2433
 		}
2433 2434
 		err := service.CreateMonitor(&record)
2434 2435
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":monitor_records"

+ 11 - 13
controllers/mobile_api_controllers/patient_api_controller.go View File

@@ -684,6 +684,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
684 684
 		privateDrugConfig, _ := service.GetDrugSetByUserOrgId(adminUserInfo.Org.Id)
685 685
 
686 686
 		storeHouseConfig, _ := service.GetAllStoreHouseConfig(adminUserInfo.Org.Id)
687
+		fmt.Println("drugStockConfig.IsOpen32232323232", drugStockConfig.IsOpen)
687 688
 		if drugStockConfig.IsOpen == 1 {
688 689
 			if groupno > 0 {
689 690
 				advices, _ := service.FindAllDoctorAdviceByGoroupNo(adminUserInfo.Org.Id, groupno)
@@ -699,6 +700,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
699 700
 				if isHasWay {
700 701
 					var total int64
701 702
 					var prescribing_number_total int64
703
+					fmt.Println("advicesssssssssssssssss", len(advices))
702 704
 					for _, item := range advices {
703 705
 						if item.Way == 1 {
704 706
 							houseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
@@ -721,7 +723,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
721 723
 								total = list.Count*medical.MinNumber + list.StockMinNumber
722 724
 								prescribing_number_total = count
723 725
 							}
724
-
726
+							fmt.Println("meiddidididssddssddsdsds", medical.IsUse)
725 727
 							if medical.IsUse == 1 {
726 728
 								c.ServeSuccessJSON(map[string]interface{}{
727 729
 									"msg":    "1",
@@ -807,13 +809,8 @@ func (c *PatientApiController) ExecDoctorAdvice() {
807 809
 							}
808 810
 						}
809 811
 					}
812
+
810 813
 				}
811
-				c.ServeSuccessJSON(map[string]interface{}{
812
-					"msg":    "1",
813
-					"advice": advice,
814
-					"ids":    ids,
815
-				})
816
-				return
817 814
 			} else {
818 815
 
819 816
 				advices, _ := service.FindDoctorAdviceByIds(adminUserInfo.Org.Id, ids)
@@ -905,12 +902,6 @@ func (c *PatientApiController) ExecDoctorAdvice() {
905 902
 									service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
906 903
 									//剩余库存
907 904
 									service.UpdateDrugStockCount(item.DrugId, item.UserOrgId, storeHouseConfig.DrugStorehouseOut, sum_count)
908
-									c.ServeSuccessJSON(map[string]interface{}{
909
-										"msg":    "1",
910
-										"advice": advice,
911
-										"ids":    ids,
912
-									})
913
-									return
914 905
 								}
915 906
 								if medical.IsUse == 1 {
916 907
 									c.ServeSuccessJSON(map[string]interface{}{
@@ -926,6 +917,13 @@ func (c *PatientApiController) ExecDoctorAdvice() {
926 917
 					}
927 918
 				}
928 919
 			}
920
+
921
+			c.ServeSuccessJSON(map[string]interface{}{
922
+				"msg":    "1",
923
+				"advice": advice,
924
+				"ids":    ids,
925
+			})
926
+			return
929 927
 		}
930 928
 
931 929
 		if privateDrugConfig != nil && privateDrugConfig.DrugStart == 1 {

+ 22 - 10
controllers/new_mobile_api_controllers/new_dialysis_api_controller.go View File

@@ -173,7 +173,7 @@ func (this *NewDialysisApiController) SavePatient() {
173 173
 	fmt.Print(birth)
174 174
 	phone := dataBody["phone"].(string)
175 175
 	relative_phone := dataBody["relative_phone"].(string)
176
-	fmt.Print("电话号码", phone)
176
+
177 177
 	patientType := dataBody["result"].([]interface{})
178 178
 	fmt.Print("患者标签", patientType)
179 179
 	dialysis := dataBody["dialysis"].(string)
@@ -243,6 +243,7 @@ func (this *NewDialysisApiController) SavePatient() {
243 243
 
244 244
 	remark := dataBody["remark"].(string)
245 245
 
246
+	treatment_plan := dataBody["treatment_plan"].(string)
246 247
 	//查询身份证号码是否存在
247 248
 	thisPatientOne, _ := service.FindPatientByIdCardNoFive(orgid, idCard)
248 249
 	if thisPatientOne.ID > 0 {
@@ -291,8 +292,9 @@ func (this *NewDialysisApiController) SavePatient() {
291 292
 			IsInfectious:      is_infectious,
292 293
 			RegistrarsId:      adminInfo.AdminUser.Id,
293 294
 			RelativePhone:     relative_phone,
294
-			Remark:            remark,
295
+			Remark:            "",
295 296
 			SchRemark:         remark,
297
+			TreatmentPlan:     treatment_plan,
296 298
 		}
297 299
 		err = service.CreateOldPatient(&patients)
298 300
 		fmt.Print("报错", err)
@@ -334,8 +336,9 @@ func (this *NewDialysisApiController) SavePatient() {
334 336
 			IdCardNo:          idCard,
335 337
 			RegistrarsId:      adminInfo.AdminUser.Id,
336 338
 			RelativePhone:     relative_phone,
337
-			Remark:            remark,
339
+			Remark:            "",
338 340
 			SchRemark:         remark,
341
+			TreatmentPlan:     treatment_plan,
339 342
 		}
340 343
 		err = service.CreateNewPatient(&patientsNew)
341 344
 		key := strconv.FormatInt(orgid, 10) + ":" + strconv.FormatInt(patient.ID, 10) + ":patient_info"
@@ -402,8 +405,9 @@ func (this *NewDialysisApiController) SavePatient() {
402 405
 					IsInfectious:      is_infectious,
403 406
 					IdCardNo:          idCard,
404 407
 					EquitmentId:       requipmentId,
405
-					Remark:            remark,
408
+					Remark:            "",
406 409
 					SchRemark:         remark,
410
+					TreatmentPlan:     treatment_plan,
407 411
 				}
408 412
 				err = service.CreateNewPatient(&patientsNew)
409 413
 				if err != nil {
@@ -465,7 +469,8 @@ func (this *NewDialysisApiController) SavePatient() {
465 469
 								MemberTreatement:  treatmentmethod,
466 470
 								RelativePhone:     relative_phone,
467 471
 								SchRemark:         remark,
468
-								Remark:            remark,
472
+								Remark:            "",
473
+								TreatmentPlan:     treatment_plan,
469 474
 							}
470 475
 							err = service.CreateNewPatient(&patientsNew)
471 476
 							fmt.Print("报错", err)
@@ -552,8 +557,9 @@ func (this *NewDialysisApiController) SavePatient() {
552 557
 					MemberPatienttype: patient_type,
553 558
 					MemberTreatement:  treatmentmethod,
554 559
 					RelativePhone:     relative_phone,
555
-					Remark:            remark,
560
+					Remark:            "",
556 561
 					SchRemark:         remark,
562
+					TreatmentPlan:     treatment_plan,
557 563
 				}
558 564
 				err = service.CreateNewPatient(&patientsNew)
559 565
 				fmt.Print("报错", err)
@@ -1338,6 +1344,8 @@ func (this *NewDialysisApiController) UpdatedPatient() {
1338 1344
 	out_reason := dataBody["out_reason"].(string)
1339 1345
 
1340 1346
 	remark := dataBody["remark"].(string)
1347
+
1348
+	treatment_plan := dataBody["treatment_plan"].(string)
1341 1349
 	fmt.Print(fisttime)
1342 1350
 	//如果是血透病人
1343 1351
 	if bloodPatient == 1 {
@@ -1392,8 +1400,9 @@ func (this *NewDialysisApiController) UpdatedPatient() {
1392 1400
 			DeathTime:         death_time,
1393 1401
 			OutReason:         out_reason,
1394 1402
 			RelativePhone:     relative_phone,
1395
-			Remark:            remark,
1403
+			Remark:            "",
1396 1404
 			SchRemark:         remark,
1405
+			TreatmentPlan:     treatment_plan,
1397 1406
 		}
1398 1407
 		err = service.UpdatedPatient(patients, patient.BloodId)
1399 1408
 		key := strconv.FormatInt(orgid, 10) + ":" + strconv.FormatInt(patient.BloodId, 10) + ":patient_info"
@@ -1424,8 +1433,9 @@ func (this *NewDialysisApiController) UpdatedPatient() {
1424 1433
 			OutReason:         out_reason,
1425 1434
 			DeathTime:         death_time,
1426 1435
 			RelativePhone:     relative_phone,
1427
-			Remark:            remark,
1436
+			Remark:            "",
1428 1437
 			SchRemark:         remark,
1438
+			TreatmentPlan:     treatment_plan,
1429 1439
 		}
1430 1440
 		err = service.UpdateXtPatientNew(patientsNew, id)
1431 1441
 		if err != nil {
@@ -1484,8 +1494,9 @@ func (this *NewDialysisApiController) UpdatedPatient() {
1484 1494
 			OutReason:         out_reason,
1485 1495
 			DeathTime:         death_time,
1486 1496
 			RelativePhone:     relative_phone,
1487
-			Remark:            remark,
1497
+			Remark:            "",
1488 1498
 			SchRemark:         remark,
1499
+			TreatmentPlan:     treatment_plan,
1489 1500
 		}
1490 1501
 		err = service.UpdateXtPatientNew(xtPatientsNew, id)
1491 1502
 		fmt.Print("更新失败", err)
@@ -1543,8 +1554,9 @@ func (this *NewDialysisApiController) UpdatedPatient() {
1543 1554
 			OutReason:         out_reason,
1544 1555
 			DeathTime:         death_time,
1545 1556
 			RelativePhone:     relative_phone,
1546
-			Remark:            remark,
1557
+			Remark:            "",
1547 1558
 			SchRemark:         remark,
1559
+			TreatmentPlan:     treatment_plan,
1548 1560
 		}
1549 1561
 		err = service.UpdateXtPatientNewOne(patientsNew, id)
1550 1562
 		if err != nil {

+ 108 - 1
controllers/new_mobile_api_controllers/staff_schedule_api_controller.go View File

@@ -724,7 +724,8 @@ func (c *StaffScheduleApiController) GetSolutionSchedule() {
724 724
 func (c *StaffScheduleApiController) GetAllBedList() {
725 725
 
726 726
 	orgId := c.GetMobileAdminUserInfo().Org.Id
727
-	list, _ := service.GetAllBedNumberSix(orgId)
727
+	partition_id, _ := c.GetInt64("partition_id")
728
+	list, _ := service.GetAllBedNumberTen(orgId, partition_id)
728 729
 	c.ServeSuccessJSON(map[string]interface{}{
729 730
 		"list": list,
730 731
 	})
@@ -744,3 +745,109 @@ func (c *StaffScheduleApiController) ChangeScheduleById() {
744 745
 		"msg": "ok",
745 746
 	})
746 747
 }
748
+
749
+func (c *StaffScheduleApiController) ChangeScheduleType() {
750
+
751
+	schedule_type, _ := c.GetInt64("schedule_type")
752
+	schedule_date, _ := c.GetInt64("schedule_date")
753
+	patient_id, _ := c.GetInt64("patient_id")
754
+	bed_id, _ := c.GetInt64("bed_id")
755
+	schedule_week, _ := c.GetInt64("schedule_week")
756
+	mode_id, _ := c.GetInt64("mode_id")
757
+	id, _ := c.GetInt64("id")
758
+	org_id := c.GetMobileAdminUserInfo().Org.Id
759
+	//查询该班次该床位是否已经存在患者
760
+	schedule, _ := service.GetScheduleByClassType(schedule_type, schedule_date, bed_id, org_id)
761
+	//查询该床位所属分区
762
+	numberlist, _ := service.GetPartionId(bed_id, org_id)
763
+	//存在
764
+	if schedule.ID > 0 {
765
+
766
+		//调换位置
767
+		sch := models.Schedule{
768
+			PatientId: schedule.PatientId,
769
+			ModeId:    schedule.ModeId,
770
+		}
771
+		service.UpdateScheduleById(id, sch)
772
+
773
+		schedu := models.Schedule{
774
+			PatientId: patient_id,
775
+			ModeId:    mode_id,
776
+		}
777
+		service.UpdateScheduleById(schedule.ID, schedu)
778
+
779
+	} else {
780
+		xtSchedule := models.Schedule{
781
+			UserOrgId:    org_id,
782
+			PartitionId:  numberlist.ZoneId,
783
+			BedId:        bed_id,
784
+			PatientId:    patient_id,
785
+			ScheduleDate: schedule_date,
786
+			ScheduleType: schedule_type,
787
+			ScheduleWeek: schedule_week,
788
+			ModeId:       mode_id,
789
+			Status:       1,
790
+			CreatedTime:  time.Now().Unix(),
791
+			UpdatedTime:  0,
792
+			IsExport:     0,
793
+		}
794
+		service.CreateSchedule(&xtSchedule)
795
+	}
796
+	c.ServeSuccessJSON(map[string]interface{}{
797
+		"msg": "ok",
798
+	})
799
+}
800
+
801
+func (c *StaffScheduleApiController) ChangeScheduleBed() {
802
+
803
+	fmt.Println("jin23323232233222323323232")
804
+	schedule_type, _ := c.GetInt64("schedule_type")
805
+	schedule_date, _ := c.GetInt64("schedule_date")
806
+	patient_id, _ := c.GetInt64("patient_id")
807
+	bed_id, _ := c.GetInt64("bed_id")
808
+	schedule_week, _ := c.GetInt64("schedule_week")
809
+	mode_id, _ := c.GetInt64("mode_id")
810
+	id, _ := c.GetInt64("id")
811
+	org_id := c.GetMobileAdminUserInfo().Org.Id
812
+
813
+	//查询该班次该床位是否已经存在患者
814
+	schedule, _ := service.GetScheduleByClassType(schedule_type, schedule_date, bed_id, org_id)
815
+	//查询该床位所属分区
816
+	numberlist, _ := service.GetPartionId(bed_id, org_id)
817
+	//存在
818
+	if schedule.ID > 0 {
819
+
820
+		//调换位置
821
+		sch := models.Schedule{
822
+			PatientId: schedule.PatientId,
823
+			ModeId:    schedule.ModeId,
824
+		}
825
+		service.UpdateScheduleById(id, sch)
826
+
827
+		schedu := models.Schedule{
828
+			PatientId: patient_id,
829
+			ModeId:    mode_id,
830
+		}
831
+		service.UpdateScheduleById(schedule.ID, schedu)
832
+	} else {
833
+		xtSchedule := models.Schedule{
834
+			UserOrgId:    org_id,
835
+			PartitionId:  numberlist.ZoneId,
836
+			BedId:        bed_id,
837
+			PatientId:    patient_id,
838
+			ScheduleDate: schedule_date,
839
+			ScheduleType: schedule_type,
840
+			ScheduleWeek: schedule_week,
841
+			ModeId:       mode_id,
842
+			Status:       1,
843
+			CreatedTime:  time.Now().Unix(),
844
+			UpdatedTime:  0,
845
+			IsExport:     0,
846
+		}
847
+		service.DeleteSchedule(id)
848
+		service.CreateSchedule(&xtSchedule)
849
+	}
850
+	c.ServeSuccessJSON(map[string]interface{}{
851
+		"msg": "ok",
852
+	})
853
+}

+ 4 - 0
controllers/new_mobile_api_controllers/staff_schedule_api_router.go View File

@@ -30,4 +30,8 @@ func StaffScheduleApiControllersRegisterRouters() {
30 30
 	beego.Router("m/api/schedule/getallbedlist", &StaffScheduleApiController{}, "Get:GetAllBedList")
31 31
 
32 32
 	beego.Router("m/api/schedule/changeschedulebyid", &StaffScheduleApiController{}, "Get:ChangeScheduleById")
33
+
34
+	beego.Router("m/api/schedule/changescheduletype", &StaffScheduleApiController{}, "Get:ChangeScheduleType")
35
+
36
+	beego.Router("m/api/schedule/changeschedulebed", &StaffScheduleApiController{}, "Get:ChangeScheduleBed")
33 37
 }

+ 3 - 0
enums/error_code.go View File

@@ -262,6 +262,8 @@ const ( // ErrorCode
262 262
 	ErrorCodeDeletePChargeWrongTwo = 3900004
263 263
 
264 264
 	ErrorCodeHisPatientNoRegException = 4000000
265
+
266
+	ErrorCodeSchedule = 50000000
265 267
 )
266 268
 
267 269
 var ErrCodeMsgs = map[int]string{
@@ -512,6 +514,7 @@ var ErrCodeMsgs = map[int]string{
512 514
 	ErrorCodeDeletePChargeWrongTwo: "该医嘱所属处方已经收费或已经上传的处方,无法删除",
513 515
 
514 516
 	ErrorCodeHisPatientNoRegException: "该患者尚未挂号,请先挂号",
517
+	ErrorCodeSchedule:                 "该班次该床位已有患者",
515 518
 }
516 519
 
517 520
 type SGJError struct {

+ 25 - 0
service/device_service.go View File

@@ -777,6 +777,12 @@ func GetAllBedNumberSix(orgId int64) (devicenumber []*models.ScheduleDeviceNumbe
777 777
 	return devicenumber, err
778 778
 }
779 779
 
780
+func GetAllBedNumberTen(orgId int64, zone_id int64) (devicenumber []*models.ScheduleDeviceNumber, err error) {
781
+
782
+	err = XTReadDB().Where("org_id = ? and status = 1 and zone_id = ?", orgId, zone_id).Find(&devicenumber).Error
783
+	return devicenumber, err
784
+}
785
+
780 786
 func GetAllBedNumberSeven(orgId int64) (devicenumber []*models.SgjDeviceNumber, err error) {
781 787
 
782 788
 	err = XTReadDB().Where("org_id = ? and status= 1", orgId).Preload("Zone", "status = 1").Find(&devicenumber).Error
@@ -796,3 +802,22 @@ func ChangeDialysisSolution(patient_id int64, schedule_date int64, org_id int64,
796 802
 	return err
797 803
 
798 804
 }
805
+
806
+func GetScheduleByClassType(schedule_type int64, schedule_date int64, bed_id int64, user_org_id int64) (models.XtSchedule, error) {
807
+	schedule := models.XtSchedule{}
808
+	err := XTReadDB().Where("schedule_type = ? and schedule_date = ? and bed_id = ? and user_org_id = ? and status = 1", schedule_type, schedule_date, bed_id, user_org_id).Find(&schedule).Error
809
+	return schedule, err
810
+}
811
+
812
+func GetPartionId(bed_id int64, org_id int64) (models.XtDeviceNumber, error) {
813
+
814
+	number := models.XtDeviceNumber{}
815
+	err = XTReadDB().Where("id = ? and status = 1 and org_id = ?", bed_id, org_id).Find(&number).Error
816
+	return number, err
817
+}
818
+
819
+func UpdateScheduleById(id int64, schedule models.Schedule) error {
820
+
821
+	err := XTWriteDB().Model(&models.Schedule{}).Where("id = ? and status =1", id).Update(map[string]interface{}{"patient_id": schedule.PatientId, "mode_id": schedule.ModeId}).Error
822
+	return err
823
+}

+ 6 - 1
service/dialysis_solution_service.go View File

@@ -2,6 +2,7 @@ package service
2 2
 
3 3
 import (
4 4
 	"XT_New/models"
5
+	"fmt"
5 6
 	"github.com/jinzhu/gorm"
6 7
 )
7 8
 
@@ -75,7 +76,7 @@ func GetPatientDialysisSolutionGroupList(keywords string, limit int64, page int6
75 76
 	return schedule, total, err
76 77
 }
77 78
 
78
-func GetDialysisAdviceTemplateList(keywords string, limit int64, page int64, partition_id int64, schedule_type int64, scheduleDate int64, orgID int64) (schedule []*models.VmBloodSchedule, total int64, err error) {
79
+func GetDialysisAdviceTemplateList(keywords string, limit int64, page int64, partition_id int64, schedule_type int64, scheduleDate int64, orgID int64, idArray []string) (schedule []*models.VmBloodSchedule, total int64, err error) {
79 80
 	db := XTReadDB().Model(&models.VmBloodSchedule{}).Where("xt_schedule.status = 1")
80 81
 	offset := (page - 1) * limit
81 82
 	if scheduleDate > 0 {
@@ -90,6 +91,10 @@ func GetDialysisAdviceTemplateList(keywords string, limit int64, page int64, par
90 91
 	if orgID > 0 {
91 92
 		db = db.Where("xt_schedule.user_org_id  = ?", orgID)
92 93
 	}
94
+	fmt.Println("idArray23233223323232233232", len(idArray))
95
+	if len(idArray) > 1 {
96
+		db = db.Where("xt_schedule.id in(?)", idArray)
97
+	}
93 98
 
94 99
 	if len(keywords) > 0 {
95 100
 		keywords = "%" + keywords + "%"

+ 14 - 11
service/patient_schedule_template_service.go View File

@@ -288,18 +288,21 @@ func UpdateScheduleTemplate(orgID int64, templateID int64,
288 288
 	for _, deviceNumber := range deviceNumbers {
289 289
 		devicesMap[deviceNumber.ID] = deviceNumber
290 290
 	}
291
-	if shouldUpdateNextWeekSchedules {
292
-		nextWeek := now.AddDate(0, 0, 7)
293
-		if updateErr := _updateWeekSchedules(tx, orgID, nextWeek, addTemplateItems, delTemplateItems, changeTemplateItems, devicesMap); updateErr != nil {
294
-			tx.Rollback()
295
-			return updateErr
291
+
292
+	if orgID != 9671 && orgID != 10340 {
293
+		if shouldUpdateNextWeekSchedules {
294
+			nextWeek := now.AddDate(0, 0, 7)
295
+			if updateErr := _updateWeekSchedules(tx, orgID, nextWeek, addTemplateItems, delTemplateItems, changeTemplateItems, devicesMap); updateErr != nil {
296
+				tx.Rollback()
297
+				return updateErr
298
+			}
296 299
 		}
297
-	}
298
-	if shouldUpdateNextSecondWeekSchedules {
299
-		nextWeek := now.AddDate(0, 0, 14)
300
-		if updateErr := _updateWeekSchedules(tx, orgID, nextWeek, addTemplateItems, delTemplateItems, changeTemplateItems, devicesMap); updateErr != nil {
301
-			tx.Rollback()
302
-			return updateErr
300
+		if shouldUpdateNextSecondWeekSchedules {
301
+			nextWeek := now.AddDate(0, 0, 14)
302
+			if updateErr := _updateWeekSchedules(tx, orgID, nextWeek, addTemplateItems, delTemplateItems, changeTemplateItems, devicesMap); updateErr != nil {
303
+				tx.Rollback()
304
+				return updateErr
305
+			}
303 306
 		}
304 307
 	}
305 308
 

+ 3 - 3
service/patientmanage_service.go View File

@@ -950,21 +950,21 @@ func GetNewPatient(id int64) (models.XtPatientsNew, error) {
950 950
 
951 951
 func UpdatedPatient(patients models.Patients, id int64) error {
952 952
 
953
-	err := XTWriteDB().Model(&patients).Where("id=?", id).Update(map[string]interface{}{"name": patients.Name, "gender": patients.Gender, "birthday": patients.Birthday, "age": patients.Age, "phone": patients.Phone, "lapseto": patients.Lapseto, "admission_number": patients.AdmissionNumber, "first_dialysis_date": patients.FirstDialysisDate, "diagnose": patients.Diagnose, "source": patients.Source, "dialysis_no": patients.DialysisNo, "avatar": patients.Avatar, "id_card_no": patients.IdCardNo, "is_infectious": patients.IsInfectious, "out_reason": patients.OutReason, "death_time": patients.DeathTime, "relative_phone": patients.RelativePhone, "remark": patients.Remark, "sch_remark": patients.SchRemark}).Error
953
+	err := XTWriteDB().Model(&patients).Where("id=?", id).Update(map[string]interface{}{"name": patients.Name, "gender": patients.Gender, "birthday": patients.Birthday, "age": patients.Age, "phone": patients.Phone, "lapseto": patients.Lapseto, "admission_number": patients.AdmissionNumber, "first_dialysis_date": patients.FirstDialysisDate, "diagnose": patients.Diagnose, "source": patients.Source, "dialysis_no": patients.DialysisNo, "avatar": patients.Avatar, "id_card_no": patients.IdCardNo, "is_infectious": patients.IsInfectious, "out_reason": patients.OutReason, "death_time": patients.DeathTime, "relative_phone": patients.RelativePhone, "remark": patients.Remark, "sch_remark": patients.SchRemark, "treatment_plan": patients.TreatmentPlan}).Error
954 954
 
955 955
 	return err
956 956
 }
957 957
 
958 958
 func UpdateXtPatientNew(patients models.XtPatientsNew, id int64) error {
959 959
 
960
-	err := XTWriteDB().Model(&patients).Where("id=?", id).Update(map[string]interface{}{"name": patients.Name, "gender": patients.Gender, "birthday": patients.Birthday, "age": patients.Age, "phone": patients.Phone, "lapseto": patients.Lapseto, "admission_number": patients.AdmissionNumber, "first_dialysis_date": patients.FirstDialysisDate, "diagnose": patients.Diagnose, "source": patients.Source, "dialysis_no": patients.DialysisNo, "avatar": patients.Avatar, "id_card_no": patients.IdCardNo, "is_infectious": patients.IsInfectious, "out_reason": patients.OutReason, "death_time": patients.DeathTime, "relative_phone": patients.RelativePhone, "remark": patients.Remark, "sch_remark": patients.SchRemark}).Error
960
+	err := XTWriteDB().Model(&patients).Where("id=?", id).Update(map[string]interface{}{"name": patients.Name, "gender": patients.Gender, "birthday": patients.Birthday, "age": patients.Age, "phone": patients.Phone, "lapseto": patients.Lapseto, "admission_number": patients.AdmissionNumber, "first_dialysis_date": patients.FirstDialysisDate, "diagnose": patients.Diagnose, "source": patients.Source, "dialysis_no": patients.DialysisNo, "avatar": patients.Avatar, "id_card_no": patients.IdCardNo, "is_infectious": patients.IsInfectious, "out_reason": patients.OutReason, "death_time": patients.DeathTime, "relative_phone": patients.RelativePhone, "remark": patients.Remark, "sch_remark": patients.SchRemark, "treatment_plan": patients.TreatmentPlan}).Error
961 961
 
962 962
 	return err
963 963
 }
964 964
 
965 965
 func UpdateXtPatientNewOne(patients models.XtPatientsNew, id int64) error {
966 966
 
967
-	err := XTWriteDB().Model(&patients).Where("id=?", id).Update(map[string]interface{}{"name": patients.Name, "gender": patients.Gender, "birthday": patients.Birthday, "age": patients.Age, "phone": patients.Phone, "lapseto": patients.Lapseto, "adminssion_number": patients.AdmissionNumber, "first_dialysis_date": patients.FirstDialysisDate, "diagnose": patients.Diagnose, "source": patients.Source, "dialysis_no": patients.DialysisNo, "avatar": patients.Avatar, "id_card_no": patients.IdCardNo, "is_infectious": patients.IsInfectious, "member_patienttype": patients.MemberPatienttype, "member_treatement": patients.MemberTreatement}).Error
967
+	err := XTWriteDB().Model(&patients).Where("id=?", id).Update(map[string]interface{}{"name": patients.Name, "gender": patients.Gender, "birthday": patients.Birthday, "age": patients.Age, "phone": patients.Phone, "lapseto": patients.Lapseto, "adminssion_number": patients.AdmissionNumber, "first_dialysis_date": patients.FirstDialysisDate, "diagnose": patients.Diagnose, "source": patients.Source, "dialysis_no": patients.DialysisNo, "avatar": patients.Avatar, "id_card_no": patients.IdCardNo, "is_infectious": patients.IsInfectious, "member_patienttype": patients.MemberPatienttype, "member_treatement": patients.MemberTreatement, "treatment_plan": patients.TreatmentPlan}).Error
968 968
 	return err
969 969
 }
970 970