DELETE p
-- SELECT p.*
FROM VCLib.T_OBJECT_MODIFICATION_ACTION_PARAM p
JOIN VCLib.T_OBJECT_MODIFICATION_ACTION a ON p.ObjectModificationAction = a.ObjectModificationActionID
WHERE
    a.Name = 'sp_GetSetNosologyList'
GO

DELETE d
-- SELECT
--     d.*
FROM VCLib.T_DEPENDENCY_MODIFICATION_ACTION d
JOIN VCLib.T_OBJECT_MODIFICATION_ACTION a ON a.ObjectModificationActionID = d.ObjectModificationActionID
WHERE
    a.Name = 'sp_GetSetNosologyList'
GO

DELETE s
-- select s.*
FROM vclib.T_SINGLE_MODIFICATION_ACTION s
JOIN VCLib.T_OBJECT_MODIFICATION_ACTION a ON a.ObjectModificationActionID = s.ObjectModificationActionID
WHERE
    a.Name = 'sp_GetSetNosologyList'
GO

DELETE a
FROM VCLib.T_OBJECT_MODIFICATION_ACTION A
WHERE
    A.Name = 'sp_GetSetNosologyList'
GO

INSERT INTO
    VCLib.T_OBJECT_MODIFICATION_ACTION (ObjectModificationActionID,
                                        Entities,
                                        Position,
                                        type_,
                                        Active,
                                        Name,
                                        Instruction,
                                        InstructionType)
VALUES
    ('1E94CDEB-A8C8-4371-AB4F-12BC401ED74C',
     (SELECT TOP 1 EntityID FROM VCLib.T_ENTITIES WHERE EntName = 'NOSOLOGY'),
     1,
     (SELECT TOP 1 EntityID FROM VCLib.T_ENTITIES WHERE EntName = 'DEPENDENCY_MODIFICATION_ACTION'),
     1,
     'sp_GetSetNosologyList',
     'sp_GetSetNosologyList',
     0),
    ('CE34CC0F-1226-4122-B55B-9335237559C2',
     (SELECT TOP 1 EntityID FROM VCLib.T_ENTITIES WHERE EntName = 'NOSOLOGY'),
     1,
     (SELECT TOP 1 EntityID FROM VCLib.T_ENTITIES WHERE EntName = 'SINGLE_MODIFICATION_ACTION'),
     1,
     'sp_GetSetNosologyList',
     'sp_GetSetNosologyList',
     0)
GO

INSERT INTO
    VCLib.T_DEPENDENCY_MODIFICATION_ACTION (ObjectModificationActionID, Dependencies)
VALUES
    (N'1E94CDEB-A8C8-4371-AB4F-12BC401ED74C', N'{NosologyBenefitss}')
GO

INSERT INTO
    VCLib.T_SINGLE_MODIFICATION_ACTION (ObjectModificationActionID, InsertFilter, UpdateFilter, DeleteFilter, EditType)
