delete ea
from VCLib.T_ENTITIES_ATTRIBUTES ea
	join VCLib.T_ENTITIES e on e.EntityID = ea.EntityID
where ea.Name = 'TFOMSBranch'
		and
	e.EntName = 'MO'



IF NOT EXISTS(SELECT * FROM VCLib.T_ENTITIES WHERE [Schema]='FIES' and EntName='MO')
BEGIN
	INSERT INTO VCLib.T_ENTITIES (EntityID, EntName, XML, ServerName, NeedHistory, [Schema])
	VALUES ((isnull((select top 1 EntityID from VCLib.T_ENTITIES order by EntityID desc), 0) + 1),'MO',NULL,'Primary SQL Server', 0, 'FIES')
	UPDATE dbo.T_ENTITY_IDS SET id = ISNULL((select MAX(e.EntityID) from VCLib.T_ENTITIES e), 0) + 1 WHERE EntName = 'VCLib.ENTITIES' AND FieldName = 'PrimaryKey'
END
GO

UPDATE VCLib.T_ENTITIES
SET XML='<?xml version="1.0" encoding="utf-8" standalone="yes"?><Entity Schema="FIES" Name="MO" Description="Медицинская организация" PrimaryKey="MCOD" DNAttributes="{NAM_MFF}" DisplayName="{0}"><Customs><Custom Name="FilterUICondition"><![CDATA[<lx:Criterion type="=" xmlns:lx="lexem">
    <lx:Path OwnerQueryLevel="0">
      <lx:StepInt index="6940033" />
    </lx:Path>
    <lx:ConstOperand type="Boolean">True</lx:ConstOperand>
  </lx:Criterion>]]></Custom></Customs><Fields><Attribute Name="TF_OKATO" Index="6940002" Type="string" Description="Код субъекта РФ по ОКАТО" CharacterMaximumLength="5"></Attribute><Attribute Name="MCOD" Index="6940003" Type="string" Description="Код МО" CharacterMaximumLength="6" Required="1"></Attribute><Attribute Name="NAM_MOP" Index="6940004" Type="string" Description="Наименование МО полное" CharacterMaximumLength="250" Required="1"></Attribute><Attribute Name="INN" Index="6940006" Type="string" Description="ИНН" CharacterMaximumLength="12"></Attribute><Attribute Name="OGRN" Index="6940007" Type="string" Description="ОГРН" CharacterMaximumLength="15"></Attribute><Attribute Name="KPP" Index="6940008" Type="string" Description="КПП" CharacterMaximumLength="9"></Attribute><Attribute Name="INDEX_J" Index="6940009" Type="string" Description="Почтовый индекс юридического адреса МО" CharacterMaximumLength="6"></Attribute><Attribute Name="ADDR_J" Index="6940010" Type="string" Description="Юридический адрес МО" CharacterMaximumLength="254"></Attribute><Attribute Name="FAM_RUK" Index="6940014" Type="string" Description="Фамилия руководителя" CharacterMaximumLength="40"></Attribute><Attribute Name="IM_RUK" Index="6940015" Type="string" Description="Имя руководителя" CharacterMaximumLength="40"></Attribute><Attribute Name="OT_RUK" Index="6940016" Type="string" Description="Отчество руководителя" CharacterMaximumLength="40"></Attribute><Attribute Name="PHONE" Index="6940017" Type="string" Description="Телефон" CharacterMaximumLength="40"></Attribute><Attribute Name="FAX" Index="6940018" Type="string" Description="Факс" CharacterMaximumLength="40"></Attribute><Attribute Name="E_MAIL" Index="6940019" Type="string" Description="Адрес электронной почты" CharacterMaximumLength="50"></Attribute><Attribute Name="MP" Index="6940023" Type="string" Description="Виды медицинской помощи" CharacterMaximumLength="15"></Attribute><Attribute Name="WWW" Index="6940024" Type="string" Description="Адрес сайта в сети интернет" CharacterMaximumLength="100"></Attribute><Attribute Name="D_BEGIN" Index="6940025" Type="date" Description="Дата включения в реестр МО"></Attribute><Attribute Name="D_END" Index="6940026" Type="date" Description="Дата исключения из реестра МО"></Attribute><Attribute Name="NAME_E" Index="6940027" Type="string" Description="Причина исключения МО из реестра МО" CharacterMaximumLength="10"></Attribute><Attribute Name="DUVED" Index="6940028" Type="date" Description="Дата уведомления об осуществлении деятельности в сфере ОМС"></Attribute><Attribute Name="D_EDIT" Index="6940029" Type="date" Description="Дата последнего редактирования"></Attribute><Attribute Name="IsActive" Index="6940033" Type="bool" Description="Активное" Required="1"></Attribute><Attribute Name="ShortFIODative" Index="6940038" Type="string" Description="ФИО в дательном падеже кратко" CharacterMaximumLength="50"></Attribute><Attribute Name="MO_NUMBER" Index="6940041" Type="string" Description="Номер МО" CharacterMaximumLength="40"></Attribute><Attribute Name="NAM_MOK" Index="6940042" Type="string" Description="Наименование МО краткое" CharacterMaximumLength="250" Required="1"></Attribute><Attribute Name="IsFondHolder" Index="6940044" Type="bool" Description="Признак фондодержания"></Attribute><Attribute Name="IsUsingDigitalSignature" Index="6940046" Type="bool" Description="Признак использования ЭЦП"></Attribute><Attribute Name="NAM_MFF" Index="6970037" Type="string" Description="Наименование МО в свободной форме" CharacterMaximumLength="250" Required="1"></Attribute><Parent Name="OKOPF" Index="6940011" Type="FIES.O005_OKOPF" Description="ОКОПФ"></Parent><Parent Name="VEDPRI" Index="6940012" Type="FIES.F007_DEPARTMENT" Description="Ведомственная принадлежность МО"></Parent><Parent Name="MoType" Index="6940031" Type="FIES.MO_TYPE" Description="Тип МО"></Parent><Parent Name="Rajonrt" Index="6940037" Type="FIES.RAJONRT" Description="Район региона"></Parent><Child Name="MoLicenses" Index="6940047" Type="FIES.MO_LICENSE" Description="Лицензия МО" ChildAttribute="Mo"></Child><Child Name="Coefficients" Index="6940048" Type="FIES.COEFFICIENT" Description="Коэффициенты" ChildAttribute="Mo"></Child><Child Name="SmoCoefMonthValuesDefaults" Index="6940049" Type="FIES.SMO_COEF_MONTH_VALUES_DEFAULT" Description="Стандартные значения коэффициентов планов по СМО для МО" ChildAttribute="Mo" SortingAttr="Smo"></Child><Child Name="SmoCoefMonthValuesExceptions" Index="6970038" Type="FIES.SMO_COEF_MONTH_VALUES_EXCEPTION" Description="Исключения коэффициентов планов по СМО для МО" ChildAttribute="Mo"></Child><Choice Name="ORG" Index="6940013" Description="Признак подчиненности" Required="1"><Item Name="Головная организация" Index="1"></Item><Item Name="Филиал" Index="2"></Item></Choice><Child Name="PlanPeriodMoLinks" Index="6940005" Type="FIES.PLAN_PERIOD_MO_LINK" Description="Cвязка с отчетным периодом" ChildAttribute="Mo"></Child><Choice Name="MoOwnershipType" Index="6940020" Description="Форма собственности" Required="1"><Item Name="Региональное" Index="0"></Item><Item Name="Федеральное" Index="1"></Item><Item Name="Другое" Index="2"></Item></Choice><Child Name="MoDepartments" Index="6970041" Type="FIES.MO_DEPARTMENT" Description="Отделения" ChildAttribute="Mo"></Child><Attribute Name="KDsp" Index="6970042" Type="float" Description="Коэффициент содержания структурных подразделений" NumericPrecision="12" NumericScale="9"></Attribute><Attribute Name="KDpn" Index="6970043" Type="float" Description="Коэффициент плотности населения" NumericPrecision="12" NumericScale="9"></Attribute><Attribute Name="KDsi" Index="6970044" Type="float" Description="Коэффициент на содержание имущества МО" NumericPrecision="12" NumericScale="9"></Attribute><Attribute Name="KDzp" Index="6970045" Type="float" Description="коэффициент уровня заработной платы" NumericPrecision="12" NumericScale="9"></Attribute><Attribute Name="KDsub" Index="6970046" Type="float" Description="Районный коэффициент к заработной плате" NumericPrecision="12" NumericScale="9"></Attribute><Child Name="MoTypeHistorys" Type="FIES.MO_TYPE_HISTORY" Description="История уровней МО" ChildAttribute="Mo"></Child><Child Name="BankAccounts" Type="FIES.BANK_ACCOUNT" Description="Банковские счета" ChildAttribute="Mo"></Child><Link Name="TfomsBranchMo" Type="FIES.TFOMS_BRANCH_MO" Description="Связь филиала ТФОМС с МО" LinkAttribute="Mo"></Link><Parent Name="TFOMSBranch" Type="FIES.TFOMS_BRANCH" Description="Филиал ТФОМС"></Parent></Fields><DbMapping><Table name="T_MO"><Map Name="TF_OKATO" Column="TF_OKATO"></Map><Map Name="MCOD" Column="MCOD"></Map><Map Name="NAM_MOP" Column="NAM_MOP"></Map><Map Name="INN" Column="INN"></Map><Map Name="OGRN" Column="OGRN"></Map><Map Name="KPP" Column="KPP"></Map><Map Name="INDEX_J" Column="INDEX_J"></Map><Map Name="ADDR_J" Column="ADDR_J"></Map><Map Name="FAM_RUK" Column="FAM_RUK"></Map><Map Name="IM_RUK" Column="IM_RUK"></Map><Map Name="OT_RUK" Column="OT_RUK"></Map><Map Name="PHONE" Column="PHONE"></Map><Map Name="FAX" Column="FAX"></Map><Map Name="E_MAIL" Column="E_MAIL"></Map><Map Name="MP" Column="MP"></Map><Map Name="WWW" Column="WWW"></Map><Map Name="D_BEGIN" Column="D_BEGIN"></Map><Map Name="D_END" Column="D_END"></Map><Map Name="NAME_E" Column="NAME_E"></Map><Map Name="DUVED" Column="DUVED"></Map><Map Name="D_EDIT" Column="D_EDIT"></Map><Map Name="IsActive" Column="IsActive"></Map><Map Name="ShortFIODative" Column="ShortFIODative"></Map><Map Name="MO_NUMBER" Column="MO_NUMBER"></Map><Map Name="NAM_MOK" Column="NAM_MOK"></Map><Map Name="IsFondHolder" Column="IsFondHolder"></Map><Map Name="IsUsingDigitalSignature" Column="IsUsingDigitalSignature"></Map><Map Name="NAM_MFF" Column="NAM_MFF"></Map><Map Name="OKOPF" Column="OKOPF"></Map><Map Name="VEDPRI" Column="VEDPRI"></Map><Map Name="Rajonrt" Column="Rajonrt"></Map><Map Name="ORG" Column="ORG"></Map><Map Name="MoOwnershipType" Column="MoOwnershipType"></Map><Map Name="KDsp" Column="KDsp"></Map><Map Name="KDpn" Column="KDpn"></Map><Map Name="KDsi" Column="KDsi"></Map><Map Name="KDzp" Column="KDzp"></Map><Map Name="KDsub" Column="KDsub"></Map></Table><Lexem><Map Name="MoType" PathAttributes="{MoTypeHistorys / MoType}"><lx:ChildCount xmlns:lx="lexem"><condition><lx:Criterion type="&lt;=" xmlns:lx="lexem"><lx:Path OwnerQueryLevel="0" xmlns:lx="lexem"><lx:StepString name="DateBegin" xmlns:lx="lexem"></lx:StepString></lx:Path><lx:ParamHolder xmlns:lx="lexem"><lx:StepString name="CURRENT_DATETIME" xmlns:lx="lexem"></lx:StepString></lx:ParamHolder></lx:Criterion></condition><lx:Path OwnerQueryLevel="0" xmlns:lx="lexem"><lx:StepString name="MoTypeHistorys" xmlns:lx="lexem"></lx:StepString></lx:Path><lx:First xmlns:lx="lexem"><lx:Path OwnerQueryLevel="0" xmlns:lx="lexem"><lx:StepString name="MoType" xmlns:lx="lexem"></lx:StepString></lx:Path></lx:First><lx:Path OwnerQueryLevel="0" xmlns:lx="lexem"><lx:StepString name="DateBegin" xmlns:lx="lexem"></lx:StepString></lx:Path><lx:ConstOperand type="String" xmlns:lx="lexem"><![CDATA[desc]]></lx:ConstOperand></lx:ChildCount></Map><Map Name="TFOMSBranch" PathAttributes="{TfomsBranchMo/TfomsBranch}"><lx:Path OwnerQueryLevel="0" xmlns:lx="lexem"><lx:StepString name="TfomsBranchMo" xmlns:lx="lexem"></lx:StepString><lx:StepString name="TfomsBranch" xmlns:lx="lexem"></lx:StepString></lx:Path></Map></Lexem></DbMapping></Entity>',
EntDesc = 'Медицинская организация',
PrimaryKeyName = 'MCOD',
[Version] = 0,
BaseEntityName = NULL,
BaseEntity = NULL,
DisplayName = '{0}',
DNAttributes = '{NAM_MFF}',
IsTree = 0,
UnrestrictedAccess = 0,
Customs = '<?xml version="1.0" encoding="utf-16"?><Customs xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><Custom Name="FilterUICondition"><![CDATA[<lx:Criterion type="=" xmlns:lx="lexem">
    <lx:Path OwnerQueryLevel="0">
      <lx:StepInt index="6940033" />
    </lx:Path>
    <lx:ConstOperand type="Boolean">True</lx:ConstOperand>
  </lx:Criterion>]]></Custom></Customs>',
Sortings = NULL,
CanGroupInTreeListBy = NULL
WHERE [Schema]='FIES' and EntName='MO'
GO

DECLARE @EntId int
SET @EntId = (SELECT TOP 1 EntityId FROM VCLib.T_ENTITIES WHERE [Schema]='FIES' and EntName='MO')

UPDATE VCLib.T_ENTITIES SET BaseEntity = @EntId WHERE BaseEntityName = 'FIES.MO'

DELETE FROM VCLib.T_ENTITIES_ATTRIBUTES WHERE IsAdditional = 0 AND EntityId = @EntId AND Name NOT IN ('TF_OKATO', 'MCOD', 'NAM_MOP', 'INN', 'OGRN', 'KPP', 'INDEX_J', 'ADDR_J', 'FAM_RUK', 'IM_RUK', 'OT_RUK', 'PHONE', 'FAX', 'E_MAIL', 'MP', 'WWW', 'D_BEGIN', 'D_END', 'NAME_E', 'DUVED', 'D_EDIT', 'IsActive', 'ShortFIODative', 'MO_NUMBER', 'NAM_MOK', 'IsFondHolder', 'IsUsingDigitalSignature', 'NAM_MFF', 'OKOPF', 'VEDPRI', 'MoType', 'Rajonrt', 'MoLicenses', 'Coefficients', 'SmoCoefMonthValuesDefaults', 'SmoCoefMonthValuesExceptions', 'ORG', 'PlanPeriodMoLinks', 'MoOwnershipType', 'MoDepartments', 'KDsp', 'KDpn', 'KDsi', 'KDzp', 'KDsub', 'MoTypeHistorys', 'BankAccounts', 'TfomsBranchMo', 'TFOMSBranch')

UPDATE VCLib.T_ENTITIES_ATTRIBUTES SET [Index] = 6940002, [AttributeType] = 0, [Name] = 'TF_OKATO', [Description] = 'Код субъекта РФ по ОКАТО', [SystemType] = 'string', [MaxLength] = 5, [Precision] = NULL, [Scale] = NULL, [DefaultFormat] = NULL, [IsCalculated] = 0, [IsFlag] = 0, [IsRequired] = 0, [Save] = 1, [LinkAttributeName] = NULL, [PathsAttributes] = NULL, [IsCashed] = 0, [RequiredAttributes] = NULL, [SortingAttribute] = NULL, [EnumType] = NULL, [IsIdentity] = 0, [IsCustom] = 0, [RemoveAction] = 1, [IsPrimaryKey] = 0, [ChoiceAttributeData] = NULL, [ParametersData] = NULL, [CustomsData] = NULL, [MappingType] = 1, [MappingName] = 'TF_OKATO', [IsStored] = 1, [MappingTable] = 'T_MO', [MappingRefTable] = NULL, [RefTableSearchMode] = NULL, [RefTableHashFunc] = NULL, [AttrLexem] = NULL
WHERE EntityID = @EntId AND Name = 'TF_OKATO' AND IsAdditional = 0
INSERT INTO VCLib.T_ENTITIES_ATTRIBUTES ([EntitiesAttributesId], [EntityID], [Index], [AttributeType], [Name], [Description], [SystemType], [MaxLength], [Precision], [Scale], [DefaultFormat], [IsCalculated], [IsFlag], [IsRequired], [Save], [LinkAttributeName], [PathsAttributes], [IsCashed], [RequiredAttributes], [SortingAttribute], [EnumType], [IsIdentity], [IsCustom], [RemoveAction], [IsPrimaryKey], [IsAdditional], [ChoiceAttributeData], [ParametersData], [CustomsData], [MappingType], [MappingName], [IsStored], [MappingTable], [MappingRefTable], [RefTableSearchMode], [RefTableHashFunc], [AttrLexem])
SELECT newid(), @EntId, 6940002, 0, 'TF_OKATO', 'Код субъекта РФ по ОКАТО', 'string', 5, NULL, NULL, NULL, 0, 0, 0, 1, NULL, NULL, 0, NULL, NULL, NULL, 0, 0, 1, 0, 0, NULL, NULL, NULL, 1, 'TF_OKATO', 1, 'T_MO', NULL, NULL, NULL, NULL
WHERE NOT EXISTS(SELECT * FROM VCLib.T_ENTITIES_ATTRIBUTES where EntityID = @EntId AND Name = 'TF_OKATO' AND IsAdditional = 0)

