Сравнение версий

Ключ

  • Эта строка добавлена.
  • Эта строка удалена.
  • Изменено форматирование.

...

Блок кода
languagesql
firstline1
titleТекст запроса
linenumberstrue
collapsetrue
if not exists (select * from lbr_LaboratoryResearch with (NOLOCK) where Number = '{4}')
begin 
insert into lbr_LaboratoryResearch(Date_Direction,	rf_MKABID, rf_mkbId, Number, Pat_Birthday,	
                                   Pat_Family, Pat_Name, Pat_Ot,
                                   Pat_S_POL, Pat_N_POL, rf_LPUSenderID, rf_LPUID, DateCreate)
values (convert(datetime,'{0}'),  
        isnull((Select top 1 MKABID from hlt_mkab with (NOLOCK) where S_POL = '{1}' and N_pol = '{2}'), 0), -- MKABID
		isnull((Select MKBID from oms_mkb with (NOLOCK) where DS = '{3}'), 0), -- МКБ
		'{4}', -- номер направления
		isnull((Select top 1  convert(datetime, DATE_BD, 104) from hlt_mkab with (NOLOCK) where S_POL = '{1}' and N_pol = '{2}'), 0), -- дата рождения
		isnull((Select top 1 FAMILY from hlt_mkab with (NOLOCK) where S_POL = '{1}' and N_pol = '{2}'), 0), --фамилия
		isnull((Select top 1 NAME from hlt_mkab with (NOLOCK) where S_POL = '{1}' and N_pol = '{2}'), 0), -- имя
		isnull((Select top 1 OT from hlt_mkab with (NOLOCK) where S_POL = '{1}' and N_pol = '{2}'), 0), -- отчество
        '{1}', -- серия полиса
        '{2}', -- номер полиса
        isnull((Select top 1 LPUID from oms_lpu with (NOLOCK) where GUIDLPU = '{5}'), 0), -- ЛПУ источник
		isnull((Select top 1 LPUID from oms_lpu with (NOLOCK) where GUIDLPU = '{6}'), 0), -- ЛПУ назначения
        GetDAte())

Select scope_identity()

declare @@researchTypeGuid uniqueidentifier, @@laboratoryResearchGuid uniqueidentifier
Select @@researchTypeGUID = UGuid from lbr_ResearchType with (NOLOCK) where code = '{7}'
Select @@laboratoryResearchGuid = GUID from lbr_LaboratoryResearch with (NOLOCK) where LaboratoryResearchId = scope_identity()

insert into lbr_Research(rf_LaboratoryResearchGuid, rf_ResearchTypeUGUID)
values (@@laboratoryResearchGuid, @@researchTypeGuid)
end

select top 1 LaboratoryResearchID from lbr_LaboratoryResearch where Number = '{4}'

...

Блок кода
languagesql
firstline1
titleТекст запроса
linenumberstrue
collapsetrue
if not exists (select * from hlt_Direction with (NOLOCK) where Num = '{6}')
begin 
insert into hlt_Direction(Date,	rf_MKABID, rf_mkbID, rf_LPUID,	rf_TypeDirectionID,	
                            rf_LPUSenderID,	FAMILY,	NAME,	OT,	BD,	Address, 
						  S_POL,	N_POL, Num,	rf_PRVSID,	DatePlan)
 values (convert(datetime,'{0}'), 
	   isnull((Select top 1 MKABID from hlt_mkab with (NOLOCK) where S_POL = '{1}' and N_pol = '{2}'), 0), -- MKABID
	   isnull((Select MKBID from oms_mkb with (NOLOCK) where DS = '{3}'), 0),
 -- MKBID
       isnull((Select top 1 LPUID from oms_lpu with (NOLOCK) where GUIDLPU = '{4}'), 0), -- ЛПУ назначения
	   3,
 -- тип направления
       isnull((Select top 1 LPUID from oms_lpu with (NOLOCK) where GUIDLPU = '{5}'), 0),
 -- ЛПУ источник
       isnull((Select top 1 FAMILY from hlt_mkab with (NOLOCK) where S_POL = '{1}' and N_pol = '{2}'), 0),
 -- Фамилия
       isnull((Select top 1 NAME from hlt_mkab with (NOLOCK) where S_POL = '{1}' and N_pol = '{2}'), 0),
 -- Имя
       isnull((Select top 1 OT from hlt_mkab with (NOLOCK) where S_POL = '{1}' and N_pol = '{2}'), 0),
 -- Отчество
       isnull((Select top 1  convert(datetime, DATE_BD, 104) from hlt_mkab with (NOLOCK) where S_POL = '{1}' and N_pol = '{2}'), 0),
 -- ДР
       isnull((Select top 1 Adres from hlt_mkab with (NOLOCK) where S_POL = '{1}' and N_pol = '{2}'), 0),
 -- Адрес
       '{1}',
 -- Серия полиса
       '{2}',
 -- Номер полиса
       '{6}',
 -- Номер направления
       isnull((Select top 1 PRVSID from oms_PRVS with (NOLOCK) where C_PRVS = '{7}'), 0),
 -- специальность
       convert(datetime,'{0}')) -- Дата направления
Select scope_identity()
end
else 
select DirectionID from hlt_Direction with (NOLOCK) where Num = '{6}'

...