From b1bcbad471abb95eba408e7b19f57bdf92875a9b Mon Sep 17 00:00:00 2001
From: "DESKTOP-G961P6V\\Zhh" <839860190@qq.com>
Date: Fri, 12 Apr 2024 14:55:38 +0800
Subject: [PATCH] =?UTF-8?q?=E8=AE=A1=E7=AE=97=E5=87=BD=E6=95=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../PatientRegisterNoInputDto.cs | 17 ++
.../PatientRegisterOrNoDto.cs | 6 +-
.../DiagnosisFunctions/CodeBuilder.cs | 108 +++++++++
.../DiagnosisFunctionAppService.cs | 80 +++++-
.../PatientRegisterAppService.cs | 121 ++++++++-
src/Shentun.Peis.Domain/CacheService.cs | 125 +++++++++-
src/Shentun.Peis.Domain/CompileHelper.cs | 7 +
.../RegisterCheckAsbitemManager.cs | 29 +--
.../DiagnosisFunctionAppServiceTest.cs | 153 ++++++++++++
.../PatientRegisterAppServiceTest.cs | 229 +++++++++++-------
10 files changed, 759 insertions(+), 116 deletions(-)
create mode 100644 src/Shentun.Peis.Application.Contracts/PatientRegisters/PatientRegisterNoInputDto.cs
create mode 100644 src/Shentun.Peis.Application/DiagnosisFunctions/CodeBuilder.cs
create mode 100644 test/Shentun.Peis.Application.Tests/DiagnosisFunctionAppServiceTest.cs
diff --git a/src/Shentun.Peis.Application.Contracts/PatientRegisters/PatientRegisterNoInputDto.cs b/src/Shentun.Peis.Application.Contracts/PatientRegisters/PatientRegisterNoInputDto.cs
new file mode 100644
index 0000000..e0d4474
--- /dev/null
+++ b/src/Shentun.Peis.Application.Contracts/PatientRegisters/PatientRegisterNoInputDto.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Shentun.Peis.PatientRegisters
+{
+ public class PatientRegisterNoInputDto
+ {
+
+ public string PatientRegisterNo { get; set; }
+
+ ///
+ /// 档案号
+ ///
+ public string PatientNo { get; set; }
+ }
+}
diff --git a/src/Shentun.Peis.Application.Contracts/PatientRegisters/PatientRegisterOrNoDto.cs b/src/Shentun.Peis.Application.Contracts/PatientRegisters/PatientRegisterOrNoDto.cs
index cca5745..6e6ad48 100644
--- a/src/Shentun.Peis.Application.Contracts/PatientRegisters/PatientRegisterOrNoDto.cs
+++ b/src/Shentun.Peis.Application.Contracts/PatientRegisters/PatientRegisterOrNoDto.cs
@@ -42,6 +42,7 @@ namespace Shentun.Peis.PatientRegisters
/// 性别
///
public char? SexId { get; set; }
+ public string SexName { get; set; }
///
/// 出生日期
///
@@ -62,14 +63,17 @@ namespace Shentun.Peis.PatientRegisters
/// 婚姻状况
///
public char? MaritalStatusId { get; set; }
+ public string MaritalStatusName { get; set; }
///
/// 体检类别
///
public Guid? MedicalTypeId { get; set; }
+ public string MedicalTypeName { get; set; }
///
/// 人员类别
///
public Guid? PersonnelTypeId { get; set; }
+ public string PersonnelTypeName { get; set; }
///
/// 职务
///
@@ -200,7 +204,7 @@ namespace Shentun.Peis.PatientRegisters
/// 民族编号
///
public string? NationId { get; set; }
-
+ public string? NationName { get; set; }
///
/// 出生地
///
diff --git a/src/Shentun.Peis.Application/DiagnosisFunctions/CodeBuilder.cs b/src/Shentun.Peis.Application/DiagnosisFunctions/CodeBuilder.cs
new file mode 100644
index 0000000..ef19b51
--- /dev/null
+++ b/src/Shentun.Peis.Application/DiagnosisFunctions/CodeBuilder.cs
@@ -0,0 +1,108 @@
+using Microsoft.CodeAnalysis.CSharp;
+using Microsoft.CodeAnalysis.Emit;
+using Microsoft.CodeAnalysis;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Reflection;
+namespace Shentun.Peis.DiagnosisFunctions
+{
+ public class CodeBuilder
+ {
+ private static List _references = new List();
+ ///
+ /// 编译前的初始化,只需要一次
+ ///
+ ///
+ static CodeBuilder()
+ {
+ _references = new List();
+
+ // 元数据引用
+ if (_references == null || _references.Count == 0)
+ {
+ _references = new List()
+ {
+ MetadataReference.CreateFromFile(typeof(System.Uri).Assembly.Location),
+ MetadataReference.CreateFromFile(typeof(System.Linq.Enumerable).Assembly.Location),
+ MetadataReference.CreateFromFile(typeof(object).Assembly.Location),
+ MetadataReference.CreateFromFile(typeof(System.IO.File).Assembly.Location),
+ MetadataReference.CreateFromFile(Assembly.Load("System.Runtime").Location),
+ MetadataReference.CreateFromFile(Assembly.Load("System.Collections").Location),
+ MetadataReference.CreateFromFile(Assembly.LoadFrom(AppDomain.CurrentDomain.BaseDirectory+"Shentun.Peis.Application.dll").Location),
+ };
+ }
+ //Assembly as1 = Assembly.LoadFrom(AppDomain.CurrentDomain.BaseDirectory + "mscorlib.dll");
+ //MetadataReference metadataReference = _references.Find((o => o.Display.Contains("mscorlib.dll")));
+ //if (_references.Find((o => o.Display.Contains("mscorlib.dll"))) == null)
+ //{
+ // _references.Add(MetadataReference.CreateFromFile(as1.Location));
+ //}
+ }
+
+ //public CodeBuilder()
+ //{
+ //}
+ //public Assembly CreateCode(string code)
+ //{
+ // //var domain = new NatashaDomain("key");
+ // //var domain = DomainManagement.Random();
+ // NatashaManagement.Preheating();
+ // Path.GetRandomFileName();
+ // using (DomainManagement.Create("myDomain").CreateScope())
+ // {
+ // AssemblyCSharpBuilder builder = new AssemblyCSharpBuilder();
+ // builder.Add(code);
+ // var func = builder.GetDelegateFromShortName>("Test", "GetName");
+ // }
+
+ // return myAssembly;
+ //}
+ public Assembly GenerateAssemblyFromCode(string code, params Assembly[] referencedAssemblies)
+ {
+ Assembly assembly = null;
+
+ // 丛代码中转换表达式树
+ SyntaxTree syntaxTree = CSharpSyntaxTree.ParseText(code);
+ // 随机程序集名称
+ //string assemblyName = Path.GetRandomFileName();
+ var assemblyName = "_" + Guid.NewGuid().ToString("D");
+ //assemblyName = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;
+ //assemblyName = "Shentun.Peis.Application";
+ var syntaxTrees = new SyntaxTree[] { syntaxTree };
+ // 引用
+ var references = _references;// referencedAssemblies.Select(x => MetadataReference.CreateFromFile(x.Location));
+ var options = new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary);
+
+ // 创建编译对象
+ CSharpCompilation compilation = CSharpCompilation.Create(assemblyName, syntaxTrees, references, options);
+
+ using (var ms = new MemoryStream())
+ {
+ // 将编译好的IL代码放入内存流
+ EmitResult result = compilation.Emit(ms);
+
+ // 编译失败,提示
+ if (!result.Success)
+ {
+ IEnumerable failures = result.Diagnostics.Where(diagnostic =>
+ diagnostic.IsWarningAsError ||
+ diagnostic.Severity == DiagnosticSeverity.Error);
+ foreach (Diagnostic diagnostic in failures)
+ {
+ Console.Error.WriteLine("{0}: {1}", diagnostic.Id, diagnostic.GetMessage());
+ }
+ }
+ else
+ {
+ // 编译成功,从内存中加载编译好的程序集
+ ms.Seek(0, SeekOrigin.Begin);
+ assembly = Assembly.Load(ms.ToArray());
+ }
+ }
+ return assembly;
+ }
+ }
+
+}
diff --git a/src/Shentun.Peis.Application/DiagnosisFunctions/DiagnosisFunctionAppService.cs b/src/Shentun.Peis.Application/DiagnosisFunctions/DiagnosisFunctionAppService.cs
index 3dfcb74..bf7c586 100644
--- a/src/Shentun.Peis.Application/DiagnosisFunctions/DiagnosisFunctionAppService.cs
+++ b/src/Shentun.Peis.Application/DiagnosisFunctions/DiagnosisFunctionAppService.cs
@@ -10,14 +10,12 @@ using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
-using TencentCloud.Ccc.V20200210.Models;
-using TencentCloud.Mps.V20190612.Models;
-using TencentCloud.Npp.V20190823.Models;
using Volo.Abp;
using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Uow;
+
namespace Shentun.Peis.DiagnosisFunctions
{
[ApiExplorerSettings(GroupName = "Work")]
@@ -854,9 +852,85 @@ namespace Shentun.Peis.DiagnosisFunctions
return tempcode;
}
+
+ public string GetItemResult(PatientDiagnosisInputArg patient, string codeInput)
+ {
+ string result = "";
+ string code = @"
+using System;
+using System.IO;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.Concurrent;
+using System.Linq;
+using Shentun.Peis.DiagnosisFunctions;
+
+ public class DiagnosisResultInAsbitemHeight
+ {
+ public string GetDiagnosisResult(PatientDiagnosisInputArg patient)
+ {
+ "
+ + codeInput + @"
+
+ }
+ }
+";
+
+ CompileHelper compileHelper = new CompileHelper();
+ CodeBuilder codeBuilder = new CodeBuilder();
+ Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
+
+
+ var assembly = codeBuilder.GenerateAssemblyFromCode(code, Assembly.Load(new AssemblyName("System.Runtime")), typeof(object).Assembly);
+ //var assembly = compileHelper.GenerateAssemblyFromCode(code, assemblies);
+ // var assembly = codeBuilder.GenerateAssemblyFromCode(code, assemblies);
+ //var assembly = codeBuilder.CreateCode(code);
+ if (assembly != null)
+ {
+
+ // 反射获取程序集中 的类
+ Type type = assembly.GetType("DiagnosisResultInAsbitemHeight");
+
+ // 创建该类的实例
+ object obj = Activator.CreateInstance(type);
+ object[] objects = { patient };
+ ;
+ var msg = type.InvokeMember("GetDiagnosisResult",
+ BindingFlags.Default | BindingFlags.InvokeMethod,
+ null,
+ obj,
+ objects);
+ if(msg == null)
+ {
+ return "";
+ }
+ if (!string.IsNullOrEmpty(msg.ToString()))
+ {
+ result = msg.ToString();
+ }
+ }
+
+ return result;
+ }
+
}
+ public class PatientDiagnosisInputArg()
+ {
+ public string SexName { get; set; }
+ public short Age { get; set; }
+ public Guid AsbitemId { get; set; }
+ public string AsbitemName { get; set; }
+ public List Items { get; set; } = new List();
+
+ }
+ public class ItemDiagnosisInputArg
+ {
+ public Guid ItemId { get; set; }
+ public string ItemName { get; set; }
+ public string Result { get; set; }
+ }
}
diff --git a/src/Shentun.Peis.Application/PatientRegisters/PatientRegisterAppService.cs b/src/Shentun.Peis.Application/PatientRegisters/PatientRegisterAppService.cs
index 852bc02..eb44466 100644
--- a/src/Shentun.Peis.Application/PatientRegisters/PatientRegisterAppService.cs
+++ b/src/Shentun.Peis.Application/PatientRegisters/PatientRegisterAppService.cs
@@ -30,6 +30,7 @@ using System.Threading.Tasks;
using TencentCloud.Cwp.V20180228.Models;
using TencentCloud.Mps.V20190612.Models;
using TencentCloud.Npp.V20190823.Models;
+using TencentCloud.Trtc.V20190722.Models;
using Volo.Abp;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
@@ -541,6 +542,120 @@ namespace Shentun.Peis.PatientRegisters
return entdto;
}
+ ///
+ /// 获取档案登记信息 根据档案号或者条码号(档案号条件返回最新的一条)
+ ///
+ ///
+ ///
+ ///
+ [HttpPost("api/app/patientregister/GetAlreadyRegisterPatientRegisterByNo")]
+ public async Task GetAlreadyRegisterPatientRegisterByNoAsync(PatientRegisterNoInputDto input)
+ {
+ var query = (await _repository.GetQueryableAsync()).Include(x => x.Patient).AsQueryable();
+ var patientRegisterList = new List();
+ PatientRegister ent = null;
+ if (!string.IsNullOrWhiteSpace(input.PatientRegisterNo))
+ {
+ ent = query.Where(m => m.PatientRegisterNo == input.PatientRegisterNo).First();
+ if (ent == null)
+ {
+ throw new UserFriendlyException("未找到人员信息");
+ }
+
+
+ }
+
+ else if (!string.IsNullOrWhiteSpace(input.PatientNo))
+ {
+ patientRegisterList = query.Where(m => m.Patient.PatientNo == input.PatientNo).OrderByDescending(o => o.MedicalTimes).ToList();
+ if (patientRegisterList.Count == 0)
+ {
+ throw new UserFriendlyException("未找到人员信息");
+ }
+ ent = patientRegisterList.First();
+
+ }
+
+ else
+ {
+ throw new UserFriendlyException("人员登记号和档案号至少有一个");
+ }
+ if (ent.CompleteFlag == PatientRegisterCompleteFlag.PreRegistration)
+ {
+ throw new UserFriendlyException("该人未正式登记");
+ }
+
+ var entdto = new PatientRegisterOrNoDto
+ {
+ CreationTime = ent.CreationTime,
+ CreatorId = ent.CreatorId,
+ Id = ent.Id,
+ LastModificationTime = ent.LastModificationTime,
+ LastModifierId = ent.LastModifierId,
+ ThirdInfo = ent.ThirdInfo,
+ SummaryDoctor = ent.SummaryDoctor,
+ SummaryDate = ent.SummaryDate.ToString(),
+ SexId = ent.SexId,
+ SexName = _cacheService.GetSexNameAsync(ent.SexId).Result,
+ Age = ent.Age,
+ AuditDate = ent.AuditDate.ToString(),
+ AuditDoctor = ent.AuditDoctor,
+ BirthDate = ent.BirthDate.ToString(),
+ CompleteFlag = ent.CompleteFlag,
+ CustomerOrgGroupId = ent.CustomerOrgGroupId,
+ CustomerOrgId = ent.CustomerOrgId,
+ CustomerOrgRegisterId = ent.CustomerOrgRegisterId,
+ GuidePrintTimes = ent.GuidePrintTimes,
+ InterposeMeasure = ent.InterposeMeasure,
+ IsAudit = ent.IsAudit,
+ IsLock = ent.IsLock,
+ IsMedicalStart = ent.IsMedicalStart,
+ IsNameHide = ent.IsNameHide,
+ IsPhoneFollow = ent.IsPhoneFollow,
+ IsRecoverGuide = ent.IsRecoverGuide,
+ IsUpload = ent.IsUpload,
+ IsVip = ent.IsVip,
+ JobCardNo = ent.JobCardNo,
+ JobPost = ent.JobPost,
+ JobTitle = ent.JobTitle,
+ MaritalStatusId = ent.MaritalStatusId,
+ MaritalStatusName = _cacheService.GetMaritalStatusNameAsync(ent.MaritalStatusId).Result,
+ MedicalCardNo = ent.MedicalCardNo,
+ MedicalConclusionId = ent.MedicalConclusionId,
+ MedicalPackageId = ent.MedicalPackageId,
+ MedicalStartDate = ent.MedicalStartDate.ToString(),
+ MedicalTimes = ent.MedicalTimes,
+ MedicalTypeId = ent.MedicalTypeId,
+ MedicalTypeName = _cacheService.GetMedicalTypeNameAsync(ent.MedicalTypeId).Result,
+ MedicalCenterId = ent.MedicalCenterId,
+ PatientId = ent.PatientId,
+ PatientName = ent.PatientName,
+ PatientRegisterNo = ent.PatientRegisterNo,
+ PersonnelTypeId = ent.PersonnelTypeId,
+ PersonnelTypeName = _cacheService.GetPersonnelTypeNameAsync(ent.PersonnelTypeId).Result,
+ Remark = ent.Remark,
+ ReportPrintTimes = ent.ReportPrintTimes,
+ Salesman = ent.Salesman,
+ SexHormoneTermId = ent.SexHormoneTermId,
+ CreatorName = _cacheService.GetUserNameAsync(ent.CreatorId).Result,
+ LastModifierName = _cacheService.GetUserNameAsync(ent.LastModifierId).Result,
+ Address = ent.Patient.Address, //档案表信息
+ BirthPlaceId = ent.Patient.BirthPlaceId,
+ DisplayName = ent.Patient.DisplayName,
+ Email = ent.Patient.Email,
+ IdNo = ent.Patient.IdNo,
+ MobileTelephone = ent.Patient.MobileTelephone,
+ NationId = ent.Patient.NationId,
+ NationName = _cacheService.GetNationNameAsync(ent.Patient.NationId).Result,
+ PatientNo = ent.Patient.PatientNo,
+ PostalCode = ent.Patient.PostalCode,
+ Telephone = ent.Patient.Telephone,
+ CustomerOrgName = _cacheService.GetCustomerOrgNameAsync(ent.CustomerOrgId).Result,
+ CustomerOrgParentId = _cacheService.GetTopCustomerOrgAsync(ent.CustomerOrgId).Result.Id,
+ CustomerOrgParentName = _cacheService.GetTopCustomerOrgAsync(ent.CustomerOrgId).Result.DisplayName
+ };
+ return entdto;
+ }
/////
@@ -1438,7 +1553,7 @@ namespace Shentun.Peis.PatientRegisters
PayTypeFlag = PayTypeFlag.OrgPay,
StandardPrice = s.Asbitem.Price
}).ToList();
-
+
createRegisterCheckAsbitemEntity = await _registerAsbitemManager.UpdateManyAsync(patientRegister, registerAsbitems);
if (createRegisterCheckAsbitemEntity != null)
@@ -1723,7 +1838,7 @@ namespace Shentun.Peis.PatientRegisters
}
-
+
///
/// 按历史登记导入体检名单操作
///
@@ -1787,7 +1902,7 @@ namespace Shentun.Peis.PatientRegisters
PayTypeFlag = PayTypeFlag.OrgPay,
StandardPrice = s.Asbitem.Price
}).ToList();
-
+
var createRegisterCheckAsbitemEntity = await _registerAsbitemManager.UpdateManyAsync(patientRegister, registerAsbitems);
if (createRegisterCheckAsbitemEntity != null)
diff --git a/src/Shentun.Peis.Domain/CacheService.cs b/src/Shentun.Peis.Domain/CacheService.cs
index caacbc0..fce3e44 100644
--- a/src/Shentun.Peis.Domain/CacheService.cs
+++ b/src/Shentun.Peis.Domain/CacheService.cs
@@ -16,10 +16,14 @@ namespace Shentun.Peis
public class CacheService : ISingletonDependency
{
private readonly IDistributedCache _userCache;
+ private readonly IDistributedCache _customerOrgCache;
private readonly IDistributedCache _nationCache;
private readonly IDistributedCache _sexCache;
+ private readonly IDistributedCache _maritalStatusCache;
private readonly IDistributedCache _forSexCache;
private readonly IDistributedCache _deviceTypeCache;
+ private readonly IDistributedCache _medicalTypeCache;
+ private readonly IDistributedCache _personnelTypeCache;
private readonly IDistributedCache _asbitemCache;
private readonly IDistributedCache _itemTypeCache;
private readonly IRepository _userRepository;
@@ -29,13 +33,22 @@ namespace Shentun.Peis
private readonly IRepository _deviceTypeRepository;
private readonly IRepository _asbitemRepository;
private readonly IRepository _itemTypeRepository;
+ private readonly IRepository _customerOrgRepository;
+ private readonly IRepository _maritalStatusRepository;
+ private readonly IRepository _medicalTypeRepository;
+ private readonly IRepository _personnelTypeRepository;
+
public CacheService(
IDistributedCache userCache,
+ IDistributedCache customerOrgCache,
IDistributedCache nationCache,
IRepository userRepository,
IDistributedCache sexCache,
IDistributedCache asbitemCache,
IDistributedCache itemTypeCache,
+ IDistributedCache maritalStatusCache,
+ IDistributedCache medicalTypeCache,
+ IDistributedCache personnelTypeCache,
IRepository sexRepository,
IDistributedCache deviceTypeCache,
IRepository deviceTypeRepository,
@@ -43,7 +56,11 @@ namespace Shentun.Peis
IRepository forSexRepository,
IRepository asbitemRepository,
IRepository itemTypeRepository,
- IRepository nationRepository
+ IRepository nationRepository,
+ IRepository customerOrgRepository,
+ IRepository maritalStatusRepository,
+ IRepository medicalTypeRepository,
+ IRepository personnelTypeRepository
)
{
_userCache = userCache;
@@ -66,6 +83,18 @@ namespace Shentun.Peis
_nationCache = nationCache;
_nationRepository = nationRepository;
+
+ _customerOrgCache = customerOrgCache;
+ _customerOrgRepository = customerOrgRepository;
+
+ _maritalStatusCache = maritalStatusCache;
+ _maritalStatusRepository = maritalStatusRepository;
+
+ _medicalTypeCache = medicalTypeCache;
+ _medicalTypeRepository = medicalTypeRepository;
+
+ _personnelTypeCache = personnelTypeCache;
+ _personnelTypeRepository = personnelTypeRepository;
}
private async Task GetUserAsync(Guid id)
@@ -120,6 +149,22 @@ namespace Shentun.Peis
return entity.DisplayName;
}
+ private async Task GetMaritalStatusAsync(char id)
+ {
+
+ var entity = await _maritalStatusCache.GetOrAddAsync(
+ id, //缓存键
+ async () => (await _maritalStatusRepository.GetQueryableAsync()).Where(o => o.Id == id).Single()
+ );
+ return entity;
+ }
+ public async Task GetMaritalStatusNameAsync(char id)
+ {
+
+ var entity = await GetMaritalStatusAsync(id);
+ return entity.DisplayName;
+ }
+
private async Task GetDeviceTypeAsync(Guid id)
{
@@ -140,6 +185,45 @@ namespace Shentun.Peis
return entity.DisplayName;
}
+ private async Task GetMedicalTypeAsync(Guid id)
+ {
+
+ var entity = await _medicalTypeCache.GetOrAddAsync(
+ id, //缓存键
+ async () => await _medicalTypeRepository.GetAsync(id)
+
+ );
+ return entity;
+ }
+ public async Task GetMedicalTypeNameAsync(Guid? id)
+ {
+ if (id == null || id == default(Guid) || !id.HasValue)
+ {
+ return "";
+ }
+ var entity = await GetMedicalTypeAsync((Guid)id);
+ return entity.DisplayName;
+ }
+ private async Task GetPersonnelTypeAsync(Guid id)
+ {
+
+ var entity = await _personnelTypeCache.GetOrAddAsync(
+ id, //缓存键
+ async () => await _personnelTypeRepository.GetAsync(id)
+
+ );
+ return entity;
+ }
+ public async Task GetPersonnelTypeNameAsync(Guid? id)
+ {
+ if (id == null || id == default(Guid) || !id.HasValue)
+ {
+ return "";
+ }
+ var entity = await GetPersonnelTypeAsync((Guid)id);
+ return entity.DisplayName;
+ }
+
public async Task GetAsbitemAsync(Guid id)
{
@@ -167,7 +251,7 @@ namespace Shentun.Peis
var entity = await _nationCache.GetOrAddAsync(
id, //缓存键
- async () => await _nationRepository.GetAsync(o=>o.Id == id)
+ async () => await _nationRepository.GetAsync(o => o.Id == id)
);
return entity;
@@ -183,5 +267,42 @@ namespace Shentun.Peis
return entity.DisplayName;
}
+ public async Task GetCustomerOrgAsync(Guid id)
+ {
+
+ var entity = await _customerOrgCache.GetOrAddAsync(
+ id, //缓存键
+ async () => await _customerOrgRepository.GetAsync(o => o.Id == id)
+
+ );
+ return entity;
+ }
+
+ public async Task GetCustomerOrgNameAsync(Guid? id)
+ {
+ if (id == null || id == default(Guid) || !id.HasValue)
+ {
+ return "";
+ }
+ var entity = await GetCustomerOrgAsync((Guid)id);
+ return entity.DisplayName;
+ }
+
+ public async Task GetTopCustomerOrgAsync(Guid id)
+ {
+
+ var entity = await _customerOrgCache.GetOrAddAsync(
+ id, //缓存键
+ async () => await _customerOrgRepository.GetAsync(o => o.Id == id)
+
+ );
+
+ if (entity.ParentId != null && entity.ParentId != Guid.Empty)
+ {
+ entity = await GetTopCustomerOrgAsync((Guid)entity.ParentId);
+ }
+ return entity;
+ }
+
}
}
diff --git a/src/Shentun.Peis.Domain/CompileHelper.cs b/src/Shentun.Peis.Domain/CompileHelper.cs
index 1465052..0d6dacf 100644
--- a/src/Shentun.Peis.Domain/CompileHelper.cs
+++ b/src/Shentun.Peis.Domain/CompileHelper.cs
@@ -8,11 +8,14 @@ using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
+using NPOI.SS.Formula.Functions;
+using Microsoft.EntityFrameworkCore.Metadata.Internal;
namespace Shentun.Peis
{
public class CompileHelper
{
+
///
/// 动态编译
///
@@ -27,6 +30,8 @@ namespace Shentun.Peis
// 随机程序集名称
//string assemblyName = Path.GetRandomFileName();
var assemblyName = "_" + Guid.NewGuid().ToString("D");
+ //assemblyName = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;
+ //assemblyName = "Shentun.Peis.Application";
var syntaxTrees = new SyntaxTree[] { syntaxTree };
// 引用
var references = referencedAssemblies.Select(x => MetadataReference.CreateFromFile(x.Location));
@@ -60,5 +65,7 @@ namespace Shentun.Peis
}
return assembly;
}
+
+
}
}
diff --git a/src/Shentun.Peis.Domain/RegisterCheckAsbitems/RegisterCheckAsbitemManager.cs b/src/Shentun.Peis.Domain/RegisterCheckAsbitems/RegisterCheckAsbitemManager.cs
index 440af32..950067f 100644
--- a/src/Shentun.Peis.Domain/RegisterCheckAsbitems/RegisterCheckAsbitemManager.cs
+++ b/src/Shentun.Peis.Domain/RegisterCheckAsbitems/RegisterCheckAsbitemManager.cs
@@ -372,17 +372,17 @@ namespace Shentun.Peis.RegisterAsbitems
var existRegisterItems = (await _registerCheckItemRepository.GetQueryableAsync()).Where(o =>
existRegisterChecks.Select(x => x.Id).Contains(o.RegisterCheckId)).ToList();
- if (registerAsbitems == null || registerAsbitems.Count == 0)
- {
- //删除登记的组合项目信息
- if (existRegisterChecks.Count > 0)
- {
- createRegisterCheckAsbitemEntity.DeleteRegisterChecks = existRegisterChecks;
- createRegisterCheckAsbitemEntity.DeleteRegisterCheckAsbitems = existRegisterAsbitems;
- createRegisterCheckAsbitemEntity.DeleteRegisterCheckItems = existRegisterItems;
- }
- return createRegisterCheckAsbitemEntity;
- }
+ //if (registerAsbitems == null || registerAsbitems.Count == 0)
+ //{
+ // //删除登记的组合项目信息
+ // if (existRegisterChecks.Count > 0)
+ // {
+ // createRegisterCheckAsbitemEntity.DeleteRegisterChecks = existRegisterChecks;
+ // createRegisterCheckAsbitemEntity.DeleteRegisterCheckAsbitems = existRegisterAsbitems;
+ // createRegisterCheckAsbitemEntity.DeleteRegisterCheckItems = existRegisterItems;
+ // }
+ // return createRegisterCheckAsbitemEntity;
+ //}
//获取删除的组合项目
foreach (var existRegisterAsbitem in existRegisterAsbitems)
{
@@ -421,7 +421,8 @@ namespace Shentun.Peis.RegisterAsbitems
}
if (registerAsbitem.Id == Guid.Empty)
{
- if (existRegisterAsbitems.Where(o => o.AsbitemId == registerAsbitem.AsbitemId).Count() > 0)
+ if (existRegisterAsbitems.Where(o => o.AsbitemId == registerAsbitem.AsbitemId).Count() > 0 &&
+ createRegisterCheckAsbitemEntity.DeleteRegisterCheckAsbitems.Where(o=>o.AsbitemId == registerAsbitem.AsbitemId).Count() == 0)
{
throw new UserFriendlyException($"组合项目:{asbitem.DisplayName}已存在不能增加");
}
@@ -542,7 +543,7 @@ namespace Shentun.Peis.RegisterAsbitems
RegisterCheck registerCheck = null;
if (registerCheckId == Guid.Empty)
{
- if (itemType.IsMergeAsbitem == 'Y' && asbitem.IsItemResultMerger == 'Y' && registerCheckIdValues.TryGetValue(itemType.Id, out registerCheckId))
+ if (itemType.IsMergeAsbitem == 'Y' && asbitem.IsItemResultMerger == 'Y' && registerCheckIdValues.TryGetValue(asbitem.ItemTypeId, out registerCheckId))
{
registerCheckAsbitem.RegisterCheckId = registerCheckId;
@@ -562,7 +563,7 @@ namespace Shentun.Peis.RegisterAsbitems
registerCheckId = registerCheck.Id;
registerCheckAsbitem.RegisterCheckId = registerCheckId;
createRegisterCheckAsbitemEntity.NewRegisterChecks.Add(registerCheck);
- registerCheckIdValues[itemType.Id] = registerCheckId;
+ registerCheckIdValues[asbitem.ItemTypeId] = registerCheckId;
}
}
diff --git a/test/Shentun.Peis.Application.Tests/DiagnosisFunctionAppServiceTest.cs b/test/Shentun.Peis.Application.Tests/DiagnosisFunctionAppServiceTest.cs
new file mode 100644
index 0000000..d27426e
--- /dev/null
+++ b/test/Shentun.Peis.Application.Tests/DiagnosisFunctionAppServiceTest.cs
@@ -0,0 +1,153 @@
+using NPOI.POIFS.Properties;
+using Shentun.Peis.CustomerOrgs;
+using Shentun.Peis.DiagnosisFunctions;
+using Shentun.Peis.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using TencentCloud.Ame.V20190916.Models;
+using Volo.Abp.Domain.Repositories;
+using Volo.Abp.Uow;
+using Xunit;
+using Xunit.Abstractions;
+
+namespace Shentun.Peis
+{
+ public class DiagnosisFunctionAppServiceTest : PeisApplicationTestBase
+ {
+ private readonly IRepository _repository;
+ private readonly DiagnosisFunctionAppService _appService;
+ private readonly ITestOutputHelper _output;
+ private readonly IUnitOfWorkManager _unitOfWorkManager;
+ public DiagnosisFunctionAppServiceTest(ITestOutputHelper testOutputHelper)
+ {
+ _output = testOutputHelper;
+ _unitOfWorkManager = GetRequiredService();
+ _repository = GetRequiredService>();
+ _appService = GetRequiredService();
+ }
+
+ [Fact]
+ public void GetItemResult()
+ {
+ PatientDiagnosisInputArg patient = new PatientDiagnosisInputArg();
+ patient.AsbitemId = Guid.NewGuid();
+ patient.SexName = "男";
+ patient.Age = 30;
+ patient.Items = new List()
+ {
+ new ItemDiagnosisInputArg()
+ {
+ ItemId = Guid.NewGuid(),
+ ItemName = "身高",
+ Result = "122"
+ },
+ new ItemDiagnosisInputArg()
+ {
+ ItemId = Guid.NewGuid(),
+ ItemName = "体重",
+ Result = "221"
+ },
+ new ItemDiagnosisInputArg()
+ {
+ ItemId = Guid.NewGuid(),
+ ItemName = "体重指数",
+ }
+ };
+ var result = GetItemResultSample(patient);
+ _output.WriteLine("结果:"+result);
+ string code = @"
+ string result = """";
+ decimal sg = 0;
+ decimal tz = 0;
+ foreach (var item in patient.Items)
+ {
+ if (item.ItemName == ""身高"")
+ {
+ if (decimal.TryParse(item.Result, out sg))
+ {
+ if (sg == 0)
+ {
+ return null;
+ }
+ }
+ else
+ {
+ return null;
+ }
+
+ }
+ if (item.ItemName == ""体重"")
+ {
+ if (decimal.TryParse(item.Result, out tz))
+ {
+ if (tz == 0)
+ {
+ return null;
+ }
+ }
+ else
+ {
+ return null;
+ }
+
+ }
+ }
+ result = (tz /((sg/100) * (sg / 100))).ToString(""0.00"");
+ return result;
+ ";
+
+
+
+ result = _appService.GetItemResult(patient, code);
+ _output.WriteLine("动态结果:" + result);
+
+
+ }
+
+
+ public string GetItemResultSample(PatientDiagnosisInputArg patient)
+ {
+ string result = "";
+ decimal sg = 0;
+ decimal tz = 0;
+ foreach (var item in patient.Items)
+ {
+ if (item.ItemName == "身高")
+ {
+ if (decimal.TryParse(item.Result, out sg))
+ {
+ if (sg == 0)
+ {
+ return null;
+ }
+ }
+ else
+ {
+ return null;
+ }
+
+ }
+ if (item.ItemName == "体重")
+ {
+ if (decimal.TryParse(item.Result, out tz))
+ {
+ if (tz == 0)
+ {
+ return null;
+ }
+ }
+ else
+ {
+ return null;
+ }
+
+ }
+ }
+ result = (tz /((sg/100) * (sg / 100))).ToString("0.00");
+ return result;
+ }
+ }
+}
diff --git a/test/Shentun.Peis.Application.Tests/PatientRegisterAppServiceTest.cs b/test/Shentun.Peis.Application.Tests/PatientRegisterAppServiceTest.cs
index 8ea47b7..f08b5dd 100644
--- a/test/Shentun.Peis.Application.Tests/PatientRegisterAppServiceTest.cs
+++ b/test/Shentun.Peis.Application.Tests/PatientRegisterAppServiceTest.cs
@@ -35,88 +35,113 @@ namespace Shentun.Peis
[Fact]
public async Task CreatePatientRegisterAsync()
{
- using (var unitOfWork = _unitOfWorkManager.Begin(isTransactional:true))
+ for (var i = 0; i < 3; i++)
{
- var entity = new CreatePatientRegisterDto()
- {
- MedicalCenterId = new Guid("68f2d834-2bf0-4978-ad54-d2133c12a333"),
- PatientId = new Guid("3a119be6-d9aa-2e13-a764-0b363c60169d"),
- CustomerOrgId = new Guid("00000000-0000-0000-0000-000000000001"),
- CustomerOrgRegisterId = new Guid("00000000-0000-0000-0000-000000000001"),
- PatientName = "test",
- SexId = SexFlag.UnKnown,
- BirthDate = null,
- Age = 38,
- Telephone = "010-0000001",
- MobileTelephone = "18911254911",
- JobCardNo = "jobCardNo",
- MedicalCardNo = "MedicalCardNo",
- MaritalStatusId = MaritalStatusFlag.Married,
- MedicalTypeId = new Guid("3a0c5093-6dbf-d29b-cfbc-b1f742ee59d3"),
- PersonnelTypeId = new Guid("3a0c5099-a5f3-e41a-dfab-caeae79e0dfe"),
- NationId = "001",
- JobPost = "JobPost",
- JobTitle = "JobTitle",
- Salesman = "Salesman",
- SexHormoneTermId = new Guid("3a0d38cf-8b3c-95db-1a69-5119f28dc468"),
- MedicalConclusionId = new Guid("3a0c50fe-cacf-d3c8-8c3c-9d3495d8bd76"),
- IsUpload = 'N',
- CompleteFlag = PatientRegisterCompleteFlag.PreRegistration,
- IsMedicalStart = 'N',
- MedicalStartDate = null,
- IsRecoverGuide = 'N',
- SummaryDate = null,
- IsAudit = 'N',
- IsLock = 'N',
- IsNameHide = 'N',
- IsPhoneFollow = 'N',
- IsVip = 'N',
- Remark = "Remark",
- Address = "Address1",
- Email ="83986010@qq.com"
- };
-
- entity.RegisterCheckAsbitems.Add(new CreatePatientRegisterRegisterCheckAsbitem()
- {
- AsbitemId = new Guid("3a0c55fa-63b9-1510-3e81-20750c496d44"),
- StandardPrice = 10,
- ChargePrice = 10,
- Amount = 1,
- PayTypeFlag = PayTypeFlag.PersonPay,
- IsCharge = 'N'
- });
- entity.RegisterCheckAsbitems.Add(new CreatePatientRegisterRegisterCheckAsbitem()
+ using (var unitOfWork = _unitOfWorkManager.Begin(isTransactional: true))
{
- AsbitemId = new Guid("3a0c5600-ae78-9ed4-e3c1-993ef41d3c51"),
- StandardPrice = 10,
- ChargePrice = 10,
- Amount = 1,
- PayTypeFlag = PayTypeFlag.PersonPay,
- IsCharge = 'N'
- });
- entity.RegisterCheckAsbitems.Add(new CreatePatientRegisterRegisterCheckAsbitem()
- {
- AsbitemId = new Guid("3a0c5635-b904-dc9b-593e-93d0dd228576"),
- StandardPrice = 10,
- ChargePrice = 10,
- Amount = 1,
- PayTypeFlag = PayTypeFlag.PersonPay,
- IsCharge = 'N'
- });
+ var entity = new CreatePatientRegisterDto()
+ {
+ MedicalCenterId = new Guid("68f2d834-2bf0-4978-ad54-d2133c12a333"),
+ PatientId = new Guid("3a119be6-d9aa-2e13-a764-0b363c60169d"),
+ CustomerOrgId = new Guid("00000000-0000-0000-0000-000000000001"),
+ CustomerOrgRegisterId = new Guid("00000000-0000-0000-0000-000000000001"),
+ PatientName = "test",
+ SexId = SexFlag.UnKnown,
+ BirthDate = null,
+ Age = 38,
+ Telephone = "010-0000001",
+ MobileTelephone = "18911254911",
+ JobCardNo = "jobCardNo",
+ MedicalCardNo = "MedicalCardNo",
+ MaritalStatusId = MaritalStatusFlag.Married,
+ MedicalTypeId = new Guid("3a0c5093-6dbf-d29b-cfbc-b1f742ee59d3"),
+ PersonnelTypeId = new Guid("3a0c5099-a5f3-e41a-dfab-caeae79e0dfe"),
+ NationId = "001",
+ JobPost = "JobPost",
+ JobTitle = "JobTitle",
+ Salesman = "Salesman",
+ SexHormoneTermId = new Guid("3a0d38cf-8b3c-95db-1a69-5119f28dc468"),
+ MedicalConclusionId = new Guid("3a0c50fe-cacf-d3c8-8c3c-9d3495d8bd76"),
+ IsUpload = 'N',
+ CompleteFlag = PatientRegisterCompleteFlag.PreRegistration,
+ IsMedicalStart = 'N',
+ MedicalStartDate = null,
+ IsRecoverGuide = 'N',
+ SummaryDate = null,
+ IsAudit = 'N',
+ IsLock = 'N',
+ IsNameHide = 'N',
+ IsPhoneFollow = 'N',
+ IsVip = 'N',
+ Remark = "Remark",
+ Address = "Address1",
+ Email = "83986010@qq.com"
+ };
- entity.RegisterCheckAsbitems.Add(new CreatePatientRegisterRegisterCheckAsbitem()
- {
- AsbitemId = new Guid("3a11abbc-b19e-3549-e639-acc0e9aa6fbc"),
- StandardPrice = 10,
- ChargePrice = 10,
- Amount = 1,
- PayTypeFlag = PayTypeFlag.PersonPay,
- IsCharge = 'N'
- });
-
- var newEntity = await _appService.CreatePatientRegisterAsync(entity);
- await unitOfWork.CompleteAsync();
+ entity.RegisterCheckAsbitems.Add(new CreatePatientRegisterRegisterCheckAsbitem()
+ {
+
+ AsbitemId = new Guid("3a0c657d-4e73-9bab-68da-56ab2f088bb1"),
+ StandardPrice = 10,
+ ChargePrice = 10,
+ Amount = 1,
+ PayTypeFlag = PayTypeFlag.PersonPay,
+ IsCharge = 'N'
+ });
+
+ entity.RegisterCheckAsbitems.Add(new CreatePatientRegisterRegisterCheckAsbitem()
+ {
+
+
+ AsbitemId = new Guid("3a0c5616-dab2-c209-f099-a6231ef57ac3"),
+ StandardPrice = 10,
+ ChargePrice = 10,
+ Amount = 1,
+ PayTypeFlag = PayTypeFlag.PersonPay,
+ IsCharge = 'N'
+ });
+
+ entity.RegisterCheckAsbitems.Add(new CreatePatientRegisterRegisterCheckAsbitem()
+ {
+
+ AsbitemId = new Guid("3a0c55f0-92b7-caa6-3fc3-f9f04ca45ad3"),
+ StandardPrice = 10,
+ ChargePrice = 10,
+ Amount = 1,
+ PayTypeFlag = PayTypeFlag.PersonPay,
+ IsCharge = 'N'
+ });
+
+ entity.RegisterCheckAsbitems.Add(new CreatePatientRegisterRegisterCheckAsbitem()
+ {
+
+
+ AsbitemId = new Guid("3a0c55fa-63b9-1510-3e81-20750c496d44"),
+ StandardPrice = 10,
+ ChargePrice = 10,
+ Amount = 1,
+ PayTypeFlag = PayTypeFlag.PersonPay,
+ IsCharge = 'N'
+ });
+
+
+
+ entity.RegisterCheckAsbitems.Add(new CreatePatientRegisterRegisterCheckAsbitem()
+ {
+
+
+ AsbitemId = new Guid("3a0c55fe-559e-d6e7-7f74-221edeeaf817"),
+ StandardPrice = 10,
+ ChargePrice = 10,
+ Amount = 1,
+ PayTypeFlag = PayTypeFlag.PersonPay,
+ IsCharge = 'N'
+ });
+
+ var newEntity = await _appService.CreatePatientRegisterAsync(entity);
+ await unitOfWork.CompleteAsync();
+ }
}
}
@@ -127,7 +152,7 @@ namespace Shentun.Peis
{
var entity = new CreatePatientRegisterDto()
{
- PatientRegisterId = new Guid("3a11abec-a6aa-e656-16db-cb0bccf8de46"),
+ //PatientRegisterId = new Guid("3a11abec-a6aa-e656-16db-cb0bccf8de46"),
MedicalCenterId = new Guid("68f2d834-2bf0-4978-ad54-d2133c12a333"),
PatientId = new Guid("3a119be6-d9aa-2e13-a764-0b363c60169d"),
CustomerOrgId = new Guid("00000000-0000-0000-0000-000000000001"),
@@ -164,10 +189,10 @@ namespace Shentun.Peis
Address = "Address1",
Email = "83986010@qq.com"
};
- var medicalPackageId = new Guid("3a0c51d3-2345-38df-ba0b-1862a3c3606f");
+ var medicalPackageId = new Guid("3a0c51d4-2c5a-2a05-e4c4-e335012617be");
entity.MedicalPackageId = medicalPackageId;
- var medicalPackageDetails = (await _medicalPackageDetailRepository.GetQueryableAsync()).Include(o=>o.Asbitem).Where(o => o.MedicalPackageId == medicalPackageId).ToList();
- foreach(var medicalPackageDetail in medicalPackageDetails)
+ var medicalPackageDetails = (await _medicalPackageDetailRepository.GetQueryableAsync()).Include(o => o.Asbitem).Where(o => o.MedicalPackageId == medicalPackageId).ToList();
+ foreach (var medicalPackageDetail in medicalPackageDetails)
{
var registerCheckAsbitem = new CreatePatientRegisterRegisterCheckAsbitem()
{
@@ -180,7 +205,7 @@ namespace Shentun.Peis
};
entity.RegisterCheckAsbitems.Add(registerCheckAsbitem);
}
-
+
var newEntity = await _appService.CreatePatientRegisterAsync(entity);
await unitOfWork.CompleteAsync();
@@ -290,10 +315,10 @@ namespace Shentun.Peis
PatientRegisterId = new Guid("3a11abec-a6aa-e656-16db-cb0bccf8de46")
};
- entity.RegisterCheckAsbitems.Add(new BatchCreateRegisterCheckAsbitem()
+ entity.RegisterCheckAsbitems.Add(new BatchCreateRegisterCheckAsbitem()
{
AsbitemId = new Guid("3a0c55fe-559e-d6e7-7f74-221edeeaf817"),
-
+
ChargePrice = (decimal)10.51,
Amount = 2,
PayTypeFlag = PayTypeFlag.OrgPay,
@@ -306,7 +331,7 @@ namespace Shentun.Peis
PayTypeFlag = PayTypeFlag.PersonPay,
});
-
+
await _appService.BatchAddAsbitems(entity);
await unitOfWork.CompleteAsync();
@@ -328,12 +353,12 @@ namespace Shentun.Peis
{
AsbitemId = new Guid("3a0c55fe-559e-d6e7-7f74-221edeeaf817"),
-
+
});
entity.RegisterCheckAsbitems.Add(new BatchDeleteRegisterCheckAsbitem()
{
AsbitemId = new Guid("3a0c55ff-e111-0551-1381-6bd2a894c158"),
-
+
});
@@ -428,14 +453,14 @@ namespace Shentun.Peis
{
using (var unitOfWork = _unitOfWorkManager.Begin(isTransactional: true))
{
-
- var items = await _appService.GetSameNamePatientAsync(new GetSameNamePatientInputDto() { Name = "李九" });
+
+ var items = await _appService.GetSameNamePatientAsync(new GetSameNamePatientInputDto() { Name = "李九" });
_output.WriteLine(items.Count().ToString());
- foreach(var item in items)
+ foreach (var item in items)
{
- _output.WriteLine(item.PatientName + ","+item.CustomerOrgName + "," + item.DepartmentName);
+ _output.WriteLine(item.PatientName + "," + item.CustomerOrgName + "," + item.DepartmentName);
}
await unitOfWork.CompleteAsync();
}
@@ -452,7 +477,7 @@ namespace Shentun.Peis
{
CustomerOrgId = new Guid("3a0c5101-a6a6-e48a-36ec-33e7567a99e6"),
Name = "李九"
- }) ;
+ });
_output.WriteLine(items.Count().ToString());
foreach (var item in items)
{
@@ -461,5 +486,23 @@ namespace Shentun.Peis
await unitOfWork.CompleteAsync();
}
}
+
+ [Fact]
+ public async Task GetAlreadyRegisterPatientRegisterByNoAsync()
+ {
+ using (var unitOfWork = _unitOfWorkManager.Begin(isTransactional: true))
+ {
+
+
+
+ var item = await _appService.GetAlreadyRegisterPatientRegisterByNoAsync(new PatientRegisterNoInputDto()
+ {
+ PatientRegisterNo = "T4830",
+ PatientNo = ""
+ });
+ _output.WriteLine(item.PatientName + "," + item.CustomerOrgName + "," + item.CustomerOrgParentName);
+ await unitOfWork.CompleteAsync();
+ }
+ }
}
}