科室报表数据统计SQL修改

parent c2c1a74f
......@@ -182,15 +182,12 @@ public IEnumerable<report_original_workload> QueryWorkloadData(int allotid, stri
string unittype = unittypes.Any(t => !string.IsNullOrEmpty(t) && t.Contains("医生"))
? "医生组"
: unittypes.Any(t => !string.IsNullOrEmpty(t) && t.Contains("护理")) ? "护理组" : "其他组";
string clear = @"SELECT DISTINCT t3.AccountingUnit as Department,ifnull(t1.DoctorName, '未知') DoctorName,t1.PersonnelNumber,t1.Category,SUM(t1.Fee) Fee FROM ex_result t1
JOIN (select distinct AccountingUnit,HISDeptName,unittype from per_dept_dic where HospitalId = @hospitalid) t3 ON t1.Department = t3.HISDeptName
WHERE t1.allotid = @allotid
AND t3.unittype in @unittypes
AND t3.accountingunit = @accountingunit
AND (t1.Source LIKE CONCAT('%',@unittype,'工作量%') OR t1.Source = '通用工作量')
AND T1.IsDelete = 0
GROUP BY ifnull(t1.DoctorName, '未知'),t1.PersonnelNumber,t1.Category
ORDER BY t1.doctorname,t1.Category;";
string clear = @"
SELECT DISTINCT AccountingUnit as Department,if(ifnull(DoctorName,'')='', '未知',DoctorName) DoctorName,PersonnelNumber,Category,SUM(Fee) Fee
FROM view_second_report_workload
WHERE AllotId = @allotid AND UnitType in @unittypes AND AccountingUnit = @accountingunit
GROUP BY AccountingUnit,DoctorName,PersonnelNumber,Category
ORDER BY doctorname,Category;";
return connection.Query<report_original_workload>(clear, new { allotid, accountingunit, unittypes, unittype, hospitalid }, commandTimeout: 60 * 60);
}
catch (Exception ex)
......@@ -211,15 +208,16 @@ public IEnumerable<ex_result> QueryIncomeData(int allotid, string source, string
if (connection.State != ConnectionState.Open) connection.Open();
try
{
string clear = $@"SELECT DISTINCT t3.AccountingUnit as Department,ifnull(t1.DoctorName, '未知') DoctorName,t1.PersonnelNumber,t1.Category,SUM(t1.Fee) Fee FROM ex_result t1
JOIN (select distinct AccountingUnit,HISDeptName,unittype from per_dept_dic where HospitalId = @hospitalid) t3 ON t1.Department = t3.HISDeptName
WHERE t1.allotid = @allotid
AND t3.unittype in @unittype
AND t3.accountingunit = @accountingunit
AND (t1.Source like '%{source}开单%' OR t1.Source like '%{source}就诊%')
AND T1.IsDelete = 0
GROUP BY ifnull(t1.DoctorName, '未知'),t1.PersonnelNumber,t1.Category
ORDER BY t1.doctorname,t1.Category;";
var tableName = (source == "门诊") ? "view_second_report_income_out" : "view_second_report_income_inpat";
string clear = $@"
SELECT DISTINCT AccountingUnit as Department,if(ifnull(DoctorName,'')='', '未知',DoctorName) DoctorName,PersonnelNumber,Category,SUM(Fee) Fee
FROM {tableName}
WHERE AllotId = @allotid AND UnitType in @unittypes AND AccountingUnit = @accountingunit
GROUP BY AccountingUnit,DoctorName,PersonnelNumber,Category
ORDER BY doctorname,Category;";
return connection.Query<ex_result>(clear, new { allotid, accountingunit, unittype, hospitalid }, commandTimeout: 60 * 60);
}
catch (Exception ex)
......
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