Browse Source

海豚云推送

master
wxd 1 month ago
parent
commit
0712bf2a36
  1. 15
      ThirdPlugIns/Shentun.Peis.PlugIns.Gem/ThirdPushs/Hty/ItemDzModel.cs
  2. 87
      ThirdPlugIns/Shentun.Peis.PlugIns.Gem/ThirdPushs/Hty/PushHtyDataInputDto.cs
  3. 270
      ThirdPlugIns/Shentun.Peis.PlugIns.Gem/ThirdPushs/Hty/PushPeisResultPlugInsHty.cs
  4. 104
      src/Shentun.ColumnReferencePlugIns/ThirdPushs/Hty/GetHtyTokenDto.cs
  5. 99
      src/Shentun.ColumnReferencePlugIns/ThirdPushs/Hty/HtyHttpPostHelper.cs
  6. 91
      src/Shentun.ColumnReferencePlugIns/ThirdPushs/Hty/PushPeisResultPlugInsBase.cs
  7. 6
      src/Shentun.Peis.Application.Contracts/PeisReports/GetPatientRegisterReportDto.cs
  8. 5
      src/Shentun.Peis.Application.Contracts/PeisReports/GetPatientRegisterReportRequestDto.cs
  9. 27
      src/Shentun.Peis.Application/PeisReports/PeisReportAppService.cs
  10. 154
      src/Shentun.Peis.Application/ThirdResultPushs/ThirdResultPushAppService.cs
  11. 4
      src/Shentun.Peis.Domain.Shared/Enums/ThirdInterfaceTypeFlag.cs
  12. 7
      src/Shentun.Peis.Domain/PatientRegisters/PatientRegister.cs
  13. 2
      src/Shentun.Peis.EntityFrameworkCore/DbMapping/PatientRegisters/PatientRegisterDbMapping.cs
  14. 16623
      src/Shentun.Peis.EntityFrameworkCore/Migrations/20260304082752_update_patient_register_add_is_push_third_result.Designer.cs
  15. 27
      src/Shentun.Peis.EntityFrameworkCore/Migrations/20260304082752_update_patient_register_add_is_push_third_result.cs
  16. 7
      src/Shentun.Peis.EntityFrameworkCore/Migrations/PeisDbContextModelSnapshot.cs

15
ThirdPlugIns/Shentun.Peis.PlugIns.Gem/ThirdPushs/Hty/ItemDzModel.cs

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Shentun.Peis.PlugIns.Extensions.ThirdPushs.Hty
{
public class ItemDzModel
{
public string CodeValue { get; set; }
public string InterfaceCodeValue { get; set; }
}
}

87
ThirdPlugIns/Shentun.Peis.PlugIns.Gem/ThirdPushs/Hty/PushHtyDataInputDto.cs

@ -0,0 +1,87 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Shentun.Peis.PlugIns.Extensions.ThirdPushs.Hty
{
public class PushHtyDataInputDto
{
public PushHtyDataInputPatientDto info { get; set; }
public object content { get; set; }
//public string serious { get; set; }
}
public class PushHtyDataInputPatientDto
{
/// <summary>
///
/// </summary>
public string USERID { get; set; }
/// <summary>
///
/// </summary>
public string CERTNO { get; set; }
/// <summary>
///
/// </summary>
public string BIRTHDATE { get; set; }
/// <summary>
///
/// </summary>
public string USERTIMES { get; set; }
/// <summary>
/// 男、女
/// </summary>
public string GENDER { get; set; }
/// <summary>
///
/// </summary>
public string NAME { get; set; }
/// <summary>
///
/// </summary>
public string MEDICALDATE { get; set; }
/// <summary>
///
/// </summary>
public string RORGNAME { get; set; }
/// <summary>
///
/// </summary>
public string MEDICALCODE { get; set; }
}
public class pushHtyDataItemDto
{
/// <summary>
///
/// </summary>
public string sysCode { get; set; }
/// <summary>
///
/// </summary>
public string p_value { get; set; }
/// <summary>
///
/// </summary>
public int ordinary { get; set; }
/// <summary>
///
/// </summary>
public string unit { get; set; }
/// <summary>
/// 男:<85|女:<80
/// </summary>
public string dicValue { get; set; }
}
public class PushHtyDataResultDto
{
public string stateMessage { get; set; }
}
}

