Browse Source

lis对接

master
wxd 2 years ago
parent
commit
c976d5c936
  1. 57
      src/Shentun.Peis.Application.Contracts/LisRequests/LisPatientRegisterDto.cs
  2. 36
      src/Shentun.Peis.Application/ImportLisResults/ImportLisResultAppService.cs
  3. 93
      src/Shentun.Peis.Application/LisRequests/LisRequestAppService.cs
  4. 8
      src/Shentun.Peis.Application/SampleTypes/SampleTypeAppService.cs
  5. 30
      src/Shentun.Peis.Domain/CacheService.cs

57
src/Shentun.Peis.Application.Contracts/LisRequests/LisPatientRegisterDto.cs

@ -0,0 +1,57 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Shentun.Peis.LisRequests
{
public class LisPatientRegisterDto
{
/// <summary>
/// 姓名
/// </summary>
public string PatientName { get; set; }
/// <summary>
/// 检验单号码
/// </summary>
public string LisRequestNo { get; set; }
/// <summary>
/// 年龄
/// </summary>
public short? Age { get; set; }
/// <summary>
/// 性别
/// </summary>
public string SexName { get; set; }
/// <summary>
/// 标本类型
/// </summary>
public string SampleTypeName { get; set; }
/// <summary>
/// 项目信息
/// </summary>
public List<LisPatientRegisterDetailDto> AsbitemDetail { get; set; }
}
public class LisPatientRegisterDetailDto
{
/// <summary>
/// 组合项目ID
/// </summary>
public Guid AsbitemId { get; set; }
/// <summary>
/// 组合项目
/// </summary>
public string AsbitemName { get; set; }
/// <summary>
/// 项目价格
/// </summary>
public decimal AsbitemPrice { get; set; }
}
}

36
src/Shentun.Peis.Application/ImportLisResults/ImportLisResultAppService.cs

@ -6,6 +6,7 @@ using NPOI.Util;
using Shentun.Peis.DiagnosisFunctions;
using Shentun.Peis.Enums;
using Shentun.Peis.Items;
using Shentun.Peis.LisRequests;
using Shentun.Peis.Models;
using Shentun.Peis.PatientRegisters;
using Shentun.Peis.PlugIns.ImportLisResults;
@ -288,7 +289,7 @@ namespace Shentun.Peis.ImportLisResults
public async Task ImportResultByPatientRegisterIdAsync(PatientRegisterIdInputDto input)
{
var patientRegister = await _patientRegisterRepository.GetAsync(input.PatientRegisterId);
var thirdInterfaces = await _thirdInterfaceRepository.GetListAsync(o =>
var thirdInterfaces = await _thirdInterfaceRepository.GetListAsync(o =>
o.ThirdInterfaceType == ThirdInterfaceTypeFlag.ImportLisResult
&& o.MedicalCenterId == patientRegister.MedicalCenterId
&& o.IsActive == 'Y');
@ -301,7 +302,7 @@ namespace Shentun.Peis.ImportLisResults
var assemblyName = config.GetSection("Interface").GetSection("AssemblyName").Value;
var className = config.GetSection("Interface").GetSection("ClassName").Value;
object[] objects = new object[] { input.PatientRegisterId };
var pluginsOut = await Utilities.ReflectionHelper.InvokeAsync<ImportLisResultPlugInsOut>(assemblyName,
var pluginsOut = await Utilities.ReflectionHelper.InvokeAsync<ImportLisResultPlugInsOut>(assemblyName,
className, [thirdInterface.Id], "ImportResultByPatientRegisterIdAsync", objects);
}
@ -412,5 +413,36 @@ namespace Shentun.Peis.ImportLisResults
await _unitRepository.InsertAsync(unit);
_units.Add(unit);
}
/// <summary>
/// 根据lis检验单号导入结果
/// </summary>
/// <returns></returns>
[HttpPost("api/app/ImportLisResult/ImportResultByLisRequestNo")]
public async Task ImportResultByLisRequestNoAsync(LisRequestNoInputDto input)
{
if (input == null)
throw new UserFriendlyException("请求参数无效");
var query = (from lisRequest in await _lisRequestRepository.GetQueryableAsync()
join registerCheckAsbitem in await _registerCheckAsbitemRepository.GetQueryableAsync() on lisRequest.Id equals registerCheckAsbitem.LisRequestId
join registerCheck in await _registerCheckRepository.GetQueryableAsync() on registerCheckAsbitem.RegisterCheckId equals registerCheck.Id
where lisRequest.LisRequestNo == input.LisRequestNo
select new
{
registerCheck.PatientRegisterId
}).FirstOrDefault();
if (query == null)
{
throw new UserFriendlyException("检验单号不存在");
}
await ImportResultByPatientRegisterIdAsync(new PatientRegisterIdInputDto
{
PatientRegisterId = query.PatientRegisterId
});
}
}
}

