create or replace as select a.pid HZID00,--患者id a.ipid ZYLSH0,--住院流水号 a.order_sn WBYZID,--外部医嘱ID a.parent_order_sn WBZID0,--外部主ID a.MENSTRUAL_CYCLE_CODE SLZQDM,--生理周期代码 a.Menstrual_Cycle SLZQMC,--生理周期名称 a.parent_order_sn SQDH00,--申请单号 'i' MZZYBS--门诊住院标识 from inpord.lab_order a where a.menstrual_cycle is not null and a.menstrual_cycle_code is not null union all select b.pid HZID00,--患者id b.REGISTER_SN ZYLSH0,--门诊挂号号 b.order_sn WBYZID,--外部医嘱ID b.parent_order_sn WBZID0,--外部主ID b.SL_PERIOD SLZQDM,--生理周期代码 '' SLZQMC,--生理周期名称 b.parent_order_sn SQDH00,--申请单号 'o' MZZYBS--门诊住院标识 from OUTPORD.OUTP_LAB_ORDER b where b.SL_PERIOD is not null;