270
ThirdPlugIns/Shentun.Peis.PlugIns.Gem/ThirdPushs/Hty/PushPeisResultPlugInsHty.cs

@ -0,0 +1,270 @@
using Dapper;
using Microsoft.Extensions.Configuration;
using Microsoft.Identity.Client;
using Newtonsoft.Json;
using Npgsql;
using ServiceReferenceDianLisReport;
using ServiceReferenceDianLisResult;
using Shentun.Peis.Enums;
using Shentun.Peis.ImportLisResults;
using Shentun.Peis.PlugIns.ColumnReferences;
using Shentun.Peis.PlugIns.Extensions.ImportLisResults.Dian;
using Shentun.Peis.PlugIns.ImportLisResults;
using Shentun.Peis.PlugIns.ThirdPushs.Hty;
using Shentun.Peis.PlugIns.WebAppoints;
using Shentun.Peis.PrintReports;
using Shentun.Peis.RegisterCheckPictures;
using Shentun.Peis.ThirdInterfaces;
using Spire.Pdf.Exporting.XPS.Schema;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Linq;
using System.ServiceModel;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp;
using static OpenIddict.Abstractions.OpenIddictConstants;
namespace Shentun.Peis.PlugIns.Extensions.ThirdPushs.Hty
{
public class PushPeisResultPlugInsHty : PushPeisResultPlugInsBase
{
public PushPeisResultPlugInsHty(Guid thirdInterfaceId) : base(thirdInterfaceId)
{
}
public async Task DoWork()
{
List<Guid> patientRegisters = await GetRequestPatientRegistersHtyAsync();
foreach (var patientRegisterId in patientRegisters)
{
await PushHtyPeisResultByPatientRegisterIdAsync(patientRegisterId);
}
}
/// <summary>
/// 根据id推送信息到海豚云
/// </summary>
/// <param name="patientRegisterId"></param>
/// <returns></returns>
/// <exception cref="UserFriendlyException"></exception>
public async Task<string> PushHtyPeisResultByPatientRegisterIdAsync(Guid patientRegisterId)
{
var pushBaseApi = InterfaceConfig.GetValue("Interface:PushBaseApi", "");
var columnReferenceId = InterfaceConfig.GetValue("Interface:ColumnReferenceId", "");
using (DbConnection conn = new NpgsqlConnection(AppConnctionStr))
{
var sql_patient = $@" select b.patient_no,b.id_no,b.birth_date,a.medical_times,b.sex_id,a.patient_name,
a.medical_start_date,a.patient_register_no,a.complete_flag from patient_register as a left join
patient as b on a.patient_id=b.id where a.id=@patient_register_id ";
var patientRegisterSqlEntity = (await conn.QueryFirstAsync(sql_patient,
new { patient_register_id = patientRegisterId }));
if (patientRegisterSqlEntity != null)
{
if (patientRegisterSqlEntity.complete_flag != "3")
{
throw new UserFriendlyException("人员为总检");
}
var pushRequest = new PushHtyDataInputDto();
pushRequest.info = new PushHtyDataInputPatientDto
{
USERID = patientRegisterSqlEntity.patient_no.ToString(),
CERTNO = patientRegisterSqlEntity.id_no.ToString(),
BIRTHDATE = !string.IsNullOrWhiteSpace(patientRegisterSqlEntity.birth_date.ToString()) ? Convert.ToDateTime(patientRegisterSqlEntity.birth_date).ToString("yyyy-MM-dd") : "",
USERTIMES = patientRegisterSqlEntity.medical_times.ToString(),
GENDER = ConertSex(patientRegisterSqlEntity.sex_id.ToString()),
NAME = patientRegisterSqlEntity.patient_name.ToString(),
MEDICALDATE = Convert.ToDateTime(patientRegisterSqlEntity.medical_start_date).ToString("yyyy-MM-dd HH:mm:ss"),
MEDICALCODE = patientRegisterSqlEntity.patient_register_no.ToString(),
RORGNAME = ""
};
//查看项目
var sql_item = $@" select c.display_name as item_name,b.* from register_check as a
left join register_check_item as b on a.id=b.register_check_id
left join item as c on b.item_id=c.id where a.patient_register_id=@patient_register_id ";
var registerItemSqlEntity = await conn.QueryAsync(sql_item,
new { patient_register_id = patientRegisterId });
if (registerItemSqlEntity.Count() > 0)
{
#region 获取对照数据
var sql_dz = $@" select a.code_value,b.interface_code_value from column_reference_code as a
left join column_reference_interface as b on a.id=b.column_reference_code_id
where a.column_reference_id=@column_reference_id ";
var itemDZSqlEntity = (await conn.QueryAsync(sql_dz,
new { column_reference_id = Guid.Parse(columnReferenceId) })).ToList();
#endregion
Dictionary<string, pushHtyDataItemDto> contents = new Dictionary<string, pushHtyDataItemDto>();
foreach (var itemRow in registerItemSqlEntity)
{
var itemCode = itemDZSqlEntity.FirstOrDefault(f => f.code_value == itemRow.item_id.ToString());
if (itemCode != null)
{
var constr = new pushHtyDataItemDto
{
dicValue = itemRow.reference_range_value.ToString(),
ordinary = 1,
p_value = itemRow.result.ToString(),
sysCode = itemCode.interface_code_value,
unit = itemRow.unit.ToString()
};
var dcIndex = contents.Count + 1;
contents.Add("con" + dcIndex, constr);
}
}
pushRequest.content = contents;
}
string pushRequestJsonString = JsonConvert.SerializeObject(pushRequest, Formatting.Indented);
//推送信息
var formContent = new MultipartFormDataContent();
formContent.Add(new StringContent(_thirdToken), "token");
formContent.Add(new StringContent("fbpc"), "urlFrom");
formContent.Add(new StringContent("-1"), "tmId");
formContent.Add(new StringContent(pushRequestJsonString, Encoding.UTF8, "application/json"), "pushData");
var result = await HtyHttpPostHelper.PostFormDataAsync($"{pushBaseApi}/api/manageFrame/healthCheck/medicalInterfaceDataFetch.action", formContent, "PostmanRuntime-ApipostRuntime/1.1.0");
var resultModel = JsonConvert.DeserializeObject<PushHtyDataResultDto>(result);
if (resultModel.stateMessage == "suc")
{
#region 更新人员状态
#endregion
}
return $"{pushRequest.info.NAME}_{pushRequest.info.MEDICALCODE}_推送结果:{resultModel.stateMessage}";
}
else
{
throw new UserFriendlyException("人员不存在");
}
}
}
/// <summary>
/// 获取需要推送的人员id集合
/// </summary>
/// <returns></returns>
public async Task<List<Guid>> GetRequestPatientRegistersHtyAsync()
{
var patientRegisterIds = new List<Guid>();
var queryDaysStr = InterfaceConfig.GetValue("Interface:Scheduler:QueryDays", "");
var isAuditWhere = InterfaceConfig.GetValue("Interface:Scheduler:IsAuditWhere", "");
var uploadDateType = InterfaceConfig.GetValue("Interface:Scheduler:UploadDateType", "");
var otherWhere = InterfaceConfig.GetValue("Interface:Scheduler:OtherWhere", "");
var uploadCountLimit = InterfaceConfig.GetValue("Interface:Scheduler:UploadCountLimit", "");
if (string.IsNullOrWhiteSpace(queryDaysStr))
{
queryDaysStr = "1";
}
if (!int.TryParse(queryDaysStr, out int days))
{
days = 1;
}
using (DbConnection conn = new NpgsqlConnection(AppConnctionStr))
{
string sql;
sql = @"
SELECT
id
from patient_register
where complete_flag = @CompleteFlag ";
if (uploadDateType == "1")
{
sql += " and summary_date>= @HandDate ";
}
else if (uploadDateType == "2")
{
sql += " and audit_date>= @HandDate ";
}
else
{
sql += " and last_modification_time>= @HandDate ";
}
if (isAuditWhere == "Y")
{
sql += " and is_audit='Y' ";
}
if (!string.IsNullOrWhiteSpace(otherWhere))
{
sql += otherWhere;
}
var parameters = new DynamicParameters();
parameters.Add("HandDate", DateTime.Now.Date.AddDays(-days));
parameters.Add("CompleteFlag", PatientRegisterCompleteFlag.SumCheck);
sql += $" limit {uploadCountLimit} ";
var patientRegisterSqlList = (await conn.QueryAsync<SyncPatientRegisterIdsDto>(sql, parameters)).ToList();
patientRegisterIds = patientRegisterSqlList.Select(s => s.Id).ToList();
}
return patientRegisterIds;
}
private string ConertSex(string sexId)
{
string res = "";
if (sexId == "M")
{
res = "男";
}
else if (sexId == "F")
{
res = "女";
}
else
{
res = "未知";
}
return res;
}
}
}

