
            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 := '520101213093214',
                Lpu_id := '2785',
                Server_id := 2785,
                PersonEvn_id := '520101055265093',
                EvnVizitDispDop_setDT := '2022-04-01 06:55:00.000',
                EvnVizitDispDop_didDT := '2022-04-01 06:55:00.000',
                Diag_id := '5379',
                TumorStage_id := NULL,
                EvnVizitDispDop_DeseaseStage := NULL,
                LpuSection_id := '520101000001377',
                MedPersonal_id := '520101000034133',
                MedStaffFact_id := '520101000082707',
                MedStaffFact_sid := NULL,
                DopDispDiagType_id := '1',
                DopDispInfoConsent_id := '520101018248049',
                EvnVizitDispDop_IsFirstTime := (SELECT IsFirstTime FROM cte),
                EvnVizitDispDop_IsVMP := (SELECT IsVMP FROM cte),
                DispSurveilType_id := (SELECT DST_id FROM cte),
                ElectronicService_id := NULL,
                UslugaComplex_id := '520101000001016',
                pmUser_id := '403972090992');
        
