Commit a6739108 by 李承祥

开单医院,工作量绩效计算

parent 57244c0c
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using Performance.DtoModels; using Performance.DtoModels;
using Performance.DtoModels.AppSettings; using Performance.DtoModels.AppSettings;
using Performance.EntityModels;
using Performance.Infrastructure; using Performance.Infrastructure;
using Performance.Services; using Performance.Services;
using System; using System;
...@@ -135,7 +136,6 @@ public ApiResponse Delete([CustomizeValidator(RuleSet = "Delete"), FromBody]Drug ...@@ -135,7 +136,6 @@ public ApiResponse Delete([CustomizeValidator(RuleSet = "Delete"), FromBody]Drug
} }
#endregion #endregion
#region drugprop #region drugprop
/// <summary> /// <summary>
/// 获取 药占比类型信息列表 /// 获取 药占比类型信息列表
...@@ -355,5 +355,60 @@ public ApiResponse AgainDelete([CustomizeValidator(RuleSet = "Delete"), FromBody ...@@ -355,5 +355,60 @@ public ApiResponse AgainDelete([CustomizeValidator(RuleSet = "Delete"), FromBody
return new ApiResponse(ResponseType.OK); return new ApiResponse(ResponseType.OK);
} }
#endregion #endregion
#region workitem
/// <summary>
/// 获取工作量绩效配置列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Route("workitemlist")]
[HttpPost]
public ApiResponse<List<cof_workitem>> GetWorkItems([CustomizeValidator(RuleSet = "Select"), FromBody]WorkItemRequest request)
{
var list = _configService.GetWorkItems(request.AllotID);
return new ApiResponse<List<cof_workitem>>(ResponseType.OK, "ok", list);
}
/// <summary>
/// 新增工作量绩效配置
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Route("workiteminsert")]
[HttpPost]
public ApiResponse<cof_workitem> WorkItemInsert([CustomizeValidator(RuleSet = "Insert"), FromBody]WorkItemRequest request)
{
var workyear = _configService.WorkItemInsert(request);
return new ApiResponse<cof_workitem>(ResponseType.OK, workyear);
}
/// <summary>
/// 修改工作量绩效配置
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Route("workitemupdate")]
[HttpPost]
public ApiResponse<cof_workitem> WorkItemUpdate([CustomizeValidator(RuleSet = "Update"), FromBody]WorkItemRequest request)
{
var workyear = _configService.WorkItemUpdate(request);
return new ApiResponse<cof_workitem>(ResponseType.OK, workyear);
}
/// <summary>
/// 删除工作量绩效配置
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Route("workitemdelete")]
[HttpPost]
public ApiResponse WorkItemDelete([CustomizeValidator(RuleSet = "Delete"), FromBody]WorkItemRequest request)
{
if (!_configService.WorkItemkDelete(request))
return new ApiResponse(ResponseType.Fail);
return new ApiResponse(ResponseType.OK);
}
#endregion
} }
} }
\ No newline at end of file
using FluentValidation;
using System;
using System.Collections.Generic;
using System.Text;
namespace Performance.DtoModels
{
public class WorkItemRequest
{
public int ID { get; set; }
public int AllotID { get; set; }
/// <summary>
/// 工作量绩效项
/// </summary>
public string Item { get; set; }
public class WorkItemRequestValidator : AbstractValidator<WorkItemRequest>
{
public WorkItemRequestValidator()
{
RuleSet("Select", () =>
{
RuleFor(x => x.AllotID).NotNull().NotEmpty().GreaterThan(0);
});
RuleSet("Insert", () =>
{
RuleFor(x => x.AllotID).NotNull().GreaterThan(0);
});
RuleSet("Update", () =>
{
RuleFor(x => x.ID).NotNull().GreaterThan(0);
});
RuleSet("Delete", () =>
{
RuleFor(x => x.ID).NotNull().GreaterThan(0);
});
}
}
}
}
...@@ -25,6 +25,7 @@ public class ProcessComputService : IAutoInjection ...@@ -25,6 +25,7 @@ public class ProcessComputService : IAutoInjection
private PerforResaccountRepository perforResaccountRepository; private PerforResaccountRepository perforResaccountRepository;
private PerforResbaiscnormRepository perforResbaiscnormRepository; private PerforResbaiscnormRepository perforResbaiscnormRepository;
private PerforCofdrugtypeRepository perforCofdrugtypeRepository; private PerforCofdrugtypeRepository perforCofdrugtypeRepository;
private PerforCofworkitemRepository perforCofworkitemRepository;
private readonly LogManageService logManageService; private readonly LogManageService logManageService;
public ProcessComputService(PerforCofincomeRepository perforCofincomeRepository, public ProcessComputService(PerforCofincomeRepository perforCofincomeRepository,
PerforCofdrugpropRepository perforCofdrugpropRepository, PerforCofdrugpropRepository perforCofdrugpropRepository,
...@@ -35,6 +36,7 @@ public class ProcessComputService : IAutoInjection ...@@ -35,6 +36,7 @@ public class ProcessComputService : IAutoInjection
PerforResaccountRepository perforResaccountRepository, PerforResaccountRepository perforResaccountRepository,
PerforResbaiscnormRepository perforResbaiscnormRepository, PerforResbaiscnormRepository perforResbaiscnormRepository,
PerforCofdrugtypeRepository perforCofdrugtypeRepository, PerforCofdrugtypeRepository perforCofdrugtypeRepository,
PerforCofworkitemRepository perforCofworkitemRepository,
LogManageService logManageService) LogManageService logManageService)
{ {
this.perforCofincomeRepository = perforCofincomeRepository; this.perforCofincomeRepository = perforCofincomeRepository;
...@@ -46,6 +48,7 @@ public class ProcessComputService : IAutoInjection ...@@ -46,6 +48,7 @@ public class ProcessComputService : IAutoInjection
this.perforResaccountRepository = perforResaccountRepository; this.perforResaccountRepository = perforResaccountRepository;
this.perforResbaiscnormRepository = perforResbaiscnormRepository; this.perforResbaiscnormRepository = perforResbaiscnormRepository;
this.perforCofdrugtypeRepository = perforCofdrugtypeRepository; this.perforCofdrugtypeRepository = perforCofdrugtypeRepository;
this.perforCofworkitemRepository = perforCofworkitemRepository;
this.logManageService = logManageService; this.logManageService = logManageService;
} }
...@@ -212,11 +215,12 @@ private List<PerSheet> MergeCompute(PerExcel excel, int allotid) ...@@ -212,11 +215,12 @@ private List<PerSheet> MergeCompute(PerExcel excel, int allotid)
logManageService.WriteMsg("正在生成绩效", "获取药品费用分割比例", 1, allotid, "ReceiveMessage"); logManageService.WriteMsg("正在生成绩效", "获取药品费用分割比例", 1, allotid, "ReceiveMessage");
var confs = GetDrugConfig(excel, allotid); var confs = GetDrugConfig(excel, allotid);
var conitem = perforCofworkitemRepository.GetEntities(t => t.AllotID == allotid);
//医生组 一次计算 //医生组 一次计算
//var onceWorkload1 = workloadCompute.OnceCompute(workload1, confs); //var onceWorkload1 = workloadCompute.OnceCompute(workload1, confs);
//医生组 二次计算 //医生组 二次计算
logManageService.WriteMsg("正在生成绩效", "医生组工作量计算", 1, allotid, "ReceiveMessage"); logManageService.WriteMsg("正在生成绩效", "医生组工作量计算", 1, allotid, "ReceiveMessage");
var twiceWorkloadResult1 = workloadCompute.TwiceCompute(workload1); var twiceWorkloadResult1 = workloadCompute.TwiceCompute(workload1, confs, conitem);
twiceWorkloadResult1.Sheet.SheetType = SheetType.ComputeDoctorWorkload; twiceWorkloadResult1.Sheet.SheetType = SheetType.ComputeDoctorWorkload;
perSheet.Add(twiceWorkloadResult1.Sheet); perSheet.Add(twiceWorkloadResult1.Sheet);
...@@ -227,7 +231,7 @@ private List<PerSheet> MergeCompute(PerExcel excel, int allotid) ...@@ -227,7 +231,7 @@ private List<PerSheet> MergeCompute(PerExcel excel, int allotid)
//var onceWorkload2 = workloadCompute.OnceCompute(workload2); //var onceWorkload2 = workloadCompute.OnceCompute(workload2);
//护理组 二次计算 //护理组 二次计算
logManageService.WriteMsg("正在生成绩效", "护理组工作量计算", 1, allotid, "ReceiveMessage"); logManageService.WriteMsg("正在生成绩效", "护理组工作量计算", 1, allotid, "ReceiveMessage");
var twiceWorkloadResult2 = workloadCompute.TwiceCompute(workload2); var twiceWorkloadResult2 = workloadCompute.TwiceCompute(workload2, confs, conitem);
twiceWorkloadResult2.Sheet.SheetType = SheetType.ComputeNurseWorkload; twiceWorkloadResult2.Sheet.SheetType = SheetType.ComputeNurseWorkload;
perSheet.Add(twiceWorkloadResult2.Sheet); perSheet.Add(twiceWorkloadResult2.Sheet);
...@@ -400,7 +404,7 @@ private List<CofDrugProp> GetDrugConfig(PerExcel excel, int allotid) ...@@ -400,7 +404,7 @@ private List<CofDrugProp> GetDrugConfig(PerExcel excel, int allotid)
var allData = datalist.GroupBy(t => t.AccountingUnit).Select(t => new { AccountingUnit = t.Key, SumValue = t.Sum(s => s.CellValue) }); var allData = datalist.GroupBy(t => t.AccountingUnit).Select(t => new { AccountingUnit = t.Key, SumValue = t.Sum(s => s.CellValue) });
var cofList = perforCofdrugpropRepository.GetEntities(); var cofList = perforCofdrugpropRepository.GetEntities(t => t.AllotID == allotid);
var unitList = (drugData?.Select(t => t.AccountingUnit) ?? new List<string>()).Union(allData.Select(t => t.AccountingUnit)); var unitList = (drugData?.Select(t => t.AccountingUnit) ?? new List<string>()).Union(allData.Select(t => t.AccountingUnit));
...@@ -410,9 +414,7 @@ private List<CofDrugProp> GetDrugConfig(PerExcel excel, int allotid) ...@@ -410,9 +414,7 @@ private List<CofDrugProp> GetDrugConfig(PerExcel excel, int allotid)
var asv = allData.FirstOrDefault(t => t.AccountingUnit == unit)?.SumValue; var asv = allData.FirstOrDefault(t => t.AccountingUnit == unit)?.SumValue;
var prop = asv.HasValue && asv.Value > 0 ? Math.Round((dsv ?? 0) / asv.Value, 2) : 0; var prop = asv.HasValue && asv.Value > 0 ? Math.Round((dsv ?? 0) / asv.Value, 2) : 0;
var fvalue = prop == 0 var fvalue = cofList.FirstOrDefault(t => prop > t.MinRange && prop <= t.MaxRange)?.Value ?? 0;
? 0
: cofList.FirstOrDefault(t => prop > t.MinRange && prop <= t.MaxRange)?.Value ?? 0;
cofs.Add(new CofDrugProp { AccoutingUnit = unit, Factor = fvalue, Prop = prop }); cofs.Add(new CofDrugProp { AccoutingUnit = unit, Factor = fvalue, Prop = prop });
} }
return cofs; return cofs;
......
...@@ -23,6 +23,7 @@ public class ConfigService : IAutoInjection ...@@ -23,6 +23,7 @@ public class ConfigService : IAutoInjection
private PerforPerallotRepository perforPerAllotRepository; private PerforPerallotRepository perforPerAllotRepository;
private PerforPeragainallotRepository perforPeragainallotRepository; private PerforPeragainallotRepository perforPeragainallotRepository;
private PerforHospitalRepository perforHospitalRepository; private PerforHospitalRepository perforHospitalRepository;
private PerforCofworkitemRepository _workitemRepository;
//private PerforLogdbugRepository logdbug; //private PerforLogdbugRepository logdbug;
private readonly LogManageService logManageService; private readonly LogManageService logManageService;
public ConfigService(PerforCofdirectorRepository cofdirectorRepository, public ConfigService(PerforCofdirectorRepository cofdirectorRepository,
...@@ -34,6 +35,7 @@ public class ConfigService : IAutoInjection ...@@ -34,6 +35,7 @@ public class ConfigService : IAutoInjection
PerforPerallotRepository perforPerAllotRepository, PerforPerallotRepository perforPerAllotRepository,
PerforPeragainallotRepository perforPeragainallotRepository, PerforPeragainallotRepository perforPeragainallotRepository,
PerforHospitalRepository perforHospitalRepository, PerforHospitalRepository perforHospitalRepository,
PerforCofworkitemRepository workitemRepository,
//PerforLogdbugRepository logdbug //PerforLogdbugRepository logdbug
LogManageService logManageService) LogManageService logManageService)
{ {
...@@ -41,6 +43,7 @@ public class ConfigService : IAutoInjection ...@@ -41,6 +43,7 @@ public class ConfigService : IAutoInjection
this._drugpropRepository = cofdrugpropRepository; this._drugpropRepository = cofdrugpropRepository;
this._incomeRepository = cofincomeRepository; this._incomeRepository = cofincomeRepository;
this._workyearRepository = cofworkyearRepository; this._workyearRepository = cofworkyearRepository;
this._workitemRepository = workitemRepository;
this._againRepository = againRepository; this._againRepository = againRepository;
this._drugtypeRepository = drugtypeRepository; this._drugtypeRepository = drugtypeRepository;
this.perforPerAllotRepository = perforPerAllotRepository; this.perforPerAllotRepository = perforPerAllotRepository;
...@@ -348,6 +351,63 @@ public bool WorkDelete(WorkyearRequest request) ...@@ -348,6 +351,63 @@ public bool WorkDelete(WorkyearRequest request)
} }
#endregion #endregion
#region cof_workitem 工作量绩效
/// <summary>
/// 获取cof_workitem列表
/// </summary>
/// <returns></returns>
public List<cof_workitem> GetWorkItems(int allotId)
{
var list = _workitemRepository.GetEntities(t => t.AllotID == allotId);
return Mapper.Map<List<cof_workitem>>(list);
}
/// <summary>
/// 添加数据
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public cof_workitem WorkItemInsert(WorkItemRequest request)
{
var workyear = Mapper.Map<cof_workitem>(request);
if (!_workitemRepository.Add(workyear))
throw new PerformanceException("保存失败");
return Mapper.Map<cof_workitem>(workyear);
}
/// <summary>
/// 更新数据
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public cof_workitem WorkItemUpdate(WorkItemRequest request)
{
var workyear = _workitemRepository.GetEntity(t => t.ID == request.ID);
if (null == workyear)
throw new PerformanceException($"ID不存在 :{request.ID}");
workyear.Item = request.Item;
if (!_workitemRepository.Update(workyear))
throw new PerformanceException("保存失败");
return Mapper.Map<cof_workitem>(workyear);
}
/// <summary>
/// 删除数据
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public bool WorkItemkDelete(WorkItemRequest request)
{
var workyear = _workitemRepository.GetEntity(t => t.ID == request.ID);
if (null == workyear)
throw new PerformanceException($"ID不存在 :{request.ID}");
return _workitemRepository.Remove(workyear);
}
#endregion
#region Copy #region Copy
/// <summary> /// <summary>
/// 复制报表基础配置 /// 复制报表基础配置
......
using Performance.DtoModels; using Performance.DtoModels;
using Performance.EntityModels;
using Performance.Infrastructure; using Performance.Infrastructure;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
...@@ -98,7 +99,7 @@ public PerSheet OnceCompute(PerSheet sheet, List<CofDrugProp> confs = null) ...@@ -98,7 +99,7 @@ public PerSheet OnceCompute(PerSheet sheet, List<CofDrugProp> confs = null)
/// </summary> /// </summary>
/// <param name="sheet"></param> /// <param name="sheet"></param>
/// <returns></returns> /// <returns></returns>
public (PerSheet Sheet, List<PerData> PerData) TwiceCompute(PerSheet sheet) public (PerSheet Sheet, List<PerData> PerData) TwiceCompute(PerSheet sheet, List<CofDrugProp> confs = null, List<cof_workitem> workitems = null)
{ {
//获取最大列坐标位置 //获取最大列坐标位置
int thiscell = sheet.PerHeader.OrderByDescending(t => t.PointCell).FirstOrDefault().PointCell + 1; int thiscell = sheet.PerHeader.OrderByDescending(t => t.PointCell).FirstOrDefault().PointCell + 1;
...@@ -117,7 +118,7 @@ public PerSheet OnceCompute(PerSheet sheet, List<CofDrugProp> confs = null) ...@@ -117,7 +118,7 @@ public PerSheet OnceCompute(PerSheet sheet, List<CofDrugProp> confs = null)
UnitType = group.Key.UnitType, UnitType = group.Key.UnitType,
AccountingUnit = group.Key.AccountingUnit, AccountingUnit = group.Key.AccountingUnit,
//CellValue = group.Sum(s => s.CellValue), //CellValue = group.Sum(s => s.CellValue),
CellValue = group.Sum(s => s.IsFactor ? s.CellValue * s.FactorValue : s.CellValue), CellValue = ComputValue(group, confs, workitems),
TypeName = group.Key.UnitType, TypeName = group.Key.UnitType,
RowNumber = group.FirstOrDefault()?.RowNumber ?? 0, RowNumber = group.FirstOrDefault()?.RowNumber ?? 0,
IsTotal = 1, IsTotal = 1,
...@@ -131,6 +132,24 @@ public PerSheet OnceCompute(PerSheet sheet, List<CofDrugProp> confs = null) ...@@ -131,6 +132,24 @@ public PerSheet OnceCompute(PerSheet sheet, List<CofDrugProp> confs = null)
sheet.PerData.AddRange(perDataList); sheet.PerData.AddRange(perDataList);
return (sheet, perDataList); return (sheet, perDataList);
} }
private decimal? ComputValue(IGrouping<object, PerData> group, List<CofDrugProp> confs = null, List<cof_workitem> workitems = null)
{
if (confs == null || workitems == null)
return group.Sum(s => s.IsFactor ? s.CellValue * s.FactorValue : s.CellValue);
else
{
var factor = confs.FirstOrDefault(t => t.AccoutingUnit == group.First().AccountingUnit)?.Factor ?? 1;
//需要乘系数的项
var fgroup = group.Where(t => workitems.Select(s => s.Item).Contains(t.TypeName));
//需要乘系数的项
var ngroup = group.Where(t => !workitems.Select(s => s.Item).Contains(t.TypeName));
var value = fgroup.Sum(s => s.IsFactor ? s.CellValue * s.FactorValue : s.CellValue) * factor;
value += ngroup.Sum(s => s.IsFactor ? s.CellValue * s.FactorValue : s.CellValue);
return value;
}
}
#endregion #endregion
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment