
            with cte as (
                select
                    case when EvnDirection_IsSigned = 2 then 1 else EvnDirection_IsSigned end as EvnDirection_IsSigned,
                    pmUser_signID,
                    EvnDirection_signDT
                from
                    v_EvnDirection_all
                where
                    EvnDirection_id = NULL
                limit 1
            )

            SELECT
                EvnDirection_id as "EvnDirection_id",
                NULL as "EvnDirection_TalonCode",
                error_code as "Error_Code",
                error_message as "Error_Msg"
            FROM dbo.p_EvnDirection_insToQueue(
                ConsultingForm_id := NULL,
                EvnDirection_id := NULL,
                EvnDirection_pid := '890101028875140',
                Server_id := 13101856,
                PersonEvn_id := '890101013041446',
                EvnDirection_setDT := '2022-05-09',
                DirType_id := '10',
                MedicalCareFormType_id := NULL,
                StudyTarget_id := NULL,
                PayType_id := '299',
                Diag_id := NULL,
                EvnDirection_Num := '1002173',
                EvnDirection_Descr := NULL,
                Lpu_did := '13101856', --куда направлен
                LpuSection_did := '890101000000836',
                LpuSectionProfile_id := '20000828',
                Lpu_id := '13101856', -- кто направил
                LpuSection_id := '890101000000780',
                LpuUnit_did := '890101000000462',
                MedPersonal_id := '890101000000979',
                MedStaffFact_id := '890101000002002',
                MedPersonal_zid := NULL,
                MedPersonal_Code := NULL,
                MedService_id := '890101000000226',
                EvnDirection_desDT := NULL,
                EvnDirection_IsAuto := '2',
                EvnDirection_IsCito := '1',
                EvnStatus_id := 10,
                Post_id := '91',
                Lpu_sid := '13101856',
                Org_sid := NULL,
                Org_oid := NULL,
                PrehospDirect_id := '1',
                TimetableGraf_id := NULL,
                TimetableStac_id := NULL,
                TimetableResource_id := NULL,
                TimetableMedService_id := NULL,
                EvnDirection_IsNeedOper := 1,
                EvnQueue_id := NULL,
                ARMType_id := '3',
                EvnDirection_IsReceive := NULL,
                Resource_id := '890101000000025',
                MedPersonal_did := NULL,
                RemoteConsultCause_id := NULL,
                MedSpec_fid := NULL,
                UslugaComplex_did := '200884',
                FSIDI_id := NULL,
                LpuUnitType_id := NULL,
                EvnDirection_TalonCode := NULL,
                RecMethodType_id := '10',
                ConsultationForm_id := NULL,
                EvnDirection_IsAgreement := NULL,
                RequestConsult_id := NULL,
                
                    MedStaffFact_did := NULL,
                    LpuSectionProfile_did := NULL,
                    MedService_did := '890101000000226',
                    Resource_did := '890101000000025',
                 LpuSectionBedProfile_id := NULL,  EvnDirection_IsBiopsy := NULL, 
                pmUser_id := '372470700064'
            )
        
