
             WITH cte AS (
                SELECT
                    cast('400101227661256' as bigint) AS res,
                    CASE WHEN NULL IS NOT NULL THEN NULL ELSE (SELECT morbus_id FROM v_EvnVizitPL WHERE EvnVizitPL_id = '400101227661130' 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_upd(
            	EvnUslugaCommon_id := (select res from cte),
                EvnUslugaCommon_pid := '400101227661130',
                EvnUslugaCommon_IsSigned := NULL,
                Lpu_id := '1806021',
                Server_id := 0,
                PersonEvn_id := '400101025181317',
                EvnUslugaCommon_setDT := '2023-07-31 12:28',
                EvnUslugaCommon_disDT := '2023-07-31 12:28',
                PayType_id := '161',
                Usluga_id := NULL,
                UslugaComplex_id := '400101000023719',
                MedSpecOms_id := NULL,
                LpuSectionProfile_id := '20001803',
                MedPersonal_id := '400101000020067',
                MedStaffFact_id := '400101000082942',
                MedStaffFact_sid := NULL,
                UslugaPlace_id := '1',
                Lpu_uid := NULL,
                LpuSection_uid := '400101000011653',
                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 := 2,
                EvnDirection_id := NULL,
                UslugaExecutionType_id := NULL,
                UslugaExecutionReason_id := NULL,
                pmUser_id := '422980356103');
        
