|
@@ -981,6 +981,69 @@ func (c *HisApiController) CreateHisPrescription() {
|
981
|
981
|
|
982
|
982
|
_, stockConfig := service.FindAutomaticReduceRecordByOrgId(c.GetAdminUserInfo().CurrentOrgId)
|
983
|
983
|
|
|
984
|
+ //已发药和已收费限制逻辑
|
|
985
|
+ isMidicine := false
|
|
986
|
+ isCharge := false
|
|
987
|
+ if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
|
|
988
|
+ prescriptions, _ := dataBody["prescriptions"].([]interface{})
|
|
989
|
+ if len(prescriptions) > 0 {
|
|
990
|
+ for _, item := range prescriptions {
|
|
991
|
+ items := item.(map[string]interface{})
|
|
992
|
+ if items["id"] == nil || reflect.TypeOf(items["id"]).String() != "float64" {
|
|
993
|
+ utils.ErrorLog("id")
|
|
994
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
995
|
+ return
|
|
996
|
+ }
|
|
997
|
+ id := int64(items["id"].(float64))
|
|
998
|
+ if id > 0 {
|
|
999
|
+ new_prescription, err := service.GetPrescriptionById(id, adminInfo.CurrentOrgId)
|
|
1000
|
+ if err != nil {
|
|
1001
|
+ if new_prescription.OrderStatus == 2 {
|
|
1002
|
+ isCharge = true
|
|
1003
|
+ }
|
|
1004
|
+ }
|
|
1005
|
+ }
|
|
1006
|
+
|
|
1007
|
+ if items["advices"] != nil && reflect.TypeOf(items["advices"]).String() == "[]interface {}" {
|
|
1008
|
+ advices := items["advices"].([]interface{})
|
|
1009
|
+ fmt.Println("~~~~~~~~4")
|
|
1010
|
+
|
|
1011
|
+ if len(advices) > 0 {
|
|
1012
|
+ for _, advice := range advices {
|
|
1013
|
+ fmt.Println("~~~~~~~~3")
|
|
1014
|
+
|
|
1015
|
+ var adviceId int64
|
|
1016
|
+ if advice.(map[string]interface{})["advice_id"] != nil || reflect.TypeOf(advice.(map[string]interface{})["advice_id"]).String() == "float64" {
|
|
1017
|
+ adviceId = int64(advice.(map[string]interface{})["advice_id"].(float64))
|
|
1018
|
+ }
|
|
1019
|
+ if adviceId > 0 {
|
|
1020
|
+ his_advice_info, err := service.GetHisDoctorAdviceInfo(adviceId)
|
|
1021
|
+ fmt.Println("~~~~~~~~1")
|
|
1022
|
+ fmt.Println("~~~~~~~~1")
|
|
1023
|
+
|
|
1024
|
+ if err == nil {
|
|
1025
|
+ if his_advice_info.IsMedicine == 1 {
|
|
1026
|
+ fmt.Println("~~~~~~~~2")
|
|
1027
|
+ isMidicine = true
|
|
1028
|
+ }
|
|
1029
|
+ }
|
|
1030
|
+ }
|
|
1031
|
+ }
|
|
1032
|
+ }
|
|
1033
|
+ }
|
|
1034
|
+ }
|
|
1035
|
+ }
|
|
1036
|
+ }
|
|
1037
|
+ if isMidicine == true {
|
|
1038
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeMedicineWrong)
|
|
1039
|
+ return
|
|
1040
|
+ }
|
|
1041
|
+ if isCharge == true {
|
|
1042
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeChargeWrong)
|
|
1043
|
+ return
|
|
1044
|
+ }
|
|
1045
|
+ //已发药和已收费限制逻辑
|
|
1046
|
+
|
984
|
1047
|
if drugStockConfig.IsOpen == 1 {
|
985
|
1048
|
//校验库存总量
|
986
|
1049
|
if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
|
|
@@ -1484,6 +1547,7 @@ func (c *HisApiController) CreateHisPrescription() {
|
1484
|
1547
|
tempPrescription.Modifier = adminInfo.AdminUser.Id
|
1485
|
1548
|
tempPrescription.Mtime = time.Now().Unix()
|
1486
|
1549
|
tempPrescription.Doctor = role.UserName
|
|
1550
|
+
|
1487
|
1551
|
//tempPrescription.OrderStatus = order_status
|
1488
|
1552
|
tempPrescription.PreTime = pTime
|
1489
|
1553
|
tempPrescription.MedType = med_type
|
|
@@ -2068,6 +2132,47 @@ func (c *HisApiController) DeletePrescription() {
|
2068
|
2132
|
|
2069
|
2133
|
_, stockConfig := service.FindAutomaticReduceRecordByOrgId(c.GetAdminUserInfo().CurrentOrgId)
|
2070
|
2134
|
|
|
2135
|
+ //已收费和已发药限制逻辑
|
|
2136
|
+ isCharge := false
|
|
2137
|
+ isMedicine := false
|
|
2138
|
+ new_prescription, p_err := service.GetPrescriptionById(prescription_id, c.GetAdminUserInfo().CurrentOrgId)
|
|
2139
|
+ new_prescriptions, _ := service.GetHisPrescription(c.GetAdminUserInfo().CurrentOrgId, new_prescription.PatientId, new_prescription.RecordDate, new_prescription.PType)
|
|
2140
|
+
|
|
2141
|
+ for _, item := range new_prescriptions {
|
|
2142
|
+ if item.IsMedicine == 1 {
|
|
2143
|
+ isMedicine = true
|
|
2144
|
+ }
|
|
2145
|
+ }
|
|
2146
|
+
|
|
2147
|
+ for _, item := range new_prescriptions {
|
|
2148
|
+ if item.OrderStatus == 2 {
|
|
2149
|
+ isCharge = true
|
|
2150
|
+ }
|
|
2151
|
+ }
|
|
2152
|
+
|
|
2153
|
+ if p_err != nil {
|
|
2154
|
+ if new_prescription.ID > 0 {
|
|
2155
|
+ if new_prescription.OrderStatus == 2 {
|
|
2156
|
+ isCharge = true
|
|
2157
|
+ }
|
|
2158
|
+ }
|
|
2159
|
+ }
|
|
2160
|
+ for _, item := range advices {
|
|
2161
|
+ if item.IsMedicine == 1 {
|
|
2162
|
+ isMedicine = true
|
|
2163
|
+ }
|
|
2164
|
+ }
|
|
2165
|
+ if isCharge {
|
|
2166
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeletePChargeWrong)
|
|
2167
|
+ return
|
|
2168
|
+ }
|
|
2169
|
+
|
|
2170
|
+ if isMedicine {
|
|
2171
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeletePMedicineWrong)
|
|
2172
|
+ return
|
|
2173
|
+ }
|
|
2174
|
+ //已收费和已发药限制逻辑
|
|
2175
|
+
|
2071
|
2176
|
if len(projects) > 0 {
|
2072
|
2177
|
for _, item := range projects {
|
2073
|
2178
|
service.DeletePrintInfo(item.ID) //删除打印信息
|
|
@@ -2296,13 +2401,63 @@ func (c *HisApiController) DeletePrescription() {
|
2296
|
2401
|
return
|
2297
|
2402
|
|
2298
|
2403
|
}
|
2299
|
|
-
|
2300
|
2404
|
func (c *HisApiController) DeleteDoctorAdvice() {
|
2301
|
2405
|
id, _ := c.GetInt64("id")
|
2302
|
2406
|
advice, _ := service.GetHisDoctorAdvicesById(id)
|
2303
|
2407
|
|
2304
|
2408
|
_, drugStockConfig := service.FindDrugStockAutomaticReduceRecordByOrgId(c.GetAdminUserInfo().CurrentOrgId)
|
2305
|
2409
|
|
|
2410
|
+ //已收费和已发药的限制逻辑
|
|
2411
|
+ isCharge := false
|
|
2412
|
+ isMedicine := false
|
|
2413
|
+ new_prescription, _ := service.GetPrescriptionById(advice.PrescriptionId, c.GetAdminUserInfo().CurrentOrgId)
|
|
2414
|
+
|
|
2415
|
+ //获取今天该患者所有处方,判断是否发药或者收费
|
|
2416
|
+ new_prescriptions, _ := service.GetHisPrescription(c.GetAdminUserInfo().CurrentOrgId, new_prescription.PatientId, new_prescription.RecordDate, new_prescription.PType)
|
|
2417
|
+ for _, item := range new_prescriptions {
|
|
2418
|
+ if item.IsMedicine == 1 {
|
|
2419
|
+ isMedicine = true
|
|
2420
|
+ }
|
|
2421
|
+ }
|
|
2422
|
+ for _, item := range new_prescriptions {
|
|
2423
|
+ if item.OrderStatus == 2 {
|
|
2424
|
+ isCharge = true
|
|
2425
|
+ }
|
|
2426
|
+ }
|
|
2427
|
+
|
|
2428
|
+ if isMedicine {
|
|
2429
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeletePMedicineWrong)
|
|
2430
|
+ return
|
|
2431
|
+ }
|
|
2432
|
+
|
|
2433
|
+ if isCharge {
|
|
2434
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeletePChargeWrong)
|
|
2435
|
+ return
|
|
2436
|
+ }
|
|
2437
|
+
|
|
2438
|
+ advices, _ := service.GetHisPrescriptionAdviceByID(advice.PrescriptionId)
|
|
2439
|
+ for _, item := range advices {
|
|
2440
|
+ if item.IsMedicine == 1 {
|
|
2441
|
+ isMedicine = true
|
|
2442
|
+ }
|
|
2443
|
+ }
|
|
2444
|
+
|
|
2445
|
+ if isMedicine {
|
|
2446
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteMedicineWrong)
|
|
2447
|
+ return
|
|
2448
|
+ }
|
|
2449
|
+ if new_prescription.ID > 0 {
|
|
2450
|
+ if new_prescription.OrderStatus == 2 {
|
|
2451
|
+ isCharge = true
|
|
2452
|
+ }
|
|
2453
|
+ }
|
|
2454
|
+
|
|
2455
|
+ if isCharge {
|
|
2456
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeletePChargeWrongTwo)
|
|
2457
|
+ return
|
|
2458
|
+ }
|
|
2459
|
+ //已收费和已发药的限制逻辑
|
|
2460
|
+
|
2306
|
2461
|
err := service.DelelteDoctorAdvice(id, c.GetAdminUserInfo().CurrentOrgId)
|
2307
|
2462
|
redis := service.RedisClient()
|
2308
|
2463
|
keyFive := strconv.FormatInt(advice.UserOrgId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":his_advices_list_all"
|
|
@@ -2342,7 +2497,6 @@ func (c *HisApiController) DeleteDoctorAdvice() {
|
2342
|
2497
|
return
|
2343
|
2498
|
}
|
2344
|
2499
|
}
|
2345
|
|
-
|
2346
|
2500
|
func (c *HisApiController) DeleteProject() {
|
2347
|
2501
|
id, _ := c.GetInt64("id")
|
2348
|
2502
|
adminInfo := c.GetAdminUserInfo()
|
|
@@ -2350,6 +2504,40 @@ func (c *HisApiController) DeleteProject() {
|
2350
|
2504
|
// var consumable models.DialysisBeforePrepare
|
2351
|
2505
|
_, stockConfig := service.FindAutomaticReduceRecordByOrgId(c.GetAdminUserInfo().CurrentOrgId)
|
2352
|
2506
|
|
|
2507
|
+ isCharge := false
|
|
2508
|
+ isMedicine := false
|
|
2509
|
+ new_prescription, _ := service.GetPrescriptionById(project.PrescriptionId, c.GetAdminUserInfo().CurrentOrgId)
|
|
2510
|
+ new_prescriptions, _ := service.GetHisPrescription(c.GetAdminUserInfo().CurrentOrgId, new_prescription.PatientId, new_prescription.RecordDate, new_prescription.PType)
|
|
2511
|
+ for _, item := range new_prescriptions {
|
|
2512
|
+ if item.IsMedicine == 1 {
|
|
2513
|
+ isMedicine = true
|
|
2514
|
+ }
|
|
2515
|
+ }
|
|
2516
|
+ for _, item := range new_prescriptions {
|
|
2517
|
+ if item.OrderStatus == 2 {
|
|
2518
|
+ isCharge = true
|
|
2519
|
+ }
|
|
2520
|
+ }
|
|
2521
|
+ if isMedicine {
|
|
2522
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeletePMedicineWrong)
|
|
2523
|
+ return
|
|
2524
|
+ }
|
|
2525
|
+ if isCharge {
|
|
2526
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeletePChargeWrong)
|
|
2527
|
+ return
|
|
2528
|
+ }
|
|
2529
|
+
|
|
2530
|
+ if new_prescription.ID > 0 {
|
|
2531
|
+ if new_prescription.OrderStatus == 2 {
|
|
2532
|
+ isCharge = true
|
|
2533
|
+ }
|
|
2534
|
+ }
|
|
2535
|
+
|
|
2536
|
+ if isCharge {
|
|
2537
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeletePChargeWrongTwo)
|
|
2538
|
+ return
|
|
2539
|
+ }
|
|
2540
|
+
|
2353
|
2541
|
service.DeletePrintInfo(id)
|
2354
|
2542
|
label, _ := service.GetProjectById(adminInfo.CurrentOrgId, id, project.RecordDate, project.PatientId)
|
2355
|
2543
|
label.Status = 0
|
|
@@ -3262,7 +3450,7 @@ func (c *HisApiController) setAdviceWithJSON(advice *models.HisDoctorAdviceInfo,
|
3262
|
3450
|
advice.CheckState = hisAdvice.CheckState
|
3263
|
3451
|
advice.StartTime = hisAdvice.StartTime
|
3264
|
3452
|
advice.HospApprFlag = hisAdvice.HospApprFlag
|
3265
|
|
-
|
|
3453
|
+ advice.IsMedicine = hisAdvice.IsMedicine
|
3266
|
3454
|
if hisAdvice.UserOrgId == 10028 {
|
3267
|
3455
|
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 {
|
3268
|
3456
|
advice.ExecutionTime = 0
|