104
src/Shentun.ColumnReferencePlugIns/ThirdPushs/Hty/GetHtyTokenDto.cs

@ -0,0 +1,104 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Shentun.Peis.PlugIns.ThirdPushs.Hty
{
public class GetHtyTokenDto
{
/// <summary>
/// 登录成功
/// </summary>
public string msg { get; set; }
/// <summary>
///
/// </summary>
public string expireDays { get; set; }
/// <summary>
///
/// </summary>
public int gender { get; set; }
/// <summary>
///
/// </summary>
public string photomiddle { get; set; }
/// <summary>
///
/// </summary>
public string isCusService { get; set; }
/// <summary>
///
/// </summary>
public string userLoginTimeStr { get; set; }
/// <summary>
///
/// </summary>
public string isShopUser { get; set; }
/// <summary>
///
/// </summary>
public string isShowCoupon { get; set; }
/// <summary>
///
/// </summary>
public string isAdmin { get; set; }
/// <summary>
///
/// </summary>
public string userName { get; set; }
/// <summary>
///
/// </summary>
public string userLoginIp { get; set; }
/// <summary>
///
/// </summary>
public string userId { get; set; }
/// <summary>
///
/// </summary>
public string userCode { get; set; }
/// <summary>
///
/// </summary>
public string rfqId { get; set; }
/// <summary>
///
/// </summary>
public string isDoctor { get; set; }
/// <summary>
/// 石家庄长城中西医接合体检中心
/// </summary>
public string name { get; set; }
/// <summary>
///
/// </summary>
public string eaId { get; set; }
/// <summary>
///
/// </summary>
public string token2 { get; set; }
/// <summary>
///
/// </summary>
public string eaCode { get; set; }
/// <summary>
///
/// </summary>
public string expireDate { get; set; }
/// <summary>
///
/// </summary>
public string state { get; set; }
/// <summary>
///
/// </summary>
public string msgCode { get; set; }
/// <summary>
///
/// </summary>
public string isService { get; set; }
}
}