93
src/Shentun.Peis.Application/LisRequests/LisRequestAppService.cs

@ -45,6 +45,7 @@ namespace Shentun.Peis.LisRequests
private readonly CustomerOrgManager _customerOrgManager;
private readonly IRepository<SampleContainer, Guid> _sampleContainerRepository;
private readonly IRepository<SampleType, Guid> _sampleTypeRepository;
private readonly IRepository<LisRequest, Guid> _lisRequestRepository;
public LisRequestAppService(
IRepository<IdentityUser, Guid> userRepository,
IRepository<PatientRegister, Guid> patientRegisterRepository,
@ -62,7 +63,8 @@ namespace Shentun.Peis.LisRequests
IRepository<SampleGroup, Guid> sampleGroupRepository,
IRepository<SampleGroupDetail> sampleGroupDetailRepository,
IRepository<ItemType, Guid> itemTypeRepository
)
,
IRepository<LisRequest, Guid> lisRequestRepository)
{
this._userRepository = userRepository;
this._patientRegisterRepository = patientRegisterRepository;
@ -80,6 +82,7 @@ namespace Shentun.Peis.LisRequests
_sampleGroupRepository = sampleGroupRepository;
_sampleGroupDetailRepository = sampleGroupDetailRepository;
_itemTypeRepository = itemTypeRepository;
_lisRequestRepository = lisRequestRepository;
}
[HttpPost("api/app/LisRequest/GetListInFilter")]
@ -111,7 +114,7 @@ namespace Shentun.Peis.LisRequests
if (input.SexId != null && input.SexId != ForSexFlag.All)
patientRegisterQuery = patientRegisterQuery.Where(m => m.SexId == input.SexId);
if(input.EndDate == null)
if (input.EndDate == null)
input.EndDate = DateTime.Now;
if (input.StartDate != null && input.EndDate != null)
@ -148,7 +151,7 @@ namespace Shentun.Peis.LisRequests
}
//返回检索到的数据
var list = (from patient in await _patientRepository.GetQueryableAsync()
join patientRegister in patientRegisterQuery
join patientRegister in patientRegisterQuery
on patient.Id equals patientRegister.PatientId
join registerCheck in await _registerCheckRepository.GetQueryableAsync()
on patientRegister.Id equals registerCheck.PatientRegisterId
@ -159,9 +162,9 @@ namespace Shentun.Peis.LisRequests
join lisRequest in await _lisRequestReportRepository.GetQueryableAsync()
on registerCheckAsbitem.LisRequestId equals lisRequest.Id
join sampleContainer in await _sampleContainerRepository.GetQueryableAsync()
on lisRequest.SampleContainerId equals sampleContainer.Id
on lisRequest.SampleContainerId equals sampleContainer.Id
join sampleType in await _sampleTypeRepository.GetQueryableAsync()
on lisRequest.SampleTypeId equals sampleType.Id
on lisRequest.SampleTypeId equals sampleType.Id
select new
{
patient,
@ -173,7 +176,7 @@ namespace Shentun.Peis.LisRequests
}).ToList();
var lisRequestIds = list.Select(o => new { Id = o.lisRequest.Id }).Distinct().ToList();
var lisRequestDtoList = new List<LisRequestDto>();
foreach (var lisRequestId in lisRequestIds)
{
@ -192,14 +195,14 @@ namespace Shentun.Peis.LisRequests
SampleContainerName = patient.sampleContainer.DisplayName,
ContainerColor = patient.sampleContainer.ContainerColor,
SampleContainerRemark = patient.sampleContainer.ContainerRemark,
AsbitemNames = string.Join(",", patientList.OrderBy(o=>o.asbitem.DisplayOrder).Select(o=> o.asbitem.DisplayName ).Distinct()),
AsbitemNames = string.Join(",", patientList.OrderBy(o => o.asbitem.DisplayOrder).Select(o => o.asbitem.DisplayName).Distinct()),
CustomerOrgName = _cacheService.GetTopCustomerOrgAsync(patient.patientRegister.CustomerOrgId).Result.DisplayName,
DepartmentName = _cacheService.GetCustomerOrgNameAsync(patient.patientRegister.CustomerOrgId).Result
};
lisRequestDtoList.Add(lisRequestDto);
}
lisRequestDtoList = lisRequestDtoList.OrderBy(o=>o.PatientNo).ToList();
var result = new PagedResultDto<LisRequestDto>(patientRegisterList.Count,lisRequestDtoList);
lisRequestDtoList = lisRequestDtoList.OrderBy(o => o.PatientNo).ToList();
var result = new PagedResultDto<LisRequestDto>(patientRegisterList.Count, lisRequestDtoList);
return result;
}
@ -268,7 +271,7 @@ namespace Shentun.Peis.LisRequests
var sampleGroups = await _sampleGroupRepository.GetListAsync();
var _sampleGroupDetail = await _sampleGroupDetailRepository.GetListAsync();
var patientRegisterRequests = (
from patientRegister in patientRegisterQuery
from patientRegister in patientRegisterQuery
join registerCheck in await _registerCheckRepository.GetQueryableAsync()
on patientRegister.Id equals registerCheck.PatientRegisterId
join registerCheckAsbitem in await _registerCheckAsbitemRepository.GetQueryableAsync()
@ -278,26 +281,26 @@ namespace Shentun.Peis.LisRequests
join itemType in await _itemTypeRepository.GetQueryableAsync()
on asbitem.ItemTypeId equals itemType.Id
where itemType.CheckTypeFlag == CheckTypeFlag.Laboratory &&
registerCheck.CompleteFlag == RegisterCheckCompleteFlag.UnChecked
registerCheck.CompleteFlag == RegisterCheckCompleteFlag.UnChecked
select new
{
patientRegister,
registerCheckAsbitem
}).ToList();
//生成LIS申请数据
var patientRegisters = patientRegisterRequests.Select(o=>o.patientRegister).Distinct().ToList();
var patientRegisters = patientRegisterRequests.Select(o => o.patientRegister).Distinct().ToList();
var createLisRequestList = new List<LisRequest>();
var updateRegisterCheckAsbitemList = new List<RegisterCheckAsbitem>();
foreach (var patientRegister in patientRegisters)
{
var registerCheckAsbitems = patientRegisterRequests.Select(o=>o.registerCheckAsbitem)
.Where(o => o.PatientRegisterId == patientRegister.Id).Distinct().ToList();
var registerCheckAsbitems = patientRegisterRequests.Select(o => o.registerCheckAsbitem)
.Where(o => o.PatientRegisterId == patientRegister.Id).Distinct().ToList();
_lisRequestManager.SetLisRequest(patientRegister, registerCheckAsbitems, sampleGroups, _sampleGroupDetail
, out var updateRegisterCheckAsbitems, out var createLisRequests);
createLisRequestList.AddRange(createLisRequests);
updateRegisterCheckAsbitemList.AddRange(updateRegisterCheckAsbitems);
}
await _lisRequestReportRepository.InsertManyAsync(createLisRequestList,true);
await _lisRequestReportRepository.InsertManyAsync(createLisRequestList, true);
await _registerCheckAsbitemRepository.UpdateManyAsync(updateRegisterCheckAsbitemList, true);
//返回检索到的数据
@ -425,7 +428,7 @@ namespace Shentun.Peis.LisRequests
lisRequestDtoList.Add(lisRequestDto);
}
lisRequestDtoList = lisRequestDtoList.OrderBy(o => o.PatientNo).ToList();
return lisRequestDtoList;
}
@ -457,7 +460,7 @@ namespace Shentun.Peis.LisRequests
sampleType
}).Distinct().ToList();
if(!list.Any() )
if (!list.Any())
{
return null;
}
@ -596,5 +599,61 @@ namespace Shentun.Peis.LisRequests
}
}
}
/// <summary>
/// 根据检验单号返回信息给Lis系统
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("api/app/LisRequest/GetPatientRegisterByLisRequestNo")]
public async Task<LisPatientRegisterDto> GetLisPatientRegisterByLisRequestNoAsync(LisRequestNoInputDto input)
{
if (input == null)
throw new UserFriendlyException("请求参数无效");
var query = (from lisRequest in await _lisRequestRepository.GetQueryableAsync()
join registerCheckAsbitem in await _registerCheckAsbitemRepository.GetQueryableAsync() on lisRequest.Id equals registerCheckAsbitem.LisRequestId
join asbitem in await _asbitemRepository.GetQueryableAsync() on registerCheckAsbitem.AsbitemId equals asbitem.Id
join registerCheck in await _registerCheckRepository.GetQueryableAsync() on registerCheckAsbitem.RegisterCheckId equals registerCheck.Id
join patientRegister in await _patientRegisterRepository.GetQueryableAsync() on registerCheck.PatientRegisterId equals patientRegister.Id
join patient in await _patientRepository.GetQueryableAsync() on patientRegister.PatientId equals patient.Id
where lisRequest.LisRequestNo == input.LisRequestNo
select new
{
lisRequest,
registerCheckAsbitem,
asbitem,
registerCheck,
patientRegister,
patient
}).ToList();
if (query == null)
{
throw new UserFriendlyException("检验单号不存在");
}
var patientRegisterGroup = query.GroupBy(g => g.patientRegister);
var resultDto = new LisPatientRegisterDto
{
Age = patientRegisterGroup.FirstOrDefault().Key.Age,
LisRequestNo = input.LisRequestNo,
PatientName = patientRegisterGroup.FirstOrDefault().Key.PatientName,
SexName = _cacheService.GetSexNameAsync(patientRegisterGroup.FirstOrDefault().Key.SexId).Result,
SampleTypeName = _cacheService.GetSampleTypeNameAsync(patientRegisterGroup.FirstOrDefault().FirstOrDefault().lisRequest.SampleTypeId).Result,
AsbitemDetail = patientRegisterGroup.FirstOrDefault().Select(ss => new LisPatientRegisterDetailDto
{
AsbitemId = ss.registerCheckAsbitem.AsbitemId,
AsbitemName = ss.asbitem.DisplayName,
AsbitemPrice = ss.registerCheckAsbitem.ChargePrice * ss.registerCheckAsbitem.Amount
}).ToList()
};
return resultDto;
}
}
}