UPDATE VCLib.T_ENTITIES_ATTRIBUTES SET [Index] = 6940003, [AttributeType] = 0, [Name] = 'MCOD', [Description] = 'Код МО', [SystemType] = 'string', [MaxLength] = 6, [Precision] = NULL, [Scale] = NULL, [DefaultFormat] = NULL, [IsCalculated] = 0, [IsFlag] = 0, [IsRequired] = 1, [Save] = 1, [LinkAttributeName] = NULL, [PathsAttributes] = NULL, [IsCashed] = 0, [RequiredAttributes] = NULL, [SortingAttribute] = NULL, [EnumType] = NULL, [IsIdentity] = 0, [IsCustom] = 0, [RemoveAction] = 1, [IsPrimaryKey] = 1, [ChoiceAttributeData] = NULL, [ParametersData] = NULL, [CustomsData] = NULL, [MappingType] = 1, [MappingName] = 'MCOD', [IsStored] = 1, [MappingTable] = 'T_MO', [MappingRefTable] = NULL, [RefTableSearchMode] = NULL, [RefTableHashFunc] = NULL, [AttrLexem] = NULL
WHERE EntityID = @EntId AND Name = 'MCOD' AND IsAdditional = 0
INSERT INTO VCLib.T_ENTITIES_ATTRIBUTES ([EntitiesAttributesId], [EntityID], [Index], [AttributeType], [Name], [Description], [SystemType], [MaxLength], [Precision], [Scale], [DefaultFormat], [IsCalculated], [IsFlag], [IsRequired], [Save], [LinkAttributeName], [PathsAttributes], [IsCashed], [RequiredAttributes], [SortingAttribute], [EnumType], [IsIdentity], [IsCustom], [RemoveAction], [IsPrimaryKey], [IsAdditional], [ChoiceAttributeData], [ParametersData], [CustomsData], [MappingType], [MappingName], [IsStored], [MappingTable], [MappingRefTable], [RefTableSearchMode], [RefTableHashFunc], [AttrLexem])
SELECT newid(), @EntId, 6940003, 0, 'MCOD', 'Код МО', 'string', 6, NULL, NULL, NULL, 0, 0, 1, 1, NULL, NULL, 0, NULL, NULL, NULL, 0, 0, 1, 1, 0, NULL, NULL, NULL, 1, 'MCOD', 1, 'T_MO', NULL, NULL, NULL, NULL
WHERE NOT EXISTS(SELECT * FROM VCLib.T_ENTITIES_ATTRIBUTES where EntityID = @EntId AND Name = 'MCOD' AND IsAdditional = 0)

UPDATE VCLib.T_ENTITIES_ATTRIBUTES SET [Index] = 6940004, [AttributeType] = 0, [Name] = 'NAM_MOP', [Description] = 'Наименование МО полное', [SystemType] = 'string', [MaxLength] = 250, [Precision] = NULL, [Scale] = NULL, [DefaultFormat] = NULL, [IsCalculated] = 0, [IsFlag] = 0, [IsRequired] = 1, [Save] = 1, [LinkAttributeName] = NULL, [PathsAttributes] = NULL, [IsCashed] = 0, [RequiredAttributes] = NULL, [SortingAttribute] = NULL, [EnumType] = NULL, [IsIdentity] = 0, [IsCustom] = 0, [RemoveAction] = 1, [IsPrimaryKey] = 0, [ChoiceAttributeData] = NULL, [ParametersData] = NULL, [CustomsData] = NULL, [MappingType] = 1, [MappingName] = 'NAM_MOP', [IsStored] = 1, [MappingTable] = 'T_MO', [MappingRefTable] = NULL, [RefTableSearchMode] = NULL, [RefTableHashFunc] = NULL, [AttrLexem] = NULL
WHERE EntityID = @EntId AND Name = 'NAM_MOP' AND IsAdditional = 0
INSERT INTO VCLib.T_ENTITIES_ATTRIBUTES ([EntitiesAttributesId], [EntityID], [Index], [AttributeType], [Name], [Description], [SystemType], [MaxLength], [Precision], [Scale], [DefaultFormat], [IsCalculated], [IsFlag], [IsRequired], [Save], [LinkAttributeName], [PathsAttributes], [IsCashed], [RequiredAttributes], [SortingAttribute], [EnumType], [IsIdentity], [IsCustom], [RemoveAction], [IsPrimaryKey], [IsAdditional], [ChoiceAttributeData], [ParametersData], [CustomsData], [MappingType], [MappingName], [IsStored], [MappingTable], [MappingRefTable], [RefTableSearchMode], [RefTableHashFunc], [AttrLexem])
SELECT newid(), @EntId, 6940004, 0, 'NAM_MOP', 'Наименование МО полное', 'string', 250, NULL, NULL, NULL, 0, 0, 1, 1, NULL, NULL, 0, NULL, NULL, NULL, 0, 0, 1, 0, 0, NULL, NULL, NULL, 1, 'NAM_MOP', 1, 'T_MO', NULL, NULL, NULL, NULL
WHERE NOT EXISTS(SELECT * FROM VCLib.T_ENTITIES_ATTRIBUTES where EntityID = @EntId AND Name = 'NAM_MOP' AND IsAdditional = 0)

UPDATE VCLib.T_ENTITIES_ATTRIBUTES SET [Index] = 6940006, [AttributeType] = 0, [Name] = 'INN', [Description] = 'ИНН', [SystemType] = 'string', [MaxLength] = 12, [Precision] = NULL, [Scale] = NULL, [DefaultFormat] = NULL, [IsCalculated] = 0, [IsFlag] = 0, [IsRequired] = 0, [Save] = 1, [LinkAttributeName] = NULL, [PathsAttributes] = NULL, [IsCashed] = 0, [RequiredAttributes] = NULL, [SortingAttribute] = NULL, [EnumType] = NULL, [IsIdentity] = 0, [IsCustom] = 0, [RemoveAction] = 1, [IsPrimaryKey] = 0, [ChoiceAttributeData] = NULL, [ParametersData] = NULL, [CustomsData] = NULL, [MappingType] = 1, [MappingName] = 'INN', [IsStored] = 1, [MappingTable] = 'T_MO', [MappingRefTable] = NULL, [RefTableSearchMode] = NULL, [RefTableHashFunc] = NULL, [AttrLexem] = NULL
WHERE EntityID = @EntId AND Name = 'INN' AND IsAdditional = 0
INSERT INTO VCLib.T_ENTITIES_ATTRIBUTES ([EntitiesAttributesId], [EntityID], [Index], [AttributeType], [Name], [Description], [SystemType], [MaxLength], [Precision], [Scale], [DefaultFormat], [IsCalculated], [IsFlag], [IsRequired], [Save], [LinkAttributeName], [PathsAttributes], [IsCashed], [RequiredAttributes], [SortingAttribute], [EnumType], [IsIdentity], [IsCustom], [RemoveAction], [IsPrimaryKey], [IsAdditional], [ChoiceAttributeData], [ParametersData], [CustomsData], [MappingType], [MappingName], [IsStored], [MappingTable], [MappingRefTable], [RefTableSearchMode], [RefTableHashFunc], [AttrLexem])
SELECT newid(), @EntId, 6940006, 0, 'INN', 'ИНН', 'string', 12, NULL, NULL, NULL, 0, 0, 0, 1, NULL, NULL, 0, NULL, NULL, NULL, 0, 0, 1, 0, 0, NULL, NULL, NULL, 1, 'INN', 1, 'T_MO', NULL, NULL, NULL, NULL
WHERE NOT EXISTS(SELECT * FROM VCLib.T_ENTITIES_ATTRIBUTES where EntityID = @EntId AND Name = 'INN' AND IsAdditional = 0)

UPDATE VCLib.T_ENTITIES_ATTRIBUTES SET [Index] = 6940007, [AttributeType] = 0, [Name] = 'OGRN', [Description] = 'ОГРН', [SystemType] = 'string', [MaxLength] = 15, [Precision] = NULL, [Scale] = NULL, [DefaultFormat] = NULL, [IsCalculated] = 0, [IsFlag] = 0, [IsRequired] = 0, [Save] = 1, [LinkAttributeName] = NULL, [PathsAttributes] = NULL, [IsCashed] = 0, [RequiredAttributes] = NULL, [SortingAttribute] = NULL, [EnumType] = NULL, [IsIdentity] = 0, [IsCustom] = 0, [RemoveAction] = 1, [IsPrimaryKey] = 0, [ChoiceAttributeData] = NULL, [ParametersData] = NULL, [CustomsData] = NULL, [MappingType] = 1, [MappingName] = 'OGRN', [IsStored] = 1, [MappingTable] = 'T_MO', [MappingRefTable] = NULL, [RefTableSearchMode] = NULL, [RefTableHashFunc] = NULL, [AttrLexem] = NULL
WHERE EntityID = @EntId AND Name = 'OGRN' AND IsAdditional = 0
INSERT INTO VCLib.T_ENTITIES_ATTRIBUTES ([EntitiesAttributesId], [EntityID], [Index], [AttributeType], [Name], [Description], [SystemType], [MaxLength], [Precision], [Scale], [DefaultFormat], [IsCalculated], [IsFlag], [IsRequired], [Save], [LinkAttributeName], [PathsAttributes], [IsCashed], [RequiredAttributes], [SortingAttribute], [EnumType], [IsIdentity], [IsCustom], [RemoveAction], [IsPrimaryKey], [IsAdditional], [ChoiceAttributeData], [ParametersData], [CustomsData], [MappingType], [MappingName], [IsStored], [MappingTable], [MappingRefTable], [RefTableSearchMode], [RefTableHashFunc], [AttrLexem])
SELECT newid(), @EntId, 6940007, 0, 'OGRN', 'ОГРН', 'string', 15, NULL, NULL, NULL, 0, 0, 0, 1, NULL, NULL, 0, NULL, NULL, NULL, 0, 0, 1, 0, 0, NULL, NULL, NULL, 1, 'OGRN', 1, 'T_MO', NULL, NULL, NULL, NULL
WHERE NOT EXISTS(SELECT * FROM VCLib.T_ENTITIES_ATTRIBUTES where EntityID = @EntId AND Name = 'OGRN' AND IsAdditional = 0)

UPDATE VCLib.T_ENTITIES_ATTRIBUTES SET [Index] = 6940008, [AttributeType] = 0, [Name] = 'KPP', [Description] = 'КПП', [SystemType] = 'string', [MaxLength] = 9, [Precision] = NULL, [Scale] = NULL, [DefaultFormat] = NULL, [IsCalculated] = 0, [IsFlag] = 0, [IsRequired] = 0, [Save] = 1, [LinkAttributeName] = NULL, [PathsAttributes] = NULL, [IsCashed] = 0, [RequiredAttributes] = NULL, [SortingAttribute] = NULL, [EnumType] = NULL, [IsIdentity] = 0, [IsCustom] = 0, [RemoveAction] = 1, [IsPrimaryKey] = 0, [ChoiceAttributeData] = NULL, [ParametersData] = NULL, [CustomsData] = NULL, [MappingType] = 1, [MappingName] = 'KPP', [IsStored] = 1, [MappingTable] = 'T_MO', [MappingRefTable] = NULL, [RefTableSearchMode] = NULL, [RefTableHashFunc] = NULL, [AttrLexem] = NULL
WHERE EntityID = @EntId AND Name = 'KPP' AND IsAdditional = 0
INSERT INTO VCLib.T_ENTITIES_ATTRIBUTES ([EntitiesAttributesId], [EntityID], [Index], [AttributeType], [Name], [Description], [SystemType], [MaxLength], [Precision], [Scale], [DefaultFormat], [IsCalculated], [IsFlag], [IsRequired], [Save], [LinkAttributeName], [PathsAttributes], [IsCashed], [RequiredAttributes], [SortingAttribute], [EnumType], [IsIdentity], [IsCustom], [RemoveAction], [IsPrimaryKey], [IsAdditional], [ChoiceAttributeData], [ParametersData], [CustomsData], [MappingType], [MappingName], [IsStored], [MappingTable], [MappingRefTable], [RefTableSearchMode], [RefTableHashFunc], [AttrLexem])
SELECT newid(), @EntId, 6940008, 0, 'KPP', 'КПП', 'string', 9, NULL, NULL, NULL, 0, 0, 0, 1, NULL, NULL, 0, NULL, NULL, NULL, 0, 0, 1, 0, 0, NULL, NULL, NULL, 1, 'KPP', 1, 'T_MO', NULL, NULL, NULL, NULL
WHERE NOT EXISTS(SELECT * FROM VCLib.T_ENTITIES_ATTRIBUTES where EntityID = @EntId AND Name = 'KPP' AND IsAdditional = 0)

UPDATE VCLib.T_ENTITIES_ATTRIBUTES SET [Index] = 6940009, [AttributeType] = 0, [Name] = 'INDEX_J', [Description] = 'Почтовый индекс юридического адреса МО', [SystemType] = 'string', [MaxLength] = 6, [Precision] = NULL, [Scale] = NULL, [DefaultFormat] = NULL, [IsCalculated] = 0, [IsFlag] = 0, [IsRequired] = 0, [Save] = 1, [LinkAttributeName] = NULL, [PathsAttributes] = NULL, [IsCashed] = 0, [RequiredAttributes] = NULL, [SortingAttribute] = NULL, [EnumType] = NULL, [IsIdentity] = 0, [IsCustom] = 0, [RemoveAction] = 1, [IsPrimaryKey] = 0, [ChoiceAttributeData] = NULL, [ParametersData] = NULL, [CustomsData] = NULL, [MappingType] = 1, [MappingName] = 'INDEX_J', [IsStored] = 1, [MappingTable] = 'T_MO', [MappingRefTable] = NULL, [RefTableSearchMode] = NULL, [RefTableHashFunc] = NULL, [AttrLexem] = NULL
WHERE EntityID = @EntId AND Name = 'INDEX_J' AND IsAdditional = 0
INSERT INTO VCLib.T_ENTITIES_ATTRIBUTES ([EntitiesAttributesId], [EntityID], [Index], [AttributeType], [Name], [Description], [SystemType], [MaxLength], [Precision], [Scale], [DefaultFormat], [IsCalculated], [IsFlag], [IsRequired], [Save], [LinkAttributeName], [PathsAttributes], [IsCashed], [RequiredAttributes], [SortingAttribute], [EnumType], [IsIdentity], [IsCustom], [RemoveAction], [IsPrimaryKey], [IsAdditional], [ChoiceAttributeData], [ParametersData], [CustomsData], [MappingType], [MappingName], [IsStored], [MappingTable], [MappingRefTable], [RefTableSearchMode], [RefTableHashFunc], [AttrLexem])
SELECT newid(), @EntId, 6940009, 0, 'INDEX_J', 'Почтовый индекс юридического адреса МО', 'string', 6, NULL, NULL, NULL, 0, 0, 0, 1, NULL, NULL, 0, NULL, NULL, NULL, 0, 0, 1, 0, 0, NULL, NULL, NULL, 1, 'INDEX_J', 1, 'T_MO', NULL, NULL, NULL, NULL
WHERE NOT EXISTS(SELECT * FROM VCLib.T_ENTITIES_ATTRIBUTES where EntityID = @EntId AND Name = 'INDEX_J' AND IsAdditional = 0)

UPDATE VCLib.T_ENTITIES_ATTRIBUTES SET [Index] = 6940010, [AttributeType] = 0, [Name] = 'ADDR_J', [Description] = 'Юридический адрес МО', [SystemType] = 'string', [MaxLength] = 254, [Precision] = NULL, [Scale] = NULL, [DefaultFormat] = NULL, [IsCalculated] = 0, [IsFlag] = 0, [IsRequired] = 0, [Save] = 1, [LinkAttributeName] = NULL, [PathsAttributes] = NULL, [IsCashed] = 0, [RequiredAttributes] = NULL, [SortingAttribute] = NULL, [EnumType] = NULL, [IsIdentity] = 0, [IsCustom] = 0, [RemoveAction] = 1, [IsPrimaryKey] = 0, [ChoiceAttributeData] = NULL, [ParametersData] = NULL, [CustomsData] = NULL, [MappingType] = 1, [MappingName] = 'ADDR_J', [IsStored] = 1, [MappingTable] = 'T_MO', [MappingRefTable] = NULL, [RefTableSearchMode] = NULL, [RefTableHashFunc] = NULL, [AttrLexem] = NULL
WHERE EntityID = @EntId AND Name = 'ADDR_J' AND IsAdditional = 0
INSERT INTO VCLib.T_ENTITIES_ATTRIBUTES ([EntitiesAttributesId], [EntityID], [Index], [AttributeType], [Name], [Description], [SystemType], [MaxLength], [Precision], [Scale], [DefaultFormat], [IsCalculated], [IsFlag], [IsRequired], [Save], [LinkAttributeName], [PathsAttributes], [IsCashed], [RequiredAttributes], [SortingAttribute], [EnumType], [IsIdentity], [IsCustom], [RemoveAction], [IsPrimaryKey], [IsAdditional], [ChoiceAttributeData], [ParametersData], [CustomsData], [MappingType], [MappingName], [IsStored], [MappingTable], [MappingRefTable], [RefTableSearchMode], [RefTableHashFunc], [AttrLexem])
SELECT newid(), @EntId, 6940010, 0, 'ADDR_J', 'Юридический адрес МО', 'string', 254, NULL, NULL, NULL, 0, 0, 0, 1, NULL, NULL, 0, NULL, NULL, NULL, 0, 0, 1, 0, 0, NULL, NULL, NULL, 1, 'ADDR_J', 1, 'T_MO', NULL, NULL, NULL, NULL
WHERE NOT EXISTS(SELECT * FROM VCLib.T_ENTITIES_ATTRIBUTES where EntityID = @EntId AND Name = 'ADDR_J' AND IsAdditional = 0)

UPDATE VCLib.T_ENTITIES_ATTRIBUTES SET [Index] = 6940014, [AttributeType] = 0, [Name] = 'FAM_RUK', [Description] = 'Фамилия руководителя', [SystemType] = 'string', [MaxLength] = 40, [Precision] = NULL, [Scale] = NULL, [DefaultFormat] = NULL, [IsCalculated] = 0, [IsFlag] = 0, [IsRequired] = 0, [Save] = 1, [LinkAttributeName] = NULL, [PathsAttributes] = NULL, [IsCashed] = 0, [RequiredAttributes] = NULL, [SortingAttribute] = NULL, [EnumType] = NULL, [IsIdentity] = 0, [IsCustom] = 0, [RemoveAction] = 1, [IsPrimaryKey] = 0, [ChoiceAttributeData] = NULL, [ParametersData] = NULL, [CustomsData] = NULL, [MappingType] = 1, [MappingName] = 'FAM_RUK', [IsStored] = 1, [MappingTable] = 'T_MO', [MappingRefTable] = NULL, [RefTableSearchMode] = NULL, [RefTableHashFunc] = NULL, [AttrLexem] = NULL
WHERE EntityID = @EntId AND Name = 'FAM_RUK' AND IsAdditional = 0
INSERT INTO VCLib.T_ENTITIES_ATTRIBUTES ([EntitiesAttributesId], [EntityID], [Index], [AttributeType], [Name], [Description], [SystemType], [MaxLength], [Precision], [Scale], [DefaultFormat], [IsCalculated], [IsFlag], [IsRequired], [Save], [LinkAttributeName], [PathsAttributes], [IsCashed], [RequiredAttributes], [SortingAttribute], [EnumType], [IsIdentity], [IsCustom], [RemoveAction], [IsPrimaryKey], [IsAdditional], [ChoiceAttributeData], [ParametersData], [CustomsData], [MappingType], [MappingName], [IsStored], [MappingTable], [MappingRefTable], [RefTableSearchMode], [RefTableHashFunc], [AttrLexem])
SELECT newid(), @EntId, 6940014, 0, 'FAM_RUK', 'Фамилия руководителя', 'string', 40, NULL, NULL, NULL, 0, 0, 0, 1, NULL, NULL, 0, NULL, NULL, NULL, 0, 0, 1, 0, 0, NULL, NULL, NULL, 1, 'FAM_RUK', 1, 'T_MO', NULL, NULL, NULL, NULL
WHERE NOT EXISTS(SELECT * FROM VCLib.T_ENTITIES_ATTRIBUTES where EntityID = @EntId AND Name = 'FAM_RUK' AND IsAdditional = 0)

UPDATE VCLib.T_ENTITIES_ATTRIBUTES SET [Index] = 6940015, [AttributeType] = 0, [Name] = 'IM_RUK', [Description] = 'Имя руководителя', [SystemType] = 'string', [MaxLength] = 40, [Precision] = NULL, [Scale] = NULL, [DefaultFormat] = NULL, [IsCalculated] = 0, [IsFlag] = 0, [IsRequired] = 0, [Save] = 1, [LinkAttributeName] = NULL, [PathsAttributes] = NULL, [IsCashed] = 0, [RequiredAttributes] = NULL, [SortingAttribute] = NULL, [EnumType] = NULL, [IsIdentity] = 0, [IsCustom] = 0, [RemoveAction] = 1, [IsPrimaryKey] = 0, [ChoiceAttributeData] = NULL, [ParametersData] = NULL, [CustomsData] = NULL, [MappingType] = 1, [MappingName] = 'IM_RUK', [IsStored] = 1, [MappingTable] = 'T_MO', [MappingRefTable] = NULL, [RefTableSearchMode] = NULL, [RefTableHashFunc] = NULL, [AttrLexem] = NULL
WHERE EntityID = @EntId AND Name = 'IM_RUK' AND IsAdditional = 0
INSERT INTO VCLib.T_ENTITIES_ATTRIBUTES ([EntitiesAttributesId], [EntityID], [Index], [AttributeType], [Name], [Description], [SystemType], [MaxLength], [Precision], [Scale], [DefaultFormat], [IsCalculated], [IsFlag], [IsRequired], [Save], [LinkAttributeName], [PathsAttributes], [IsCashed], [RequiredAttributes], [SortingAttribute], [EnumType], [IsIdentity], [IsCustom], [RemoveAction], [IsPrimaryKey], [IsAdditional], [ChoiceAttributeData], [ParametersData], [CustomsData], [MappingType], [MappingName], [IsStored], [MappingTable], [MappingRefTable], [RefTableSearchMode], [RefTableHashFunc], [AttrLexem])
SELECT newid(), @EntId, 6940015, 0, 'IM_RUK', 'Имя руководителя', 'string', 40, NULL, NULL, NULL, 0, 0, 0, 1, NULL, NULL, 0, NULL, NULL, NULL, 0, 0, 1, 0, 0, NULL, NULL, NULL, 1, 'IM_RUK', 1, 'T_MO', NULL, NULL, NULL, NULL
WHERE NOT EXISTS(SELECT * FROM VCLib.T_ENTITIES_ATTRIBUTES where EntityID = @EntId AND Name = 'IM_RUK' AND IsAdditional = 0)

UPDATE VCLib.T_ENTITIES_ATTRIBUTES SET [Index] = 6940016, [AttributeType] = 0, [Name] = 'OT_RUK', [Description] = 'Отчество руководителя', [SystemType] = 'string', [MaxLength] = 40, [Precision] = NULL, [Scale] = NULL, [DefaultFormat] = NULL, [IsCalculated] = 0, [IsFlag] = 0, [IsRequired] = 0, [Save] = 1, [LinkAttributeName] = NULL, [PathsAttributes] = NULL, [IsCashed] = 0, [RequiredAttributes] = NULL, [SortingAttribute] = NULL, [EnumType] = NULL, [IsIdentity] = 0, [IsCustom] = 0, [RemoveAction] = 1, [IsPrimaryKey] = 0, [ChoiceAttributeData] = NULL, [ParametersData] = NULL, [CustomsData] = NULL, [MappingType] = 1, [MappingName] = 'OT_RUK', [IsStored] = 1, [MappingTable] = 'T_MO', [MappingRefTable] = NULL, [RefTableSearchMode] = NULL, [RefTableHashFunc] = NULL, [AttrLexem] = NULL
WHERE EntityID = @EntId AND Name = 'OT_RUK' AND IsAdditional = 0
INSERT INTO VCLib.T_ENTITIES_ATTRIBUTES ([EntitiesAttributesId], [EntityID], [Index], [AttributeType], [Name], [Description], [SystemType], [MaxLength], [Precision], [Scale], [DefaultFormat], [IsCalculated], [IsFlag], [IsRequired], [Save], [LinkAttributeName], [PathsAttributes], [IsCashed], [RequiredAttributes], [SortingAttribute], [EnumType], [IsIdentity], [IsCustom], [RemoveAction], [IsPrimaryKey], [IsAdditional], [ChoiceAttributeData], [ParametersData], [CustomsData], [MappingType], [MappingName], [IsStored], [MappingTable], [MappingRefTable], [RefTableSearchMode], [RefTableHashFunc], [AttrLexem])
SELECT newid(), @EntId, 6940016, 0, 'OT_RUK', 'Отчество руководителя', 'string', 40, NULL, NULL, NULL, 0, 0, 0, 1, NULL, NULL, 0, NULL, NULL, NULL, 0, 0, 1, 0, 0, NULL, NULL, NULL, 1, 'OT_RUK', 1, 'T_MO', NULL, NULL, NULL, NULL
WHERE NOT EXISTS(SELECT * FROM VCLib.T_ENTITIES_ATTRIBUTES where EntityID = @EntId AND Name = 'OT_RUK' AND IsAdditional = 0)

UPDATE VCLib.T_ENTITIES_ATTRIBUTES SET [Index] = 6940017, [AttributeType] = 0, [Name] = 'PHONE', [Description] = 'Телефон', [SystemType] = 'string', [MaxLength] = 40, [Precision] = NULL, [Scale] = NULL, [DefaultFormat] = NULL, [IsCalculated] = 0, [IsFlag] = 0, [IsRequired] = 0, [Save] = 1, [LinkAttributeName] = NULL, [PathsAttributes] = NULL, [IsCashed] = 0, [RequiredAttributes] = NULL, [SortingAttribute] = NULL, [EnumType] = NULL, [IsIdentity] = 0, [IsCustom] = 0, [RemoveAction] = 1, [IsPrimaryKey] = 0, [ChoiceAttributeData] = NULL, [ParametersData] = NULL, [CustomsData] = NULL, [MappingType] = 1, [MappingName] = 'PHONE', [IsStored] = 1, [MappingTable] = 'T_MO', [MappingRefTable] = NULL, [RefTableSearchMode] = NULL, [RefTableHashFunc] = NULL, [AttrLexem] = NULL
WHERE EntityID = @EntId AND Name = 'PHONE' AND IsAdditional = 0
INSERT INTO VCLib.T_ENTITIES_ATTRIBUTES ([EntitiesAttributesId], [EntityID], [Index], [AttributeType], [Name], [Description], [SystemType], [MaxLength], [Precision], [Scale], [DefaultFormat], [IsCalculated], [IsFlag], [IsRequired], [Save], [LinkAttributeName], [PathsAttributes], [IsCashed], [RequiredAttributes], [SortingAttribute], [EnumType], [IsIdentity], [IsCustom], [RemoveAction], [IsPrimaryKey], [IsAdditional], [ChoiceAttributeData], [ParametersData], [CustomsData], [MappingType], [MappingName], [IsStored], [MappingTable], [MappingRefTable], [RefTableSearchMode], [RefTableHashFunc], [AttrLexem])
SELECT newid(), @EntId, 6940017, 0, 'PHONE', 'Телефон', 'string', 40, NULL, NULL, NULL, 0, 0, 0, 1, NULL, NULL, 0, NULL, NULL, NULL, 0, 0, 1, 0, 0, NULL, NULL, NULL, 1, 'PHONE', 1, 'T_MO', NULL, NULL, NULL, NULL
WHERE NOT EXISTS(SELECT * FROM VCLib.T_ENTITIES_ATTRIBUTES where EntityID = @EntId AND Name = 'PHONE' AND IsAdditional = 0)

UPDATE VCLib.T_ENTITIES_ATTRIBUTES SET [Index] = 6940018, [AttributeType] = 0, [Name] = 'FAX', [Description] = 'Факс', [SystemType] = 'string', [MaxLength] = 40, [Precision] = NULL, [Scale] = NULL, [DefaultFormat] = NULL, [IsCalculated] = 0, [IsFlag] = 0, [IsRequired] = 0, [Save] = 1, [LinkAttributeName] = NULL, [PathsAttributes] = NULL, [IsCashed] = 0, [RequiredAttributes] = NULL, [SortingAttribute] = NULL, [EnumType] = NULL, [IsIdentity] = 0, [IsCustom] = 0, [RemoveAction] = 1, [IsPrimaryKey] = 0, [ChoiceAttributeData] = NULL, [ParametersData] = NULL, [CustomsData] = NULL, [MappingType] = 1, [MappingName] = 'FAX', [IsStored] = 1, [MappingTable] = 'T_MO', [MappingRefTable] = NULL, [RefTableSearchMode] = NULL, [RefTableHashFunc] = NULL, [AttrLexem] = NULL
WHERE EntityID = @EntId AND Name = 'FAX' AND IsAdditional = 0
INSERT INTO VCLib.T_ENTITIES_ATTRIBUTES ([EntitiesAttributesId], [EntityID], [Index], [AttributeType], [Name], [Description], [SystemType], [MaxLength], [Precision], [Scale], [DefaultFormat], [IsCalculated], [IsFlag], [IsRequired], [Save], [LinkAttributeName], [PathsAttributes], [IsCashed], [RequiredAttributes], [SortingAttribute], [EnumType], [IsIdentity], [IsCustom], [RemoveAction], [IsPrimaryKey], [IsAdditional], [ChoiceAttributeData], [ParametersData], [CustomsData], [MappingType], [MappingName], [IsStored], [MappingTable], [MappingRefTable], [RefTableSearchMode], [RefTableHashFunc], [AttrLexem])
SELECT newid(), @EntId, 6940018, 0, 'FAX', 'Факс', 'string', 40, NULL, NULL, NULL, 0, 0, 0, 1, NULL, NULL, 0, NULL, NULL, NULL, 0, 0, 1, 0, 0, NULL, NULL, NULL, 1, 'FAX', 1, 'T_MO', NULL, NULL, NULL, NULL
WHERE NOT EXISTS(SELECT * FROM VCLib.T_ENTITIES_ATTRIBUTES where EntityID = @EntId AND Name = 'FAX' AND IsAdditional = 0)

UPDATE VCLib.T_ENTITIES_ATTRIBUTES SET [Index] = 6940019, [AttributeType] = 0, [Name] = 'E_MAIL', [Description] = 'Адрес электронной почты', [SystemType] = 'string', [MaxLength] = 50, [Precision] = NULL, [Scale] = NULL, [DefaultFormat] = NULL, [IsCalculated] = 0, [IsFlag] = 0, [IsRequired] = 0, [Save] = 1, [LinkAttributeName] = NULL, [PathsAttributes] = NULL, [IsCashed] = 0, [RequiredAttributes] = NULL, [SortingAttribute] = NULL, [EnumType] = NULL, [IsIdentity] = 0, [IsCustom] = 0, [RemoveAction] = 1, [IsPrimaryKey] = 0, [ChoiceAttributeData] = NULL, [ParametersData] = NULL, [CustomsData] = NULL, [MappingType] = 1, [MappingName] = 'E_MAIL', [IsStored] = 1, [MappingTable] = 'T_MO', [MappingRefTable] = NULL, [RefTableSearchMode] = NULL, [RefTableHashFunc] = NULL, [AttrLexem] = NULL
WHERE EntityID = @EntId AND Name = 'E_MAIL' AND IsAdditional = 0
INSERT INTO VCLib.T_ENTITIES_ATTRIBUTES ([EntitiesAttributesId], [EntityID], [Index], [AttributeType], [Name], [Description], [SystemType], [MaxLength], [Precision], [Scale], [DefaultFormat], [IsCalculated], [IsFlag], [IsRequired], [Save], [LinkAttributeName], [PathsAttributes], [IsCashed], [RequiredAttributes], [SortingAttribute], [EnumType], [IsIdentity], [IsCustom], [RemoveAction], [IsPrimaryKey], [IsAdditional], [ChoiceAttributeData], [ParametersData], [CustomsData], [MappingType], [MappingName], [IsStored], [MappingTable], [MappingRefTable], [RefTableSearchMode], [RefTableHashFunc], [AttrLexem])
SELECT newid(), @EntId, 6940019, 0, 'E_MAIL', 'Адрес электронной почты', 'string', 50, NULL, NULL, NULL, 0, 0, 0, 1, NULL, NULL, 0, NULL, NULL, NULL, 0, 0, 1, 0, 0, NULL, NULL, NULL, 1, 'E_MAIL', 1, 'T_MO', NULL, NULL, NULL, NULL
WHERE NOT EXISTS(SELECT * FROM VCLib.T_ENTITIES_ATTRIBUTES where EntityID = @EntId AND Name = 'E_MAIL' AND IsAdditional = 0)

UPDATE VCLib.T_ENTITIES_ATTRIBUTES SET [Index] = 6940023, [AttributeType] = 0, [Name] = 'MP', [Description] = 'Виды медицинской помощи', [SystemType] = 'string', [MaxLength] = 15, [Precision] = NULL, [Scale] = NULL, [DefaultFormat] = NULL, [IsCalculated] = 0, [IsFlag] = 0, [IsRequired] = 0, [Save] = 1, [LinkAttributeName] = NULL, [PathsAttributes] = NULL, [IsCashed] = 0, [RequiredAttributes] = NULL, [SortingAttribute] = NULL, [EnumType] = NULL, [IsIdentity] = 0, [IsCustom] = 0, [RemoveAction] = 1, [IsPrimaryKey] = 0, [ChoiceAttributeData] = NULL, [ParametersData] = NULL, [CustomsData] = NULL, [MappingType] = 1, [MappingName] = 'MP', [IsStored] = 1, [MappingTable] = 'T_MO', [MappingRefTable] = NULL, [RefTableSearchMode] = NULL, [RefTableHashFunc] = NULL, [AttrLexem] = NULL
WHERE EntityID = @EntId AND Name = 'MP' AND IsAdditional = 0
INSERT INTO VCLib.T_ENTITIES_ATTRIBUTES ([EntitiesAttributesId], [EntityID], [Index], [AttributeType], [Name], [Description], [SystemType], [MaxLength], [Precision], [Scale], [DefaultFormat], [IsCalculated], [IsFlag], [IsRequired], [Save], [LinkAttributeName], [PathsAttributes], [IsCashed], [RequiredAttributes], [SortingAttribute], [EnumType], [IsIdentity], [IsCustom], [RemoveAction], [IsPrimaryKey], [IsAdditional], [ChoiceAttributeData], [ParametersData], [CustomsData], [MappingType], [MappingName], [IsStored], [MappingTable], [MappingRefTable], [RefTableSearchMode], [RefTableHashFunc], [AttrLexem])
SELECT newid(), @EntId, 6940023, 0, 'MP', 'Виды медицинской помощи', 'string', 15, NULL, NULL, NULL, 0, 0, 0, 1, NULL, NULL, 0, NULL, NULL, NULL, 0, 0, 1, 0, 0, NULL, NULL, NULL, 1, 'MP', 1, 'T_MO', NULL, NULL, NULL, NULL
WHERE NOT EXISTS(SELECT * FROM VCLib.T_ENTITIES_ATTRIBUTES where EntityID = @EntId AND Name = 'MP' AND IsAdditional = 0)