99
src/Shentun.ColumnReferencePlugIns/ThirdPushs/Hty/HtyHttpPostHelper.cs

@ -0,0 +1,99 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Shentun.Peis.PlugIns.ThirdPushs.Hty
{
public class HtyHttpPostHelper
{
private static readonly HttpClient _httpClient = new HttpClient();
/// <summary>
/// 发送普通表单POST请求
/// </summary>
public static async Task<string> PostFormDataAsync(string url,
Dictionary<string, string> formData,
Dictionary<string, string> headers = null)
{
var content = new FormUrlEncodedContent(formData ?? new Dictionary<string, string>());
return await SendRequestAsync(url, content, headers);
}
/// <summary>
/// 发送JSON格式POST请求
/// </summary>
public static async Task<string> PostJsonAsync(string url,
object jsonData,
Dictionary<string, string> headers = null)
{
var json = JsonConvert.SerializeObject(jsonData);
var content = new StringContent(json, Encoding.UTF8, "application/json");
return await SendRequestAsync(url, content, headers);
}
/// <summary>
/// 发送原始字符串POST请求
/// </summary>
public static async Task<string> PostRawStringAsync(string url,
string rawData,
string contentType,
Dictionary<string, string> headers = null)
{
var content = new StringContent(rawData, Encoding.UTF8, contentType);
return await SendRequestAsync(url, content, headers);
}
private static async Task<string> SendRequestAsync(string url,
HttpContent content,
Dictionary<string, string> headers)
{
try
{
var request = new HttpRequestMessage(HttpMethod.Post, url);
request.Content = content;
if (headers != null)
{
foreach (var header in headers)
{
request.Headers.Add(header.Key, header.Value);
}
}
var response = await _httpClient.SendAsync(request);
response.EnsureSuccessStatusCode();
return await response.Content.ReadAsStringAsync();
}
catch (HttpRequestException ex)
{
throw new Exception($"HTTP请求失败: {ex.Message}");
}
}
/// <summary>
/// formdata提交post
/// </summary>
/// <param name="url"></param>
/// <param name="formContent"></param>
/// <param name="userAgentName"></param>
/// <returns></returns>
public static async Task<string> PostFormDataAsync(string url, MultipartFormDataContent formContent, string userAgentName)
{
using (HttpClient client = new HttpClient())
{
if (!string.IsNullOrWhiteSpace(userAgentName))
client.DefaultRequestHeaders.UserAgent.ParseAdd(userAgentName);
var response = await client.PostAsync(url, formContent);
response.EnsureSuccessStatusCode();
var resStr = await response.Content.ReadAsStringAsync();
return resStr;
}
}
}
}

