You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
726 lines
29 KiB
726 lines
29 KiB
using Dapper;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Newtonsoft.Json;
|
|
using Npgsql;
|
|
using ServiceReferenceYinHai;
|
|
using Shentun.Peis.ChargeRequests;
|
|
using Shentun.Peis.Enums;
|
|
using Shentun.Peis.LisRequests;
|
|
using Shentun.Peis.PlugIns.ChargeRequests;
|
|
using Shentun.Peis.PlugIns.Extensions.ChargeRequests.YinHai;
|
|
using Shentun.Peis.PlugIns.Extensions.ChargeRequests.YinHai.FeeBacks;
|
|
using Shentun.Peis.PlugIns.Extensions.LisRequests.YinHai;
|
|
using Shentun.Peis.PlugIns.Extensions.LisRequests.YinHai.Dto;
|
|
using Shentun.Peis.PlugIns.Extensions.PacsRequests.YinHai.Dto;
|
|
using Shentun.Peis.PlugIns.LisRequests;
|
|
using Shentun.Peis.PlugIns.PatientRegisters;
|
|
using Shentun.Peis.PrintReports;
|
|
using Shentun.Peis.ThirdInterfaces;
|
|
using Shentun.Utilities;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data.Common;
|
|
using System.Linq;
|
|
using System.ServiceModel;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Xml;
|
|
|
|
namespace Shentun.Peis.PlugIns.Extensions.PacsRequests.YinHai
|
|
{
|
|
public class PacsRequestPlugInsYinHai
|
|
{
|
|
|
|
protected IConfiguration? AppConfig;
|
|
private readonly string AppConnctionStr;
|
|
private readonly IConfiguration? InterfaceConfig;
|
|
private readonly ThirdInterfaceDto? _thirdInterfaceDto;
|
|
private readonly PluginLogger _logger; // 添加日志实例
|
|
|
|
static PacsRequestPlugInsYinHai()
|
|
{
|
|
Dapper.DefaultTypeMap.MatchNamesWithUnderscores = true;
|
|
|
|
}
|
|
|
|
public PacsRequestPlugInsYinHai(Guid thirdInterfaceId)
|
|
{
|
|
_logger = new PluginLogger();
|
|
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();
|
|
}
|
|
public PacsRequestPlugInsYinHai(string parmValue)
|
|
{
|
|
_logger = new PluginLogger();
|
|
AppConfig = new ConfigurationBuilder()
|
|
.SetBasePath(DirectoryHelper.GetAppDirectory()) // 设置基础路径为当前目录
|
|
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
|
|
.Build();
|
|
AppConnctionStr = AppConfig.GetSection("ConnectionStrings")
|
|
.GetSection("Default").Value;
|
|
|
|
var configurationBuilder = new ConfigurationBuilder()
|
|
.AddJsonStream(new MemoryStream(System.Text.Encoding.UTF8.GetBytes(parmValue)));
|
|
InterfaceConfig = configurationBuilder.Build();
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 发送Pacs申请
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
/// <exception cref="Exception"></exception>
|
|
public async Task<PacsRequestPlugInsOut> SendRequestAsync(RegisterCheckIdInputDto input)
|
|
{
|
|
_logger.Log("银海发送Pacs申请", $"Pacs申请Id:{input.RegisterCheckId}");
|
|
|
|
try
|
|
{
|
|
//建立人员档案
|
|
var patientRegisterForPlugIns = await GetPatientRegisterAsync(input.RegisterCheckId);
|
|
var pacsRequestForPlugIns = await GetPacsRequestForPlugInsAsync(input.RegisterCheckId);
|
|
if (pacsRequestForPlugIns == null)
|
|
{
|
|
throw new Exception("没有申请单信息");
|
|
}
|
|
|
|
if (patientRegisterForPlugIns.BirthDate == null)
|
|
{
|
|
throw new Exception("出生日期不能为空");
|
|
}
|
|
|
|
|
|
var endpointAddress = InterfaceConfig.GetValue("Interface:EndpointAddress", "");
|
|
if (string.IsNullOrWhiteSpace(endpointAddress))
|
|
{
|
|
throw new Exception("接口地址不能为空");
|
|
}
|
|
|
|
|
|
|
|
|
|
string actionName = "request_call";
|
|
string codeName = "pacs_server";
|
|
|
|
|
|
using (var client = new WebServiceClient(new BasicHttpBinding(),
|
|
new EndpointAddress(endpointAddress)))
|
|
{
|
|
//// 添加消息拦截器行为
|
|
//var behavior = new SoapEndpointBehavior();
|
|
//client.Endpoint.EndpointBehaviors.Add(behavior);
|
|
|
|
var request = new PacsRequestCallDto();
|
|
#region head
|
|
string requestId = new Random().Next(100000, 999999).ToString();
|
|
string timestamp = DateTime.Now.ToString("yyyyMMddHHmmss");
|
|
request.Head = new PacsRequestCallHeadDto
|
|
{
|
|
Action = actionName,
|
|
Code = codeName,
|
|
ObjectSystem = "pacs",
|
|
RequestId = requestId,
|
|
Sign = "",
|
|
SourceSystem = "peis",
|
|
Timestamp = timestamp,
|
|
Version = "1"
|
|
};
|
|
|
|
string headString = $"version={request.Head.Version}×tamp={request.Head.Timestamp}&request_id={request.Head.RequestId}&source_system={request.Head.SourceSystem}&object_system={request.Head.ObjectSystem}&action={request.Head.Action}";
|
|
string sign = Convert.ToBase64String(Encoding.UTF8.GetBytes(headString));
|
|
request.Head.Sign = sign;
|
|
#endregion
|
|
|
|
var orgCode = InterfaceConfig.GetValue("Interface:OrgCode", "");
|
|
var orgName = InterfaceConfig.GetValue("Interface:OrgName", "");
|
|
var systemSource = InterfaceConfig.GetValue("Interface:SystemSource", "");
|
|
var billingDeptCode = InterfaceConfig.GetValue("Interface:BillingDeptCode", "");
|
|
var billingDeptName = InterfaceConfig.GetValue("Interface:BillingDeptName", "");
|
|
|
|
var commonTableTypeId = InterfaceConfig.GetValue("Interface:CommonTableTypeId", "");
|
|
var execDoctorUser = InterfaceConfig.GetValue("Interface:ExecDoctorUser", "");
|
|
|
|
var createUser = await GetUserInfo(patientRegisterForPlugIns.CreatorId);
|
|
|
|
var dataDetails = new List<PacsRequestCallBodyDataDetailDto>();
|
|
var dataRequest = new PacsRequestCallBodyDataRequestDto
|
|
{
|
|
|
|
Age = patientRegisterForPlugIns.Age?.ToString() ?? "0",
|
|
AgeUnit = "岁",
|
|
RequestNo = pacsRequestForPlugIns.CheckRequestNo,
|
|
PatientType = "4",
|
|
OrgCode = orgCode,
|
|
OrgName = orgName,
|
|
SystemSource = "04.01",
|
|
VisitId = patientRegisterForPlugIns.PatientRegisterNo,
|
|
VisitNo = patientRegisterForPlugIns.PatientRegisterNo,
|
|
PatientId = patientRegisterForPlugIns.PatientNo,
|
|
PatientNo = patientRegisterForPlugIns.PatientNo,
|
|
IsBaby = "0",
|
|
PatientName = patientRegisterForPlugIns.PatientName,
|
|
GenderCode = ConvertSex(patientRegisterForPlugIns.SexId),
|
|
IdCard = patientRegisterForPlugIns.IdNo,
|
|
RequestorCode = createUser.UserName,
|
|
Requestor = createUser.Surname,
|
|
RequestDeptCode = billingDeptCode,
|
|
RequestDeptName = billingDeptName,
|
|
Birthday = patientRegisterForPlugIns.BirthDate?.ToString("yyyy-MM-dd") ?? "",
|
|
IsEmergency = "0",
|
|
SumCost = pacsRequestForPlugIns.ChargePrice.ToString(),
|
|
PayFlag = "0",
|
|
ExecDeptCode = "",
|
|
ExecDeptName = "",
|
|
CancelFlag = "0",
|
|
ExecFlag = "0",
|
|
GcFlag = "0",
|
|
AppointmentFlag = "0",
|
|
BillingDate = patientRegisterForPlugIns.CreationTime.ToString("yyyy-MM-dd HH:mm:ss"),
|
|
DeviceType = "DR",
|
|
PrintFlag = "0",
|
|
PresentAddress = "",
|
|
HealthCardNo = "",
|
|
HealthFileNo = "",
|
|
Purpose = "",
|
|
Telphone = "",
|
|
NationCode = "",
|
|
NationName = "",
|
|
NationalityCode = "",
|
|
NationalityName = "",
|
|
MarriageCode = "",
|
|
PresentHistory = "",
|
|
Complanit = "",
|
|
SymptomsInfo = "",
|
|
DiagCode = "",
|
|
DiagName = "",
|
|
WardCode = "",
|
|
WardName = "",
|
|
RoomNo = "",
|
|
BedNo = "",
|
|
IdentyNo = "",
|
|
DeptCode = "",
|
|
DeptName = "",
|
|
VisitCount = "",
|
|
MaxitemId = "",
|
|
MaxitemCode = "",
|
|
MaxitemName = "",
|
|
SpecimenType = "",
|
|
SpecimenStatus = "",
|
|
SpecimenFixer = "",
|
|
CheckSpecimenNo = "",
|
|
PrintCount = "",
|
|
MedCardNo = ""
|
|
};
|
|
|
|
|
|
#region 对照关系
|
|
|
|
var yinHaiAsbitemCommonTableList = await GetCommonTableByTypeId(commonTableTypeId);
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
var dzFirst = yinHaiAsbitemCommonTableList.FirstOrDefault(f => f.DisplayName == pacsRequestForPlugIns.AsbitemId.ToString());
|
|
|
|
if (dzFirst == null)
|
|
{
|
|
throw new Exception($"项目【{pacsRequestForPlugIns.AsbitemName},Id:{pacsRequestForPlugIns.AsbitemId}】没有对照");
|
|
}
|
|
|
|
|
|
dataDetails.Add(new PacsRequestCallBodyDataDetailDto
|
|
{
|
|
RequestNo = pacsRequestForPlugIns.CheckRequestNo,
|
|
PatientType = "4",
|
|
ItemSerialNo = $"{pacsRequestForPlugIns.CheckRequestNo}{dzFirst.ThirdCode}",
|
|
OrgCode = orgCode,
|
|
OrgName = orgName,
|
|
SystemSource = systemSource,
|
|
PatientId = patientRegisterForPlugIns.PatientNo,
|
|
VisitId = patientRegisterForPlugIns.PatientRegisterNo,
|
|
OrderId = "-",
|
|
ItemId = pacsRequestForPlugIns.AsbitemId.ToString(),
|
|
ItemCode = dzFirst.ThirdCode,
|
|
ItemName = pacsRequestForPlugIns.AsbitemName,
|
|
Cost = pacsRequestForPlugIns.ChargePrice.ToString(),
|
|
ExecFlag = "0",
|
|
CancelFlag = "0",
|
|
IsEmergency = "0",
|
|
AnestheisaTcmModernCode = "",
|
|
AnesthesiaObserveResult = "",
|
|
AnesthesiaPhysicianCode = "",
|
|
AnesthesiaPhysicianSign = "",
|
|
AnesthesiaWayCode = "",
|
|
DeviceName = "",
|
|
DeviceTypeName = "",
|
|
DeviceWayName = "",
|
|
DiagPeocessInfo = "",
|
|
ExecDeptCode = "",
|
|
ExecDeptName = "",
|
|
InvolvedName = "",
|
|
OpeartionCode = "",
|
|
OperationCount = "",
|
|
OperationDate = "",
|
|
OperationName = "",
|
|
OperationPositionCode = "",
|
|
OperationPositionName = "",
|
|
OperationWayInfo = ""
|
|
});
|
|
|
|
|
|
|
|
var requestBody = new PacsRequestCallBodyDto
|
|
{
|
|
Data = new PacsRequestCallBodyDataDto
|
|
{
|
|
Request = dataRequest,
|
|
RequestDetails = new PacsRequestCallBodyDataDetailsDto
|
|
{
|
|
Details = dataDetails
|
|
}
|
|
}
|
|
};
|
|
|
|
request.Body = requestBody;
|
|
|
|
|
|
var requestXml = XmlHelper.SerializeToXmlEmpty(request);
|
|
|
|
|
|
var resultP = await client.callBussinessAsync(requestXml);
|
|
|
|
|
|
|
|
if (resultP.data.status_code == "1")
|
|
{
|
|
//成功 更新lis申请表 执行状态
|
|
await UpdatePacsRequestExecFlag(pacsRequestForPlugIns.RegisterCheckId, '1');
|
|
|
|
}
|
|
|
|
var returnValue = JsonConvert.SerializeObject(resultP.data, Newtonsoft.Json.Formatting.Indented);
|
|
|
|
_logger.Log("银海发送Pacs申请", $"发送结果:{returnValue}");
|
|
|
|
var yinHaiSendInterfaceLogDto = new YinHaiSendInterfaceLogDto
|
|
{
|
|
LogName = "发送Pacs申请",
|
|
ExecDoctorUser = Guid.Parse(execDoctorUser),
|
|
InterfaceName = $"{codeName}_{actionName}",
|
|
ParaValue = requestXml,
|
|
RequestNo = dataRequest.RequestNo,
|
|
ReturnParaValue = returnValue
|
|
};
|
|
|
|
await AddSendLog(yinHaiSendInterfaceLogDto);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
// Console.WriteLine(ex.Message);
|
|
_logger.Log("银海发送Pacs申请", ex, $"发送Pacs申请异常");
|
|
}
|
|
|
|
|
|
|
|
return new PacsRequestPlugInsOut();
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 取消Pacs申请
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
/// <exception cref="Exception"></exception>
|
|
public async Task<PacsRequestPlugInsOut> CancelRequestAsync(RegisterCheckIdInputDto input)
|
|
{
|
|
_logger.Log("银海取消Pacs申请", $"Pacs申请Id:{input.RegisterCheckId}");
|
|
try
|
|
{
|
|
var patientRegisterForPlugIns = await GetPatientRegisterAsync(input.RegisterCheckId);
|
|
var pacsRequestForPlugIns = await GetPacsRequestForPlugInsAsync(input.RegisterCheckId);
|
|
if (pacsRequestForPlugIns == null)
|
|
{
|
|
throw new Exception("没有申请单信息");
|
|
}
|
|
|
|
var endpointAddress = InterfaceConfig.GetValue("Interface:EndpointAddress", "");
|
|
if (string.IsNullOrWhiteSpace(endpointAddress))
|
|
{
|
|
throw new Exception("接口地址不能为空");
|
|
}
|
|
|
|
|
|
|
|
|
|
string actionName = "request_cancel";
|
|
string codeName = "pacs_server";
|
|
|
|
using (var client = new WebServiceClient(new BasicHttpBinding(),
|
|
new EndpointAddress(endpointAddress)))
|
|
{
|
|
var request = new PacsRequestCancelDto();
|
|
#region head
|
|
string requestId = new Random().Next(100000, 999999).ToString();
|
|
string timestamp = DateTime.Now.ToString("yyyyMMddHHmmss");
|
|
request.Head = new PacsRequestCancelHeadDto
|
|
{
|
|
Action = actionName,
|
|
Code = codeName,
|
|
ObjectSystem = "pacs",
|
|
RequestId = requestId,
|
|
Sign = "",
|
|
SourceSystem = "peis",
|
|
Timestamp = timestamp,
|
|
Version = "1"
|
|
};
|
|
|
|
string headString = $"version={request.Head.Version}×tamp={request.Head.Timestamp}&request_id={request.Head.RequestId}&source_system={request.Head.SourceSystem}&object_system={request.Head.ObjectSystem}&action={request.Head.Action}";
|
|
string sign = Convert.ToBase64String(Encoding.UTF8.GetBytes(headString));
|
|
request.Head.Sign = sign;
|
|
#endregion
|
|
|
|
|
|
var orgCode = InterfaceConfig.GetValue("Interface:OrgCode", "");
|
|
var systemSource = InterfaceConfig.GetValue("Interface:SystemSource", "");
|
|
|
|
var execDoctorUser = InterfaceConfig.GetValue("Interface:ExecDoctorUser", "");
|
|
var commonTableTypeId = InterfaceConfig.GetValue("Interface:CommonTableTypeId", "");
|
|
|
|
|
|
var dataDetails = new List<PacsRequestCancelBodyDataDetailDto>();
|
|
var dataRequest = new PacsRequestCancelBodyDataRequestDto
|
|
{
|
|
OrgCode = orgCode,
|
|
SystemSource = systemSource,
|
|
CancelFlag = "1",
|
|
PatientType = "4",
|
|
RequestNo = pacsRequestForPlugIns.CheckRequestNo
|
|
};
|
|
|
|
#region 对照关系
|
|
|
|
var yinHaiAsbitemCommonTableList = await GetCommonTableByTypeId(commonTableTypeId);
|
|
|
|
#endregion
|
|
|
|
|
|
var dzFirst = yinHaiAsbitemCommonTableList.FirstOrDefault(f => f.DisplayName == pacsRequestForPlugIns.AsbitemId.ToString());
|
|
|
|
if (dzFirst == null)
|
|
{
|
|
throw new Exception($"项目【{pacsRequestForPlugIns.AsbitemName},Id:{pacsRequestForPlugIns.AsbitemId}】没有对照");
|
|
}
|
|
|
|
|
|
dataDetails.Add(new PacsRequestCancelBodyDataDetailDto
|
|
{
|
|
RequestNo = pacsRequestForPlugIns.CheckRequestNo,
|
|
PatientType = "4",
|
|
ItemSerialNo = $"{pacsRequestForPlugIns.CheckRequestNo}{dzFirst.ThirdCode}",
|
|
OrgCode = orgCode,
|
|
SystemSource = systemSource,
|
|
CancelFlag = "1"
|
|
});
|
|
|
|
|
|
|
|
var requestBody = new PacsRequestCancelBodyDto
|
|
{
|
|
Data = new PacsRequestCancelBodyDataDto
|
|
{
|
|
Request = dataRequest,
|
|
RequestDetails = new PacsRequestCancelBodyDataDetailsDto
|
|
{
|
|
Details = dataDetails
|
|
}
|
|
}
|
|
};
|
|
|
|
request.Body = requestBody;
|
|
|
|
var requestXml = XmlHelper.SerializeToXmlEmpty(request);
|
|
|
|
|
|
var resultP = await client.callBussinessAsync(requestXml);
|
|
|
|
|
|
if (resultP.data.status_code == "1")
|
|
{
|
|
//成功 更新lis申请表 执行状态
|
|
await UpdatePacsRequestExecFlag(pacsRequestForPlugIns.RegisterCheckId, '0');
|
|
|
|
}
|
|
|
|
var returnValue = JsonConvert.SerializeObject(resultP.data, Newtonsoft.Json.Formatting.Indented);
|
|
|
|
_logger.Log("银海取消Pacs申请", $"发送结果:{returnValue}");
|
|
|
|
var yinHaiSendInterfaceLogDto = new YinHaiSendInterfaceLogDto
|
|
{
|
|
LogName = "取消Pacs申请",
|
|
ExecDoctorUser = Guid.Parse(execDoctorUser),
|
|
InterfaceName = $"{codeName}_{actionName}",
|
|
ParaValue = requestXml,
|
|
RequestNo = pacsRequestForPlugIns.CheckRequestNo,
|
|
ReturnParaValue = returnValue
|
|
};
|
|
|
|
await AddSendLog(yinHaiSendInterfaceLogDto);
|
|
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
//Console.WriteLine(ex.Message);
|
|
_logger.Log("银海取消Pacs申请", ex, $"发送取消Pacs申请异常");
|
|
}
|
|
|
|
|
|
return new PacsRequestPlugInsOut();
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 更新register_check表的执行状态,标记用于是否发送
|
|
/// </summary>
|
|
/// <param name="registerCheckId"></param>
|
|
/// <returns></returns>
|
|
private async Task UpdatePacsRequestExecFlag(Guid registerCheckId, char execFlag)
|
|
{
|
|
_logger.LogResult("更新register_check表的执行状态", $"registerCheckId=>{registerCheckId.ToString()},execFlag=>{execFlag}");
|
|
using (DbConnection conn = new NpgsqlConnection(AppConnctionStr))
|
|
{
|
|
string sql;
|
|
sql = @"update register_check set exec_flag=@execFlag
|
|
WHERE id =@registerCheckId
|
|
";
|
|
await conn.ExecuteAsync(sql,
|
|
new { execFlag = execFlag, registerCheckId = registerCheckId });
|
|
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 获取用户信息
|
|
/// </summary>
|
|
/// <param name="registerCheckId"></param>
|
|
/// <returns></returns>
|
|
private async Task<PatientRegisterForPlugIns> GetPatientRegisterAsync(Guid registerCheckId)
|
|
{
|
|
using (DbConnection conn = new NpgsqlConnection(AppConnctionStr))
|
|
{
|
|
string sql;
|
|
sql = @"select DISTINCT patient.id as patient_id,
|
|
patient_register.id as patient_register_id,
|
|
patient_register.patient_register_no,
|
|
patient.patient_no ,
|
|
patient_register.his_patient_id,
|
|
patient_register.medical_center_id,
|
|
patient_register.patient_name,
|
|
patient_register.sex_id,
|
|
patient_register.marital_status_id,
|
|
patient_register.birth_date,
|
|
patient_register.age,
|
|
patient_register.creation_time,
|
|
patient_register.creator_id,
|
|
patient.nation_id,
|
|
patient.id_no,
|
|
patient.email,
|
|
patient.telephone,
|
|
patient.mobile_telephone,
|
|
patient.address
|
|
from register_check_asbitem
|
|
left join register_check on register_check_asbitem.register_check_id=register_check.id
|
|
left join patient_register on register_check.patient_register_id=patient_register.id
|
|
left join patient on patient_register.patient_id=patient.id
|
|
where register_check.id=@registerCheckId
|
|
";
|
|
var patientRegisterForPlugIns = (await conn.QueryAsync<PatientRegisterForPlugIns>(sql,
|
|
new { registerCheckId = registerCheckId })).SingleOrDefault();
|
|
return patientRegisterForPlugIns;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 获取申请单信息
|
|
/// </summary>
|
|
/// <param name="registerCheckId"></param>
|
|
/// <returns></returns>
|
|
private async Task<PacsRequestForPlugIns> GetPacsRequestForPlugInsAsync(Guid registerCheckId)
|
|
{
|
|
using (DbConnection conn = new NpgsqlConnection(AppConnctionStr))
|
|
{
|
|
string sql;
|
|
sql = @"select distinct register_check.id as register_check_id,
|
|
register_check.check_request_no,
|
|
asbitem.id as asbitem_id,
|
|
asbitem.display_name as asbitem_name,
|
|
register_check_asbitem.charge_price as charge_price
|
|
from patient_register
|
|
left join register_check on patient_register.id=register_check.patient_register_id
|
|
left join register_check_asbitem on register_check.id=register_check_asbitem.register_check_id
|
|
left join asbitem on register_check_asbitem.asbitem_id=asbitem.id
|
|
left join item_type on asbitem.item_type_id=item_type.id
|
|
where register_check.id=@registerCheckId and patient_register.complete_flag <> '3' and
|
|
register_check.complete_flag <> '1' and asbitem.barcode_mode='0' and asbitem.is_check='Y' and item_type.is_check_request='Y'
|
|
";
|
|
var pacsRequestForPlugIns = (await conn.QueryAsync<PacsRequestForPlugIns>(sql,
|
|
new { registerCheckId = registerCheckId })).SingleOrDefault();
|
|
|
|
return pacsRequestForPlugIns;
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取收费用户
|
|
/// </summary>
|
|
/// <param name="UserId"></param>
|
|
/// <returns></returns>
|
|
private async Task<ChargeUserDto> GetUserInfo(Guid UserId)
|
|
{
|
|
using (DbConnection conn = new NpgsqlConnection(AppConnctionStr))
|
|
{
|
|
string sql;
|
|
sql = @"select user_name,surname from abp_users
|
|
WHERE id =@UserId
|
|
";
|
|
var chargeUser = (await conn.QueryAsync<ChargeUserDto>(sql,
|
|
new { UserId = UserId })).SingleOrDefault();
|
|
if (chargeUser == null)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
|
|
return chargeUser;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取对照数据
|
|
/// </summary>
|
|
/// <param name="commonTableTypeId"></param>
|
|
/// <returns></returns>
|
|
private async Task<List<YinHaiAsbitemCommonTableDto>> GetCommonTableByTypeId(string commonTableTypeId)
|
|
{
|
|
var thirdCode = InterfaceConfig.GetValue("Interface:ThirdCode", "");
|
|
|
|
|
|
using (DbConnection conn = new NpgsqlConnection(AppConnctionStr))
|
|
{
|
|
string sql;
|
|
sql = $@"select display_name,{thirdCode} as thirdCode from common_table where common_table_type_id='{commonTableTypeId}' ";
|
|
var yinHaiAsbitemCommonTableList = (await conn.QueryAsync<YinHaiAsbitemCommonTableDto>(sql)).ToList();
|
|
|
|
return yinHaiAsbitemCommonTableList;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 添加日志
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
private async Task AddSendLog(YinHaiSendInterfaceLogDto input)
|
|
{
|
|
using (DbConnection conn = new NpgsqlConnection(AppConnctionStr))
|
|
{
|
|
string sql;
|
|
sql = $@" insert into interface_send_log (id,request_no,interface_name,para_value,return_para_value,concurrency_stamp,
|
|
creation_time,creator_id,last_modification_time,last_modifier_id) values
|
|
(@id,@request_no,@interface_name,@para_value,@return_para_value,@concurrency_stamp,
|
|
@creation_time,@creator_id,@last_modification_time,@last_modifier_id)
|
|
";
|
|
await conn.ExecuteAsync(sql,
|
|
new
|
|
{
|
|
id = Guid.NewGuid(),
|
|
request_no = input.RequestNo,
|
|
interface_name = input.InterfaceName,
|
|
para_value = input.ParaValue,
|
|
return_para_value = input.ReturnParaValue,
|
|
concurrency_stamp = Guid.NewGuid().ToString("N"),
|
|
creation_time = DateTime.Now,
|
|
creator_id = input.ExecDoctorUser,
|
|
last_modification_time = DateTime.Now,
|
|
last_modifier_id = input.ExecDoctorUser
|
|
});
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 转换性别
|
|
/// </summary>
|
|
/// <param name="sexId"></param>
|
|
/// <returns></returns>
|
|
private string ConvertSex(char sexId)
|
|
{
|
|
string msg = "";
|
|
switch (sexId)
|
|
{
|
|
case 'M':
|
|
msg = "1";
|
|
break;
|
|
case 'F':
|
|
msg = "2";
|
|
break;
|
|
case 'U':
|
|
msg = "0";
|
|
break;
|
|
default:
|
|
msg = "9";
|
|
break;
|
|
}
|
|
return msg;
|
|
}
|
|
|
|
#region 解析xml
|
|
|
|
private string GetNodeValue(XmlNode parent, string nodeName)
|
|
{
|
|
var node = parent.SelectSingleNode(nodeName);
|
|
return node?.InnerText ?? "";
|
|
}
|
|
#endregion
|
|
|
|
}
|
|
}
|