UPDATE VCLib.T_ENTITIES_ATTRIBUTES SET [Index] = 6940024, [AttributeType] = 0, [Name] = 'WWW', [Description] = 'Адрес сайта в сети интернет', [SystemType] = 'string', [MaxLength] = 100, [Precision] = NULL, [Scale] = NULL, [DefaultFormat] = NULL, [IsCalculated] = 0, [IsFlag] = 0, [IsRequired] = 0, [Save] = 1, [LinkAttributeName] = NULL, [PathsAttributes] = NULL, [IsCashed] = 0, [RequiredAttributes] = NULL, [SortingAttribute] = NULL, [EnumType] = NULL, [IsIdentity] = 0, [IsCustom] = 0, [RemoveAction] = 1, [IsPrimaryKey] = 0, [ChoiceAttributeData] = NULL, [ParametersData] = NULL, [CustomsData] = NULL, [MappingType] = 1, [MappingName] = 'WWW', [IsStored] = 1, [MappingTable] = 'T_MO', [MappingRefTable] = NULL, [RefTableSearchMode] = NULL, [RefTableHashFunc] = NULL, [AttrLexem] = NULL
WHERE EntityID = @EntId AND Name = 'WWW' AND IsAdditional = 0
INSERT INTO VCLib.T_ENTITIES_ATTRIBUTES ([EntitiesAttributesId], [EntityID], [Index], [AttributeType], [Name], [Description], [SystemType], [MaxLength], [Precision], [Scale], [DefaultFormat], [IsCalculated], [IsFlag], [IsRequired], [Save], [LinkAttributeName], [PathsAttributes], [IsCashed], [RequiredAttributes], [SortingAttribute], [EnumType], [IsIdentity], [IsCustom], [RemoveAction], [IsPrimaryKey], [IsAdditional], [ChoiceAttributeData], [ParametersData], [CustomsData], [MappingType], [MappingName], [IsStored], [MappingTable], [MappingRefTable], [RefTableSearchMode], [RefTableHashFunc], [AttrLexem])
SELECT newid(), @EntId, 6940024, 0, 'WWW', 'Адрес сайта в сети интернет', 'string', 100, NULL, NULL, NULL, 0, 0, 0, 1, NULL, NULL, 0, NULL, NULL, NULL, 0, 0, 1, 0, 0, NULL, NULL, NULL, 1, 'WWW', 1, 'T_MO', NULL, NULL, NULL, NULL
WHERE NOT EXISTS(SELECT * FROM VCLib.T_ENTITIES_ATTRIBUTES where EntityID = @EntId AND Name = 'WWW' AND IsAdditional = 0)

UPDATE VCLib.T_ENTITIES_ATTRIBUTES SET [Index] = 6940025, [AttributeType] = 0, [Name] = 'D_BEGIN', [Description] = 'Дата включения в реестр МО', [SystemType] = 'date', [MaxLength] = NULL, [Precision] = NULL, [Scale] = NULL, [DefaultFormat] = NULL, [IsCalculated] = 0, [IsFlag] = 0, [IsRequired] = 0, [Save] = 1, [LinkAttributeName] = NULL, [PathsAttributes] = NULL, [IsCashed] = 0, [RequiredAttributes] = NULL, [SortingAttribute] = NULL, [EnumType] = NULL, [IsIdentity] = 0, [IsCustom] = 0, [RemoveAction] = 1, [IsPrimaryKey] = 0, [ChoiceAttributeData] = NULL, [ParametersData] = NULL, [CustomsData] = NULL, [MappingType] = 1, [MappingName] = 'D_BEGIN', [IsStored] = 1, [MappingTable] = 'T_MO', [MappingRefTable] = NULL, [RefTableSearchMode] = NULL, [RefTableHashFunc] = NULL, [AttrLexem] = NULL
WHERE EntityID = @EntId AND Name = 'D_BEGIN' AND IsAdditional = 0
INSERT INTO VCLib.T_ENTITIES_ATTRIBUTES ([EntitiesAttributesId], [EntityID], [Index], [AttributeType], [Name], [Description], [SystemType], [MaxLength], [Precision], [Scale], [DefaultFormat], [IsCalculated], [IsFlag], [IsRequired], [Save], [LinkAttributeName], [PathsAttributes], [IsCashed], [RequiredAttributes], [SortingAttribute], [EnumType], [IsIdentity], [IsCustom], [RemoveAction], [IsPrimaryKey], [IsAdditional], [ChoiceAttributeData], [ParametersData], [CustomsData], [MappingType], [MappingName], [IsStored], [MappingTable], [MappingRefTable], [RefTableSearchMode], [RefTableHashFunc], [AttrLexem])
SELECT newid(), @EntId, 6940025, 0, 'D_BEGIN', 'Дата включения в реестр МО', 'date', NULL, NULL, NULL, NULL, 0, 0, 0, 1, NULL, NULL, 0, NULL, NULL, NULL, 0, 0, 1, 0, 0, NULL, NULL, NULL, 1, 'D_BEGIN', 1, 'T_MO', NULL, NULL, NULL, NULL
WHERE NOT EXISTS(SELECT * FROM VCLib.T_ENTITIES_ATTRIBUTES where EntityID = @EntId AND Name = 'D_BEGIN' AND IsAdditional = 0)

UPDATE VCLib.T_ENTITIES_ATTRIBUTES SET [Index] = 6940026, [AttributeType] = 0, [Name] = 'D_END', [Description] = 'Дата исключения из реестра МО', [SystemType] = 'date', [MaxLength] = NULL, [Precision] = NULL, [Scale] = NULL, [DefaultFormat] = NULL, [IsCalculated] = 0, [IsFlag] = 0, [IsRequired] = 0, [Save] = 1, [LinkAttributeName] = NULL, [PathsAttributes] = NULL, [IsCashed] = 0, [RequiredAttributes] = NULL, [SortingAttribute] = NULL, [EnumType] = NULL, [IsIdentity] = 0, [IsCustom] = 0, [RemoveAction] = 1, [IsPrimaryKey] = 0, [ChoiceAttributeData] = NULL, [ParametersData] = NULL, [CustomsData] = NULL, [MappingType] = 1, [MappingName] = 'D_END', [IsStored] = 1, [MappingTable] = 'T_MO', [MappingRefTable] = NULL, [RefTableSearchMode] = NULL, [RefTableHashFunc] = NULL, [AttrLexem] = NULL
WHERE EntityID = @EntId AND Name = 'D_END' AND IsAdditional = 0
INSERT INTO VCLib.T_ENTITIES_ATTRIBUTES ([EntitiesAttributesId], [EntityID], [Index], [AttributeType], [Name], [Description], [SystemType], [MaxLength], [Precision], [Scale], [DefaultFormat], [IsCalculated], [IsFlag], [IsRequired], [Save], [LinkAttributeName], [PathsAttributes], [IsCashed], [RequiredAttributes], [SortingAttribute], [EnumType], [IsIdentity], [IsCustom], [RemoveAction], [IsPrimaryKey], [IsAdditional], [ChoiceAttributeData], [ParametersData], [CustomsData], [MappingType], [MappingName], [IsStored], [MappingTable], [MappingRefTable], [RefTableSearchMode], [RefTableHashFunc], [AttrLexem])
SELECT newid(), @EntId, 6940026, 0, 'D_END', 'Дата исключения из реестра МО', 'date', NULL, NULL, NULL, NULL, 0, 0, 0, 1, NULL, NULL, 0, NULL, NULL, NULL, 0, 0, 1, 0, 0, NULL, NULL, NULL, 1, 'D_END', 1, 'T_MO', NULL, NULL, NULL, NULL
WHERE NOT EXISTS(SELECT * FROM VCLib.T_ENTITIES_ATTRIBUTES where EntityID = @EntId AND Name = 'D_END' AND IsAdditional = 0)

UPDATE VCLib.T_ENTITIES_ATTRIBUTES SET [Index] = 6940027, [AttributeType] = 0, [Name] = 'NAME_E', [Description] = 'Причина исключения МО из реестра МО', [SystemType] = 'string', [MaxLength] = 10, [Precision] = NULL, [Scale] = NULL, [DefaultFormat] = NULL, [IsCalculated] = 0, [IsFlag] = 0, [IsRequired] = 0, [Save] = 1, [LinkAttributeName] = NULL, [PathsAttributes] = NULL, [IsCashed] = 0, [RequiredAttributes] = NULL, [SortingAttribute] = NULL, [EnumType] = NULL, [IsIdentity] = 0, [IsCustom] = 0, [RemoveAction] = 1, [IsPrimaryKey] = 0, [ChoiceAttributeData] = NULL, [ParametersData] = NULL, [CustomsData] = NULL, [MappingType] = 1, [MappingName] = 'NAME_E', [IsStored] = 1, [MappingTable] = 'T_MO', [MappingRefTable] = NULL, [RefTableSearchMode] = NULL, [RefTableHashFunc] = NULL, [AttrLexem] = NULL
WHERE EntityID = @EntId AND Name = 'NAME_E' AND IsAdditional = 0
INSERT INTO VCLib.T_ENTITIES_ATTRIBUTES ([EntitiesAttributesId], [EntityID], [Index], [AttributeType], [Name], [Description], [SystemType], [MaxLength], [Precision], [Scale], [DefaultFormat], [IsCalculated], [IsFlag], [IsRequired], [Save], [LinkAttributeName], [PathsAttributes], [IsCashed], [RequiredAttributes], [SortingAttribute], [EnumType], [IsIdentity], [IsCustom], [RemoveAction], [IsPrimaryKey], [IsAdditional], [ChoiceAttributeData], [ParametersData], [CustomsData], [MappingType], [MappingName], [IsStored], [MappingTable], [MappingRefTable], [RefTableSearchMode], [RefTableHashFunc], [AttrLexem])
SELECT newid(), @EntId, 6940027, 0, 'NAME_E', 'Причина исключения МО из реестра МО', 'string', 10, NULL, NULL, NULL, 0, 0, 0, 1, NULL, NULL, 0, NULL, NULL, NULL, 0, 0, 1, 0, 0, NULL, NULL, NULL, 1, 'NAME_E', 1, 'T_MO', NULL, NULL, NULL, NULL
WHERE NOT EXISTS(SELECT * FROM VCLib.T_ENTITIES_ATTRIBUTES where EntityID = @EntId AND Name = 'NAME_E' AND IsAdditional = 0)

UPDATE VCLib.T_ENTITIES_ATTRIBUTES SET [Index] = 6940028, [AttributeType] = 0, [Name] = 'DUVED', [Description] = 'Дата уведомления об осуществлении деятельности в сфере ОМС', [SystemType] = 'date', [MaxLength] = NULL, [Precision] = NULL, [Scale] = NULL, [DefaultFormat] = NULL, [IsCalculated] = 0, [IsFlag] = 0, [IsRequired] = 0, [Save] = 1, [LinkAttributeName] = NULL, [PathsAttributes] = NULL, [IsCashed] = 0, [RequiredAttributes] = NULL, [SortingAttribute] = NULL, [EnumType] = NULL, [IsIdentity] = 0, [IsCustom] = 0, [RemoveAction] = 1, [IsPrimaryKey] = 0, [ChoiceAttributeData] = NULL, [ParametersData] = NULL, [CustomsData] = NULL, [MappingType] = 1, [MappingName] = 'DUVED', [IsStored] = 1, [MappingTable] = 'T_MO', [MappingRefTable] = NULL, [RefTableSearchMode] = NULL, [RefTableHashFunc] = NULL, [AttrLexem] = NULL
WHERE EntityID = @EntId AND Name = 'DUVED' AND IsAdditional = 0
INSERT INTO VCLib.T_ENTITIES_ATTRIBUTES ([EntitiesAttributesId], [EntityID], [Index], [AttributeType], [Name], [Description], [SystemType], [MaxLength], [Precision], [Scale], [DefaultFormat], [IsCalculated], [IsFlag], [IsRequired], [Save], [LinkAttributeName], [PathsAttributes], [IsCashed], [RequiredAttributes], [SortingAttribute], [EnumType], [IsIdentity], [IsCustom], [RemoveAction], [IsPrimaryKey], [IsAdditional], [ChoiceAttributeData], [ParametersData], [CustomsData], [MappingType], [MappingName], [IsStored], [MappingTable], [MappingRefTable], [RefTableSearchMode], [RefTableHashFunc], [AttrLexem])
SELECT newid(), @EntId, 6940028, 0, 'DUVED', 'Дата уведомления об осуществлении деятельности в сфере ОМС', 'date', NULL, NULL, NULL, NULL, 0, 0, 0, 1, NULL, NULL, 0, NULL, NULL, NULL, 0, 0, 1, 0, 0, NULL, NULL, NULL, 1, 'DUVED', 1, 'T_MO', NULL, NULL, NULL, NULL
WHERE NOT EXISTS(SELECT * FROM VCLib.T_ENTITIES_ATTRIBUTES where EntityID = @EntId AND Name = 'DUVED' AND IsAdditional = 0)

UPDATE VCLib.T_ENTITIES_ATTRIBUTES SET [Index] = 6940029, [AttributeType] = 0, [Name] = 'D_EDIT', [Description] = 'Дата последнего редактирования', [SystemType] = 'date', [MaxLength] = NULL, [Precision] = NULL, [Scale] = NULL, [DefaultFormat] = NULL, [IsCalculated] = 0, [IsFlag] = 0, [IsRequired] = 0, [Save] = 1, [LinkAttributeName] = NULL, [PathsAttributes] = NULL, [IsCashed] = 0, [RequiredAttributes] = NULL, [SortingAttribute] = NULL, [EnumType] = NULL, [IsIdentity] = 0, [IsCustom] = 0, [RemoveAction] = 1, [IsPrimaryKey] = 0, [ChoiceAttributeData] = NULL, [ParametersData] = NULL, [CustomsData] = NULL, [MappingType] = 1, [MappingName] = 'D_EDIT', [IsStored] = 1, [MappingTable] = 'T_MO', [MappingRefTable] = NULL, [RefTableSearchMode] = NULL, [RefTableHashFunc] = NULL, [AttrLexem] = NULL
WHERE EntityID = @EntId AND Name = 'D_EDIT' AND IsAdditional = 0
INSERT INTO VCLib.T_ENTITIES_ATTRIBUTES ([EntitiesAttributesId], [EntityID], [Index], [AttributeType], [Name], [Description], [SystemType], [MaxLength], [Precision], [Scale], [DefaultFormat], [IsCalculated], [IsFlag], [IsRequired], [Save], [LinkAttributeName], [PathsAttributes], [IsCashed], [RequiredAttributes], [SortingAttribute], [EnumType], [IsIdentity], [IsCustom], [RemoveAction], [IsPrimaryKey], [IsAdditional], [ChoiceAttributeData], [ParametersData], [CustomsData], [MappingType], [MappingName], [IsStored], [MappingTable], [MappingRefTable], [RefTableSearchMode], [RefTableHashFunc], [AttrLexem])
SELECT newid(), @EntId, 6940029, 0, 'D_EDIT', 'Дата последнего редактирования', 'date', NULL, NULL, NULL, NULL, 0, 0, 0, 1, NULL, NULL, 0, NULL, NULL, NULL, 0, 0, 1, 0, 0, NULL, NULL, NULL, 1, 'D_EDIT', 1, 'T_MO', NULL, NULL, NULL, NULL
WHERE NOT EXISTS(SELECT * FROM VCLib.T_ENTITIES_ATTRIBUTES where EntityID = @EntId AND Name = 'D_EDIT' AND IsAdditional = 0)

UPDATE VCLib.T_ENTITIES_ATTRIBUTES SET [Index] = 6940033, [AttributeType] = 0, [Name] = 'IsActive', [Description] = 'Активное', [SystemType] = 'bool', [MaxLength] = NULL, [Precision] = NULL, [Scale] = NULL, [DefaultFormat] = NULL, [IsCalculated] = 0, [IsFlag] = 0, [IsRequired] = 1, [Save] = 1, [LinkAttributeName] = NULL, [PathsAttributes] = NULL, [IsCashed] = 0, [RequiredAttributes] = NULL, [SortingAttribute] = NULL, [EnumType] = NULL, [IsIdentity] = 0, [IsCustom] = 0, [RemoveAction] = 1, [IsPrimaryKey] = 0, [ChoiceAttributeData] = NULL, [ParametersData] = NULL, [CustomsData] = NULL, [MappingType] = 1, [MappingName] = 'IsActive', [IsStored] = 1, [MappingTable] = 'T_MO', [MappingRefTable] = NULL, [RefTableSearchMode] = NULL, [RefTableHashFunc] = NULL, [AttrLexem] = NULL
WHERE EntityID = @EntId AND Name = 'IsActive' AND IsAdditional = 0
INSERT INTO VCLib.T_ENTITIES_ATTRIBUTES ([EntitiesAttributesId], [EntityID], [Index], [AttributeType], [Name], [Description], [SystemType], [MaxLength], [Precision], [Scale], [DefaultFormat], [IsCalculated], [IsFlag], [IsRequired], [Save], [LinkAttributeName], [PathsAttributes], [IsCashed], [RequiredAttributes], [SortingAttribute], [EnumType], [IsIdentity], [IsCustom], [RemoveAction], [IsPrimaryKey], [IsAdditional], [ChoiceAttributeData], [ParametersData], [CustomsData], [MappingType], [MappingName], [IsStored], [MappingTable], [MappingRefTable], [RefTableSearchMode], [RefTableHashFunc], [AttrLexem])
SELECT newid(), @EntId, 6940033, 0, 'IsActive', 'Активное', 'bool', NULL, NULL, NULL, NULL, 0, 0, 1, 1, NULL, NULL, 0, NULL, NULL, NULL, 0, 0, 1, 0, 0, NULL, NULL, NULL, 1, 'IsActive', 1, 'T_MO', NULL, NULL, NULL, NULL
WHERE NOT EXISTS(SELECT * FROM VCLib.T_ENTITIES_ATTRIBUTES where EntityID = @EntId AND Name = 'IsActive' AND IsAdditional = 0)

UPDATE VCLib.T_ENTITIES_ATTRIBUTES SET [Index] = 6940038, [AttributeType] = 0, [Name] = 'ShortFIODative', [Description] = 'ФИО в дательном падеже кратко', [SystemType] = 'string', [MaxLength] = 50, [Precision] = NULL, [Scale] = NULL, [DefaultFormat] = NULL, [IsCalculated] = 0, [IsFlag] = 0, [IsRequired] = 0, [Save] = 1, [LinkAttributeName] = NULL, [PathsAttributes] = NULL, [IsCashed] = 0, [RequiredAttributes] = NULL, [SortingAttribute] = NULL, [EnumType] = NULL, [IsIdentity] = 0, [IsCustom] = 0, [RemoveAction] = 1, [IsPrimaryKey] = 0, [ChoiceAttributeData] = NULL, [ParametersData] = NULL, [CustomsData] = NULL, [MappingType] = 1, [MappingName] = 'ShortFIODative', [IsStored] = 1, [MappingTable] = 'T_MO', [MappingRefTable] = NULL, [RefTableSearchMode] = NULL, [RefTableHashFunc] = NULL, [AttrLexem] = NULL
WHERE EntityID = @EntId AND Name = 'ShortFIODative' AND IsAdditional = 0
INSERT INTO VCLib.T_ENTITIES_ATTRIBUTES ([EntitiesAttributesId], [EntityID], [Index], [AttributeType], [Name], [Description], [SystemType], [MaxLength], [Precision], [Scale], [DefaultFormat], [IsCalculated], [IsFlag], [IsRequired], [Save], [LinkAttributeName], [PathsAttributes], [IsCashed], [RequiredAttributes], [SortingAttribute], [EnumType], [IsIdentity], [IsCustom], [RemoveAction], [IsPrimaryKey], [IsAdditional], [ChoiceAttributeData], [ParametersData], [CustomsData], [MappingType], [MappingName], [IsStored], [MappingTable], [MappingRefTable], [RefTableSearchMode], [RefTableHashFunc], [AttrLexem])
SELECT newid(), @EntId, 6940038, 0, 'ShortFIODative', 'ФИО в дательном падеже кратко', 'string', 50, NULL, NULL, NULL, 0, 0, 0, 1, NULL, NULL, 0, NULL, NULL, NULL, 0, 0, 1, 0, 0, NULL, NULL, NULL, 1, 'ShortFIODative', 1, 'T_MO', NULL, NULL, NULL, NULL
WHERE NOT EXISTS(SELECT * FROM VCLib.T_ENTITIES_ATTRIBUTES where EntityID = @EntId AND Name = 'ShortFIODative' AND IsAdditional = 0)