91
src/Shentun.ColumnReferencePlugIns/ThirdPushs/Hty/PushPeisResultPlugInsBase.cs

@ -0,0 +1,91 @@
using Dapper;
using Microsoft.Extensions.Configuration;
using Microsoft.Identity.Client;
using Newtonsoft.Json;
using Npgsql;
using Shentun.Peis.ThirdInterfaces;
using Shentun.Utilities;
using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp;
namespace Shentun.Peis.PlugIns.ThirdPushs.Hty
{
public class PushPeisResultPlugInsBase
{
protected IConfiguration? InterfaceConfig;
protected IConfiguration? AppConfig;
//当前系统数据库地址
protected string? AppConnctionStr;
protected ThirdInterfaceDto? _thirdInterfaceDto;
protected string? _thirdToken;
static PushPeisResultPlugInsBase()
{
Dapper.DefaultTypeMap.MatchNamesWithUnderscores = true;
}
public PushPeisResultPlugInsBase(Guid thirdInterfaceId)
{
AppConfig = new ConfigurationBuilder()
.SetBasePath(DirectoryHelper.GetAppDirectory()) // 设置基础路径为当前目录
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.Build();
AppConnctionStr = AppConfig.GetSection("ConnectionStrings")
.GetSection("Default").Value;
using (DbConnection conn = new NpgsqlConnection(AppConnctionStr))
{
string sql;
sql = @"
SELECT *
from third_interface
where id =@ThirdInterfaceId
";
_thirdInterfaceDto = (conn.Query<ThirdInterfaceDto>(sql,
new { ThirdInterfaceId = thirdInterfaceId })).Single();
var configurationBuilder = new ConfigurationBuilder()
.AddJsonStream(new MemoryStream(System.Text.Encoding.UTF8.GetBytes(_thirdInterfaceDto.ParmValue)));
InterfaceConfig = configurationBuilder.Build();
}
GetThirdToken();
}
private void GetThirdToken()
{
var pushBaseApi = InterfaceConfig.GetValue("Interface:PushBaseApi", "");
var thirdLoginUser = InterfaceConfig.GetValue("Interface:ThirdLoginUser", "");
var thirdLoginPassWord = InterfaceConfig.GetValue("Interface:ThirdLoginPassWord", "");
var formContent = new MultipartFormDataContent();
formContent.Add(new StringContent(thirdLoginUser), "username");
formContent.Add(new StringContent(thirdLoginPassWord), "password");
formContent.Add(new StringContent("Ea"), "type");
var result = (HtyHttpPostHelper.PostFormDataAsync($"{pushBaseApi}/api/loginEaV.action", formContent, "PostmanRuntime-ApipostRuntime/1.1.0")).GetAwaiter().GetResult();
var resModel = JsonConvert.DeserializeObject<GetHtyTokenDto>(result);
if (resModel != null && resModel.state == "suc")
{
_thirdToken = resModel.token2;
}
else
{
throw new UserFriendlyException("获取token失败,检查配置的账户");
}
}
}
}

6
src/Shentun.Peis.Application.Contracts/PeisReports/GetPatientRegisterReportDto.cs

@ -204,5 +204,11 @@ namespace Shentun.Peis.PeisReports
/// </summary>
public string ReportFormatTemplateId { get; set; }
/// <summary>
/// 是否推送第三方结果
/// </summary>
public char IsPushThirdResult { get; set; }
}
}

