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.
158 lines
6.2 KiB
158 lines
6.2 KiB
using Dapper;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Npgsql;
|
|
using Shentun.Utilities;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data.Common;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Shentun.Peis.PlugIns
|
|
{
|
|
public class LisRequestPlugInsBase : ThirdPlugInsBase
|
|
{
|
|
protected Guid AsbitemColumnReferenceId;
|
|
protected Guid SampleTypeColumnReferenceId;
|
|
|
|
public LisRequestPlugInsBase(Guid thirdInterfaceId):base(thirdInterfaceId)
|
|
{
|
|
var asbitemColumnReferenceIdStr = InterfaceConfig.GetSection("Interface").GetSection("AsbitemColumnReferenceId").Value;
|
|
if (!string.IsNullOrWhiteSpace(asbitemColumnReferenceIdStr))
|
|
{
|
|
AsbitemColumnReferenceId = new Guid(asbitemColumnReferenceIdStr);
|
|
}
|
|
var sampleTypeColumnReferenceIdStr = InterfaceConfig.GetSection("Interface").GetSection("SampleTypeColumnReferenceId").Value;
|
|
if (!string.IsNullOrWhiteSpace(sampleTypeColumnReferenceIdStr))
|
|
{
|
|
SampleTypeColumnReferenceId = new Guid(sampleTypeColumnReferenceIdStr);
|
|
}
|
|
}
|
|
|
|
public LisRequestPlugInsBase(string parmValue) : base(parmValue)
|
|
{
|
|
|
|
|
|
var asbitemColumnReferenceIdStr = InterfaceConfig.GetSection("Interface").GetSection("AsbitemColumnReferenceId").Value;
|
|
if(!string.IsNullOrWhiteSpace(asbitemColumnReferenceIdStr))
|
|
{
|
|
AsbitemColumnReferenceId = new Guid(asbitemColumnReferenceIdStr);
|
|
}
|
|
var sampleTypeColumnReferenceIdStr = InterfaceConfig.GetSection("Interface").GetSection("SampleTypeColumnReferenceId").Value;
|
|
if (!string.IsNullOrWhiteSpace(sampleTypeColumnReferenceIdStr))
|
|
{
|
|
SampleTypeColumnReferenceId = new Guid(sampleTypeColumnReferenceIdStr);
|
|
}
|
|
|
|
}
|
|
|
|
public virtual async Task<LisRequestPlugInsOut> SendRequestAsync(LisRequestPlugInsInput input)
|
|
{
|
|
var result = new LisRequestPlugInsOut();
|
|
return result;
|
|
}
|
|
|
|
public async Task<PatientRegisterForPlugIns> GetPatientRegisterForPlugInsAsync(Guid lisRequestId)
|
|
{
|
|
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.nation_id,
|
|
patient.id_no,
|
|
patient.email,
|
|
patient.telephone,
|
|
patient.mobile_telephone,
|
|
patient.address
|
|
from patient,patient_register,lis_request,register_check_asbitem,register_check
|
|
where patient.id = patient_register.patient_id and
|
|
patient_register.id = register_check.patient_register_id and
|
|
register_check.id = register_check_asbitem.register_check_id and
|
|
register_check_asbitem.lis_request_id = lis_request.id and
|
|
lis_request.id =@LisRequestId
|
|
";
|
|
var patientRegisterForPlugIns = (await conn.QueryAsync<PatientRegisterForPlugIns>(sql,
|
|
new { LisRequestId = lisRequestId })).SingleOrDefault();
|
|
return patientRegisterForPlugIns;
|
|
}
|
|
|
|
}
|
|
|
|
public async Task<LisRequestForPlugIns> GetLisRequestForPlugInsAsync(Guid lisRequestId)
|
|
{
|
|
using (DbConnection conn = new NpgsqlConnection(AppConnctionStr))
|
|
{
|
|
string sql;
|
|
sql = @"SELECT DISTINCT lis_request.id as lis_request_id,
|
|
lis_request.lis_request_no ,
|
|
lis_request.is_print ,
|
|
abp_users.name ,
|
|
lis_request.sampling_time,
|
|
lis_request.is_sign_in,
|
|
lis_request.sign_in_order,
|
|
lis_request.sign_in_person,
|
|
lis_request.sign_in_time,
|
|
sample_type.id as sample_type_id,
|
|
sample_type.display_name as sample_type_name,
|
|
sample_container.display_name as sample_container_name
|
|
from patient_register
|
|
JOIN register_check on patient_register.id = register_check.patient_register_id
|
|
JOIN register_check_asbitem on register_check.id = register_check_asbitem.register_check_id
|
|
JOIN lis_request on register_check_asbitem.lis_request_id = lis_request.id
|
|
left JOIN abp_users on lis_request.sampler_id = abp_users.id
|
|
JOIN sample_container ON lis_request.sample_container_id = sample_container.id
|
|
join sample_type on lis_request.sample_type_id = sample_type.id
|
|
where lis_request.id =@LisRequestId and
|
|
patient_register.complete_flag <> '3' and
|
|
register_check.complete_flag <> '1'
|
|
";
|
|
var lisRequestForPlugIns = (await conn.QueryAsync<LisRequestForPlugIns>(sql,
|
|
new { LisRequestId = lisRequestId })).SingleOrDefault();
|
|
if (lisRequestForPlugIns == null)
|
|
{
|
|
return null;
|
|
}
|
|
sql = @"
|
|
SELECT register_check_asbitem.asbitem_id,
|
|
asbitem.display_name as asbitem_name,
|
|
register_check_asbitem.amount * register_check_asbitem.charge_price as charges
|
|
from register_check
|
|
JOIN register_check_asbitem on register_check.id = register_check_asbitem.register_check_id
|
|
JOIN lis_request on register_check_asbitem.lis_request_id = lis_request.id
|
|
JOIN asbitem on register_check_asbitem.asbitem_id = asbitem.id
|
|
where
|
|
lis_request.id=@LisRequestId
|
|
";
|
|
|
|
lisRequestForPlugIns.Asbitems = (await conn.QueryAsync<LisRequestAsbitemForPlugIns>(sql,
|
|
new { LisRequestId = lisRequestId })).ToList();
|
|
|
|
return lisRequestForPlugIns;
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
public class LisRequestPlugInsInput
|
|
{
|
|
public Guid LisRequestId { get; set; }
|
|
}
|
|
|
|
|
|
|
|
public class LisRequestPlugInsOut
|
|
{
|
|
public string? ThirdLisRequestId { get; set; }
|
|
}
|
|
}
|