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.
255 lines
9.1 KiB
255 lines
9.1 KiB
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Shentun.PeisReport.Api.Dto;
|
|
using Shentun.PeisReport.Api.Dto.ReportBusiness;
|
|
using Shentun.PeisReport.Api.Jwt;
|
|
using SqlSugar;
|
|
using System.Data;
|
|
using System.Security.Claims;
|
|
|
|
namespace Shentun.PeisReport.Api.Controllers
|
|
{
|
|
/// <summary>
|
|
/// 监利医院
|
|
/// </summary>
|
|
[Route("api/[controller]/[action]")]
|
|
[ApiController]
|
|
[ApiExplorerSettings(GroupName ="JianLiApi")]
|
|
//[Authorize]
|
|
public class ReportBusinessController : ControllerBase
|
|
{
|
|
|
|
private readonly SqlSugarClient _peisDb;
|
|
private readonly SqlSugarClient _lisDb;
|
|
private readonly IConfiguration _configuration;
|
|
private readonly ILogger<ReportBusinessController> _logger;
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public ReportBusinessController(
|
|
ILogger<ReportBusinessController> logger,
|
|
IConfiguration configuration
|
|
)
|
|
{
|
|
_logger = logger;
|
|
_configuration = configuration;
|
|
_peisDb = new SqlSugarClient(new ConnectionConfig()
|
|
{
|
|
ConnectionString = _configuration.GetSection("ConnectionStrings:Default").Value,
|
|
DbType = SqlSugar.DbType.SqlServer,
|
|
IsAutoCloseConnection = true
|
|
});
|
|
_lisDb = new SqlSugarClient(new ConnectionConfig()
|
|
{
|
|
ConnectionString = _configuration.GetSection("ConnectionStrings:Lis").Value,
|
|
DbType = SqlSugar.DbType.SqlServer,
|
|
IsAutoCloseConnection = true
|
|
});
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据身份证号码获取体检报告
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
public async Task<GetPeisReportByIdNoDto> GetPeisReportByIdNoAsync(GetPeisReportByIdNoInputDto input)
|
|
{
|
|
|
|
var result = new GetPeisReportByIdNoDto
|
|
{
|
|
Code = 100,
|
|
Message = "请求失败"
|
|
};
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(input.IdNo))
|
|
{
|
|
result.Message = "身份证不能为空";
|
|
|
|
return result;
|
|
}
|
|
|
|
try
|
|
{
|
|
|
|
var query = await _peisDb.Ado.GetDataTableAsync($"select top {input.ReportCount} patient_register_id,barcode_no,medical_times,id_card_no," +
|
|
$"medical_start_date,mobile_telephone,name as patient_name" +
|
|
$" from patient_register " +
|
|
$" where id_card_no='{input.IdNo}' and create_pdf_flag='1' order by patient_register_id desc ");
|
|
if (query.Rows.Count > 0)
|
|
{
|
|
List<GetPeisReportByIdNoResultDataDto> patientRegisterList = new List<GetPeisReportByIdNoResultDataDto>();
|
|
|
|
foreach (DataRow row in query.Rows)
|
|
{
|
|
var patientRegister = new GetPeisReportByIdNoResultDataDto
|
|
{
|
|
BarcodeNo = row["barcode_no"].ToString(),
|
|
MedicalDate = Convert.ToDateTime(row["medical_start_date"].ToString()).ToString("yyyy-MM-dd"),
|
|
MedicalTimes = row["medical_times"].ToString(),
|
|
MobileTelephone = row["mobile_telephone"].ToString(),
|
|
PatientName = row["patient_name"].ToString(),
|
|
IdNo = row["id_card_no"].ToString()
|
|
};
|
|
|
|
|
|
var patientRegisterId = row["patient_register_id"].ToString();
|
|
string directoryDate = patientRegisterId.Substring(0, 6);
|
|
string hostAddress = _configuration.GetSection("HostAddress").Value;
|
|
string reportVirtual = _configuration.GetSection("ReportVirtualPath:RequestPath").Value;
|
|
string reportUrl = $"{hostAddress + reportVirtual}/{directoryDate}/{patientRegisterId}({patientRegister.PatientName}).pdf";
|
|
|
|
patientRegister.ReportUrl = reportUrl;
|
|
|
|
patientRegisterList.Add(patientRegister);
|
|
}
|
|
|
|
result.Message = "请求成功";
|
|
result.Data = patientRegisterList;
|
|
result.Code = 200;
|
|
|
|
}
|
|
else
|
|
{
|
|
result.Code = 100;
|
|
result.Message = "身份证号未查到体检数据";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
result.Message = ex.Message;
|
|
_logger.LogError($"访问GetPeisReportByIdNoAsync异常,异常信息:{ex.Message}");
|
|
}
|
|
return result;
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 根据身份证号码获取检验报告
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
public async Task<GetLisReportByIdNoDto> GetLisReportByIdNoAsync(GetLisReportByIdNoInputDto input)
|
|
{
|
|
|
|
var result = new GetLisReportByIdNoDto
|
|
{
|
|
Code = 100,
|
|
Message = "请求失败"
|
|
};
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(input.IdNo))
|
|
{
|
|
result.Message = "身份证不能为空";
|
|
|
|
return result;
|
|
}
|
|
|
|
try
|
|
{
|
|
|
|
var query = await _lisDb.Ado.GetDataTableAsync($" select patient_register_id,patient_name,inspection_purpose,telephone,send_datetime from patient_register" +
|
|
$" where upload_web_flag='Y' and inspection_datetime>= DATEADD(DAY,-{input.ReportDay},GETDATE()) " +
|
|
$" and recieve_source_primarykey in " +
|
|
$" (select recieve_source_primarykey from patient_request where id_card_no='{input.IdNo}' ) order by patient_register_id desc ");
|
|
if (query.Rows.Count > 0)
|
|
{
|
|
List<GetLisReportByIdNoResultDataDto> patientRegisterList = new List<GetLisReportByIdNoResultDataDto>();
|
|
|
|
foreach (DataRow row in query.Rows)
|
|
{
|
|
var patientRegister = new GetLisReportByIdNoResultDataDto
|
|
{
|
|
InspectionPurpose = row["inspection_purpose"].ToString(),
|
|
SendDateTime = Convert.ToDateTime(row["send_datetime"].ToString()).ToString("yyyy-MM-dd"),
|
|
MobileTelephone = row["telephone"].ToString(),
|
|
PatientName = row["patient_name"].ToString(),
|
|
IdNo = input.IdNo
|
|
};
|
|
|
|
var patientRegisterId = row["patient_register_id"].ToString();
|
|
string hostAddress = _configuration.GetSection("HostAddress").Value;
|
|
string reportVirtual = _configuration.GetSection("LisReportVirtualPath:RequestPath").Value;
|
|
string reportUrl = $"{hostAddress + reportVirtual}/{patientRegisterId}.pdf";
|
|
|
|
patientRegister.ReportUrl = reportUrl;
|
|
|
|
patientRegisterList.Add(patientRegister);
|
|
}
|
|
|
|
result.Message = "请求成功";
|
|
result.Data = patientRegisterList;
|
|
result.Code = 200;
|
|
|
|
}
|
|
else
|
|
{
|
|
result.Code = 100;
|
|
result.Message = "身份证号未查到检验报告数据";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
result.Message = ex.Message;
|
|
_logger.LogError($"访问GetLisReportByIdNoAsync异常,异常信息:{ex.Message}");
|
|
}
|
|
return result;
|
|
}
|
|
|
|
|
|
#region 身份验证
|
|
|
|
///// <summary>
|
|
///// 登陆
|
|
///// </summary>
|
|
///// <returns></returns>
|
|
//[HttpPost]
|
|
//[AllowAnonymous]
|
|
//public ActionResult<string> Logon()
|
|
//{
|
|
// var userId = "001";
|
|
// var userName = "wenxiande";
|
|
// var roleName = "Bus";
|
|
|
|
// var claims = new List<Claim>()
|
|
// {
|
|
// new Claim("UserId",userId),
|
|
// new Claim(ClaimTypes.Sid,userId),
|
|
// new Claim("UserName",userName),
|
|
// new Claim(ClaimTypes.Name,userName)
|
|
// };
|
|
|
|
// claims.Add(new Claim(ClaimTypes.Role, roleName));
|
|
|
|
// JwtHelper jwtHelper = new JwtHelper();
|
|
// return jwtHelper.GetJwt(claims);
|
|
|
|
//}
|
|
|
|
///// <summary>
|
|
///// 查询测试
|
|
///// </summary>
|
|
///// <returns></returns>
|
|
//[HttpPost]
|
|
//[Authorize(Roles = "Bus")]
|
|
//public PublicResultDto TestSqlAsync()
|
|
//{
|
|
|
|
// var result = new PublicResultDto
|
|
// {
|
|
// Code = 200,
|
|
// Message = "请求成功"
|
|
// };
|
|
|
|
// return result;
|
|
//}
|
|
#endregion
|
|
}
|
|
}
|