5
src/Shentun.Peis.Application.Contracts/PeisReports/GetPatientRegisterReportRequestDto.cs

@ -73,6 +73,11 @@ namespace Shentun.Peis.PeisReports
/// </summary>
public char? IsUpload { get; set; }
/// <summary>
/// 是否推送第三方结果
/// </summary>
public char? IsPushThirdResult { get; set; }
/// <summary>
/// 身份证号
/// </summary>

27
src/Shentun.Peis.Application/PeisReports/PeisReportAppService.cs

@ -152,7 +152,8 @@ namespace Shentun.Peis.PeisReports
a.IsReceiveReport,
a.ReportReceiveDate,
a.ReportReceiveName,
a.Remark
a.Remark,
a.IsPushThirdResult
},
//RegisterCheckCompleteFlag = registerCheck.CompleteFlag,
//IsCheck = asbitem.IsCheck,
@ -340,6 +341,11 @@ namespace Shentun.Peis.PeisReports
sumquery = sumquery.Where(m => m.a.IsUpload == input.IsUpload);
}
if (input.IsPushThirdResult != null)
{
sumquery = sumquery.Where(m => m.a.IsPushThirdResult == input.IsPushThirdResult);
}
if (!string.IsNullOrEmpty(input.IdNo))
{
sumquery = sumquery.Where(m => m.ab.IdNo == input.IdNo);
@ -439,7 +445,8 @@ namespace Shentun.Peis.PeisReports
ReportReceiveDate = DataHelper.ConversionDateShortToString(s.a.ReportReceiveDate),
ReportReceiveName = s.a.ReportReceiveName,
Remark = s.a.Remark,
ReportFormatTemplateId = reportFormatTemplateId
ReportFormatTemplateId = reportFormatTemplateId,
IsPushThirdResult = s.a.IsPushThirdResult
});
}
@ -496,7 +503,8 @@ namespace Shentun.Peis.PeisReports
patientRegister.ReportReceiveDate,
patientRegister.ReportReceiveName,
patientRegister.Remark,
patientRegister.MedicalPackageId
patientRegister.MedicalPackageId,
patientRegister.IsPushThirdResult
},
patient = new { patient.IdNo, patient.Address, patient.PatientNo, patient.MobileTelephone, patient.Telephone, patient.Email, patient.DisplayName }
};
@ -623,7 +631,7 @@ namespace Shentun.Peis.PeisReports
{
sumquery = sumquery.Where(m => !string.IsNullOrWhiteSpace(input.PatientName) && m.patientRegister.PatientName.Contains(input.PatientName));
}
}
if (!string.IsNullOrEmpty(input.phone))
@ -675,6 +683,11 @@ namespace Shentun.Peis.PeisReports
sumquery = sumquery.Where(m => m.patientRegister.IsUpload == input.IsUpload);
}
if (input.IsPushThirdResult != null)
{
sumquery = sumquery.Where(m => m.patientRegister.IsPushThirdResult == input.IsPushThirdResult);
}
if (!string.IsNullOrEmpty(input.IdNo))
{
sumquery = sumquery.Where(m => m.patient.IdNo == input.IdNo);
@ -746,7 +759,8 @@ namespace Shentun.Peis.PeisReports
patientRegister.ReportReceiveDate,
patientRegister.ReportReceiveName,
patientRegister.Remark,
patientRegister.MedicalPackageId
patientRegister.MedicalPackageId,
patientRegister.IsPushThirdResult
},
patient = new { patient.IdNo, patient.Address, patient.PatientNo, patient.MobileTelephone, patient.Telephone, patient.Email, patient.DisplayName },
registerCheckAsbitemHaveEmpty = registerCheckAsbitemHaveEmpty != null ? new
@ -820,7 +834,8 @@ namespace Shentun.Peis.PeisReports
IsReceiveReport = group.Key.IsReceiveReport,
ReportReceiveDate = DataHelper.ConversionDateShortToString(group.Key.ReportReceiveDate),
ReportReceiveName = group.Key.ReportReceiveName,
Remark = group.Key.Remark
Remark = group.Key.Remark,
IsPushThirdResult = group.Key.IsPushThirdResult
};
entDto.StandardAmount = 0;

