8 changed files with 427 additions and 4 deletions
			
			
		- 
					6ThirdPlugIns/Shentun.Peis.PlugIns.Gem/ImportPacsResultPlugInsGem.cs
 - 
					169ThirdPlugIns/Shentun.Peis.PlugIns.Gem/ImportPatientRegisterPlugInsGem.cs
 - 
					17ThirdPlugIns/Shentun.Peis.PlugIns.Gem/QztlImportDataEntity.cs
 - 
					140ThirdPlugIns/Shentun.Peis.PlugIns.Gem/QztlPatientRegisterFromInterface.cs
 - 
					49ThirdPlugIns/Shentun.Peis.PlugIns.Gem/test/Shentun.Peis.PlugIns.Gem.Test/ImportPatientRegisterPlugInsGemTest.cs
 - 
					12ThirdPlugIns/Shentun.Peis.PlugIns.Gem/test/Shentun.Peis.PlugIns.Gem.Test/appsettings.json
 - 
					18src/Shentun.ColumnReferencePlugIns/CustomerOrgForPlugIns.cs
 - 
					20src/Shentun.ColumnReferencePlugIns/ImportPatientRegisterPlugInsBase.cs
 
@ -0,0 +1,169 @@ | 
			
		|||||
 | 
				using Dapper; | 
			
		||||
 | 
				using Newtonsoft.Json.Converters; | 
			
		||||
 | 
				using Newtonsoft.Json; | 
			
		||||
 | 
				using Npgsql; | 
			
		||||
 | 
				using NPOI.SS.Formula.Functions; | 
			
		||||
 | 
				using System; | 
			
		||||
 | 
				using System.Collections.Generic; | 
			
		||||
 | 
				using System.Data.Common; | 
			
		||||
 | 
				using System.Linq; | 
			
		||||
 | 
				using System.Net.Http.Headers; | 
			
		||||
 | 
				using System.Text; | 
			
		||||
 | 
				using System.Threading.Tasks; | 
			
		||||
 | 
				using System.Text.RegularExpressions; | 
			
		||||
 | 
				
 | 
			
		||||
 | 
				namespace Shentun.Peis.PlugIns.Gem | 
			
		||||
 | 
				{ | 
			
		||||
 | 
				    public class ImportPatientRegisterPlugInsGem : ImportPatientRegisterPlugInsBase | 
			
		||||
 | 
				    { | 
			
		||||
 | 
				        private Guid _importCustomerOrgId; | 
			
		||||
 | 
				        private string _hospitalId; | 
			
		||||
 | 
				        private string _aesKEY; | 
			
		||||
 | 
				        private string _year; | 
			
		||||
 | 
				        public ImportPatientRegisterPlugInsGem(string parmValue) : base(parmValue) | 
			
		||||
 | 
				        { | 
			
		||||
 | 
				
 | 
			
		||||
 | 
				        } | 
			
		||||
 | 
				
 | 
			
		||||
 | 
				        public override async Task ImportAsync() | 
			
		||||
 | 
				        { | 
			
		||||
 | 
				            await InitAsync(); | 
			
		||||
 | 
				
 | 
			
		||||
 | 
				            var qztlPatientRegisterFromInterface = await CallInterfaceServiceAsync(); | 
			
		||||
 | 
				            if (qztlPatientRegisterFromInterface == null || !qztlPatientRegisterFromInterface.plans.Any()) | 
			
		||||
 | 
				            { | 
			
		||||
 | 
				                return; | 
			
		||||
 | 
				            } | 
			
		||||
 | 
				
 | 
			
		||||
 | 
				            foreach(var patient in qztlPatientRegisterFromInterface.plans) | 
			
		||||
 | 
				            { | 
			
		||||
 | 
				
 | 
			
		||||
 | 
				            } | 
			
		||||
 | 
				
 | 
			
		||||
 | 
				
 | 
			
		||||
 | 
				        } | 
			
		||||
 | 
				
 | 
			
		||||
 | 
				        public async Task InitAsync() | 
			
		||||
 | 
				        { | 
			
		||||
 | 
				            var customerOrgIdStr = InterfaceConfig.GetSection("Interface").GetSection("单位编号").Value; | 
			
		||||
 | 
				            _hospitalId = InterfaceConfig.GetSection("Interface").GetSection("HospitalId").Value; | 
			
		||||
 | 
				            _aesKEY = InterfaceConfig.GetSection("Interface").GetSection("aesKEY").Value; | 
			
		||||
 | 
				            if (string.IsNullOrWhiteSpace(customerOrgIdStr)) | 
			
		||||
 | 
				            { | 
			
		||||
 | 
				                return; | 
			
		||||
 | 
				            } | 
			
		||||
 | 
				            if (!Guid.TryParse(customerOrgIdStr, out _importCustomerOrgId)) | 
			
		||||
 | 
				            { | 
			
		||||
 | 
				                throw new Exception("单位编号不正确"); | 
			
		||||
 | 
				            } | 
			
		||||
 | 
				            if (string.IsNullOrWhiteSpace(_hospitalId)) | 
			
		||||
 | 
				            { | 
			
		||||
 | 
				                throw new Exception("HospitalId参数不能为空"); | 
			
		||||
 | 
				            } | 
			
		||||
 | 
				            if (string.IsNullOrWhiteSpace(_aesKEY)) | 
			
		||||
 | 
				            { | 
			
		||||
 | 
				                throw new Exception("_aesKEY参数不能为空"); | 
			
		||||
 | 
				            } | 
			
		||||
 | 
				            using (DbConnection conn = new NpgsqlConnection(AppConnctionStr)) | 
			
		||||
 | 
				            { | 
			
		||||
 | 
				                string sql; | 
			
		||||
 | 
				                sql = @"
 | 
			
		||||
 | 
				                      SELECT id as  customer_org_id, | 
			
		||||
 | 
				                             display_name as customer_org_name, | 
			
		||||
 | 
				                             parent_id , | 
			
		||||
 | 
				                             path_code | 
			
		||||
 | 
				                      from  | 
			
		||||
 | 
				                      customer_org  | 
			
		||||
 | 
				                      where id = @CustomerOrgId | 
			
		||||
 | 
				                      ";
 | 
			
		||||
 | 
				                var customerOrgForPlugInss = (await conn.QueryAsync<CustomerOrgForPlugIns>(sql, | 
			
		||||
 | 
				                    new { CustomerOrgId = _importCustomerOrgId })).FirstOrDefault(); | 
			
		||||
 | 
				
 | 
			
		||||
 | 
				                if (customerOrgForPlugInss == null) | 
			
		||||
 | 
				                { | 
			
		||||
 | 
				                    throw new Exception("单位编号不正确,找不到单位"); | 
			
		||||
 | 
				                } | 
			
		||||
 | 
				
 | 
			
		||||
 | 
				                var year = customerOrgForPlugInss.CustomerOrgName.Substring( | 
			
		||||
 | 
				                    customerOrgForPlugInss.CustomerOrgName.Length - 5 | 
			
		||||
 | 
				                    , 4); | 
			
		||||
 | 
				                if (!int.TryParse(year, out var yearNumber)) | 
			
		||||
 | 
				                { | 
			
		||||
 | 
				                    throw new Exception("单位名称必须是以2000年这样的格式结尾"); | 
			
		||||
 | 
				                } | 
			
		||||
 | 
				                if (yearNumber < 2024 || yearNumber > 2050) | 
			
		||||
 | 
				                { | 
			
		||||
 | 
				                    throw new Exception("单位名称年限范围必须在2024-2050之间"); | 
			
		||||
 | 
				                } | 
			
		||||
 | 
				
 | 
			
		||||
 | 
				                _year = year; | 
			
		||||
 | 
				            } | 
			
		||||
 | 
				        } | 
			
		||||
 | 
				
 | 
			
		||||
 | 
				
 | 
			
		||||
 | 
				        public async Task<QztlPatientRegisterFromInterface?> CallInterfaceServiceAsync() | 
			
		||||
 | 
				        { | 
			
		||||
 | 
				            string baseAddress = InterfaceWebApiUrl; | 
			
		||||
 | 
				            string ary = "HospitalId=" + _hospitalId + (Char)38 + "year=" + _year + (Char)38 + "AesKey=" + _aesKEY; | 
			
		||||
 | 
				            baseAddress = baseAddress + ary; | 
			
		||||
 | 
				            using (var httpClientHandler = new HttpClientHandler()) | 
			
		||||
 | 
				            { | 
			
		||||
 | 
				                using (var httpClient = new HttpClient(httpClientHandler)) | 
			
		||||
 | 
				                { | 
			
		||||
 | 
				                    httpClient.BaseAddress = new Uri(baseAddress); | 
			
		||||
 | 
				
 | 
			
		||||
 | 
				                    httpClient.DefaultRequestHeaders.Accept.Add( | 
			
		||||
 | 
				                      new MediaTypeWithQualityHeaderValue("application/x-www-form-urlencoded"));//设置accept标头,告诉JSON是可接受的响应类型
 | 
			
		||||
 | 
				                    //httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", _accesToken);
 | 
			
		||||
 | 
				                    IsoDateTimeConverter timeFormat = new IsoDateTimeConverter(); | 
			
		||||
 | 
				                    timeFormat.DateTimeFormat = "yyyy-MM-dd HH:mm:ss"; | 
			
		||||
 | 
				                    //var sendData = JsonConvert.SerializeObject(data, Newtonsoft.Json.Formatting.Indented, timeFormat);
 | 
			
		||||
 | 
				                    using (HttpContent httpContent = new StringContent("")) | 
			
		||||
 | 
				                    { | 
			
		||||
 | 
				                        httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/x-www-form-urlencoded"); | 
			
		||||
 | 
				                        HttpResponseMessage response = await httpClient.GetAsync(""); | 
			
		||||
 | 
				                        string result; | 
			
		||||
 | 
				                        if (!response.IsSuccessStatusCode) | 
			
		||||
 | 
				                        { | 
			
		||||
 | 
				                            result = response.Content.ReadAsStringAsync().Result; | 
			
		||||
 | 
				                            throw new Exception("http通信错误:" + response.StatusCode + ",结果:" + result); | 
			
		||||
 | 
				                        } | 
			
		||||
 | 
				                        result = await response.Content.ReadAsStringAsync(); | 
			
		||||
 | 
				
 | 
			
		||||
 | 
				                        result = result.Replace(":\"[{", ":[{").Replace("}]\"", "}]").Replace("\\", ""); | 
			
		||||
 | 
				                         | 
			
		||||
 | 
				                        QztlPatientRegisterFromInterface? resultDto = JsonConvert.DeserializeObject<QztlPatientRegisterFromInterface>(result); | 
			
		||||
 | 
				                        if (resultDto != null) | 
			
		||||
 | 
				                        { | 
			
		||||
 | 
				                            if (resultDto.status != 0) | 
			
		||||
 | 
				                            { | 
			
		||||
 | 
				                                throw new Exception($"调用WebApi失败,返回错误,消息:" + resultDto.status + resultDto.errorMsg); | 
			
		||||
 | 
				                            } | 
			
		||||
 | 
				                            //插入数据库中备份
 | 
			
		||||
 | 
				                            using (DbConnection conn = new NpgsqlConnection(AppConnctionStr)) | 
			
		||||
 | 
				                            { | 
			
		||||
 | 
				                                string sql; | 
			
		||||
 | 
				                                var qztlImportDataEntity = new QztlImportDataEntity() | 
			
		||||
 | 
				                                { | 
			
		||||
 | 
				                                    Id = Guid.NewGuid(), | 
			
		||||
 | 
				                                    Data = result, | 
			
		||||
 | 
				                                    DataType = '0', | 
			
		||||
 | 
				                                    IsComplete = 'Y', | 
			
		||||
 | 
				                                    CreationTime = DateTime.Now, | 
			
		||||
 | 
				                                }; | 
			
		||||
 | 
				
 | 
			
		||||
 | 
				                                sql = @"insert into qztl_import_data(id, data, data_type, is_complete,creation_time) 
 | 
			
		||||
 | 
				                             values(@Id, @Data, @DataType, @IsComplete,@CreationTime)";
 | 
			
		||||
 | 
				                                conn.Execute(sql, qztlImportDataEntity); | 
			
		||||
 | 
				
 | 
			
		||||
 | 
				                            } | 
			
		||||
 | 
				                            return (QztlPatientRegisterFromInterface)resultDto; | 
			
		||||
 | 
				                        } | 
			
		||||
 | 
				                        return null; | 
			
		||||
 | 
				                    } | 
			
		||||
 | 
				
 | 
			
		||||
 | 
				                } | 
			
		||||
 | 
				            } | 
			
		||||
 | 
				        } | 
			
		||||
 | 
				    } | 
			
		||||
 | 
				} | 
			
		||||
