select output.* from
(
select result.doctor_name, result.patient_guid, result.patient_name, result.inpatient_department, result.admission_date,
result.discharge_date, "小儿肺炎" as "病种", "" as "诊断分类", "病原学诊断" as "指标名称", "重症肺炎患儿" as "细指标名称",
case
when part1.valid_flag="未完成" then "未完成"
else "完成"
end valid_flag
from yd_patient_11_basic_info as result
left join
(
select uuid, "未完成" as valid_flag from yd_patient_11_basic_info as detail
where detail.uuid not in (select csqc.uuid from cap_statistics_qc_common as csqc where project_name="重症肺炎患儿")
and detail.disease_class_name="小儿肺炎"
) as part1
on result.uuid=part1.uuid
where result.disease_class_name="小儿肺炎"
-- AND { result.discharge_date BETWEEN [ startTime2 ]} AND {[ endTime2 ]}
-- AND { result.inpatient_department = [ inpatient_department ]}
-- AND { result.disease_name = [disease_class_name ]}
-- AND { result.diagnosis_category = [ diagnose_class_name ]}
) as output
where output.valid_flag="完成"
网友评论