VALUES
    (N'CE34CC0F-1226-4122-B55B-9335237559C2', NULL, N'<lx:Criteria type="And" xmlns:lx="lexem">
    <lx:CriterionChildExists>
        <condition />
        <lx:Path OwnerQueryLevel="0">
            <lx:StepString name="NosologyBenefitss" />
        </lx:Path>
    </lx:CriterionChildExists>
    <lx:CriterionChildExists not="1">
        <condition>
            <lx:Criterion type="=">
                <lx:Path OwnerQueryLevel="0">
                    <lx:StepString name="ObjectProperties" />
                    <lx:StepString name="Modified" />
                </lx:Path>
                <lx:ConstOperand type="Boolean">True</lx:ConstOperand>
            </lx:Criterion>
        </condition>
        <lx:Path OwnerQueryLevel="0">
            <lx:StepString name="NosologyBenefitss" />
        </lx:Path>
    </lx:CriterionChildExists>
</lx:Criteria>', NULL, 4)
GO

INSERT INTO
    VCLib.T_OBJECT_MODIFICATION_ACTION_PARAM (ObjectModificationActionParamID,
                                              ObjectModificationAction,
                                              ParamValue,
                                              Name)
VALUES
    (N'DBFD3513-331C-496C-AB53-025D3AAB53CA', N'1E94CDEB-A8C8-4371-AB4F-12BC401ED74C', N'<lx:Path OwnerQueryLevel="0" xmlns:lx="lexem">
    <lx:StepString name="FatherName" />
</lx:Path>', N'FatherName'),
    (N'A5E79579-6B58-450F-9BDC-3D47D72B5846', N'1E94CDEB-A8C8-4371-AB4F-12BC401ED74C', N'<lx:Path OwnerQueryLevel="0" xmlns:lx="lexem">
    <lx:StepString name="ObjectProperties" />
    <lx:StepString name="IsNew" />
</lx:Path>', N'IsNew'),
    (N'DA02D37C-C3E4-46AE-91C2-7F32997653BE', N'1E94CDEB-A8C8-4371-AB4F-12BC401ED74C', N'<lx:Path OwnerQueryLevel="0" xmlns:lx="lexem">
    <lx:StepString name="SNILS" />
</lx:Path>', N'SNILS'),
    (N'F9748750-4A8B-42A6-82C6-B2CF5F7CF772', N'1E94CDEB-A8C8-4371-AB4F-12BC401ED74C', N'<lx:Path OwnerQueryLevel="0" xmlns:lx="lexem">
    <lx:StepString name="LastName" />
</lx:Path>', N'LastName'),
    (N'2555C5AF-94BC-43F6-B382-C57CB033B4EE', N'1E94CDEB-A8C8-4371-AB4F-12BC401ED74C', N'<lx:Path OwnerQueryLevel="0" xmlns:lx="lexem">
    <lx:StepString name="PAC_ID" />
</lx:Path>', N'PacId'),
    (N'514F3E9C-6764-4064-B17D-CA7CC2904A31', N'1E94CDEB-A8C8-4371-AB4F-12BC401ED74C', N'<lx:Path OwnerQueryLevel="0" xmlns:lx="lexem">
    <lx:StepString name="NosologyID" />
</lx:Path>', N'ID'),
    (N'B27C7208-4DC2-460C-A79A-EC7D14378909', N'1E94CDEB-A8C8-4371-AB4F-12BC401ED74C', N'<lx:Path OwnerQueryLevel="0" xmlns:lx="lexem">
    <lx:StepString name="DocSeries" />
</lx:Path>', N'DocSeries'),
    (N'56E11174-FA77-493C-9E4F-F8B6FF8DCAFD', N'1E94CDEB-A8C8-4371-AB4F-12BC401ED74C', N'<lx:Path OwnerQueryLevel="0" xmlns:lx="lexem">
    <lx:StepString name="FirstName" />
</lx:Path>', N'FirstName'),
    (N'47EC6104-4C77-481C-9EFF-FA7658ECC4F4', N'1E94CDEB-A8C8-4371-AB4F-12BC401ED74C', N'<lx:Path OwnerQueryLevel="0" xmlns:lx="lexem">
    <lx:StepString name="DocNumber" />
</lx:Path>', N'DocNumber'),
    (N'BE6D8900-3311-43B1-A6C5-FF01D4BD06DA', N'1E94CDEB-A8C8-4371-AB4F-12BC401ED74C', N'<lx:Path OwnerQueryLevel="0" xmlns:lx="lexem">
    <lx:StepString name="Birthday" />
</lx:Path>', N'Birthday'),
    (N'760192DC-9066-47D2-9BAB-3042DB510067', N'CE34CC0F-1226-4122-B55B-9335237559C2', N'<lx:Path OwnerQueryLevel="0" xmlns:lx="lexem">
    <lx:StepString name="LastName" />
</lx:Path>', N'LastName'),
    (N'029671C8-709B-41B4-931B-32253F1A6F1A', N'CE34CC0F-1226-4122-B55B-9335237559C2', N'<lx:Path OwnerQueryLevel="0" xmlns:lx="lexem">
    <lx:StepString name="FatherName" />
</lx:Path>', N'FatherName'),
    (N'DD286FE1-50E0-4916-8DAF-7DD34DD2956F', N'CE34CC0F-1226-4122-B55B-9335237559C2', N'<lx:Path OwnerQueryLevel="0" xmlns:lx="lexem">
    <lx:StepString name="DocNumber" />
</lx:Path>', N'DocNumber'),
    (N'6F7D396D-F74A-4252-9E3B-8B1141F77E0D', N'CE34CC0F-1226-4122-B55B-9335237559C2', N'<lx:Path OwnerQueryLevel="0" xmlns:lx="lexem">
    <lx:StepString name="FirstName" />
</lx:Path>', N'FirstName'),
    (N'5C515720-EA45-4254-8059-8DA1BE55CEB2', N'CE34CC0F-1226-4122-B55B-9335237559C2', N'<lx:Path OwnerQueryLevel="0" xmlns:lx="lexem">
    <lx:StepString name="DocSeries" />
</lx:Path>', N'DocSeries'),
    (N'6951C779-8659-434F-A5D1-B5E883E96494', N'CE34CC0F-1226-4122-B55B-9335237559C2', N'<lx:Path OwnerQueryLevel="0" xmlns:lx="lexem">
    <lx:StepString name="NosologyID" />
</lx:Path>', N'ID'),
    (N'EEB076F7-0F83-4E42-AE4C-BDEBDBFFF4E0', N'CE34CC0F-1226-4122-B55B-9335237559C2', N'<lx:Path OwnerQueryLevel="0" xmlns:lx="lexem">
    <lx:StepString name="PAC_ID" />
</lx:Path>', N'PacId'),
    (N'9A61669A-BDDB-4F5B-97E7-C10DD92F2464', N'CE34CC0F-1226-4122-B55B-9335237559C2', N'<lx:Path OwnerQueryLevel="0" xmlns:lx="lexem">
    <lx:StepString name="ObjectProperties" />
    <lx:StepString name="IsNew" />
</lx:Path>', N'IsNew'),
    (N'A779EBBF-665A-462A-A2D7-EC4F909B9AA1', N'CE34CC0F-1226-4122-B55B-9335237559C2', N'<lx:Path OwnerQueryLevel="0" xmlns:lx="lexem">
    <lx:StepString name="SNILS" />
</lx:Path>', N'SNILS'),
    (N'2446388A-7582-4900-A953-FD387DABA1D0', N'CE34CC0F-1226-4122-B55B-9335237559C2', N'<lx:Path OwnerQueryLevel="0" xmlns:lx="lexem">
    <lx:StepString name="Birthday" />
</lx:Path>', N'Birthday')
GO