Вы просматриваете старую версию данной страницы. Смотрите текущую версию.

Сравнить с текущим просмотр истории страницы

« Предыдущий Версия 4 Следующий »

Получение списка медицинских мероприятий

Спецификация метода доступна по ссылке.

Внутренняя логика:

На БД указанной ЛПУ выполняется следующий запрос

Текст запроса
select distinct kl_NomServiceID as id,oms_kl_NomService.code as code, oms_kl_NomService.name as 
from lbr_ResearchType lbr with (NOLOCK)
inner join oms_kl_NomService with (NOLOCK) on rf_kl_NomServiceID = kl_NomServiceID
where lbr.rf_kl_NomServiceID > 0

Получение информации о направлениях на медицинские мероприятия

Спецификация метода доступна по ссылке.

Внутренняя логика:

1) Получение полезной нагрузки из CodToken;
2) Получение списка ЛПУ-МКАБ через PersonClient;
3) Через multiTicketIemkClient собираем данные о направлениях по всем ЛПУ пациента:
3.1) Пытаемся получить MKABID в БД ЛПУ по Guid из МИП. Если не получилось - статус 400;
3.2) Получаем направления на консультации и исследования следующим запросом:

Текст запроса
declare @@mkabID int = @0
select convert(varchar(50), dir.GUID) as Guid, 
        dir.Num  as Number, 
        'consultation' as typeDirection, 
        'консультации узкопрофильных специалистов' typeName, 
        convert(datetime, dir.Date) DateBeginDirection, 
        convert(datetime, dateAdd(month, 1, dir.Date)) as DateEndDirection,
        prvs.C_PRVS as CodeEvent,
        prvs.PRVS_NAME as NameEvent,
        prvd.GUID as doctorSourceGuid,
        prvs.C_PRVS as SpecialityCodeDestination,
        dir.rf_lpuSenderID LpuSourceId,
        dir.rf_lpuID LpuDestinationId
from hlt_direction dir with (NOLOCK)
inner join hlt_Typedirection typ with (NOLOCK) on typ.TypeDirectionID = dir.rf_TypeDirectionID
inner join oms_PRVS prvs with (NOLOCK) on dir.rf_PRVSID = prvs.PRVSID
inner join oms_lpu lpufrom with (NOLOCK) on lpuFrom.LPUID = dir.rf_LPUSenderID
inner join hlt_DocPRVD prvd with (NOLOCK) on prvd.DocPRVDID = dir.rf_DocPRVDID
inner join oms_lpu lputo with (NOLOCK) on lputo.LPUID = dir.rf_LPUID
where dateAdd(month, 1, dir.Date) > getdate() and prvs.PRVSID > 0 and typ.Cod = 3 AND dir.rf_MKABID = @@mkabID
union all
Select convert(varchar(50), dir.GUID) as Guid, 
        dir.Number as Number, 
        'diagnostic' as typeDirection, 
        'клинико-диагностические исследования' typeName,
        convert(datetime, dir.Date_Direction) DateBeginDirection,  
        convert(datetime, dateAdd(month, 1, dir.Date_Direction)) as DateEndDirection, 
        nomservice.CODE as CodeEvent,
        nomservice.NAME as NameEvent,
        docFrom.UGUID as doctorSourceGuid,
        '' as SpecialityCodeDestination,
        dir.rf_LPUSenderID LpuSourceId,
        dir.rf_lpuID LpuDestinationId
from lbr_LaboratoryResearch dir with (NOLOCK)
inner join lbr_Research reseach with (NOLOCK) on reseach.rf_LaboratoryResearchGUID = dir.GUID
inner join lbr_ResearchType reseachType with (NOLOCK) on reseachType.UGUID = reseach.rf_ResearchTypeUGUID
inner join oms_kl_NomService nomservice with (NOLOCK) on nomservice.kl_NomServiceID = reseachType.rf_kl_NomServiceID
inner join hlt_LPUDoctor docFrom with (NOLOCK) on docFrom.LPUDoctorID = dir.rf_LPUDoctorID
where  DATEDiff(month, Date_Direction, GETDATE()) < 1 and nomservice.kl_NomServiceID>0 AND dir.rf_MKABID = @@mkabID

3.3) Получаем "направления" по диспансерному учёту следующим запросом:

Текст запроса
declare @@mkabID int = @0
Select convert(varchar(50), dir.GUID) as Guid, 
        ''  as Number, 
        'duvisit' as typeDirection, 
        'диспансерное наблюдение' typeName, 
        convert(datetime, dir.DateRegistration) DateBeginDirection, 
        convert(datetime, dateAdd(month, 1, dir.Dateoff)) as DateEndDirection,
        prvs.C_PRVS as CodeEvent,
        prvs.PRVS_NAME as NameEvent,
        docFrom.UGUID as doctorSourceGuid,
        prvs.C_PRVS as SpecialityCodeDestination,
        dir.rf_lpuID LpuSourceId,
        dir.rf_lpuID LpuDestinationId
from hlt_RegMedicalCheck dir with (NOLOCK)
inner join hlt_LPUDoctor docFrom with (NOLOCK) on docFrom.LPUDoctorID = dir.rf_LPUDoctorID
inner join oms_Prvs prvs with (NOLOCK) on prvs.PrvsID = dir.rf_prvsID
where dir.rf_MKABID = @@mkabID 
and Dateoff >= getdate()
and dir.rf_LPUID > 0
and dir.rf_PRVSID > 0

3.4) Сортируем данные по диспансерному учёту по дате начала, группируем по врачу и объединяем со списком направлений на консультации и исследования;
3.5) Далее для всех направлений проставляется TicketGuid, LpuDestinationGuid и LpuSourceGuid:
    * Для typeDirection = "duvisit" - string.Empty;
    * Для typeDirection = "diagnostic" - результат выполнения запроса:

Текст запроса
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" - результат выполнения запроса:

Текст запроса
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

    * ЛПУ источник направления и ЛПУ назначения получаются следующим запросом:

Текст запроса
Select GUIDLPU GuidLpu
from oms_Lpu 
where LpuID = @0

3.6) Удаляем все направления, где TicketGuid = "0"
4) Получаем информацию о врачах по направлениям следующим запросом:

Текст запроса
Select hlt_LPUDoctor.UGUID Guid, IM_V Name, FAM_V SurName, OT_V Lastname, oms_PRVD.Name Role, oms_PRVS.prvs_name Speciality
from hlt_LPUDoctor with (NOLOCK)
inner join oms_lpu with (NOLOCK) on rf_LpuID = LpuID
inner join hlt_DocPRVD with (NOLOCK) ON hlt_DocPRVD.rf_LPUDoctorID=hlt_LPUDoctor.LPUDoctorID
inner join oms_PRVD with (NOLOCK) ON hlt_DocPRVD.rf_PRVDID = PRVDID
inner join oms_PRVS with (NOLOCK) ON hlt_DocPRVD.rf_PRVSID = PRVSID
where hlt_DocPRVD.GUID = @0
  • Нет меток