154
src/Shentun.Peis.Application/ThirdResultPushs/ThirdResultPushAppService.cs

@ -0,0 +1,154 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Shentun.Peis.Enums;
using Shentun.Peis.Models;
using Shentun.Peis.PatientRegisters;
using Shentun.Peis.PlugIns.ImportLisResults;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Repositories;
namespace Shentun.Peis.ThirdResultPushs
{
/// <summary>
/// 第三方结果推送
/// </summary>
[ApiExplorerSettings(GroupName = "Work")]
[Authorize]
public class ThirdResultPushAppService : ApplicationService
{
private readonly IRepository<PatientRegister, Guid> _patientRegisterRepository;
private readonly IRepository<ThirdInterface, Guid> _thirdInterfaceRepository;
private readonly IRepository<Item, Guid> _itemRepository;
private readonly IConfiguration _configuration;
private readonly IRepository<ColumnReferenceCode, Guid> _columnReferenceCodeRepository;
private readonly IRepository<ColumnReferenceInterface, Guid> _columnReferenceInterfaceRepository;
public ThirdResultPushAppService(
IRepository<PatientRegister, Guid> patientRegisterRepository,
IRepository<ThirdInterface, Guid> thirdInterfaceRepository,
IConfiguration configuration,
IRepository<Item, Guid> itemRepository,
IRepository<ColumnReferenceCode, Guid> columnReferenceCodeRepository,
IRepository<ColumnReferenceInterface, Guid> columnReferenceInterfaceRepository)
{
_patientRegisterRepository = patientRegisterRepository;
_thirdInterfaceRepository = thirdInterfaceRepository;
_configuration = configuration;
_itemRepository = itemRepository;
_columnReferenceCodeRepository = columnReferenceCodeRepository;
_columnReferenceInterfaceRepository = columnReferenceInterfaceRepository;
}
/// <summary>
/// 推送体检信息到海豚云
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("api/app/ThirdResultPush/PushHtyResultByPatientRegisterId")]
public async Task PushHtyResultByPatientRegisterIdAsync(PatientRegisterIdInputDto input)
{
var patientRegister = await _patientRegisterRepository.GetAsync(input.PatientRegisterId);
var thirdInterfaces = await _thirdInterfaceRepository.GetListAsync(o =>
o.ThirdInterfaceType == ThirdInterfaceTypeFlag.CheckResultPush
&& o.IsActive == 'Y');
foreach (var thirdInterface in thirdInterfaces)
{
var parmValue = thirdInterface.ParmValue;
var configurationBuilder = new ConfigurationBuilder()
.AddJsonStream(new MemoryStream(System.Text.Encoding.UTF8.GetBytes(parmValue)));
var config = configurationBuilder.Build();
var assemblyName = config.GetSection("Interface").GetSection("AssemblyName").Value;
var className = config.GetSection("Interface").GetSection("ClassName").Value;
object[] objects = new object[] { input.PatientRegisterId };
var pluginsOut = await Utilities.ReflectionHelper.InvokeAsync<string>(assemblyName,
className, [thirdInterface.Id], "PushHtyPeisResultByPatientRegisterIdAsync", objects);
Logger.LogInformation(pluginsOut);
}
}
/// <summary>
/// 自动对照海豚云
/// </summary>
/// <param name="columnReferenceId"></param>
/// <returns></returns>
[HttpPost("api/app/ThirdResultPush/AutoColumnReferenceHtyAsync")]
public async Task AutoColumnReferenceHtyAsync(Guid columnReferenceId)
{
var itemList = await _itemRepository.GetListAsync();
SqlSugarClient Db = new SqlSugarClient(new ConnectionConfig()
{
ConnectionString = _configuration.GetValue("ConnectionStrings:Default", ""),
DbType = SqlSugar.DbType.PostgreSQL,
IsAutoCloseConnection = true
});
var dzList = await Db.Ado.SqlQueryAsync<TempThirdDzData>(" select * from third_dz_data ");
var columnReferenceCodeList = await _columnReferenceCodeRepository.GetListAsync(m => m.ColumnReferenceId == columnReferenceId);
foreach (var item in itemList)
{
var iCount = itemList.Count(c => c.DisplayName == item.DisplayName);
if (iCount == 1)
{
//体检系统不重名
var dqList = dzList.Where(m => m.third_name == item.DisplayName).ToList();
if (dqList.Count == 1)
{
var isColumnReferenceCode = columnReferenceCodeList.FirstOrDefault(f => f.CodeValue == item.Id.ToString());
if (isColumnReferenceCode == null)
{
Guid columnReferenceCodeId = GuidGenerator.Create();
//未对照
var columnReferenceCodeEntity = new ColumnReferenceCode(columnReferenceCodeId)
{
CodeValue = item.Id.ToString(),
ColumnReferenceId = columnReferenceId,
FilterCodeValue = ""
};
await _columnReferenceCodeRepository.InsertAsync(columnReferenceCodeEntity);
var columnReferenceInterfaceEntity = new ColumnReferenceInterface()
{
ColumnReferenceCodeId = columnReferenceCodeId,
InterfaceCodeValue = dqList.FirstOrDefault().third_code
};
await _columnReferenceInterfaceRepository.InsertAsync(columnReferenceInterfaceEntity);
}
}
}
}
}
}
public class TempThirdDzData
{
public string third_name { get; set; }
public string third_code { get; set; }
public string third_ks { get; set; }
public string third_asbitem_name { get; set; }
}
}