@ -0,0 +1,17 @@ | 
			
		|||||
 | 
				using System; | 
			
		||||
 | 
				using System.Collections.Generic; | 
			
		||||
 | 
				using System.Linq; | 
			
		||||
 | 
				using System.Text; | 
			
		||||
 | 
				using System.Threading.Tasks; | 
			
		||||
 | 
				
 | 
			
		||||
 | 
				namespace Shentun.Peis.PlugIns.Gem | 
			
		||||
 | 
				{ | 
			
		||||
 | 
				    public class QztlImportDataEntity | 
			
		||||
 | 
				    { | 
			
		||||
 | 
				        public Guid Id { get; set; } | 
			
		||||
 | 
				        public string Data { get; set; } | 
			
		||||
 | 
				        public char DataType { get; set; } | 
			
		||||
 | 
				        public char IsComplete { get; set; }    | 
			
		||||
 | 
				        public DateTime CreationTime { get; set; } | 
			
		||||
 | 
				    } | 
			
		||||
 | 
				} | 
			
		||||
@ -0,0 +1,140 @@ | 
			
		|||||
 | 
				using System; | 
			
		||||
 | 
				using System.Collections.Generic; | 
			
		||||
 | 
				using System.Linq; | 
			
		||||
 | 
				using System.Text; | 
			
		||||
 | 
				using System.Threading.Tasks; | 
			
		||||
 | 
				
 | 
			
		||||
 | 
				namespace Shentun.Peis.PlugIns.Gem | 
			
		||||
 | 
				{ | 
			
		||||
 | 
				    public class QztlPatientRegisterFromInterface | 
			
		||||
 | 
				    { | 
			
		||||
 | 
				        public int status {  get; set; } | 
			
		||||
 | 
				        public string errorMsg { get; set; } | 
			
		||||
 | 
				        public int size { get; set; } | 
			
		||||
 | 
				        public List<string> delIds { get; set; } = new List<string>(); | 
			
		||||
 | 
				        public List<QztlPatientRegisterFromInterfacePlan> plans { get; set; } = new List<QztlPatientRegisterFromInterfacePlan>(); | 
			
		||||
 | 
				    } | 
			
		||||
 | 
				    public class QztlPatientRegisterFromInterfacePlan | 
			
		||||
 | 
				    { | 
			
		||||
 | 
				        /// <summary>
 | 
			
		||||
 | 
				        /// 
 | 
			
		||||
 | 
				        /// </summary>
 | 
			
		||||
 | 
				        public string gradeJsV { get; set; } | 
			
		||||
 | 
				        /// <summary>
 | 
			
		||||
 | 
				        /// 体检年份 int
 | 
			
		||||
 | 
				        /// </summary>
 | 
			
		||||
 | 
				        public int year { get; set; } | 
			
		||||
 | 
				        /// <summary>
 | 
			
		||||
 | 
				        /// 2024年全员体检
 | 
			
		||||
 | 
				        /// </summary>
 | 
			
		||||
 | 
				        public string planName { get; set; } | 
			
		||||
 | 
				        /// <summary>
 | 
			
		||||
 | 
				        /// 体检批次
 | 
			
		||||
 | 
				        /// </summary>
 | 
			
		||||
 | 
				        public string tjpcV {  get; set; } | 
			
		||||
 | 
				        /// <summary>
 | 
			
		||||
 | 
				        /// 体检阶段 int
 | 
			
		||||
 | 
				        /// </summary>
 | 
			
		||||
 | 
				        public int tjJieduan { get; set; } | 
			
		||||
 | 
				        /// <summary>
 | 
			
		||||
 | 
				        /// 年龄 int
 | 
			
		||||
 | 
				        /// </summary>
 | 
			
		||||
 | 
				        public int age { get; set; } | 
			
		||||
 | 
				        /// <summary>
 | 
			
		||||
 | 
				        /// 身份证号
 | 
			
		||||
 | 
				        /// </summary>
 | 
			
		||||
 | 
				        public string cardId { get; set; } | 
			
		||||
 | 
				        /// <summary>
 | 
			
		||||
 | 
				        /// 本次体检唯一ID号,long
 | 
			
		||||
 | 
				        /// </summary>
 | 
			
		||||
 | 
				        public long id { get; set; } | 
			
		||||
 | 
				        /// <summary>
 | 
			
		||||
 | 
				        /// 职称
 | 
			
		||||
 | 
				        /// </summary>
 | 
			
		||||
 | 
				        public string gradeZwV { get; set; } | 
			
		||||
 | 
				        /// <summary>
 | 
			
		||||
 | 
				        /// 高原体检,int
 | 
			
		||||
 | 
				        /// </summary>
 | 
			
		||||
 | 
				        public int ifGy { get; set; } | 
			
		||||
 | 
				        /// <summary>
 | 
			
		||||
 | 
				        /// 健康体检
 | 
			
		||||
 | 
				        /// </summary>
 | 
			
		||||
 | 
				        public int ifJk { get; set; } | 
			
		||||
 | 
				        /// <summary>
 | 
			
		||||
 | 
				        /// 普速体检
 | 
			
		||||
 | 
				        /// </summary>
 | 
			
		||||
 | 
				        public int ifCw { get; set; } | 
			
		||||
 | 
				        /// <summary>
 | 
			
		||||
 | 
				        /// 从业
 | 
			
		||||
 | 
				        /// </summary>
 | 
			
		||||
 | 
				        public int ifCy { get; set; } | 
			
		||||
 | 
				        /// <summary>
 | 
			
		||||
 | 
				        /// 复检
 | 
			
		||||
 | 
				        /// </summary>
 | 
			
		||||
 | 
				        public int ifFj { get; set; } | 
			
		||||
 | 
				        /// <summary>
 | 
			
		||||
 | 
				        /// 高铁
 | 
			
		||||
 | 
				        /// </summary>
 | 
			
		||||
 | 
				        public int ifGt { get; set; } | 
			
		||||
 | 
				        /// <summary>
 | 
			
		||||
 | 
				        /// 行车体检
 | 
			
		||||
 | 
				        /// </summary>
 | 
			
		||||
 | 
				        public int ifMain { get; set; } | 
			
		||||
 | 
				        /// <summary>
 | 
			
		||||
 | 
				        /// 危害体检
 | 
			
		||||
 | 
				        /// </summary>
 | 
			
		||||
 | 
				        public int ifWh { get; set; } | 
			
		||||
 | 
				        /// <summary>
 | 
			
		||||
 | 
				        /// 手机号
 | 
			
		||||
 | 
				        /// </summary>
 | 
			
		||||
 | 
				        public string mobile { get; set; } | 
			
		||||
 | 
				        /// <summary>
 | 
			
		||||
 | 
				        /// 单位 int
 | 
			
		||||
 | 
				        /// </summary>
 | 
			
		||||
 | 
				        public long orgId { get; set; } | 
			
		||||
 | 
				        /// <summary>
 | 
			
		||||
 | 
				        /// 单位名
 | 
			
		||||
 | 
				        /// </summary>
 | 
			
		||||
 | 
				        public string orgName { get; set; } | 
			
		||||
 | 
				        /// <summary>
 | 
			
		||||
 | 
				        /// 姓名
 | 
			
		||||
 | 
				        /// </summary>
 | 
			
		||||
 | 
				        public string personName { get; set; } | 
			
		||||
 | 
				        /// <summary>
 | 
			
		||||
 | 
				        /// 性别,int
 | 
			
		||||
 | 
				        /// </summary>
 | 
			
		||||
 | 
				        public int sex { get; set; } | 
			
		||||
 | 
				        /// <summary>
 | 
			
		||||
 | 
				        /// 
 | 
			
		||||
 | 
				        /// </summary>
 | 
			
		||||
 | 
				        public int wedding { get; set; } | 
			
		||||
 | 
				        /// <summary>
 | 
			
		||||
 | 
				        /// 干部
 | 
			
		||||
 | 
				        /// </summary>
 | 
			
		||||
 | 
				        public string workTypeV { get; set; } | 
			
		||||
 | 
				        /// <summary>
 | 
			
		||||
 | 
				        /// 备注
 | 
			
		||||
 | 
				        /// </summary>
 | 
			
		||||
 | 
				        public string remark { get; set; } | 
			
		||||
 | 
				        /// <summary>
 | 
			
		||||
 | 
				        /// 职务
 | 
			
		||||
 | 
				        /// </summary>
 | 
			
		||||
 | 
				        public string tjTab1 { get; set; } | 
			
		||||
 | 
				        /// <summary>
 | 
			
		||||
 | 
				        /// 体检备注
 | 
			
		||||
 | 
				        /// </summary>
 | 
			
		||||
 | 
				        public string tjOpinion { get; set; } | 
			
		||||
 | 
				        /// <summary>
 | 
			
		||||
 | 
				        /// 复检备注
 | 
			
		||||
 | 
				        /// </summary>
 | 
			
		||||
 | 
				        public string fjOpinion { get; set; } | 
			
		||||
 | 
				        /// <summary>
 | 
			
		||||
 | 
				        /// int
 | 
			
		||||
 | 
				        /// </summary>
 | 
			
		||||
 | 
				        public int altitude { get; set; } | 
			
		||||
 | 
				        /// <summary>
 | 
			
		||||
 | 
				        /// DateTime
 | 
			
		||||
 | 
				        /// </summary>
 | 
			
		||||
 | 
				        public DateTime beginTime { get; set; } | 
			
		||||
 | 
				    } | 
			
		||||
 | 
				} | 
			
		||||
						
							
						
						
							49
	
						
						ThirdPlugIns/Shentun.Peis.PlugIns.Gem/test/Shentun.Peis.PlugIns.Gem.Test/ImportPatientRegisterPlugInsGemTest.cs
						
							File diff suppressed because it is too large
							
							
								
									View File
								
							
						
					
				File diff suppressed because it is too large
							
							
								
									View File
								
							
						@ -0,0 +1,18 @@ | 
			
		|||||
 | 
				using System; | 
			
		||||
 | 
				using System.Collections.Generic; | 
			
		||||
 | 
				using System.Linq; | 
			
		||||
 | 
				using System.Text; | 
			
		||||
 | 
				using System.Threading.Tasks; | 
			
		||||
 | 
				
 | 
			
		||||
 | 
				namespace Shentun.Peis.PlugIns | 
			
		||||
 | 
				{ | 
			
		||||
 | 
				    public class CustomerOrgForPlugIns | 
			
		||||
 | 
				    { | 
			
		||||
 | 
				        public Guid CustomerOrgId { get; set; } | 
			
		||||
 | 
				        public string CustomerOrgName { get; set; } | 
			
		||||
 | 
				
 | 
			
		||||
 | 
				        public Guid ParentId { get; set; } | 
			
		||||
 | 
				
 | 
			
		||||
 | 
				        public string PathCode { get; set; } | 
			
		||||
 | 
				    } | 
			
		||||
 | 
				} | 
			
		||||
@ -0,0 +1,20 @@ | 
			
		|||||
 | 
				using System; | 
			
		||||
 | 
				using System.Collections.Generic; | 
			
		||||
 | 
				using System.Linq; | 
			
		||||
 | 
				using System.Text; | 
			
		||||
 | 
				using System.Threading.Tasks; | 
			
		||||
 | 
				
 | 
			
		||||
 | 
				namespace Shentun.Peis.PlugIns | 
			
		||||
 | 
				{ | 
			
		||||
 | 
				    public class ImportPatientRegisterPlugInsBase : ThirdPlugInsBase | 
			
		||||
 | 
				    { | 
			
		||||
 | 
				        public ImportPatientRegisterPlugInsBase(string parmValue) : base(parmValue) | 
			
		||||
 | 
				        { | 
			
		||||
 | 
				        } | 
			
		||||
 | 
				
 | 
			
		||||
 | 
				        public virtual async Task ImportAsync() | 
			
		||||
 | 
				        { | 
			
		||||
 | 
				            return ; | 
			
		||||
 | 
				        } | 
			
		||||
 | 
				    } | 
			
		||||
 | 
				} | 
			
		||||
						Write
						Preview
					
					
					Loading…
					
					Cancel
						Save
					
		Reference in new issue