|
@@ -983,6 +983,72 @@ func (c *HisApiController) CreateHisPrescription() {
|
983
|
983
|
|
984
|
984
|
_, stockConfig := service.FindAutomaticReduceRecordByOrgId(c.GetAdminUserInfo().CurrentOrgId)
|
985
|
985
|
|
|
986
|
+ //已发药和已收费限制逻辑
|
|
987
|
+ isMidicine := false
|
|
988
|
+ isCharge := false
|
|
989
|
+ if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
|
|
990
|
+
|
|
991
|
+
|
|
992
|
+
|
|
993
|
+ prescriptions, _ := dataBody["prescriptions"].([]interface{})
|
|
994
|
+ if len(prescriptions) > 0 {
|
|
995
|
+ for _, item := range prescriptions {
|
|
996
|
+ items := item.(map[string]interface{})
|
|
997
|
+ if items["id"] == nil || reflect.TypeOf(items["id"]).String() != "float64" {
|
|
998
|
+ utils.ErrorLog("id")
|
|
999
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1000
|
+ return
|
|
1001
|
+ }
|
|
1002
|
+ id := int64(items["id"].(float64))
|
|
1003
|
+ if id > 0 {
|
|
1004
|
+ new_prescription, err := service.GetPrescriptionById(id, adminInfo.CurrentOrgId)
|
|
1005
|
+ if err != nil {
|
|
1006
|
+ if new_prescription.OrderStatus == 2 {
|
|
1007
|
+ isCharge = true
|
|
1008
|
+ }
|
|
1009
|
+ }
|
|
1010
|
+ }
|
|
1011
|
+
|
|
1012
|
+ if items["advices"] != nil && reflect.TypeOf(items["advices"]).String() == "[]interface {}" {
|
|
1013
|
+ advices := items["advices"].([]interface{})
|
|
1014
|
+ fmt.Println("~~~~~~~~4")
|
|
1015
|
+
|
|
1016
|
+ if len(advices) > 0 {
|
|
1017
|
+ for _, advice := range advices {
|
|
1018
|
+ fmt.Println("~~~~~~~~3")
|
|
1019
|
+
|
|
1020
|
+ var adviceId int64
|
|
1021
|
+ if advice.(map[string]interface{})["advice_id"] != nil || reflect.TypeOf(advice.(map[string]interface{})["advice_id"]).String() == "float64" {
|
|
1022
|
+ adviceId = int64(advice.(map[string]interface{})["advice_id"].(float64))
|
|
1023
|
+ }
|
|
1024
|
+ if adviceId > 0 {
|
|
1025
|
+ his_advice_info, err := service.GetHisDoctorAdviceInfo(adviceId)
|
|
1026
|
+ fmt.Println("~~~~~~~~1")
|
|
1027
|
+ fmt.Println("~~~~~~~~1")
|
|
1028
|
+
|
|
1029
|
+ if err == nil {
|
|
1030
|
+ if his_advice_info.IsMedicine == 1 {
|
|
1031
|
+ fmt.Println("~~~~~~~~2")
|
|
1032
|
+ isMidicine = true
|
|
1033
|
+ }
|
|
1034
|
+ }
|
|
1035
|
+ }
|
|
1036
|
+ }
|
|
1037
|
+ }
|
|
1038
|
+ }
|
|
1039
|
+ }
|
|
1040
|
+ }
|
|
1041
|
+ }
|
|
1042
|
+ if isMidicine == true {
|
|
1043
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeMedicineWrong)
|
|
1044
|
+ return
|
|
1045
|
+ }
|
|
1046
|
+ if isCharge == true {
|
|
1047
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeChargeWrong)
|
|
1048
|
+ return
|
|
1049
|
+ }
|
|
1050
|
+ //已发药和已收费限制逻辑
|
|
1051
|
+
|
986
|
1052
|
if drugStockConfig.IsOpen == 1 {
|
987
|
1053
|
//校验库存总量
|
988
|
1054
|
if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
|
|
@@ -2298,6 +2364,47 @@ func (c *HisApiController) DeletePrescription() {
|
2298
|
2364
|
|
2299
|
2365
|
_, stockConfig := service.FindAutomaticReduceRecordByOrgId(c.GetAdminUserInfo().CurrentOrgId)
|
2300
|
2366
|
|
|
2367
|
+ //已收费和已发药限制逻辑
|
|
2368
|
+ isCharge := false
|
|
2369
|
+ isMedicine := false
|
|
2370
|
+ new_prescription, p_err := service.GetPrescriptionById(prescription_id, c.GetAdminUserInfo().CurrentOrgId)
|
|
2371
|
+ new_prescriptions, _ := service.GetHisPrescription(c.GetAdminUserInfo().CurrentOrgId, new_prescription.PatientId, new_prescription.RecordDate, new_prescription.PType)
|
|
2372
|
+
|
|
2373
|
+ for _, item := range new_prescriptions {
|
|
2374
|
+ if item.IsMedicine == 1 {
|
|
2375
|
+ isMedicine = true
|
|
2376
|
+ }
|
|
2377
|
+ }
|
|
2378
|
+
|
|
2379
|
+ for _, item := range new_prescriptions {
|
|
2380
|
+ if item.OrderStatus == 2 {
|
|
2381
|
+ isCharge = true
|
|
2382
|
+ }
|
|
2383
|
+ }
|
|
2384
|
+
|
|
2385
|
+ if p_err != nil {
|
|
2386
|
+ if new_prescription.ID > 0 {
|
|
2387
|
+ if new_prescription.OrderStatus == 2 {
|
|
2388
|
+ isCharge = true
|
|
2389
|
+ }
|
|
2390
|
+ }
|
|
2391
|
+ }
|
|
2392
|
+ for _, item := range advices {
|
|
2393
|
+ if item.IsMedicine == 1 {
|
|
2394
|
+ isMedicine = true
|
|
2395
|
+ }
|
|
2396
|
+ }
|
|
2397
|
+ if isCharge {
|
|
2398
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeletePChargeWrong)
|
|
2399
|
+ return
|
|
2400
|
+ }
|
|
2401
|
+
|
|
2402
|
+ if isMedicine {
|
|
2403
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeletePMedicineWrong)
|
|
2404
|
+ return
|
|
2405
|
+ }
|
|
2406
|
+ //已收费和已发药限制逻辑
|
|
2407
|
+
|
2301
|
2408
|
if len(projects) > 0 {
|
2302
|
2409
|
for _, item := range projects {
|
2303
|
2410
|
service.DeletePrintInfo(item.ID) //删除打印信息
|
|
@@ -2533,6 +2640,57 @@ func (c *HisApiController) DeleteDoctorAdvice() {
|
2533
|
2640
|
|
2534
|
2641
|
_, drugStockConfig := service.FindDrugStockAutomaticReduceRecordByOrgId(c.GetAdminUserInfo().CurrentOrgId)
|
2535
|
2642
|
|
|
2643
|
+ //已收费和已发药的限制逻辑
|
|
2644
|
+ isCharge := false
|
|
2645
|
+ isMedicine := false
|
|
2646
|
+ new_prescription, _ := service.GetPrescriptionById(advice.PrescriptionId, c.GetAdminUserInfo().CurrentOrgId)
|
|
2647
|
+
|
|
2648
|
+ //获取今天该患者所有处方,判断是否发药或者收费
|
|
2649
|
+ new_prescriptions, _ := service.GetHisPrescription(c.GetAdminUserInfo().CurrentOrgId, new_prescription.PatientId, new_prescription.RecordDate, new_prescription.PType)
|
|
2650
|
+ for _, item := range new_prescriptions {
|
|
2651
|
+ if item.IsMedicine == 1 {
|
|
2652
|
+ isMedicine = true
|
|
2653
|
+ }
|
|
2654
|
+ }
|
|
2655
|
+ for _, item := range new_prescriptions {
|
|
2656
|
+ if item.OrderStatus == 2 {
|
|
2657
|
+ isCharge = true
|
|
2658
|
+ }
|
|
2659
|
+ }
|
|
2660
|
+
|
|
2661
|
+ if isMedicine {
|
|
2662
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeletePMedicineWrong)
|
|
2663
|
+ return
|
|
2664
|
+ }
|
|
2665
|
+
|
|
2666
|
+ if isCharge {
|
|
2667
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeletePChargeWrong)
|
|
2668
|
+ return
|
|
2669
|
+ }
|
|
2670
|
+
|
|
2671
|
+ advices, _ := service.GetHisPrescriptionAdviceByID(advice.PrescriptionId)
|
|
2672
|
+ for _, item := range advices {
|
|
2673
|
+ if item.IsMedicine == 1 {
|
|
2674
|
+ isMedicine = true
|
|
2675
|
+ }
|
|
2676
|
+ }
|
|
2677
|
+
|
|
2678
|
+ if isMedicine {
|
|
2679
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteMedicineWrong)
|
|
2680
|
+ return
|
|
2681
|
+ }
|
|
2682
|
+ if new_prescription.ID > 0 {
|
|
2683
|
+ if new_prescription.OrderStatus == 2 {
|
|
2684
|
+ isCharge = true
|
|
2685
|
+ }
|
|
2686
|
+ }
|
|
2687
|
+
|
|
2688
|
+ if isCharge {
|
|
2689
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeletePChargeWrongTwo)
|
|
2690
|
+ return
|
|
2691
|
+ }
|
|
2692
|
+ //已收费和已发药的限制逻辑
|
|
2693
|
+
|
2536
|
2694
|
err := service.DelelteDoctorAdvice(id, c.GetAdminUserInfo().CurrentOrgId)
|
2537
|
2695
|
redis := service.RedisClient()
|
2538
|
2696
|
keyFive := strconv.FormatInt(advice.UserOrgId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":his_advices_list_all"
|
|
@@ -2580,6 +2738,40 @@ func (c *HisApiController) DeleteProject() {
|
2580
|
2738
|
// var consumable models.DialysisBeforePrepare
|
2581
|
2739
|
_, stockConfig := service.FindAutomaticReduceRecordByOrgId(c.GetAdminUserInfo().CurrentOrgId)
|
2582
|
2740
|
|
|
2741
|
+ isCharge := false
|
|
2742
|
+ isMedicine := false
|
|
2743
|
+ new_prescription, _ := service.GetPrescriptionById(project.PrescriptionId, c.GetAdminUserInfo().CurrentOrgId)
|
|
2744
|
+ new_prescriptions, _ := service.GetHisPrescription(c.GetAdminUserInfo().CurrentOrgId, new_prescription.PatientId, new_prescription.RecordDate, new_prescription.PType)
|
|
2745
|
+ for _, item := range new_prescriptions {
|
|
2746
|
+ if item.IsMedicine == 1 {
|
|
2747
|
+ isMedicine = true
|
|
2748
|
+ }
|
|
2749
|
+ }
|
|
2750
|
+ for _, item := range new_prescriptions {
|
|
2751
|
+ if item.OrderStatus == 2 {
|
|
2752
|
+ isCharge = true
|
|
2753
|
+ }
|
|
2754
|
+ }
|
|
2755
|
+ if isMedicine {
|
|
2756
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeletePMedicineWrong)
|
|
2757
|
+ return
|
|
2758
|
+ }
|
|
2759
|
+ if isCharge {
|
|
2760
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeletePChargeWrong)
|
|
2761
|
+ return
|
|
2762
|
+ }
|
|
2763
|
+
|
|
2764
|
+ if new_prescription.ID > 0 {
|
|
2765
|
+ if new_prescription.OrderStatus == 2 {
|
|
2766
|
+ isCharge = true
|
|
2767
|
+ }
|
|
2768
|
+ }
|
|
2769
|
+
|
|
2770
|
+ if isCharge {
|
|
2771
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeletePChargeWrongTwo)
|
|
2772
|
+ return
|
|
2773
|
+ }
|
|
2774
|
+
|
2583
|
2775
|
service.DeletePrintInfo(id)
|
2584
|
2776
|
label, _ := service.GetProjectById(adminInfo.CurrentOrgId, id, project.RecordDate, project.PatientId)
|
2585
|
2777
|
label.Status = 0
|
|
@@ -3492,7 +3684,7 @@ func (c *HisApiController) setAdviceWithJSON(advice *models.HisDoctorAdviceInfo,
|
3492
|
3684
|
advice.CheckState = hisAdvice.CheckState
|
3493
|
3685
|
advice.StartTime = hisAdvice.StartTime
|
3494
|
3686
|
advice.HospApprFlag = hisAdvice.HospApprFlag
|
3495
|
|
-
|
|
3687
|
+ advice.IsMedicine = hisAdvice.IsMedicine
|
3496
|
3688
|
if hisAdvice.UserOrgId == 10028 {
|
3497
|
3689
|
if hisAdvice.DeliveryWay != advice.DeliveryWay || hisAdvice.ExecutionFrequency != advice.ExecutionFrequency || hisAdvice.Day != advice.Day || hisAdvice.PrescribingNumber != advice.PrescribingNumber || hisAdvice.Price != advice.Price || hisAdvice.Remark != advice.Remark || hisAdvice.PrescribingNumberUnit != advice.PrescribingNumberUnit {
|
3498
|
3690
|
advice.ExecutionTime = 0
|
|
@@ -6222,7 +6414,7 @@ func (c *HisApiController) GetFaPiaoData() {
|
6222
|
6414
|
operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
|
6223
|
6415
|
}
|
6224
|
6416
|
|
6225
|
|
- if item.MedChrgitmType == "08" { //材料费
|
|
6417
|
+ if item.MedChrgitmType == "08" || item.MedChrgitmType == "1401" { //材料费
|
6226
|
6418
|
materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
|
6227
|
6419
|
materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
|
6228
|
6420
|
materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
|