|
@@ -23,6 +23,9 @@ using WingInterfaceLibrary.DTO.Patient;
|
|
|
using WingServerCommon.Utilities;
|
|
|
using WingInterfaceLibrary.Enum.VitalEnum;
|
|
|
using System.Text.RegularExpressions;
|
|
|
+using WingInterfaceLibrary.Request.DBVitalRequest;
|
|
|
+using System.Reflection;
|
|
|
+using WingInterfaceLibrary.Interface.VitalInterface;
|
|
|
|
|
|
namespace VitalRegisterService;
|
|
|
|
|
@@ -33,6 +36,7 @@ public partial class HealthExamBookingService : JsonRpcService, IVitalHealthExam
|
|
|
private string _cloudServerUrl;
|
|
|
private string _syncToken;
|
|
|
private int _syncSeconds;
|
|
|
+ private string _jingQiServerUrl;
|
|
|
private List<HealthExamLabelDTO> _examLabels = new List<HealthExamLabelDTO>();
|
|
|
private IAuthenticationService _authenticationService;
|
|
|
private IVitalUserDBService _vitalUserDBService;
|
|
@@ -46,6 +50,8 @@ public partial class HealthExamBookingService : JsonRpcService, IVitalHealthExam
|
|
|
private IReportService _wingReportService;
|
|
|
private IVitalPatientDBService _vitalPatientDBService;
|
|
|
private RpcClient _cloudRpcClient;
|
|
|
+ private IVitalFacturyUserDBService _vitalFacturyUserDBService;
|
|
|
+ private IVitalFacturyUserService _vitalFacturyUserService;
|
|
|
private List<HealthExamItemDTO> _jiayiExamItems = new List<HealthExamItemDTO>
|
|
|
{
|
|
|
new HealthExamItemDTO { Code = "HEIBasic", Name = "基础检查", Content = "" },
|
|
@@ -90,6 +96,16 @@ public partial class HealthExamBookingService : JsonRpcService, IVitalHealthExam
|
|
|
_wingReportService = GetProxy<IReportService>();
|
|
|
_vitalPatientDBService = GetProxy<IVitalPatientDBService>();
|
|
|
_cloudRpcClient = new RpcClient();
|
|
|
+ _vitalFacturyUserDBService = GetProxy<IVitalFacturyUserDBService>();
|
|
|
+ _vitalFacturyUserService = GetProxy<IVitalFacturyUserService>();
|
|
|
+ try
|
|
|
+ {
|
|
|
+ _jingQiServerUrl = EnvironmentConfigManager.GetParammeter<StringParameter>("Vital", "JingQiServerUrl").Value;
|
|
|
+ }
|
|
|
+ catch
|
|
|
+ {
|
|
|
+ Logger.WriteLineWarn($"HealthExamBookingService Vital JingQiServerUrl not config");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -455,7 +471,7 @@ public partial class HealthExamBookingService : JsonRpcService, IVitalHealthExam
|
|
|
{
|
|
|
if (existedRegisterInfos?.Any(x => x.ProjectType == request.ProjectType) ?? false)
|
|
|
{
|
|
|
- ThrowCustomerException(WingInterfaceLibrary.Enum.CustomerRpcCode.RegisteredSameDay, "Registered Same Day");
|
|
|
+ ThrowCustomerException(CustomerRpcCode.RegisteredSameDay, "Registered Same Day");
|
|
|
}
|
|
|
}
|
|
|
var patientInfo = await _vitalPatientDBService.GetPatientDetailAsync(new WingInterfaceLibrary.Request.DBVitalRequest.GetPatientDBRequest
|
|
@@ -465,6 +481,9 @@ public partial class HealthExamBookingService : JsonRpcService, IVitalHealthExam
|
|
|
});
|
|
|
var isNewPatient = patientInfo == null || string.IsNullOrWhiteSpace(patientInfo.Code);
|
|
|
var crowdLabels = patientInfo?.CrowdLabels?.ToList() ?? new List<string>();
|
|
|
+ //晶奇
|
|
|
+ var jingQiRes = await JingQiExamRegisterAsync(request);
|
|
|
+ dto.JingQiExamInfos = jingQiRes;
|
|
|
//体检号
|
|
|
var num = await _registerInfoDBService.GetRegisterNumberAsync(organizationCode);
|
|
|
var physicalExamNumber = $"{orgInfo.OrganizationUniqueCode ?? string.Empty}{DateTime.Now.ToString("yyyyMMdd")}{(num + 1).ToString("000")}";
|
|
@@ -484,7 +503,6 @@ public partial class HealthExamBookingService : JsonRpcService, IVitalHealthExam
|
|
|
{
|
|
|
await CreateRecordAsync(dto);
|
|
|
}
|
|
|
-
|
|
|
if (orgInfo.ExamItemCodes?.Contains("HEIECG") ?? false)//心电
|
|
|
{
|
|
|
await AddElectrocardiogramRecord(dto, userInfo.Code, organizationCode);
|
|
@@ -501,6 +519,89 @@ public partial class HealthExamBookingService : JsonRpcService, IVitalHealthExam
|
|
|
return new AddRegiterInfoResult();
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 删除登记信息
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ public async Task<bool> DeleteRegiterInfoAsync(DeleteRegiterInfoRequest request)
|
|
|
+ {
|
|
|
+ var registerCode = request.RegisterCode;
|
|
|
+ var registerInfo = await _registerInfoDBService.FindRegisterInfoByCodeAsync(registerCode);
|
|
|
+ if (registerInfo != null && registerInfo.JingQiExamInfos != null && registerInfo.JingQiExamInfos.Any())
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ var jingQiRes = await _vitalFacturyUserService.FacturyExamDeleteAsync(new FacturyExamDeleteRequest
|
|
|
+ {
|
|
|
+ Token = request.Token,
|
|
|
+ PhyId = "",
|
|
|
+ });
|
|
|
+ if (jingQiRes.Status != "0")
|
|
|
+ {
|
|
|
+ Logger.WriteLineError($"HealthExamBookingService DeleteRegiterInfoAsync failed, cardNo:{registerInfo.IDCardNo}, Status:{jingQiRes.Status}, ErroMsg:{jingQiRes.ErroMsg}");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Logger.WriteLineInfo($"HealthExamBookingService DeleteRegiterInfoAsync success, cardNo:{registerInfo.IDCardNo}, Status:{jingQiRes.Status}, ErroMsg:{jingQiRes.ErroMsg}");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return await _registerInfoDBService.DeleteRegisterInfoAsync(registerCode);
|
|
|
+ }
|
|
|
+
|
|
|
+ private async Task<Dictionary<string, string>> JingQiExamRegisterAsync(AddRegiterInfoRequest request)
|
|
|
+ {
|
|
|
+ var jingQiExamInfos = new Dictionary<string, string>();
|
|
|
+ if (await IsJingQiRequiredAsync(request))
|
|
|
+ {
|
|
|
+ FacturyExamRegisterResult jingQiRes = null;
|
|
|
+ try
|
|
|
+ {
|
|
|
+ jingQiRes = await _vitalFacturyUserService.FacturyExamRegisterAsync(new FacturyExamRegisterRequest
|
|
|
+ {
|
|
|
+ Token = request.Token,
|
|
|
+ Identity = request.IDCardNo,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ return jingQiExamInfos;
|
|
|
+ }
|
|
|
+ if (jingQiRes.Status != "0")
|
|
|
+ {
|
|
|
+ Logger.WriteLineError($"HealthExamBookingService JingQiExamRegisterAsync failed, cardNo:{request.IDCardNo}, Status:{jingQiRes.Status}, ErroMsg:{jingQiRes.ErroMsg}");
|
|
|
+ if (jingQiRes.Status == "2")
|
|
|
+ {
|
|
|
+ ThrowCustomerException(CustomerRpcCode.JingQiNonArea, "JingQiNonArea");
|
|
|
+ }
|
|
|
+ else if (jingQiRes.Status == "3")
|
|
|
+ {
|
|
|
+ ThrowCustomerException(CustomerRpcCode.JingQiExamedInYear, "JingQiExamedInYear");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ThrowCustomerException(CustomerRpcCode.JingQiApiFailed, jingQiRes.ErroMsg);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Logger.WriteLineInfo($"HealthExamBookingService JingQiExamRegisterAsync success, cardNo:{request.IDCardNo}, Status:{jingQiRes.Status}, ErroMsg:{jingQiRes.ErroMsg}");
|
|
|
+ }
|
|
|
+ PropertyInfo[] properties = typeof(FacturyExamRegisterResult).GetProperties();
|
|
|
+ foreach (PropertyInfo property in properties)
|
|
|
+ {
|
|
|
+ if (property.Name != "Status" && property.Name != "ErroMsg")
|
|
|
+ {
|
|
|
+ jingQiExamInfos.Add(property.Name, property.GetValue(jingQiRes)?.ToString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return jingQiExamInfos;
|
|
|
+ }
|
|
|
+
|
|
|
private async Task<string> CreateRecordAsync(RegisterInfoDTO registerInfo)
|
|
|
{
|
|
|
try
|
|
@@ -835,4 +936,35 @@ public partial class HealthExamBookingService : JsonRpcService, IVitalHealthExam
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
+
|
|
|
+ private async Task<bool> IsJingQiRequiredAsync(TokenRequest request)
|
|
|
+ {
|
|
|
+ if (string.IsNullOrWhiteSpace(_jingQiServerUrl))
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ var userCode = await GetClientIdByTokenAsync(request.Token);
|
|
|
+ var userInfo = await _vitalUserDBService.GetUserDetailAsync(new GetUserDBRequest
|
|
|
+ {
|
|
|
+ Code = userCode,
|
|
|
+ });
|
|
|
+ if (userInfo == null || string.IsNullOrWhiteSpace(userInfo.FacturyUserCode))
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ var facturyUser = await _vitalFacturyUserDBService.GetFacturyUserDBAsync(new GetFacturyUserDBRequest
|
|
|
+ {
|
|
|
+ Code = userInfo.FacturyUserCode,
|
|
|
+ });
|
|
|
+ var facturyOrg = await _vitalFacturyUserDBService.GetFacturyUserDBAsync(new GetFacturyUserDBRequest
|
|
|
+ {
|
|
|
+ Code = facturyUser.FatherCode,
|
|
|
+ });
|
|
|
+ if (facturyUser == null || string.IsNullOrWhiteSpace(facturyUser.FacturyCode)
|
|
|
+ || facturyOrg == null || string.IsNullOrWhiteSpace(facturyOrg.FacturyCode))
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
}
|