Commit 08a9f0b6 by 李承祥

费用分类

parent 8798741c
......@@ -136,7 +136,7 @@ public ApiResponse Delete([CustomizeValidator(RuleSet = "Delete"), FromBody]Drug
}
#endregion
#region drugprop
#region drugtype
/// <summary>
/// 获取 药占比类型信息列表
/// </summary>
......
......@@ -26,6 +26,10 @@ public class DrugpropRequest
/// 费用名称
/// </summary>
public string Charge { get; set; }
/// <summary>
/// 费用类别
/// </summary>
public string ChargeType { get; set; }
public class DrugpropRequestValidator : AbstractValidator<DrugpropRequest>
......
......@@ -30,5 +30,10 @@ public class cof_drugtype
/// 费用名称
/// </summary>
public string Charge { get; set; }
/// <summary>
/// 费用类别
/// </summary>
public string ChargeType { get; set; }
}
}
......@@ -42,48 +42,48 @@ public List<PerReport> AvgRatio(int hospitalid)
/// 门诊患者均次费用
/// </summary>
/// <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;";
return DapperQuery(sql, new { date }).ToList();
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, hospitalId }).ToList();
}
/// <summary>
/// 住院患者均次费用
/// </summary>
/// <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;";
return DapperQuery(sql, new { date }).ToList();
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, hospitalId }).ToList();
}
/// <summary>
/// 科室药占比
/// </summary>
/// <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
('中成药费','西药费','中草药费'),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
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;";
return DapperQuery(sql, new { date }).ToList();
return DapperQuery(sql, new { hospitalId, date }).ToList();
}
/// <summary>
/// 科室有效收入占比
/// </summary>
/// <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
('中成药费','西药费','中草药费','医材费'),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
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;";
return DapperQuery(sql, new { date }).ToList();
in @date and hospitalid = @hospitalId group by year,month,accountingunit order by y asc,value desc;";
return DapperQuery(sql, new { hospitalId, date }).ToList();
}
}
}
......@@ -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 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) });
if (drugtype == null)
......
......@@ -199,7 +199,8 @@ public cof_drugtype DrugtypeInsert(DrugpropRequest request)
var entity = new cof_drugtype
{
AllotID = request.AllotID,
Charge = request.Charge
Charge = request.Charge,
ChargeType = request.ChargeType
};
if (!_drugtypeRepository.Add(entity))
throw new PerformanceException("保存失败");
......@@ -218,6 +219,7 @@ public cof_drugtype DrugtypeUpdate(DrugpropRequest request)
throw new PerformanceException($"ID不存在 :{request.ID}");
entity.Charge = request.Charge;
entity.ChargeType = request.ChargeType;
if (!_drugtypeRepository.Update(entity))
throw new PerformanceException("保存失败");
......
......@@ -168,7 +168,7 @@ public List<PerReport> OutFeeAvg(int hospitalId)
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();
return perforReportRepository.OutFeeAvg(date);
return perforReportRepository.OutFeeAvg(hospitalId, date);
}
/// <summary>
......@@ -184,7 +184,7 @@ public List<PerReport> InpatFeeAvg(int hospitalId)
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();
return perforReportRepository.InpatFeeAvg(date);
return perforReportRepository.InpatFeeAvg(hospitalId, date);
}
/// <summary>
......@@ -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();
}
return perforReportRepository.Medicine(date);
return perforReportRepository.Medicine(hospitalId, date);
}
/// <summary>
......@@ -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();
}
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