
             WITH cte AS (
                SELECT
                    cast(NULL as bigint) AS res,
                    CASE WHEN NULL IS NOT NULL THEN NULL ELSE (SELECT morbus_id FROM v_evn WHERE evn_id = '450101259600202' LIMIT 1) END AS morbus_id
            )
            select
            	EvnUslugaCommon_id as "EvnUslugaCommon_id",
                Error_Code as "Error_Code",
                Error_Message as "Error_Msg"
            from dbo.p_EvnUslugaCommon_ins(
            	EvnUslugaCommon_id := (select res from cte),
                EvnUslugaCommon_pid := '450101259600202',
                Lpu_id := '1143538',
                Server_id := 0,
                PersonEvn_id := '450101010059871',
                EvnUslugaCommon_setDT := '2022-03-23 14:04',
                EvnUslugaCommon_disDT := '2022-03-23 14:04',
                PayType_id := '450101000000005',
                Usluga_id := NULL,
                UslugaComplex_id := '206896',
                MedSpecOms_id := NULL,
                LpuSectionProfile_id := '20001411',
                MedPersonal_id := '450101000024588',
                MedStaffFact_id := '450101000102724',
                MedStaffFact_sid := NULL,
                UslugaPlace_id := '1',
                Lpu_uid := NULL,
                LpuSection_uid := '450101000004792',
                Org_uid := NULL,
                EvnUslugaCommon_Kolvo := 1,
                Morbus_id := (select morbus_id from cte),
                EvnUslugaCommon_CoeffTariff := NULL,
                EvnUslugaCommon_IsModern := NULL,
                MesOperType_id := NULL,
                UslugaComplexTariff_id := NULL,
                DiagSetClass_id := NULL,
                Diag_id := NULL,
                EvnUslugaCommon_Price := NULL,
                EvnUslugaCommon_Summa := NULL,
                EvnPrescr_id := NULL,
                EvnUslugaCommon_IsVizitCode := NULL,
                EvnUslugaCommon_IsMinusUsluga := 1,
                EvnDirection_id := NULL,
                UslugaExecutionType_id := NULL,
                UslugaExecutionReason_id := NULL,
                pmUser_id := '375275068737');
        