4
src/Shentun.Peis.Domain.Shared/Enums/ThirdInterfaceTypeFlag.cs

@ -53,5 +53,9 @@ namespace Shentun.Peis.Enums
[Description("自动签到")]
public const string AutoSign = "15";
[Description("检后结果推送")]
public const string CheckResultPush = "16";
}
}

7
src/Shentun.Peis.Domain/PatientRegisters/PatientRegister.cs

@ -366,6 +366,13 @@ namespace Shentun.Peis.Models
[Column("report_receive_date")]
public DateTime? ReportReceiveDate { get; set; }
/// <summary>
/// 是否推送第三方结果
/// </summary>
[Column("is_push_third_result")]
public char IsPushThirdResult { get; set; }
[Column("concurrency_stamp")]
public string ConcurrencyStamp { get; set; }

2
src/Shentun.Peis.EntityFrameworkCore/DbMapping/PatientRegisters/PatientRegisterDbMapping.cs

@ -106,6 +106,8 @@ namespace Shentun.Peis.DbMapping
entity.Property(t => t.IsReceiveReport).HasComment("报告是否领取").HasDefaultValueSql("'N'");
entity.Property(t => t.ReportReceiveName).HasComment("报告领取人");
entity.Property(t => t.ReportReceiveDate).HasComment("报告领取时间");
entity.Property(t => t.IsPushThirdResult).HasComment("是否推送第三方结果").HasDefaultValueSql("'N'");
//entity.HasOne(d => d.CustomerOrgRegister)
// .WithMany(p => p.PatientRegisters)

16623
src/Shentun.Peis.EntityFrameworkCore/Migrations/20260304082752_update_patient_register_add_is_push_third_result.Designer.cs
File diff suppressed because it is too large
View File

27
src/Shentun.Peis.EntityFrameworkCore/Migrations/20260304082752_update_patient_register_add_is_push_third_result.cs

@ -0,0 +1,27 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Shentun.Peis.Migrations
{
public partial class update_patient_register_add_is_push_third_result : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<char>(
name: "is_push_third_result",
table: "patient_register",
type: "character(1)",
nullable: false,
defaultValueSql: "'N'",
comment: "是否推送第三方结果");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "is_push_third_result",
table: "patient_register");
}
}
}

7
src/Shentun.Peis.EntityFrameworkCore/Migrations/PeisDbContextModelSnapshot.cs

@ -7850,6 +7850,13 @@ namespace Shentun.Peis.Migrations
.HasDefaultValueSql("'N'")
.HasComment("电话随访");
b.Property<char>("IsPushThirdResult")
.ValueGeneratedOnAdd()
.HasColumnType("character(1)")
.HasColumnName("is_push_third_result")
.HasDefaultValueSql("'N'")
.HasComment("是否推送第三方结果");
b.Property<char>("IsReceiveReport")
.ValueGeneratedOnAdd()
.HasColumnType("character(1)")

Loading…
Cancel
Save