...
3.4) Сортируем данные по диспансерному учёту по дате начала, группируем по врачу и объединяем со списком направлений на консультации и исследования;
3.5) Далее для всех направлений проставляется TicketGuid, LpuDestinationGuid и LpuSourceGuid:
* Для typeDirection = "duvisit" - string.Empty;
* Для typeDirection = "diagnostic" - результат выполнения запроса:
Блок кода |
---|
language | sql |
---|
firstline | 1 |
---|
title | Текст запроса |
---|
linenumbers | true |
---|
collapse | true |
---|
|
select case when dtt.Begin_Time > getdate() then CONVERT(varchar(36), docvisit.UGUID) else '0' end
from lbr_LaboratoryResearch dir with (NOLOCK)
inner join hlt_ActionSchedule actSched with (NOLOCK) on actSched.rf_DocTypeID = dir.LaboratoryResearchID and DocTypeDefID = 586
inner join hlt_DoctorVisitTable docvisit with (NOLOCK) on docvisit.DoctorVisitTableID = actSched.rf_DoctorVisitTableID
inner join hlt_DoctorTimeTable dtt with (NOLOCK) on docvisit.rf_DoctorTimeTableID = dtt.DoctorTimeTableID
where dir.GUID = @0 |
* Для typeDirection = "consultation" - результат выполнения запроса:
Блок кода |
---|
language | sql |
---|
firstline | 1 |
---|
title | Текст запроса |
---|
linenumbers | true |
---|
collapse | true |
---|
|
select case when dtt.Begin_Time > getdate() then CONVERT(varchar(36), docvisit.UGUID) else '0' end
from hlt_direction dir with (NOLOCK)
left join hlt_DoctorVisitTable docvisit with (NOLOCK) on docvisit.rf_DirectionID = dir.DirectionID
inner join hlt_DoctorTimeTable dtt with (NOLOCK) on docvisit.rf_DoctorTimeTableID = dtt.DoctorTimeTableID
where dir.GUID = @0 |
* ЛПУ источник направления и ЛПУ назначения получаются следующим запросом:
Блок кода |
---|
language | sql |
---|
firstline | 1 |
---|
title | Текст запроса |
---|
linenumbers | true |
---|
collapse | true |
---|
|
Select GUIDLPU GuidLpu
from oms_Lpu
where LpuID = @0 |