UPDATE VCLib.T_ENTITIES_ATTRIBUTES SET [Index] = 6940041, [AttributeType] = 0, [Name] = 'MO_NUMBER', [Description] = 'Номер МО', [SystemType] = 'string', [MaxLength] = 40, [Precision] = NULL, [Scale] = NULL, [DefaultFormat] = NULL, [IsCalculated] = 0, [IsFlag] = 0, [IsRequired] = 0, [Save] = 1, [LinkAttributeName] = NULL, [PathsAttributes] = NULL, [IsCashed] = 0, [RequiredAttributes] = NULL, [SortingAttribute] = NULL, [EnumType] = NULL, [IsIdentity] = 0, [IsCustom] = 0, [RemoveAction] = 1, [IsPrimaryKey] = 0, [ChoiceAttributeData] = NULL, [ParametersData] = NULL, [CustomsData] = NULL, [MappingType] = 1, [MappingName] = 'MO_NUMBER', [IsStored] = 1, [MappingTable] = 'T_MO', [MappingRefTable] = NULL, [RefTableSearchMode] = NULL, [RefTableHashFunc] = NULL, [AttrLexem] = NULL
WHERE EntityID = @EntId AND Name = 'MO_NUMBER' AND IsAdditional = 0
INSERT INTO VCLib.T_ENTITIES_ATTRIBUTES ([EntitiesAttributesId], [EntityID], [Index], [AttributeType], [Name], [Description], [SystemType], [MaxLength], [Precision], [Scale], [DefaultFormat], [IsCalculated], [IsFlag], [IsRequired], [Save], [LinkAttributeName], [PathsAttributes], [IsCashed], [RequiredAttributes], [SortingAttribute], [EnumType], [IsIdentity], [IsCustom], [RemoveAction], [IsPrimaryKey], [IsAdditional], [ChoiceAttributeData], [ParametersData], [CustomsData], [MappingType], [MappingName], [IsStored], [MappingTable], [MappingRefTable], [RefTableSearchMode], [RefTableHashFunc], [AttrLexem])
SELECT newid(), @EntId, 6940041, 0, 'MO_NUMBER', 'Номер МО', 'string', 40, NULL, NULL, NULL, 0, 0, 0, 1, NULL, NULL, 0, NULL, NULL, NULL, 0, 0, 1, 0, 0, NULL, NULL, NULL, 1, 'MO_NUMBER', 1, 'T_MO', NULL, NULL, NULL, NULL
WHERE NOT EXISTS(SELECT * FROM VCLib.T_ENTITIES_ATTRIBUTES where EntityID = @EntId AND Name = 'MO_NUMBER' AND IsAdditional = 0)

UPDATE VCLib.T_ENTITIES_ATTRIBUTES SET [Index] = 6940042, [AttributeType] = 0, [Name] = 'NAM_MOK', [Description] = 'Наименование МО краткое', [SystemType] = 'string', [MaxLength] = 250, [Precision] = NULL, [Scale] = NULL, [DefaultFormat] = NULL, [IsCalculated] = 0, [IsFlag] = 0, [IsRequired] = 1, [Save] = 1, [LinkAttributeName] = NULL, [PathsAttributes] = NULL, [IsCashed] = 0, [RequiredAttributes] = NULL, [SortingAttribute] = NULL, [EnumType] = NULL, [IsIdentity] = 0, [IsCustom] = 0, [RemoveAction] = 1, [IsPrimaryKey] = 0, [ChoiceAttributeData] = NULL, [ParametersData] = NULL, [CustomsData] = NULL, [MappingType] = 1, [MappingName] = 'NAM_MOK', [IsStored] = 1, [MappingTable] = 'T_MO', [MappingRefTable] = NULL, [RefTableSearchMode] = NULL, [RefTableHashFunc] = NULL, [AttrLexem] = NULL
WHERE EntityID = @EntId AND Name = 'NAM_MOK' AND IsAdditional = 0
INSERT INTO VCLib.T_ENTITIES_ATTRIBUTES ([EntitiesAttributesId], [EntityID], [Index], [AttributeType], [Name], [Description], [SystemType], [MaxLength], [Precision], [Scale], [DefaultFormat], [IsCalculated], [IsFlag], [IsRequired], [Save], [LinkAttributeName], [PathsAttributes], [IsCashed], [RequiredAttributes], [SortingAttribute], [EnumType], [IsIdentity], [IsCustom], [RemoveAction], [IsPrimaryKey], [IsAdditional], [ChoiceAttributeData], [ParametersData], [CustomsData], [MappingType], [MappingName], [IsStored], [MappingTable], [MappingRefTable], [RefTableSearchMode], [RefTableHashFunc], [AttrLexem])
SELECT newid(), @EntId, 6940042, 0, 'NAM_MOK', 'Наименование МО краткое', 'string', 250, NULL, NULL, NULL, 0, 0, 1, 1, NULL, NULL, 0, NULL, NULL, NULL, 0, 0, 1, 0, 0, NULL, NULL, NULL, 1, 'NAM_MOK', 1, 'T_MO', NULL, NULL, NULL, NULL
WHERE NOT EXISTS(SELECT * FROM VCLib.T_ENTITIES_ATTRIBUTES where EntityID = @EntId AND Name = 'NAM_MOK' AND IsAdditional = 0)

UPDATE VCLib.T_ENTITIES_ATTRIBUTES SET [Index] = 6940044, [AttributeType] = 0, [Name] = 'IsFondHolder', [Description] = 'Признак фондодержания', [SystemType] = 'bool', [MaxLength] = NULL, [Precision] = NULL, [Scale] = NULL, [DefaultFormat] = NULL, [IsCalculated] = 0, [IsFlag] = 0, [IsRequired] = 0, [Save] = 1, [LinkAttributeName] = NULL, [PathsAttributes] = NULL, [IsCashed] = 0, [RequiredAttributes] = NULL, [SortingAttribute] = NULL, [EnumType] = NULL, [IsIdentity] = 0, [IsCustom] = 0, [RemoveAction] = 1, [IsPrimaryKey] = 0, [ChoiceAttributeData] = NULL, [ParametersData] = NULL, [CustomsData] = NULL, [MappingType] = 1, [MappingName] = 'IsFondHolder', [IsStored] = 1, [MappingTable] = 'T_MO', [MappingRefTable] = NULL, [RefTableSearchMode] = NULL, [RefTableHashFunc] = NULL, [AttrLexem] = NULL
WHERE EntityID = @EntId AND Name = 'IsFondHolder' AND IsAdditional = 0
INSERT INTO VCLib.T_ENTITIES_ATTRIBUTES ([EntitiesAttributesId], [EntityID], [Index], [AttributeType], [Name], [Description], [SystemType], [MaxLength], [Precision], [Scale], [DefaultFormat], [IsCalculated], [IsFlag], [IsRequired], [Save], [LinkAttributeName], [PathsAttributes], [IsCashed], [RequiredAttributes], [SortingAttribute], [EnumType], [IsIdentity], [IsCustom], [RemoveAction], [IsPrimaryKey], [IsAdditional], [ChoiceAttributeData], [ParametersData], [CustomsData], [MappingType], [MappingName], [IsStored], [MappingTable], [MappingRefTable], [RefTableSearchMode], [RefTableHashFunc], [AttrLexem])
SELECT newid(), @EntId, 6940044, 0, 'IsFondHolder', 'Признак фондодержания', 'bool', NULL, NULL, NULL, NULL, 0, 0, 0, 1, NULL, NULL, 0, NULL, NULL, NULL, 0, 0, 1, 0, 0, NULL, NULL, NULL, 1, 'IsFondHolder', 1, 'T_MO', NULL, NULL, NULL, NULL
WHERE NOT EXISTS(SELECT * FROM VCLib.T_ENTITIES_ATTRIBUTES where EntityID = @EntId AND Name = 'IsFondHolder' AND IsAdditional = 0)

UPDATE VCLib.T_ENTITIES_ATTRIBUTES SET [Index] = 6940046, [AttributeType] = 0, [Name] = 'IsUsingDigitalSignature', [Description] = 'Признак использования ЭЦП', [SystemType] = 'bool', [MaxLength] = NULL, [Precision] = NULL, [Scale] = NULL, [DefaultFormat] = NULL, [IsCalculated] = 0, [IsFlag] = 0, [IsRequired] = 0, [Save] = 1, [LinkAttributeName] = NULL, [PathsAttributes] = NULL, [IsCashed] = 0, [RequiredAttributes] = NULL, [SortingAttribute] = NULL, [EnumType] = NULL, [IsIdentity] = 0, [IsCustom] = 0, [RemoveAction] = 1, [IsPrimaryKey] = 0, [ChoiceAttributeData] = NULL, [ParametersData] = NULL, [CustomsData] = NULL, [MappingType] = 1, [MappingName] = 'IsUsingDigitalSignature', [IsStored] = 1, [MappingTable] = 'T_MO', [MappingRefTable] = NULL, [RefTableSearchMode] = NULL, [RefTableHashFunc] = NULL, [AttrLexem] = NULL
WHERE EntityID = @EntId AND Name = 'IsUsingDigitalSignature' AND IsAdditional = 0
INSERT INTO VCLib.T_ENTITIES_ATTRIBUTES ([EntitiesAttributesId], [EntityID], [Index], [AttributeType], [Name], [Description], [SystemType], [MaxLength], [Precision], [Scale], [DefaultFormat], [IsCalculated], [IsFlag], [IsRequired], [Save], [LinkAttributeName], [PathsAttributes], [IsCashed], [RequiredAttributes], [SortingAttribute], [EnumType], [IsIdentity], [IsCustom], [RemoveAction], [IsPrimaryKey], [IsAdditional], [ChoiceAttributeData], [ParametersData], [CustomsData], [MappingType], [MappingName], [IsStored], [MappingTable], [MappingRefTable], [RefTableSearchMode], [RefTableHashFunc], [AttrLexem])
SELECT newid(), @EntId, 6940046, 0, 'IsUsingDigitalSignature', 'Признак использования ЭЦП', 'bool', NULL, NULL, NULL, NULL, 0, 0, 0, 1, NULL, NULL, 0, NULL, NULL, NULL, 0, 0, 1, 0, 0, NULL, NULL, NULL, 1, 'IsUsingDigitalSignature', 1, 'T_MO', NULL, NULL, NULL, NULL
WHERE NOT EXISTS(SELECT * FROM VCLib.T_ENTITIES_ATTRIBUTES where EntityID = @EntId AND Name = 'IsUsingDigitalSignature' AND IsAdditional = 0)

UPDATE VCLib.T_ENTITIES_ATTRIBUTES SET [Index] = 6970037, [AttributeType] = 0, [Name] = 'NAM_MFF', [Description] = 'Наименование МО в свободной форме', [SystemType] = 'string', [MaxLength] = 250, [Precision] = NULL, [Scale] = NULL, [DefaultFormat] = NULL, [IsCalculated] = 0, [IsFlag] = 0, [IsRequired] = 1, [Save] = 1, [LinkAttributeName] = NULL, [PathsAttributes] = NULL, [IsCashed] = 0, [RequiredAttributes] = NULL, [SortingAttribute] = NULL, [EnumType] = NULL, [IsIdentity] = 0, [IsCustom] = 0, [RemoveAction] = 1, [IsPrimaryKey] = 0, [ChoiceAttributeData] = NULL, [ParametersData] = NULL, [CustomsData] = NULL, [MappingType] = 1, [MappingName] = 'NAM_MFF', [IsStored] = 1, [MappingTable] = 'T_MO', [MappingRefTable] = NULL, [RefTableSearchMode] = NULL, [RefTableHashFunc] = NULL, [AttrLexem] = NULL
WHERE EntityID = @EntId AND Name = 'NAM_MFF' AND IsAdditional = 0
INSERT INTO VCLib.T_ENTITIES_ATTRIBUTES ([EntitiesAttributesId], [EntityID], [Index], [AttributeType], [Name], [Description], [SystemType], [MaxLength], [Precision], [Scale], [DefaultFormat], [IsCalculated], [IsFlag], [IsRequired], [Save], [LinkAttributeName], [PathsAttributes], [IsCashed], [RequiredAttributes], [SortingAttribute], [EnumType], [IsIdentity], [IsCustom], [RemoveAction], [IsPrimaryKey], [IsAdditional], [ChoiceAttributeData], [ParametersData], [CustomsData], [MappingType], [MappingName], [IsStored], [MappingTable], [MappingRefTable], [RefTableSearchMode], [RefTableHashFunc], [AttrLexem])
SELECT newid(), @EntId, 6970037, 0, 'NAM_MFF', 'Наименование МО в свободной форме', 'string', 250, NULL, NULL, NULL, 0, 0, 1, 1, NULL, NULL, 0, NULL, NULL, NULL, 0, 0, 1, 0, 0, NULL, NULL, NULL, 1, 'NAM_MFF', 1, 'T_MO', NULL, NULL, NULL, NULL
WHERE NOT EXISTS(SELECT * FROM VCLib.T_ENTITIES_ATTRIBUTES where EntityID = @EntId AND Name = 'NAM_MFF' AND IsAdditional = 0)

UPDATE VCLib.T_ENTITIES_ATTRIBUTES SET [Index] = 6940011, [AttributeType] = 1, [Name] = 'OKOPF', [Description] = 'ОКОПФ', [SystemType] = 'FIES.O005_OKOPF', [MaxLength] = NULL, [Precision] = NULL, [Scale] = NULL, [DefaultFormat] = NULL, [IsCalculated] = 0, [IsFlag] = 0, [IsRequired] = 0, [Save] = 1, [LinkAttributeName] = NULL, [PathsAttributes] = NULL, [IsCashed] = 0, [RequiredAttributes] = NULL, [SortingAttribute] = NULL, [EnumType] = NULL, [IsIdentity] = 0, [IsCustom] = 0, [RemoveAction] = 1, [IsPrimaryKey] = 0, [ChoiceAttributeData] = NULL, [ParametersData] = NULL, [CustomsData] = NULL, [MappingType] = 1, [MappingName] = 'OKOPF', [IsStored] = 1, [MappingTable] = 'T_MO', [MappingRefTable] = NULL, [RefTableSearchMode] = NULL, [RefTableHashFunc] = NULL, [AttrLexem] = NULL
WHERE EntityID = @EntId AND Name = 'OKOPF' AND IsAdditional = 0
INSERT INTO VCLib.T_ENTITIES_ATTRIBUTES ([EntitiesAttributesId], [EntityID], [Index], [AttributeType], [Name], [Description], [SystemType], [MaxLength], [Precision], [Scale], [DefaultFormat], [IsCalculated], [IsFlag], [IsRequired], [Save], [LinkAttributeName], [PathsAttributes], [IsCashed], [RequiredAttributes], [SortingAttribute], [EnumType], [IsIdentity], [IsCustom], [RemoveAction], [IsPrimaryKey], [IsAdditional], [ChoiceAttributeData], [ParametersData], [CustomsData], [MappingType], [MappingName], [IsStored], [MappingTable], [MappingRefTable], [RefTableSearchMode], [RefTableHashFunc], [AttrLexem])
SELECT newid(), @EntId, 6940011, 1, 'OKOPF', 'ОКОПФ', 'FIES.O005_OKOPF', NULL, NULL, NULL, NULL, 0, 0, 0, 1, NULL, NULL, 0, NULL, NULL, NULL, 0, 0, 1, 0, 0, NULL, NULL, NULL, 1, 'OKOPF', 1, 'T_MO', NULL, NULL, NULL, NULL
WHERE NOT EXISTS(SELECT * FROM VCLib.T_ENTITIES_ATTRIBUTES where EntityID = @EntId AND Name = 'OKOPF' AND IsAdditional = 0)

UPDATE VCLib.T_ENTITIES_ATTRIBUTES SET [Index] = 6940012, [AttributeType] = 1, [Name] = 'VEDPRI', [Description] = 'Ведомственная принадлежность МО', [SystemType] = 'FIES.F007_DEPARTMENT', [MaxLength] = NULL, [Precision] = NULL, [Scale] = NULL, [DefaultFormat] = NULL, [IsCalculated] = 0, [IsFlag] = 0, [IsRequired] = 0, [Save] = 1, [LinkAttributeName] = NULL, [PathsAttributes] = NULL, [IsCashed] = 0, [RequiredAttributes] = NULL, [SortingAttribute] = NULL, [EnumType] = NULL, [IsIdentity] = 0, [IsCustom] = 0, [RemoveAction] = 1, [IsPrimaryKey] = 0, [ChoiceAttributeData] = NULL, [ParametersData] = NULL, [CustomsData] = NULL, [MappingType] = 1, [MappingName] = 'VEDPRI', [IsStored] = 1, [MappingTable] = 'T_MO', [MappingRefTable] = NULL, [RefTableSearchMode] = NULL, [RefTableHashFunc] = NULL, [AttrLexem] = NULL
WHERE EntityID = @EntId AND Name = 'VEDPRI' AND IsAdditional = 0
INSERT INTO VCLib.T_ENTITIES_ATTRIBUTES ([EntitiesAttributesId], [EntityID], [Index], [AttributeType], [Name], [Description], [SystemType], [MaxLength], [Precision], [Scale], [DefaultFormat], [IsCalculated], [IsFlag], [IsRequired], [Save], [LinkAttributeName], [PathsAttributes], [IsCashed], [RequiredAttributes], [SortingAttribute], [EnumType], [IsIdentity], [IsCustom], [RemoveAction], [IsPrimaryKey], [IsAdditional], [ChoiceAttributeData], [ParametersData], [CustomsData], [MappingType], [MappingName], [IsStored], [MappingTable], [MappingRefTable], [RefTableSearchMode], [RefTableHashFunc], [AttrLexem])
SELECT newid(), @EntId, 6940012, 1, 'VEDPRI', 'Ведомственная принадлежность МО', 'FIES.F007_DEPARTMENT', NULL, NULL, NULL, NULL, 0, 0, 0, 1, NULL, NULL, 0, NULL, NULL, NULL, 0, 0, 1, 0, 0, NULL, NULL, NULL, 1, 'VEDPRI', 1, 'T_MO', NULL, NULL, NULL, NULL
WHERE NOT EXISTS(SELECT * FROM VCLib.T_ENTITIES_ATTRIBUTES where EntityID = @EntId AND Name = 'VEDPRI' AND IsAdditional = 0)

