Commit 08a9f0b6 by 李承祥

费用分类

parent 8798741c
...@@ -136,7 +136,7 @@ public ApiResponse Delete([CustomizeValidator(RuleSet = "Delete"), FromBody]Drug ...@@ -136,7 +136,7 @@ public ApiResponse Delete([CustomizeValidator(RuleSet = "Delete"), FromBody]Drug
} }
#endregion #endregion
#region drugprop #region drugtype
/// <summary> /// <summary>
/// 获取 药占比类型信息列表 /// 获取 药占比类型信息列表
/// </summary> /// </summary>
......
...@@ -26,6 +26,10 @@ public class DrugpropRequest ...@@ -26,6 +26,10 @@ public class DrugpropRequest
/// 费用名称 /// 费用名称
/// </summary> /// </summary>
public string Charge { get; set; } public string Charge { get; set; }
/// <summary>
/// 费用类别
/// </summary>
public string ChargeType { get; set; }
public class DrugpropRequestValidator : AbstractValidator<DrugpropRequest> public class DrugpropRequestValidator : AbstractValidator<DrugpropRequest>
......
...@@ -30,5 +30,10 @@ public class cof_drugtype ...@@ -30,5 +30,10 @@ public class cof_drugtype
/// 费用名称 /// 费用名称
/// </summary> /// </summary>
public string Charge { get; set; } public string Charge { get; set; }
/// <summary>
/// 费用类别
/// </summary>
public string ChargeType { get; set; }
} }
} }
...@@ -42,48 +42,48 @@ public List<PerReport> AvgRatio(int hospitalid) ...@@ -42,48 +42,48 @@ public List<PerReport> AvgRatio(int hospitalid)
/// 门诊患者均次费用 /// 门诊患者均次费用
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public List<PerReport> OutFeeAvg(List<string> date) public List<PerReport> OutFeeAvg(int hospitalId, List<string> date)
{ {
string sql = @"select concat(year,'-',lpad(month,2,'0')) y,deptname x,round(sum(fee) / sum(persontime),2) value from hos_personfee where source = '门诊' and concat(year,'-',lpad(month,2,'0')) in @date group by year,month,deptname order by y asc,value desc;"; string sql = @"select concat(year,'-',lpad(month,2,'0')) y,deptname x,round(sum(fee) / sum(persontime),2) value from hos_personfee where source = '门诊' and concat(year,'-',lpad(month,2,'0')) and hospitalid = @hospitalId in @date group by year,month,deptname order by y asc,value desc;";
return DapperQuery(sql, new { date }).ToList(); return DapperQuery(sql, new { date, hospitalId }).ToList();
} }
/// <summary> /// <summary>
/// 住院患者均次费用 /// 住院患者均次费用
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public List<PerReport> InpatFeeAvg(List<string> date) public List<PerReport> InpatFeeAvg(int hospitalId, List<string> date)
{ {
string sql = @"select concat(year,'-',lpad(month,2,'0')) y,deptname x,round(sum(fee) / sum(persontime),2) value from hos_personfee where source = '住院' and concat(year,'-',lpad(month,2,'0')) in @date group by year,month,deptname order by y asc,value desc;"; string sql = @"select concat(year,'-',lpad(month,2,'0')) y,deptname x,round(sum(fee) / sum(persontime),2) value from hos_personfee where source = '住院' and concat(year,'-',lpad(month,2,'0')) in @date and hospitalid = @hospitalId group by year,month,deptname order by y asc,value desc;";
return DapperQuery(sql, new { date }).ToList(); return DapperQuery(sql, new { date, hospitalId }).ToList();
} }
/// <summary> /// <summary>
/// 科室药占比 /// 科室药占比
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public List<PerReport> Medicine(List<string> date) public List<PerReport> Medicine(int hospitalId, List<string> date)
{ {
string sql = @"select accountingunit x,concat(year,'-',lpad(month,2,'0')) y,round((sum(if(dt.TypeName in string sql = @"select accountingunit x,concat(year,'-',lpad(month,2,'0')) y,round((sum(if(dt.TypeName in
('中成药费','西药费','中草药费'),cellvalue,0)) / sum(cellvalue))*100,2) value from per_allot aot (select charge from cof_drugtype where allotid = aot.id and chargetype = '药品'),cellvalue,0)) / sum(cellvalue))*100,2) value from per_allot aot
join per_sheet sht on aot.id=sht.allotid join im_data dt on dt.sheetid=sht.id where unittype=1 and sheettype=3 join per_sheet sht on aot.id=sht.allotid join im_data dt on dt.sheetid=sht.id where unittype=1 and sheettype=3
and sheetname like '%就诊收入' and ifnull(accountingunit,'') not in ('') and concat(year,'-',lpad(month,2,'0')) and sheetname like '%就诊收入' and ifnull(accountingunit,'') not in ('') and concat(year,'-',lpad(month,2,'0'))
in @date group by year,month,accountingunit order by y asc,value desc;"; in @date group by year,month,accountingunit order by y asc,value desc;";
return DapperQuery(sql, new { date }).ToList(); return DapperQuery(sql, new { hospitalId, date }).ToList();
} }
/// <summary> /// <summary>
/// 科室有效收入占比 /// 科室有效收入占比
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public List<PerReport> Income(List<string> date) public List<PerReport> Income(int hospitalId, List<string> date)
{ {
string sql = @"select accountingunit x,concat(year,'-',lpad(month,2,'0')) y,round((sum(if(dt.TypeName not in string sql = @"select accountingunit x,concat(year,'-',lpad(month,2,'0')) y,round((sum(if(dt.TypeName not in
('中成药费','西药费','中草药费','医材费'),cellvalue,0)) / sum(cellvalue))*100,2) value from per_allot aot (select charge from cof_drugtype where allotid = aot.id),cellvalue,0)) / sum(cellvalue))*100,2) value from per_allot aot
join per_sheet sht on aot.id=sht.allotid join im_data dt on dt.sheetid=sht.id where unittype=1 and sheettype=3 join per_sheet sht on aot.id=sht.allotid join im_data dt on dt.sheetid=sht.id where unittype=1 and sheettype=3
and sheetname like '%就诊收入' and ifnull(accountingunit,'') not in ('') and concat(year,'-',lpad(month,2,'0')) and sheetname like '%就诊收入' and ifnull(accountingunit,'') not in ('') and concat(year,'-',lpad(month,2,'0'))
in @date group by year,month,accountingunit order by y asc,value desc;"; in @date and hospitalid = @hospitalId group by year,month,accountingunit order by y asc,value desc;";
return DapperQuery(sql, new { date }).ToList(); return DapperQuery(sql, new { hospitalId, date }).ToList();
} }
} }
} }
...@@ -499,7 +499,7 @@ private List<CofDrugProp> GetDrugConfig(PerExcel excel, int allotid) ...@@ -499,7 +499,7 @@ private List<CofDrugProp> GetDrugConfig(PerExcel excel, int allotid)
var incomeSheet = excel.PerSheet.FirstOrDefault(t => t.SheetType == SheetType.Income && t.SheetName.Contains("门诊") && t.SheetName.Contains("就诊")); var incomeSheet = excel.PerSheet.FirstOrDefault(t => t.SheetType == SheetType.Income && t.SheetName.Contains("门诊") && t.SheetName.Contains("就诊"));
var datalist = incomeSheet.PerData.Select(t => (PerData)t); var datalist = incomeSheet.PerData.Select(t => (PerData)t);
var drugtype = perforCofdrugtypeRepository.GetEntities(t => t.AllotID == allotid)?.Select(t => t.Charge).ToList(); var drugtype = perforCofdrugtypeRepository.GetEntities(t => t.AllotID == allotid && t.ChargeType == "药品")?.Select(t => t.Charge).ToList();
var drugData = datalist.Where(t => drugtype.Contains(t.TypeName)).GroupBy(t => t.AccountingUnit).Select(t => new { AccountingUnit = t.Key, SumValue = t.Sum(s => s.CellValue) }); var drugData = datalist.Where(t => drugtype.Contains(t.TypeName)).GroupBy(t => t.AccountingUnit).Select(t => new { AccountingUnit = t.Key, SumValue = t.Sum(s => s.CellValue) });
if (drugtype == null) if (drugtype == null)
......
...@@ -199,7 +199,8 @@ public cof_drugtype DrugtypeInsert(DrugpropRequest request) ...@@ -199,7 +199,8 @@ public cof_drugtype DrugtypeInsert(DrugpropRequest request)
var entity = new cof_drugtype var entity = new cof_drugtype
{ {
AllotID = request.AllotID, AllotID = request.AllotID,
Charge = request.Charge Charge = request.Charge,
ChargeType = request.ChargeType
}; };
if (!_drugtypeRepository.Add(entity)) if (!_drugtypeRepository.Add(entity))
throw new PerformanceException("保存失败"); throw new PerformanceException("保存失败");
...@@ -218,6 +219,7 @@ public cof_drugtype DrugtypeUpdate(DrugpropRequest request) ...@@ -218,6 +219,7 @@ public cof_drugtype DrugtypeUpdate(DrugpropRequest request)
throw new PerformanceException($"ID不存在 :{request.ID}"); throw new PerformanceException($"ID不存在 :{request.ID}");
entity.Charge = request.Charge; entity.Charge = request.Charge;
entity.ChargeType = request.ChargeType;
if (!_drugtypeRepository.Update(entity)) if (!_drugtypeRepository.Update(entity))
throw new PerformanceException("保存失败"); throw new PerformanceException("保存失败");
......
...@@ -168,7 +168,7 @@ public List<PerReport> OutFeeAvg(int hospitalId) ...@@ -168,7 +168,7 @@ public List<PerReport> OutFeeAvg(int hospitalId)
var date = new List<string>(); var date = new List<string>();
date = allotList.OrderByDescending(t => t.Year).ThenByDescending(t => t.Month).Take(6).Select(t => t.Year + "-" + t.Month.ToString().PadLeft(2, '0')).ToList(); date = allotList.OrderByDescending(t => t.Year).ThenByDescending(t => t.Month).Take(6).Select(t => t.Year + "-" + t.Month.ToString().PadLeft(2, '0')).ToList();
return perforReportRepository.OutFeeAvg(date); return perforReportRepository.OutFeeAvg(hospitalId, date);
} }
/// <summary> /// <summary>
...@@ -184,7 +184,7 @@ public List<PerReport> InpatFeeAvg(int hospitalId) ...@@ -184,7 +184,7 @@ public List<PerReport> InpatFeeAvg(int hospitalId)
var date = new List<string>(); var date = new List<string>();
date = allotList.OrderByDescending(t => t.Year).ThenByDescending(t => t.Month).Take(6).Select(t => t.Year + "-" + t.Month.ToString().PadLeft(2, '0')).ToList(); date = allotList.OrderByDescending(t => t.Year).ThenByDescending(t => t.Month).Take(6).Select(t => t.Year + "-" + t.Month.ToString().PadLeft(2, '0')).ToList();
return perforReportRepository.InpatFeeAvg(date); return perforReportRepository.InpatFeeAvg(hospitalId, date);
} }
/// <summary> /// <summary>
...@@ -208,7 +208,7 @@ public List<PerReport> Medicine(int hospitalId, int isIndex) ...@@ -208,7 +208,7 @@ public List<PerReport> Medicine(int hospitalId, int isIndex)
{ {
date = allotList.OrderByDescending(t => t.Year).ThenByDescending(t => t.Month).Take(6).Select(t => t.Year + "-" + t.Month.ToString().PadLeft(2, '0')).ToList(); date = allotList.OrderByDescending(t => t.Year).ThenByDescending(t => t.Month).Take(6).Select(t => t.Year + "-" + t.Month.ToString().PadLeft(2, '0')).ToList();
} }
return perforReportRepository.Medicine(date); return perforReportRepository.Medicine(hospitalId, date);
} }
/// <summary> /// <summary>
...@@ -232,7 +232,7 @@ public List<PerReport> Income(int hospitalId, int isIndex) ...@@ -232,7 +232,7 @@ public List<PerReport> Income(int hospitalId, int isIndex)
{ {
date = allotList.OrderByDescending(t => t.Year).ThenByDescending(t => t.Month).Take(6).Select(t => t.Year + "-" + t.Month.ToString().PadLeft(2, '0')).ToList(); date = allotList.OrderByDescending(t => t.Year).ThenByDescending(t => t.Month).Take(6).Select(t => t.Year + "-" + t.Month.ToString().PadLeft(2, '0')).ToList();
} }
return perforReportRepository.Income(date); return perforReportRepository.Income(hospitalId, date);
} }
} }
} }
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