28169 1 год назад
Родитель
Сommit
953fd65f03

+ 9 - 8
controllers/doctor_schedule_api_controller.go Просмотреть файл

@@ -1,13 +1,14 @@
1 1
 package controllers
2 2
 
3 3
 import (
4
+	"fmt"
5
+	"time"
6
+
4 7
 	"XT_New/enums"
5 8
 	"XT_New/models"
6 9
 	"XT_New/service"
7
-	"fmt"
8 10
 	"github.com/astaxie/beego"
9 11
 	"github.com/jinzhu/gorm"
10
-	"time"
11 12
 )
12 13
 
13 14
 type DoctorScheduleApiController struct {
@@ -282,17 +283,17 @@ func (this *DoctorScheduleApiController) AddSchedule() {
282 283
 
283 284
 	orgId := this.GetAdminUserInfo().CurrentOrgId
284 285
 	doctor_id, _ := this.GetInt64("doctor_id")
285
-	fmt.Println("doctor_id", doctor_id)
286
+
286 287
 	doctor_type, _ := this.GetInt64("doctor_type")
287
-	fmt.Println("doctor_type", doctor_type)
288
+
288 289
 	start_time, _ := this.GetInt64("start_time")
289
-	fmt.Println("start_time", start_time)
290
+
290 291
 	end_time, _ := this.GetInt64("end_time")
291
-	fmt.Println("end_time", end_time)
292
+
292 293
 	schedule_type, _ := this.GetInt64("schedule_type")
293
-	fmt.Println("schedule_type", schedule_type)
294
+
294 295
 	schedule_week, _ := this.GetInt64("schedule_week")
295
-	fmt.Println("schedule_week", schedule_week)
296
+
296 297
 	schedule_date, _ := this.GetInt64("schedule_date")
297 298
 	schedule := models.StaffSchedule{
298 299
 		DoctorId:     doctor_id,

+ 118 - 264
controllers/his_api_controller.go Просмотреть файл

@@ -1866,7 +1866,7 @@ func (c *HisApiController) CreateHisPrescription() {
1866 1866
 
1867 1867
 	patient, _ := service.GetPatientByIDTwo(adminInfo.CurrentOrgId, patient_id)
1868 1868
 
1869
-	//保存处方出库
1869
+	//自动出库的开关开启
1870 1870
 	_, drugStockConfig := service.FindDrugStockAutomaticReduceRecordByOrgId(c.GetAdminUserInfo().CurrentOrgId)
1871 1871
 
1872 1872
 	//自动出库
@@ -1927,6 +1927,7 @@ func (c *HisApiController) CreateHisPrescription() {
1927 1927
 		}
1928 1928
 	}
1929 1929
 	if isMidicine == true {
1930
+
1930 1931
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeMedicineWrong)
1931 1932
 		return
1932 1933
 	}
@@ -1982,6 +1983,8 @@ func (c *HisApiController) CreateHisPrescription() {
1982 1983
 
1983 1984
 								drug, _ := service.FindBaseDrugLibRecordSeven(adminInfo.CurrentOrgId, drug_id)
1984 1985
 								if drug.ID == 0 {
1986
+
1987
+									tx.Rollback()
1985 1988
 									c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1986 1989
 									return
1987 1990
 								}
@@ -1997,18 +2000,20 @@ func (c *HisApiController) CreateHisPrescription() {
1997 2000
 								//查询该药品是否存在开药记录
1998 2001
 								advicelist, _ := service.GetHisAdviceListByDrugIdEight(drug_id, patient_id, recordDateTime, adviceId)
1999 2002
 
2000
-								//新增处方
2003
+								//新增处方盘点库存是否充足
2001 2004
 								if advicelist.ID == 0 {
2002 2005
 									all_count, _ := strconv.ParseFloat(totals, 64)
2003 2006
 									if prescribingNumberUnit == drug.MinUnit {
2004 2007
 										if drug.IsUse != 1 {
2005 2008
 											if drug.IsProject == 0 || drug.IsProject == 2 {
2006 2009
 												if all_count == 0 {
2010
+													tx.Rollback()
2007 2011
 													c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2008 2012
 													return
2009 2013
 												}
2010 2014
 
2011 2015
 												if prescribing_number > all_count {
2016
+													tx.Rollback()
2012 2017
 													c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2013 2018
 													return
2014 2019
 												}
@@ -2022,10 +2027,12 @@ func (c *HisApiController) CreateHisPrescription() {
2022 2027
 										if drug.IsUse != 1 {
2023 2028
 											if drug.IsProject == 0 || drug.IsProject == 2 {
2024 2029
 												if all_count == 0 {
2030
+													tx.Rollback()
2025 2031
 													c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2026 2032
 													return
2027 2033
 												}
2028 2034
 												if num > all_count {
2035
+													tx.Rollback()
2029 2036
 													c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2030 2037
 													return
2031 2038
 												}
@@ -2036,6 +2043,7 @@ func (c *HisApiController) CreateHisPrescription() {
2036 2043
 								}
2037 2044
 
2038 2045
 								drugOutConfig, _ := service.GetDrugOpenConfigOne(adminInfo.CurrentOrgId)
2046
+								//不使用保存处方出库
2039 2047
 								if drugOutConfig.IsOpen != 1 {
2040 2048
 									//修改处方
2041 2049
 									for _, advice := range advices {
@@ -2064,6 +2072,7 @@ func (c *HisApiController) CreateHisPrescription() {
2064 2072
 
2065 2073
 										drug, _ := service.FindBaseDrugLibRecordSeven(adminInfo.CurrentOrgId, drug_id)
2066 2074
 										if drug.ID == 0 {
2075
+											tx.Rollback()
2067 2076
 											c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2068 2077
 											return
2069 2078
 										}
@@ -2085,10 +2094,12 @@ func (c *HisApiController) CreateHisPrescription() {
2085 2094
 												if drug.IsUse != 1 {
2086 2095
 													if drug.IsProject == 0 || drug.IsProject == 2 {
2087 2096
 														if all_count == 0 {
2097
+															tx.Rollback()
2088 2098
 															c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2089 2099
 															return
2090 2100
 														}
2091 2101
 														if prescribing_number > all_count {
2102
+															tx.Rollback()
2092 2103
 															c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2093 2104
 															return
2094 2105
 														}
@@ -2101,10 +2112,12 @@ func (c *HisApiController) CreateHisPrescription() {
2101 2112
 													if drug.IsUse != 1 {
2102 2113
 														if drug.IsProject == 0 || drug.IsProject == 2 {
2103 2114
 															if all_count == 0 {
2115
+																tx.Rollback()
2104 2116
 																c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2105 2117
 																return
2106 2118
 															}
2107 2119
 															if num > all_count {
2120
+																tx.Rollback()
2108 2121
 																c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2109 2122
 																return
2110 2123
 															}
@@ -2146,6 +2159,7 @@ func (c *HisApiController) CreateHisPrescription() {
2146 2159
 												//如果修改的差数量 大于库存数量
2147 2160
 												if drug.IsUse != 1 {
2148 2161
 													if (number_count - device_number) > total_count {
2162
+														tx.Rollback()
2149 2163
 														c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2150 2164
 														return
2151 2165
 													}
@@ -2197,6 +2211,7 @@ func (c *HisApiController) CreateHisPrescription() {
2197 2211
 
2198 2212
 								drug, _ := service.FindBaseDrugLibRecordSeven(adminInfo.CurrentOrgId, drug_id)
2199 2213
 								if drug.ID == 0 {
2214
+									tx.Rollback()
2200 2215
 									c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2201 2216
 									return
2202 2217
 								}
@@ -2221,6 +2236,7 @@ func (c *HisApiController) CreateHisPrescription() {
2221 2236
 								//新增处方
2222 2237
 								if advicelist.ID == 0 {
2223 2238
 									all_count, _ := strconv.ParseFloat(totals, 64)
2239
+
2224 2240
 									batch_number_all_count, _ := strconv.ParseFloat(batch_number_counts, 64)
2225 2241
 
2226 2242
 									if prescribingNumberUnit == drug.MinUnit {
@@ -2229,10 +2245,12 @@ func (c *HisApiController) CreateHisPrescription() {
2229 2245
 
2230 2246
 											if drug.IsProject == 0 || drug.IsProject == 2 {
2231 2247
 												if all_count == 0 {
2248
+													tx.Rollback()
2232 2249
 													c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2233 2250
 													return
2234 2251
 												}
2235 2252
 												if prescribing_number > all_count {
2253
+													tx.Rollback()
2236 2254
 													c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2237 2255
 													return
2238 2256
 												}
@@ -2240,6 +2258,7 @@ func (c *HisApiController) CreateHisPrescription() {
2240 2258
 
2241 2259
 											if adminInfo.CurrentOrgId == 10215 {
2242 2260
 												if prescribing_number > batch_number_all_count {
2261
+													tx.Rollback()
2243 2262
 													c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
2244 2263
 													return
2245 2264
 												}
@@ -2253,10 +2272,12 @@ func (c *HisApiController) CreateHisPrescription() {
2253 2272
 										if drug.IsUse != 1 {
2254 2273
 											if drug.IsProject == 0 || drug.IsProject == 2 {
2255 2274
 												if all_count == 0 {
2275
+													tx.Rollback()
2256 2276
 													c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2257 2277
 													return
2258 2278
 												}
2259 2279
 												if num > all_count {
2280
+													tx.Rollback()
2260 2281
 													c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2261 2282
 													return
2262 2283
 												}
@@ -2264,6 +2285,7 @@ func (c *HisApiController) CreateHisPrescription() {
2264 2285
 
2265 2286
 											if adminInfo.CurrentOrgId == 10215 {
2266 2287
 												if num > batch_number_all_count {
2288
+													tx.Rollback()
2267 2289
 													c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
2268 2290
 													return
2269 2291
 												}
@@ -2302,6 +2324,7 @@ func (c *HisApiController) CreateHisPrescription() {
2302 2324
 
2303 2325
 										drug, _ := service.FindBaseDrugLibRecordSeven(adminInfo.CurrentOrgId, drug_id)
2304 2326
 										if drug.ID == 0 {
2327
+											tx.Rollback()
2305 2328
 											c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2306 2329
 											return
2307 2330
 										}
@@ -2329,10 +2352,12 @@ func (c *HisApiController) CreateHisPrescription() {
2329 2352
 												if drug.IsUse != 1 {
2330 2353
 													if drug.IsProject == 0 || drug.IsProject == 2 {
2331 2354
 														if all_count == 0 {
2355
+															tx.Rollback()
2332 2356
 															c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2333 2357
 															return
2334 2358
 														}
2335 2359
 														if prescribing_number > all_count {
2360
+															tx.Rollback()
2336 2361
 															c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2337 2362
 															return
2338 2363
 														}
@@ -2340,6 +2365,7 @@ func (c *HisApiController) CreateHisPrescription() {
2340 2365
 
2341 2366
 													if adminInfo.CurrentOrgId == 10215 {
2342 2367
 														if prescribing_number > batch_number_all_count {
2368
+															tx.Rollback()
2343 2369
 															c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
2344 2370
 															return
2345 2371
 														}
@@ -2354,10 +2380,12 @@ func (c *HisApiController) CreateHisPrescription() {
2354 2380
 													if drug.IsUse != 1 {
2355 2381
 														if drug.IsProject == 0 || drug.IsProject == 2 {
2356 2382
 															if all_count == 0 {
2383
+																tx.Rollback()
2357 2384
 																c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2358 2385
 																return
2359 2386
 															}
2360 2387
 															if num > all_count {
2388
+																tx.Rollback()
2361 2389
 																c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2362 2390
 																return
2363 2391
 															}
@@ -2365,6 +2393,7 @@ func (c *HisApiController) CreateHisPrescription() {
2365 2393
 
2366 2394
 														if adminInfo.CurrentOrgId == 10215 {
2367 2395
 															if prescribing_number > batch_number_all_count {
2396
+																tx.Rollback()
2368 2397
 																c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
2369 2398
 																return
2370 2399
 															}
@@ -2412,15 +2441,18 @@ func (c *HisApiController) CreateHisPrescription() {
2412 2441
 												if drug.IsUse != 1 {
2413 2442
 													if drug.IsProject == 0 || drug.IsProject == 2 {
2414 2443
 														if total_count == 0 {
2444
+															tx.Rollback()
2415 2445
 															c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2416 2446
 															return
2417 2447
 														}
2418 2448
 														if (number_count - device_number) > total_count {
2449
+															tx.Rollback()
2419 2450
 															c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2420 2451
 															return
2421 2452
 														}
2422 2453
 
2423 2454
 														if (number_count - device_number) > batch_number_count {
2455
+															tx.Rollback()
2424 2456
 															c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
2425 2457
 															return
2426 2458
 														}
@@ -2449,6 +2481,7 @@ func (c *HisApiController) CreateHisPrescription() {
2449 2481
 
2450 2482
 														if out_count > 0 {
2451 2483
 															if (number_count - device_number) > in_count {
2484
+																tx.Rollback()
2452 2485
 																c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(stock_max_number, 10) + drug.MaxUnit + strconv.FormatInt(stock_min_number, 10) + drug.MinUnit)
2453 2486
 																return
2454 2487
 															}
@@ -2461,6 +2494,7 @@ func (c *HisApiController) CreateHisPrescription() {
2461 2494
 															fmt.Println("sum_in_count", sum_in_count)
2462 2495
 															//如果修改的数量大于有库存的第一个批次
2463 2496
 															if number_count > sum_in_count {
2497
+																tx.Rollback()
2464 2498
 																c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(warehouseInfo.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(warehouseInfo.StockMinNumber, 10) + drug.MinUnit)
2465 2499
 																return
2466 2500
 															}
@@ -2584,10 +2618,12 @@ func (c *HisApiController) CreateHisPrescription() {
2584 2618
 												if drug.IsUse != 1 {
2585 2619
 													if drug.IsProject == 0 || drug.IsProject == 2 {
2586 2620
 														if all_count == 0 {
2621
+															tx.Rollback()
2587 2622
 															c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2588 2623
 															return
2589 2624
 														}
2590 2625
 														if prescribing_number > all_count {
2626
+															tx.Rollback()
2591 2627
 															c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2592 2628
 															return
2593 2629
 														}
@@ -2595,6 +2631,7 @@ func (c *HisApiController) CreateHisPrescription() {
2595 2631
 
2596 2632
 													if adminInfo.CurrentOrgId == 10215 {
2597 2633
 														if prescribing_number > batch_number_all_count {
2634
+															tx.Rollback()
2598 2635
 															c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
2599 2636
 															return
2600 2637
 														}
@@ -2609,10 +2646,12 @@ func (c *HisApiController) CreateHisPrescription() {
2609 2646
 													if drug.IsUse != 1 {
2610 2647
 														if drug.IsProject == 0 || drug.IsProject == 2 {
2611 2648
 															if all_count == 0 {
2649
+																tx.Rollback()
2612 2650
 																c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2613 2651
 																return
2614 2652
 															}
2615 2653
 															if num > all_count {
2654
+																tx.Rollback()
2616 2655
 																c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2617 2656
 																return
2618 2657
 															}
@@ -2620,6 +2659,7 @@ func (c *HisApiController) CreateHisPrescription() {
2620 2659
 
2621 2660
 														if adminInfo.CurrentOrgId == 10215 {
2622 2661
 															if prescribing_number > batch_number_all_count {
2662
+																tx.Rollback()
2623 2663
 																c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
2624 2664
 																return
2625 2665
 															}
@@ -2659,16 +2699,21 @@ func (c *HisApiController) CreateHisPrescription() {
2659 2699
 												prescribingNumberInt, _ := strconv.ParseInt(prescribingNumber, 10, 64)
2660 2700
 												number_count = prescribingNumberInt
2661 2701
 											}
2702
+											fmt.Println("number_count--------------", number_count)
2703
+											fmt.Println("device_number--------------", device_number)
2704
+											fmt.Println("batch_number_count", batch_number_count)
2662 2705
 											//如果修改的数量大于之前修改的数量
2663 2706
 											if (number_count - device_number) > 0 {
2664 2707
 												//如果修改的差数量 大于库存数量
2665 2708
 												if drug.IsUse != 1 {
2666 2709
 													if drug.IsProject == 0 || drug.IsProject == 2 {
2667 2710
 														if total_count == 0 {
2711
+															tx.Rollback()
2668 2712
 															c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2669 2713
 															return
2670 2714
 														}
2671 2715
 														if (number_count - device_number) > total_count {
2716
+															tx.Rollback()
2672 2717
 															c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
2673 2718
 															return
2674 2719
 														}
@@ -2676,6 +2721,7 @@ func (c *HisApiController) CreateHisPrescription() {
2676 2721
 
2677 2722
 													if adminInfo.CurrentOrgId == 10215 {
2678 2723
 														if (number_count - device_number) > batch_number_count {
2724
+															tx.Rollback()
2679 2725
 															c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
2680 2726
 															return
2681 2727
 														}
@@ -2703,6 +2749,7 @@ func (c *HisApiController) CreateHisPrescription() {
2703 2749
 
2704 2750
 														if out_count > 0 {
2705 2751
 															if (number_count - device_number) > in_count {
2752
+																tx.Rollback()
2706 2753
 																c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(stock_max_number, 10) + drug.MaxUnit + strconv.FormatInt(stock_min_number, 10) + drug.MinUnit)
2707 2754
 																return
2708 2755
 															}
@@ -2714,11 +2761,13 @@ func (c *HisApiController) CreateHisPrescription() {
2714 2761
 															warehouseInfo, _ := service.FindLastDrugWarehousingInfoByID(drug_id, storeConfig.DrugStorehouseOut)
2715 2762
 															sum_in_count = warehouseInfo.StockMaxNumber*drug.MinNumber + warehouseInfo.StockMinNumber
2716 2763
 															if sum_in_count == 0 {
2764
+																tx.Rollback()
2717 2765
 																c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(warehouseInfo.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(warehouseInfo.StockMinNumber, 10) + drug.MinUnit)
2718 2766
 																return
2719 2767
 															}
2720 2768
 															//如果修改的数量大于有库存的第一个批次
2721 2769
 															if number_count > sum_in_count {
2770
+																tx.Rollback()
2722 2771
 																c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(warehouseInfo.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(warehouseInfo.StockMinNumber, 10) + drug.MinUnit)
2723 2772
 																return
2724 2773
 															}
@@ -2790,10 +2839,12 @@ func (c *HisApiController) CreateHisPrescription() {
2790 2839
 										stock_counts := strconv.FormatInt(stock_count, 10)
2791 2840
 										stock_total_count, _ := strconv.ParseFloat(stock_counts, 64)
2792 2841
 										if stock_total_count == 0 {
2842
+											tx.Rollback()
2793 2843
 											c.ServeDynamicFailJsonSend(project_name + "库存不足")
2794 2844
 											return
2795 2845
 										}
2796 2846
 										if totals > stock_total_count {
2847
+											tx.Rollback()
2797 2848
 											c.ServeDynamicFailJsonSend(project_name + "库存不足")
2798 2849
 											return
2799 2850
 										}
@@ -2817,10 +2868,12 @@ func (c *HisApiController) CreateHisPrescription() {
2817 2868
 
2818 2869
 												//库存不足
2819 2870
 												if stock_count == 0 {
2871
+													tx.Rollback()
2820 2872
 													c.ServeDynamicFailJsonSend(project_name + "库存不足")
2821 2873
 													return
2822 2874
 												}
2823 2875
 												if (parsetotal - count) > stock_count {
2876
+													tx.Rollback()
2824 2877
 													c.ServeDynamicFailJsonSend(project_name + "库存不足")
2825 2878
 													return
2826 2879
 												}
@@ -2896,10 +2949,12 @@ func (c *HisApiController) CreateHisPrescription() {
2896 2949
 											stock_counts := strconv.FormatInt(stock_count, 10)
2897 2950
 											stock_total_count, _ := strconv.ParseFloat(stock_counts, 64)
2898 2951
 											if stock_total_count == 0 {
2952
+												tx.Rollback()
2899 2953
 												c.ServeDynamicFailJsonSend(project_name + "库存不足")
2900 2954
 												return
2901 2955
 											}
2902 2956
 											if totals > stock_total_count {
2957
+												tx.Rollback()
2903 2958
 												c.ServeDynamicFailJsonSend(project_name + "库存不足")
2904 2959
 												return
2905 2960
 											}
@@ -3117,7 +3172,7 @@ func (c *HisApiController) CreateHisPrescription() {
3117 3172
 	var adviceList []models.HisDoctorAdviceInfo
3118 3173
 	var projectList []models.HisPrescriptionProject
3119 3174
 
3120
-	if adminInfo.CurrentOrgId == 10489 || adminInfo.CurrentOrgId == 10510 || adminInfo.CurrentOrgId == 10164 || adminInfo.CurrentOrgId == 10478 {
3175
+	if adminInfo.CurrentOrgId == 10489 || adminInfo.CurrentOrgId == 10510 || adminInfo.CurrentOrgId == 10164 || adminInfo.CurrentOrgId == 10478 || adminInfo.CurrentOrgId == 10318 || adminInfo.CurrentOrgId == 10480 {
3121 3176
 		if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
3122 3177
 			prescriptions, _ := dataBody["prescriptions"].([]interface{})
3123 3178
 
@@ -3308,16 +3363,23 @@ func (c *HisApiController) CreateHisPrescription() {
3308 3363
 										s.Price = lastWarehouse.RetailPrice
3309 3364
 									}
3310 3365
 									if s.Price == 0 {
3311
-										s.Price = lastWarehouse.RetailPrice
3366
+										if lastWarehouse.ID == 0 {
3367
+											lastWarehouseTwo, _ := service.FindLastDrugWarehousingInfoByIDTwo(s.DrugId, storeConfig.DrugStorehouseOut)
3368
+											s.Price = lastWarehouseTwo.RetailPrice
3369
+										}
3370
+
3312 3371
 									}
3313 3372
 								}
3314 3373
 
3315 3374
 								//查询保存处方出库开关是否打开
3316 3375
 								drugOutConfig, _ := service.GetDrugOpenConfigOne(adminInfo.CurrentOrgId)
3376
+
3317 3377
 								if drugOutConfig.IsOpen == 1 {
3378
+
3318 3379
 									drug, _ := service.FindBaseDrugLibRecordSeven(adminInfo.CurrentOrgId, s.DrugId)
3319 3380
 									// 查询该药品最后一次出库记录
3320 3381
 									druginfo, _ := service.GetLastDrugWarehouseOutByDrugIdTwenty(s.DrugId, patient_id, recordDateTime, s.ID)
3382
+
3321 3383
 									if len(druginfo) > 0 {
3322 3384
 										//回退库存
3323 3385
 										for _, it := range druginfo {
@@ -3337,8 +3399,10 @@ func (c *HisApiController) CreateHisPrescription() {
3337 3399
 
3338 3400
 											}
3339 3401
 										}
3402
+
3340 3403
 										//删除记录
3341
-										service.DeleteDrugAutoWarehouseSeven(s.DrugId, patient_id, recordDateTime, s.ID)
3404
+										service.DeleteNewDrugAutoWarehouseSeven(s.DrugId, patient_id, recordDateTime, s.ID)
3405
+
3342 3406
 									}
3343 3407
 
3344 3408
 									service.CreateHisDoctorAdviceOne(&s, tx)
@@ -3472,8 +3536,55 @@ func (c *HisApiController) CreateHisPrescription() {
3472 3536
 								timeFormat := tempTime.Format("20060102150405")
3473 3537
 								s.FeedetlSn = timeFormat + strconv.FormatInt(int64(randNum), 10) + "-" + "1" + "-" + strconv.FormatInt(s.ID, 10)
3474 3538
 								service.CreateHisDoctorAdviceOne(&s, tx)
3475
-
3539
+								//list, _ := service.GetHisToday(s.PatientId, s.AdviceDate, s.UserOrgId, s.DrugId, tx)
3540
+								//var count_total int64
3541
+								//var count_one int64
3542
+								//for _, its := range list {
3543
+								//	baseDrug, _ := service.GetNewBaseDrugMedical(its.DrugId, tx)
3544
+								//	if its.PrescribingNumberUnit == baseDrug.MaxUnit && baseDrug.MaxUnit != baseDrug.MinUnit {
3545
+								//		prescribingNumberTenty := strconv.FormatFloat(its.PrescribingNumber, 'f', -1, 64)
3546
+								//		prescribingNumberSevenTy, _ := strconv.ParseInt(prescribingNumberTenty, 10, 64)
3547
+								//		count_total += prescribingNumberSevenTy * baseDrug.MinNumber
3548
+								//	}
3549
+								//
3550
+								//	if its.PrescribingNumberUnit == baseDrug.MinUnit && baseDrug.MaxUnit != baseDrug.MinUnit {
3551
+								//		prescribingNumberTenty := strconv.FormatFloat(its.PrescribingNumber, 'f', -1, 64)
3552
+								//		prescribingNumberSevenTy, _ := strconv.ParseInt(prescribingNumberTenty, 10, 64)
3553
+								//		count_total += prescribingNumberSevenTy
3554
+								//	}
3555
+								//
3556
+								//	if its.PrescribingNumberUnit == baseDrug.MaxUnit && baseDrug.MaxUnit == baseDrug.MinUnit {
3557
+								//		prescribingNumberTenty := strconv.FormatFloat(its.PrescribingNumber, 'f', -1, 64)
3558
+								//		prescribingNumberSevenTy, _ := strconv.ParseInt(prescribingNumberTenty, 10, 64)
3559
+								//		count_total += prescribingNumberSevenTy
3560
+								//	}
3561
+								//
3562
+								//	drugAuto, _ := service.GetLastDrugAuto(its.ID, its.DrugId, its.AdviceDate, its.PatientId,its.UserOrgId, tx)
3563
+								//
3564
+								//	if drugAuto.CountUnit == baseDrug.MaxUnit && baseDrug.MaxUnit != baseDrug.MinUnit {
3565
+								//
3566
+								//		count_one = drugAuto.Count * baseDrug.MinNumber
3567
+								//	}
3568
+								//
3569
+								//	if drugAuto.CountUnit == baseDrug.MinUnit && baseDrug.MaxUnit != baseDrug.MinUnit {
3570
+								//
3571
+								//		count_one = drugAuto.Count
3572
+								//	}
3573
+								//
3574
+								//	if drugAuto.CountUnit == baseDrug.MaxUnit && baseDrug.MaxUnit == baseDrug.MinUnit {
3575
+								//
3576
+								//		count_one = drugAuto.Count
3577
+								//	}
3578
+								//	fmt.Println("count_one==================", count_one)
3579
+								//	fmt.Println("count_total==================", count_total)
3580
+								//	if count_total != count_one {
3581
+								//
3582
+								//		service.UpdateTodayHis(its.DrugId, its.AdviceDate, its.PatientId, its.UserOrgId, baseDrug.MinUnit, count_total, its.ID, tx)
3583
+								//	}
3584
+								//
3585
+								//}
3476 3586
 								tx.Commit()
3587
+
3477 3588
 								keySix := strconv.FormatInt(adminInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(theTime.Unix(), 10) + ":his_advices_list_all"
3478 3589
 								redis.Set(keySix, "", time.Second)
3479 3590
 								keyFive := strconv.FormatInt(adminInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(recordDateTime, 10) + ":his_doctor_advice"
@@ -3859,265 +3970,8 @@ func (c *HisApiController) CreateHisPrescription() {
3859 3970
 				}
3860 3971
 
3861 3972
 			}
3862
-
3863
-			//查询今日该患者开的药品处方
3864
-			//hisdoctorlist, _ := service.GetNewHisAdviceListByDrugIdTwo(patient_id, recordDateTime, adminInfo.CurrentOrgId, tx)
3865
-			//drugOutConfig, _ := service.GetDrugOpenConfigOne(adminInfo.CurrentOrgId)
3866
-
3867
-			//药品出库
3868
-			//if drugOutConfig.IsOpen == 1 {
3869
-			//	for _, item := range hisdoctorlist {
3870
-			//		drug, _ := service.FindBaseDrugLibRecordSeven(adminInfo.CurrentOrgId, item.DrugId)
3871
-			//
3872
-			//		// 查询该药品最后一次出库记录
3873
-			//		druginfo, _ := service.GetLastNewDrugWarehouseOutByDrugIdTwenty(item.DrugId, patient_id, recordDateTime, item.ID, tx)
3874
-			//
3875
-			//		if len(druginfo) > 0 {
3876
-			//			//回退库存
3877
-			//			for _, it := range druginfo {
3878
-			//
3879
-			//				if it.CountUnit == drug.MaxUnit && drug.MaxUnit != drug.MinUnit {
3880
-			//
3881
-			//					service.ModifyNewDrugWarehouseInfoStockMaxNumber(it.Count, it.DrugId, it.OrgId, it.WarehouseInfoId, tx)
3882
-			//
3883
-			//				}
3884
-			//				if it.CountUnit == drug.MinUnit && drug.MaxUnit != drug.MinUnit {
3885
-			//
3886
-			//					service.ModifyNewDrugWarehouseInfoStockMinNumber(it.Count, it.DrugId, it.OrgId, it.WarehouseInfoId, tx)
3887
-			//
3888
-			//				}
3889
-			//				if it.CountUnit == drug.MaxUnit && drug.MaxUnit == drug.MinUnit {
3890
-			//
3891
-			//					service.ModifyNewDrugWarehouseInfoStockMaxNumber(it.Count, it.DrugId, it.OrgId, it.WarehouseInfoId, tx)
3892
-			//
3893
-			//				}
3894
-			//			}
3895
-			//		}
3896
-			//
3897
-			//		//删除记录
3898
-			//		service.DeleteNewDrugAutoWarehouseSeven(item.DrugId, patient_id, recordDateTime, item.ID, tx)
3899
-			//		//查询最后一次数据
3900
-			//		if drugOutConfig.IsOpen == 1 {
3901
-			//			//出库
3902
-			//			if drug.IsUse == 2 {
3903
-			//				creater := adminInfo.AdminUser.Id
3904
-			//
3905
-			//				service.NewHisDrugsDelivery(item.UserOrgId, creater, item, tx)
3906
-			//
3907
-			//			}
3908
-			//
3909
-			//			//更新字典里面的库存
3910
-			//			stockInfo, _ := service.GetNewDrugAllStockInfo(storeConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId, tx)
3911
-			//			var sum_count int64
3912
-			//			for _, its := range stockInfo {
3913
-			//				baseDrug, _ := service.GetNewBaseDrugMedical(its.DrugId, tx)
3914
-			//				if its.MaxUnit == baseDrug.MaxUnit {
3915
-			//					its.StockMaxNumber = its.StockMaxNumber * baseDrug.MinNumber
3916
-			//				}
3917
-			//				sum_count += its.StockMaxNumber + its.StockMinNumber
3918
-			//			}
3919
-			//			//更新基础库存
3920
-			//			service.UpdateNewBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId, tx)
3921
-			//			//剩余库存
3922
-			//			service.UpdateNewDrugStockCount(item.DrugId, item.UserOrgId, storeConfig.DrugStorehouseOut, sum_count, tx)
3923
-			//
3924
-			//			over, _ := service.FindNewOverCount(item.DrugId, item.UserOrgId, storeConfig.DrugStorehouseOut, tx)
3925
-			//			service.UpdateNewActOut(over.ID, over.SumInCount, over.FlushCount, over.SumCancelCount, tx)
3926
-			//
3927
-			//		}
3928
-			//	}
3929
-			//}
3930
-
3931
-			//耗材保存处方出库
3932
-			//if goodOutConfig.IsOpen == 1 {
3933
-			//
3934
-			//	//查询今日耗材出库数量
3935
-			//	hisgoodlist, _ := service.GetHisGoodList(patient_id, recordDateTime, adminInfo.CurrentOrgId)
3936
-			//
3937
-			//	for _, item := range hisgoodlist {
3938
-			//
3939
-			//		//查询历史出库数据
3940
-			//		flowGood, _ := service.GetStockFlowIsBatchNumberSeventy(item.PatientId, item.RecordDate, item.ProjectId, item.ID)
3941
-			//		var out_count_five int64
3942
-			//		for _, item := range flowGood {
3943
-			//			out_count_five += item.Count
3944
-			//		}
3945
-			//
3946
-			//		parseIntCount, _ := strconv.ParseInt(item.Count, 10, 64)
3947
-			//
3948
-			//		if out_count_five != parseIntCount {
3949
-			//
3950
-			//			//查询耗材最后一次出库记录
3951
-			//			wareOut, _ := service.GetLastGoodWarehouseOutInfoByProjectId(item.ProjectId, patient_id, recordDateTime, item.ID)
3952
-			//			//查询默认出库仓库库存
3953
-			//			storeConfig, _ := service.GetAllStoreHouseConfig(adminInfo.CurrentOrgId)
3954
-			//			if len(wareOut) > 0 {
3955
-			//
3956
-			//				for _, it := range wareOut {
3957
-			//					//回退库存
3958
-			//					service.ModifyGoodWarehouseInfo(it.GoodId, it.WarehouseInfotId, it.OrgId, it.Count)
3959
-			//
3960
-			//					//删除出库记录
3961
-			//					service.DeleteGoodWarehouseOutInfo(it.GoodId, it.SysRecordTime, it.OrgId, it.ProjectId)
3962
-			//
3963
-			//				}
3964
-			//			}
3965
-			//
3966
-			//			timeStr := time.Now().Format("2006-01-02")
3967
-			//			timeArr := strings.Split(timeStr, "-")
3968
-			//			total, _ := service.FindAllWarehouseOut(adminInfo.CurrentOrgId)
3969
-			//
3970
-			//			total = total + 1
3971
-			//			warehousing_out_order := strconv.FormatInt(adminInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
3972
-			//			number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
3973
-			//			number = number + total
3974
-			//			warehousing_out_order = "CKD" + strconv.FormatInt(number, 10)
3975
-			//
3976
-			//			operation_time := time.Now().Unix()
3977
-			//			creater := c.GetAdminUserInfo().AdminUser.Id
3978
-			//
3979
-			//			recordDateStr := time.Now().Format("2006-01-02")
3980
-			//			recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
3981
-			//			nowtime := recordDate.Unix()
3982
-			//			warehouseOut := models.WarehouseOut{
3983
-			//				WarehouseOutOrderNumber: warehousing_out_order,
3984
-			//				OperationTime:           operation_time,
3985
-			//				OrgId:                   adminInfo.CurrentOrgId,
3986
-			//				Creater:                 creater,
3987
-			//				Ctime:                   time.Now().Unix(),
3988
-			//				Status:                  1,
3989
-			//				WarehouseOutTime:        nowtime,
3990
-			//				Type:                    1,
3991
-			//				StorehouseId:            storeConfig.StorehouseOutInfo,
3992
-			//				IsCheck:                 1,
3993
-			//				IsSys:                   1,
3994
-			//			}
3995
-			//			//查询是否生成出库单
3996
-			//			out, _ := service.FindPrescriptionWarehouseOut(adminInfo.CurrentOrgId, nowtime)
3997
-			//
3998
-			//			if out.ID == 0 {
3999
-			//				service.AddSigleWarehouseOut(&warehouseOut)
4000
-			//			}
4001
-			//
4002
-			//			lastOut, _ := service.FindLastPrescriptionWarehouseOut(adminInfo.CurrentOrgId, nowtime)
4003
-			//
4004
-			//			goodObj, _ := service.GetGoodInformationByGoodIdThirty(item.ProjectId)
4005
-			//			houseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
4006
-			//
4007
-			//			dialyPrepareOne := models.DialysisBeforePrepare{
4008
-			//				GoodTypeId:   goodObj.GoodTypeId,
4009
-			//				GoodId:       item.ProjectId,
4010
-			//				PatientId:    item.PatientId,
4011
-			//				RecordDate:   item.RecordDate,
4012
-			//				UserOrgId:    adminInfo.CurrentOrgId,
4013
-			//				Count:        parseIntCount,
4014
-			//				Ctime:        time.Now().Unix(),
4015
-			//				Creater:      creater,
4016
-			//				Status:       1,
4017
-			//				StorehouseId: houseConfig.StorehouseOutInfo,
4018
-			//				ProjectId:    item.ID,
4019
-			//			}
4020
-			//			goodinfo, _ := service.GetGoodInformationByGoodIdThirty(item.ProjectId)
4021
-			//			if goodinfo.IsUser == 2 || goodinfo.IsUser == 0 {
4022
-			//
4023
-			//				//查询历史出库数据
4024
-			//				flowGood, _ := service.GetStockFlowIsBatchNumberSeventy(item.PatientId, item.RecordDate, item.ProjectId, item.ID)
4025
-			//				var out_count int64
4026
-			//				for _, item := range flowGood {
4027
-			//					out_count += item.Count
4028
-			//				}
4029
-			//
4030
-			//				//如果历史数和当前数据不想等才进行退库出库
4031
-			//				if out_count != parseIntCount {
4032
-			//					service.ConsumablePrescriptionDelivery(adminInfo.CurrentOrgId, item.PatientId, item.RecordDate, &dialyPrepareOne, &lastOut, creater, parseIntCount)
4033
-			//
4034
-			//					service.UpdateAutomaticReduce(item.PatientId, item.RecordDate, item.ProjectId, item.ID)
4035
-			//					detail := models.AutomaticReduceDetail{
4036
-			//						WarehouseOutId:          0,
4037
-			//						WarehouseOutOrderNumber: "",
4038
-			//						PatientId:               item.PatientId,
4039
-			//						Ctime:                   time.Now().Unix(),
4040
-			//						Mtime:                   0,
4041
-			//						Status:                  1,
4042
-			//						RecordTime:              item.RecordDate,
4043
-			//						OrgId:                   item.UserOrgId,
4044
-			//						GoodId:                  item.ProjectId,
4045
-			//						GoodTypeId:              0,
4046
-			//						Count:                   parseIntCount,
4047
-			//						Type:                    0,
4048
-			//						ProjectId:               item.ID,
4049
-			//						StorehouseId:            0,
4050
-			//					}
4051
-			//
4052
-			//					service.CreateAutoDetail(detail)
4053
-			//
4054
-			//					//查询剩余库存
4055
-			//					goodList, _ := service.GetAllGoodSumCount(item.ProjectId, adminInfo.CurrentOrgId, houseConfig.StorehouseOutInfo)
4056
-			//					var sum_count int64
4057
-			//					for _, item := range goodList {
4058
-			//						sum_count += item.StockCount
4059
-			//					}
4060
-			//
4061
-			//					//更新剩余库存
4062
-			//					service.UpdateGoodFlushCount(houseConfig.StorehouseOutInfo, item.ProjectId, adminInfo.CurrentOrgId, sum_count)
4063
-			//
4064
-			//					//耗材
4065
-			//					service.UpdateGoodSumCountSeven(sum_count, item.ProjectId, adminInfo.CurrentOrgId)
4066
-			//				}
4067
-			//
4068
-			//			}
4069
-			//
4070
-			//			if goodinfo.IsUser == 1 && goodinfo.IsWarehouse == 1 {
4071
-			//				//查询历史出库数据
4072
-			//				flowGood, _ := service.GetStockFlowIsBatchNumberSeventy(item.PatientId, item.RecordDate, item.ProjectId, item.ID)
4073
-			//				var out_count int64
4074
-			//				for _, item := range flowGood {
4075
-			//					out_count += item.Count
4076
-			//				}
4077
-			//				//如果历史数和当前数据不想等才进行退库出库
4078
-			//				if out_count != parseIntCount {
4079
-			//					service.ConsumablePrescriptionDelivery(adminInfo.CurrentOrgId, item.PatientId, item.RecordDate, &dialyPrepareOne, &lastOut, creater, parseIntCount)
4080
-			//
4081
-			//					service.UpdateAutomaticReduce(item.PatientId, item.RecordDate, item.ProjectId, item.ID)
4082
-			//					detail := models.AutomaticReduceDetail{
4083
-			//						WarehouseOutId:          0,
4084
-			//						WarehouseOutOrderNumber: "",
4085
-			//						PatientId:               item.PatientId,
4086
-			//						Ctime:                   time.Now().Unix(),
4087
-			//						Mtime:                   0,
4088
-			//						Status:                  1,
4089
-			//						RecordTime:              item.RecordDate,
4090
-			//						OrgId:                   item.UserOrgId,
4091
-			//						GoodId:                  item.ProjectId,
4092
-			//						GoodTypeId:              0,
4093
-			//						Count:                   parseIntCount,
4094
-			//						Type:                    0,
4095
-			//						ProjectId:               item.ID,
4096
-			//						StorehouseId:            0,
4097
-			//					}
4098
-			//
4099
-			//					service.CreateAutoDetail(detail)
4100
-			//
4101
-			//					//查询剩余库存
4102
-			//					goodList, _ := service.GetAllGoodSumCount(item.ProjectId, adminInfo.CurrentOrgId, houseConfig.StorehouseOutInfo)
4103
-			//					var sum_count int64
4104
-			//					for _, item := range goodList {
4105
-			//						sum_count += item.StockCount
4106
-			//					}
4107
-			//
4108
-			//					//更新剩余库存
4109
-			//					service.UpdateGoodFlushCount(houseConfig.StorehouseOutInfo, item.ProjectId, adminInfo.CurrentOrgId, sum_count)
4110
-			//
4111
-			//					//耗材
4112
-			//					service.UpdateGoodSumCountSeven(sum_count, item.ProjectId, adminInfo.CurrentOrgId)
4113
-			//				}
4114
-			//
4115
-			//			}
4116
-			//
4117
-			//		}
4118
-			//	}
4119
-			//}
4120 3973
 		}
3974
+
4121 3975
 		tx.Commit()
4122 3976
 		if err == nil {
4123 3977
 			c.ServeSuccessJSON(map[string]interface{}{

+ 0 - 3
controllers/mobile_api_controllers/dialysis_api_controller.go Просмотреть файл

@@ -9628,9 +9628,6 @@ func (this *DialysisAPIController) ExectionMobileAdvice() {
9628 9628
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
9629 9629
 		}
9630 9630
 	}
9631
-
9632
-	fmt.Println("config233322333223", config.IsOpen)
9633
-
9634 9631
 	//血透客户
9635 9632
 	if config.IsOpen == 2 || config.IsOpen == 0 {
9636 9633
 

+ 13 - 33
controllers/mobile_api_controllers/patient_api_controller.go Просмотреть файл

@@ -1288,6 +1288,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1288 1288
 		ids = strings.Split(advice_ids, ",")
1289 1289
 		if len(execution_time) <= 0 {
1290 1290
 			utils.ErrorLog("execution_time")
1291
+			tx.Rollback()
1291 1292
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1292 1293
 			return
1293 1294
 		}
@@ -1297,6 +1298,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1297 1298
 
1298 1299
 		if errs != nil {
1299 1300
 			utils.ErrorLog(errs.Error())
1301
+			tx.Rollback()
1300 1302
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1301 1303
 			return
1302 1304
 		}
@@ -1304,16 +1306,19 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1304 1306
 		var err error
1305 1307
 		for _, item := range advices {
1306 1308
 			if item.ExecutionState == 1 {
1309
+				tx.Rollback()
1307 1310
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdviceExced)
1308 1311
 				return
1309 1312
 			}
1310 1313
 
1311 1314
 			if item.Checker >= 0 && item.Checker == adminInfo.AdminUser.Id {
1315
+				tx.Rollback()
1312 1316
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeExceAndCheckNotOneUser)
1313 1317
 				return
1314 1318
 			}
1315 1319
 
1316 1320
 			if item.StartTime > theTime.Unix() {
1321
+				tx.Rollback()
1317 1322
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdviceExceBeforeStart)
1318 1323
 				return
1319 1324
 			}
@@ -1341,6 +1346,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1341 1346
 					infor, _ := service.GetDialysisInformationByRecordDate(item.PatientId, item.AdviceDate, item.UserOrgId, 4)
1342 1347
 					//申请状态不允许的情况 拒绝修改
1343 1348
 					if infor.ApplicationStatus != 1 {
1349
+						tx.Rollback()
1344 1350
 						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
1345 1351
 						return
1346 1352
 					}
@@ -1436,7 +1442,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1436 1442
 						}
1437 1443
 					}
1438 1444
 					advice, _ := service.FindHisDoctorAdviceByIdTwo(adminInfo.Org.Id, item.ID, tx)
1439
-					tx.Commit()
1445
+					tx.Rollback()
1440 1446
 					c.ServeSuccessJSON(map[string]interface{}{
1441 1447
 						"msg":    "7",
1442 1448
 						"advice": advice,
@@ -1489,6 +1495,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1489 1495
 				var total int64
1490 1496
 				var prescribing_number_total int64
1491 1497
 
1498
+				//保存处方出库
1492 1499
 				config, _ := service.GetDrugOpenConfigOne(adminInfo.Org.Id)
1493 1500
 
1494 1501
 				if config.IsOpen != 1 {
@@ -1529,7 +1536,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1529 1536
 								PrescribingNumberUnit: advice.PrescribingNumberUnit,
1530 1537
 							}
1531 1538
 							service.CreateDrugError(drugError)
1532
-							tx.Commit()
1539
+							tx.Rollback()
1533 1540
 							c.ServeSuccessJSON(map[string]interface{}{
1534 1541
 								"msg":    "1",
1535 1542
 								"advice": advice,
@@ -1555,7 +1562,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1555 1562
 								PrescribingNumberUnit: advice.PrescribingNumberUnit,
1556 1563
 							}
1557 1564
 							service.CreateDrugError(drugError)
1558
-							tx.Commit()
1565
+							tx.Rollback()
1559 1566
 							c.ServeSuccessJSON(map[string]interface{}{
1560 1567
 								"msg":    "3",
1561 1568
 								"advice": advice,
@@ -1578,7 +1585,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1578 1585
 								PrescribingNumberUnit: advice.PrescribingNumberUnit,
1579 1586
 							}
1580 1587
 							service.CreateDrugError(drugError)
1581
-							tx.Commit()
1588
+							tx.Rollback()
1582 1589
 							c.ServeSuccessJSON(map[string]interface{}{
1583 1590
 								"msg":    "2",
1584 1591
 								"advice": advice,
@@ -1588,10 +1595,6 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1588 1595
 						}
1589 1596
 					}
1590 1597
 
1591
-					fmt.Println("hhahhahahahhhhhha", prescribing_number_total)
1592
-					fmt.Println("total0000000000000", total)
1593
-					fmt.Println("medical22222222222222", medical.IsUse)
1594
-					fmt.Println("config.isp", config.IsOpen)
1595 1598
 					if prescribing_number_total <= total {
1596 1599
 
1597 1600
 						pharmacyConfig, _ := service.FindPharmacyConfig(advice.UserOrgId)
@@ -1601,9 +1604,6 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1601 1604
 							if config.IsOpen != 1 {
1602 1605
 								if pharmacyConfig.IsOpen == 1 && medical.IsPharmacy == 0 {
1603 1606
 
1604
-									//service.NewHisDrugsDelivery(adminInfo.Org.Id, creater, &advice, tx)
1605
-									//service.HisDrugsDelivery(adminInfo.Org.Id, creater, &advice)
1606
-
1607 1607
 									if adminInfo.Org.Id == 3877 || adminInfo.Org.Id == 10265 {
1608 1608
 										//查询该药品是否有出库记录
1609 1609
 										flowMap, _ := service.GetDrugFLowByAdviceByIdOne(advice.DrugId, advice.PatientId, advice.UserOrgId, advice.AdviceDate, tx)
@@ -1625,7 +1625,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1625 1625
 												}
1626 1626
 												service.CreateDrugError(drugError)
1627 1627
 											}
1628
-											tx.Commit()
1628
+											tx.Rollback()
1629 1629
 											c.ServeSuccessJSON(map[string]interface{}{
1630 1630
 												"msg":    "6",
1631 1631
 												"advice": advice,
@@ -1662,7 +1662,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1662 1662
 												}
1663 1663
 												service.CreateDrugError(drugError)
1664 1664
 											}
1665
-											tx.Commit()
1665
+											tx.Rollback()
1666 1666
 											c.ServeSuccessJSON(map[string]interface{}{
1667 1667
 												"msg":    "6",
1668 1668
 												"advice": advice,
@@ -1693,26 +1693,6 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1693 1693
 					}
1694 1694
 				}
1695 1695
 
1696
-				//fmt.Println("config+++++++++++", config.IsOpen)
1697
-				//fmt.Println("config+++++++++++", item.UserOrgId)
1698
-				//
1699
-				//if config.IsOpen == 1 && item.UserOrgId == 10402 {
1700
-				//
1701
-				//	service.HisDrugsDelivery(adminInfo.Org.Id, creater, &advice)
1702
-				//	//更新字典里面的库存
1703
-				//	stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
1704
-				//	var sum_count int64
1705
-				//	for _, its := range stockInfo {
1706
-				//		if its.MaxUnit == medical.MaxUnit {
1707
-				//			its.StockMaxNumber = its.StockMaxNumber * medical.MinNumber
1708
-				//		}
1709
-				//		sum_count += its.StockMaxNumber + its.StockMinNumber
1710
-				//	}
1711
-				//	service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
1712
-				//	//剩余库存
1713
-				//	service.UpdateDrugStockCount(item.DrugId, item.UserOrgId, storeHouseConfig.DrugStorehouseOut, sum_count)
1714
-				//}
1715
-
1716 1696
 			}
1717 1697
 		}
1718 1698
 		tx.Commit()

+ 10 - 10
controllers/new_mobile_api_controllers/staff_schedule_api_controller.go Просмотреть файл

@@ -1431,16 +1431,16 @@ func (c *StaffScheduleApiController) ChangeScheduleBed() {
1431 1431
 			}
1432 1432
 		}
1433 1433
 
1434
-		if org_id == 10206 || org_id == 10344 {
1435
-			hisAdvice, _ := service.GetHisDoctorAdviceListTwenty(scheduleToday.PatientId, scheduleToday.ScheduleDate, org_id)
1436
-			project, _ := service.GetHisPrescriptionProjectList(scheduleToday.PatientId, scheduleToday.ScheduleDate, org_id)
1437
-			if len(hisAdvice) > 0 {
1438
-				service.UpdateHisAdviceObj(scheduleToday.PatientId, scheduleToday.ScheduleDate, org_id)
1439
-			}
1440
-			if len(project) > 0 {
1441
-				service.UpdateProjectObj(scheduleToday.PatientId, scheduleToday.ScheduleDate, org_id)
1442
-			}
1443
-		}
1434
+		//if org_id == 10206 || org_id == 10344 {
1435
+		//	hisAdvice, _ := service.GetHisDoctorAdviceListTwenty(scheduleToday.PatientId, scheduleToday.ScheduleDate, org_id)
1436
+		//	project, _ := service.GetHisPrescriptionProjectList(scheduleToday.PatientId, scheduleToday.ScheduleDate, org_id)
1437
+		//	if len(hisAdvice) > 0 {
1438
+		//		service.UpdateHisAdviceObj(scheduleToday.PatientId, scheduleToday.ScheduleDate, org_id)
1439
+		//	}
1440
+		//	if len(project) > 0 {
1441
+		//		service.UpdateProjectObj(scheduleToday.PatientId, scheduleToday.ScheduleDate, org_id)
1442
+		//	}
1443
+		//}
1444 1444
 		if err == nil {
1445 1445
 			c.ServeSuccessJSON(map[string]interface{}{
1446 1446
 				"msg": "ok",

+ 2 - 38
controllers/patient_api_controller.go Просмотреть файл

@@ -2798,7 +2798,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
2798 2798
 
2799 2799
 		//1.判断是否启用药品管理和自备药出库功能
2800 2800
 
2801
-		//药品管理信息
2801
+		//药品自动出库开关管理信息
2802 2802
 		_, drugStockConfig := service.FindDrugStockAutomaticReduceRecordByOrgId(adminUserInfo.CurrentOrgId)
2803 2803
 
2804 2804
 		if drugStockConfig.IsOpen == 1 {
@@ -2806,46 +2806,10 @@ func (c *PatientApiController) ExecDoctorAdvice() {
2806 2806
 			advices, _ := service.GetHisExecutionDoctorsTwo(adminUserInfo.CurrentOrgId, patient, id)
2807 2807
 			for _, item := range advices {
2808 2808
 				medical, _ := service.GetBaseDrugMedical(advice.DrugId)
2809
-				//查询这个患者这个患者这个药已经出库的所有数量
2810
-				//advicelist, _ := service.GetAllHisDoctorAdviceById(item.DrugId, item.PatientId, item.AdviceDate, item.UserOrgId)
2811
-				//drugoutlist, _ := service.GetAllDrugFlowById(item.DrugId, item.PatientId, item.AdviceDate, item.UserOrgId)
2812
-				//var total_count int64 // 现在出库的
2813
-				//var drug_count int64  // 已经出库的
2814
-				//for _, it := range advicelist {
2815
-				//	if it.PrescribingNumberUnit == medical.MaxUnit {
2816
-				//		prescribingNumber_temp := strconv.FormatFloat(math.Abs(it.PrescribingNumber), 'f', 0, 64)
2817
-				//		prenumber, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
2818
-				//		total_count += prenumber * medical.MinNumber
2819
-				//	}
2820
-				//	if it.PrescribingNumberUnit == medical.MinUnit {
2821
-				//		prescribingNumber_temp := strconv.FormatFloat(math.Abs(it.PrescribingNumber), 'f', 0, 64)
2822
-				//		prenumber, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
2823
-				//		total_count += prenumber
2824
-				//	}
2825
-				//
2826
-				//}
2827
-				//
2828
-				//
2829
-				//for _, its := range drugoutlist {
2830
-				//	if its.CountUnit == medical.MaxUnit {
2831
-				//		drug_count += its.Count * medical.MinNumber
2832
-				//	}
2833
-				//	if its.CountUnit == medical.MinUnit {
2834
-				//		drug_count += its.Count
2835
-				//	}
2836
-				//}
2837
-				//fmt.Println("total_count23232323232323232wode",total_count)
2838
-				//fmt.Println("total_count23232323232323232wode",drug_count)
2839
-				//if total_count == drug_count {
2840
-				//	c.ServeSuccessJSON(map[string]interface{}{
2841
-				//		"msg":    "1",
2842
-				//		"advice": advice,
2843
-				//	})
2844
-				//	return
2845
-				//}
2846 2809
 
2847 2810
 				var total int64
2848 2811
 				var prescribing_number_total int64
2812
+				//药品保存处方出库
2849 2813
 				config, _ := service.GetDrugOpenConfigOne(adminUserInfo.CurrentOrgId)
2850 2814
 				if config.IsOpen != 1 {
2851 2815
 					//查询默认出库仓库

+ 3 - 0
controllers/pharmacy_controller.go Просмотреть файл

@@ -335,6 +335,8 @@ func (this *PharmacyController) GetPharmacyContent() {
335 335
 	appId := this.GetAdminUserInfo().CurrentAppId
336 336
 	adminUserES, _ := service.GetAllAdminUserES(orgid, appId)
337 337
 	allDoctor, _ := service.GetAllDoctor(orgid, appId)
338
+
339
+	prescriptionListByToDay, _ := service.GetPrescriptionListByToDay(orgid, patient_id, stime)
338 340
 	if err != nil {
339 341
 		utils.ErrorLog(err.Error())
340 342
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
@@ -349,6 +351,7 @@ func (this *PharmacyController) GetPharmacyContent() {
349 351
 	return_value["zoneList"] = zoneList
350 352
 	return_value["adminUserES"] = adminUserES
351 353
 	return_value["doctors"] = allDoctor
354
+	return_value["prescription"] = prescriptionListByToDay
352 355
 
353 356
 	//if is_medicine == 1{发药时间先不展示
354 357
 	//	return_value["time"] = time

+ 10 - 10
controllers/schedule_api_controller.go Просмотреть файл

@@ -742,16 +742,16 @@ func (c *ScheduleApiController) BatchPostSmartSch() {
742 742
 						}
743 743
 					}
744 744
 
745
-					if adminInfo.CurrentOrgId == 10206 || adminInfo.CurrentOrgId == 10344 {
746
-						hisAdvice, _ := service.GetHisDoctorAdviceListTwenty(schedule.PatientId, schedule.ScheduleDate, adminInfo.CurrentOrgId)
747
-						project, _ := service.GetHisPrescriptionProjectList(schedule.PatientId, schedule.ScheduleDate, adminInfo.CurrentOrgId)
748
-						if len(hisAdvice) > 0 {
749
-							service.UpdateHisAdviceObj(schedule.PatientId, schedule.ScheduleDate, adminInfo.CurrentOrgId)
750
-						}
751
-						if len(project) > 0 {
752
-							service.UpdateProjectObj(schedule.PatientId, schedule.ScheduleDate, adminInfo.CurrentOrgId)
753
-						}
754
-					}
745
+					//if adminInfo.CurrentOrgId == 10206 || adminInfo.CurrentOrgId == 10344 {
746
+					//	hisAdvice, _ := service.GetHisDoctorAdviceListTwenty(schedule.PatientId, schedule.ScheduleDate, adminInfo.CurrentOrgId)
747
+					//	project, _ := service.GetHisPrescriptionProjectList(schedule.PatientId, schedule.ScheduleDate, adminInfo.CurrentOrgId)
748
+					//	if len(hisAdvice) > 0 {
749
+					//		service.UpdateHisAdviceObj(schedule.PatientId, schedule.ScheduleDate, adminInfo.CurrentOrgId)
750
+					//	}
751
+					//	if len(project) > 0 {
752
+					//		service.UpdateProjectObj(schedule.PatientId, schedule.ScheduleDate, adminInfo.CurrentOrgId)
753
+					//	}
754
+					//}
755 755
 					service.SaveSch(&schedule)
756 756
 				}
757 757
 				HandleRedis(adminInfo.CurrentOrgId, schedule.ScheduleDate)

+ 1 - 1
controllers/self_drug_api_congtroller.go Просмотреть файл

@@ -2950,7 +2950,7 @@ func (this *SelfDrugApiController) GetGoodExpiryDateQuery() {
2950 2950
 		goodIds = append(goodIds, it.ID)
2951 2951
 	}
2952 2952
 	list, total, err := service.GetGoodExpiryDateQuery(storehouse_id, expiry_type, keyword, page, limit, orgId, ids, goodIds, nowtime, endTime)
2953
-	fmt.Println("total233223322332323232323223", total)
2953
+
2954 2954
 	manufacturerList, _ := service.GetAllManufacturerList(orgId)
2955 2955
 
2956 2956
 	if err != nil {

+ 3 - 2
controllers/sign_api_controller.go Просмотреть файл

@@ -1238,9 +1238,10 @@ func (this *SignApiController) ToAutoDiagnose() {
1238 1238
 	//	service.UpdateAllPatient(item.BloodId, item.Diagnose, item.UserOrgId)
1239 1239
 	//}
1240 1240
 
1241
-	list, _ := service.GetAllDialysisOrder(10490)
1241
+	list, _ := service.GetAllDialysisOrder(10469)
1242 1242
 	for _, item := range list {
1243
-		service.UpdateScheduleByOrder(item.PatientId, item.DialysisDate, orgId, item.BedId, item.ZoneId, item.SchedualType)
1243
+		schedule, _ := service.GetLastScheduleByUserOrg(item.PatientId, item.DialysisDate, orgId, item.BedId, item.ZoneId, item.SchedualType)
1244
+		service.UpdateScheduleByOrder(item.PatientId, item.DialysisDate, orgId, item.BedId, item.ZoneId, item.SchedualType, schedule.ID)
1244 1245
 	}
1245 1246
 
1246 1247
 	//drugList, _ := service.GetAllBaseDrugList(10571)

+ 9 - 0
service/gobal_config_service.go Просмотреть файл

@@ -1368,3 +1368,12 @@ func GetMobiledialysiOrder(user_org_id int64, patient_id int64, record_date int6
1368 1368
 
1369 1369
 	return dialysisOrder, err
1370 1370
 }
1371
+
1372
+func GetPrescriptionListByToDay(user_org_id int64, patient_id int64, record_Date int64) (models.HisPrescriptionInfo, error) {
1373
+
1374
+	prescriptionInfo := models.HisPrescriptionInfo{}
1375
+
1376
+	err := XTReadDB().Where("user_org_id = ? and patient_id = ? and record_date = ? and status =1", user_org_id, patient_id, record_Date).Find(&prescriptionInfo).Error
1377
+
1378
+	return prescriptionInfo, err
1379
+}

+ 38 - 0
service/his_service.go Просмотреть файл

@@ -905,6 +905,44 @@ func CreateHisDoctorAdviceOne(s *models.HisDoctorAdviceInfo, tx *gorm.DB) (err e
905 905
 	return
906 906
 }
907 907
 
908
+func GetHisToday(patient_id int64, advice_date int64, user_org_id int64, drug_id int64, tx *gorm.DB) (list []*models.HisDoctorAdviceInfo, err error) {
909
+
910
+	err = tx.Where("patient_id = ? and advice_date = ? and user_org_id = ? and status =1 and drug_id = ?", patient_id, advice_date, user_org_id, drug_id).Find(&list).Error
911
+	if err != gorm.ErrRecordNotFound {
912
+		if err != nil {
913
+			tx.Rollback()
914
+			return list, err
915
+		}
916
+	}
917
+	return list, err
918
+}
919
+
920
+func GetLastDrugAuto(advice_id int64, drug_id int64, advice_date int64, patient_id int64, user_org_id int64, tx *gorm.DB) (models.DrugAutomaticReduceDetail, error) {
921
+
922
+	automaticReduceDetail := models.DrugAutomaticReduceDetail{}
923
+
924
+	err := XTReadDB().Where("advice_id = ? and drug_id = ? and record_time= ? and patient_id =? and status=1 and org_id = ?", advice_id, drug_id, advice_date, patient_id, user_org_id).Find(&automaticReduceDetail).Error
925
+	if err != gorm.ErrRecordNotFound {
926
+		if err != nil {
927
+			tx.Rollback()
928
+			return automaticReduceDetail, err
929
+		}
930
+	}
931
+	return automaticReduceDetail, err
932
+}
933
+
934
+func UpdateTodayHis(drug_id int64, advice_date int64, patient_id int64, user_org_id int64, min_unit string, count_total int64, id int64, tx *gorm.DB) (models.XtDrugAutomaticReduceDetail, error) {
935
+
936
+	drugAutomaticReduceDetail := models.XtDrugAutomaticReduceDetail{}
937
+
938
+	err = tx.Model(&drugAutomaticReduceDetail).Where("drug_id = ? and record_time = ? and patient_id =? and org_id = ? and status=1 and advice_id = ?", drug_id, advice_date, patient_id, user_org_id, id).Updates(map[string]interface{}{"count": count_total, "count_unit": min_unit}).Error
939
+	if err != nil {
940
+		tx.Rollback()
941
+		return drugAutomaticReduceDetail, err
942
+	}
943
+	return drugAutomaticReduceDetail, err
944
+}
945
+
908 946
 func CreateHisDoctorAdvice(s *models.HisDoctorAdviceInfo) (err error) {
909 947
 
910 948
 	tx := writeDb.Begin()

+ 1 - 0
service/new_warehouse_service.go Просмотреть файл

@@ -4144,6 +4144,7 @@ func NewBloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehous
4144 4144
 			AdviceId:                advice.ID,
4145 4145
 		}
4146 4146
 
4147
+		fmt.Println("天激发阿凡达阿道夫阿道夫阿道夫阿道夫阿道夫阿道夫阿道夫阿道夫阿道夫")
4147 4148
 		AddNewSigleDrugAutoReduceRecordInfo(details, tx)
4148 4149
 
4149 4150
 		return nil

+ 9 - 5
service/pharmacy_service.go Просмотреть файл

@@ -865,12 +865,16 @@ func DispensingMedicineOne(orgid, patient_id, stime, etime, creater int64) (err
865 865
 	if len(adviceList) > 0 {
866 866
 		for _, item := range adviceList {
867 867
 
868
-			//扣减库存
869
-			err = HisDrugsDelivery(orgid, creater, item)
870
-			if err != nil {
871
-				err = fmt.Errorf("!:%v", err)
872
-				return
868
+			pharmacyConfig := IsPharmacyConfig(orgid)
869
+			if pharmacyConfig == true {
870
+				//扣减库存
871
+				err = HisDrugsDelivery(orgid, creater, item)
872
+				if err != nil {
873
+					err = fmt.Errorf("!:%v", err)
874
+					return
875
+				}
873 876
 			}
877
+
874 878
 			//修改发药状态
875 879
 			err = UpdateIsMedicalHisAdvice(item.ID)
876 880
 			if err != nil {

+ 13 - 7
service/schedule_service.go Просмотреть файл

@@ -1524,8 +1524,14 @@ func GetDoctorAdviceListSchedule(org_id int64, patient_id int64) (advices []*mod
1524 1524
 func GetLastDialysisPrescriptionTwo(org_id int64, patient_id int64, mode_id int64, schedule_date int64) (models.NewDialysisPrescription, error) {
1525 1525
 
1526 1526
 	dialysisprescription := models.NewDialysisPrescription{}
1527
-	err := XTReadDB().Where("user_org_id = ? and patient_id = ? and mode_id = ? and status = 1 and record_date = ?", org_id, patient_id, mode_id, schedule_date).Order("id desc").First(&dialysisprescription).Error
1528
-	return dialysisprescription, err
1527
+
1528
+	if org_id == 10340 {
1529
+		err := XTReadDB().Where("user_org_id = ? and patient_id = ? and mode_id = ? and status = 1 and record_date <= ?", org_id, patient_id, mode_id, schedule_date).Order("id desc").Last(&dialysisprescription).Error
1530
+		return dialysisprescription, err
1531
+	} else {
1532
+		err := XTReadDB().Where("user_org_id = ? and patient_id = ? and mode_id = ? and status = 1 and record_date = ?", org_id, patient_id, mode_id, schedule_date).Order("id desc").First(&dialysisprescription).Error
1533
+		return dialysisprescription, err
1534
+	}
1529 1535
 
1530 1536
 }
1531 1537
 
@@ -1838,23 +1844,23 @@ func GetHisPrescriptionProjectList(patient_id int64, record_date int64, user_org
1838 1844
 
1839 1845
 func UpdateProjectObj(patient_id int64, schedule_date int64, user_org_id int64) (err error) {
1840 1846
 
1841
-	err = XTWriteDB().Model(&models.HisPrescriptionProject{}).Where("patient_id = ? and record_date =? and status=1 and user_org_id = ?", patient_id, schedule_date, user_org_id).Updates(map[string]interface{}{"status": 9}).Error
1847
+	err = XTWriteDB().Model(&models.HisPrescriptionProject{}).Where("patient_id = ? and record_date =? and status=1 and user_org_id = ?", patient_id, schedule_date, user_org_id).Updates(map[string]interface{}{"status": 0}).Error
1842 1848
 
1843
-	err = XTWriteDB().Model(&models.HisPrescription{}).Where("patient_id = ? and status=1 and record_date = ? and user_org_id =?", patient_id, schedule_date, user_org_id).Updates(map[string]interface{}{"status": 9}).Error
1849
+	err = XTWriteDB().Model(&models.HisPrescription{}).Where("patient_id = ? and status=1 and record_date = ? and user_org_id =?", patient_id, schedule_date, user_org_id).Updates(map[string]interface{}{"status": 0}).Error
1844 1850
 
1845
-	err = XTWriteDB().Model(&models.HisPrescriptionInfo{}).Where("patient_id = ? and status=1 and record_date = ? and user_org_id = ?", patient_id, schedule_date, user_org_id).Updates(map[string]interface{}{"status": 9}).Error
1851
+	err = XTWriteDB().Model(&models.HisPrescriptionInfo{}).Where("patient_id = ? and status=1 and record_date = ? and user_org_id = ?", patient_id, schedule_date, user_org_id).Updates(map[string]interface{}{"status": 0}).Error
1846 1852
 	return err
1847 1853
 }
1848 1854
 
1849 1855
 func UpdateAdviceObj(patient_id int64, schedule_date int64, user_org_id int64) (err error) {
1850 1856
 
1851
-	err = XTWriteDB().Model(&models.XtDoctorAdvice{}).Where("patient_id = ? and advice_date =? and status=1 and user_org_id = ?", patient_id, schedule_date, user_org_id).Updates(map[string]interface{}{"status": 9}).Error
1857
+	err = XTWriteDB().Model(&models.XtDoctorAdvice{}).Where("patient_id = ? and advice_date =? and status=1 and user_org_id = ?", patient_id, schedule_date, user_org_id).Updates(map[string]interface{}{"status": 0}).Error
1852 1858
 	return err
1853 1859
 }
1854 1860
 
1855 1861
 func UpdateHisAdviceObj(patient_id int64, schedule_date int64, user_org_id int64) (err error) {
1856 1862
 
1857
-	err = XTWriteDB().Model(&models.HisDoctorAdvice{}).Where("patient_id = ? and advice_date =? and status=1 and user_org_id = ?", patient_id, schedule_date, user_org_id).Updates(map[string]interface{}{"status": 9}).Error
1863
+	err = XTWriteDB().Model(&models.HisDoctorAdvice{}).Where("patient_id = ? and advice_date =? and status=1 and user_org_id = ?", patient_id, schedule_date, user_org_id).Updates(map[string]interface{}{"status": 0}).Error
1858 1864
 	return err
1859 1865
 }
1860 1866
 

+ 1 - 1
service/self_drug_service.go Просмотреть файл

@@ -2002,7 +2002,7 @@ func GetDrugWarehouseInfoName(drugid int64, orgid int64) (info []*models.DrugWar
2002 2002
 
2003 2003
 func UpdateDrugById(id int64, orgid int64, limit_count int64, total_count int64) error {
2004 2004
 
2005
-	err := XTWriteDB().Model(&models.BaseDrugLibTen{}).Where("id = ? and org_id = ? and status = 1", id, orgid).Update(map[string]interface{}{"drug_stock_limit_count": limit_count, "total_count": total_count}).Error
2005
+	err := XTWriteDB().Model(&models.BaseDrugLibTen{}).Where("id = ? and org_id = ? and status = 1", id, orgid).Update(map[string]interface{}{"drug_stock_limit_count": limit_count, "sum_count": total_count}).Error
2006 2006
 	return err
2007 2007
 }
2008 2008
 

+ 11 - 3
service/sign_service.go Просмотреть файл

@@ -2112,14 +2112,22 @@ func UpdateAllPatient(id int64, diagose string, orgid int64) error {
2112 2112
 
2113 2113
 func GetAllDialysisOrder(user_org_id int64) (list []*models.XtDialysisOrder, err error) {
2114 2114
 
2115
-	err = XTReadDB().Where("patient_id = ? and status =1", 21767).Find(&list).Error
2115
+	err = XTReadDB().Where("patient_id = ? and status =1", 28449).Find(&list).Error
2116 2116
 
2117 2117
 	return list, err
2118 2118
 }
2119 2119
 
2120
-func UpdateScheduleByOrder(patient_id int64, schedule_date int64, user_org_id int64, bed_id int64, zone_id int64, shcedule_type int64) error {
2120
+func GetLastScheduleByUserOrg(patient_id int64, schedule_date int64, user_org_id int64, bed_id int64, zone_id int64, shcedule_type int64) (models.Schedule, error) {
2121 2121
 
2122
-	err := XTWriteDB().Model(&models.XtSchedule{}).Where("schedule_date =? and user_org_id =? and patient_id =?", schedule_date, user_org_id, patient_id).Updates(map[string]interface{}{"bed_id": bed_id, "partition_id": zone_id, "schedule_type": shcedule_type, "status": 1}).Error
2122
+	schedule := models.Schedule{}
2123
+	err := XTReadDB().Where("patient_id = ? and schedule_date = ? and status=0", patient_id, schedule_date).First(&schedule).Error
2124
+
2125
+	return schedule, err
2126
+}
2127
+
2128
+func UpdateScheduleByOrder(patient_id int64, schedule_date int64, user_org_id int64, bed_id int64, zone_id int64, shcedule_type int64, id int64) error {
2129
+
2130
+	err := XTWriteDB().Model(&models.XtSchedule{}).Where("id = ?", id).Updates(map[string]interface{}{"bed_id": bed_id, "partition_id": zone_id, "schedule_type": shcedule_type, "status": 1}).Error
2123 2131
 	return err
2124 2132
 }
2125 2133
 

+ 9 - 7
service/stock_service.go Просмотреть файл

@@ -876,6 +876,11 @@ func FindLastDrugWarehousingInfoByID(drug_id int64, storehouse_id int64) (info m
876 876
 	return info, err
877 877
 }
878 878
 
879
+func FindLastDrugWarehousingInfoByIDTwo(drug_id int64, storehouse_id int64) (info models.XtDrugWarehouseInfo, err error) {
880
+	err = readDb.Model(&models.XtDrugWarehouseInfo{}).Where("drug_id = ? AND status = 1 and storehouse_id = ? and is_check = 1", drug_id, storehouse_id).Order("ctime").Last(&info).Error
881
+	return info, err
882
+}
883
+
879 884
 func FindNewLastDrugWarehousingInfoByID(drug_id int64, storehouse_id int64, tx *gorm.DB) (info models.XtDrugWarehouseInfo, err error) {
880 885
 	err = tx.Model(&models.XtDrugWarehouseInfo{}).Where("drug_id = ? AND status = 1 AND (stock_max_number > 0 or stock_min_number > 0) and storehouse_id = ? and is_check = 1", drug_id, storehouse_id).Order("ctime").First(&info).Error
881 886
 	if err != gorm.ErrRecordNotFound {
@@ -5923,14 +5928,11 @@ func DeleteDrugAutoWarehouseSeven(drugid int64, patient_id int64, record_time in
5923 5928
 	return err
5924 5929
 }
5925 5930
 
5926
-func DeleteNewDrugAutoWarehouseSeven(drugid int64, patient_id int64, record_time int64, advice_id int64, tx *gorm.DB) error {
5931
+func DeleteNewDrugAutoWarehouseSeven(drugid int64, patient_id int64, record_time int64, advice_id int64) error {
5932
+
5933
+	err := XTWriteDB().Model(models.DrugAutomaticReduceDetail{}).Where("drug_id = ? and patient_id = ? and record_time = ? and status = 1", drugid, patient_id, record_time).Updates(map[string]interface{}{"status": 0}).Error
5934
+	err = XTWriteDB().Model(models.DrugFlow{}).Where("drug_id = ? and patient_id = ? and system_time = ? and status = 1 and advice_id = ?", drugid, patient_id, record_time, advice_id).Updates(map[string]interface{}{"status": 0}).Error
5927 5935
 
5928
-	err := tx.Model(models.DrugAutomaticReduceDetail{}).Where("drug_id = ? and patient_id = ? and record_time = ? and status = 1 and advice_id = ?", drugid, patient_id, record_time, advice_id).Updates(map[string]interface{}{"status": 0}).Error
5929
-	err = tx.Model(models.DrugFlow{}).Where("drug_id = ? and patient_id = ? and system_time = ? and status = 1 and advice_id = ?", drugid, patient_id, record_time, advice_id).Updates(map[string]interface{}{"status": 0}).Error
5930
-	if err != nil {
5931
-		tx.Rollback()
5932
-		return err
5933
-	}
5934 5936
 	return err
5935 5937
 }
5936 5938
 

+ 0 - 1
service/warhouse_service.go Просмотреть файл

@@ -7849,7 +7849,6 @@ func NewHisDrugsDelivery(orgID int64, creater int64, advice *models.HisDoctorAdv
7849 7849
 	if isHasWay {
7850 7850
 		//判断当天当前机构有没有创建出库单,没有则创建
7851 7851
 		out, err := FindNewDrugStockOutByIsSys(orgID, 1, record_time, tx)
7852
-		fmt.Println(out)
7853 7852
 		houseConfig, _ := GetAllStoreHouseConfig(orgID)
7854 7853
 		if err == gorm.ErrRecordNotFound {
7855 7854
 			timeStr := time.Now().Format("2006-01-02")