diff --git a/src/Shentun.Peis.Application.Contracts/LisRequests/LisPatientRegisterDto.cs b/src/Shentun.Peis.Application.Contracts/LisRequests/LisPatientRegisterDto.cs
new file mode 100644
index 0000000..a1a478b
--- /dev/null
+++ b/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
+ {
+ ///
+ /// 姓名
+ ///
+ public string PatientName { get; set; }
+
+ ///
+ /// 检验单号码
+ ///
+ public string LisRequestNo { get; set; }
+
+ ///
+ /// 年龄
+ ///
+ public short? Age { get; set; }
+
+ ///
+ /// 性别
+ ///
+ public string SexName { get; set; }
+
+ ///
+ /// 标本类型
+ ///
+ public string SampleTypeName { get; set; }
+
+ ///
+ /// 项目信息
+ ///
+ public List AsbitemDetail { get; set; }
+ }
+
+ public class LisPatientRegisterDetailDto
+ {
+ ///
+ /// 组合项目ID
+ ///
+ public Guid AsbitemId { get; set; }
+
+ ///
+ /// 组合项目
+ ///
+ public string AsbitemName { get; set; }
+
+ ///
+ /// 项目价格
+ ///
+ public decimal AsbitemPrice { get; set; }
+ }
+}
diff --git a/src/Shentun.Peis.Application/ImportLisResults/ImportLisResultAppService.cs b/src/Shentun.Peis.Application/ImportLisResults/ImportLisResultAppService.cs
index a377d85..2e245e7 100644
--- a/src/Shentun.Peis.Application/ImportLisResults/ImportLisResultAppService.cs
+++ b/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(assemblyName,
+ var pluginsOut = await Utilities.ReflectionHelper.InvokeAsync(assemblyName,
className, [thirdInterface.Id], "ImportResultByPatientRegisterIdAsync", objects);
}
@@ -412,5 +413,36 @@ namespace Shentun.Peis.ImportLisResults
await _unitRepository.InsertAsync(unit);
_units.Add(unit);
}
+
+
+ ///
+ /// 根据lis检验单号导入结果
+ ///
+ ///
+ [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
+ });
+ }
}
}
diff --git a/src/Shentun.Peis.Application/LisRequests/LisRequestAppService.cs b/src/Shentun.Peis.Application/LisRequests/LisRequestAppService.cs
index 3002aa9..d08801d 100644
--- a/src/Shentun.Peis.Application/LisRequests/LisRequestAppService.cs
+++ b/src/Shentun.Peis.Application/LisRequests/LisRequestAppService.cs
@@ -45,6 +45,7 @@ namespace Shentun.Peis.LisRequests
private readonly CustomerOrgManager _customerOrgManager;
private readonly IRepository _sampleContainerRepository;
private readonly IRepository _sampleTypeRepository;
+ private readonly IRepository _lisRequestRepository;
public LisRequestAppService(
IRepository userRepository,
IRepository patientRegisterRepository,
@@ -62,7 +63,8 @@ namespace Shentun.Peis.LisRequests
IRepository sampleGroupRepository,
IRepository sampleGroupDetailRepository,
IRepository itemTypeRepository
- )
+,
+ IRepository 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();
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(patientRegisterList.Count,lisRequestDtoList);
+ lisRequestDtoList = lisRequestDtoList.OrderBy(o => o.PatientNo).ToList();
+ var result = new PagedResultDto(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();
var updateRegisterCheckAsbitemList = new List();
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
}
}
}
+
+
+ ///
+ /// 根据检验单号返回信息给Lis系统
+ ///
+ ///
+ ///
+ [HttpPost("api/app/LisRequest/GetPatientRegisterByLisRequestNo")]
+ public async Task 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;
+ }
}
}
diff --git a/src/Shentun.Peis.Application/SampleTypes/SampleTypeAppService.cs b/src/Shentun.Peis.Application/SampleTypes/SampleTypeAppService.cs
index 2a822c1..7d0765b 100644
--- a/src/Shentun.Peis.Application/SampleTypes/SampleTypeAppService.cs
+++ b/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 _userRepository;
private readonly SampleTypeManager _manager;
private readonly CacheService _cacheService;
+ private readonly IDistributedCache _sampleTypeCache;
public SampleTypeAppService(
IRepository repository,
IRepository userRepository,
SampleTypeManager manager,
- CacheService cacheService)
+ CacheService cacheService,
+ IDistributedCache sampleTypeCache)
: base(repository)
{
_userRepository = userRepository;
_manager = manager;
_cacheService = cacheService;
+ _sampleTypeCache = sampleTypeCache;
}
///
/// 获取通过主键
@@ -115,6 +119,7 @@ namespace Shentun.Peis.SampleTypes
var createEntity = ObjectMapper.Map(input);
var entity = await _manager.CreateAsync(createEntity);
entity = await Repository.InsertAsync(entity);
+ await _sampleTypeCache.SetAsync(entity.Id, entity);
var dto = ObjectMapper.Map(entity);
return dto;
}
@@ -130,6 +135,7 @@ namespace Shentun.Peis.SampleTypes
var sourceEntity = ObjectMapper.Map(input);
await _manager.UpdateAsync(sourceEntity, entity);
entity = await Repository.UpdateAsync(entity);
+ await _sampleTypeCache.SetAsync(entity.Id, entity);
return ObjectMapper.Map(entity);
}
///
diff --git a/src/Shentun.Peis.Domain/CacheService.cs b/src/Shentun.Peis.Domain/CacheService.cs
index cec2bf5..a36e19c 100644
--- a/src/Shentun.Peis.Domain/CacheService.cs
+++ b/src/Shentun.Peis.Domain/CacheService.cs
@@ -45,6 +45,9 @@ namespace Shentun.Peis
private readonly IRepository _medicalTypeRepository;
private readonly IRepository _personnelTypeRepository;
+ private readonly IDistributedCache _sampleTypeCache;
+ private readonly IRepository _sampleTypeRepository;
+
public CacheService(
IDistributedCache userCache,
IMemoryCache customerOrgCache,
@@ -68,7 +71,9 @@ namespace Shentun.Peis
IRepository maritalStatusRepository,
IRepository medicalTypeRepository,
IRepository personnelTypeRepository,
- IDistributedCache customerOrgTopNameCache)
+ IDistributedCache customerOrgTopNameCache,
+ IDistributedCache sampleTypeCache,
+ IRepository 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 GetUserAsync(Guid id)
@@ -388,5 +395,26 @@ namespace Shentun.Peis
return entity.DisplayName;
}
+
+ private async Task GetSampleTypeAsync(Guid id)
+ {
+
+ var entity = await _sampleTypeCache.GetOrAddAsync(
+ id, //缓存键
+ async () => await _sampleTypeRepository.GetAsync(id)
+
+ );
+ return entity;
+ }
+ public async Task GetSampleTypeNameAsync(Guid? id)
+ {
+ if (id == null || id == default(Guid) || !id.HasValue)
+ {
+ return "";
+ }
+ var entity = await GetSampleTypeAsync((Guid)id);
+ return entity.DisplayName;
+ }
+
}
}