|
|
|
@ -5,6 +5,7 @@ using NPOI.HPSF; |
|
|
|
using NPOI.HSSF.Record; |
|
|
|
using NPOI.HSSF.Record.Chart; |
|
|
|
using Shentun.Peis.Enums; |
|
|
|
using Shentun.Peis.GiveUpCheckTemplates; |
|
|
|
using Shentun.Peis.InformedConsentTemplates; |
|
|
|
using Shentun.Peis.Migrations; |
|
|
|
using Shentun.Peis.Models; |
|
|
|
@ -51,6 +52,7 @@ namespace Shentun.Peis.Paperlesss |
|
|
|
private readonly IRepository<RoomDetail> _roomDetailRepository; |
|
|
|
private readonly IRepository<QueueRegister, Guid> _queueRegisterRepository; |
|
|
|
private readonly QueueRegisterAppService _queueRegisterAppService; |
|
|
|
private readonly IRepository<GiveUpCheckTemplate, Guid> _giveUpCheckTemplateRepository; |
|
|
|
public PaperlessAppService( |
|
|
|
IRepository<PatientRegister, Guid> patientRegisterRepository, |
|
|
|
IRepository<Patient, Guid> patientRepository, |
|
|
|
@ -70,7 +72,8 @@ namespace Shentun.Peis.Paperlesss |
|
|
|
IRepository<DoctorSignIn, Guid> doctorSignInRepository, |
|
|
|
IRepository<RoomDetail> roomDetailRepository, |
|
|
|
IRepository<QueueRegister, Guid> queueRegisterRepository, |
|
|
|
QueueRegisterAppService queueRegisterAppService) |
|
|
|
QueueRegisterAppService queueRegisterAppService, |
|
|
|
IRepository<GiveUpCheckTemplate, Guid> giveUpCheckTemplateRepository) |
|
|
|
{ |
|
|
|
_patientRegisterRepository = patientRegisterRepository; |
|
|
|
_patientRepository = patientRepository; |
|
|
|
@ -91,6 +94,7 @@ namespace Shentun.Peis.Paperlesss |
|
|
|
_roomDetailRepository = roomDetailRepository; |
|
|
|
_queueRegisterRepository = queueRegisterRepository; |
|
|
|
_queueRegisterAppService = queueRegisterAppService; |
|
|
|
_giveUpCheckTemplateRepository = giveUpCheckTemplateRepository; |
|
|
|
} |
|
|
|
|
|
|
|
#region 体检系统用
|
|
|
|
@ -203,6 +207,51 @@ namespace Shentun.Peis.Paperlesss |
|
|
|
return entDto; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 获取人员签署的弃检内容 根据register_check_id 小程序公用
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost("api/app/Paperless/GetRegisterCheckGiveUpCheckPictureByRegisterCheckId")] |
|
|
|
public async Task<GetRegisterCheckGiveUpCheckPictureByRegisterCheckIdDto> GetRegisterCheckGiveUpCheckPictureByRegisterCheckIdAsync(RegisterCheckIdInputDto input) |
|
|
|
{ |
|
|
|
|
|
|
|
string icContent = ""; |
|
|
|
var queryFirst = (from patientRegister in await _patientRegisterRepository.GetQueryableAsync() |
|
|
|
join registerCheck in await _registerCheckRepository.GetQueryableAsync() on patientRegister.Id equals registerCheck.PatientRegisterId |
|
|
|
where registerCheck.Id == input.RegisterCheckId |
|
|
|
select new |
|
|
|
{ |
|
|
|
registerCheck |
|
|
|
}).FirstOrDefault(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (queryFirst != null && !string.IsNullOrWhiteSpace(queryFirst.registerCheck.GiveUpCheckFile)) |
|
|
|
{ |
|
|
|
|
|
|
|
string fileName = queryFirst.registerCheck.GiveUpCheckFile.TrimStart('/'); // 去除开头的 /
|
|
|
|
// fileName: SignatureTemplate/3a209c4d-cad9-ad05-62af-c7824067d8f7.html
|
|
|
|
|
|
|
|
string physicalPath = Path.Combine(Directory.GetCurrentDirectory(), fileName); |
|
|
|
|
|
|
|
|
|
|
|
if (File.Exists(physicalPath)) |
|
|
|
{ |
|
|
|
icContent = await File.ReadAllTextAsync(physicalPath, Encoding.UTF8); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var entDto = new GetRegisterCheckGiveUpCheckPictureByRegisterCheckIdDto |
|
|
|
{ |
|
|
|
GiveUpCheckContent = icContent |
|
|
|
}; |
|
|
|
|
|
|
|
return entDto; |
|
|
|
} |
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
@ -309,6 +358,7 @@ namespace Shentun.Peis.Paperlesss |
|
|
|
//知情同意书模板
|
|
|
|
var informedConsentTemplateList = await _informedConsentTemplateRepository.GetListAsync(); |
|
|
|
|
|
|
|
var giveUpCheckTemplateFirst = await _giveUpCheckTemplateRepository.FirstOrDefaultAsync(f => f.IsActive == 'Y'); |
|
|
|
|
|
|
|
//前置项目
|
|
|
|
var preCheckAsbitemList = (from preCheckAsbitem in await _preCheckAsbitemRepository.GetQueryableAsync() |
|
|
|
@ -337,16 +387,22 @@ namespace Shentun.Peis.Paperlesss |
|
|
|
PatientName = item.patientRegister.PatientName, |
|
|
|
RegisterCheckId = item.registerCheck.Id, |
|
|
|
IsBeforeEat = item.asbitem.IsBeforeEat, |
|
|
|
IsSignInformedConsent = 'N' |
|
|
|
IsSignInformedConsent = 'N', |
|
|
|
IsSignGiveUpCheck = 'N', |
|
|
|
GiveUpCheckTemplateId = giveUpCheckTemplateFirst != null ? giveUpCheckTemplateFirst.Id : null |
|
|
|
}; |
|
|
|
|
|
|
|
#region 是否签写知情同意书
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(item.registerCheck.InformedConsentFile) && !string.IsNullOrWhiteSpace(item.registerCheck.InformedConsentFile)) |
|
|
|
if (!string.IsNullOrWhiteSpace(item.registerCheck.InformedConsentFile) && !string.IsNullOrWhiteSpace(item.registerCheck.InformedConsentSignFile)) |
|
|
|
{ |
|
|
|
detailDto.IsSignInformedConsent = 'Y'; |
|
|
|
} |
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(item.registerCheck.GiveUpCheckFile) && !string.IsNullOrWhiteSpace(item.registerCheck.GiveUpCheckSignFile)) |
|
|
|
{ |
|
|
|
detailDto.IsSignGiveUpCheck = 'Y'; |
|
|
|
} |
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
@ -493,6 +549,13 @@ namespace Shentun.Peis.Paperlesss |
|
|
|
[HttpPost("api/app/Paperless/GiveCheckByRegisterCheckId")] |
|
|
|
public async Task GiveCheckByRegisterCheckIdAsync(GiveCheckByRegisterCheckIdInputDto input) |
|
|
|
{ |
|
|
|
|
|
|
|
if (input.GiveUpCheckTemplateId == null) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException("弃检模板id不能为空"); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(input.SignImageBase64)) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException("签名数据不能为空"); |
|
|
|
@ -517,15 +580,75 @@ namespace Shentun.Peis.Paperlesss |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 检查图片生成
|
|
|
|
#region 弃检签名图片生成
|
|
|
|
string imgurl = $"GiveUpSignFiles/{DateTime.Now.Year}/{DateTime.Now.Month}/{DateTime.Now.Day}/{registerCheck.PatientRegisterId}/give_up_sign"; |
|
|
|
var signUrl = ImageHelper.Base64StrToImage(input.SignImageBase64, imgurl); |
|
|
|
if (string.IsNullOrEmpty(signUrl)) |
|
|
|
throw new UserFriendlyException("签名base64数据不正确"); |
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 整个弃检文件生成
|
|
|
|
|
|
|
|
var giveUpCheckTemplateFirst = await _giveUpCheckTemplateRepository.FirstOrDefaultAsync(f => f.Id == input.GiveUpCheckTemplateId); |
|
|
|
if (giveUpCheckTemplateFirst == null) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException("弃检模板Id不正确"); |
|
|
|
} |
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(giveUpCheckTemplateFirst.GiveUpCheckTemplateFile)) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException("弃检模板不存在"); |
|
|
|
} |
|
|
|
|
|
|
|
string giveUpCheckTemplateFileName = giveUpCheckTemplateFirst.GiveUpCheckTemplateFile.TrimStart('/'); |
|
|
|
|
|
|
|
string physicalPath = Path.Combine(Directory.GetCurrentDirectory(), giveUpCheckTemplateFileName); |
|
|
|
|
|
|
|
if (!File.Exists(physicalPath)) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException("弃检模板文件有误"); |
|
|
|
} |
|
|
|
|
|
|
|
string content = await File.ReadAllTextAsync(physicalPath, Encoding.UTF8); |
|
|
|
|
|
|
|
// 替换签名占位符为 img 标签
|
|
|
|
string imgTag = @$"<img width=""100"" height=""50"" src=""{input.SignImageBase64}"">"; |
|
|
|
content = content.Replace("${signMan}", imgTag); |
|
|
|
|
|
|
|
// 替换日期占位符为当前日期 (yyyy-MM-dd)
|
|
|
|
string currentDate = DateTime.Now.ToString("yyyy-MM-dd"); |
|
|
|
content = content.Replace("${signDate}", currentDate); |
|
|
|
|
|
|
|
|
|
|
|
string saveML = $"/GiveUpCheckFiles/{DateTime.Now.Year}/{DateTime.Now.Month}/{DateTime.Now.Day}/{registerCheck.PatientRegisterId}"; |
|
|
|
string fileName = $"give_up_check{Path.GetExtension(giveUpCheckTemplateFirst.GiveUpCheckTemplateFile)}"; |
|
|
|
string giveUpCheckUrl = $"{saveML}/{fileName}"; |
|
|
|
|
|
|
|
// 创建目录(关键代码)
|
|
|
|
string fullDirectoryPath = Path.Combine(Directory.GetCurrentDirectory(), saveML.TrimStart('/')); |
|
|
|
if (!Directory.Exists(fullDirectoryPath)) |
|
|
|
{ |
|
|
|
Directory.CreateDirectory(fullDirectoryPath); |
|
|
|
} |
|
|
|
|
|
|
|
// 4. 完整的文件路径
|
|
|
|
string fullFilePath = Path.Combine(fullDirectoryPath, fileName); |
|
|
|
// 5. 写入HTML内容到文件
|
|
|
|
await File.WriteAllTextAsync(fullFilePath, content, Encoding.UTF8); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
registerCheck.CompleteFlag = RegisterCheckCompleteFlag.GiveUpChecked; |
|
|
|
registerCheck.GiveUpCheckSignFile = signUrl; |
|
|
|
registerCheck.GiveUpCheckFile = giveUpCheckUrl; |
|
|
|
|
|
|
|
await _registerCheckRepository.UpdateAsync(registerCheck); |
|
|
|
} |
|
|
|
@ -684,6 +807,46 @@ namespace Shentun.Peis.Paperlesss |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 获取弃检模板内容
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost("api/app/Paperless/GetGiveUpCheckTemplateByGiveUpCheckTemplateId")] |
|
|
|
public async Task<GetGiveUpCheckTemplateByGiveUpCheckTemplateIdDto> GetGiveUpCheckTemplateByGiveUpCheckTemplateIdAsync(GiveUpCheckTemplateIdInputDto input) |
|
|
|
{ |
|
|
|
//模板存储html文件
|
|
|
|
|
|
|
|
var giveUpCheckTemplateEnt = await _giveUpCheckTemplateRepository.GetAsync(input.GiveUpCheckTemplateId); |
|
|
|
|
|
|
|
string giveUpCheckTemplateFileContent = ""; |
|
|
|
if (!string.IsNullOrWhiteSpace(giveUpCheckTemplateEnt.GiveUpCheckTemplateFile)) |
|
|
|
{ |
|
|
|
|
|
|
|
string fileName = giveUpCheckTemplateEnt.GiveUpCheckTemplateFile.TrimStart('/'); // 去除开头的 /
|
|
|
|
// fileName: SignatureTemplate/3a209c4d-cad9-ad05-62af-c7824067d8f7.html
|
|
|
|
|
|
|
|
string physicalPath = Path.Combine(Directory.GetCurrentDirectory(), fileName); |
|
|
|
|
|
|
|
|
|
|
|
if (File.Exists(physicalPath)) |
|
|
|
{ |
|
|
|
giveUpCheckTemplateFileContent = await File.ReadAllTextAsync(physicalPath, Encoding.UTF8); |
|
|
|
|
|
|
|
giveUpCheckTemplateFileContent = giveUpCheckTemplateFileContent.Replace("${signMan}", "").Replace("${signDate}", ""); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
var entDto = new GetGiveUpCheckTemplateByGiveUpCheckTemplateIdDto |
|
|
|
{ |
|
|
|
GiveUpCheckTemplateContent = giveUpCheckTemplateFileContent |
|
|
|
}; |
|
|
|
return entDto; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 获取明细结果根据检查id
|
|
|
|
/// </summary>
|
|
|
|
|