Browse Source

历史排班

28169 1 year ago
parent
commit
8346bb7e3f

+ 3 - 3
controllers/dialysis_api_controller.go View File

@@ -3419,9 +3419,9 @@ func adviceFormDatas(advice *models.DoctorAdvice, data []byte, action string) (c
3419 3419
 }
3420 3420
 
3421 3421
 func (c *DialysisApiController) GetDialysisOrder() {
3422
-	xtno := c.GetString("xtno")
3422
+	//xtno := c.GetString("xtno")
3423 3423
 	xtdate := c.GetString("xtdate")
3424
-
3424
+	patient_id, _ := c.GetInt64("patient_id")
3425 3425
 	timeLayout := "2006-01-02"
3426 3426
 	loc, _ := time.LoadLocation("Local")
3427 3427
 	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", xtdate+" 00:00:00", loc)
@@ -3438,7 +3438,7 @@ func (c *DialysisApiController) GetDialysisOrder() {
3438 3438
 
3439 3439
 	adminUser, _ := service.GetAllAdminUsers(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
3440 3440
 
3441
-	patientInfo, _ := service.FindPatientWithDeviceByNo(adminUserInfo.CurrentOrgId, xtno, xttime)
3441
+	patientInfo, _ := service.FindPatientWithDeviceByPatientId(adminUserInfo.CurrentOrgId, patient_id, xttime)
3442 3442
 
3443 3443
 	//透析单
3444 3444
 	dialysisOrder, _ := service.MobileGetSchedualDialysisRecordTen(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)

+ 52 - 7
controllers/mobile_api_controllers/patient_api_controller.go View File

@@ -719,6 +719,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
719 719
 							}
720 720
 
721 721
 							if medical.IsUse == 1 {
722
+								service.UpdateDoctorAdviceByExcecute(advice.ID, advice.UserOrgId)
722 723
 								c.ServeSuccessJSON(map[string]interface{}{
723 724
 									"msg":    "1",
724 725
 									"advice": advice,
@@ -729,14 +730,17 @@ func (c *PatientApiController) ExecDoctorAdvice() {
729 730
 
730 731
 							if medical.IsUse != 1 {
731 732
 								if (list.Count*medical.MinNumber + list.StockMinNumber) == 0 {
733
+									service.UpdateDoctorAdviceByExcecute(advice.ID, advice.UserOrgId)
732 734
 									c.ServeSuccessJSON(map[string]interface{}{
733 735
 										"msg":    "3",
734 736
 										"advice": advice,
735 737
 										"ids":    ids,
736 738
 									})
737 739
 									return
740
+
738 741
 								}
739 742
 								if prescribing_number_total > total {
743
+									service.UpdateDoctorAdviceByExcecute(advice.ID, advice.UserOrgId)
740 744
 									c.ServeSuccessJSON(map[string]interface{}{
741 745
 										"msg":    "2",
742 746
 										"advice": advice,
@@ -752,7 +756,6 @@ func (c *PatientApiController) ExecDoctorAdvice() {
752 756
 					//出库
753 757
 					for _, item := range advices {
754 758
 						if item.Way == 1 {
755
-
756 759
 							//查询是否出库按钮开启
757 760
 							adviceSetting, _ := service.FindAdviceSettingById(item.UserOrgId)
758 761
 							//查询改药品信息
@@ -760,14 +763,23 @@ func (c *PatientApiController) ExecDoctorAdvice() {
760 763
 							if adviceSetting.IsAdviceOpen == 1 {
761 764
 								//查询是否出库按钮开启
762 765
 								prescriptionConfig, _ := service.FindPrescriptionConfigById(item.UserOrgId)
766
+								//患者发药
763 767
 								pharmacyConfig, _ := service.FindPharmacyConfig(item.UserOrgId)
764 768
 								if prescriptionConfig.IsOpen == 1 {
765 769
 									if medical.IsUse == 2 {
766 770
 										if pharmacyConfig.IsOpen == 1 && medical.IsPharmacy == 0 {
767
-											service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
771
+											//查询今日是否出库
772
+											drugOutInfo, _ := service.GetAdviceIsOut(item.ID, item.UserOrgId, item.PatientId, item.AdviceDate, item.DrugId)
773
+											if drugOutInfo.ID == 0 {
774
+												service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
775
+											}
776
+
768 777
 										}
769 778
 										if pharmacyConfig.IsOpen != 1 {
770
-											service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
779
+											drugOutInfo, _ := service.GetAdviceIsOut(item.ID, item.UserOrgId, item.PatientId, item.AdviceDate, item.DrugId)
780
+											if drugOutInfo.ID == 0 {
781
+												service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
782
+											}
771 783
 										}
772 784
 
773 785
 										//更新字典里面的库存
@@ -788,10 +800,32 @@ func (c *PatientApiController) ExecDoctorAdvice() {
788 800
 								pharmacyConfig, _ := service.FindPharmacyConfig(item.UserOrgId)
789 801
 								if medical.IsUse == 2 {
790 802
 									if pharmacyConfig.IsOpen == 1 && medical.IsPharmacy == 0 {
791
-										service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
803
+										drugOutInfo, _ := service.GetAdviceIsOut(item.ID, item.UserOrgId, item.PatientId, item.AdviceDate, item.DrugId)
804
+										if drugOutInfo.ID == 0 {
805
+											service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
806
+										}
792 807
 									}
793 808
 									if pharmacyConfig.IsOpen != 1 {
794
-										service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
809
+										drugError := models.XtDrugError{
810
+											ID:                    0,
811
+											UserOrgId:             item.UserOrgId,
812
+											DrugId:                item.DrugId,
813
+											RecordDate:            item.AdviceDate,
814
+											PatientId:             item.PatientId,
815
+											Remark:                "恒泰中医院出库开始",
816
+											Status:                1,
817
+											Ctime:                 time.Now().Unix(),
818
+											Mtime:                 0,
819
+											Prescribingnumber:     item.PrescribingNumber,
820
+											PrescribingNumberUnit: item.PrescribingNumberUnit,
821
+											SumCount:              0,
822
+										}
823
+										service.CreateDrugError(drugError)
824
+										drugOutInfo, _ := service.GetAdviceIsOut(item.ID, item.UserOrgId, item.PatientId, item.AdviceDate, item.DrugId)
825
+										if drugOutInfo.ID == 0 {
826
+
827
+											service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
828
+										}
795 829
 									}
796 830
 
797 831
 									stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
@@ -855,6 +889,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
855 889
 							}
856 890
 
857 891
 							if medical.IsUse == 1 {
892
+								service.UpdateDoctorAdviceByExcecute(advice.ID, advice.UserOrgId)
858 893
 								c.ServeSuccessJSON(map[string]interface{}{
859 894
 									"msg":    "1",
860 895
 									"advice": advice,
@@ -864,6 +899,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
864 899
 							}
865 900
 							if medical.IsUse != 1 {
866 901
 								if (list.Count*medical.MinNumber + list.StockMinNumber) == 0 {
902
+									service.UpdateDoctorAdviceByExcecute(advice.ID, advice.UserOrgId)
867 903
 									c.ServeSuccessJSON(map[string]interface{}{
868 904
 										"msg":    "3",
869 905
 										"advice": advice,
@@ -872,6 +908,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
872 908
 									return
873 909
 								}
874 910
 								if prescribing_number_total > total {
911
+									service.UpdateDoctorAdviceByExcecute(advice.ID, advice.UserOrgId)
875 912
 									c.ServeSuccessJSON(map[string]interface{}{
876 913
 										"msg":    "2",
877 914
 										"advice": advice,
@@ -891,10 +928,18 @@ func (c *PatientApiController) ExecDoctorAdvice() {
891 928
 							pharmacyConfig, _ := service.FindPharmacyConfig(item.UserOrgId)
892 929
 							if medical.IsUse == 2 {
893 930
 								if pharmacyConfig.IsOpen == 1 && medical.IsPharmacy == 0 {
894
-									service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
931
+									//查询今日是否出库
932
+									drugOutInfo, _ := service.GetAdviceIsOut(item.ID, item.UserOrgId, item.PatientId, item.AdviceDate, item.DrugId)
933
+									if drugOutInfo.ID == 0 {
934
+										service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
935
+									}
895 936
 								}
896 937
 								if pharmacyConfig.IsOpen != 1 {
897
-									service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
938
+									//查询今日是否出库
939
+									drugOutInfo, _ := service.GetAdviceIsOut(item.ID, item.UserOrgId, item.PatientId, item.AdviceDate, item.DrugId)
940
+									if drugOutInfo.ID == 0 {
941
+										service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
942
+									}
898 943
 								}
899 944
 
900 945
 								//更新字典里面的库存

+ 1 - 1
controllers/print_data_api_controller.go View File

@@ -37,7 +37,7 @@ func (this *PrintDataAPIController) ScheduleDialysisRecordPrintData() {
37 37
 	idStrs := strings.Split(schIDStr, ",")
38 38
 	adminUserInfo := this.GetAdminUserInfo()
39 39
 
40
-	if this.GetAdminUserInfo().CurrentOrgId == 10016 || this.GetAdminUserInfo().CurrentOrgId == 9882 || this.GetAdminUserInfo().CurrentOrgId == 10138 || this.GetAdminUserInfo().CurrentOrgId == 10278 || this.GetAdminUserInfo().CurrentOrgId == 9841 || this.GetAdminUserInfo().CurrentOrgId == 9845 || this.GetAdminUserInfo().CurrentOrgId == 10081 || this.GetAdminUserInfo().CurrentOrgId == 10215 || this.GetAdminUserInfo().CurrentOrgId == 10121 || this.GetAdminUserInfo().CurrentOrgId == 10234 || this.GetAdminUserInfo().CurrentOrgId == 10188 || this.GetAdminUserInfo().CurrentOrgId == 10217 || this.GetAdminUserInfo().CurrentOrgId == 10340 {
40
+	if this.GetAdminUserInfo().CurrentOrgId == 10016 || this.GetAdminUserInfo().CurrentOrgId == 9882 || this.GetAdminUserInfo().CurrentOrgId == 10138 || this.GetAdminUserInfo().CurrentOrgId == 10278 || this.GetAdminUserInfo().CurrentOrgId == 9841 || this.GetAdminUserInfo().CurrentOrgId == 9845 || this.GetAdminUserInfo().CurrentOrgId == 10081 || this.GetAdminUserInfo().CurrentOrgId == 10215 || this.GetAdminUserInfo().CurrentOrgId == 10121 || this.GetAdminUserInfo().CurrentOrgId == 10234 || this.GetAdminUserInfo().CurrentOrgId == 10188 || this.GetAdminUserInfo().CurrentOrgId == 10217 || this.GetAdminUserInfo().CurrentOrgId == 10340 || this.GetAdminUserInfo().CurrentOrgId == 10340 {
41 41
 		schedules, getScheduleErr := service.GetSchedulesSeven(adminUserInfo.CurrentOrgId, idStrs)
42 42
 		for _, item := range schedules {
43 43
 

+ 6 - 0
service/dialysis_service.go View File

@@ -2090,3 +2090,9 @@ func UpdateLastMonitorRecordToday(accumulated_blood_volume float64, id int64) er
2090 2090
 	err := XTWriteDB().Model(&models.MonitoringRecord{}).Where(" id = ? and status= 1", id).Update(map[string]interface{}{"accumulated_blood_volume": accumulated_blood_volume}).Error
2091 2091
 	return err
2092 2092
 }
2093
+
2094
+func UpdateDoctorAdviceByExcecute(id int64, user_org_id int64) error {
2095
+
2096
+	err := XTWriteDB().Model(models.DoctorAdvice{}).Where("id = ? and user_org_id = ? and status =1").Updates(map[string]interface{}{"execution_time": 0, "execution_staff": 0, "execution_state": 0}).Error
2097
+	return err
2098
+}

+ 9 - 0
service/patient_service.go View File

@@ -609,6 +609,15 @@ func FindPatientWithDeviceByNo(orgID int64, no string, time int64) (patient mode
609 609
 	return
610 610
 }
611 611
 
612
+func FindPatientWithDeviceByPatientId(orgID int64, id int64, time int64) (patient models.SchedualPatient2, err error) {
613
+	err = readDb.Preload("DialysisSchedule", func(db *gorm.DB) *gorm.DB {
614
+		return db.Preload("DeviceNumber", "org_id = ?", orgID).
615
+			Preload("DeviceZone", "org_id = ?", orgID).
616
+			Where("user_org_id = ? AND schedule_date = ? ", orgID, time)
617
+	}).Preload("InfectiousDiseases", "status = 1").Where("user_org_id=? and id = ? and status = 1 ", orgID, id).First(&patient).Error
618
+	return
619
+}
620
+
612 621
 func CreatePatient(patient *models.Patients, contagions []int64, diseases []int64) (err error) {
613 622
 
614 623
 	user, _ := GetSgjUserByMobild(patient.Phone)

+ 30 - 0
service/warhouse_service.go View File

@@ -83,6 +83,21 @@ func DrugsDelivery(orgID int64, creater int64, advice *models.DoctorAdvice) (err
83 83
 // 药品自动出库 递归方式
84 84
 func DrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *models.DrugWarehouseOut, drup *models.BaseDrugLib, advice *models.DoctorAdvice) (err error) {
85 85
 
86
+	drugError := models.XtDrugError{
87
+		ID:                    0,
88
+		UserOrgId:             advice.UserOrgId,
89
+		DrugId:                advice.DrugId,
90
+		RecordDate:            advice.AdviceDate,
91
+		PatientId:             advice.PatientId,
92
+		Remark:                "恒泰中医院出库进来",
93
+		Status:                1,
94
+		Ctime:                 time.Now().Unix(),
95
+		Mtime:                 0,
96
+		Prescribingnumber:     advice.PrescribingNumber,
97
+		PrescribingNumberUnit: advice.PrescribingNumberUnit,
98
+		SumCount:              0,
99
+	}
100
+	CreateDrugError(drugError)
86 101
 	// 判断处方里药品单位是拆零单位还是包装单位,	如果是包装单位,则根据规格,将包装数量转为拆零数量
87 102
 	var deliver_number int64 = 0
88 103
 	var stock_number int64 = 0
@@ -249,6 +264,7 @@ func DrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *model
249 264
 			StorehouseId:            storeConfig.DrugStorehouseOut,
250 265
 			IsCheck:                 1,
251 266
 			OverCount:               sum_count,
267
+			AdviceId:                advice.ID,
252 268
 		}
253 269
 
254 270
 		errOne := AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
@@ -282,6 +298,7 @@ func DrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *model
282 298
 			WarehouseOutDetailId:    lastDrugOutInfo.ID,
283 299
 			LastPrice:               warehouse.Price,
284 300
 			OverCount:               sum_count,
301
+			AdviceId:                advice.ID,
285 302
 		}
286 303
 
287 304
 		CreateDrugFlowOne(drugflow)
@@ -302,6 +319,7 @@ func DrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *model
302 319
 			CountUnit:               drup.MinUnit,
303 320
 			WarehouseInfoId:         warehouse.ID,
304 321
 			StorehouseId:            storeConfig.DrugStorehouseOut,
322
+			AdviceId:                advice.ID,
305 323
 		}
306 324
 		errTwo := AddSigleDrugAutoReduceRecordInfo(details)
307 325
 		if errTwo != nil {
@@ -346,6 +364,7 @@ func DrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *model
346 364
 			SupplyWarehouseId:       warehouse.SupplyWarehouseId,
347 365
 			StorehouseId:            storeConfig.DrugStorehouseOut,
348 366
 			IsCheck:                 1,
367
+			AdviceId:                advice.ID,
349 368
 		}
350 369
 		errOne := AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
351 370
 		if errOne != nil {
@@ -366,6 +385,7 @@ func DrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *model
366 385
 			CountUnit:               drup.MinUnit,
367 386
 			WarehouseInfoId:         warehouse.ID,
368 387
 			StorehouseId:            storeConfig.DrugStorehouseOut,
388
+			AdviceId:                advice.ID,
369 389
 		}
370 390
 		errTwo := AddSigleDrugAutoReduceRecordInfo(details)
371 391
 		if errTwo != nil {
@@ -455,6 +475,7 @@ func DrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *model
455 475
 			WarehouseOutDetailId:    lastDrugOutInfo.ID,
456 476
 			LastPrice:               warehouse.Price,
457 477
 			OverCount:               sum_count,
478
+			AdviceId:                advice.ID,
458 479
 		}
459 480
 
460 481
 		CreateDrugFlowOne(drugflow)
@@ -7489,3 +7510,12 @@ func UpdateHisAdviceById(id int64) error {
7489 7510
 	err := XTWriteDB().Model(&models.HisDoctorAdviceInfo{}).Where("id = ?", id).Updates(map[string]interface{}{"execution_time": "", "execution_staff": "", "execution_state": 2}).Error
7490 7511
 	return err
7491 7512
 }
7513
+
7514
+func GetAdviceIsOut(advice_id int64, user_org_id int64, patient_id int64, advice_date int64, drug_id int64) (models.DrugWarehouseOutInfo, error) {
7515
+
7516
+	advice := models.DrugWarehouseOutInfo{}
7517
+
7518
+	err := XTReadDB().Where("advice_id = ? and org_id = ? and patient_id = ? and sys_record_time = ? and status=1 and drug_id = ?", advice_id, user_org_id, patient_id, advice_date, drug_id).Find(&advice).Error
7519
+
7520
+	return advice, err
7521
+}