8
src/Shentun.Peis.Application/SampleTypes/SampleTypeAppService.cs

@ -16,6 +16,7 @@ using Shentun.Peis.DiagnosisPostfixs;
using Microsoft.AspNetCore.Authorization;
using SqlSugar;
using Volo.Abp;
using Volo.Abp.Caching;
namespace Shentun.Peis.SampleTypes
{
@ -36,16 +37,19 @@ namespace Shentun.Peis.SampleTypes
private readonly IRepository<IdentityUser, Guid> _userRepository;
private readonly SampleTypeManager _manager;
private readonly CacheService _cacheService;
private readonly IDistributedCache<SampleType, Guid> _sampleTypeCache;
public SampleTypeAppService(
IRepository<SampleType, Guid> repository,
IRepository<IdentityUser, Guid> userRepository,
SampleTypeManager manager,
CacheService cacheService)
CacheService cacheService,
IDistributedCache<SampleType, Guid> sampleTypeCache)
: base(repository)
{
_userRepository = userRepository;
_manager = manager;
_cacheService = cacheService;
_sampleTypeCache = sampleTypeCache;
}
/// <summary>
/// 获取通过主键
@ -115,6 +119,7 @@ namespace Shentun.Peis.SampleTypes
var createEntity = ObjectMapper.Map<CreateSampleTypeDto, SampleType>(input);
var entity = await _manager.CreateAsync(createEntity);
entity = await Repository.InsertAsync(entity);
await _sampleTypeCache.SetAsync(entity.Id, entity);
var dto = ObjectMapper.Map<SampleType, SampleTypeDto>(entity);
return dto;
}
@ -130,6 +135,7 @@ namespace Shentun.Peis.SampleTypes
var sourceEntity = ObjectMapper.Map<UpdateSampleTypeDto, SampleType>(input);
await _manager.UpdateAsync(sourceEntity, entity);
entity = await Repository.UpdateAsync(entity);
await _sampleTypeCache.SetAsync(entity.Id, entity);
return ObjectMapper.Map<SampleType, SampleTypeDto>(entity);
}
/// <summary>

