diff --git a/src/Shentun.Pacs.Application.Contracts/PacsBusiness/GetPatientRegisterPacsCheckInputDto.cs b/src/Shentun.Pacs.Application.Contracts/PacsBusiness/GetPatientRegisterPacsCheckInputDto.cs index 337c0ff..3e4eeec 100644 --- a/src/Shentun.Pacs.Application.Contracts/PacsBusiness/GetPatientRegisterPacsCheckInputDto.cs +++ b/src/Shentun.Pacs.Application.Contracts/PacsBusiness/GetPatientRegisterPacsCheckInputDto.cs @@ -45,6 +45,11 @@ namespace Shentun.Pacs.PacsBusiness /// public List CustomerOrgIds { get; set; } = new List(); + /// + /// 体检类别id,用于查询健康证 可选参数 查询所有传null值过来 + /// + public Guid? MedicalTypeId { get; set; } + public int MaxResultCount { get; set; } = 1000; public int SkipCount { get; set; } = 0; diff --git a/src/Shentun.Pacs.Application.Contracts/PacsBusiness/ImportPacsDicomServiceDataInputDto.cs b/src/Shentun.Pacs.Application.Contracts/PacsBusiness/ImportPacsDicomServiceDataInputDto.cs index ac125b2..a5406b8 100644 --- a/src/Shentun.Pacs.Application.Contracts/PacsBusiness/ImportPacsDicomServiceDataInputDto.cs +++ b/src/Shentun.Pacs.Application.Contracts/PacsBusiness/ImportPacsDicomServiceDataInputDto.cs @@ -62,5 +62,15 @@ namespace Shentun.Pacs.PacsBusiness /// 是否检查 Y N 默认为Y /// public char IsPacsCheck { get; set; } = 'Y'; + + /// + /// 预检AET + /// + public string ScheduledAet { get; set; } + + /// + /// 设备类型 + /// + public string Modality { get; set; } } } diff --git a/src/Shentun.Pacs.Application/PacsBusiness/PacsBusinessAppService.cs b/src/Shentun.Pacs.Application/PacsBusiness/PacsBusinessAppService.cs index 8528388..3db9eca 100644 --- a/src/Shentun.Pacs.Application/PacsBusiness/PacsBusinessAppService.cs +++ b/src/Shentun.Pacs.Application/PacsBusiness/PacsBusinessAppService.cs @@ -427,7 +427,7 @@ namespace Shentun.Pacs.PacsBusiness return resultDto; } - + /// /// 获取pacs检查项目 pacs看图界面列表 @@ -462,6 +462,7 @@ namespace Shentun.Pacs.PacsBusiness registerCheckId = registerCheck.Id, checkTypeFlag = itemType.CheckTypeFlag, deviceId = patientRegister.DeviceId, + medicalTypeId = patientRegister.MedicalTypeId, encodingFlag = deviceHaveEmpty == null ? '0' : deviceHaveEmpty.EncodingFlag, isFilmRelease = asbitem.IsFilmRelease }; @@ -528,6 +529,11 @@ namespace Shentun.Pacs.PacsBusiness query = query.Where(m => customerOrgIds.Contains(m.customerOrgId)); } + if (input.MedicalTypeId != null) + { + query = query.Where(m => m.medicalTypeId == input.MedicalTypeId); + } + //#region 增加项目类别权限 //string AdminId = _configuration.GetValue("AdminId"); @@ -606,12 +612,8 @@ namespace Shentun.Pacs.PacsBusiness [HttpPost("api/app/PacsBusiness/ImportPacsDicomServiceData")] public async Task ImportPacsDicomServiceDataAsync(ImportPacsDicomServiceDataInputDto input) { - if (string.IsNullOrWhiteSpace(input.CheckRequestNo)) throw new UserFriendlyException("条码号不能为空"); - var registerCheckEnt = await _registerCheckRepository.FirstOrDefaultAsync(f => f.CheckRequestNo == input.CheckRequestNo); - if (registerCheckEnt == null) - throw new UserFriendlyException("条码号不正确"); if (string.IsNullOrWhiteSpace(input.InstanceId)) throw new UserFriendlyException("InstanceId不正确"); @@ -635,38 +637,70 @@ namespace Shentun.Pacs.PacsBusiness throw new UserFriendlyException("文件名称不能为空"); + var query = from patientRegister in await _patientRegisterRepository.GetQueryableAsync() + join registerCheck in await _registerCheckRepository.GetQueryableAsync() on patientRegister.Id equals registerCheck.PatientRegisterId + join device in await _deviceRepository.GetQueryableAsync() on patientRegister.DeviceId equals device.Id + join deviceType in await _deviceTypeRepository.GetQueryableAsync() on device.DeviceTypeId equals deviceType.Id + where registerCheck.CheckRequestNo == input.CheckRequestNo + select new + { + registerCheck, + deviceType + }; + + if (!string.IsNullOrWhiteSpace(input.ScheduledAet)) + { + query = query.Where(m => m.registerCheck.ScheduledAet == input.ScheduledAet); + } + + if (!string.IsNullOrWhiteSpace(input.Modality)) + { + query = query.Where(m => m.deviceType.DisplayName == input.Modality || m.deviceType.Alias.Contains(input.Modality)); + } + + var queryList = query.Select(s => s.registerCheck).ToList(); + + if (!queryList.Any()) + throw new UserFriendlyException("条码号不正确"); + + var dicomFileDetailEnt = await _dicomFileDetailRepository.FirstOrDefaultAsync(f => f.InstanceId == input.InstanceId); if (dicomFileDetailEnt == null) { - dicomFileDetailEnt = new DicomFileDetail + foreach (var item in queryList) { - DisplayOrder = 1, - RegisterCheckId = registerCheckEnt.Id, - FileName = input.FileName, - InstanceId = input.InstanceId, - ParentPatientId = input.ParentPatientId, - ParentSeriesId = input.ParentSeriesId, - ParentStudyId = input.ParentStudyId, - Path = input.Path, - Status = input.Status - }; - await _dicomFileDetailRepository.InsertAsync(dicomFileDetailEnt); + dicomFileDetailEnt = new DicomFileDetail + { + DisplayOrder = queryList.IndexOf(item) + 1, + RegisterCheckId = item.Id, + FileName = input.FileName, + InstanceId = input.InstanceId, + ParentPatientId = input.ParentPatientId, + ParentSeriesId = input.ParentSeriesId, + ParentStudyId = input.ParentStudyId, + Path = input.Path, + Status = input.Status + }; + await _dicomFileDetailRepository.InsertAsync(dicomFileDetailEnt); + } } - if (registerCheckEnt.IsPacsCheck != 'Y') + foreach (var item in queryList) { - registerCheckEnt.IsPacsCheck = input.IsPacsCheck; - registerCheckEnt.PacsCheckDate = Convert.ToDateTime(input.PacsCheckDate); - registerCheckEnt.PacsUploadDate = Convert.ToDateTime(input.PacsUploadDate); + if (item.IsPacsCheck != 'Y') + { + item.IsPacsCheck = input.IsPacsCheck; + item.PacsCheckDate = Convert.ToDateTime(input.PacsCheckDate); + // item.PacsUploadDate = Convert.ToDateTime(input.PacsUploadDate); + item.PacsUploadDate = DateTime.Now; - await _registerCheckRepository.UpdateAsync(registerCheckEnt); + await _registerCheckRepository.UpdateAsync(item); + } } - - } /// - /// 查询人员的dicom数据 000 + /// 查询人员的dicom数据 /// /// /// @@ -707,7 +741,7 @@ namespace Shentun.Pacs.PacsBusiness } /// - /// 删除体检dicom服务数据,并清理dicom服务记录 000 + /// 删除体检dicom服务数据,并清理dicom服务记录 /// /// /// @@ -723,9 +757,12 @@ namespace Shentun.Pacs.PacsBusiness { throw new UserFriendlyException("请配置pacs相关信息"); } - string parentPatientId = dicomFileDetailList.First().ParentPatientId; + //string parentPatientId = dicomFileDetailList.First().ParentPatientId; + string parentStudyId = dicomFileDetailList.First().ParentStudyId; + + //await CallPacsDicomServiceAsync($"{baseApiUrl}/patients/{parentPatientId}", authString, "delete"); - await CallPacsDicomServiceAsync($"{baseApiUrl}/patients/{parentPatientId}", authString, "delete"); + await CallPacsDicomServiceAsync($"{baseApiUrl}/studies/{parentStudyId}", authString, "delete"); await _dicomFileDetailRepository.DeleteManyAsync(dicomFileDetailList); @@ -743,7 +780,7 @@ namespace Shentun.Pacs.PacsBusiness /// - /// 获取dicom文件的数量 根据检查条码号或者实例ID查询 000 + /// 获取dicom文件的数量 根据检查条码号或者实例ID查询 /// /// /// @@ -1229,7 +1266,7 @@ namespace Shentun.Pacs.PacsBusiness if (input.BarcodeMode == '0') { registerAsbitemSql = "select a.name as patient_name,a.sex_id,a.mobile_telephone,a.telephone," + - "a.age,a.id_card_no,a.marital_status_id,a.complete_flag,a.birth_date," + + "a.age,a.id_card_no,a.marital_status_id,a.complete_flag,a.birth_date,a.medical_type_id," + "b.patient_register_id,b.print_barcode_no,b.asbitem_id,b.price,b.standard_price,b.charge_flag,b.payment_mode " + "from patient_register as a left join register_asbitem as b on a.patient_register_id=b.patient_register_id " + " left join asbitem as c on b.asbitem_id=c.asbitem_id " + @@ -1239,7 +1276,7 @@ namespace Shentun.Pacs.PacsBusiness { registerAsbitemSql = "select a.name as patient_name,a.sex_id,a.mobile_telephone,a.telephone," + - "a.age,a.id_card_no,a.marital_status_id,a.complete_flag,a.birth_date," + + "a.age,a.id_card_no,a.marital_status_id,a.complete_flag,a.birth_date,a.medical_type_id," + "b.patient_register_id,b.print_barcode_no,b.asbitem_id,b.price,b.standard_price,b.charge_flag,b.payment_mode " + "from patient_register as a left join register_asbitem as b on a.patient_register_id=b.patient_register_id " + " left join asbitem as c on b.asbitem_id=c.asbitem_id " + @@ -1268,6 +1305,20 @@ namespace Shentun.Pacs.PacsBusiness }).ToList(); + #region 转换体检类别 + Guid? newMedicalTypeId = null; + + string oldMedicalTypeId = oldRegisterAsbitemList.Rows[0]["medical_type_id"].ToString(); + + Guid medicalTypeColumnReferenId = Guid.Parse(_configuration.GetValue("OldPeis:MedicalTypeColumnReferenId", Guid.Empty.ToString())); + + var medicalTypeCodeValues = await _columnReferenceCodeManager.GetColumnReferenCodeValueAsync(medicalTypeColumnReferenId, oldMedicalTypeId); + if (medicalTypeCodeValues.Any()) + { + newMedicalTypeId = Guid.Parse(medicalTypeCodeValues.First()); + } + #endregion + #region 处理人员信息 if (registerCheckList.Count > 0) { @@ -1275,9 +1326,13 @@ namespace Shentun.Pacs.PacsBusiness //更新之前登记的人员信息中的仪器id var fisrtPatientRegister = registerCheckList.Select(s => s.patientRegister).First(); fisrtPatientRegister.DeviceId = Guid.Parse(input.DeviceId); - + if (fisrtPatientRegister.MedicalTypeId != newMedicalTypeId) + { + fisrtPatientRegister.MedicalTypeId = newMedicalTypeId; + } await _patientRegisterRepository.UpdateAsync(fisrtPatientRegister); + tempPatientRegisterId = fisrtPatientRegister.Id; } else { @@ -1395,7 +1450,8 @@ namespace Shentun.Pacs.PacsBusiness PatientRegisterNo = await _patientRegisterManager.CreatePatientRegisterNo(Guid.Empty), SendFlag = '0', SexId = sexId, - BirthDate = newBirthDate + BirthDate = newBirthDate, + MedicalTypeId = newMedicalTypeId }; patientRegisterEnt = await _patientRegisterRepository.InsertAsync(patientRegisterEnt, true); diff --git a/src/Shentun.Pacs.HttpApi.Host/appsettings.json b/src/Shentun.Pacs.HttpApi.Host/appsettings.json index afc7110..81a65a1 100644 --- a/src/Shentun.Pacs.HttpApi.Host/appsettings.json +++ b/src/Shentun.Pacs.HttpApi.Host/appsettings.json @@ -68,6 +68,7 @@ "ItemColumnReferenId": "", "DeviceTypeColumnReferenId": "", "DeviceColumnReferenId": "", + "MedicalTypeColumnReferenId": "", "ShareAddress": "\\192.168.0.188" } } \ No newline at end of file