Browse Source

医保对接

csx 2 years ago
parent
commit
6815e02b4a

+ 191 - 3
controllers/his_api_controller.go View File

@@ -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

+ 25 - 0
controllers/role_controller.go View File

@@ -261,6 +261,9 @@ func (this *RoleAPIController) EditPurviewInitData() {
261 261
 	_, _, originDictMedicinePurview := service.GetOtherAllGeneralPurviewVMsProcessed("/dict/manage")
262 262
 	_, _, originBedPurview := service.GetOtherAllGeneralPurviewVMsProcessed("/bed/manage")
263 263
 
264
+	//采购管理
265
+	_, _, purchaseManagerPurview := service.GetOtherAllGeneralPurviewVMsProcessed("/supply/query")
266
+
264 267
 	//门诊管理
265 268
 
266 269
 	subPurviewTreeViewModel := []*service.PurviewTreeViewModel{}
@@ -269,6 +272,8 @@ func (this *RoleAPIController) EditPurviewInitData() {
269 272
 	subPurviewTreeViewModelThree := []*service.PurviewTreeViewModel{}
270 273
 	subPurviewTreeViewModelFour := []*service.PurviewTreeViewModel{}
271 274
 
275
+	subPurviewTreeViewModelFive := []*service.PurviewTreeViewModel{}
276
+
272 277
 	for _, item := range outpatientRegistrationPurview {
273 278
 		temp := &service.PurviewTreeViewModel{
274 279
 			ID:     item.Id,
@@ -309,6 +314,17 @@ func (this *RoleAPIController) EditPurviewInitData() {
309 314
 		subPurviewTreeViewModelFour = append(subPurviewTreeViewModelFour, temp)
310 315
 	}
311 316
 
317
+	//采购管理
318
+	for _, item := range purchaseManagerPurview {
319
+		temp := &service.PurviewTreeViewModel{
320
+			ID:     item.Id,
321
+			PID:    item.Parentid,
322
+			Name:   item.Name,
323
+			Number: 1,
324
+		}
325
+		subPurviewTreeViewModelFive = append(subPurviewTreeViewModelFive, temp)
326
+	}
327
+
312 328
 	for _, item := range outpatientRegistration {
313 329
 		if item.Name == "门诊挂号" {
314 330
 			item.Childs = append(item.Childs, subPurviewTreeViewModel...)
@@ -640,6 +656,15 @@ func (this *RoleAPIController) EditPurviewInitData() {
640 656
 	}
641 657
 	purviews = append(purviews, dianzi)
642 658
 
659
+	caigou := &service.PurviewTreeViewModel{
660
+		ID:     0,
661
+		PID:    0,
662
+		Name:   "采购管理",
663
+		Number: 3,
664
+		Childs: subPurviewTreeViewModelFive,
665
+	}
666
+	purviews = append(purviews, caigou)
667
+
643 668
 	touxi := &service.PurviewTreeViewModel{
644 669
 		ID:     0,
645 670
 		PID:    0,

+ 16 - 0
enums/error_code.go View File

@@ -252,6 +252,14 @@ const ( // ErrorCode
252 252
 
253 253
 	ErrorCheckGoodParamSuccess = 3400000
254 254
 	ErrorCheckGoodParamWrong   = 3300000
255
+
256
+	ErrorCodeMedicineWrong        = 3800000
257
+	ErrorCodeChargeWrong          = 3900000
258
+	ErrorCodeDeletePMedicineWrong = 3900001
259
+	ErrorCodeDeletePChargeWrong   = 3900002
260
+
261
+	ErrorCodeDeleteMedicineWrong   = 3900003
262
+	ErrorCodeDeletePChargeWrongTwo = 3900004
255 263
 )
256 264
 
257 265
 var ErrCodeMsgs = map[int]string{
@@ -492,6 +500,14 @@ var ErrCodeMsgs = map[int]string{
492 500
 	ErrorEmployeeNumber:        "请输入正确的工号",
493 501
 	ErrorCheckGoodParamSuccess: "反审核成功!",
494 502
 	ErrorCheckGoodParamWrong:   "该入库单已出库,反审核失败!",
503
+
504
+	ErrorCodeMedicineWrong: "处方中包含已发药的药品,无法保存或修改",
505
+	ErrorCodeChargeWrong:   "处方中包含已收费处方,无法保存或修改",
506
+
507
+	ErrorCodeDeletePMedicineWrong:  "处方中包含已发药的药品,无法删除",
508
+	ErrorCodeDeletePChargeWrong:    "处方中包含收费处方,无法删除",
509
+	ErrorCodeDeleteMedicineWrong:   "该药品已经发药,无法删除",
510
+	ErrorCodeDeletePChargeWrongTwo: "该医嘱所属处方已经收费,无法删除",
495 511
 }
496 512
 
497 513
 type SGJError struct {

+ 1 - 0
models/his_charge_models.go View File

@@ -30,6 +30,7 @@ type HisChargeDoctorAdviceInfo struct {
30 30
 	Remark                string `gorm:"column:remark" json:"remark" form:"remark"`
31 31
 	AdviceDate            int64  `gorm:"column:advice_date" json:"advice_date" form:"advice_date"`
32 32
 	Drug                  Drug   `gorm:"ForeignKey:ID;AssociationForeignKey:DrugId" json:"drug"`
33
+	IsMedicine            int64  `gorm:"column:is_medicine" json:"is_medicine" form:"is_medicine"`
33 34
 }
34 35
 
35 36
 func (HisChargeDoctorAdviceInfo) TableName() string {

+ 3 - 4
models/his_models.go View File

@@ -255,6 +255,7 @@ type HisDoctorAdviceInfo struct {
255 255
 	HospApprFlag          int64                  `gorm:"column:hosp_appr_flag" json:"hosp_appr_flag" form:"hosp_appr_flag"`
256 256
 	LmtUsedFlag           int64                  `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
257 257
 	HisOrderInfo          HisOrderInfo           `gorm:"ForeignKey:AdviceId;AssociationForeignKey:ID" json:"order_info"`
258
+	IsMedicine            int64                  `gorm:"column:is_medicine" json:"is_medicine" form:"is_medicine"`
258 259
 }
259 260
 
260 261
 func (HisDoctorAdviceInfo) TableName() string {
@@ -538,6 +539,7 @@ type HisPrescription struct {
538 539
 	PType                  int64                     `gorm:"column:p_type" json:"p_type" form:"p_type"`
539 540
 	MedType                string                    `gorm:"column:med_type" json:"med_type" form:"med_type"`
540 541
 	TempHisOrder           TempHisOrder              `gorm:"ForeignKey:Number,MedType;AssociationForeignKey:BatchNumber,MedType" json:"order"`
542
+	IsMedicine             int64                     `gorm:"column:is_medicine" json:"is_medicine" form:"is_medicine"`
541 543
 }
542 544
 
543 545
 func (HisPrescription) TableName() string {
@@ -1036,7 +1038,7 @@ type HisOrder struct {
1036 1038
 	HisOrderInfo           HisOrderInfo           `gorm:"ForeignKey:ID;AssociationForeignKey:OrderId" json:"order_info"`
1037 1039
 	Patients               Patients               `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
1038 1040
 	HisPatient             HisPatient             `gorm:"ForeignKey:MdtrtId;AssociationForeignKey:Number" json:"his_patient"`
1039
-	HisHospitalCheckRecord HisHospitalCheckRecord `gorm:"ForeignKey:MdtrtId,PatientId;AssociationForeignKey:Number,PatientId" json:"his_hospital_patient"`
1041
+	HisHospitalCheckRecord HisHospitalCheckRecord `gorm:"ForeignKey:MdtrtId;AssociationForeignKey:Number" json:"his_hospital_patient"`
1040 1042
 
1041 1043
 	HisPrescriptionInfo HisPrescriptionInfo `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"p_info"`
1042 1044
 
@@ -2169,9 +2171,6 @@ func (NewHisHospitalCheckRecord) TableName() string {
2169 2171
 	return "his_hospital_check_record"
2170 2172
 }
2171 2173
 
2172
-
2173
-
2174
-
2175 2174
 type HisOrderTenty struct {
2176 2175
 	ID                           int64                        `gorm:"column:id" json:"id" form:"id"`
2177 2176
 	UserOrgId                    int64                        `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`

+ 1 - 0
models/his_summary_models.go View File

@@ -275,6 +275,7 @@ type VmHisDoctorAdviceInfo struct {
275 275
 	Way                   int64   `gorm:"column:way" json:"way" form:"way"`
276 276
 	Mtime                 int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
277 277
 	AdviceId              int64   `gorm:"column:advice_id" json:"advice_id" form:"advice_id"`
278
+	IsMedicine            int64   `gorm:"column:is_medicine" json:"is_medicine" form:"is_medicine"`
278 279
 }
279 280
 
280 281
 func (VmHisDoctorAdviceInfo) TableName() string {

+ 1 - 0
service/his_service.go View File

@@ -1695,6 +1695,7 @@ type HisDoctorAdviceInfo struct {
1695 1695
 	DrugId               int64                `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
1696 1696
 	Drug                 Drug                 `gorm:"ForeignKey:ID;AssociationForeignKey:DrugId" json:"drug"`
1697 1697
 	VMHisPrescriptionTwo VMHisPrescriptionTwo `gorm:"ForeignKey:ID;AssociationForeignKey:PrescriptionId" json:"prescription"`
1698
+	IsMedicine           int64                `gorm:"column:is_medicine" json:"is_medicine" form:"is_medicine"`
1698 1699
 }
1699 1700
 
1700 1701
 func (HisDoctorAdviceInfo) TableName() string {

+ 1 - 0
service/mobile_dialysis_service.go View File

@@ -321,6 +321,7 @@ type VMHisDoctorAdviceInfo struct {
321 321
 	ExecutionTime  int64 `gorm:"column:execution_time" json:"execution_time" form:"execution_time"`
322 322
 	ExecutionStaff int64 `gorm:"column:execution_staff" json:"execution_staff" form:"execution_staff"`
323 323
 	ExecutionState int64 `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
324
+	IsMedicine     int64 `gorm:"column:is_medicine" json:"is_medicine" form:"is_medicine"`
324 325
 }
325 326
 
326 327
 func (VMHisDoctorAdviceInfo) TableName() string {