You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
328 lines
16 KiB
328 lines
16 KiB
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Shentun.Peis.Models;
|
|
using Shentun.Peis.PatientRegisters;
|
|
using Shentun.Peis.SumSuggestionContents;
|
|
using Shentun.Peis.SumSuggestionHeaders;
|
|
using Shentun.Peis.SumSummaryContents;
|
|
using Shentun.Peis.SumSummaryHeaders;
|
|
using Shentun.Peis.SumSummaryReports;
|
|
using Shentun.Peis.SysParmValues;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using TencentCloud.Wedata.V20210820.Models;
|
|
using Volo.Abp;
|
|
using Volo.Abp.Application.Services;
|
|
using Volo.Abp.Domain.Repositories;
|
|
using Volo.Abp.Identity;
|
|
|
|
namespace Shentun.Peis.PrintReports
|
|
{
|
|
/// <summary>
|
|
/// 打印报告服务
|
|
/// </summary>
|
|
[ApiExplorerSettings(GroupName = "Work")]
|
|
[Authorize]
|
|
public class PrintReportAppService : ApplicationService
|
|
{
|
|
private readonly IRepository<CustomerOrg, Guid> _customerOrgRepository;
|
|
private readonly IRepository<PatientRegister, Guid> _patientRegisterRepository;
|
|
private readonly IRepository<Sex> _sexRegisterRepository;
|
|
private readonly IRepository<ResultStatus> _resultStatusRepository;
|
|
private readonly IRepository<SumSummaryHeader, Guid> _sumSummaryHeaderRepository;
|
|
private readonly IRepository<IdentityUser, Guid> _identityUserRepository;
|
|
private readonly IRepository<SumSuggestionHeader, Guid> _sumSuggestionHeaderRepository;
|
|
private readonly IRepository<RegisterCheck, Guid> _registerCheckRepository;
|
|
private readonly IOrganizationUnitRepository _organizationUnitRepository;
|
|
private readonly IPatientRegisterGuideReportRepository _patientRegisterGuideReportRepository;
|
|
private readonly ILisRequestReportRepository _lisRequestReportRepository;
|
|
private readonly ICheckRequestNoReportRepository _checkRequestNoReportRepository;
|
|
private readonly IChargeReportRepository _chargeReportRepository;
|
|
private readonly SysParmValueManager _sysParmValueManager;
|
|
|
|
public PrintReportAppService(
|
|
IRepository<CustomerOrg, Guid> customerOrgRepository,
|
|
IRepository<PatientRegister, Guid> patientRegisterRepository,
|
|
IRepository<Sex> sexRegisterRepository,
|
|
IRepository<ResultStatus> resultStatusRepository,
|
|
IRepository<SumSummaryHeader, Guid> sumSummaryHeaderRepository,
|
|
IRepository<IdentityUser, Guid> identityUserRepository,
|
|
IRepository<SumSuggestionHeader, Guid> sumSuggestionHeaderRepository,
|
|
IRepository<RegisterCheck, Guid> registerCheckRepository,
|
|
IOrganizationUnitRepository organizationUnitRepository,
|
|
IPatientRegisterGuideReportRepository patientRegisterGuideReportRepository,
|
|
ILisRequestReportRepository lisRequestReportRepository,
|
|
ICheckRequestNoReportRepository checkRequestNoReportRepository,
|
|
IChargeReportRepository chargeReportRepository,
|
|
SysParmValueManager sysParmValueManager
|
|
)
|
|
{
|
|
this._customerOrgRepository = customerOrgRepository;
|
|
this._patientRegisterRepository = patientRegisterRepository;
|
|
this._sexRegisterRepository = sexRegisterRepository;
|
|
this._resultStatusRepository = resultStatusRepository;
|
|
this._sumSummaryHeaderRepository = sumSummaryHeaderRepository;
|
|
this._identityUserRepository = identityUserRepository;
|
|
this._sumSuggestionHeaderRepository = sumSuggestionHeaderRepository;
|
|
this._registerCheckRepository = registerCheckRepository;
|
|
this._organizationUnitRepository = organizationUnitRepository;
|
|
this._patientRegisterGuideReportRepository = patientRegisterGuideReportRepository;
|
|
this._lisRequestReportRepository = lisRequestReportRepository;
|
|
this._checkRequestNoReportRepository = checkRequestNoReportRepository;
|
|
this._chargeReportRepository = chargeReportRepository;
|
|
this._sysParmValueManager = sysParmValueManager;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 获取体检人员指引单报告数据
|
|
/// </summary>
|
|
/// <param name="PatientRegisterId"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("api/app/printreport/getpatientregisterguidereport")]
|
|
public async Task<PatientRegisterGuideReportDto> GetPatientRegisterGuideReportAsync(Guid PatientRegisterId)
|
|
{
|
|
return await _patientRegisterGuideReportRepository.GetPatientRegisterGuideReportAsync(PatientRegisterId);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 批量获取体检人员指引单报告数据
|
|
/// </summary>
|
|
/// <param name="PatientRegisterIds"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("api/app/printreport/getpatientregisterguidereportmany")]
|
|
public async Task<List<PatientRegisterGuideReportDto>> GetPatientRegisterGuideReportManyAsync(List<Guid> PatientRegisterIds)
|
|
{
|
|
return await _patientRegisterGuideReportRepository.GetPatientRegisterGuideReportManyAsync(PatientRegisterIds);
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 打印检验申请单
|
|
/// </summary>
|
|
/// <param name="PatientRegisterId"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("api/app/printreport/getlisrequestreport")]
|
|
public async Task<List<LisRequestReportDto>> GetLisRequestReportAsync(Guid PatientRegisterId)
|
|
{
|
|
return await _lisRequestReportRepository.GetLisRequestReportAsync(PatientRegisterId);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 打印体检报告
|
|
/// </summary>
|
|
/// <param name="PatientRegisterId"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("api/app/printreport/getpeisreport")]
|
|
public async Task<PeisReportDto> GetPeisReportAsync(Guid PatientRegisterId)
|
|
{
|
|
PeisReportDto msg = new PeisReportDto();
|
|
|
|
var userlist = await _identityUserRepository.GetListAsync();
|
|
|
|
var customerOrgList = await _customerOrgRepository.GetListAsync();
|
|
|
|
var organizationUnitList = await _organizationUnitRepository.GetListAsync();
|
|
|
|
var sexList = await _sexRegisterRepository.GetListAsync();
|
|
|
|
var patientRegisterEnt = (await _patientRegisterRepository.GetDbSetAsync())
|
|
.Include(x => x.Patient)
|
|
.Where(m => m.Id == PatientRegisterId).FirstOrDefault();
|
|
if (patientRegisterEnt != null)
|
|
{
|
|
|
|
#region 系统参数配置
|
|
var MedicalCenterAddress = await _sysParmValueManager.GetSysParmValueInMedicalCenterId(patientRegisterEnt.MedicalCenterId, "medical_center_address");
|
|
var MedicalCenterFax = await _sysParmValueManager.GetSysParmValueInMedicalCenterId(patientRegisterEnt.MedicalCenterId, "medical_center_fax");
|
|
var MedicalCenterTelphone = await _sysParmValueManager.GetSysParmValueInMedicalCenterId(patientRegisterEnt.MedicalCenterId, "medical_center_telphone");
|
|
#endregion
|
|
|
|
msg = new PeisReportDto
|
|
{
|
|
Age = patientRegisterEnt.Age,
|
|
CustomerOrgName = EntityHelper.GetCustomerOrgParentNameNoSql(customerOrgList, patientRegisterEnt.CustomerOrgId),
|
|
DepartmentName = EntityHelper.GetCustomerOrgNameNoSql(customerOrgList, patientRegisterEnt.CustomerOrgId),
|
|
MedicalCenterTelphone = MedicalCenterTelphone,
|
|
detailedResultsListDtos = new List<DetailedResultsListDto>(),
|
|
MedicalCenterAddress = MedicalCenterAddress,
|
|
MedicalStartDate = patientRegisterEnt.MedicalStartDate.ToString(),
|
|
OrganizationUnitId = patientRegisterEnt.MedicalCenterId,
|
|
OrganizationUnitName = organizationUnitList.Where(m => m.Id == patientRegisterEnt.MedicalCenterId).Select(s => s.DisplayName).FirstOrDefault(),
|
|
PatientName = patientRegisterEnt.PatientName,
|
|
PatientNo = patientRegisterEnt.Patient.PatientNo,
|
|
PatientRegisterNo = patientRegisterEnt.PatientRegisterNo,
|
|
resultStatusDtos = new List<ResultStatuses.ResultStatusDto>(),
|
|
sumSuggestionHeaderOrContentDtos = new List<SumSuggestionHeaderOrContentDto>(),
|
|
SexName = sexList.Where(m => m.Id == patientRegisterEnt.SexId).Select(s => s.DisplayName).FirstOrDefault(),
|
|
SummaryDate = patientRegisterEnt.SummaryDate.ToString(),
|
|
sumSummaryHeaderOrContentDtos = new List<SumSummaryHeaderOrContentDto>()
|
|
};
|
|
|
|
#region 结果状态
|
|
var resultStatusList = (await _resultStatusRepository.GetListAsync());
|
|
if (resultStatusList.Any())
|
|
{
|
|
msg.resultStatusDtos = resultStatusList.Select(s => new ResultStatuses.ResultStatusDto
|
|
{
|
|
DataInputBackgroundColor = s.DataInputBackgroundColor,
|
|
DataInputFontColor = s.DataInputFontColor,
|
|
DataInputPrompt = s.DataInputPrompt,
|
|
DisplayName = s.DisplayName,
|
|
DisplayOrder = s.DisplayOrder,
|
|
Id = s.Id,
|
|
ReportBackgroundColor = s.ReportBackgroundColor,
|
|
ReportFontColor = s.ReportFontColor,
|
|
ReportPrompt = s.ReportPrompt
|
|
}).OrderBy(o => o.DisplayOrder).ToList();
|
|
}
|
|
#endregion
|
|
|
|
#region 小结
|
|
|
|
var sumSummarylist = (await _sumSummaryHeaderRepository.GetDbSetAsync())
|
|
.Include(x => x.SumSummaryContents)
|
|
.Where(m => m.PatientRegisterId == PatientRegisterId).OrderBy(o => o.DisplayOrder).ToList();
|
|
|
|
if (sumSummarylist.Any())
|
|
{
|
|
msg.sumSummaryHeaderOrContentDtos = sumSummarylist.Select(s => new SumSummaryHeaderOrContentDto
|
|
{
|
|
SummaryTitle = s.SummaryTitle,
|
|
SummaryFlag = s.SummaryFlag,
|
|
PatientRegisterId = s.PatientRegisterId,
|
|
DisplayOrder = s.DisplayOrder,
|
|
Id = s.Id,
|
|
Details = s.SumSummaryContents.OrderBy(o => o.DisplayOrder).Select(sa => new SumSummaryContentDto
|
|
{
|
|
DisplayOrder = sa.DisplayOrder,
|
|
SummaryContent = sa.SummaryContent,
|
|
SumSummaryHeaderId = sa.SumSummaryHeaderId,
|
|
}).OrderBy(o => o.DisplayOrder).ToList()
|
|
}).OrderBy(o => o.DisplayOrder).ToList();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 建议
|
|
|
|
var sumSuggestionlist = (await _sumSuggestionHeaderRepository.GetDbSetAsync())
|
|
.Include(x => x.SumSuggestionContents)
|
|
.Where(m => m.PatientRegisterId == PatientRegisterId).OrderBy(o => o.DisplayOrder).ToList();
|
|
|
|
if (sumSuggestionlist.Any())
|
|
{
|
|
msg.sumSuggestionHeaderOrContentDtos = sumSuggestionlist.Select(s => new SumSuggestionHeaderOrContentDto
|
|
{
|
|
SuggestionTitle = s.SuggestionTitle,
|
|
SuggestionFlag = s.SuggestionFlag,
|
|
PatientRegisterId = s.PatientRegisterId,
|
|
DisplayOrder = s.DisplayOrder,
|
|
Id = s.Id,
|
|
Details = s.SumSuggestionContents.OrderBy(o => o.DisplayOrder).Select(sa => new SumSuggestionContentDto
|
|
{
|
|
DisplayOrder = sa.DisplayOrder,
|
|
SuggestionContent = sa.SuggestionContent,
|
|
SumSuggestionHeaderId = sa.SumSuggestionHeaderId
|
|
}).OrderBy(o => o.DisplayOrder).ToList()
|
|
}).OrderBy(o => o.DisplayOrder).ToList();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 明细结果
|
|
|
|
var detailedResultsList = new List<DetailedResultsListDto>();
|
|
|
|
var registerChecklist = (await _registerCheckRepository.GetDbSetAsync())
|
|
.Include(x => x.RegisterCheckAsbitems)
|
|
.ThenInclude(x => x.Asbitem)
|
|
.ThenInclude(x => x.ItemType)
|
|
.Include(x => x.RegisterCheckSummaries)
|
|
.Include(x => x.RegisterCheckItems)
|
|
.ThenInclude(x => x.Item)
|
|
.Where(m => m.RegisterCheckAsbitems.Select(s => s.PatientRegisterId).Contains(PatientRegisterId))
|
|
.ToList();
|
|
|
|
|
|
var asbitemList = registerChecklist.Select(s => new DetailedResultsList_Asbitem
|
|
{
|
|
AsbitemName = string.Join(",", s.RegisterCheckAsbitems.Select(rs => rs.Asbitem.DisplayName).ToList()),
|
|
ItemTypeName = string.Join(",", s.RegisterCheckAsbitems.Select(rs => rs.Asbitem.ItemType.DisplayName).ToList()),
|
|
CheckDate = s.CheckDate.ToString(),
|
|
CheckDoctorName = EntityHelper.GetCheckDoctorName(s.CheckDoctorId, userlist),
|
|
Items = s.RegisterCheckItems.Select(sa => new DetailedResultsList_Asbitem_Item
|
|
{
|
|
CriticalRangeValue = sa.CriticalRangeValue,
|
|
ItemName = sa.Item.DisplayName,
|
|
ItemResult = sa.Result,
|
|
ReferenceRangeValue = sa.ReferenceRangeValue,
|
|
ResultStatusName = sa.ResultStatusId,
|
|
Unit = sa.Unit
|
|
}).ToList(),
|
|
Summarys = s.RegisterCheckSummaries.Count > 0 ? s.RegisterCheckSummaries.Select(sb => new DetailedResultsList_Asbitem_Summary
|
|
{
|
|
Summary = sb.Summary,
|
|
}).ToList() : new List<DetailedResultsList_Asbitem_Summary>()
|
|
}).ToList();
|
|
|
|
|
|
var grouplist = asbitemList.GroupBy(g => g.ItemTypeName);
|
|
|
|
foreach (var g in grouplist)
|
|
{
|
|
var glist = g.ToList();
|
|
var resultlist = new DetailedResultsListDto
|
|
{
|
|
ItemTypeName = glist.FirstOrDefault().ItemTypeName,
|
|
Asbitems = glist
|
|
};
|
|
|
|
detailedResultsList.Add(resultlist);
|
|
}
|
|
|
|
if (detailedResultsList.Any())
|
|
{
|
|
msg.detailedResultsListDtos = detailedResultsList;
|
|
}
|
|
#endregion
|
|
}
|
|
|
|
|
|
|
|
return msg;
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 打印Pacs条码数据
|
|
/// </summary>
|
|
/// <param name="PatientRegisterId"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("api/app/printreport/getpacsnoreport")]
|
|
public async Task<List<PacsNoReportDto>> GetPacsNoReportAsync(Guid PatientRegisterId)
|
|
{
|
|
return await _checkRequestNoReportRepository.GetPacsNoReportAsync(PatientRegisterId);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 打印收费单
|
|
/// </summary>
|
|
/// <param name="ChargeId">收费主表ID</param>
|
|
/// <returns></returns>
|
|
[HttpPost("api/app/printreport/getchargereport")]
|
|
public async Task<ChargeReportDto> GetChargeReportAsync(Guid ChargeId)
|
|
{
|
|
return await _chargeReportRepository.GetChargeReportAsync(ChargeId);
|
|
}
|
|
|
|
}
|
|
}
|