Browse Source

历史排班

28169 2 years ago
parent
commit
1f6ceb7d93

+ 5 - 0
controllers/dialysis_record_api_controller.go View File

@@ -415,6 +415,9 @@ func (this *DialysisRecordAPIController) DialysisSchedule() {
415 415
 
416 416
 	//统计表
417 417
 	dryWeightList, _ := service.GetPatientDryWeight(adminInfo.CurrentOrgId, patientID)
418
+
419
+	allDoctor, _ := service.GetAllDoctor(adminInfo.CurrentOrgId, adminInfo.CurrentAppId)
420
+
418 421
 	if getDryErr != nil {
419 422
 		this.ErrorLog("获取最后一条干体重失败:%v", getDryErr)
420 423
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
@@ -470,6 +473,7 @@ func (this *DialysisRecordAPIController) DialysisSchedule() {
470 473
 			"is_advice_open":              adviceConfig,
471 474
 			"lastOrder":                   lastOrder,
472 475
 			"dryWeightList":               dryWeightList,
476
+			"docList":                     allDoctor,
473 477
 		}
474 478
 		this.ServeSuccessJSON(returnData)
475 479
 
@@ -508,6 +512,7 @@ func (this *DialysisRecordAPIController) DialysisSchedule() {
508 512
 			"is_advice_open":              adviceConfig,
509 513
 			"lastOrder":                   lastOrder,
510 514
 			"dryWeightList":               dryWeightList,
515
+			"docList":                     allDoctor,
511 516
 		}
512 517
 		this.ServeSuccessJSON(returnData)
513 518
 	}

+ 1 - 3
controllers/mobile_api_controllers/dialysis_api_controller.go View File

@@ -6079,11 +6079,10 @@ func (c *DialysisAPIController) EditConsumables() {
6079 6079
 					}
6080 6080
 				}
6081 6081
 
