stringsql=$"select year x,'业务总收入(年)' y,sum(CellValue) value from report_original_income where hospitalid = @hospitalId group by year;";
if(isOnlyYear!=1)
sql=$"select concat(year,'-',lpad(month,2,'0')) x,'业务总收入(月)' y,sum(CellValue) value from report_original_income where hospitalid = @hospitalId group by year,month;";
returnDapperQuery(sql,new{hospitalId}).ToList();
stringwhere="";
if(!string.IsNullOrEmpty(request.Year))
{
where+=$" and year in ({request.Year}) ";
}
if(!string.IsNullOrEmpty(request.Month))
{
where+=$" and month in ({request.Month}) ";
}
stringsql=$"select year x,'业务总收入(年)' y,sum(CellValue) value from report_original_income where hospitalid = @hospitalId {where} group by year;";
if(request.OnlyYear!=1)
sql=$"select concat(year,'-',lpad(month,2,'0')) x,'业务总收入(月)' y,sum(CellValue) value from report_original_income where hospitalid = @hospitalId {where} group by year,month;";
stringsql=$"select '住院' x,year y,round(t.InHos/(t.InHos + t.Outpatient) * 100, 2) value from (select year,sum(case SourceType when '住院' then CellValue else 0 end) InHos,sum(case SourceType when '门诊' then CellValue else 0 end) Outpatient from report_original_income where hospitalid = @hospitalId group by year)t"+
stringwhere="";
if(!string.IsNullOrEmpty(request.Year))
{
where+=$" and year in ({request.Year}) ";
}
if(!string.IsNullOrEmpty(request.Month))
{
where+=$" and month in ({request.Month}) ";
}
stringsql=$"select '住院' x,year y,round(t.InHos/(t.InHos + t.Outpatient) * 100, 2) value from (select year,sum(case SourceType when '住院' then CellValue else 0 end) InHos,sum(case SourceType when '门诊' then CellValue else 0 end) Outpatient from report_original_income where hospitalid = @hospitalId {where} group by year)t"+
$" union "+
$"select '门诊' x,year y,round(t.Outpatient/(t.InHos + t.Outpatient) * 100, 2) value from (select year,sum(case SourceType when '住院' then CellValue else 0 end) InHos,sum(case SourceType when '门诊' then CellValue else 0 end) Outpatient from report_original_income where hospitalid = @hospitalId group by year)t;";
if(isOnlyYear!=1)
sql=$"select '住院' x,concat(year,'-',lpad(month,2,'0')) y,round(t.InHos/(t.InHos+t.Outpatient) * 100, 2) value from (select year,month,sum(case SourceType when '住院' then CellValue else 0 end) InHos,sum(case SourceType when '门诊' then CellValue else 0 end) Outpatient from report_original_income where hospitalid = @hospitalId group by year,month)t"+
$"select '门诊' x,year y,round(t.Outpatient/(t.InHos + t.Outpatient) * 100, 2) value from (select year,sum(case SourceType when '住院' then CellValue else 0 end) InHos,sum(case SourceType when '门诊' then CellValue else 0 end) Outpatient from report_original_income where hospitalid = @hospitalId {where}group by year)t;";
if(request.OnlyYear!=1)
sql=$"select '住院' x,concat(year,'-',lpad(month,2,'0')) y,round(t.InHos/(t.InHos+t.Outpatient) * 100, 2) value from (select year,month,sum(case SourceType when '住院' then CellValue else 0 end) InHos,sum(case SourceType when '门诊' then CellValue else 0 end) Outpatient from report_original_income where hospitalid = @hospitalId {where}group by year,month)t"+
$" union "+
$"select '门诊' x,concat(year,'-',lpad(month,2,'0')) y,round(t.Outpatient/(t.InHos+t.Outpatient) * 100, 2) value from (select year,month,sum(case SourceType when '住院' then CellValue else 0 end) InHos,sum(case SourceType when '门诊' then CellValue else 0 end) Outpatient from report_original_income where hospitalid = @hospitalId group by year,month)t;";
returnDapperQuery(sql,new{hospitalId}).ToList();
$"select '门诊' x,concat(year,'-',lpad(month,2,'0')) y,round(t.Outpatient/(t.InHos+t.Outpatient) * 100, 2) value from (select year,month,sum(case SourceType when '住院' then CellValue else 0 end) InHos,sum(case SourceType when '门诊' then CellValue else 0 end) Outpatient from report_original_income where hospitalid = @hospitalId {where}group by year,month)t;";
stringsql=$"select TypeName x,t1.y,round(CellValue/t2.`value`*100,2) value from (select year y,TypeName,sum(CellValue) CellValue from report_original_income where HospitalID = @hospitalId group by year,TypeName) t1 inner join (select year y,sum(CellValue) value from report_original_income where hospitalid = @hospitalId group by year)t2 on t1.y = t2.y order by y asc,value desc;";
if(isOnlyYear!=1)
sql=$"select TypeName x,t1.y,round(CellValue/t2.`value`*100,2) value from (select concat(year,'-',lpad(month,2,'0')) y,TypeName,sum(CellValue) CellValue from report_original_income where HospitalID = @hospitalId group by year,month,TypeName) t1 inner join (select concat(year,'-',lpad(month,2,'0')) y,sum(CellValue) value from report_original_income where hospitalid = @hospitalId group by year,month)t2 on t1.y = t2.y order by y asc,value desc;";
returnDapperQuery(sql,new{hospitalId}).ToList();
stringwhere="";
if(!string.IsNullOrEmpty(request.Year))
{
where+=$" and year in ({request.Year}) ";
}
if(!string.IsNullOrEmpty(request.Month))
{
where+=$" and month in ({request.Month}) ";
}
stringsql=$"select TypeName x,t1.y,round(CellValue/t2.`value`*100,2) value from (select year y,TypeName,sum(CellValue) CellValue from report_original_income where HospitalID = @hospitalId {where} group by year,TypeName) t1 inner join (select year y,sum(CellValue) value from report_original_income where hospitalid = @hospitalId {where} group by year)t2 on t1.y = t2.y order by y asc,value desc;";
if(request.OnlyYear!=1)
sql=$"select TypeName x,t1.y,round(CellValue/t2.`value`*100,2) value from (select concat(year,'-',lpad(month,2,'0')) y,TypeName,sum(CellValue) CellValue from report_original_income where HospitalID = @hospitalId {where} group by year,month,TypeName) t1 inner join (select concat(year,'-',lpad(month,2,'0')) y,sum(CellValue) value from report_original_income where hospitalid = @hospitalId {where} group by year,month)t2 on t1.y = t2.y order by y asc,value desc;";
stringsql=$"select TypeName x,t1.y,round(CellValue/t2.`value`*100,2) value from (select year y,TypeName,sum(CellValue) CellValue from report_original_income t1 inner join cof_drugtype t2 on t1.TypeName = t2.Charge and t1.AllotID = t2.AllotId and t2.ChargeType = '药品' where HospitalID = @hospitalId group by year,TypeName) t1 inner join (select year y,sum(CellValue) value from report_original_income where hospitalid = @hospitalId group by year)t2 on t1.y = t2.y;";
if(isOnlyYear!=1)
sql=$"select TypeName x,t1.y,round(CellValue/t2.`value`*100,2) value from (select concat(year,'-',lpad(month,2,'0')) y,TypeName,sum(CellValue) CellValue from report_original_income t1 inner join cof_drugtype t2 on t1.TypeName = t2.Charge and t1.AllotID = t2.AllotId and t2.ChargeType = '药品' where HospitalID = @hospitalId group by year,month,TypeName) t1 inner join (select concat(year,'-',lpad(month,2,'0')) y,sum(CellValue) value from report_original_income where hospitalid = @hospitalId group by year,month)t2 on t1.y = t2.y;";
returnDapperQuery(sql,new{hospitalId}).ToList();
stringwhere="";
if(!string.IsNullOrEmpty(request.Year))
{
where+=$" and year in ({request.Year}) ";
}
if(!string.IsNullOrEmpty(request.Month))
{
where+=$" and month in ({request.Month}) ";
}
stringsql=$"select TypeName x,t1.y,round(CellValue/t2.`value`*100,2) value from (select year y,TypeName,sum(CellValue) CellValue from report_original_income t1 inner join cof_drugtype t2 on t1.TypeName = t2.Charge and t1.AllotID = t2.AllotId and t2.ChargeType = '药品' where HospitalID = @hospitalId {where} group by year,TypeName) t1 inner join (select year y,sum(CellValue) value from report_original_income where hospitalid = @hospitalId {where} group by year)t2 on t1.y = t2.y;";
if(request.OnlyYear!=1)
sql=$"select TypeName x,t1.y,round(CellValue/t2.`value`*100,2) value from (select concat(year,'-',lpad(month,2,'0')) y,TypeName,sum(CellValue) CellValue from report_original_income t1 inner join cof_drugtype t2 on t1.TypeName = t2.Charge and t1.AllotID = t2.AllotId and t2.ChargeType = '药品' where HospitalID = @hospitalId {where} group by year,month,TypeName) t1 inner join (select concat(year,'-',lpad(month,2,'0')) y,sum(CellValue) value from report_original_income where hospitalid = @hospitalId {where} group by year,month)t2 on t1.y = t2.y;";
stringsql=$"select TypeName x,t1.y,round(CellValue/t2.`value`*100,2) value from (select year y,TypeName,sum(CellValue) CellValue from report_original_income t1 inner join cof_drugtype t2 on t1.TypeName = t2.Charge and t1.AllotID = t2.AllotId and t2.ChargeType = '耗材' where HospitalID = @hospitalId group by year,TypeName) t1 inner join (select year y,sum(CellValue) value from report_original_income where hospitalid = @hospitalId group by year)t2 on t1.y = t2.y;";
if(isOnlyYear!=1)
sql=$"select TypeName x,t1.y,round(CellValue/t2.`value`*100,2) value from (select concat(year,'-',lpad(month,2,'0')) y,TypeName,sum(CellValue) CellValue from report_original_income t1 inner join cof_drugtype t2 on t1.TypeName = t2.Charge and t1.AllotID = t2.AllotId and t2.ChargeType = '耗材' where HospitalID = @hospitalId group by year,month,TypeName) t1 inner join (select concat(year,'-',lpad(month,2,'0')) y,sum(CellValue) value from report_original_income where hospitalid = @hospitalId group by year,month)t2 on t1.y = t2.y;";
returnDapperQuery(sql,new{hospitalId}).ToList();
stringwhere="";
if(!string.IsNullOrEmpty(request.Year))
{
where+=$" and year in ({request.Year}) ";
}
if(!string.IsNullOrEmpty(request.Month))
{
where+=$" and month in ({request.Month}) ";
}
stringsql=$"select TypeName x,t1.y,round(CellValue/t2.`value`*100,2) value from (select year y,TypeName,sum(CellValue) CellValue from report_original_income t1 inner join cof_drugtype t2 on t1.TypeName = t2.Charge and t1.AllotID = t2.AllotId and t2.ChargeType = '耗材' where HospitalID = @hospitalId {where} group by year,TypeName) t1 inner join (select year y,sum(CellValue) value from report_original_income where hospitalid = @hospitalId {where} group by year)t2 on t1.y = t2.y;";
if(request.OnlyYear!=1)
sql=$"select TypeName x,t1.y,round(CellValue/t2.`value`*100,2) value from (select concat(year,'-',lpad(month,2,'0')) y,TypeName,sum(CellValue) CellValue from report_original_income t1 inner join cof_drugtype t2 on t1.TypeName = t2.Charge and t1.AllotID = t2.AllotId and t2.ChargeType = '耗材' where HospitalID = @hospitalId {where} group by year,month,TypeName) t1 inner join (select concat(year,'-',lpad(month,2,'0')) y,sum(CellValue) value from report_original_income where hospitalid = @hospitalId {where} group by year,month)t2 on t1.y = t2.y;";
stringsql=$"select t2.x,'绩效发放金额占全院收入占比(年)' y,round(t1.RealGiveFee/t2.income * 100, 2) value from (select `year`,sum(realgivefee) realgivefee from report_allot_summary where HospitalID = @hospitalId group by year) t1 inner join (select year x,sum(CellValue) income from report_original_income where HospitalId = @hospitalId group by year)t2 on t1.`Year` = t2.x;";
if(isOnlyYear!=1)
sql=$"select t2.x,'绩效发放金额占全院收入占比(月)' y,round(t1.RealGiveFee/t2.income * 100, 2) value from report_allot_summary t1 inner join (select concat(year,'-',lpad(month,2,'0')) x,sum(CellValue) income from report_original_income where HospitalId = @hospitalId group by year,month)t2 on concat(t1.year,'-',lpad(t1.month,2,'0')) = t2.x where t1.HospitalID = @hospitalId;";
returnDapperQuery(sql,new{hospitalId}).ToList();
stringwhere="";
if(!string.IsNullOrEmpty(request.Year))
{
where+=$" and year in ({request.Year}) ";
}
if(!string.IsNullOrEmpty(request.Month))
{
where+=$" and month in ({request.Month}) ";
}
stringsql=$"select t2.x,'绩效发放金额占全院收入占比(年)' y,round(t1.RealGiveFee/t2.income * 100, 2) value from (select `year`,sum(realgivefee) realgivefee from report_allot_summary where HospitalID = @hospitalId {where} group by year) t1 inner join (select year x,sum(CellValue) income from report_original_income where HospitalId = @hospitalId {where} group by year)t2 on t1.`Year` = t2.x;";
if(request.OnlyYear!=1)
sql=$"select t2.x,'绩效发放金额占全院收入占比(月)' y,round(t1.RealGiveFee/t2.income * 100, 2) value from report_allot_summary t1 inner join (select concat(year,'-',lpad(month,2,'0')) x,sum(CellValue) income from report_original_income where HospitalId = @hospitalId {where} group by year,month)t2 on concat(t1.year,'-',lpad(t1.month,2,'0')) = t2.x where t1.HospitalID = @hospitalId {where};";
stringsql=$"select PositionName x,year y,round(sum(avgvalue), 2) value from (select t1.PositionName,year,AvgValue from res_baiscnorm t1 inner join per_allot t2 on t1.AllotID = t2.Id and t2.HospitalId = @hospitalId and locate('保底', t1.PositionName) = 0)t group by PositionName,year;";
if(isOnlyYear!=1)
sql=$"select t1.PositionName x, concat(t2.year, '-', lpad(t2.month, 2, '0')) y,round(AvgValue, 2) value from res_baiscnorm t1 inner join per_allot t2 on t1.AllotID = t2.Id and t2.HospitalId = @hospitalId and locate('保底', t1.PositionName) = 0;";
returnDapperQuery(sql,new{hospitalId}).ToList();
stringwhere="";
if(!string.IsNullOrEmpty(request.Year))
{
where+=$" and year in ({request.Year}) ";
}
if(!string.IsNullOrEmpty(request.Month))
{
where+=$" and month in ({request.Month}) ";
}
stringsql=$"select PositionName x,year y,round(sum(avgvalue), 2) value from (select t1.PositionName,year,AvgValue from res_baiscnorm t1 inner join per_allot t2 on t1.AllotID = t2.Id and t2.HospitalId = @hospitalId {where} and locate('保底', t1.PositionName) = 0)t group by PositionName,year;";
if(request.OnlyYear!=1)
sql=$"select t1.PositionName x, concat(t2.year, '-', lpad(t2.month, 2, '0')) y,round(AvgValue, 2) value from res_baiscnorm t1 inner join per_allot t2 on t1.AllotID = t2.Id and t2.HospitalId = @hospitalId {where} and locate('保底', t1.PositionName) = 0;";
stringsql=$"select `Year` y,AccountingUnit x,round(sum(avg),2) value from (select t1.AccountingUnit,t1.Avg,t2.`Year`,t2.`Month`,t2.ID from res_account t1 inner join per_allot t2 on t1.AllotID = t2.ID and t2.HospitalId = @hospitalId and t1.UnitType != 2)t group by year,AccountingUnit;";
if(isOnlyYear!=1)
sql=$"select concat(year,'-',lpad(month,2,'0')) y,AccountingUnit x,round(sum(avg),2) value from (select t1.AccountingUnit,t1.Avg,t2.`Year`,t2.`Month`,t2.ID from res_account t1 inner join per_allot t2 on t1.AllotID = t2.ID and t2.HospitalId = @hospitalId and t1.UnitType != 2)t group by year,month,AccountingUnit;";
returnDapperQuery(sql,new{hospitalId}).ToList();
stringwhere="";
if(!string.IsNullOrEmpty(request.Year))
{
where+=$" and t2.year in ({request.Year}) ";
}
if(!string.IsNullOrEmpty(request.Month))
{
where+=$" and t2.month in ({request.Month}) ";
}
stringsql=$"select `Year` y,AccountingUnit x,round(sum(avg),2) value from (select t1.AccountingUnit,t1.Avg,t2.`Year`,t2.`Month`,t2.ID from res_account t1 inner join per_allot t2 on t1.AllotID = t2.ID and t2.HospitalId = @hospitalId and t1.UnitType != 2 where 1=1 {where})t group by year,AccountingUnit;";
if(request.OnlyYear!=1)
sql=$"select concat(year,'-',lpad(month,2,'0')) y,AccountingUnit x,round(sum(avg),2) value from (select t1.AccountingUnit,t1.Avg,t2.`Year`,t2.`Month`,t2.ID from res_account t1 inner join per_allot t2 on t1.AllotID = t2.ID and t2.HospitalId = @hospitalId and t1.UnitType != 2 where 1=1 {where})t group by year,month,AccountingUnit;";
stringsql=$"select `Year` y,AccountingUnit x,round(sum(avg),2) value from (select t1.AccountingUnit,t1.Avg,t2.`Year`,t2.`Month`,t2.ID from res_account t1 inner join per_allot t2 on t1.AllotID = t2.ID and t2.HospitalId = @hospitalId and t1.UnitType = 2)t group by year,AccountingUnit;";
if(isOnlyYear!=1)
sql=$"select concat(year,'-',lpad(month,2,'0')) y,AccountingUnit x,round(sum(avg),2) value from (select t1.AccountingUnit,t1.Avg,t2.`Year`,t2.`Month`,t2.ID from res_account t1 inner join per_allot t2 on t1.AllotID = t2.ID and t2.HospitalId = @hospitalId and t1.UnitType = 2)t group by year,month,AccountingUnit;";
returnDapperQuery(sql,new{hospitalId}).ToList();
stringwhere="";
if(!string.IsNullOrEmpty(request.Year))
{
where+=$" and t2.year in ({request.Year}) ";
}
if(!string.IsNullOrEmpty(request.Month))
{
where+=$" and t2.month in ({request.Month}) ";
}
stringsql=$"select `Year` y,AccountingUnit x,round(sum(avg),2) value from (select t1.AccountingUnit,t1.Avg,t2.`Year`,t2.`Month`,t2.ID from res_account t1 inner join per_allot t2 on t1.AllotID = t2.ID and t2.HospitalId = @hospitalId and t1.UnitType = 2 where 1=1 {where})t group by year,AccountingUnit;";
if(request.OnlyYear!=1)
sql=$"select concat(year,'-',lpad(month,2,'0')) y,AccountingUnit x,round(sum(avg),2) value from (select t1.AccountingUnit,t1.Avg,t2.`Year`,t2.`Month`,t2.ID from res_account t1 inner join per_allot t2 on t1.AllotID = t2.ID and t2.HospitalId = @hospitalId and t1.UnitType = 2 where 1=1 {where})t group by year,month,AccountingUnit;";