2019-08-14: 插入完成实验室检查的患儿信息到中间表

insert ETL_0730_ZY_WXS.`cap_statistics_qc_common`(
    uuid,
  patient_guid,
  patient_name,
  patient_gender,
  patient_age,
  patient_age_type,
  
    inpatient_department,   
    doctor_name,
    admission_time,
    discharge_time,
    project_id,
    project_name,
    project_status
)
-- 获取满足实验室检查(ESR/CRP/PCT)的患儿信息                   
select *
from
(
select detail.uuid, detail.patient_guid, detail.patient_name, detail.patient_gender, detail.patient_age, detail.patient_age_type,
       detail.inpatient_department, detail.doctor_name, detail.admission_date, detail.discharge_date, NULL, 
             "实验室检查(ESR/CRP/PCT)" as project_name, 1 as project_status
from yd_patient_11_basic_info as detail
where detail.uuid in (select CONCAT(customer_id, "-", record_id) as uuid from pt_patient_test_advice where test_name like "%血沉%")
and detail.uuid in (select CONCAT(customer_id, "-", record_id) as uuid from pt_patient_test_advice where test_name like "%降钙素原%")
and detail.uuid in (select CONCAT(customer_id, "-", record_id) as uuid from pt_patient_test_advice where test_name like "%超敏C反应蛋白%")
) as part1
union
(
select detail.uuid, detail.patient_guid, detail.patient_name, detail.patient_gender, detail.patient_age, detail.patient_age_type,
       detail.inpatient_department, detail.doctor_name, detail.admission_date, detail.discharge_date, NULL, 
             "实验室检查(ESR/CRP/PCT)" as project_name, 1 as project_status
from yd_patient_11_basic_info as detail
where detail.uuid in (select uuid from cap_statistics_qc_common where project_name="ESR检测")
and detail.uuid in (select uuid from cap_statistics_qc_common where project_name="CRP检测")
and detail.uuid in (select uuid from cap_statistics_qc_common where project_name="PCT检测")
)

你可能感兴趣的:(2019-08-14: 插入完成实验室检查的患儿信息到中间表)