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.
		
		
		
	
	
		
		
			
	
    
		
			
				
					
						                                                            | 
						 | 
						using Dapper;using Npgsql;using Shentun.Peis.PlugIns.LisRequests;using System;using System.Collections.Generic;using System.Data.Common;using System.Linq;using System.Text;using System.Threading.Tasks;
namespace Shentun.Peis.PlugIns.ImportLisResults{    public class ImportLisResultPlugInsBase : ThirdPlugInsBase    {        public ImportLisResultPlugInsBase(Guid thirdInterfaceId) : base(thirdInterfaceId)        {
        }
        //protected string AppLisUser;
        //protected string AppLisPassword;
        public ImportLisResultPlugInsBase(string parmValue) : base(parmValue)        {
            //AppLisUser = AppConfig.GetSection("App")
            //   .GetSection("LisUser").Value;
            //AppLisPassword = AppConfig.GetSection("App")
            //  .GetSection("LisPassword").Value;
        }        public virtual async Task<ImportLisResultPlugInsOut> ImportResultByPatientRegisterIdAsync(Guid patientRegisterId)        {            var result = new ImportLisResultPlugInsOut();            return result;        }
        public async Task<List<LisRequestForImportResultPlugIns>> GetLisRequestForImportResultPlugInssAsync(Guid patientRegisterId)        {            using (DbConnection conn = new NpgsqlConnection(AppConnctionStr))            {                string sql;                sql = @"
  SELECT distinct lis_request.id ,         lis_request.lis_request_no 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  where patient_register.id = @PatientRegisterId                      ";
                var lisRequestForImportResultPlugInss = (await conn.QueryAsync<LisRequestForImportResultPlugIns>(sql,                    new { PatientRegisterId = patientRegisterId })).ToList();                return lisRequestForImportResultPlugInss;            }        }
        public async Task<List<PatientRegisterForLisRequest>> GetRequestPatientRegisters(int days)        {            using (DbConnection conn = new NpgsqlConnection(AppConnctionStr))            {                string sql;                var startDate = DateTime.Now.Date.AddDays(-days);                sql = @" SELECT distinct register_check.patient_register_id
 from lis_request ,register_check_asbitem,register_check,patient_registerWHERE lis_request.id = register_check_asbitem.lis_request_id andregister_check_asbitem.register_check_id = register_check.id andregister_check.patient_register_id = patient_register.id and(          patient_register.complete_flag = '1' or           patient_register.complete_flag = '2') and         patient_register.medical_center_id =@MedicalCenterId andlis_request.creation_time > @StartDateORDER BY register_check.patient_register_id                      ";
                var patientRegisterForLisRequests = (await conn.QueryAsync<PatientRegisterForLisRequest>(sql,                    new { _thirdInterfaceDto.MedicalCenterId, StartDate = startDate })).ToList();
                return patientRegisterForLisRequests;            }
        }
        public override Task DoWork()        {            //var loginResult =  LoginAsync().Result;
            var queryDaysStr = InterfaceConfig.GetSection("Interface").GetSection("Scheduler").GetSection("QueryDays").Value;            if (string.IsNullOrWhiteSpace(queryDaysStr))            {                queryDaysStr = "1";            }            if (!int.TryParse(queryDaysStr, out int days))            {                days = 1;            }            var patientRegisters = GetRequestPatientRegisters(days).Result;
            foreach (var patientRegister in patientRegisters)            {                try                {                    var result = ImportResultByPatientRegisterIdAsync(patientRegister.PatientRegisterId).Result;                }                catch (Exception ex)                {
                }
            }            return Task.CompletedTask;        }
        //protected async override Task<LoginOutDto> LoginAsync() 
        //{
        //   var relult = await LoginAsync(AppLisUser, AppLisPassword);
        //    return relult;
        //}
    }}
  |