UPDATE VCLib.T_ENTITIES_ATTRIBUTES SET [Index] = 6940031, [AttributeType] = 1, [Name] = 'MoType', [Description] = 'Тип МО', [SystemType] = 'FIES.MO_TYPE', [MaxLength] = NULL, [Precision] = NULL, [Scale] = NULL, [DefaultFormat] = NULL, [IsCalculated] = 0, [IsFlag] = 0, [IsRequired] = 0, [Save] = 1, [LinkAttributeName] = NULL, [PathsAttributes] = '{MoTypeHistorys / MoType}', [IsCashed] = 0, [RequiredAttributes] = NULL, [SortingAttribute] = NULL, [EnumType] = NULL, [IsIdentity] = 0, [IsCustom] = 0, [RemoveAction] = 1, [IsPrimaryKey] = 0, [ChoiceAttributeData] = NULL, [ParametersData] = NULL, [CustomsData] = NULL, [MappingType] = 4, [MappingName] = NULL, [IsStored] = 1, [MappingTable] = NULL, [MappingRefTable] = NULL, [RefTableSearchMode] = NULL, [RefTableHashFunc] = NULL, [AttrLexem] = '<lx:ChildCount xmlns:lx="lexem"><condition><lx:Criterion type="&lt;=" xmlns:lx="lexem"><lx:Path OwnerQueryLevel="0" xmlns:lx="lexem"><lx:StepString name="DateBegin" xmlns:lx="lexem"></lx:StepString></lx:Path><lx:ParamHolder xmlns:lx="lexem"><lx:StepString name="CURRENT_DATETIME" xmlns:lx="lexem"></lx:StepString></lx:ParamHolder></lx:Criterion></condition><lx:Path OwnerQueryLevel="0" xmlns:lx="lexem"><lx:StepString name="MoTypeHistorys" xmlns:lx="lexem"></lx:StepString></lx:Path><lx:First xmlns:lx="lexem"><lx:Path OwnerQueryLevel="0" xmlns:lx="lexem"><lx:StepString name="MoType" xmlns:lx="lexem"></lx:StepString></lx:Path></lx:First><lx:Path OwnerQueryLevel="0" xmlns:lx="lexem"><lx:StepString name="DateBegin" xmlns:lx="lexem"></lx:StepString></lx:Path><lx:ConstOperand type="String" xmlns:lx="lexem"><![CDATA[desc]]></lx:ConstOperand></lx:ChildCount>'
WHERE EntityID = @EntId AND Name = 'MoType' AND IsAdditional = 0
INSERT INTO VCLib.T_ENTITIES_ATTRIBUTES ([EntitiesAttributesId], [EntityID], [Index], [AttributeType], [Name], [Description], [SystemType], [MaxLength], [Precision], [Scale], [DefaultFormat], [IsCalculated], [IsFlag], [IsRequired], [Save], [LinkAttributeName], [PathsAttributes], [IsCashed], [RequiredAttributes], [SortingAttribute], [EnumType], [IsIdentity], [IsCustom], [RemoveAction], [IsPrimaryKey], [IsAdditional], [ChoiceAttributeData], [ParametersData], [CustomsData], [MappingType], [MappingName], [IsStored], [MappingTable], [MappingRefTable], [RefTableSearchMode], [RefTableHashFunc], [AttrLexem])
SELECT newid(), @EntId, 6940031, 1, 'MoType', 'Тип МО', 'FIES.MO_TYPE', NULL, NULL, NULL, NULL, 0, 0, 0, 1, NULL, '{MoTypeHistorys / MoType}', 0, NULL, NULL, NULL, 0, 0, 1, 0, 0, NULL, NULL, NULL, 4, NULL, 1, NULL, NULL, NULL, NULL, '<lx:ChildCount xmlns:lx="lexem"><condition><lx:Criterion type="&lt;=" xmlns:lx="lexem"><lx:Path OwnerQueryLevel="0" xmlns:lx="lexem"><lx:StepString name="DateBegin" xmlns:lx="lexem"></lx:StepString></lx:Path><lx:ParamHolder xmlns:lx="lexem"><lx:StepString name="CURRENT_DATETIME" xmlns:lx="lexem"></lx:StepString></lx:ParamHolder></lx:Criterion></condition><lx:Path OwnerQueryLevel="0" xmlns:lx="lexem"><lx:StepString name="MoTypeHistorys" xmlns:lx="lexem"></lx:StepString></lx:Path><lx:First xmlns:lx="lexem"><lx:Path OwnerQueryLevel="0" xmlns:lx="lexem"><lx:StepString name="MoType" xmlns:lx="lexem"></lx:StepString></lx:Path></lx:First><lx:Path OwnerQueryLevel="0" xmlns:lx="lexem"><lx:StepString name="DateBegin" xmlns:lx="lexem"></lx:StepString></lx:Path><lx:ConstOperand type="String" xmlns:lx="lexem"><![CDATA[desc]]></lx:ConstOperand></lx:ChildCount>'
WHERE NOT EXISTS(SELECT * FROM VCLib.T_ENTITIES_ATTRIBUTES where EntityID = @EntId AND Name = 'MoType' AND IsAdditional = 0)

UPDATE VCLib.T_ENTITIES_ATTRIBUTES SET [Index] = 6940037, [AttributeType] = 1, [Name] = 'Rajonrt', [Description] = 'Район региона', [SystemType] = 'FIES.RAJONRT', [MaxLength] = NULL, [Precision] = NULL, [Scale] = NULL, [DefaultFormat] = NULL, [IsCalculated] = 0, [IsFlag] = 0, [IsRequired] = 0, [Save] = 1, [LinkAttributeName] = NULL, [PathsAttributes] = NULL, [IsCashed] = 0, [RequiredAttributes] = NULL, [SortingAttribute] = NULL, [EnumType] = NULL, [IsIdentity] = 0, [IsCustom] = 0, [RemoveAction] = 1, [IsPrimaryKey] = 0, [ChoiceAttributeData] = NULL, [ParametersData] = NULL, [CustomsData] = NULL, [MappingType] = 1, [MappingName] = 'Rajonrt', [IsStored] = 1, [MappingTable] = 'T_MO', [MappingRefTable] = NULL, [RefTableSearchMode] = NULL, [RefTableHashFunc] = NULL, [AttrLexem] = NULL
WHERE EntityID = @EntId AND Name = 'Rajonrt' AND IsAdditional = 0
INSERT INTO VCLib.T_ENTITIES_ATTRIBUTES ([EntitiesAttributesId], [EntityID], [Index], [AttributeType], [Name], [Description], [SystemType], [MaxLength], [Precision], [Scale], [DefaultFormat], [IsCalculated], [IsFlag], [IsRequired], [Save], [LinkAttributeName], [PathsAttributes], [IsCashed], [RequiredAttributes], [SortingAttribute], [EnumType], [IsIdentity], [IsCustom], [RemoveAction], [IsPrimaryKey], [IsAdditional], [ChoiceAttributeData], [ParametersData], [CustomsData], [MappingType], [MappingName], [IsStored], [MappingTable], [MappingRefTable], [RefTableSearchMode], [RefTableHashFunc], [AttrLexem])
SELECT newid(), @EntId, 6940037, 1, 'Rajonrt', 'Район региона', 'FIES.RAJONRT', NULL, NULL, NULL, NULL, 0, 0, 0, 1, NULL, NULL, 0, NULL, NULL, NULL, 0, 0, 1, 0, 0, NULL, NULL, NULL, 1, 'Rajonrt', 1, 'T_MO', NULL, NULL, NULL, NULL
WHERE NOT EXISTS(SELECT * FROM VCLib.T_ENTITIES_ATTRIBUTES where EntityID = @EntId AND Name = 'Rajonrt' AND IsAdditional = 0)

UPDATE VCLib.T_ENTITIES_ATTRIBUTES SET [Index] = 6940047, [AttributeType] = 2, [Name] = 'MoLicenses', [Description] = 'Лицензия МО', [SystemType] = 'FIES.MO_LICENSE', [MaxLength] = NULL, [Precision] = NULL, [Scale] = NULL, [DefaultFormat] = NULL, [IsCalculated] = 0, [IsFlag] = 0, [IsRequired] = 0, [Save] = 1, [LinkAttributeName] = 'Mo', [PathsAttributes] = NULL, [IsCashed] = 0, [RequiredAttributes] = NULL, [SortingAttribute] = NULL, [EnumType] = NULL, [IsIdentity] = 0, [IsCustom] = 0, [RemoveAction] = 1, [IsPrimaryKey] = 0, [ChoiceAttributeData] = NULL, [ParametersData] = NULL, [CustomsData] = NULL, [MappingType] = 0, [MappingName] = NULL, [IsStored] = 1, [MappingTable] = NULL, [MappingRefTable] = NULL, [RefTableSearchMode] = NULL, [RefTableHashFunc] = NULL, [AttrLexem] = NULL
WHERE EntityID = @EntId AND Name = 'MoLicenses' AND IsAdditional = 0
INSERT INTO VCLib.T_ENTITIES_ATTRIBUTES ([EntitiesAttributesId], [EntityID], [Index], [AttributeType], [Name], [Description], [SystemType], [MaxLength], [Precision], [Scale], [DefaultFormat], [IsCalculated], [IsFlag], [IsRequired], [Save], [LinkAttributeName], [PathsAttributes], [IsCashed], [RequiredAttributes], [SortingAttribute], [EnumType], [IsIdentity], [IsCustom], [RemoveAction], [IsPrimaryKey], [IsAdditional], [ChoiceAttributeData], [ParametersData], [CustomsData], [MappingType], [MappingName], [IsStored], [MappingTable], [MappingRefTable], [RefTableSearchMode], [RefTableHashFunc], [AttrLexem])
SELECT newid(), @EntId, 6940047, 2, 'MoLicenses', 'Лицензия МО', 'FIES.MO_LICENSE', NULL, NULL, NULL, NULL, 0, 0, 0, 1, 'Mo', NULL, 0, NULL, NULL, NULL, 0, 0, 1, 0, 0, NULL, NULL, NULL, 0, NULL, 1, NULL, NULL, NULL, NULL, NULL
WHERE NOT EXISTS(SELECT * FROM VCLib.T_ENTITIES_ATTRIBUTES where EntityID = @EntId AND Name = 'MoLicenses' AND IsAdditional = 0)

UPDATE VCLib.T_ENTITIES_ATTRIBUTES SET [Index] = 6940048, [AttributeType] = 2, [Name] = 'Coefficients', [Description] = 'Коэффициенты', [SystemType] = 'FIES.COEFFICIENT', [MaxLength] = NULL, [Precision] = NULL, [Scale] = NULL, [DefaultFormat] = NULL, [IsCalculated] = 0, [IsFlag] = 0, [IsRequired] = 0, [Save] = 1, [LinkAttributeName] = 'Mo', [PathsAttributes] = NULL, [IsCashed] = 0, [RequiredAttributes] = NULL, [SortingAttribute] = NULL, [EnumType] = NULL, [IsIdentity] = 0, [IsCustom] = 0, [RemoveAction] = 1, [IsPrimaryKey] = 0, [ChoiceAttributeData] = NULL, [ParametersData] = NULL, [CustomsData] = NULL, [MappingType] = 0, [MappingName] = NULL, [IsStored] = 1, [MappingTable] = NULL, [MappingRefTable] = NULL, [RefTableSearchMode] = NULL, [RefTableHashFunc] = NULL, [AttrLexem] = NULL
WHERE EntityID = @EntId AND Name = 'Coefficients' AND IsAdditional = 0
INSERT INTO VCLib.T_ENTITIES_ATTRIBUTES ([EntitiesAttributesId], [EntityID], [Index], [AttributeType], [Name], [Description], [SystemType], [MaxLength], [Precision], [Scale], [DefaultFormat], [IsCalculated], [IsFlag], [IsRequired], [Save], [LinkAttributeName], [PathsAttributes], [IsCashed], [RequiredAttributes], [SortingAttribute], [EnumType], [IsIdentity], [IsCustom], [RemoveAction], [IsPrimaryKey], [IsAdditional], [ChoiceAttributeData], [ParametersData], [CustomsData], [MappingType], [MappingName], [IsStored], [MappingTable], [MappingRefTable], [RefTableSearchMode], [RefTableHashFunc], [AttrLexem])
SELECT newid(), @EntId, 6940048, 2, 'Coefficients', 'Коэффициенты', 'FIES.COEFFICIENT', NULL, NULL, NULL, NULL, 0, 0, 0, 1, 'Mo', NULL, 0, NULL, NULL, NULL, 0, 0, 1, 0, 0, NULL, NULL, NULL, 0, NULL, 1, NULL, NULL, NULL, NULL, NULL
WHERE NOT EXISTS(SELECT * FROM VCLib.T_ENTITIES_ATTRIBUTES where EntityID = @EntId AND Name = 'Coefficients' AND IsAdditional = 0)

UPDATE VCLib.T_ENTITIES_ATTRIBUTES SET [Index] = 6940049, [AttributeType] = 2, [Name] = 'SmoCoefMonthValuesDefaults', [Description] = 'Стандартные значения коэффициентов планов по СМО для МО', [SystemType] = 'FIES.SMO_COEF_MONTH_VALUES_DEFAULT', [MaxLength] = NULL, [Precision] = NULL, [Scale] = NULL, [DefaultFormat] = NULL, [IsCalculated] = 0, [IsFlag] = 0, [IsRequired] = 0, [Save] = 1, [LinkAttributeName] = 'Mo', [PathsAttributes] = NULL, [IsCashed] = 0, [RequiredAttributes] = NULL, [SortingAttribute] = 'Smo', [EnumType] = NULL, [IsIdentity] = 0, [IsCustom] = 0, [RemoveAction] = 1, [IsPrimaryKey] = 0, [ChoiceAttributeData] = NULL, [ParametersData] = NULL, [CustomsData] = NULL, [MappingType] = 0, [MappingName] = NULL, [IsStored] = 1, [MappingTable] = NULL, [MappingRefTable] = NULL, [RefTableSearchMode] = NULL, [RefTableHashFunc] = NULL, [AttrLexem] = NULL
WHERE EntityID = @EntId AND Name = 'SmoCoefMonthValuesDefaults' AND IsAdditional = 0
INSERT INTO VCLib.T_ENTITIES_ATTRIBUTES ([EntitiesAttributesId], [EntityID], [Index], [AttributeType], [Name], [Description], [SystemType], [MaxLength], [Precision], [Scale], [DefaultFormat], [IsCalculated], [IsFlag], [IsRequired], [Save], [LinkAttributeName], [PathsAttributes], [IsCashed], [RequiredAttributes], [SortingAttribute], [EnumType], [IsIdentity], [IsCustom], [RemoveAction], [IsPrimaryKey], [IsAdditional], [ChoiceAttributeData], [ParametersData], [CustomsData], [MappingType], [MappingName], [IsStored], [MappingTable], [MappingRefTable], [RefTableSearchMode], [RefTableHashFunc], [AttrLexem])
SELECT newid(), @EntId, 6940049, 2, 'SmoCoefMonthValuesDefaults', 'Стандартные значения коэффициентов планов по СМО для МО', 'FIES.SMO_COEF_MONTH_VALUES_DEFAULT', NULL, NULL, NULL, NULL, 0, 0, 0, 1, 'Mo', NULL, 0, NULL, 'Smo', NULL, 0, 0, 1, 0, 0, NULL, NULL, NULL, 0, NULL, 1, NULL, NULL, NULL, NULL, NULL
WHERE NOT EXISTS(SELECT * FROM VCLib.T_ENTITIES_ATTRIBUTES where EntityID = @EntId AND Name = 'SmoCoefMonthValuesDefaults' AND IsAdditional = 0)

UPDATE VCLib.T_ENTITIES_ATTRIBUTES SET [Index] = 6970038, [AttributeType] = 2, [Name] = 'SmoCoefMonthValuesExceptions', [Description] = 'Исключения коэффициентов планов по СМО для МО', [SystemType] = 'FIES.SMO_COEF_MONTH_VALUES_EXCEPTION', [MaxLength] = NULL, [Precision] = NULL, [Scale] = NULL, [DefaultFormat] = NULL, [IsCalculated] = 0, [IsFlag] = 0, [IsRequired] = 0, [Save] = 1, [LinkAttributeName] = 'Mo', [PathsAttributes] = NULL, [IsCashed] = 0, [RequiredAttributes] = NULL, [SortingAttribute] = NULL, [EnumType] = NULL, [IsIdentity] = 0, [IsCustom] = 0, [RemoveAction] = 1, [IsPrimaryKey] = 0, [ChoiceAttributeData] = NULL, [ParametersData] = NULL, [CustomsData] = NULL, [MappingType] = 0, [MappingName] = NULL, [IsStored] = 1, [MappingTable] = NULL, [MappingRefTable] = NULL, [RefTableSearchMode] = NULL, [RefTableHashFunc] = NULL, [AttrLexem] = NULL
WHERE EntityID = @EntId AND Name = 'SmoCoefMonthValuesExceptions' AND IsAdditional = 0
INSERT INTO VCLib.T_ENTITIES_ATTRIBUTES ([EntitiesAttributesId], [EntityID], [Index], [AttributeType], [Name], [Description], [SystemType], [MaxLength], [Precision], [Scale], [DefaultFormat], [IsCalculated], [IsFlag], [IsRequired], [Save], [LinkAttributeName], [PathsAttributes], [IsCashed], [RequiredAttributes], [SortingAttribute], [EnumType], [IsIdentity], [IsCustom], [RemoveAction], [IsPrimaryKey], [IsAdditional], [ChoiceAttributeData], [ParametersData], [CustomsData], [MappingType], [MappingName], [IsStored], [MappingTable], [MappingRefTable], [RefTableSearchMode], [RefTableHashFunc], [AttrLexem])
SELECT newid(), @EntId, 6970038, 2, 'SmoCoefMonthValuesExceptions', 'Исключения коэффициентов планов по СМО для МО', 'FIES.SMO_COEF_MONTH_VALUES_EXCEPTION', NULL, NULL, NULL, NULL, 0, 0, 0, 1, 'Mo', NULL, 0, NULL, NULL, NULL, 0, 0, 1, 0, 0, NULL, NULL, NULL, 0, NULL, 1, NULL, NULL, NULL, NULL, NULL
WHERE NOT EXISTS(SELECT * FROM VCLib.T_ENTITIES_ATTRIBUTES where EntityID = @EntId AND Name = 'SmoCoefMonthValuesExceptions' AND IsAdditional = 0)

