
            WITH cte AS (
                    select
                    	CASE WHEN NULL is not null
                            and '5379' is not null
                            and not exists (select Diag_id from v_Diag  where Diag_id = '5379' and left(Diag_Code, 1) = 'Z')
                        THEN
                            DispSurveilType_id ELSE null END as DST_id,
                    	CASE WHEN NULL is not null
                            and '5379' is not null
                            and not exists (select Diag_id from v_Diag  where Diag_id = '5379' and left(Diag_Code, 1) = 'Z')
                        THEN
                            EvnVizitDispDop_IsFirstTime ELSE null END  as IsFirstTime,
                    	CASE WHEN NULL is not null
                            and '5379' is not null
                            and not exists (select Diag_id from v_Diag  where Diag_id = '5379' and left(Diag_Code, 1) = 'Z')
                        THEN
                            EvnVizitDispDop_IsVMP ELSE null END  as IsVMP
                    from v_EvnVizitDispDop
                    where EvnVizitDispDop_id = NULL
                    limit 1
            )

            select EvnVizitDispDop_id as "EvnVizitDispDop_id", Error_Code as "Error_Code", Error_Message as "Error_Msg"
            from dbo.p_EvnVizitDispDop_ins(
                EvnVizitDispDop_id := NULL,
                EvnVizitDispDop_pid := '50101306194044',
                Lpu_id := '878',
                Server_id := 0,
                PersonEvn_id := '50101010733716',
                EvnVizitDispDop_setDT := '2023-07-03 09:54:00.000',
                EvnVizitDispDop_didDT := '2023-07-03 09:54:00.000',
                OrpDispSpec_id := NULL,
                Diag_id := '5379',
                TumorStage_id := NULL,
                EvnVizitDispDop_DeseaseStage := NULL,
                LpuSection_id := '50101000001644',
                MedPersonal_id := '50101000015712',
                MedStaffFact_id := '50101000059867',
                MedStaffFact_sid := NULL,
                DopDispDiagType_id := '1',
                DiagValidityType_id := NULL,
                EvnVizitDispDop_isProf := NULL,
                EvnVizitDispDop_isSomatic := NULL,
                EvnVizitDispDop_isInfect := NULL,
                DopDispInfoConsent_id := '50101031540624',
                EvnVizitDispDop_IsFirstTime := (SELECT IsFirstTime FROM cte),
                EvnVizitDispDop_IsVMP := (SELECT IsVMP FROM cte),
                DispSurveilType_id := (SELECT DST_id FROM cte),
                ElectronicService_id := NULL,
                UslugaComplex_id := '50101000022990',
                pmUser_id := '377285934362');
        