6082
-				fmt.Println("lnet---------------------------", len(outbefor))
6083 6082
 				if len(outbefor) > 0 {
6084 6083
 					//出库
6085 6084
 					for _, item := range outbefor {
6086
-						fmt.Println("出库ID", item.GoodId)
6085
+
6087 6086
 						var last_total int64
6088 6087
 						//1.查看该患者该耗材型号最后一次出库数量
6089 6088
 						goodInfoOne, _ := service.GetLastGoodListByPatientIdOne(record_time, patient_id, item.GoodId, item.GoodTypeId)
@@ -6140,7 +6139,6 @@ func (c *DialysisAPIController) EditConsumables() {
6140 6139
 							//1.查看该患者该耗材型号最后一次出库数量
6141 6140
 							goodInfoTwo, _ := service.GetLastGoodListByPatientIdOne(record_time, patient_id, item.GoodId, item.GoodTypeId)
6142 6141
 
6143
-							fmt.Println("count2323323222323wi", item.Count)
6144 6142
 							prepare := models.DialysisBeforePrepare{
6145 6143
 								UserOrgId:    adminInfo.Org.Id,
6146 6144
 								PatientId:    patient_id,

+ 98 - 0
controllers/patient_api_controller.go View File

@@ -2382,6 +2382,20 @@ func (c *PatientApiController) ExecDoctorAdvice() {
2382 2382
 					}
2383 2383
 
2384 2384
 					if medical.IsUse == 1 {
2385
+						drugError := models.XtDrugError{
2386
+							UserOrgId:             item.UserOrgId,
2387
+							DrugId:                item.DrugId,
2388
+							RecordDate:            item.AdviceDate,
2389
+							PatientId:             item.PatientId,
2390
+							Remark:                "电脑端零用药品",
2391
+							Status:                1,
2392
+							Ctime:                 time.Now().Unix(),
2393
+							Mtime:                 0,
2394
+							SumCount:              list.Count*medical.MinNumber + list.StockMinNumber,
2395
+							Prescribingnumber:     item.PrescribingNumber,
2396
+							PrescribingNumberUnit: item.PrescribingNumberUnit,
2397
+						}
2398
+						service.CreateDrugError(drugError)
2385 2399
 						c.ServeSuccessJSON(map[string]interface{}{
2386 2400
 							"msg":    "1",
2387 2401
 							"advice": advice,
@@ -2390,6 +2404,20 @@ func (c *PatientApiController) ExecDoctorAdvice() {
2390 2404
 					}
2391 2405
 					if medical.IsUse != 1 {
2392 2406
 						if (list.Count*medical.MinNumber + list.StockMinNumber) == 0 {
2407
+							drugError := models.XtDrugError{
2408
+								UserOrgId:             item.UserOrgId,
2409
+								DrugId:                item.DrugId,
2410
+								RecordDate:            item.AdviceDate,
2411
+								PatientId:             item.PatientId,
2412
+								Remark:                "电脑端药品库存不足",
2413
+								Status:                1,
2414
+								Ctime:                 time.Now().Unix(),
2415
+								Mtime:                 0,
2416
+								SumCount:              list.Count*medical.MinNumber + list.StockMinNumber,
2417
+								Prescribingnumber:     item.PrescribingNumber,
2418
+								PrescribingNumberUnit: item.PrescribingNumberUnit,
2419
+							}
2420
+							service.CreateDrugError(drugError)
2393 2421
 							c.ServeSuccessJSON(map[string]interface{}{
2394 2422
 								"msg":    "3",
2395 2423
 								"advice": advice,
@@ -2398,6 +2426,20 @@ func (c *PatientApiController) ExecDoctorAdvice() {
2398 2426
 						}
2399 2427
 
2400 2428
 						if prescribing_number_total > total {
2429
+							drugError := models.XtDrugError{
2430
+								UserOrgId:             item.UserOrgId,
2431
+								DrugId:                item.DrugId,
2432
+								RecordDate:            item.AdviceDate,
2433
+								PatientId:             item.PatientId,
2434
+								Remark:                "电脑端出库数量大于总库存",
2435
+								Status:                1,
2436
+								Ctime:                 time.Now().Unix(),
2437
+								Mtime:                 0,
2438
+								SumCount:              list.Count*medical.MinNumber + list.StockMinNumber,
2439
+								Prescribingnumber:     item.PrescribingNumber,
2440
+								PrescribingNumberUnit: item.PrescribingNumberUnit,
2441
+							}
2442
+							service.CreateDrugError(drugError)
2401 2443
 							c.ServeSuccessJSON(map[string]interface{}{
2402 2444
 								"msg":    "2",
2403 2445
 								"advice": advice,
@@ -2414,10 +2456,66 @@ func (c *PatientApiController) ExecDoctorAdvice() {
2414 2456
 								if pharmacyConfig.IsOpen == 1 && medical.IsPharmacy == 0 {
2415 2457
 									service.HisDrugsDelivery(item.UserOrgId, item.ExecutionStaff, item)
2416 2458
 
2459
+									if item.UserOrgId == 3877 || item.UserOrgId == 10265 {
2460
+										//查询该药品是否有出库记录
2461
+										flowMap, _ := service.GetDrugFLowByAdviceById(item.DrugId, item.PatientId, item.UserOrgId, item.AdviceDate)
2462
+										if len(flowMap) == 0 {
2463
+											errs := service.UpdateHisAdviceById(item.ID)
2464
+											if errs != nil {
2465
+												drugError := models.XtDrugError{
2466
+													UserOrgId:             item.UserOrgId,
2467
+													DrugId:                item.DrugId,
2468
+													RecordDate:            item.AdviceDate,
2469
+													PatientId:             item.PatientId,
2470
+													Remark:                "出库记录为空,更新执行人失败",
2471
+													Status:                1,
2472
+													Ctime:                 time.Now().Unix(),
2473
+													Mtime:                 0,
2474
+													SumCount:              list.Count*medical.MinNumber + list.StockMinNumber,
2475
+													Prescribingnumber:     item.PrescribingNumber,
2476
+													PrescribingNumberUnit: item.PrescribingNumberUnit,
2477
+												}
2478
+												service.CreateDrugError(drugError)
2479
+											}
2480
+											c.ServeSuccessJSON(map[string]interface{}{
2481
+												"msg":    "6",
2482
+												"advice": advice,
2483
+											})
2484
+											return
2485
+										}
2486
+									}
2417 2487
 								}
2418 2488
 								//不通过药房发药
2419 2489
 								if pharmacyConfig.IsOpen != 1 {
2420 2490
 									service.HisDrugsDelivery(item.UserOrgId, item.ExecutionStaff, item)
2491
+									if item.UserOrgId == 3877 || item.UserOrgId == 10265 {
2492
+										//查询该药品是否有出库记录
2493
+										flowMap, _ := service.GetDrugFLowByAdviceById(item.DrugId, item.PatientId, item.UserOrgId, item.AdviceDate)
2494
+										if len(flowMap) == 0 {
2495
+											errs := service.UpdateHisAdviceById(item.ID)
2496
+											if errs != nil {
2497
+												drugError := models.XtDrugError{
2498
+													UserOrgId:             item.UserOrgId,
2499
+													DrugId:                item.DrugId,
2500
+													RecordDate:            item.AdviceDate,
2501
+													PatientId:             item.PatientId,
2502
+													Remark:                "出库记录为空,更新执行人失败",
2503
+													Status:                1,
2504
+													Ctime:                 time.Now().Unix(),
2505
+													Mtime:                 0,
2506
+													SumCount:              list.Count*medical.MinNumber + list.StockMinNumber,
2507
+													Prescribingnumber:     item.PrescribingNumber,
2508
+													PrescribingNumberUnit: item.PrescribingNumberUnit,
2509
+												}
2510
+												service.CreateDrugError(drugError)
2511
+											}
2512
+											c.ServeSuccessJSON(map[string]interface{}{
2513
+												"msg":    "6",
2514
+												"advice": advice,
2515
+											})
2516
+											return
2517
+										}
2518
+									}
2421 2519
 								}
2422 2520
 								//查询默认仓库
2423 2521
 								storeHouseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)

+ 31 - 29
controllers/stock_in_api_controller.go View File

@@ -7546,36 +7546,38 @@ func (this *StockManagerApiController) ReturnCheckWarehouseInfo() {
7546 7546
 			return
7547 7547
 		}
7548 7548
 	}
7549
-	for _, item := range list {
7550
-
7551
-		//扣减数量
7552
-		service.UpdateWarehouseInfoByIdListTwo(item.WarehousingCount, item.ID)
7553
-
7554
-		//删除流水
7555
-		service.UpdateWarehouseInfoFlow(item.ID)
7556
-
7557
-		goodList, _ := service.GetSumGoodList(orgId, item.StorehouseId, item.GoodId)
7558
-		var flush_count int64
7559
-		for _, it := range goodList {
7560
-			flush_count += it.StockCount
7561
-		}
7562
-
7563
-		//扣减数量
7564
-		service.UpdateGoodInCount(item.WarehousingCount, item.OrgId, item.GoodId, item.StorehouseId, flush_count)
7549
+	//for _, item := range list {
7550
+	//
7551
+	//	//扣减数量
7552
+	//	service.UpdateWarehouseInfoByIdListTwo(item.WarehousingCount, item.ID)
7553
+	//
7554
+	//	//删除流水
7555
+	//	service.UpdateWarehouseInfoFlow(item.ID)
7556
+	//
7557
+	//	goodList, _ := service.GetSumGoodList(orgId, item.StorehouseId, item.GoodId)
7558
+	//	var flush_count int64
7559
+	//	for _, it := range goodList {
7560
+	//		flush_count += it.StockCount
7561
+	//	}
7562
+	//
7563
+	//	//扣减数量
7564
+	//	service.UpdateGoodInCount(item.WarehousingCount, item.OrgId, item.GoodId, item.StorehouseId, flush_count)
7565
+	//
7566
+	//	//查询默认仓库
7567
+	//	storeHouseConfig, _ := service.GetAllStoreHouseConfig(orgId)
7568
+	//	//查询该耗材剩余多少库存
7569
+	//	stockList, _ := service.GetStockCountByGoodId(item.GoodId, storeHouseConfig.StorehouseOutInfo, orgId)
7570
+	//	var sum_count int64
7571
+	//	var sum_in_count int64
7572
+	//	for _, it := range stockList {
7573
+	//		sum_count += it.StockCount
7574
+	//		sum_in_count += it.WarehousingCount
7575
+	//	}
7576
+	//	service.UpdateGoodInfoAddSumCount(item.GoodId, sum_count, orgId, sum_in_count)
7577
+	//}
7578
+	//err := service.ReturnCheckWarehouseInfo(warehousing_info_id)
7565 7579
 
7566
-		//查询默认仓库
7567
-		storeHouseConfig, _ := service.GetAllStoreHouseConfig(orgId)
7568
-		//查询该耗材剩余多少库存
7569
-		stockList, _ := service.GetStockCountByGoodId(item.GoodId, storeHouseConfig.StorehouseOutInfo, orgId)
7570
-		var sum_count int64
7571
-		var sum_in_count int64
7572
-		for _, it := range stockList {
7573
-			sum_count += it.StockCount
7574
-			sum_in_count += it.WarehousingCount
7575
-		}
7576
-		service.UpdateGoodInfoAddSumCount(item.GoodId, sum_count, orgId, sum_in_count)
7577
-	}
7578
-	err := service.ReturnCheckWarehouseInfo(warehousing_info_id)
7580
+	err := service.UpdateWarehouseInfoMap(list, warehousing_info_id, orgId)
7579 7581
 	if err == nil {
7580 7582
 		this.ServeSuccessJSON(map[string]interface{}{
7581 7583
 			"msg": "反审核成功!",

+ 1 - 1
service/dialysis_service.go View File

@@ -357,7 +357,7 @@ func ExecBatchDoctorAdvice(patient_id int64, orgid int64, ids []string, creater
357 357
 }
358 358
 
359 359
 func ExceHidDoctorAdviceById(m *models.HisDoctorAdviceInfo, id int64, patientId int64) error {
360
-	err := writeDb.Model(&models.HisDoctorAdviceInfo{}).Where("patient_id = ? AND (id = ? Or parent_id=?)  AND status = 1 ", patientId, id, id).Updates(map[string]interface{}{"execution_time": m.ExecutionTime, "execution_staff": m.ExecutionStaff, "execution_state": 1}).Error
360
+	err := writeDb.Model(&models.HisDoctorAdviceInfo{}).Where("patient_id = ? AND (id = ? Or parent_id=?)  AND status = 1 ", patientId, id, id).Updates(map[string]interface{}{"execution_time": m.ExecutionTime, "execution_staff": m.ExecutionStaff, "execution_state": 1, "is_mobile": 2}).Error
361 361
 	return err
362 362
 }
363 363
 

+ 2 - 2
service/mobile_dialysis_service.go View File

@@ -7237,9 +7237,9 @@ func GetHisDoctorAdvicesTwentyOne(orgID int64, scheduleDate int64, deliverWay st
7237 7237
 	return vms, err
7238 7238
 }
7239 7239
 
7240
-func GetPatientDryWeight(org_id int64, patient_id int64) (weight []*models.XtPatientDryweight, err error) {
7240
+func GetPatientDryWeight(org_id int64, patient_id int64) (weight []*models.SgjPatientDryweight, err error) {
7241 7241
 
7242
-	err = XTReadDB().Where("user_org_id = ? and patient_id = ? and status =1", org_id, patient_id).Find(&weight).Error
7242
+	err = XTReadDB().Where("user_org_id = ? and patient_id = ? and status =1", org_id, patient_id).Order("id asc").Limit(6).Find(&weight).Error
7243 7243
 
7244 7244
 	return weight, err
7245 7245
 }

+ 80 - 0
service/stock_service.go View File

@@ -8521,3 +8521,83 @@ func UpdateDeleteAutoGood(good_id int64, record_date int64, patient_id int64) er
8521 8521
 	err = XTWriteDB().Model(&models.DialysisBeforePrepare{}).Where("good_id = ? and record_date = ? and patient_id = ?", good_id, record_date, patient_id).Updates(map[string]interface{}{"status": 1}).Error
8522 8522
 	return err
8523 8523
 }
8524
+
8525
+func UpdateWarehouseInfoMap(list []*models.WarehousingInfo, warehousing_info_id int64, orgId int64) error {
8526
+
8527
+	tx := XTWriteDB().Begin()
8528
+
8529
+	for _, item := range list {
8530
+
8531
+		err := tx.Model(&models.WarehousingInfo{}).Where("id = ? and status = 1", item.ID).UpdateColumn("stock_count", gorm.Expr("stock_count - ?", item.WarehousingCount)).Error
8532
+		if err != nil {
8533
+			tx.Rollback()
8534
+			return err
8535
+		}
8536
+		err = tx.Model(&models.WarehousingInfo{}).Where("id = ? and status = 1", item.ID).Update(map[string]interface{}{"is_check": 2}).Error
8537
+		if err != nil {
8538
+			tx.Rollback()
8539
+			return err
8540
+		}
8541
+
8542
+		err = tx.Model(models.VmStockFlow{}).Where("warehousing_detail_id =  ?", item.ID).Update(map[string]interface{}{"status": 0, "is_check": 2}).Error
8543
+
8544
+		if err != nil {
8545
+			tx.Rollback()
8546
+			return err
8547
+		}
8548
+
8549
+		var goodList []*models.WarehousingInfo
8550
+		err = tx.Where("org_id = ? and storehouse_id = ? and good_id = ? and status =1  and is_check = 1", orgId, item.StorehouseId, item.GoodId).Find(&goodList).Error
8551
+
8552
+		var flush_count int64
8553
+		for _, it := range goodList {
8554
+			flush_count += it.StockCount
8555
+		}
8556
+
8557
+		err = tx.Model(&models.XtGoodStockCount{}).Where("user_org_id = ? and good_id  = ? and storehouse_id = ? and status = 1", item.OrgId, item.GoodId, item.StorehouseId).UpdateColumn("stock_in_count", gorm.Expr("stock_in_count - ?", item.WarehousingCount)).Error
8558
+		if err != nil {
8559
+			tx.Rollback()
8560
+			return err
8561
+		}
8562
+		err = tx.Model(&models.XtGoodStockCount{}).Where("user_org_id = ? and good_id = ? and storehouse_id = ? and status = 1", item.OrgId, item.GoodId, item.StorehouseId).Update(map[string]interface{}{"flush_count": flush_count}).Error
8563
+		if err != nil {
8564
+			tx.Rollback()
8565
+			return err
8566
+		}
8567
+
8568
+		storeHouseConfig := models.XtStorehouseConfig{}
8569
+		err = tx.Where("user_org_id = ? and status = 1", orgId).First(&storeHouseConfig).Error
8570
+
8571
+		var stockList []*models.WarehousingInfo
8572
+		//查询该耗材剩余多少库存
8573
+		err = tx.Where("good_id = ? and storehouse_id = ? and org_id = ? and status = 1 and is_check = 1", item.GoodId, storeHouseConfig.StorehouseOutInfo, orgId).Find(&stockList).Error
8574
+
8575
+		var sum_count int64
8576
+		var sum_in_count int64
8577
+		for _, it := range stockList {
8578
+			sum_count += it.StockCount
8579
+			sum_in_count += it.WarehousingCount
8580
+		}
8581
+
8582
+		err = tx.Model(&models.GoodInfo{}).Where("id = ? and org_id = ? and status = 1", item.GoodId, orgId).Update(map[string]interface{}{"sum_count": sum_count}).Error
8583
+		if err != nil {
8584
+			tx.Rollback()
8585
+			return err
8586
+		}
8587
+		err = tx.Model(&models.GoodInfo{}).Where("id = ? and org_id = ? and status = 1", item.GoodId, orgId).Update(map[string]interface{}{"sum_in_count": sum_in_count}).Error
8588
+		if err != nil {
8589
+			tx.Rollback()
8590
+			return err
8591
+		}
8592
+
8593
+	}
8594
+	err := tx.Model(&models.Warehousing{}).Where("id = ? and status = 1", warehousing_info_id).Update(map[string]interface{}{"is_check": 2}).Error
8595
+	if err != nil {
8596
+		tx.Rollback()
8597
+		return err
8598
+	}
8599
+	err = tx.Model(&models.WarehousingInfo{}).Where("warehousing_id = ? and status = 1", warehousing_info_id).Update(map[string]interface{}{"is_check": 2}).Error
8600
+	tx.Commit()
8601
+	return err
8602
+
8603
+}