diff --git a/ThirdPlugIns/Shentun.Peis.PlugIns.Gem/ImportPatientRegisterPlugInsGem.cs b/ThirdPlugIns/Shentun.Peis.PlugIns.Gem/ImportPatientRegisterPlugInsGem.cs index 2e5f80c..1dbabb1 100644 --- a/ThirdPlugIns/Shentun.Peis.PlugIns.Gem/ImportPatientRegisterPlugInsGem.cs +++ b/ThirdPlugIns/Shentun.Peis.PlugIns.Gem/ImportPatientRegisterPlugInsGem.cs @@ -20,6 +20,7 @@ using Shentun.Peis.CustomerReports; using Shentun.Peis.CustomerOrgGroupDetails; using Shentun.Peis.CustomerOrgRegisters; using Shentun.Peis.Enums; +using Shentun.Peis.Patients; namespace Shentun.Peis.PlugIns.Gem { @@ -42,199 +43,234 @@ namespace Shentun.Peis.PlugIns.Gem { await LoginAsync(); await InitAsync(); - - var qztlPatientRegisterFromInterface = await CallInterfaceServiceAsync(); - if (qztlPatientRegisterFromInterface == null || !qztlPatientRegisterFromInterface.plans.Any()) - { - return; - } - //设置导入人员信息 - foreach (var patient in qztlPatientRegisterFromInterface.plans) + for(var i = 0;i<30;i++) { - //婚姻状况 - var maritalStatusId = ConvertMaritalStatus(patient.wedding); - //人员类别 - var personnelType = ConvertPersonnelType(patient.tjJieduan); - //性别 - var sexId = ConvertSex(patient.sex); - //体检类别 - var medicalTypeName = patient.tjpcV; - MedicalTypeDto medicalTypeDto = null; - if (!string.IsNullOrWhiteSpace(medicalTypeName)) + var qztlPatientRegisterFromInterface = await CallInterfaceServiceAsync(); + if (qztlPatientRegisterFromInterface == null || !qztlPatientRegisterFromInterface.plans.Any()) + { + return; + } + //设置导入人员信息 + foreach (var patient in qztlPatientRegisterFromInterface.plans) { - medicalTypeDto = await CallAppServiceAsync( - "api/app/MedicalType/GetByDisplayName", new DisplayNameInputDto() { DisplayName = medicalTypeName }); - if (medicalTypeDto == null) + //婚姻状况 + var maritalStatusId = ConvertMaritalStatus(patient.wedding); + //人员类别 + var personnelType = ConvertPersonnelType(patient.tjJieduan); + //性别 + var sexId = ConvertSex(patient.sex); + //体检类别 + var medicalTypeName = patient.tjpcV; + MedicalTypeDto medicalTypeDto = null; + if (!string.IsNullOrWhiteSpace(medicalTypeName)) { - var createMedicalTypeDto = new CreateMedicalTypeDto() + medicalTypeDto = await CallAppServiceAsync( + "api/app/MedicalType/GetByDisplayName", new DisplayNameInputDto() { DisplayName = medicalTypeName }); + if (medicalTypeDto == null) { - DisplayName = medicalTypeName, - }; - medicalTypeDto = await CallAppServiceAsync( - "api/app/medical-type", new CreateMedicalTypeDto() { DisplayName = medicalTypeName }); + var createMedicalTypeDto = new CreateMedicalTypeDto() + { + DisplayName = medicalTypeName, + }; + medicalTypeDto = await CallAppServiceAsync( + "api/app/medical-type", new CreateMedicalTypeDto() { DisplayName = medicalTypeName }); + } } - } - //职称 - var jobTitle = ConvertJobTitle(patient.gradeZwV); - //职务 - var jobPost = ConvertJobPost(patient.tjTab1); - string workTypeV = patient.workTypeV; - if (string.IsNullOrWhiteSpace(workTypeV)) - { - workTypeV = ""; - } - else - { - workTypeV = "," + workTypeV; - } - jobPost = jobPost + workTypeV; - jobPost = jobPost.Substring(0, 10);//只能存储10个汉字 - //查找子单位是否存在,如存在获取子单位id,如果不存在这创建子单位 - var orgName = patient.orgName; - var pos = orgName.IndexOf("_"); - orgName = orgName.Substring(0, pos); - if (string.IsNullOrWhiteSpace(patient.mobile)) - { - //青海省第五人民医院要强行设置为 11111111111 - } - var customerOrgDtos = await CallAppServiceAsync>( - "api/app/CustomerOrg/GetChildCustomerOrgsById", - new CustomerOrgIdInputDto() { CustomerOrgId = _importCustomerOrgId }); - CustomerOrgDto customerOrgDto = null; - if (customerOrgDtos != null && customerOrgDtos.Any()) - { - customerOrgDto = customerOrgDtos.Where(o => o.DisplayName == orgName).FirstOrDefault(); - } - if (customerOrgDto == null) - { - customerOrgDto = await CallAppServiceAsync( - "api/app/customerorg/create", new CreateCustomerOrgDto() - { - MedicalCenterId = _importCustomerOrgId, - ParentId = _customerOrgDto.MedicalCenterId, - DisplayName = orgName, - ShortName = orgName, - IsActive = 'Y', - IsLock = 'Y' - }); - } - CustomerOrgGroupDto customerOrgGroupDto; - if (patient.ifFj == 1) - { - //复检 - //加载单位分组信息 - _customerOrgGroupDtos = await CallAppServiceAsync>( - "api/app/customerorgregister/getlistincustomerorgid?CustomerOrgId=" + _importCustomerOrgId.ToString() - , Guid.Empty, "get"); - customerOrgGroupDto = _customerOrgGroupDtos.Where(o => o.DisplayName == "复检").FirstOrDefault(); - if (customerOrgGroupDto == null) + //职称 + var jobTitle = ConvertJobTitle(patient.gradeZwV); + //职务 + var jobPost = ConvertJobPost(patient.tjTab1); + string workTypeV = patient.workTypeV; + if (string.IsNullOrWhiteSpace(workTypeV)) { - throw new Exception("没有复检这个分组"); + workTypeV = ""; } - } - else - { - List groupNames = new List(); - if (patient.ifGy == 1) + else + { + workTypeV = "," + workTypeV; + } + jobPost = jobPost + workTypeV; + if (!string.IsNullOrWhiteSpace(jobPost) && jobPost.Length >= 10) + { + jobPost = jobPost.Substring(0, 10);//只能存储10个汉字 + } + + //查找子单位是否存在,如存在获取子单位id,如果不存在这创建子单位 + var orgName = patient.orgName; + var pos = orgName.IndexOf("_"); + orgName = orgName.Substring(0, pos); + if (string.IsNullOrWhiteSpace(patient.mobile)) + { + //青海省第五人民医院要强行设置为 11111111111 + } + var customerOrgDtos = await CallAppServiceAsync>( + "api/app/CustomerOrg/GetChildCustomerOrgsById", + new CustomerOrgIdInputDto() { CustomerOrgId = _importCustomerOrgId }); + CustomerOrgDto customerOrgDto = null; + if (customerOrgDtos != null && customerOrgDtos.Any()) { - groupNames.Add("高原"); + customerOrgDto = customerOrgDtos.Where(o => o.DisplayName == orgName).FirstOrDefault(); } - else if (patient.ifJk == 1) + if (customerOrgDto == null) { - groupNames.Add("健康"); + customerOrgDto = await CallAppServiceAsync( + "api/app/customerorg/create", new CreateCustomerOrgDto() + { + MedicalCenterId = _customerOrgDto.MedicalCenterId , + ParentId = _importCustomerOrgId, + DisplayName = orgName, + ShortName = orgName, + IsActive = 'Y', + IsLock = 'Y' + }); + } + CustomerOrgGroupDto customerOrgGroupDto; + if (patient.ifFj == 1) + { + //复检 + //加载单位分组信息 + _customerOrgGroupDtos = await CallAppServiceAsync>( + "api/app/customer-org-group/in-customer-org-id/" + _importCustomerOrgId.ToString() + , Guid.Empty, "get"); + customerOrgGroupDto = _customerOrgGroupDtos.Where(o => o.DisplayName == "复检").FirstOrDefault(); + if (customerOrgGroupDto == null) + { + throw new Exception("没有复检这个分组"); + } } else { - throw new Exception("分组名称必须是高原或健康体检二选一"); + List groupNames = new List(); + if (patient.ifGy == 1) + { + groupNames.Add("高原"); + } + else if (patient.ifJk == 1) + { + groupNames.Add("健康"); + } + else + { + throw new Exception("分组名称必须是高原或健康体检二选一"); + } + if (patient.ifGt == 1) + { + groupNames.Add("高铁"); + } + if (patient.ifWh == 1) + { + groupNames.Add("职害"); + } + if (patient.ifCw == 1) + { + groupNames.Add("普速"); + } + if (patient.ifMain == 1) + { + groupNames.Add("行车"); + } + if (patient.ifCy == 1) + { + groupNames.Add("从业"); + } + customerOrgGroupDto = await GetCustomerOrgGroup(groupNames, sexId, maritalStatusId); } - if (patient.ifGt == 1) + //获取病人ID + + var patientRegister = new CreatePatientRegisterDto() { - groupNames.Add("高铁"); + MedicalCenterId = _customerOrgDto.MedicalCenterId, + //PatientRegisterId = null, + //PatientId = null, + IsMaxMedicalTimes = 'Y', + CompleteFlag = '0', + CustomerOrgId = customerOrgDto.Id, + CustomerOrgRegisterId = _customerOrgRegisterDto.Id, + CustomerOrgGroupId = customerOrgGroupDto.Id, + PatientName = patient.personName, + SexId = sexId, + Age = patient.age, + MaritalStatusId = maritalStatusId, + MobileTelephone = patient.mobile, + Planuserid = patient.id.ToString(), + IdNo = patient.cardId, + //PersonnelTypeId = personnelType.Id, + JobTitle = jobTitle, + Remark = patient.remark, + JobPost = jobPost, + Remark2 = patient.tjOpinion, + Remark3 = patient.fjOpinion, + QztlIsFj = patient.ifFj == 1 ? 'Y' : 'N', + QztlIsGt = patient.ifGt == 1 ? 'Y' : 'N', + QztlIsWh = patient.ifWh == 1 ? 'Y' : 'N', + QztlIsCw = patient.ifCw == 1 ? 'Y' : 'N', + QztlIsMain = patient.ifMain == 1 ? 'Y' : 'N', + QztlIsCy = patient.ifCy == 1 ? 'Y' : 'N', + IsQztlImport = 'Y' + }; + + + if (!string.IsNullOrWhiteSpace(patient.cardId)) + { + var patientInfo = await CallAppServiceAsync( + "api/app/patient/GetByIdNo", + new IdNoInputDto() + { + IdNo = patient.cardId + }); + if (patientInfo != null) + { + patientRegister.PatientId = patientInfo.Id; + } + } - if (patient.ifWh == 1) + + if (medicalTypeDto != null) { - groupNames.Add("职害"); + patientRegister.MedicalTypeId = medicalTypeDto.Id; } - if (patient.ifCw == 1) + if (personnelType != null) { - groupNames.Add("普速"); + patientRegister.PersonnelTypeId = personnelType.Id; } - if (patient.ifMain == 1) + if (patient.ifGy == 1) { - groupNames.Add("行车"); + patientRegister.QztlType = '0'; } - if (patient.ifCy == 1) + else if (patient.ifJk == 1) { } { - groupNames.Add("从业"); + patientRegister.QztlType = '1'; } - customerOrgGroupDto = await GetCustomerOrgGroup(groupNames, sexId, maritalStatusId); - } - var patientRegister = new CreatePatientRegisterDto() - { - MedicalCenterId = _customerOrgDto.MedicalCenterId, - //PatientRegisterId = null, - //PatientId = null, - IsMaxMedicalTimes = 'Y', - CompleteFlag = '0', - CustomerOrgId = customerOrgDto.Id, - CustomerOrgGroupId = customerOrgGroupDto.Id, - PatientName = patient.personName, - SexId = sexId, - Age = patient.age, - MaritalStatusId = maritalStatusId, - MobileTelephone = patient.mobile, - Planuserid = patient.id.ToString(), - IdNo = patient.cardId, - PersonnelTypeId = personnelType.Id, - JobTitle = jobTitle, - Remark = patient.remark, - JobPost = jobPost, - Remark2 = patient.tjOpinion, - Remark3 = patient.fjOpinion, - QztlIsFj = patient.ifFj ==1?'Y':'N', - QztlIsGt = patient.ifGt == 1 ? 'Y' : 'N', - QztlIsWh = patient.ifWh == 1 ? 'Y' : 'N', - QztlIsCw = patient.ifCw == 1 ? 'Y' : 'N', - QztlIsMain = patient.ifMain == 1 ? 'Y' : 'N', - QztlIsCy = patient.ifCy == 1 ? 'Y' : 'N', - IsQztlImport = 'Y' - }; - if(medicalTypeDto!=null) - { - patientRegister.MedicalTypeId = medicalTypeDto.Id; - } - if(patient.ifGy == 1) - { - patientRegister.QztlType = '0'; - } - else if(patient.ifJk == 1) { } - { - patientRegister.QztlType = '1'; - } - patientRegister.RegisterCheckAsbitems = new List(); - //获取分组信息 - var customerOrgGroupDetailOrAsbitemDtos = await CallAppServiceAsync>( - "api/app/customerorggroupdetail/getcustomerorggroupdetailinasbitem?CustomerOrgGroupId=" + customerOrgGroupDto.Id.ToString() - , Guid.Empty, "get"); - if(!customerOrgGroupDetailOrAsbitemDtos.Any() ) - { - throw new Exception("分组未包含项目"); - } - foreach(var asbitem in customerOrgGroupDetailOrAsbitemDtos) - { - patientRegister.RegisterCheckAsbitems.Add(new CreatePatientRegisterRegisterCheckAsbitem() + patientRegister.RegisterCheckAsbitems = new List(); + //获取分组信息 + var customerOrgGroupDetailOrAsbitemDtos = await CallAppServiceAsync>( + "api/app/customerorggroupdetail/getcustomerorggroupdetailinasbitem?CustomerOrgGroupId=" + customerOrgGroupDto.Id.ToString() + , Guid.Empty, "get"); + if (!customerOrgGroupDetailOrAsbitemDtos.Any()) { - AsbitemId = asbitem.AsbitemId, - StandardPrice = asbitem.Price, - ChargePrice = asbitem.CustomerOrgGroupDetailPrice, - PayTypeFlag = '1', - IsCharge = 'N', - Amount = asbitem.CustomerOrgGroupDetailAmount - }); + throw new Exception("分组未包含项目"); + } + foreach (var asbitem in customerOrgGroupDetailOrAsbitemDtos) + { + patientRegister.RegisterCheckAsbitems.Add(new CreatePatientRegisterRegisterCheckAsbitem() + { + AsbitemId = asbitem.AsbitemId, + StandardPrice = asbitem.Price, + ChargePrice = asbitem.CustomerOrgGroupDetailPrice, + PayTypeFlag = '1', + IsCharge = 'N', + Amount = asbitem.CustomerOrgGroupDetailAmount + }); + } + await CallAppServiceAsync( + "api/PatientRegister/CreatePatientRegister", + patientRegister); + + var succesIds = new List(); + var deleteIds = new List(); + succesIds.Add(patientRegister.Planuserid); + await NoteOk(succesIds, deleteIds); } - await CallAppServiceAsync>( - "api/PatientRegister/CreatePatientRegister", - patientRegister); } @@ -309,7 +345,7 @@ namespace Shentun.Peis.PlugIns.Gem CustomerOrgId = _importCustomerOrgId, }); //加载人员类别列表 - var _personnelTypes = await CallAppServiceAsync>("api/app/PersonnelType/GetAll", ""); + _personnelTypes = await CallAppServiceAsync>("api/app/PersonnelType/GetAll", ""); } @@ -388,7 +424,7 @@ namespace Shentun.Peis.PlugIns.Gem case 2: return '1'; case 3: - return '3'; + return '4'; default: return '9'; } @@ -503,13 +539,13 @@ namespace Shentun.Peis.PlugIns.Gem } } string maritalStatusName; - if (maritalStatusId == '9' || maritalStatusId == '1') + if (maritalStatusId == '0') { - maritalStatusName = "已婚"; + maritalStatusName = "未婚"; } else { - maritalStatusName = "未婚"; + maritalStatusName = "已婚"; } if (sexName == "女") { @@ -521,7 +557,7 @@ namespace Shentun.Peis.PlugIns.Gem } _customerOrgGroupDtos = await CallAppServiceAsync>( - "api/app/customerorgregister/getlistincustomerorgid?CustomerOrgId=" + _importCustomerOrgId.ToString() + "api/app/customer-org-group/in-customer-org-id/" + _importCustomerOrgId.ToString() , Guid.Empty, "get"); var customerOrgGroup = _customerOrgGroupDtos.Where(o => o.DisplayName == groupName).FirstOrDefault(); if (customerOrgGroup != null) @@ -601,7 +637,7 @@ namespace Shentun.Peis.PlugIns.Gem return; } - if (successIds.Count == 0 || deleteIds.Count == 0) + if (successIds.Count == 0 && deleteIds.Count == 0) { return; } @@ -658,7 +694,10 @@ namespace Shentun.Peis.PlugIns.Gem result = await response.Content.ReadAsStringAsync(); result = result.Replace(":\"[{", ":[{").Replace("}]\"", "}]").Replace("\\", ""); - + if (result.IndexOf("更新ok") >= 0 || result.IndexOf("更新OK") >= 0 || result.IndexOf("更新Ok") >= 0) + { + return; + } dynamic? resultDto = JsonConvert.DeserializeObject(result); if (resultDto != null) { diff --git a/ThirdPlugIns/Shentun.Peis.PlugIns.Gem/test/Shentun.Peis.PlugIns.Gem.Test/appsettings.json b/ThirdPlugIns/Shentun.Peis.PlugIns.Gem/test/Shentun.Peis.PlugIns.Gem.Test/appsettings.json index 5aeac74..e063494 100644 --- a/ThirdPlugIns/Shentun.Peis.PlugIns.Gem/test/Shentun.Peis.PlugIns.Gem.Test/appsettings.json +++ b/ThirdPlugIns/Shentun.Peis.PlugIns.Gem/test/Shentun.Peis.PlugIns.Gem.Test/appsettings.json @@ -8,7 +8,10 @@ "CorsOrigins": "https://*.Peis.com,http://localhost:4200,http://localhost:9530,http://192.168.1.108:9530,http://localhost:8080,http://localhost:8081", "RedirectAllowedUrls": "http://localhost:9530", "Sql": "select id::varchar as Code ,display_name as DisplayName ,simple_code as SimpleCode ,display_order as DisplayOrder from asbitem", - "ColumnNames": "编码,名称" + "ColumnNames": "编码,名称", + "AppUser": "admin", + "AppPassword": "666666" + }, "Interface": { //"DbType": "SqlServer", diff --git a/src/Shentun.ColumnReferencePlugIns/PlugInsBase.cs b/src/Shentun.ColumnReferencePlugIns/PlugInsBase.cs index fa04724..d0e5fee 100644 --- a/src/Shentun.ColumnReferencePlugIns/PlugInsBase.cs +++ b/src/Shentun.ColumnReferencePlugIns/PlugInsBase.cs @@ -2,8 +2,10 @@ using Microsoft.Extensions.Configuration; using Newtonsoft.Json; using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; using Npgsql; using Oracle.ManagedDataAccess.Client; +using Shentun.Peis.PatientRegisters; using Shentun.Utilities; using System; using System.Collections.Generic; @@ -135,7 +137,7 @@ namespace Shentun.Peis.PlugIns httpClient.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue("application/json"));//设置accept标头,告诉JSON是可接受的响应类型 - //httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", _accesToken); + 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); @@ -160,13 +162,23 @@ namespace Shentun.Peis.PlugIns } result = await response.Content.ReadAsStringAsync(); - dynamic resultDto = JsonConvert.DeserializeObject(result); + dynamic resultDto = JsonConvert.DeserializeObject(result); if(resultDto != null) { if(resultDto.code == "-1") { throw new Exception($"调用WebApi失败,返回-1,消息:"+resultDto.message); } + JObject jsonObject = JObject.Parse(result); + var returnStr = jsonObject["data"].ToString(); + if(string.IsNullOrWhiteSpace(returnStr) || returnStr == "null") + { + return default(TOut); + } + + var returnValue = JsonConvert.DeserializeObject(returnStr); + + return returnValue; } return resultDto; } diff --git a/src/Shentun.Peis.Application/CustomerOrgs/CustomerOrgAppService.cs b/src/Shentun.Peis.Application/CustomerOrgs/CustomerOrgAppService.cs index 67d609b..db0f6b5 100644 --- a/src/Shentun.Peis.Application/CustomerOrgs/CustomerOrgAppService.cs +++ b/src/Shentun.Peis.Application/CustomerOrgs/CustomerOrgAppService.cs @@ -66,6 +66,7 @@ namespace Shentun.Peis.CustomerOrgs entityDto.LastModifierName = await _cacheService.GetSurnameAsync(entityDto.LastModifierId); return entityDto; } + //[AllowAnonymous] [HttpPost("api/app/CustomerOrg/GetById")] public async Task GetByIdAsync(CustomerOrgIdInputDto input) { diff --git a/src/Shentun.Peis.Application/Patients/PatientAppService.cs b/src/Shentun.Peis.Application/Patients/PatientAppService.cs index 2626576..93e8771 100644 --- a/src/Shentun.Peis.Application/Patients/PatientAppService.cs +++ b/src/Shentun.Peis.Application/Patients/PatientAppService.cs @@ -17,6 +17,7 @@ using Microsoft.AspNetCore.Authorization; using Volo.Abp; using Microsoft.EntityFrameworkCore; using NUglify.Helpers; +using Volo.Abp.ObjectMapping; namespace Shentun.Peis.Patients { @@ -131,12 +132,13 @@ namespace Shentun.Peis.Patients { throw new UserFriendlyException("身份证号不能为空"); } - var entity = await Repository.FindAsync(o => o.IdNo == idNoInputDto.IdNo.Trim()); - if (entity == null) + var entitys = await Repository.GetListAsync(o => o.IdNo == idNoInputDto.IdNo.Trim()); + + if (entitys == null || !entitys.Any()) { return null; } - var dto = ObjectMapper.Map(entity); + var dto = ObjectMapper.Map(entitys.Last()); return dto; }