Browse Source

弃检签名

master
wxd 1 day ago
parent
commit
603a6ad3f4
  1. 15
      src/Shentun.Peis.Application.Contracts/Paperlesss/GetAsbitemListByPatientRegisterIdDto.cs
  2. 14
      src/Shentun.Peis.Application.Contracts/Paperlesss/GetGiveUpCheckTemplateByGiveUpCheckTemplateIdDto.cs
  3. 14
      src/Shentun.Peis.Application.Contracts/Paperlesss/GetRegisterCheckGiveUpCheckPictureByRegisterCheckIdDto.cs
  4. 6
      src/Shentun.Peis.Application.Contracts/Paperlesss/GiveCheckByRegisterCheckIdInputDto.cs
  5. 173
      src/Shentun.Peis.Application/Paperlesss/PaperlessAppService.cs
  6. 14
      src/Shentun.Peis.HttpApi.Host/PeisHttpApiHostModule.cs

15
src/Shentun.Peis.Application.Contracts/Paperlesss/GetAsbitemListByPatientRegisterIdDto.cs

@ -41,20 +41,31 @@ namespace Shentun.Peis.Paperlesss
public char IsInformedConsent { get; set; } public char IsInformedConsent { get; set; }
/// <summary> /// <summary>
/// 是否签写 Y-以签写 N-未签
/// 是否签写知情同意书 Y-以签写 N-未签
/// </summary> /// </summary>
public char IsSignInformedConsent { get; set; } public char IsSignInformedConsent { get; set; }
/// <summary>
/// 是否签写弃检内容 Y-以签写 N-未签
/// </summary>
public char IsSignGiveUpCheck { get; set; }
/// <summary> /// <summary>
/// 知情同意书模板内容 /// 知情同意书模板内容
/// </summary> /// </summary>
public string InformedConsentTemplateContent { get; set; } public string InformedConsentTemplateContent { get; set; }
/// <summary> /// <summary>
/// 知情同意书模板内容
/// 知情同意书模板id
/// </summary> /// </summary>
public Guid? InformedConsentTemplateId { get; set; } public Guid? InformedConsentTemplateId { get; set; }
/// <summary>
/// 弃检模板id
/// </summary>
public Guid? GiveUpCheckTemplateId { get; set; }
/// <summary> /// <summary>
/// 检查状态 /// 检查状态
/// </summary> /// </summary>

14
src/Shentun.Peis.Application.Contracts/Paperlesss/GetGiveUpCheckTemplateByGiveUpCheckTemplateIdDto.cs

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Shentun.Peis.Paperlesss
{
public class GetGiveUpCheckTemplateByGiveUpCheckTemplateIdDto
{
/// <summary>
/// 模板内容 去掉标签
/// </summary>
public string GiveUpCheckTemplateContent { get; set; }
}
}

14
src/Shentun.Peis.Application.Contracts/Paperlesss/GetRegisterCheckGiveUpCheckPictureByRegisterCheckIdDto.cs

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Shentun.Peis.Paperlesss
{
public class GetRegisterCheckGiveUpCheckPictureByRegisterCheckIdDto
{
/// <summary>
/// 弃检文件内容
/// </summary>
public string GiveUpCheckContent { get; set; }
}
}

6
src/Shentun.Peis.Application.Contracts/Paperlesss/GiveCheckByRegisterCheckIdInputDto.cs

@ -9,5 +9,11 @@ namespace Shentun.Peis.Paperlesss
public Guid RegisterCheckId { get; set; } public Guid RegisterCheckId { get; set; }
public string SignImageBase64 { get; set; } public string SignImageBase64 { get; set; }
/// <summary>
/// 弃检模板id
/// </summary>
public Guid? GiveUpCheckTemplateId { get; set; }
} }
} }

173
src/Shentun.Peis.Application/Paperlesss/PaperlessAppService.cs

