
            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 = '140101022819195'
                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_upd(
                ConsultingForm_id := NULL,
                EvnDirection_id := '140101022819195',
                EvnDirection_pid := '140101022819086',
                Server_id := '140101000000001',
                PersonEvn_id := '140101007522926',
                EvnDirection_setDT := '2022-02-14',
                DirType_id := '3',
                MedicalCareFormType_id := NULL,
                StudyTarget_id := NULL,
                PayType_id := NULL,
                Diag_id := '6893',
                EvnDirection_Num := '86708',
                EvnDirection_Descr := NULL,
                Lpu_did := '140101000000014', --куда направлен
                LpuSection_did := '140101000001384',
                LpuSectionProfile_id := '140101000000018',
                Lpu_id := '140101000000014', -- кто направил
                LpuSection_id := '140101000001245',
                LpuUnit_did := '140101000000439',
                MedPersonal_id := '140101000006228',
                MedStaffFact_id := '140101000016626',
                MedPersonal_zid := NULL,
                MedPersonal_Code := NULL,
                MedService_id := NULL,
                EvnDirection_desDT := NULL,
                EvnDirection_IsAuto := '1',
                EvnDirection_IsCito := '1',
                EvnStatus_id := '17',
                Post_id := '74',
                Lpu_sid := '140101000000014',
                Org_sid := NULL,
                Org_oid := NULL,
                PrehospDirect_id := '1',
                TimetableGraf_id := '140101003721631',
                TimetableStac_id := NULL,
                TimetableResource_id := NULL,
                TimetableMedService_id := NULL,
                EvnDirection_IsNeedOper := 2,
                EvnQueue_id := NULL,
                ARMType_id := '1047',
                EvnDirection_IsReceive := '1',
                Resource_id := NULL,
                MedPersonal_did := '140101000015909',
                RemoteConsultCause_id := NULL,
                MedSpec_fid := NULL,
                UslugaComplex_did := NULL,
                FSIDI_id := NULL,
                LpuUnitType_id := NULL,
                EvnDirection_TalonCode := NULL,
                RecMethodType_id := 10,
                ConsultationForm_id := NULL,
                EvnDirection_IsAgreement := NULL,
                RequestConsult_id := NULL,
                
                EvnDirection_IsSigned => (SELECT EvnDirection_IsSigned FROM cte),
                pmUser_signID => (SELECT pmUser_signID FROM cte),
                EvnDirection_signDT => (SELECT EvnDirection_signDT FROM cte),
             LpuSectionBedProfile_id := NULL,  EvnDirection_IsBiopsy := NULL, 
                pmUser_id := '392064408996'
            )
        