UPDATE VCLib.T_ENTITIES_ATTRIBUTES SET [Index] = 6940013, [AttributeType] = 4, [Name] = 'ORG', [Description] = 'Признак подчиненности', [SystemType] = '', [MaxLength] = NULL, [Precision] = NULL, [Scale] = NULL, [DefaultFormat] = NULL, [IsCalculated] = 0, [IsFlag] = 0, [IsRequired] = 1, [Save] = 1, [LinkAttributeName] = NULL, [PathsAttributes] = NULL, [IsCashed] = 0, [RequiredAttributes] = NULL, [SortingAttribute] = NULL, [EnumType] = NULL, [IsIdentity] = 0, [IsCustom] = 0, [RemoveAction] = 1, [IsPrimaryKey] = 0, [ChoiceAttributeData] = '<?xml version="1.0" encoding="utf-16"?><ChoiceItems xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><ChoiceItem Name="Головная организация" Index="1"></ChoiceItem><ChoiceItem Name="Филиал" Index="2"></ChoiceItem></ChoiceItems>', [ParametersData] = NULL, [CustomsData] = NULL, [MappingType] = 1, [MappingName] = 'ORG', [IsStored] = 1, [MappingTable] = 'T_MO', [MappingRefTable] = NULL, [RefTableSearchMode] = NULL, [RefTableHashFunc] = NULL, [AttrLexem] = NULL
WHERE EntityID = @EntId AND Name = 'ORG' AND IsAdditional = 0
INSERT INTO VCLib.T_ENTITIES_ATTRIBUTES ([EntitiesAttributesId], [EntityID], [Index], [AttributeType], [Name], [Description], [SystemType], [MaxLength], [Precision], [Scale], [DefaultFormat], [IsCalculated], [IsFlag], [IsRequired], [Save], [LinkAttributeName], [PathsAttributes], [IsCashed], [RequiredAttributes], [SortingAttribute], [EnumType], [IsIdentity], [IsCustom], [RemoveAction], [IsPrimaryKey], [IsAdditional], [ChoiceAttributeData], [ParametersData], [CustomsData], [MappingType], [MappingName], [IsStored], [MappingTable], [MappingRefTable], [RefTableSearchMode], [RefTableHashFunc], [AttrLexem])
SELECT newid(), @EntId, 6940013, 4, 'ORG', 'Признак подчиненности', '', NULL, NULL, NULL, NULL, 0, 0, 1, 1, NULL, NULL, 0, NULL, NULL, NULL, 0, 0, 1, 0, 0, '<?xml version="1.0" encoding="utf-16"?><ChoiceItems xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><ChoiceItem Name="Головная организация" Index="1"></ChoiceItem><ChoiceItem Name="Филиал" Index="2"></ChoiceItem></ChoiceItems>', NULL, NULL, 1, 'ORG', 1, 'T_MO', NULL, NULL, NULL, NULL
WHERE NOT EXISTS(SELECT * FROM VCLib.T_ENTITIES_ATTRIBUTES where EntityID = @EntId AND Name = 'ORG' AND IsAdditional = 0)

UPDATE VCLib.T_ENTITIES_ATTRIBUTES SET [Index] = 6940005, [AttributeType] = 2, [Name] = 'PlanPeriodMoLinks', [Description] = 'Cвязка с отчетным периодом', [SystemType] = 'FIES.PLAN_PERIOD_MO_LINK', [MaxLength] = NULL, [Precision] = NULL, [Scale] = NULL, [DefaultFormat] = NULL, [IsCalculated] = 0, [IsFlag] = 0, [IsRequired] = 0, [Save] = 1, [LinkAttributeName] = 'Mo', [PathsAttributes] = NULL, [IsCashed] = 0, [RequiredAttributes] = NULL, [SortingAttribute] = NULL, [EnumType] = NULL, [IsIdentity] = 0, [IsCustom] = 0, [RemoveAction] = 1, [IsPrimaryKey] = 0, [ChoiceAttributeData] = NULL, [ParametersData] = NULL, [CustomsData] = NULL, [MappingType] = 0, [MappingName] = NULL, [IsStored] = 1, [MappingTable] = NULL, [MappingRefTable] = NULL, [RefTableSearchMode] = NULL, [RefTableHashFunc] = NULL, [AttrLexem] = NULL
WHERE EntityID = @EntId AND Name = 'PlanPeriodMoLinks' AND IsAdditional = 0
INSERT INTO VCLib.T_ENTITIES_ATTRIBUTES ([EntitiesAttributesId], [EntityID], [Index], [AttributeType], [Name], [Description], [SystemType], [MaxLength], [Precision], [Scale], [DefaultFormat], [IsCalculated], [IsFlag], [IsRequired], [Save], [LinkAttributeName], [PathsAttributes], [IsCashed], [RequiredAttributes], [SortingAttribute], [EnumType], [IsIdentity], [IsCustom], [RemoveAction], [IsPrimaryKey], [IsAdditional], [ChoiceAttributeData], [ParametersData], [CustomsData], [MappingType], [MappingName], [IsStored], [MappingTable], [MappingRefTable], [RefTableSearchMode], [RefTableHashFunc], [AttrLexem])
SELECT newid(), @EntId, 6940005, 2, 'PlanPeriodMoLinks', 'Cвязка с отчетным периодом', 'FIES.PLAN_PERIOD_MO_LINK', NULL, NULL, NULL, NULL, 0, 0, 0, 1, 'Mo', NULL, 0, NULL, NULL, NULL, 0, 0, 1, 0, 0, NULL, NULL, NULL, 0, NULL, 1, NULL, NULL, NULL, NULL, NULL
WHERE NOT EXISTS(SELECT * FROM VCLib.T_ENTITIES_ATTRIBUTES where EntityID = @EntId AND Name = 'PlanPeriodMoLinks' AND IsAdditional = 0)

UPDATE VCLib.T_ENTITIES_ATTRIBUTES SET [Index] = 6940020, [AttributeType] = 4, [Name] = 'MoOwnershipType', [Description] = 'Форма собственности', [SystemType] = '', [MaxLength] = NULL, [Precision] = NULL, [Scale] = NULL, [DefaultFormat] = NULL, [IsCalculated] = 0, [IsFlag] = 0, [IsRequired] = 1, [Save] = 1, [LinkAttributeName] = NULL, [PathsAttributes] = NULL, [IsCashed] = 0, [RequiredAttributes] = NULL, [SortingAttribute] = NULL, [EnumType] = NULL, [IsIdentity] = 0, [IsCustom] = 0, [RemoveAction] = 1, [IsPrimaryKey] = 0, [ChoiceAttributeData] = '<?xml version="1.0" encoding="utf-16"?><ChoiceItems xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><ChoiceItem Name="Региональное" Index="0"></ChoiceItem><ChoiceItem Name="Федеральное" Index="1"></ChoiceItem><ChoiceItem Name="Другое" Index="2"></ChoiceItem></ChoiceItems>', [ParametersData] = NULL, [CustomsData] = NULL, [MappingType] = 1, [MappingName] = 'MoOwnershipType', [IsStored] = 1, [MappingTable] = 'T_MO', [MappingRefTable] = NULL, [RefTableSearchMode] = NULL, [RefTableHashFunc] = NULL, [AttrLexem] = NULL
WHERE EntityID = @EntId AND Name = 'MoOwnershipType' AND IsAdditional = 0
INSERT INTO VCLib.T_ENTITIES_ATTRIBUTES ([EntitiesAttributesId], [EntityID], [Index], [AttributeType], [Name], [Description], [SystemType], [MaxLength], [Precision], [Scale], [DefaultFormat], [IsCalculated], [IsFlag], [IsRequired], [Save], [LinkAttributeName], [PathsAttributes], [IsCashed], [RequiredAttributes], [SortingAttribute], [EnumType], [IsIdentity], [IsCustom], [RemoveAction], [IsPrimaryKey], [IsAdditional], [ChoiceAttributeData], [ParametersData], [CustomsData], [MappingType], [MappingName], [IsStored], [MappingTable], [MappingRefTable], [RefTableSearchMode], [RefTableHashFunc], [AttrLexem])
SELECT newid(), @EntId, 6940020, 4, 'MoOwnershipType', 'Форма собственности', '', NULL, NULL, NULL, NULL, 0, 0, 1, 1, NULL, NULL, 0, NULL, NULL, NULL, 0, 0, 1, 0, 0, '<?xml version="1.0" encoding="utf-16"?><ChoiceItems xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><ChoiceItem Name="Региональное" Index="0"></ChoiceItem><ChoiceItem Name="Федеральное" Index="1"></ChoiceItem><ChoiceItem Name="Другое" Index="2"></ChoiceItem></ChoiceItems>', NULL, NULL, 1, 'MoOwnershipType', 1, 'T_MO', NULL, NULL, NULL, NULL
WHERE NOT EXISTS(SELECT * FROM VCLib.T_ENTITIES_ATTRIBUTES where EntityID = @EntId AND Name = 'MoOwnershipType' AND IsAdditional = 0)

UPDATE VCLib.T_ENTITIES_ATTRIBUTES SET [Index] = 6970041, [AttributeType] = 2, [Name] = 'MoDepartments', [Description] = 'Отделения', [SystemType] = 'FIES.MO_DEPARTMENT', [MaxLength] = NULL, [Precision] = NULL, [Scale] = NULL, [DefaultFormat] = NULL, [IsCalculated] = 0, [IsFlag] = 0, [IsRequired] = 0, [Save] = 1, [LinkAttributeName] = 'Mo', [PathsAttributes] = NULL, [IsCashed] = 0, [RequiredAttributes] = NULL, [SortingAttribute] = NULL, [EnumType] = NULL, [IsIdentity] = 0, [IsCustom] = 0, [RemoveAction] = 1, [IsPrimaryKey] = 0, [ChoiceAttributeData] = NULL, [ParametersData] = NULL, [CustomsData] = NULL, [MappingType] = 0, [MappingName] = NULL, [IsStored] = 1, [MappingTable] = NULL, [MappingRefTable] = NULL, [RefTableSearchMode] = NULL, [RefTableHashFunc] = NULL, [AttrLexem] = NULL
WHERE EntityID = @EntId AND Name = 'MoDepartments' AND IsAdditional = 0
INSERT INTO VCLib.T_ENTITIES_ATTRIBUTES ([EntitiesAttributesId], [EntityID], [Index], [AttributeType], [Name], [Description], [SystemType], [MaxLength], [Precision], [Scale], [DefaultFormat], [IsCalculated], [IsFlag], [IsRequired], [Save], [LinkAttributeName], [PathsAttributes], [IsCashed], [RequiredAttributes], [SortingAttribute], [EnumType], [IsIdentity], [IsCustom], [RemoveAction], [IsPrimaryKey], [IsAdditional], [ChoiceAttributeData], [ParametersData], [CustomsData], [MappingType], [MappingName], [IsStored], [MappingTable], [MappingRefTable], [RefTableSearchMode], [RefTableHashFunc], [AttrLexem])
SELECT newid(), @EntId, 6970041, 2, 'MoDepartments', 'Отделения', 'FIES.MO_DEPARTMENT', NULL, NULL, NULL, NULL, 0, 0, 0, 1, 'Mo', NULL, 0, NULL, NULL, NULL, 0, 0, 1, 0, 0, NULL, NULL, NULL, 0, NULL, 1, NULL, NULL, NULL, NULL, NULL
WHERE NOT EXISTS(SELECT * FROM VCLib.T_ENTITIES_ATTRIBUTES where EntityID = @EntId AND Name = 'MoDepartments' AND IsAdditional = 0)

UPDATE VCLib.T_ENTITIES_ATTRIBUTES SET [Index] = 6970042, [AttributeType] = 0, [Name] = 'KDsp', [Description] = 'Коэффициент содержания структурных подразделений', [SystemType] = 'float', [MaxLength] = NULL, [Precision] = 12, [Scale] = 9, [DefaultFormat] = NULL, [IsCalculated] = 0, [IsFlag] = 0, [IsRequired] = 0, [Save] = 1, [LinkAttributeName] = NULL, [PathsAttributes] = NULL, [IsCashed] = 0, [RequiredAttributes] = NULL, [SortingAttribute] = NULL, [EnumType] = NULL, [IsIdentity] = 0, [IsCustom] = 0, [RemoveAction] = 1, [IsPrimaryKey] = 0, [ChoiceAttributeData] = NULL, [ParametersData] = NULL, [CustomsData] = NULL, [MappingType] = 1, [MappingName] = 'KDsp', [IsStored] = 1, [MappingTable] = 'T_MO', [MappingRefTable] = NULL, [RefTableSearchMode] = NULL, [RefTableHashFunc] = NULL, [AttrLexem] = NULL
WHERE EntityID = @EntId AND Name = 'KDsp' AND IsAdditional = 0
INSERT INTO VCLib.T_ENTITIES_ATTRIBUTES ([EntitiesAttributesId], [EntityID], [Index], [AttributeType], [Name], [Description], [SystemType], [MaxLength], [Precision], [Scale], [DefaultFormat], [IsCalculated], [IsFlag], [IsRequired], [Save], [LinkAttributeName], [PathsAttributes], [IsCashed], [RequiredAttributes], [SortingAttribute], [EnumType], [IsIdentity], [IsCustom], [RemoveAction], [IsPrimaryKey], [IsAdditional], [ChoiceAttributeData], [ParametersData], [CustomsData], [MappingType], [MappingName], [IsStored], [MappingTable], [MappingRefTable], [RefTableSearchMode], [RefTableHashFunc], [AttrLexem])
SELECT newid(), @EntId, 6970042, 0, 'KDsp', 'Коэффициент содержания структурных подразделений', 'float', NULL, 12, 9, NULL, 0, 0, 0, 1, NULL, NULL, 0, NULL, NULL, NULL, 0, 0, 1, 0, 0, NULL, NULL, NULL, 1, 'KDsp', 1, 'T_MO', NULL, NULL, NULL, NULL
WHERE NOT EXISTS(SELECT * FROM VCLib.T_ENTITIES_ATTRIBUTES where EntityID = @EntId AND Name = 'KDsp' AND IsAdditional = 0)

UPDATE VCLib.T_ENTITIES_ATTRIBUTES SET [Index] = 6970043, [AttributeType] = 0, [Name] = 'KDpn', [Description] = 'Коэффициент плотности населения', [SystemType] = 'float', [MaxLength] = NULL, [Precision] = 12, [Scale] = 9, [DefaultFormat] = NULL, [IsCalculated] = 0, [IsFlag] = 0, [IsRequired] = 0, [Save] = 1, [LinkAttributeName] = NULL, [PathsAttributes] = NULL, [IsCashed] = 0, [RequiredAttributes] = NULL, [SortingAttribute] = NULL, [EnumType] = NULL, [IsIdentity] = 0, [IsCustom] = 0, [RemoveAction] = 1, [IsPrimaryKey] = 0, [ChoiceAttributeData] = NULL, [ParametersData] = NULL, [CustomsData] = NULL, [MappingType] = 1, [MappingName] = 'KDpn', [IsStored] = 1, [MappingTable] = 'T_MO', [MappingRefTable] = NULL, [RefTableSearchMode] = NULL, [RefTableHashFunc] = NULL, [AttrLexem] = NULL
WHERE EntityID = @EntId AND Name = 'KDpn' AND IsAdditional = 0
INSERT INTO VCLib.T_ENTITIES_ATTRIBUTES ([EntitiesAttributesId], [EntityID], [Index], [AttributeType], [Name], [Description], [SystemType], [MaxLength], [Precision], [Scale], [DefaultFormat], [IsCalculated], [IsFlag], [IsRequired], [Save], [LinkAttributeName], [PathsAttributes], [IsCashed], [RequiredAttributes], [SortingAttribute], [EnumType], [IsIdentity], [IsCustom], [RemoveAction], [IsPrimaryKey], [IsAdditional], [ChoiceAttributeData], [ParametersData], [CustomsData], [MappingType], [MappingName], [IsStored], [MappingTable], [MappingRefTable], [RefTableSearchMode], [RefTableHashFunc], [AttrLexem])
SELECT newid(), @EntId, 6970043, 0, 'KDpn', 'Коэффициент плотности населения', 'float', NULL, 12, 9, NULL, 0, 0, 0, 1, NULL, NULL, 0, NULL, NULL, NULL, 0, 0, 1, 0, 0, NULL, NULL, NULL, 1, 'KDpn', 1, 'T_MO', NULL, NULL, NULL, NULL
WHERE NOT EXISTS(SELECT * FROM VCLib.T_ENTITIES_ATTRIBUTES where EntityID = @EntId AND Name = 'KDpn' AND IsAdditional = 0)