@ -5,6 +5,7 @@ using NPOI.HPSF;
using NPOI.HSSF.Record; using NPOI.HSSF.Record;
using NPOI.HSSF.Record.Chart; using NPOI.HSSF.Record.Chart;
using Shentun.Peis.Enums; using Shentun.Peis.Enums;
using Shentun.Peis.GiveUpCheckTemplates;
using Shentun.Peis.InformedConsentTemplates; using Shentun.Peis.InformedConsentTemplates;
using Shentun.Peis.Migrations; using Shentun.Peis.Migrations;
using Shentun.Peis.Models; using Shentun.Peis.Models;
@ -51,6 +52,7 @@ namespace Shentun.Peis.Paperlesss
private readonly IRepository<RoomDetail> _roomDetailRepository; private readonly IRepository<RoomDetail> _roomDetailRepository;
private readonly IRepository<QueueRegister, Guid> _queueRegisterRepository; private readonly IRepository<QueueRegister, Guid> _queueRegisterRepository;
private readonly QueueRegisterAppService _queueRegisterAppService; private readonly QueueRegisterAppService _queueRegisterAppService;
private readonly IRepository<GiveUpCheckTemplate, Guid> _giveUpCheckTemplateRepository;
public PaperlessAppService( public PaperlessAppService(
IRepository<PatientRegister, Guid> patientRegisterRepository, IRepository<PatientRegister, Guid> patientRegisterRepository,
IRepository<Patient, Guid> patientRepository, IRepository<Patient, Guid> patientRepository,
@ -70,7 +72,8 @@ namespace Shentun.Peis.Paperlesss
IRepository<DoctorSignIn, Guid> doctorSignInRepository, IRepository<DoctorSignIn, Guid> doctorSignInRepository,
IRepository<RoomDetail> roomDetailRepository, IRepository<RoomDetail> roomDetailRepository,
IRepository<QueueRegister, Guid> queueRegisterRepository, IRepository<QueueRegister, Guid> queueRegisterRepository,
QueueRegisterAppService queueRegisterAppService)
QueueRegisterAppService queueRegisterAppService,
IRepository<GiveUpCheckTemplate, Guid> giveUpCheckTemplateRepository)
{ {
_patientRegisterRepository = patientRegisterRepository; _patientRegisterRepository = patientRegisterRepository;
_patientRepository = patientRepository; _patientRepository = patientRepository;
@ -91,6 +94,7 @@ namespace Shentun.Peis.Paperlesss
_roomDetailRepository = roomDetailRepository; _roomDetailRepository = roomDetailRepository;
_queueRegisterRepository = queueRegisterRepository; _queueRegisterRepository = queueRegisterRepository;
_queueRegisterAppService = queueRegisterAppService; _queueRegisterAppService = queueRegisterAppService;
_giveUpCheckTemplateRepository = giveUpCheckTemplateRepository;
} }
#region 体检系统用 #region 体检系统用
@ -203,6 +207,51 @@ namespace Shentun.Peis.Paperlesss
return entDto; 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 #endregion
@ -309,6 +358,7 @@ namespace Shentun.Peis.Paperlesss
//知情同意书模板 //知情同意书模板
var informedConsentTemplateList = await _informedConsentTemplateRepository.GetListAsync(); var informedConsentTemplateList = await _informedConsentTemplateRepository.GetListAsync();
var giveUpCheckTemplateFirst = await _giveUpCheckTemplateRepository.FirstOrDefaultAsync(f => f.IsActive == 'Y');
//前置项目 //前置项目
var preCheckAsbitemList = (from preCheckAsbitem in await _preCheckAsbitemRepository.GetQueryableAsync() var preCheckAsbitemList = (from preCheckAsbitem in await _preCheckAsbitemRepository.GetQueryableAsync()
@ -337,16 +387,22 @@ namespace Shentun.Peis.Paperlesss
PatientName = item.patientRegister.PatientName, PatientName = item.patientRegister.PatientName,
RegisterCheckId = item.registerCheck.Id, RegisterCheckId = item.registerCheck.Id,
IsBeforeEat = item.asbitem.IsBeforeEat, IsBeforeEat = item.asbitem.IsBeforeEat,
IsSignInformedConsent = 'N'
IsSignInformedConsent = 'N',
IsSignGiveUpCheck = 'N',
GiveUpCheckTemplateId = giveUpCheckTemplateFirst != null ? giveUpCheckTemplateFirst.Id : null
}; };
#region 是否签写知情同意书 #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'; detailDto.IsSignInformedConsent = 'Y';
} }
if (!string.IsNullOrWhiteSpace(item.registerCheck.GiveUpCheckFile) && !string.IsNullOrWhiteSpace(item.registerCheck.GiveUpCheckSignFile))
{
detailDto.IsSignGiveUpCheck = 'Y';
}
#endregion #endregion
@ -493,6 +549,13 @@ namespace Shentun.Peis.Paperlesss
[HttpPost("api/app/Paperless/GiveCheckByRegisterCheckId")] [HttpPost("api/app/Paperless/GiveCheckByRegisterCheckId")]
public async Task GiveCheckByRegisterCheckIdAsync(GiveCheckByRegisterCheckIdInputDto input) public async Task GiveCheckByRegisterCheckIdAsync(GiveCheckByRegisterCheckIdInputDto input)
{ {
if (input.GiveUpCheckTemplateId == null)
{
throw new UserFriendlyException("弃检模板id不能为空");
}
if (string.IsNullOrWhiteSpace(input.SignImageBase64)) if (string.IsNullOrWhiteSpace(input.SignImageBase64))
{ {
throw new UserFriendlyException("签名数据不能为空"); throw new UserFriendlyException("签名数据不能为空");
@ -515,17 +578,77 @@ namespace Shentun.Peis.Paperlesss
throw new UserFriendlyException("人员已总检,不允许弃检操作"); throw new UserFriendlyException("人员已总检,不允许弃检操作");
} }
#region 检查图片生成
#region 弃检签名图片生成
string imgurl = $"GiveUpSignFiles/{DateTime.Now.Year}/{DateTime.Now.Month}/{DateTime.Now.Day}/{registerCheck.PatientRegisterId}/give_up_sign"; string imgurl = $"GiveUpSignFiles/{DateTime.Now.Year}/{DateTime.Now.Month}/{DateTime.Now.Day}/{registerCheck.PatientRegisterId}/give_up_sign";
var signUrl = ImageHelper.Base64StrToImage(input.SignImageBase64, imgurl); var signUrl = ImageHelper.Base64StrToImage(input.SignImageBase64, imgurl);
if (string.IsNullOrEmpty(signUrl)) if (string.IsNullOrEmpty(signUrl))
throw new UserFriendlyException("签名base64数据不正确"); throw new UserFriendlyException("签名base64数据不正确");
#endregion #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.CompleteFlag = RegisterCheckCompleteFlag.GiveUpChecked;
registerCheck.GiveUpCheckSignFile = signUrl; registerCheck.GiveUpCheckSignFile = signUrl;
registerCheck.GiveUpCheckFile = giveUpCheckUrl;
await _registerCheckRepository.UpdateAsync(registerCheck); 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> /// <summary>
/// 获取明细结果根据检查id /// 获取明细结果根据检查id
/// </summary> /// </summary>

14
src/Shentun.Peis.HttpApi.Host/PeisHttpApiHostModule.cs

@ -326,6 +326,11 @@ public class PeisHttpApiHostModule : AbpModule
Directory.CreateDirectory(informedConsentFilesPath); Directory.CreateDirectory(informedConsentFilesPath);
} }
var giveUpCheckFilesPath = Path.Combine(hostingEnvironment.ContentRootPath, "GiveUpCheckFiles");
if (!Directory.Exists(giveUpCheckFilesPath))
{
Directory.CreateDirectory(giveUpCheckFilesPath);
}
var informedConsentSignFilesPath = Path.Combine(hostingEnvironment.ContentRootPath, "InformedConsentSignFiles"); var informedConsentSignFilesPath = Path.Combine(hostingEnvironment.ContentRootPath, "InformedConsentSignFiles");
if (!Directory.Exists(informedConsentSignFilesPath)) if (!Directory.Exists(informedConsentSignFilesPath))
{ {
@ -734,12 +739,21 @@ public class PeisHttpApiHostModule : AbpModule
RequestPath = "/GiveUpSignFiles" RequestPath = "/GiveUpSignFiles"
}); });
app.UseStaticFiles(new StaticFileOptions
{
FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), "GiveUpCheckFiles")),
RequestPath = "/GiveUpCheckFiles"
});
app.UseStaticFiles(new StaticFileOptions app.UseStaticFiles(new StaticFileOptions
{ {
FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), "InformedConsentFiles")), FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), "InformedConsentFiles")),
RequestPath = "/InformedConsentFiles" RequestPath = "/InformedConsentFiles"
}); });
app.UseStaticFiles(new StaticFileOptions app.UseStaticFiles(new StaticFileOptions
{ {
FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), "InformedConsentSignFiles")), FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), "InformedConsentSignFiles")),

Loading…
Cancel
Save