|
@@ -2248,12 +2248,97 @@ func (c *HisApiController) CreateHisPrescription() {
|
2248
|
2248
|
//已发药和已收费限制逻辑
|
2249
|
2249
|
isMidicine := false
|
2250
|
2250
|
isCharge := false
|
|
2251
|
+ //是否有库存
|
|
2252
|
+ isSumCount := false
|
|
2253
|
+
|
|
2254
|
+ is_sum_total := false
|
|
2255
|
+
|
|
2256
|
+ var drug_name = ""
|
|
2257
|
+
|
|
2258
|
+ var good_name = ""
|
2251
|
2259
|
|
2252
|
2260
|
if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
|
2253
|
2261
|
prescriptions, _ := dataBody["prescriptions"].([]interface{})
|
2254
|
2262
|
if len(prescriptions) > 0 {
|
2255
|
2263
|
for _, item := range prescriptions {
|
2256
|
2264
|
items := item.(map[string]interface{})
|
|
2265
|
+
|
|
2266
|
+ if adminInfo.CurrentOrgId == 9478 {
|
|
2267
|
+ if items["advices"] != nil && reflect.TypeOf(items["advices"]).String() == "[]interface {}" {
|
|
2268
|
+ advices := items["advices"].([]interface{})
|
|
2269
|
+ if len(advices) > 0 {
|
|
2270
|
+ for _, advice := range advices {
|
|
2271
|
+ var adviceId int64
|
|
2272
|
+ if advice.(map[string]interface{})["advice_id"] != nil || reflect.TypeOf(advice.(map[string]interface{})["advice_id"]).String() == "float64" {
|
|
2273
|
+ adviceId = int64(advice.(map[string]interface{})["advice_id"].(float64))
|
|
2274
|
+ }
|
|
2275
|
+ var drug_id int64
|
|
2276
|
+ if advice.(map[string]interface{})["id"] != nil || reflect.TypeOf(advice.(map[string]interface{})["id"]).String() == "float64" {
|
|
2277
|
+ drug_id = int64(advice.(map[string]interface{})["id"].(float64))
|
|
2278
|
+ }
|
|
2279
|
+ drug, _ := service.FindBaseDrugLibRecordSeven(adminInfo.CurrentOrgId, drug_id)
|
|
2280
|
+ //查询该药品是否存在开药记录
|
|
2281
|
+ advicelist, _ := service.GetHisAdviceListByDrugIdEight(drug_id, patient_id, recordDateTime, adviceId)
|
|
2282
|
+ if advicelist.ID == 0 {
|
|
2283
|
+ if drug.IsUse != 1 {
|
|
2284
|
+ if drug.SumCount == 0 {
|
|
2285
|
+ drug_name = drug.DrugName
|
|
2286
|
+ isSumCount = true
|
|
2287
|
+ }
|
|
2288
|
+ }
|
|
2289
|
+
|
|
2290
|
+ }
|
|
2291
|
+ }
|
|
2292
|
+ }
|
|
2293
|
+ }
|
|
2294
|
+
|
|
2295
|
+ if items["project"] != nil && reflect.TypeOf(items["project"]).String() == "[]interface {}" {
|
|
2296
|
+ projects := items["project"].([]interface{})
|
|
2297
|
+ if len(projects) > 0 {
|
|
2298
|
+ for _, project := range projects {
|
|
2299
|
+
|
|
2300
|
+ var project_id int64
|
|
2301
|
+ var project_type int64
|
|
2302
|
+ var project_name string
|
|
2303
|
+
|
|
2304
|
+ if project.(map[string]interface{})["project_id"] != nil || reflect.TypeOf(project.(map[string]interface{})["project_id"]).String() == "float64" {
|
|
2305
|
+ project_id = int64(project.(map[string]interface{})["project_id"].(float64))
|
|
2306
|
+ }
|
|
2307
|
+
|
|
2308
|
+ if project.(map[string]interface{})["type"] != nil || reflect.TypeOf(project.(map[string]interface{})["type"]).String() == "float64" {
|
|
2309
|
+ project_type = int64(project.(map[string]interface{})["type"].(float64))
|
|
2310
|
+ }
|
|
2311
|
+
|
|
2312
|
+ if project.(map[string]interface{})["project_name"] != nil || reflect.TypeOf(project.(map[string]interface{})["project_name"]).String() == "string" {
|
|
2313
|
+ project_name = project.(map[string]interface{})["project_name"].(string)
|
|
2314
|
+
|
|
2315
|
+ }
|
|
2316
|
+
|
|
2317
|
+ if project_type == 3 {
|
|
2318
|
+
|
|
2319
|
+ //查找该耗材的出库记录
|
|
2320
|
+ goodWarehouseInfo, _ := service.GetAutoRecordByGoodIdSevenEight(project_id, patient_id, recordDateTime)
|
|
2321
|
+
|
|
2322
|
+ if len(goodWarehouseInfo) == 0 {
|
|
2323
|
+ //查询耗材库存
|
|
2324
|
+ list, _ := service.GetGoodWarehouseInfoSevenTen(project_id, storeConfig.StorehouseOutInfo)
|
|
2325
|
+
|
|
2326
|
+ var stock_count int64
|
|
2327
|
+ for _, it := range list {
|
|
2328
|
+ stock_count += it.StockCount
|
|
2329
|
+ }
|
|
2330
|
+
|
|
2331
|
+ if stock_count == 0 {
|
|
2332
|
+ good_name = project_name
|
|
2333
|
+ is_sum_total = true
|
|
2334
|
+ }
|
|
2335
|
+ }
|
|
2336
|
+ }
|
|
2337
|
+ }
|
|
2338
|
+ }
|
|
2339
|
+ }
|
|
2340
|
+ }
|
|
2341
|
+
|
2257
|
2342
|
if items["id"] == nil || reflect.TypeOf(items["id"]).String() != "float64" {
|
2258
|
2343
|
utils.ErrorLog("id")
|
2259
|
2344
|
c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
@@ -2281,6 +2366,25 @@ func (c *HisApiController) CreateHisPrescription() {
|
2281
|
2366
|
return
|
2282
|
2367
|
}
|
2283
|
2368
|
|
|
2369
|
+ if adminInfo.CurrentOrgId == 9478 {
|
|
2370
|
+ //不是保存处方出库
|
|
2371
|
+ drugOutConfig, _ := service.GetDrugOpenConfigOne(adminInfo.CurrentOrgId)
|
|
2372
|
+
|
|
2373
|
+ if drugOutConfig.IsOpen == 1 {
|
|
2374
|
+ if isSumCount == true {
|
|
2375
|
+ c.ServeDynamicFailJsonSend(drug_name + "库存不足,保存失败")
|
|
2376
|
+ return
|
|
2377
|
+ }
|
|
2378
|
+ }
|
|
2379
|
+
|
|
2380
|
+ if goodOutConfig.IsOpen == 1 {
|
|
2381
|
+ if is_sum_total == true {
|
|
2382
|
+ c.ServeDynamicFailJsonSend(good_name + "库存不足,保存失败")
|
|
2383
|
+ return
|
|
2384
|
+ }
|
|
2385
|
+ }
|
|
2386
|
+ }
|
|
2387
|
+
|
2284
|
2388
|
// 开始主事务
|
2285
|
2389
|
db := service.XTWriteDB()
|
2286
|
2390
|
tx := db.Begin()
|
|
@@ -3362,8 +3466,6 @@ func (c *HisApiController) CreateHisPrescription() {
|
3362
|
3466
|
//查询该患者耗材的历史数据
|
3363
|
3467
|
ordProject, _ := service.GetHisProjectPrescriptionByPatientIdOne(id)
|
3364
|
3468
|
|
3365
|
|
- fmt.Println("ordProject-----------------------", ordProject.ProjectId)
|
3366
|
|
-
|
3367
|
3469
|
count, _ := strconv.ParseInt(ordProject.Count, 10, 64)
|
3368
|
3470
|
|
3369
|
3471
|
//数量发生改变
|
|
@@ -3817,7 +3919,7 @@ func (c *HisApiController) CreateHisPrescription() {
|
3817
|
3919
|
}
|
3818
|
3920
|
|
3819
|
3921
|
drugMedical, _ := service.GetBaseDrugMedical(s.DrugId)
|
3820
|
|
- fmt.Println("0000000000000000000000", drugMedical.SumCount)
|
|
3922
|
+
|
3821
|
3923
|
if drugMedical.SumCount == 0 {
|
3822
|
3924
|
tx.Rollback()
|
3823
|
3925
|
c.ServeDynamicFailJsonSend(drugMedical.DrugName + "库存不足,保存失败!")
|
|
@@ -3835,74 +3937,6 @@ func (c *HisApiController) CreateHisPrescription() {
|
3835
|
3937
|
return
|
3836
|
3938
|
}
|
3837
|
3939
|
|
3838
|
|
- //针对康德
|
3839
|
|
- //if s.UserOrgId == 10402 || s.UserOrgId == 10164 {
|
3840
|
|
- // //获取该药品的总入库数量
|
3841
|
|
- // drugWarehouseinfo, _ := service.GetAllDrugInfoList(s.DrugId, s.UserOrgId)
|
3842
|
|
- //
|
3843
|
|
- // //获取该药品总共开了多少支医嘱
|
3844
|
|
- // hisDocInfoList, _ := service.GetHisDocInfoList(s.DrugId, s.UserOrgId)
|
3845
|
|
- // var in_count int64
|
3846
|
|
- // var in_prescription_number_total int64
|
3847
|
|
- // if len(drugWarehouseinfo) > 0 {
|
3848
|
|
- // for _, item := range drugWarehouseinfo {
|
3849
|
|
- // if item.MaxUnit == drugMedical.MaxUnit && drugMedical.MaxUnit != drugMedical.MinUnit {
|
3850
|
|
- //
|
3851
|
|
- // in_count += item.WarehousingCount * drugMedical.MinNumber
|
3852
|
|
- // }
|
3853
|
|
- //
|
3854
|
|
- // if item.MaxUnit == drugMedical.MinUnit && drugMedical.MaxUnit != drugMedical.MinUnit {
|
3855
|
|
- //
|
3856
|
|
- // in_count += item.WarehousingCount
|
3857
|
|
- // }
|
3858
|
|
- //
|
3859
|
|
- // if item.MaxUnit == drugMedical.MinUnit && drugMedical.MaxUnit == drugMedical.MinUnit {
|
3860
|
|
- //
|
3861
|
|
- // in_count += item.WarehousingCount
|
3862
|
|
- // }
|
3863
|
|
- //
|
3864
|
|
- // }
|
3865
|
|
- // }
|
3866
|
|
- //
|
3867
|
|
- // if len(hisDocInfoList) > 0 {
|
3868
|
|
- //
|
3869
|
|
- // for _, item := range hisDocInfoList {
|
3870
|
|
- // if item.PrescribingNumberUnit == drugMedical.MaxUnit && drugMedical.MaxUnit != drugMedical.MinUnit {
|
3871
|
|
- // prescribingNumberTenty := strconv.FormatFloat(s.PrescribingNumber, 'f', -1, 64)
|
3872
|
|
- // prescribingNumberSevenTy, _ := strconv.ParseInt(prescribingNumberTenty, 10, 64)
|
3873
|
|
- //
|
3874
|
|
- // in_prescription_number_total += prescribingNumberSevenTy * drug.MinNumber
|
3875
|
|
- // }
|
3876
|
|
- //
|
3877
|
|
- // if item.PrescribingNumberUnit == drugMedical.MinUnit && drugMedical.MaxUnit != drugMedical.MinUnit {
|
3878
|
|
- // prescribingNumberTenty := strconv.FormatFloat(s.PrescribingNumber, 'f', -1, 64)
|
3879
|
|
- // prescribingNumberSevenTy, _ := strconv.ParseInt(prescribingNumberTenty, 10, 64)
|
3880
|
|
- // in_prescription_number_total += prescribingNumberSevenTy
|
3881
|
|
- // }
|
3882
|
|
- //
|
3883
|
|
- // if item.PrescribingNumberUnit == drugMedical.MinUnit && drugMedical.MaxUnit == drugMedical.MinUnit {
|
3884
|
|
- // prescribingNumberTenty := strconv.FormatFloat(s.PrescribingNumber, 'f', -1, 64)
|
3885
|
|
- // prescribingNumberSevenTy, _ := strconv.ParseInt(prescribingNumberTenty, 10, 64)
|
3886
|
|
- // in_prescription_number_total += prescribingNumberSevenTy
|
3887
|
|
- // }
|
3888
|
|
- // }
|
3889
|
|
- // }
|
3890
|
|
- // //
|
3891
|
|
- // //fmt.Println("no_user_total------------------------------", no_user_total)
|
3892
|
|
- // //fmt.Println("in_prescription_number_total---------------------------", in_prescription_number_total)
|
3893
|
|
- // //fmt.Println("in_count----------------------------------", in_count)
|
3894
|
|
- //
|
3895
|
|
- // //如果已经开过的医嘱 加上未开的医嘱数量 大于 入库总数量则提示库存不足
|
3896
|
|
- // if no_user_total+in_prescription_number_total > in_count {
|
3897
|
|
- // tx.Rollback()
|
3898
|
|
- // c.ServeDynamicFailJsonSend(drugMedical.DrugName + "库存不足,保存失败!")
|
3899
|
|
- // return
|
3900
|
|
- // }
|
3901
|
|
- //
|
3902
|
|
- //}
|
3903
|
|
-
|
3904
|
|
- //查询该药品所有入库数量
|
3905
|
|
-
|
3906
|
3940
|
}
|
3907
|
3941
|
|
3908
|
3942
|
if s.ID > 0 {
|
|
@@ -4531,46 +4565,6 @@ func (c *HisApiController) CreateHisPrescription() {
|
4531
|
4565
|
|
4532
|
4566
|
nowCount, _ := strconv.ParseInt(p.Count, 10, 64)
|
4533
|
4567
|
|
4534
|
|
- ////针对康德
|
4535
|
|
- //if p.UserOrgId == 10164 || p.UserOrgId == 10402 {
|
4536
|
|
- //
|
4537
|
|
- // //查询耗材的总入库数量
|
4538
|
|
- // warehouseInfo, _ := service.GetAllWarehouseInfo(p.ProjectId, adminInfo.CurrentOrgId)
|
4539
|
|
- //
|
4540
|
|
- // //查询该耗材的总出库数量
|
4541
|
|
- // prescriptionGood, _ := service.GetHisPrescriptionByGoodId(p.ProjectId, adminInfo.CurrentOrgId)
|
4542
|
|
- //
|
4543
|
|
- // var all_good_count int64
|
4544
|
|
- //
|
4545
|
|
- // var prescription_count int64
|
4546
|
|
- // if len(warehouseInfo) > 0 {
|
4547
|
|
- //
|
4548
|
|
- // for _, item := range warehouseInfo {
|
4549
|
|
- // all_good_count += item.WarehousingCount
|
4550
|
|
- // }
|
4551
|
|
- // }
|
4552
|
|
- // if len(prescriptionGood) > 0 {
|
4553
|
|
- // for _, item := range prescriptionGood {
|
4554
|
|
- //
|
4555
|
|
- // hisCount, _ := strconv.ParseInt(item.Count, 10, 64)
|
4556
|
|
- // prescription_count += hisCount
|
4557
|
|
- // }
|
4558
|
|
- // }
|
4559
|
|
- //
|
4560
|
|
- // //fmt.Println("prescription_count-------------------------", prescription_count)
|
4561
|
|
- // //fmt.Println("nowCount-------------------------", nowCount)
|
4562
|
|
- // //fmt.Println("all_good_count-------------------------", all_good_count)
|
4563
|
|
- //
|
4564
|
|
- // if prescription_count+nowCount > all_good_count {
|
4565
|
|
- // goodInfoOne, _ := service.GetGoodInformationByGoodIdOne(p.ProjectId)
|
4566
|
|
- // tx.Rollback()
|
4567
|
|
- // c.ServeDynamicFailJsonSend(goodInfoOne.GoodName + "耗材无库存,保存失败!")
|
4568
|
|
- // return
|
4569
|
|
- // }
|
4570
|
|
- //}
|
4571
|
|
-
|
4572
|
|
- fmt.Println("nowCount222=================", nowCount)
|
4573
|
|
- fmt.Println("historyCount-333----------------", historyCount)
|
4574
|
4568
|
//如果当前处方数量大于历史数据,则需要出库
|
4575
|
4569
|
|
4576
|
4570
|
if nowCount > historyCount {
|
|
@@ -6127,8 +6121,6 @@ func (c *HisApiController) CreateHisPrescription() {
|
6127
|
6121
|
|
6128
|
6122
|
parseIntCount, _ := strconv.ParseInt(item.Count, 10, 64)
|
6129
|
6123
|
|
6130
|
|
- fmt.Println("out_count_five-------------------", out_count_five)
|
6131
|
|
- fmt.Println("parseIntCount---------------", parseIntCount)
|
6132
|
6124
|
if out_count_five != parseIntCount {
|
6133
|
6125
|
|
6134
|
6126
|
//查询耗材最后一次出库记录
|
|
@@ -7097,7 +7089,6 @@ func (c *HisApiController) DeletePrescription() {
|
7097
|
7089
|
//查询今日是否有出库数据
|
7098
|
7090
|
lastWarehouseOut, _ := service.GetSelfDrugLastWarehouseOutTwety(c.GetAdminUserInfo().CurrentOrgId, item.AdviceDate, tx, 1)
|
7099
|
7091
|
|
7100
|
|
- fmt.Println("lastWarehouseOut-----------------------------------", lastWarehouseOut)
|
7101
|
7092
|
if lastWarehouseOut.ID == 0 {
|
7102
|
7093
|
service.AddSelfSigleDrugWarehouseOut(&drugWarehouseOut, tx)
|
7103
|
7094
|
}
|
|
@@ -7154,7 +7145,6 @@ func (c *HisApiController) DeletePrescription() {
|
7154
|
7145
|
warehousingOutInfo = append(warehousingOutInfo, warehouseOutInfo)
|
7155
|
7146
|
}
|
7156
|
7147
|
|
7157
|
|
- fmt.Println("长度-------------------------------", warehousingOutInfo)
|
7158
|
7148
|
for _, it := range warehousingOutInfo {
|
7159
|
7149
|
//查询今日是否有出库数据
|
7160
|
7150
|
lastWarehouseOutOne, _ := service.GetSelfDrugLastWarehouseOutTwety(c.GetAdminUserInfo().CurrentOrgId, it.SysRecordTime, tx, 1)
|