30
src/Shentun.Peis.Domain/CacheService.cs

@ -45,6 +45,9 @@ namespace Shentun.Peis
private readonly IRepository<MedicalType, Guid> _medicalTypeRepository;
private readonly IRepository<PersonnelType, Guid> _personnelTypeRepository;
private readonly IDistributedCache<SampleType, Guid> _sampleTypeCache;
private readonly IRepository<SampleType, Guid> _sampleTypeRepository;
public CacheService(
IDistributedCache<IdentityUser, Guid> userCache,
IMemoryCache customerOrgCache,
@ -68,7 +71,9 @@ namespace Shentun.Peis
IRepository<MaritalStatus> maritalStatusRepository,
IRepository<MedicalType, Guid> medicalTypeRepository,
IRepository<PersonnelType, Guid> personnelTypeRepository,
IDistributedCache<string, Guid> customerOrgTopNameCache)
IDistributedCache<string, Guid> customerOrgTopNameCache,
IDistributedCache<SampleType, Guid> sampleTypeCache,
IRepository<SampleType, Guid> sampleTypeRepository)
{
_userCache = userCache;
_userRepository = userRepository;
@ -103,6 +108,8 @@ namespace Shentun.Peis
_personnelTypeCache = personnelTypeCache;
_personnelTypeRepository = personnelTypeRepository;
_customerOrgTopNameCache = customerOrgTopNameCache;
_sampleTypeCache = sampleTypeCache;
_sampleTypeRepository = sampleTypeRepository;
}
private async Task<IdentityUser> GetUserAsync(Guid id)
@ -388,5 +395,26 @@ namespace Shentun.Peis
return entity.DisplayName;
}
private async Task<SampleType> GetSampleTypeAsync(Guid id)
{
var entity = await _sampleTypeCache.GetOrAddAsync(
id, //缓存键
async () => await _sampleTypeRepository.GetAsync(id)
);
return entity;
}
public async Task<string> GetSampleTypeNameAsync(Guid? id)
{
if (id == null || id == default(Guid) || !id.HasValue)
{
return "";
}
var entity = await GetSampleTypeAsync((Guid)id);
return entity.DisplayName;
}
}
}
Loading…
Cancel
Save