UPDATE VCLib.T_ENTITIES_ATTRIBUTES SET [Index] = 6970044, [AttributeType] = 0, [Name] = 'KDsi', [Description] = 'Коэффициент на содержание имущества МО', [SystemType] = 'float', [MaxLength] = NULL, [Precision] = 12, [Scale] = 9, [DefaultFormat] = NULL, [IsCalculated] = 0, [IsFlag] = 0, [IsRequired] = 0, [Save] = 1, [LinkAttributeName] = NULL, [PathsAttributes] = NULL, [IsCashed] = 0, [RequiredAttributes] = NULL, [SortingAttribute] = NULL, [EnumType] = NULL, [IsIdentity] = 0, [IsCustom] = 0, [RemoveAction] = 1, [IsPrimaryKey] = 0, [ChoiceAttributeData] = NULL, [ParametersData] = NULL, [CustomsData] = NULL, [MappingType] = 1, [MappingName] = 'KDsi', [IsStored] = 1, [MappingTable] = 'T_MO', [MappingRefTable] = NULL, [RefTableSearchMode] = NULL, [RefTableHashFunc] = NULL, [AttrLexem] = NULL
WHERE EntityID = @EntId AND Name = 'KDsi' AND IsAdditional = 0
INSERT INTO VCLib.T_ENTITIES_ATTRIBUTES ([EntitiesAttributesId], [EntityID], [Index], [AttributeType], [Name], [Description], [SystemType], [MaxLength], [Precision], [Scale], [DefaultFormat], [IsCalculated], [IsFlag], [IsRequired], [Save], [LinkAttributeName], [PathsAttributes], [IsCashed], [RequiredAttributes], [SortingAttribute], [EnumType], [IsIdentity], [IsCustom], [RemoveAction], [IsPrimaryKey], [IsAdditional], [ChoiceAttributeData], [ParametersData], [CustomsData], [MappingType], [MappingName], [IsStored], [MappingTable], [MappingRefTable], [RefTableSearchMode], [RefTableHashFunc], [AttrLexem])
SELECT newid(), @EntId, 6970044, 0, 'KDsi', 'Коэффициент на содержание имущества МО', 'float', NULL, 12, 9, NULL, 0, 0, 0, 1, NULL, NULL, 0, NULL, NULL, NULL, 0, 0, 1, 0, 0, NULL, NULL, NULL, 1, 'KDsi', 1, 'T_MO', NULL, NULL, NULL, NULL
WHERE NOT EXISTS(SELECT * FROM VCLib.T_ENTITIES_ATTRIBUTES where EntityID = @EntId AND Name = 'KDsi' AND IsAdditional = 0)

UPDATE VCLib.T_ENTITIES_ATTRIBUTES SET [Index] = 6970045, [AttributeType] = 0, [Name] = 'KDzp', [Description] = 'коэффициент уровня заработной платы', [SystemType] = 'float', [MaxLength] = NULL, [Precision] = 12, [Scale] = 9, [DefaultFormat] = NULL, [IsCalculated] = 0, [IsFlag] = 0, [IsRequired] = 0, [Save] = 1, [LinkAttributeName] = NULL, [PathsAttributes] = NULL, [IsCashed] = 0, [RequiredAttributes] = NULL, [SortingAttribute] = NULL, [EnumType] = NULL, [IsIdentity] = 0, [IsCustom] = 0, [RemoveAction] = 1, [IsPrimaryKey] = 0, [ChoiceAttributeData] = NULL, [ParametersData] = NULL, [CustomsData] = NULL, [MappingType] = 1, [MappingName] = 'KDzp', [IsStored] = 1, [MappingTable] = 'T_MO', [MappingRefTable] = NULL, [RefTableSearchMode] = NULL, [RefTableHashFunc] = NULL, [AttrLexem] = NULL
WHERE EntityID = @EntId AND Name = 'KDzp' AND IsAdditional = 0
INSERT INTO VCLib.T_ENTITIES_ATTRIBUTES ([EntitiesAttributesId], [EntityID], [Index], [AttributeType], [Name], [Description], [SystemType], [MaxLength], [Precision], [Scale], [DefaultFormat], [IsCalculated], [IsFlag], [IsRequired], [Save], [LinkAttributeName], [PathsAttributes], [IsCashed], [RequiredAttributes], [SortingAttribute], [EnumType], [IsIdentity], [IsCustom], [RemoveAction], [IsPrimaryKey], [IsAdditional], [ChoiceAttributeData], [ParametersData], [CustomsData], [MappingType], [MappingName], [IsStored], [MappingTable], [MappingRefTable], [RefTableSearchMode], [RefTableHashFunc], [AttrLexem])
SELECT newid(), @EntId, 6970045, 0, 'KDzp', 'коэффициент уровня заработной платы', 'float', NULL, 12, 9, NULL, 0, 0, 0, 1, NULL, NULL, 0, NULL, NULL, NULL, 0, 0, 1, 0, 0, NULL, NULL, NULL, 1, 'KDzp', 1, 'T_MO', NULL, NULL, NULL, NULL
WHERE NOT EXISTS(SELECT * FROM VCLib.T_ENTITIES_ATTRIBUTES where EntityID = @EntId AND Name = 'KDzp' AND IsAdditional = 0)

UPDATE VCLib.T_ENTITIES_ATTRIBUTES SET [Index] = 6970046, [AttributeType] = 0, [Name] = 'KDsub', [Description] = 'Районный коэффициент к заработной плате', [SystemType] = 'float', [MaxLength] = NULL, [Precision] = 12, [Scale] = 9, [DefaultFormat] = NULL, [IsCalculated] = 0, [IsFlag] = 0, [IsRequired] = 0, [Save] = 1, [LinkAttributeName] = NULL, [PathsAttributes] = NULL, [IsCashed] = 0, [RequiredAttributes] = NULL, [SortingAttribute] = NULL, [EnumType] = NULL, [IsIdentity] = 0, [IsCustom] = 0, [RemoveAction] = 1, [IsPrimaryKey] = 0, [ChoiceAttributeData] = NULL, [ParametersData] = NULL, [CustomsData] = NULL, [MappingType] = 1, [MappingName] = 'KDsub', [IsStored] = 1, [MappingTable] = 'T_MO', [MappingRefTable] = NULL, [RefTableSearchMode] = NULL, [RefTableHashFunc] = NULL, [AttrLexem] = NULL
WHERE EntityID = @EntId AND Name = 'KDsub' AND IsAdditional = 0
INSERT INTO VCLib.T_ENTITIES_ATTRIBUTES ([EntitiesAttributesId], [EntityID], [Index], [AttributeType], [Name], [Description], [SystemType], [MaxLength], [Precision], [Scale], [DefaultFormat], [IsCalculated], [IsFlag], [IsRequired], [Save], [LinkAttributeName], [PathsAttributes], [IsCashed], [RequiredAttributes], [SortingAttribute], [EnumType], [IsIdentity], [IsCustom], [RemoveAction], [IsPrimaryKey], [IsAdditional], [ChoiceAttributeData], [ParametersData], [CustomsData], [MappingType], [MappingName], [IsStored], [MappingTable], [MappingRefTable], [RefTableSearchMode], [RefTableHashFunc], [AttrLexem])
SELECT newid(), @EntId, 6970046, 0, 'KDsub', 'Районный коэффициент к заработной плате', 'float', NULL, 12, 9, NULL, 0, 0, 0, 1, NULL, NULL, 0, NULL, NULL, NULL, 0, 0, 1, 0, 0, NULL, NULL, NULL, 1, 'KDsub', 1, 'T_MO', NULL, NULL, NULL, NULL
WHERE NOT EXISTS(SELECT * FROM VCLib.T_ENTITIES_ATTRIBUTES where EntityID = @EntId AND Name = 'KDsub' AND IsAdditional = 0)

UPDATE VCLib.T_ENTITIES_ATTRIBUTES SET [Index] = NULL, [AttributeType] = 2, [Name] = 'MoTypeHistorys', [Description] = 'История уровней МО', [SystemType] = 'FIES.MO_TYPE_HISTORY', [MaxLength] = NULL, [Precision] = NULL, [Scale] = NULL, [DefaultFormat] = NULL, [IsCalculated] = 0, [IsFlag] = 0, [IsRequired] = 0, [Save] = 1, [LinkAttributeName] = 'Mo', [PathsAttributes] = NULL, [IsCashed] = 0, [RequiredAttributes] = NULL, [SortingAttribute] = NULL, [EnumType] = NULL, [IsIdentity] = 0, [IsCustom] = 0, [RemoveAction] = 1, [IsPrimaryKey] = 0, [ChoiceAttributeData] = NULL, [ParametersData] = NULL, [CustomsData] = NULL, [MappingType] = 0, [MappingName] = NULL, [IsStored] = 1, [MappingTable] = NULL, [MappingRefTable] = NULL, [RefTableSearchMode] = NULL, [RefTableHashFunc] = NULL, [AttrLexem] = NULL
WHERE EntityID = @EntId AND Name = 'MoTypeHistorys' AND IsAdditional = 0
INSERT INTO VCLib.T_ENTITIES_ATTRIBUTES ([EntitiesAttributesId], [EntityID], [Index], [AttributeType], [Name], [Description], [SystemType], [MaxLength], [Precision], [Scale], [DefaultFormat], [IsCalculated], [IsFlag], [IsRequired], [Save], [LinkAttributeName], [PathsAttributes], [IsCashed], [RequiredAttributes], [SortingAttribute], [EnumType], [IsIdentity], [IsCustom], [RemoveAction], [IsPrimaryKey], [IsAdditional], [ChoiceAttributeData], [ParametersData], [CustomsData], [MappingType], [MappingName], [IsStored], [MappingTable], [MappingRefTable], [RefTableSearchMode], [RefTableHashFunc], [AttrLexem])
SELECT newid(), @EntId, NULL, 2, 'MoTypeHistorys', 'История уровней МО', 'FIES.MO_TYPE_HISTORY', NULL, NULL, NULL, NULL, 0, 0, 0, 1, 'Mo', NULL, 0, NULL, NULL, NULL, 0, 0, 1, 0, 0, NULL, NULL, NULL, 0, NULL, 1, NULL, NULL, NULL, NULL, NULL
WHERE NOT EXISTS(SELECT * FROM VCLib.T_ENTITIES_ATTRIBUTES where EntityID = @EntId AND Name = 'MoTypeHistorys' AND IsAdditional = 0)

UPDATE VCLib.T_ENTITIES_ATTRIBUTES SET [Index] = NULL, [AttributeType] = 2, [Name] = 'BankAccounts', [Description] = 'Банковские счета', [SystemType] = 'FIES.BANK_ACCOUNT', [MaxLength] = NULL, [Precision] = NULL, [Scale] = NULL, [DefaultFormat] = NULL, [IsCalculated] = 0, [IsFlag] = 0, [IsRequired] = 0, [Save] = 1, [LinkAttributeName] = 'Mo', [PathsAttributes] = NULL, [IsCashed] = 0, [RequiredAttributes] = NULL, [SortingAttribute] = NULL, [EnumType] = NULL, [IsIdentity] = 0, [IsCustom] = 0, [RemoveAction] = 1, [IsPrimaryKey] = 0, [ChoiceAttributeData] = NULL, [ParametersData] = NULL, [CustomsData] = NULL, [MappingType] = 0, [MappingName] = NULL, [IsStored] = 1, [MappingTable] = NULL, [MappingRefTable] = NULL, [RefTableSearchMode] = NULL, [RefTableHashFunc] = NULL, [AttrLexem] = NULL
WHERE EntityID = @EntId AND Name = 'BankAccounts' AND IsAdditional = 0
INSERT INTO VCLib.T_ENTITIES_ATTRIBUTES ([EntitiesAttributesId], [EntityID], [Index], [AttributeType], [Name], [Description], [SystemType], [MaxLength], [Precision], [Scale], [DefaultFormat], [IsCalculated], [IsFlag], [IsRequired], [Save], [LinkAttributeName], [PathsAttributes], [IsCashed], [RequiredAttributes], [SortingAttribute], [EnumType], [IsIdentity], [IsCustom], [RemoveAction], [IsPrimaryKey], [IsAdditional], [ChoiceAttributeData], [ParametersData], [CustomsData], [MappingType], [MappingName], [IsStored], [MappingTable], [MappingRefTable], [RefTableSearchMode], [RefTableHashFunc], [AttrLexem])
SELECT newid(), @EntId, NULL, 2, 'BankAccounts', 'Банковские счета', 'FIES.BANK_ACCOUNT', NULL, NULL, NULL, NULL, 0, 0, 0, 1, 'Mo', NULL, 0, NULL, NULL, NULL, 0, 0, 1, 0, 0, NULL, NULL, NULL, 0, NULL, 1, NULL, NULL, NULL, NULL, NULL
WHERE NOT EXISTS(SELECT * FROM VCLib.T_ENTITIES_ATTRIBUTES where EntityID = @EntId AND Name = 'BankAccounts' AND IsAdditional = 0)

UPDATE VCLib.T_ENTITIES_ATTRIBUTES SET [Index] = NULL, [AttributeType] = 3, [Name] = 'TfomsBranchMo', [Description] = 'Связь филиала ТФОМС с МО', [SystemType] = 'FIES.TFOMS_BRANCH_MO', [MaxLength] = NULL, [Precision] = NULL, [Scale] = NULL, [DefaultFormat] = NULL, [IsCalculated] = 0, [IsFlag] = 0, [IsRequired] = 0, [Save] = 1, [LinkAttributeName] = 'Mo', [PathsAttributes] = NULL, [IsCashed] = 0, [RequiredAttributes] = NULL, [SortingAttribute] = NULL, [EnumType] = NULL, [IsIdentity] = 0, [IsCustom] = 0, [RemoveAction] = 1, [IsPrimaryKey] = 0, [ChoiceAttributeData] = NULL, [ParametersData] = NULL, [CustomsData] = NULL, [MappingType] = 0, [MappingName] = NULL, [IsStored] = 1, [MappingTable] = NULL, [MappingRefTable] = NULL, [RefTableSearchMode] = NULL, [RefTableHashFunc] = NULL, [AttrLexem] = NULL
WHERE EntityID = @EntId AND Name = 'TfomsBranchMo' AND IsAdditional = 0
INSERT INTO VCLib.T_ENTITIES_ATTRIBUTES ([EntitiesAttributesId], [EntityID], [Index], [AttributeType], [Name], [Description], [SystemType], [MaxLength], [Precision], [Scale], [DefaultFormat], [IsCalculated], [IsFlag], [IsRequired], [Save], [LinkAttributeName], [PathsAttributes], [IsCashed], [RequiredAttributes], [SortingAttribute], [EnumType], [IsIdentity], [IsCustom], [RemoveAction], [IsPrimaryKey], [IsAdditional], [ChoiceAttributeData], [ParametersData], [CustomsData], [MappingType], [MappingName], [IsStored], [MappingTable], [MappingRefTable], [RefTableSearchMode], [RefTableHashFunc], [AttrLexem])
SELECT newid(), @EntId, NULL, 3, 'TfomsBranchMo', 'Связь филиала ТФОМС с МО', 'FIES.TFOMS_BRANCH_MO', NULL, NULL, NULL, NULL, 0, 0, 0, 1, 'Mo', NULL, 0, NULL, NULL, NULL, 0, 0, 1, 0, 0, NULL, NULL, NULL, 0, NULL, 1, NULL, NULL, NULL, NULL, NULL
WHERE NOT EXISTS(SELECT * FROM VCLib.T_ENTITIES_ATTRIBUTES where EntityID = @EntId AND Name = 'TfomsBranchMo' AND IsAdditional = 0)

UPDATE VCLib.T_ENTITIES_ATTRIBUTES SET [Index] = NULL, [AttributeType] = 1, [Name] = 'TFOMSBranch', [Description] = 'Филиал ТФОМС', [SystemType] = 'FIES.TFOMS_BRANCH', [MaxLength] = NULL, [Precision] = NULL, [Scale] = NULL, [DefaultFormat] = NULL, [IsCalculated] = 0, [IsFlag] = 0, [IsRequired] = 0, [Save] = 1, [LinkAttributeName] = NULL, [PathsAttributes] = '{TfomsBranchMo/TfomsBranch}', [IsCashed] = 0, [RequiredAttributes] = NULL, [SortingAttribute] = NULL, [EnumType] = NULL, [IsIdentity] = 0, [IsCustom] = 0, [RemoveAction] = 1, [IsPrimaryKey] = 0, [ChoiceAttributeData] = NULL, [ParametersData] = NULL, [CustomsData] = NULL, [MappingType] = 4, [MappingName] = NULL, [IsStored] = 1, [MappingTable] = NULL, [MappingRefTable] = NULL, [RefTableSearchMode] = NULL, [RefTableHashFunc] = NULL, [AttrLexem] = '<lx:Path OwnerQueryLevel="0" xmlns:lx="lexem"><lx:StepString name="TfomsBranchMo" xmlns:lx="lexem"></lx:StepString><lx:StepString name="TfomsBranch" xmlns:lx="lexem"></lx:StepString></lx:Path>'
WHERE EntityID = @EntId AND Name = 'TFOMSBranch' AND IsAdditional = 0
INSERT INTO VCLib.T_ENTITIES_ATTRIBUTES ([EntitiesAttributesId], [EntityID], [Index], [AttributeType], [Name], [Description], [SystemType], [MaxLength], [Precision], [Scale], [DefaultFormat], [IsCalculated], [IsFlag], [IsRequired], [Save], [LinkAttributeName], [PathsAttributes], [IsCashed], [RequiredAttributes], [SortingAttribute], [EnumType], [IsIdentity], [IsCustom], [RemoveAction], [IsPrimaryKey], [IsAdditional], [ChoiceAttributeData], [ParametersData], [CustomsData], [MappingType], [MappingName], [IsStored], [MappingTable], [MappingRefTable], [RefTableSearchMode], [RefTableHashFunc], [AttrLexem])
SELECT newid(), @EntId, NULL, 1, 'TFOMSBranch', 'Филиал ТФОМС', 'FIES.TFOMS_BRANCH', NULL, NULL, NULL, NULL, 0, 0, 0, 1, NULL, '{TfomsBranchMo/TfomsBranch}', 0, NULL, NULL, NULL, 0, 0, 1, 0, 0, NULL, NULL, NULL, 4, NULL, 1, NULL, NULL, NULL, NULL, '<lx:Path OwnerQueryLevel="0" xmlns:lx="lexem"><lx:StepString name="TfomsBranchMo" xmlns:lx="lexem"></lx:StepString><lx:StepString name="TfomsBranch" xmlns:lx="lexem"></lx:StepString></lx:Path>'
WHERE NOT EXISTS(SELECT * FROM VCLib.T_ENTITIES_ATTRIBUTES where EntityID = @EntId AND Name = 'TFOMSBranch' AND IsAdditional = 0)
GO
