|
|
|
@ -1,15 +1,24 @@ |
|
|
|
using Microsoft.AspNetCore.Authorization; |
|
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
|
using Microsoft.EntityFrameworkCore.Metadata.Internal; |
|
|
|
using Microsoft.Extensions.Configuration; |
|
|
|
using Newtonsoft.Json; |
|
|
|
using NPOI.POIFS.Storage; |
|
|
|
using Shentun.Peis.DirectorManagement; |
|
|
|
using Shentun.Peis.Enums; |
|
|
|
using Shentun.Peis.InternalReports; |
|
|
|
using Shentun.Peis.Models; |
|
|
|
using Shentun.Peis.PatientRegisters; |
|
|
|
using Shentun.Peis.PrintReports; |
|
|
|
using Shentun.Peis.TransToWebPeiss; |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.IO; |
|
|
|
using System.Linq; |
|
|
|
using System.Net.Http; |
|
|
|
using System.Net.Http.Headers; |
|
|
|
using System.Text; |
|
|
|
using System.Threading; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Volo.Abp; |
|
|
|
using Volo.Abp.Application.Services; |
|
|
|
@ -32,6 +41,10 @@ namespace Shentun.Peis.DirectorManagements |
|
|
|
private readonly IRepository<Asbitem, Guid> _asbitemRepository; |
|
|
|
private readonly IRepository<MedicalPackage, Guid> _medicalPackageRepository; |
|
|
|
private readonly IRepository<CustomerOrg, Guid> _customerOrgRepository; |
|
|
|
private readonly InternalReportAppService _internalReportAppService; |
|
|
|
private readonly IRepository<ThirdInterface, Guid> _thirdInterfaceRepository; |
|
|
|
private readonly PrintReportAppService _printReportAppService; |
|
|
|
|
|
|
|
public DirectorManagementAppService( |
|
|
|
IRepository<PatientRegister, Guid> patientRegisterRepository, |
|
|
|
IRepository<Patient, Guid> patientRepository, |
|
|
|
@ -40,7 +53,10 @@ namespace Shentun.Peis.DirectorManagements |
|
|
|
IRepository<RegisterCheckAsbitem, Guid> registerCheckAsbitemRepository, |
|
|
|
IRepository<Asbitem, Guid> asbitemRepository, |
|
|
|
IRepository<MedicalPackage, Guid> medicalPackageRepository, |
|
|
|
IRepository<CustomerOrg, Guid> customerOrgRepository) |
|
|
|
IRepository<CustomerOrg, Guid> customerOrgRepository, |
|
|
|
InternalReportAppService internalReportAppService, |
|
|
|
IRepository<ThirdInterface, Guid> thirdInterfaceRepository, |
|
|
|
PrintReportAppService printReportAppService) |
|
|
|
{ |
|
|
|
_patientRegisterRepository = patientRegisterRepository; |
|
|
|
_patientRepository = patientRepository; |
|
|
|
@ -50,6 +66,9 @@ namespace Shentun.Peis.DirectorManagements |
|
|
|
_asbitemRepository = asbitemRepository; |
|
|
|
_medicalPackageRepository = medicalPackageRepository; |
|
|
|
_customerOrgRepository = customerOrgRepository; |
|
|
|
_internalReportAppService = internalReportAppService; |
|
|
|
_thirdInterfaceRepository = thirdInterfaceRepository; |
|
|
|
_printReportAppService = printReportAppService; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -320,6 +339,348 @@ namespace Shentun.Peis.DirectorManagements |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 工作量统计 某段时间科室工作量统计
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost("api/app/DirectorManagement/GetItemTypeWorkLoadReport")] |
|
|
|
public async Task<List<GetItemTypeWorkLoadInStandardDto>> GetItemTypeWorkLoadReportAsync(GetItemTypeWorkLoadReportInputDto input) |
|
|
|
{ |
|
|
|
if (string.IsNullOrWhiteSpace(input.StartDate) || string.IsNullOrWhiteSpace(input.EndDate)) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException("请选择查询时间段"); |
|
|
|
} |
|
|
|
|
|
|
|
var entListDto = await _internalReportAppService.GetItemTypeWorkLoadInStandardAsync(new GetItemTypeWorkLoadInStandardRequestDto |
|
|
|
{ |
|
|
|
StartDate = input.StartDate, |
|
|
|
EndDate = input.EndDate |
|
|
|
}); |
|
|
|
|
|
|
|
return entListDto; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 工作量统计 某段时间医生工作量统计
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost("api/app/DirectorManagement/GetDoctorWorkLoadReport")] |
|
|
|
public async Task<List<GetDoctorPersonnelWorkLoadReportDto>> GetDoctorWorkLoadReportAsync(GetDoctorWorkLoadReportInputDto input) |
|
|
|
{ |
|
|
|
if (string.IsNullOrWhiteSpace(input.StartDate) || string.IsNullOrWhiteSpace(input.EndDate)) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException("请选择查询时间段"); |
|
|
|
} |
|
|
|
|
|
|
|
var entListDto = await _internalReportAppService.GetDoctorPersonnelWorkLoadReportAsync(new GetDoctorPersonnelWorkLoadReportRequestDto |
|
|
|
{ |
|
|
|
StartDate = input.StartDate, |
|
|
|
EndDate = input.EndDate |
|
|
|
}); |
|
|
|
|
|
|
|
return entListDto; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 套餐价格查询
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost("api/app/DirectorManagement/GetMedicalPackage")] |
|
|
|
public async Task<List<GetMedicalPackageDto>> GetMedicalPackageAsync(GetMedicalPackageInputDto input) |
|
|
|
{ |
|
|
|
var query = from medicalPackage in await _medicalPackageRepository.GetQueryableAsync() |
|
|
|
where medicalPackage.IsActive == 'Y' |
|
|
|
select medicalPackage; |
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(input.MedicalPackageName)) |
|
|
|
{ |
|
|
|
query = query.Where(m => input.MedicalPackageName.Contains(m.DisplayName)); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var entListDto = query.ToList().Select(s => new GetMedicalPackageDto |
|
|
|
{ |
|
|
|
DisplayOrder = s.DisplayOrder, |
|
|
|
ForSexName = GetForSexName(s.ForSexId), |
|
|
|
MaritalStatusName = _cacheService.GetMaritalStatusNameAsync(s.MaritalStatusId).GetAwaiter().GetResult(), |
|
|
|
MedicalPackageName = s.DisplayName, |
|
|
|
Price = s.Price, |
|
|
|
Remark = s.Remark |
|
|
|
}).OrderBy(o => o.DisplayOrder).ToList(); |
|
|
|
|
|
|
|
return entListDto; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 组合项目价格查询
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost("api/app/DirectorManagement/GetAsbitem")] |
|
|
|
public async Task<List<GetAsbitemDto>> GetAsbitemAsync(GetAsbitemInputDto input) |
|
|
|
{ |
|
|
|
var query = from asbitem in await _asbitemRepository.GetQueryableAsync() |
|
|
|
where asbitem.IsActive == 'Y' |
|
|
|
select asbitem; |
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(input.AsbitemName)) |
|
|
|
{ |
|
|
|
query = query.Where(m => input.AsbitemName.Contains(m.DisplayName)); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var entListDto = query.ToList().Select(s => new GetAsbitemDto |
|
|
|
{ |
|
|
|
DisplayOrder = s.DisplayOrder, |
|
|
|
ForSexName = GetForSexName(s.ForSexId), |
|
|
|
MaritalStatusName = _cacheService.GetMaritalStatusNameAsync(s.MaritalStatusId).GetAwaiter().GetResult(), |
|
|
|
AsbitemName = s.DisplayName, |
|
|
|
Price = s.Price |
|
|
|
}).OrderBy(o => o.DisplayOrder).ToList(); |
|
|
|
|
|
|
|
return entListDto; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 客户体检报告查询
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost("api/app/DirectorManagement/GetPeisReport")] |
|
|
|
public async Task<List<GetPeisReportDto>> GetPeisReportAsync(GetPeisReportInputDto input) |
|
|
|
{ |
|
|
|
var query = from patientRegister in await _patientRegisterRepository.GetQueryableAsync() |
|
|
|
join patient in await _patientRepository.GetQueryableAsync() on patientRegister.PatientId equals patient.Id |
|
|
|
where patientRegister.CompleteFlag == PatientRegisterCompleteFlag.Audit || patientRegister.CompleteFlag == PatientRegisterCompleteFlag.SumCheck |
|
|
|
select new |
|
|
|
{ |
|
|
|
patientRegister, |
|
|
|
patient |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(input.PatientName)) |
|
|
|
{ |
|
|
|
query = query.Where(m => m.patientRegister.PatientName == input.PatientName); |
|
|
|
} |
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(input.MobileTelephone)) |
|
|
|
{ |
|
|
|
query = query.Where(m => m.patient.MobileTelephone == input.MobileTelephone); |
|
|
|
} |
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(input.PatientNo)) |
|
|
|
{ |
|
|
|
query = query.Where(m => m.patient.PatientNo == input.PatientNo); |
|
|
|
} |
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(input.IdNo)) |
|
|
|
{ |
|
|
|
query = query.Where(m => m.patient.IdNo == input.IdNo); |
|
|
|
} |
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(input.PatientRegisterNo)) |
|
|
|
{ |
|
|
|
query = query.Where(m => m.patientRegister.PatientRegisterNo == input.PatientRegisterNo); |
|
|
|
} |
|
|
|
|
|
|
|
var entListDto = query.Select(s => new GetPeisReportDto |
|
|
|
{ |
|
|
|
Age = s.patientRegister.Age == null ? "" : s.patientRegister.Age.ToString(), |
|
|
|
MedicalStartDate = DataHelper.ConversionDateShortToString(s.patientRegister.MedicalStartDate), |
|
|
|
AuditDate = DataHelper.ConversionDateShortToString(s.patientRegister.AuditDate), |
|
|
|
AuditDoctorName = _cacheService.GetSurnameAsync(s.patientRegister.AuditDoctorId).GetAwaiter().GetResult(), |
|
|
|
IdNo = s.patient.IdNo, |
|
|
|
MobileTelephone = s.patient.MobileTelephone, |
|
|
|
PatientNo = s.patient.PatientNo, |
|
|
|
SexName = GetSexName(s.patientRegister.SexId), |
|
|
|
CompleteFlag = GetPatientRegisterCompleteFlag(s.patientRegister.CompleteFlag), |
|
|
|
IsUpload = s.patientRegister.IsUpload == 'Y' ? "已上传" : "未上传", |
|
|
|
PatientName = s.patientRegister.PatientName, |
|
|
|
PatientRegisterId = s.patientRegister.Id, |
|
|
|
PatientRegisterNo = s.patientRegister.PatientRegisterNo, |
|
|
|
SummaryDate = DataHelper.ConversionDateShortToString(s.patientRegister.SummaryDate), |
|
|
|
SummaryDoctorName = _cacheService.GetSurnameAsync(s.patientRegister.SummaryDoctorId).GetAwaiter().GetResult(), |
|
|
|
CustomerOrgName = _cacheService.GetTopCustomerOrgNameAsync(s.patientRegister.CustomerOrgId).GetAwaiter().GetResult(), |
|
|
|
DepartmentName = _cacheService.GetCustomerOrgNameAsync(s.patientRegister.CustomerOrgId).GetAwaiter().GetResult() |
|
|
|
}).OrderBy(o => o.PatientRegisterId).ToList(); |
|
|
|
|
|
|
|
return entListDto; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 根据体检人员Id查询报告 返回的报告base64
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost("api/app/DirectorManagement/GetPeisReportBase64ByPatientRegisterId")] |
|
|
|
public async Task<GetPeisReportBase64ByPatientRegisterIdDto> GetPeisReportBase64ByPatientRegisterIdAsync(PatientRegisterIdInputDto input) |
|
|
|
{ |
|
|
|
var entDto = new GetPeisReportBase64ByPatientRegisterIdDto(); |
|
|
|
|
|
|
|
entDto.Base64Str = await GetPeisBase64Async(input); |
|
|
|
|
|
|
|
return entDto; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 获取报告bse64 调用服务器上客户端
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <exception cref="UserFriendlyException"></exception>
|
|
|
|
/// <exception cref="Exception"></exception>
|
|
|
|
private async Task<string> GetPeisBase64Async(PatientRegisterIdInputDto input) |
|
|
|
{ |
|
|
|
|
|
|
|
var thirdInterface = await _thirdInterfaceRepository.FirstOrDefaultAsync(f => f.ThirdInterfaceType == ThirdInterfaceTypeFlag.TranToWebPeis); |
|
|
|
if (thirdInterface.IsActive != 'Y') |
|
|
|
{ |
|
|
|
throw new UserFriendlyException("该接口已禁用"); |
|
|
|
} |
|
|
|
|
|
|
|
var parmValue = thirdInterface.ParmValue; |
|
|
|
var configurationBuilder = new ConfigurationBuilder() |
|
|
|
.AddJsonStream(new MemoryStream(System.Text.Encoding.UTF8.GetBytes(parmValue))); |
|
|
|
var config = configurationBuilder.Build(); |
|
|
|
var reportApiBaseAddress = config.GetSection("Interface").GetSection("ReportApiBaseAddress").Value; |
|
|
|
var reportApiUrl = config.GetSection("Interface").GetSection("ReportApiUrl").Value; |
|
|
|
|
|
|
|
string reportBase64 = ""; |
|
|
|
|
|
|
|
|
|
|
|
var printReportData = await _printReportAppService.GetMedicalReportConvertToReportAsync(input); |
|
|
|
|
|
|
|
|
|
|
|
using (var httpClientHandler = new HttpClientHandler()) |
|
|
|
{ |
|
|
|
using (var httpClient = new HttpClient(httpClientHandler)) |
|
|
|
{ |
|
|
|
httpClient.BaseAddress = new Uri(reportApiBaseAddress); |
|
|
|
|
|
|
|
httpClient.DefaultRequestHeaders.Accept.Add( |
|
|
|
new MediaTypeWithQualityHeaderValue("application/json"));//设置accept标头,告诉JSON是可接受的响应类型
|
|
|
|
|
|
|
|
|
|
|
|
var sendData = JsonConvert.SerializeObject(printReportData); |
|
|
|
using (HttpContent httpContent = new StringContent(sendData)) |
|
|
|
{ |
|
|
|
httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json"); |
|
|
|
HttpResponseMessage response = null; |
|
|
|
|
|
|
|
response = await httpClient.PostAsync(reportApiUrl, httpContent); |
|
|
|
|
|
|
|
|
|
|
|
string result; |
|
|
|
if (!response.IsSuccessStatusCode) |
|
|
|
{ |
|
|
|
result = response.Content.ReadAsStringAsync().Result; |
|
|
|
throw new Exception("http通信错误:" + response.StatusCode + ",结果:" + result); |
|
|
|
} |
|
|
|
result = await response.Content.ReadAsStringAsync(); |
|
|
|
|
|
|
|
var resultDto = JsonConvert.DeserializeObject<WebApiClientOutDto>(result); |
|
|
|
if (resultDto != null) |
|
|
|
{ |
|
|
|
if (resultDto.code != 1) |
|
|
|
{ |
|
|
|
throw new Exception($"调用WebApi失败,返回-1,消息:" + result); |
|
|
|
} |
|
|
|
|
|
|
|
reportBase64 = resultDto.data; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return reportBase64; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 转换适用性别
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="ForSexId"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
private string GetForSexName(char ForSexId) |
|
|
|
{ |
|
|
|
string msg = ""; |
|
|
|
if (ForSexId == 'A') |
|
|
|
{ |
|
|
|
msg = "全部"; |
|
|
|
} |
|
|
|
else if (ForSexId == 'M') |
|
|
|
{ |
|
|
|
msg = "男"; |
|
|
|
} |
|
|
|
else if (ForSexId == 'F') |
|
|
|
{ |
|
|
|
msg = "女"; |
|
|
|
} |
|
|
|
return msg; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 转换性别
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="SexId"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
private string GetSexName(char SexId) |
|
|
|
{ |
|
|
|
string msg = ""; |
|
|
|
if (SexId == 'U') |
|
|
|
{ |
|
|
|
msg = "未知"; |
|
|
|
} |
|
|
|
else if (SexId == 'M') |
|
|
|
{ |
|
|
|
msg = "男"; |
|
|
|
} |
|
|
|
else if (SexId == 'F') |
|
|
|
{ |
|
|
|
msg = "女"; |
|
|
|
} |
|
|
|
return msg; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 转换人员状态
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="completeFlag"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
private string GetPatientRegisterCompleteFlag(char completeFlag) |
|
|
|
{ |
|
|
|
string msg = ""; |
|
|
|
if (completeFlag == '0') |
|
|
|
{ |
|
|
|
msg = "预登记"; |
|
|
|
} |
|
|
|
else if (completeFlag == '1') |
|
|
|
{ |
|
|
|
msg = "正式登记"; |
|
|
|
} |
|
|
|
else if (completeFlag == '2') |
|
|
|
{ |
|
|
|
msg = "部分已检"; |
|
|
|
} |
|
|
|
else if (completeFlag == '3') |
|
|
|
{ |
|
|
|
msg = "已总检"; |
|
|
|
} |
|
|
|
return msg; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |