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.
229 lines
8.4 KiB
229 lines
8.4 KiB
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.Extensions.Configuration.UserSecrets;
|
|
using Newtonsoft.Json;
|
|
using Shentun.PeisReport.Api.Dto;
|
|
using SqlSugar;
|
|
using System.Data;
|
|
|
|
namespace Shentun.PeisReport.Api.Controllers
|
|
{
|
|
[Route("api/[controller]/[action]")]
|
|
[ApiController]
|
|
[ApiExplorerSettings(GroupName = "QingHaiWuYuanApi")]
|
|
public class PeisController : ControllerBase
|
|
{
|
|
private readonly SqlSugarClient _peisDb;
|
|
private readonly IConfiguration _configuration;
|
|
private readonly ILogger<PeisController> _logger;
|
|
public PeisController(
|
|
IConfiguration configuration,
|
|
ILogger<PeisController> logger)
|
|
{
|
|
_configuration = configuration;
|
|
_logger = logger;
|
|
_peisDb = new SqlSugarClient(new ConnectionConfig()
|
|
{
|
|
ConnectionString = _configuration.GetSection("ConnectionStrings:Default").Value,
|
|
DbType = SqlSugar.DbType.SqlServer,
|
|
IsAutoCloseConnection = true
|
|
});
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 根据身份证号码获取体检列表
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
public async Task<PatientRegisterListDto> GetPatientRegisterListAsync(IdNoInputDto input)
|
|
{
|
|
|
|
var result = new PatientRegisterListDto
|
|
{
|
|
Code = 100,
|
|
Message = "请求失败"
|
|
};
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(input.IdNo))
|
|
{
|
|
result.Message = "身份证不能为空";
|
|
|
|
return result;
|
|
}
|
|
|
|
try
|
|
{
|
|
|
|
var query = await _peisDb.Ado.GetDataTableAsync($"select b.sex_name,a.patient_register_id,a.age,a.barcode_no,a.medical_times," +
|
|
$"a.medical_start_date,a.mobile_telephone,a.name as patient_name" +
|
|
$" from patient_register as a left join sex as b " +
|
|
$" on a.sex_id=b.sex_id where id_card_no='{input.IdNo}' and audit_flag='Y' ");
|
|
if (query.Rows.Count > 0)
|
|
{
|
|
List<PatientRegisterListResultDataDto> patientRegisterList = new List<PatientRegisterListResultDataDto>();
|
|
|
|
foreach (DataRow row in query.Rows)
|
|
{
|
|
patientRegisterList.Add(new PatientRegisterListResultDataDto
|
|
{
|
|
age = row["age"].ToString(),
|
|
barcode_no = row["barcode_no"].ToString(),
|
|
medical_date = Convert.ToDateTime(row["medical_start_date"].ToString()).ToString("yyyy-MM-dd"),
|
|
medical_time = row["medical_times"].ToString(),
|
|
mobile_telephone = row["mobile_telephone"].ToString(),
|
|
name = row["patient_name"].ToString(),
|
|
patient_register_id = row["patient_register_id"].ToString(),
|
|
sex = row["sex_name"].ToString()
|
|
});
|
|
}
|
|
|
|
result.Message = "请求成功";
|
|
result.Data = patientRegisterList;
|
|
result.Code = 200;
|
|
|
|
}
|
|
else
|
|
{
|
|
result.Code = 100;
|
|
result.Message = "身份证号未查到体检数据";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
result.Message = ex.Message;
|
|
_logger.LogError($"访问GetPatientRegisterListAsync异常,异常信息:{ex.Message}");
|
|
}
|
|
return result;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 根据人员id获取体检报告地址
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
public async Task<PeisReportUrlByPatientRegisterIdDto> GetPeisReportUrlByPatientRegisterIdAsync(PatientRegisterIdInputDto input)
|
|
{
|
|
|
|
var result = new PeisReportUrlByPatientRegisterIdDto
|
|
{
|
|
Code = 100,
|
|
Message = "请求失败"
|
|
};
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(input.PatientRegisterId))
|
|
{
|
|
result.Message = "人员Id不能为空";
|
|
|
|
return result;
|
|
}
|
|
|
|
try
|
|
{
|
|
|
|
|
|
var query = await _peisDb.Ado.GetDataTableAsync($"select name as patient_name from patient_register where patient_register_id='{input.PatientRegisterId}' and create_pdf_flag='1'");
|
|
if (query.Rows.Count > 0)
|
|
{
|
|
|
|
string patientName = query.Rows[0]["patient_name"].ToString();
|
|
string directoryDate = input.PatientRegisterId.Substring(0, 6);
|
|
string hostAddress = _configuration.GetSection("HostAddress").Value;
|
|
string reportVirtual = _configuration.GetSection("ReportVirtualPath:RequestPath").Value;
|
|
string reportUrl = $"{hostAddress + reportVirtual}/{directoryDate}/{input.PatientRegisterId}({patientName}).pdf";
|
|
|
|
result.Message = "请求成功";
|
|
result.Data = new PeisReportUrlByPatientRegisterIdResultDataDto { peis_report_url = reportUrl };
|
|
result.Code = 200;
|
|
|
|
}
|
|
else
|
|
{
|
|
result.Code = 100;
|
|
result.Message = "未上传报告";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
result.Message = ex.Message;
|
|
_logger.LogError($"访问GetPeisReportUrlByPatientRegisterIdAsync异常,异常信息:{ex.Message}");
|
|
}
|
|
return result;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 获取当前人员的排队情况
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
public async Task<QueueRegisterByBarCodeNoDto> GetQueueRegisterByBarCodeNoAsync(BarCodeNoInputDto input)
|
|
{
|
|
|
|
var result = new QueueRegisterByBarCodeNoDto
|
|
{
|
|
Code = 100,
|
|
Message = "请求失败"
|
|
};
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(input.BarCodeNo))
|
|
{
|
|
result.Message = "条码不能为空";
|
|
|
|
return result;
|
|
}
|
|
|
|
try
|
|
{
|
|
|
|
|
|
var query = await _peisDb.Ado.GetDataTableAsync($" select a.queue_register_id,a.room_id,c.room_name,b.name as patient_name from queue_register as a " +
|
|
$" left join patient_register as b on a.patient_register_id=b.patient_register_id " +
|
|
$" left join room as c on a.room_id=c.room_id " +
|
|
$" where b.barcode_no='{input.BarCodeNo}' and a.complete_flag='0' and created_date >= convert(varchar(10),getdate(),121)");
|
|
if (query.Rows.Count > 0)
|
|
{
|
|
|
|
string patientName = query.Rows[0]["patient_name"].ToString();
|
|
string roomId = query.Rows[0]["room_id"].ToString();
|
|
string roomName = query.Rows[0]["room_name"].ToString();
|
|
string queueRegisterId = query.Rows[0]["queue_register_id"].ToString();
|
|
|
|
|
|
var queueCount = _peisDb.Ado.SqlQuerySingle<int>($" select count(queue_register_id) as pdcount from queue_register " +
|
|
$" where room_id='{roomId}' and complete_flag = '0' and queue_register_id<'{queueRegisterId}' and created_date >= convert(varchar(10),getdate(),121)");
|
|
|
|
result.Message = "请求成功";
|
|
result.Data = new QueueRegisterByBarCodeNoResultDataDto
|
|
{
|
|
patient_name = patientName,
|
|
queue_count = queueCount,
|
|
room_name = roomName
|
|
};
|
|
result.Code = 200;
|
|
|
|
}
|
|
else
|
|
{
|
|
result.Code = 100;
|
|
result.Message = "当前无排队信息";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
result.Message = ex.Message;
|
|
_logger.LogError($"访问GetQueueRegisterByBarCodeNoAsync异常,异常信息:{ex.Message}");
|
|
}
|
|
return result;
|
|
}
|
|
|
|
|
|
}
|
|
}
|