diff --git a/IRaCIS.Core.API/Controllers/ExtraController.cs b/IRaCIS.Core.API/Controllers/ExtraController.cs index de3d78b2c..a7e0c5e45 100644 --- a/IRaCIS.Core.API/Controllers/ExtraController.cs +++ b/IRaCIS.Core.API/Controllers/ExtraController.cs @@ -35,50 +35,7 @@ namespace IRaCIS.Api.Controllers { - /// - /// 获取医生详情 - /// - /// - /// - /// - /// - /// - /// - /// - /// - [HttpGet, Route("doctor/getDetail/{doctorId:guid}")] - - public async Task> GetDoctorDetail([FromServices] IAttachmentService attachmentService, [FromServices] IDoctorService _doctorService, - [FromServices] IEducationService _educationService, [FromServices] ITrialExperienceService _trialExperienceService, - [FromServices] IResearchPublicationService _researchPublicationService, [FromServices] IVacationService _vacationService, Guid doctorId) - { - var education = await _educationService.GetEducation(doctorId); - - var sowList = _doctorService.GetDoctorSowList(doctorId); - var ackSowList = _doctorService.GetDoctorAckSowList(doctorId); - - var doctorDetail = new DoctorDetailDTO - { - AuditView =await _doctorService.GetAuditState(doctorId), - BasicInfoView = await _doctorService.GetBasicInfo(doctorId), - EmploymentView = await _doctorService.GetEmploymentInfo(doctorId), - AttachmentList = await attachmentService.GetAttachments(doctorId), - - EducationList = education.EducationList, - PostgraduateList = education.PostgraduateList, - - TrialExperienceView = await _trialExperienceService.GetTrialExperience(doctorId), - ResearchPublicationView = await _researchPublicationService.GetResearchPublication(doctorId), - - SpecialtyView =await _doctorService.GetSpecialtyInfo(doctorId), - InHoliday = (await _vacationService.OnVacation(doctorId)).IsSuccess, - IntoGroupInfo = _doctorService.GetDoctorIntoGroupInfo(doctorId), - SowList = sowList, - AckSowList = ackSowList - }; - - return ResponseOutput.Ok(doctorDetail); - } + diff --git a/IRaCIS.Core.API/Controllers/FinancialChangeController.cs b/IRaCIS.Core.API/Controllers/FinancialChangeController.cs index 0b3b13468..f67228b2b 100644 --- a/IRaCIS.Core.API/Controllers/FinancialChangeController.cs +++ b/IRaCIS.Core.API/Controllers/FinancialChangeController.cs @@ -22,14 +22,14 @@ namespace IRaCIS.Core.API.Controllers.Special public class FinancialChangeController : ControllerBase { private readonly ITrialService _trialService; - private readonly ICalculateService _calculateService; + private IStringLocalizer _localizer { get; set; } - public FinancialChangeController(ITrialService trialService, ICalculateService calculateService, IStringLocalizer localizer + public FinancialChangeController(ITrialService trialService, IStringLocalizer localizer ) { _localizer = localizer; _trialService = trialService; - _calculateService = calculateService; + } @@ -60,268 +60,28 @@ namespace IRaCIS.Core.API.Controllers.Special var userId = Guid.Parse(User.FindFirst("id").Value); var result = await _trialService.AddOrUpdateTrial(param); - if (_trialService.TrialExpeditedChange) - { - var needCalReviewerIds = await _trialService.GetTrialEnrollmentReviewerIds(param.Id.Value); - var calcList = await _calculateService.GetNeedCalculateReviewerList(Guid.Empty, string.Empty); - - calcList.ForEach(t => - { - if (needCalReviewerIds.Contains(t.DoctorId)) - { - _calculateService.CalculateMonthlyPayment(new CalculateDoctorAndMonthDTO() - { - NeedCalculateReviewers = new List() - { - t.DoctorId - }, - CalculateMonth = DateTime.Parse(t.YearMonth) - }, User.FindFirst("id").Value); - - } - }); - } return result; } - /// - /// 添加或更新工作量[AUTH] - /// - /// - /// - /// - - [HttpPost, Route("doctorWorkload/workLoadAddOrUpdate")] - [TypeFilter(typeof(TrialResourceFilter),Arguments = new object[] { "AfterStopCannNotOpt" })] - public async Task WorkLoadAddOrUpdate([FromServices] IDoctorWorkloadService _trialWorkloadService, WorkloadCommand workLoadAddOrUpdateModel) - { - var userId = Guid.Parse(User.FindFirst("id").Value); - var result = await _trialWorkloadService.AddOrUpdateWorkload(workLoadAddOrUpdateModel, userId); - if (result.IsSuccess && workLoadAddOrUpdateModel.DataFrom == 2) - { - await _calculateService.CalculateMonthlyPayment(new CalculateDoctorAndMonthDTO() - { - NeedCalculateReviewers = new List() - { - workLoadAddOrUpdateModel.DoctorId - }, - CalculateMonth = workLoadAddOrUpdateModel.WorkTime - }, User.FindFirst("id").Value); - } - return result; - } + - - [HttpDelete, Route("doctorWorkload/deleteWorkLoad/{id:guid}/{trialId:guid}")] - [TypeFilter(typeof(TrialResourceFilter),Arguments = new object[] { "AfterStopCannNotOpt" })] - public async Task DeleteWorkLoad([FromServices] IDoctorWorkloadService _trialWorkloadService, Guid id) - { - //先判断该工作量的费用是否被锁定,如果被锁定,则不能删除 - var workload = await _trialWorkloadService.GetWorkloadDetailById(id); - var yearMonth = workload.WorkTime.ToString("yyyy-MM"); - var isLock = await _calculateService.IsLock(workload.DoctorId, yearMonth); - - if (isLock) - { - //---Expenses have been settled and workload can not be reset. - return ResponseOutput.NotOk(_localizer["Financial_ChargeSettled"]); - } - - var deleteResult = await _trialWorkloadService.DeleteWorkload(id); - if (workload.DataFrom == (int)Domain.Share.WorkLoadFromStatus.FinalConfirm) - { - await _calculateService.CalculateMonthlyPayment(new CalculateDoctorAndMonthDTO() - { - NeedCalculateReviewers = new List() - { - workload.DoctorId - }, - CalculateMonth = workload.WorkTime - }, User.FindFirst("id").Value); - } - return deleteResult; - } - - - /// - /// 添加或更新汇率(会触发没有对锁定的费用计算) - /// - - [HttpPost, Route("exchangeRate/addOrUpdateExchangeRate")] - public async Task AddOrUpdateExchangeRate([FromServices] IExchangeRateService _exchangeRateService, [FromServices] IPaymentAdjustmentService _costAdjustmentService, ExchangeRateCommand addOrUpdateModel) - { - var result = await _exchangeRateService.AddOrUpdateExchangeRate(addOrUpdateModel); - var calcList = await _calculateService.GetNeedCalculateReviewerList(Guid.Empty, addOrUpdateModel.YearMonth); - foreach (var item in calcList) - { - if (item != null) - { - await _calculateService.CalculateMonthlyPayment(new CalculateDoctorAndMonthDTO() - { - NeedCalculateReviewers = new List() - { - item.DoctorId - }, - CalculateMonth = DateTime.Parse(item.YearMonth) - }, User.FindFirst("id").Value); - } - } - await _costAdjustmentService.CalculateCNY(addOrUpdateModel.YearMonth, addOrUpdateModel.Rate); - return result; - } - - - /// - /// 添加或更新 职称单价[AUTH] - /// - - [HttpPost, Route("rankPrice/addOrUpdateRankPrice")] - public async Task AddOrUpdateRankPrice([FromServices] IReviewerPayInfoService _reviewerPayInfoService, [FromServices] IRankPriceService _rankPriceService, RankPriceCommand addOrUpdateModel) - { - if (addOrUpdateModel.Id != Guid.Empty && addOrUpdateModel.Id != null) - { - var needCalReviewerIds =await _reviewerPayInfoService.GetReviewerIdByRankId(Guid.Parse(addOrUpdateModel.Id.ToString())); - var calcList = await _calculateService.GetNeedCalculateReviewerList(Guid.Empty, string.Empty); - - foreach (var item in calcList) - { - if (item != null && needCalReviewerIds.Contains(item.DoctorId)) - { - await _calculateService.CalculateMonthlyPayment(new CalculateDoctorAndMonthDTO() - { - NeedCalculateReviewers = new List() - { - item.DoctorId - }, - CalculateMonth = DateTime.Parse(item.YearMonth) - }, User.FindFirst("id").Value); - } - } - } - var userId = Guid.Parse(User.FindFirst("id").Value); - return await _rankPriceService.AddOrUpdateRankPrice(addOrUpdateModel, userId); - } + - /// - /// 添加或更新(替换)医生支付展信息[AUTH] - /// - - [HttpPost, Route("reviewerPayInfo/addOrUpdateReviewerPayInfo")] - public async Task AddOrUpdateReviewerPayInfo([FromServices] IReviewerPayInfoService _doctorPayInfoService, ReviewerPayInfoCommand addOrUpdateModel) - { - var userId = Guid.Parse(User.FindFirst("id").Value); - var result =await _doctorPayInfoService.AddOrUpdateReviewerPayInfo(addOrUpdateModel, userId); - var calcList = await _calculateService.GetNeedCalculateReviewerList(addOrUpdateModel.DoctorId, string.Empty); - foreach (var item in calcList) - { - if (item != null) - { - await _calculateService.CalculateMonthlyPayment(new CalculateDoctorAndMonthDTO() - { - NeedCalculateReviewers = new List() - { - item.DoctorId - }, - CalculateMonth = DateTime.Parse(item.YearMonth) - }, User.FindFirst("id").Value); - } - } - return result; - } + - /// - /// 保存(替换)项目支付价格信息(会触发没有被锁定的费用计算)[AUTH] - /// - - [HttpPost, Route("trialPaymentPrice/addOrUpdateTrialPaymentPrice")] - public async Task AddOrUpdateTrialPaymentPrice([FromServices] ITrialPaymentPriceService _trialPaymentPriceService, TrialPaymentPriceCommand addOrUpdateModel) - { - var userId = Guid.Parse(User.FindFirst("id").Value); - var result =await _trialPaymentPriceService.AddOrUpdateTrialPaymentPrice(addOrUpdateModel); - var needCalReviewerIds = await _trialService.GetTrialEnrollmentReviewerIds(addOrUpdateModel.TrialId); - var calcList = await _calculateService.GetNeedCalculateReviewerList(Guid.Empty, string.Empty); + - foreach (var item in calcList) - { - if (item != null && needCalReviewerIds.Contains(item.DoctorId)) - { - await _calculateService.CalculateMonthlyPayment(new CalculateDoctorAndMonthDTO() - { - NeedCalculateReviewers = new List() - { - item.DoctorId - }, - CalculateMonth = DateTime.Parse(item.YearMonth) - }, User.FindFirst("id").Value); - } - } - return result; - } - - /// - /// 批量更新奖励费用[AUTH] - /// - - [HttpPost, Route("volumeReward/addOrUpdatevolumeRewardPriceList")] - public async Task AddOrUpdateAwardPriceList([FromServices] IVolumeRewardService _volumeRewardService, IEnumerable addOrUpdateModel) - { - - var result =await _volumeRewardService.AddOrUpdateVolumeRewardPriceList(addOrUpdateModel); - - var calcList = await _calculateService.GetNeedCalculateReviewerList(Guid.Empty, string.Empty); - foreach (var item in calcList) - { - if (item != null) - { - await _calculateService.CalculateMonthlyPayment(new CalculateDoctorAndMonthDTO() - { - NeedCalculateReviewers = new List() - { - item.DoctorId - }, - CalculateMonth = DateTime.Parse(item.YearMonth) - }, User.FindFirst("id").Value); - } - } - return result; - } + - - /// - /// 计算医生月度费用,并将计算的结果存入费用表 - /// - [HttpPost, Route("financial/calculateMonthlyPayment")] - public async Task CalculateMonthlyPayment(CalculateDoctorAndMonthDTO param) - { - if (!ModelState.IsValid) - { - //---Invalid parameter. - return ResponseOutput.NotOk(_localizer["Financial_InvalidParameter"]); - } - return await _calculateService.CalculateMonthlyPayment(param, User.FindFirst("id").Value); - } - - /// - /// Financials /Monthly Payment 列表查询接口 - /// - [HttpPost, Route("financial/getMonthlyPaymentList")] - public async Task> GetMonthlyPaymentList([FromServices] IPaymentService _paymentService, [FromServices] IExchangeRateService _exchangeRateService, MonthlyPaymentQueryDTO queryParam) - { - return ResponseOutput.Ok(new PaymentDTO - { - CostList = await _paymentService.GetMonthlyPaymentList(queryParam), - ExchangeRate = await _exchangeRateService.GetExchangeRateByMonth(queryParam.StatisticsDate.ToString("yyyy-MM")) - }); - } - + } } diff --git a/IRaCIS.Core.API/Controllers/UploadDownLoadController.cs b/IRaCIS.Core.API/Controllers/UploadDownLoadController.cs index b3e4cde44..66580badf 100644 --- a/IRaCIS.Core.API/Controllers/UploadDownLoadController.cs +++ b/IRaCIS.Core.API/Controllers/UploadDownLoadController.cs @@ -993,73 +993,8 @@ namespace IRaCIS.Core.API.Controllers } - /// - /// 下载多个医生的所有附件 - /// - /// - /// - [HttpPost, Route("file/downloadDoctorAttachments")] - public async Task> DownloadAttachment(Guid[] doctorIds) - { - - var path = await _fileService.CreateDoctorsAllAttachmentZip(doctorIds); - - return ResponseOutput.Ok(new UploadFileInfoDTO - { - FilePath = path, - FullFilePath = path + "?access_token=" + HttpContext.Request.Headers["Authorization"].ToString().Substring(7) - - }); - } - - /// - /// 下载医生官方简历 - /// - /// - /// - /// - [HttpPost, Route("file/downloadOfficialCV/{language}")] - public async Task> DownloadOfficialResume(int language, Guid[] doctorIds) - { - - var path = await _fileService.CreateDoctorsAllAttachmentZip(doctorIds); - return ResponseOutput.Ok(new UploadFileInfoDTO - { - FilePath = await _fileService.CreateOfficialResumeZip(language, doctorIds), - FullFilePath = path + "?access_token=" + HttpContext.Request.Headers["Authorization"].ToString().Substring(7) - }); - } - - /// - /// 下载指定医生的指定附件 - /// - /// 医生Id - /// 要下载的附件Id - /// - [HttpPost, Route("file/downloadByAttachmentId/{doctorId}")] - public async Task> DownloadAttachmentById(Guid doctorId, Guid[] attachmentIds) - { - var path = await _fileService.CreateZipPackageByAttachment(doctorId, attachmentIds); - return ResponseOutput.Ok(new UploadFileInfoDTO - { - FilePath = await _fileService.CreateZipPackageByAttachment(doctorId, attachmentIds), - FullFilePath = path + "?access_token=" + HttpContext.Request.Headers["Authorization"].ToString().Substring(7) - }); - } - - - - - [HttpPost, Route("enroll/downloadResume/{trialId:guid}/{language}")] - [TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })] - [AllowAnonymous] - public async Task> DownloadResume(int language, Guid trialId, Guid[] doctorIdArray) - { - var zipPath = await _fileService.CreateOfficialResumeZip(language, doctorIdArray); - - return ResponseOutput.Ok(zipPath); - } + } #endregion diff --git a/IRaCIS.Core.API/IRaCIS.Core.API.xml b/IRaCIS.Core.API/IRaCIS.Core.API.xml index ed6960728..fc2558ece 100644 --- a/IRaCIS.Core.API/IRaCIS.Core.API.xml +++ b/IRaCIS.Core.API/IRaCIS.Core.API.xml @@ -16,19 +16,6 @@ 医生基本信息 、工作信息 专业信息、审核状态 - - - 获取医生详情 - - - - - - - - - - 系统用户登录接口[New] @@ -41,49 +28,6 @@ 新记录Id - - - 添加或更新工作量[AUTH] - - - - - - - - 添加或更新汇率(会触发没有对锁定的费用计算) - - - - - 添加或更新 职称单价[AUTH] - - - - - 添加或更新(替换)医生支付展信息[AUTH] - - - - - 保存(替换)项目支付价格信息(会触发没有被锁定的费用计算)[AUTH] - - - - - 批量更新奖励费用[AUTH] - - - - - 计算医生月度费用,并将计算的结果存入费用表 - - - - - Financials /Monthly Payment 列表查询接口 - - 获取稽查数据 @@ -359,29 +303,6 @@ 文件类型 - - - 下载多个医生的所有附件 - - - - - - - 下载医生官方简历 - - - - - - - - 下载指定医生的指定附件 - - 医生Id - 要下载的附件Id - - 缩略图 diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml index e9489d018..4297d274b 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml @@ -85,105 +85,6 @@ - - - 替换表格Key - - - - - - - - 分配规则 - - - - - 获取计划列表 医生带阅片类型 - - - - - - - 获取项目下 医生账户信息下拉 - - - - - - - - 获取访视任务 应用Subject后 医生比率情况 - - - - - - 一致性分析配置表 - - - - - 设置一致性分析任务失效 - - - - - - - 一致性分析列表 (自身 组内 最后勾选 产生的任务) - - - - - - - 为自身一致性分析医生,选择Subejct 列表 - - - - - - - 确认生成自身一致性分析任务 - - - - - - - - 组间一致性分析 选择Subejct 列表 - - - - - - - 确认生成组间一致性分析任务 - - - - - - - - 仅仅自身一致性时使用( - - - - - - - - - 自身一致性分配 配置+ 统计已经生成数量统计表 - - - - 医学审核生成规则 废弃 @@ -280,74 +181,11 @@ - + - Subject 任务类型 统计 +分配情况 - - - - - - 一次性分配所有医生 批量分配(添加),后端现在没限制 - - - - - - - 阅片人维度 Subject统计表 + 获取项目下 阅片人下拉 - - - - - - 获取Subject 分配医生情况 - - - - - - - - 取消Subject 分配的医生 - - - - - - - - 任务 手动分配 重新分配 确认 取消分配 - 分配 - - - - - - 获取手动分配 未分配的Subject列表(IsHaveAssigned 传递false) - - - - - - 批量为 多个Subject 分配医生 手动分配 IsReAssign 为true 批量删除 重新分配 - - - - - - - 批量取消Subject 分配的医生 - - 数量 - - - - 手动分配确认 绑定该Subject的已存在的任务给医生 - - @@ -358,11 +196,25 @@ - + + + new- 首次审核 后续编辑审核 + + + + + + + new- 回复审核内容 + + + + + - 裁判任务 + new- 获取审核对话列表 - + @@ -441,12 +293,6 @@ - - - 基线退回 影响附加评估标准 是否参与评估 - - - 影响提示列表 重阅仅仅针对已完成的任务申请 退回针对的是未完成的(退回仅仅针对是访视类型的) @@ -1148,11 +994,6 @@ 获取登陆用户的系统通知列表 只是过滤了用户类型 和已经发布的 - - - UserLogService - - 验证CRC 是否已提交 已提交 就不允许进行任何操作,如果是IQC 那么还验证是否是当前任务领取人 @@ -2423,77 +2264,6 @@ - - - SubjectCriteriaEvaluationService - - - - - subject 某标准 是否评估列表 - - - - - - - 添加 编辑 是否参与评估 - - - - - - - 自动访视筛选 (针对单一访视,重新筛选一遍,可能不存在该接口,仅仅留存) - - - - - - 评估访视筛选列表(一致性核查通过的访视都会出现 根据条件筛选) - - - - - - - 已生成任务列表 - - - - - - - 批量勾选 生成该标准的任务 - - - - - - 获取dicom 访视检查列表 (序列的 Id CreateTime 是否为空 代表了记录是否创建、IsConfirmed 代表 保存 确认) - - - - - - 批量保存或者确认 选择的序列 - - - - - - 附加评估标准 PM 退回某一访视 影响任务列表 - - - - - - - 退回任务 - - - - 临床答案 @@ -8073,16 +7843,6 @@ 完成阅片量 - - - 未完成裁判任务数量 - - - - - 完成裁判任务数量 - - 建议完成时间 @@ -8320,9 +8080,6 @@ UserLogQuery 列表查询参数模型 - - UserLogAddOrEdit 列表查询参数模型 - 靶病灶是否为IUPD或者ICPD @@ -8603,12 +8360,6 @@ SubjectCriteriaEvaluationAddOrEdit 列表查询参数模型 - - SubjectCriteriaEvaluationVisitFilterView 列表视图模型 - - - SubjectCriteriaEvaluationVisitFilterQuery 列表查询参数模型 - SubjectCriteriaEvaluationVisitFilterAddOrEdit 列表查询参数模型 @@ -9156,11 +8907,6 @@ IUserLogService - - - ISubjectCriteriaEvaluationService - - IClinicalQuestionService @@ -10352,11 +10098,6 @@ - - - Financial---项目收入价格验证 - - 指定资源Id,获取Dicom序列所属的实例信息列表 Dicom序列的Id @@ -10796,15 +10537,6 @@ - - - PM 阅片人筛选 -- PM APM 待办 - - - - - vvv - 获取PM核对临床数据 @@ -10812,16 +10544,7 @@ - - - SPM 阅片人筛选 - - - - - vvv - - + SPM 重阅审批 @@ -10912,7 +10635,7 @@ - + MIM医学反馈 @@ -11309,21 +11032,6 @@ - - - 打包医生官方简历 - - - - - - - - 打包医生的所有附件 - - - - 发送验证码 @@ -11332,372 +11040,6 @@ - - - 医生文档关联关系维护 - - - - - 删除附件 - - - - - - - 根据医生Id 和 附件类型,获取记录 - - 医生Id - 附件类型 - - - - - 获取单个医生的多种证书附件 - - 医生Id - 类型数组 - - - - - 根据医生Id获取医生附件 - - 医生Id - - - - - 保存多个附件 - - - - - - - 将简历设置为官方简历 - - - - - - - - - 设置简历的语言类型 - - - - 0-未设置,1-中文,2-英文 - - - - - Reviewer列表分页查询 - - - - - 获取可筛选筛选及已经筛选的医生列表 - - - - - 获取提交CRO或者CRO审核的Reviewer列表 - - - 根据状态获取医生列表,入组 相关接口 (提交CRO-1) CRO确认-4 - - - - - 获取项目下医生入组状态列表[Confirmation] - - - - - 添加/更新 医生基本信息 BasicInfo - - - - - 详情、编辑-获取 医生基本信息 BasicInfo - - ReviewerID - - - - - 详情、编辑-获取医生工作信息 Employment - - - - - 添加修改医生标准文件 - - - - - - - 删除医生标准文件 - - - - - - - 获取医生标准文件 - - - - - - - 获取医生入组信息 正在提交的数量 已同意入组项目个数 正在读的 - - - - - Get Statement of Work list.[New] - - - - - Get Ack Statement of Work[New] - - - - - 根据医生Id获取医生教育经历和继续学习经历列表 - - - - - 新增医生教育经历 - - - - - - 添加/更新医生继续学习经历 - - - - 删除医生继续学习经历 - - 医生Id - - - - - 查询-医生科学研究信息 - - 医生Id - - - - - 根据医生Id,获取临床试验经历 界面所有数据 - - - - 添加或更新医生临床经验列表项 - - - - 删除临床经验 - - - - - 更新-GCP和其他临床经验 - - - - - - - 更新其他技能经验 - - - - - 添加休假时间段 - - Status不传 - - - - - 删除休假时间段 - - 记录Id - - - - - 获取休假时间段列表 - - - - - - 获取某个月下的某些医生最终确认的工作量,用于计算月度费用 - - - - - 计算月度费用,并调用AddOrUpdateMonthlyPayment和AddOrUpdateMonthlyPaymentDetail方法, - 将费用计算的月度数据及详情保存 - - - - - 保存费用计算的月度数据 - - - - - 保存费用计算的月度详情 - - - - - 获取待计算费用的Reviewer对应的月份列表 - - - - - 查询Reviewer某个月的费用是否被锁定 - - - - - 根据记录Id,删除汇率记录 - - 汇率记录Id - - - - Financials /MonthlyPayment 列表查询接口 - - - - - Financials /MonthlyPaymentDetail 详情查询接口 - - - - - NEW 导出Excel压缩包 数据获取 - - - - - Financials / Payment History 列表查询接口(已经支付锁定的数据,包含调整的)[New] - - - - - Financials / Payment History 详情接口[New] - - - - - Revenues列表接口,收入统计[New] 0是Detail 1是按照项目 2是按照人 3按照月份 - - - - - 收入支出分析接口,按照项目维度分析统计 - - - - - 收入支出分析接口,按照医生维度分析统计 - - - - - 获取劳务费用列表 - - - - - 锁定医生费用,锁定后,无法变更该医生对应月份的费用和工作量[New] - - - - - 添加或更新费用调整[AUTH] - - - - - 删除费用调整记录 - - - - - 获取费用调整列表 - - - - - 获取职称单价列表 - - - - - 获取医生支付信息列表 - - - - - 根据医生Id获取支付信息 - - 医生Id - - - - - 根据rankId 获取ReviewerId,用于当Rank的单价信息改变时,触发费用计算 - - - - - - - 添加或更新项目支付价格信息 - - - - - 获取项目支付价格信息列表 - - - - - 获取项目收入费用信息列表[New] - - - - - 批量添加或更新奖励费用单价 - - - - - 获取所有奖励单价列表-用于计算时,一次性获取所有 - - - - - 分页获取奖励单价列表 - - 分页获取CRO列表 @@ -12793,39 +12135,12 @@ Dashboard统计、全局工作量统计、入组两个维度统计(按照项目、按照人) - - 根据项目和医生,分页获取工作量统计[New] - - - 项目入组 医生维度统计[New] - 用户参与项目 统计[New] 用户参与项目 列表[New] - - 读片数分类统计[New] - - - 获取最近几个月份的数据[New] - - - 读片数量排行前几的数据[New] - - - 按Rank统计Reviewer 数量[New] - - - 最近几个季度入组人次[New] type==0 按照月份 - - - 参与项目数排行 [New] - - - 最新工作量 (已确定的)[New] - Setting页面 获取项目参与人员列表 @@ -12874,23 +12189,6 @@ 真删除项目 方便清理测试数据 临床试验项目Id - - - 根据项目Id 获取医生Id,用于触发计算费用 - - - - 分页获取医生参与的临床实验项目列表(查询条件) - - - - - 医生确认入组或拒绝入组 - - 项目Id - 9-拒绝入组,10-确认入组 - - 添加或更新受试者信息[New] @@ -12927,107 +12225,6 @@ 删除项目计划某一项 废弃 - - - 修改项目医生的阅片类型 - - - - - - - 修改项目医生启用禁用状态 - - - - - - - 0代表裁判和Tp 都可以 1、代表Tp 2 代表裁判 - - - - - - 获取某个项目入组的医生工作量统计列表 - - - - - 获取入组某个项目的医生的最近几个月的工作量详情(带有填充数据) - - - - - 获取来自Reviewer自己的数据,某个月添加的多条 - - - - - 工作量是否存在,用于判断只能添加一条的工作量记录 - - - 查询某个医生是否在某天有某个项目的工作量数据,处理添加来自医生自己的工作量数据 - - - - - 添加或更新工作量 - - - - - 删除工作量 - - - - - 获取工作量详情(用于判断工作量锁定时,调用) - - - - - 添加或更新项目医生项目价格 - - - - - 获取医生项目列表 - - - - - - 为项目筛选医生 提交 【select】 - 项目Id - 医生Id数组 - - - - - 入组流程-向CRO提交医生[Submit] - - - - - 入组流程-CRO确定医生名单 [ Approve] - - - - - 入组流程-后台确认医生入组[Confirm] - - - - - optType 0表示入组,列表没这条数据了, 1表示出组,需要填写出组时间 废弃 - - - - - - - 维护临床数据 --一定要在同步表前同步数据才行 @@ -13224,123 +12421,8 @@ - - - 医生多条件查询 - - - - - 筛选医生列表 - - - - - - - //入组 相关接口 (提交CRO-1) CRO确认-4 - - - - - 基本信息详情展示、编辑使用 - - - - - - - 添加医生基本信息 - - - - - - - 获取医生 工作信息 - - - - - - - 更新医生 工作信息 - - - - - - - 获取医生技能信息 - - - - - 更新医生技能信息 - - - - - 获取医生 审核状态 - - - - - 审核简历 和合作关系 - - - - 医生详情 入组信息 - - - 获取医生参与项目的Sow协议 - - - 获取医生入组的 ack Sow - - - 判断当前时间是否在休假 - - - - 上传入组后的Ack-SOW - - 获取医院列表 - - 按类型统计读片数量 - - - 按月份统计读片数量 - - - 读片数量排行 - - - 按Position统计 Reviewers 数量 - - - 每月入组人次 - - - 参与项目数排行 - - - 最新工作量 (已确定的) - - - 入组流程-筛选医生 [select] - - - 入组流程-向CRO提交医生[Submit] - - - 入组流程-CRO确定医生名单 [ Approve] - - - 入组流程-向CRO提交医生[Submit] - diff --git a/IRaCIS.Core.Application/Service/Allocation/TaskAllocationRuleService.cs b/IRaCIS.Core.Application/Service/Allocation/TaskAllocationRuleService.cs deleted file mode 100644 index 2695eb31f..000000000 --- a/IRaCIS.Core.Application/Service/Allocation/TaskAllocationRuleService.cs +++ /dev/null @@ -1,225 +0,0 @@ -//-------------------------------------------------------------------- -// 此代码由T4模板自动生成 byzhouhang 20210918 -// 生成时间 2022-06-07 13:14:38 -// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。 -//-------------------------------------------------------------------- - -using IRaCIS.Core.Domain.Models; -using Microsoft.AspNetCore.Mvc; -using IRaCIS.Core.Application.Interfaces; -using IRaCIS.Core.Application.ViewModel; -using IRaCIS.Core.Application.Contracts; -using IRaCIS.Core.Domain.Share; -using IRaCIS.Core.Application.Filter; - -namespace IRaCIS.Core.Application.Service -{ - /// - /// 分配规则 - /// - [ApiExplorerSettings(GroupName = "Trial")] - public class TaskAllocationRuleService : BaseService, ITaskAllocationRuleService - { - - private readonly IRepository _taskAllocationRuleRepository; - private readonly IRepository _userRepository; - - private readonly IRepository _trialRepository; - - private readonly IRepository _subjectCanceDoctorRepository; - - - - public TaskAllocationRuleService(IRepository taskAllocationRuleRepository, IRepository userRepository, IRepository trialRepository, IRepository subjectCanceDoctorRepository) - { - _taskAllocationRuleRepository = taskAllocationRuleRepository; - _userRepository = userRepository; - _trialRepository = trialRepository; - _subjectCanceDoctorRepository = subjectCanceDoctorRepository; - } - - - - - /// - /// 获取计划列表 医生带阅片类型 - /// - /// - /// - public async Task<(List,object)> GetDoctorPlanAllocationRuleList(Guid trialId) - { - - var list = await _taskAllocationRuleRepository.Where(t => t.TrialId == trialId).ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); - - //所有标准都是一样 后台只返回任意一个标准的就好了 - var trialTaskConfig = _repository.Where(t => t.TrialId == trialId && t.IsConfirm).ProjectTo(_mapper.ConfigurationProvider).FirstOrDefault(); - - return (list, trialTaskConfig); - } - - - - - [TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })] - - public async Task AddOrUpdateTaskAllocationRule(TaskAllocationRuleAddOrEdit addOrEditTaskAllocationRule) - { - - - //冗余 存 - - var enrollId = _repository.Where(t => t.TrialId == addOrEditTaskAllocationRule.TrialId && t.DoctorUserId == addOrEditTaskAllocationRule.DoctorUserId).Select(t => t.Id).FirstOrDefault(); - - if (enrollId == Guid.Empty) - { - //"错误,未在入组表中找到该医生得账号Id" - return ResponseOutput.NotOk(_localizer["TaskAllocation_DoctorIdNotFound"]); - } - - addOrEditTaskAllocationRule.EnrollId = enrollId; - - var verifyExp1 = new EntityVerifyExp() - { - VerifyExp = t => t.DoctorUserId == addOrEditTaskAllocationRule.DoctorUserId && t.TrialId == addOrEditTaskAllocationRule.TrialId, - // "已有该医生配置,不允许继续增加" - VerifyMsg = _localizer["TaskAllocation_DoctorConfigExists"] - }; - - var entity = await _taskAllocationRuleRepository.InsertOrUpdateAsync(addOrEditTaskAllocationRule, true, verifyExp1); - - return ResponseOutput.Ok(entity.Id.ToString()); - - } - - [TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })] - - [HttpDelete("{taskAllocationRuleId:guid}")] - public async Task DeleteTaskAllocationRule(Guid taskAllocationRuleId) - { - if (await _taskAllocationRuleRepository.Where(t => t.Id == taskAllocationRuleId).AnyAsync(t => t.DoctorUser.VisitTaskList.Where(u => u.TrialId == t.TrialId).Any())) - { - //"已分配任务给该医生,不允许删除" - return ResponseOutput.NotOk(_localizer["TaskAllocation_TaskAssigned"]); - } - - var success = await _taskAllocationRuleRepository.DeleteFromQueryAsync(t => t.Id == taskAllocationRuleId, true); - - - return ResponseOutput.Ok(); - } - - - //public async Task AddSubjectCancelDoctorNote(CancelDoctorCommand command) - //{ - // await _subjectCanceDoctorRepository.InsertOrUpdateAsync(command, true); - - // return ResponseOutput.Ok(); - //} - - public async Task> GetSubjectCancelDoctorHistoryList(Guid subjectId) - { - var list = await _subjectCanceDoctorRepository.Where(t => t.SubjectId == subjectId).ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); - - return list; - } - - - - - - - /// - /// 获取项目下 医生账户信息下拉 - /// - /// - /// - /// - [HttpGet("{trialId:guid}")] - public async Task> GetDoctorUserSelectList(Guid trialId, [FromServices] IRepository _enrollRepository) - { - var query = from enroll in _enrollRepository.Where(t => t.TrialId == trialId && t.EnrollStatus >= EnrollStatus.ConfirmIntoGroup) - join user in _userRepository.AsQueryable() on enroll.DoctorId equals user.DoctorId - select new TrialDoctorUserSelectView() - { - TrialId = enroll.TrialId, - //ReadingType = enroll.Trial.ReadingType, - DoctorUserId = user.Id, - FullName = user.FullName, - UserCode = user.UserCode, - UserName = user.UserName, - UserTypeEnum = user.UserTypeRole.UserTypeEnum, - ReadingCategoryList = enroll.EnrollReadingCategoryList.Select(t => t.ReadingCategory).ToList() - - }; - - return await query.ToListAsync(); - } - - - [HttpPost] - public async Task> GetDoctorSelectList(DoctorSelectQuery selectQuery, [FromServices] IRepository _enrollRepository) - { - - var query = from allocationRule in _taskAllocationRuleRepository.Where(t => t.TrialId == selectQuery.TrialId && t.IsEnable) - .WhereIf(selectQuery.ReadingCategory != null && selectQuery.TrialReadingCriterionId == null, t => t.Enroll.EnrollReadingCategoryList.Any(t => t.ReadingCategory == selectQuery.ReadingCategory)) - .WhereIf(selectQuery.TrialReadingCriterionId != null && selectQuery.ReadingCategory == null, t => t.Enroll.EnrollReadingCategoryList.Any(t => t.TrialReadingCriterionId == selectQuery.TrialReadingCriterionId)) - .WhereIf(selectQuery.TrialReadingCriterionId != null && selectQuery.ReadingCategory !=null, - t => t.Enroll.EnrollReadingCategoryList.Any(t => t.TrialReadingCriterionId == selectQuery.TrialReadingCriterionId && t.ReadingCategory==selectQuery.ReadingCategory)) - join user in _userRepository.AsQueryable() on allocationRule.DoctorUserId equals user.Id - select new TrialDoctorUserSelectView() - { - TrialId = allocationRule.TrialId, - DoctorUserId = user.Id, - FullName = user.FullName, - UserCode = user.UserCode, - UserName = user.UserName, - UserTypeEnum = user.UserTypeRole.UserTypeEnum, - - ReadingCategoryList = selectQuery.TrialReadingCriterionId == null ? - - allocationRule.Enroll.EnrollReadingCategoryList.Where(t=> (selectQuery.ReadingCategory == null ?true: t.ReadingCategory == selectQuery.ReadingCategory) ).Select(t => t.ReadingCategory).OrderBy(t => t).ToList() : - - allocationRule.Enroll.EnrollReadingCategoryList - .Where(t => t.TrialReadingCriterionId == selectQuery.TrialReadingCriterionId && (selectQuery.ReadingCategory == null?true : t.ReadingCategory == selectQuery.ReadingCategory) ) - .Select(t => t.ReadingCategory).OrderBy(t => t).ToList() - }; - - return await query.ToListAsync(); - } - - - #region 废弃 - /// - /// 获取访视任务 应用Subject后 医生比率情况 - /// - /// - [HttpPost] - [Obsolete] - public async Task> GetSubjectApplyDoctorTaskStatList(ApplySubjectCommand assignConfirmCommand) - { - var taskAllocationRuleQueryable = _taskAllocationRuleRepository.Where(t => t.TrialId == assignConfirmCommand.TrialId && t.IsJudgeDoctor == assignConfirmCommand.IsJudgeDoctor) - .ProjectTo(_mapper.ConfigurationProvider, new { subjectIdList = assignConfirmCommand.SubjectIdList, isJudgeDoctor = assignConfirmCommand.IsJudgeDoctor }); - - return await taskAllocationRuleQueryable.ToListAsync(); - } - - - - [HttpPost] - [Obsolete] - public async Task> GetTaskAllocationRuleList(TaskAllocationRuleQuery queryTaskAllocationRule) - { - var taskAllocationRuleQueryable = _taskAllocationRuleRepository.Where(t => t.TrialId == queryTaskAllocationRule.TrialId /*&& t.IsJudgeDoctor == queryTaskAllocationRule.IsJudgeDoctor*/) - .ProjectTo(_mapper.ConfigurationProvider); - - - //var trialTaskConfig = _trialRepository.Where(t => t.Id == queryTaskAllocationRule.TrialId).ProjectTo(_mapper.ConfigurationProvider, new { isJudgeDoctor = queryTaskAllocationRule.IsJudgeDoctor }).FirstOrDefault(); - - return await taskAllocationRuleQueryable.ToListAsync(); - } - - #endregion - - - } -} diff --git a/IRaCIS.Core.Application/Service/Allocation/TaskConsistentRuleService.cs b/IRaCIS.Core.Application/Service/Allocation/TaskConsistentRuleService.cs deleted file mode 100644 index 1f8480a21..000000000 --- a/IRaCIS.Core.Application/Service/Allocation/TaskConsistentRuleService.cs +++ /dev/null @@ -1,777 +0,0 @@ -//-------------------------------------------------------------------- -// 此代码由T4模板自动生成 byzhouhang 20210918 -// 生成时间 2022-07-01 15:33:04 -// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。 -//-------------------------------------------------------------------- - -using IRaCIS.Core.Domain.Models; -using Microsoft.AspNetCore.Mvc; -using IRaCIS.Core.Application.Interfaces; -using IRaCIS.Core.Application.ViewModel; -using IRaCIS.Core.Infrastructure; -using IRaCIS.Core.Domain.Share; -using System.Linq.Expressions; -using IRaCIS.Core.Infra.EFCore.Common; -using System.Linq; -using Nito.AsyncEx; -using IRaCIS.Core.Application.Contracts; -using IRaCIS.Core.Application.Filter; - -namespace IRaCIS.Core.Application.Service -{ - /// - /// 一致性分析配置表 - /// - [ApiExplorerSettings(GroupName = "Trial")] - public class TaskConsistentRuleService : BaseService, ITaskConsistentRuleService - { - - private readonly IRepository _taskConsistentRuleRepository; - private readonly IRepository _visitTaskRepository; - private readonly IRepository _subjectUserRepository; - private readonly IRepository _subjectRepository; - private readonly IRepository _enrollRepository; - - private readonly AsyncLock _mutex = new AsyncLock(); - - public TaskConsistentRuleService(IRepository visitTaskRepository, IRepository enrollRepository, IRepository taskConsistentRuleRepository, IRepository subjectUserRepository, IRepository subjectRepository) - { - _taskConsistentRuleRepository = taskConsistentRuleRepository; - _visitTaskRepository = visitTaskRepository; - _subjectUserRepository = subjectUserRepository; - _subjectRepository = subjectRepository; - _enrollRepository = enrollRepository; - } - - /// - /// 设置一致性分析任务失效 - /// - /// - /// - [HttpPost] - public async Task SetAnalysisTaskInvalid(List taskIdList) - { - - - await _visitTaskRepository.UpdatePartialFromQueryAsync(t => taskIdList.Contains(t.Id), u => new VisitTask() { TaskState = TaskState.NotEffect },true); - - await _visitTaskRepository.SaveChangesAsync(); - - return ResponseOutput.Ok(); - - } - - - /// - /// 一致性分析列表 (自身 组内 最后勾选 产生的任务) - /// - /// - /// - [HttpPost] - public async Task> GetAnalysisTaskList(VisitTaskQuery queryVisitTask) - { - var visitTaskQueryable = _visitTaskRepository.Where(t => t.TrialId == queryVisitTask.TrialId) - .Where(t => t.IsAnalysisCreate) - - .WhereIf(queryVisitTask.TrialReadingCriterionId != null, t => t.TrialReadingCriterionId == queryVisitTask.TrialReadingCriterionId) - - .WhereIf(queryVisitTask.SiteId != null, t => t.Subject.SiteId == queryVisitTask.SiteId) - .WhereIf(queryVisitTask.SubjectId != null, t => t.SubjectId == queryVisitTask.SubjectId) - .WhereIf(queryVisitTask.TaskState != null, t => t.TaskState == queryVisitTask.TaskState) - .WhereIf(queryVisitTask.IsUrgent != null, t => t.IsUrgent == queryVisitTask.IsUrgent) - .WhereIf(queryVisitTask.DoctorUserId != null, t => t.DoctorUserId == queryVisitTask.DoctorUserId) - .WhereIf(queryVisitTask.ReadingCategory != null, t => t.ReadingCategory == queryVisitTask.ReadingCategory) - .WhereIf(queryVisitTask.ReadingTaskState != null, t => t.ReadingTaskState == queryVisitTask.ReadingTaskState) - .WhereIf(queryVisitTask.TaskAllocationState != null, t => t.TaskAllocationState == queryVisitTask.TaskAllocationState) - .WhereIf(queryVisitTask.IsSelfAnalysis != null, t => t.IsSelfAnalysis == queryVisitTask.IsSelfAnalysis) - .WhereIf(queryVisitTask.ArmEnum != null, t => t.ArmEnum == queryVisitTask.ArmEnum) - .WhereIf(!string.IsNullOrEmpty(queryVisitTask.TrialSiteCode), t => (t.BlindTrialSiteCode.Contains(queryVisitTask.TrialSiteCode!) && t.IsAnalysisCreate) || (t.Subject.TrialSite.TrialSiteCode.Contains(queryVisitTask.TrialSiteCode!) && t.IsAnalysisCreate == false)) - .WhereIf(!string.IsNullOrEmpty(queryVisitTask.TaskName), t => t.TaskName.Contains(queryVisitTask.TaskName) || t.TaskBlindName.Contains(queryVisitTask.TaskName)) - .WhereIf(!string.IsNullOrEmpty(queryVisitTask.SubjectCode), t => (t.Subject.Code.Contains(queryVisitTask.SubjectCode) && t.IsAnalysisCreate == false) || (t.BlindSubjectCode.Contains(queryVisitTask.SubjectCode) && t.IsAnalysisCreate)) - .WhereIf(queryVisitTask.BeginAllocateDate != null, t => t.AllocateTime > queryVisitTask.BeginAllocateDate) - .WhereIf(queryVisitTask.EndAllocateDate != null, t => t.AllocateTime < queryVisitTask.EndAllocateDate!.Value.AddDays(1)) - .ProjectTo(_mapper.ConfigurationProvider); - - var defalutSortArray = new string[] { nameof(VisitTask.IsUrgent) + " desc", nameof(VisitTask.SubjectId), nameof(VisitTask.VisitTaskNum) }; - - var pageList = await visitTaskQueryable.ToPagedListAsync(queryVisitTask.PageIndex, queryVisitTask.PageSize, queryVisitTask.SortField, queryVisitTask.Asc, string.IsNullOrWhiteSpace(queryVisitTask.SortField), defalutSortArray); - - //var trialTaskConfig = _repository.Where(t => t.Id == queryVisitTask.TrialId).ProjectTo(_mapper.ConfigurationProvider).FirstOrDefault(); - return pageList; - } - - - /// - /// 为自身一致性分析医生,选择Subejct 列表 - /// - /// - /// - [HttpPost] - public async Task> GetDoctorSelfConsistentRuleSubjectList(ConsistentQuery inQuery) - { - var filterObj = await _taskConsistentRuleRepository.FirstOrDefaultAsync(t => t.Id == inQuery.TaskConsistentRuleId); - - var pagedList = await GetIQueryableDoctorSelfConsistentSubjectView(filterObj, inQuery.DoctorUserId).ToPagedListAsync(inQuery.PageIndex, inQuery.PageSize, string.IsNullOrWhiteSpace(inQuery.SortField) ? nameof(DoctorSelfConsistentSubjectView.SubjectCode) : inQuery.SortField, inQuery.Asc); - - return pagedList; - } - - - - /// - /// 确认生成自身一致性分析任务 - /// - /// - /// - /// - [HttpPost] - [UnitOfWork] - //[TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })] - - public async Task ConfirmGenerateSelfConsistentTask(ConsistentConfirmGenerateCommand inCommand, [FromServices] IVisitTaskHelpeService _visitTaskCommonService) - { - - - var filterObj = await _taskConsistentRuleRepository.FirstOrDefaultAsync(t => t.Id == inCommand.TaskConsistentRuleId); - var doctorUserId = inCommand.DoctorUserId; - var trialReadingCriterionId = filterObj.TrialReadingCriterionId; - - var list = await GetIQueryableDoctorSelfConsistentSubjectView(filterObj, doctorUserId, inCommand.SubejctIdList).ToListAsync(); - - //var (group, query) = GetIQueryableDoctorSelfConsistentRuleSubjectView(filterObj, inCommand.SubejctIdList); - - //var list = query.OrderByDescending(t => t.IsHaveGeneratedTask).ToList(); - - using (await _mutex.LockAsync()) - { - int maxCodeInt = 0; - - foreach (var subject in list) - { - //处理 Subject 编号 - - var blindSubjectCode = string.Empty; - - var subjectTask = _visitTaskRepository.Where(t => t.SubjectId == subject.SubjectId && t.TrialReadingCriterionId==trialReadingCriterionId && t.IsSelfAnalysis == true).OrderByDescending(t => t.BlindSubjectCode).FirstOrDefault(); - - if (subjectTask!=null && subjectTask.BlindSubjectCode != String.Empty) - { - blindSubjectCode = subjectTask.BlindSubjectCode; - } - else - { - var maxCodeStr = _visitTaskRepository.Where(t => t.TrialId == subject.TrialId && t.TrialReadingCriterionId == trialReadingCriterionId && t.IsSelfAnalysis == true).OrderByDescending(t => t.BlindSubjectCode).Select(t => t.BlindSubjectCode).FirstOrDefault(); - - if ( !string.IsNullOrEmpty(maxCodeStr)) - { - int.TryParse(maxCodeStr.Substring(maxCodeStr.Length - filterObj.BlindSubjectNumberOfPlaces), out maxCodeInt); - - } - - blindSubjectCode = filterObj.BlindTrialSiteCode + (maxCodeInt + 1).ToString($"D{filterObj.BlindSubjectNumberOfPlaces}"); - } - - subject.VisitTaskList = subject.VisitTaskList.Take(filterObj.PlanVisitCount).ToList(); - - subject.VisitTaskList.ForEach(t => - { - t.DoctorUserId = doctorUserId; - //t.TaskConsistentRuleId = filterObj.Id; - t.BlindTrialSiteCode = filterObj.BlindTrialSiteCode; - t.BlindSubjectCode = blindSubjectCode; - }); - - - //最后一个访视添加全局 - if (filterObj.IsGenerateGlobalTask) - { - var lastTask = (subject.VisitTaskList.Take(filterObj.PlanVisitCount).Last()).Clone(); - - var existGlobal = _visitTaskRepository.Where(t => t.SubjectId == lastTask.SubjectId &&t.TrialReadingCriterionId==trialReadingCriterionId && t.TaskState == TaskState.Effect && t.ReadingCategory == ReadingCategory.Global && t.VisitTaskNum == lastTask.VisitTaskNum + ReadingCommon.TaskNumDic[ReadingCategory.Global]).ProjectTo(_mapper.ConfigurationProvider).FirstOrDefault(); - - - if (existGlobal == null) - { - existGlobal = new VisitTaskSimpleDTO() - { - SubjectId = lastTask.SubjectId, - TrialId = lastTask.TrialId, - ArmEnum = lastTask.ArmEnum, - ReadingCategory = ReadingCategory.Global, - TaskName = lastTask.TaskName + "_Global", - TaskBlindName = lastTask.TaskBlindName + "_Global", - TrialReadingCriterionId=trialReadingCriterionId, - }; - } - - - existGlobal.DoctorUserId = doctorUserId; - existGlobal.BlindSubjectCode = lastTask.BlindSubjectCode; - existGlobal.BlindTrialSiteCode = lastTask.BlindTrialSiteCode; - - subject.VisitTaskList.Add(existGlobal); - } - - - - await _visitTaskCommonService.AddTaskAsync(new GenerateTaskCommand() - { - TrialId = filterObj.TrialId, - - ReadingCategory = GenerateTaskCategory.SelfConsistent, - - - //产生的过滤掉已经生成的 - GenerataConsistentTaskList = subject.VisitTaskList.Where(t => t.IsHaveGeneratedTask == false).ToList() - }); - - await _visitTaskRepository.SaveChangesAsync(); - - } - } - - return ResponseOutput.Ok(); - - - } - - - /// - /// 组间一致性分析 选择Subejct 列表 - /// - /// - /// - [HttpPost] - public async Task> GetGroupConsistentRuleSubjectList(GroupConsistentQuery inQuery) - { - var trialId = inQuery.TrialId; - - var filterObj = await _taskConsistentRuleRepository.FirstOrDefaultAsync(t => t.TrialId == trialId && t.TrialReadingCriterionId==inQuery.TrialReadingCriterionId && t.IsSelfAnalysis == false); - - - if (filterObj == null) - { - return new PageOutput(); - } - - var query = await GetGroupConsistentQueryAsync(filterObj); - - - var pagedList = await query.ToPagedListAsync(inQuery.PageIndex, inQuery.PageSize, string.IsNullOrWhiteSpace(inQuery.SortField) ? nameof(DoctorSelfConsistentSubjectView.SubjectCode) : inQuery.SortField, inQuery.Asc); - - return pagedList; - } - - - - /// - /// 确认生成组间一致性分析任务 - /// - /// - /// - /// - [HttpPost] - [UnitOfWork] - [TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })] - - public async Task ConfirmGenerateGroupConsistentTask(GroupConsistentConfirmGenrateCommand inCommand, [FromServices] IVisitTaskHelpeService _visitTaskCommonService) - { - var trialId = inCommand.TrialId; - - var filterObj = await _taskConsistentRuleRepository.FirstOrDefaultAsync(t => t.TrialId == trialId && t.IsSelfAnalysis == false); - - var trialReadingCriterionId = filterObj.TrialReadingCriterionId; - - - var query = await GetGroupConsistentQueryAsync(filterObj, inCommand.SubejctIdList); - - var subjectList = query.ToList(); - - var doctorUserIdQuery = from enroll in _repository.Where(t => t.TrialId == trialId).Where(t => t.EnrollReadingCategoryList.Where(t=>t.TrialReadingCriterionId==trialReadingCriterionId).Any(c => c.ReadingCategory == ReadingCategory.Global || c.ReadingCategory == ReadingCategory.Visit)) - join user in _repository.Where() on enroll.DoctorId equals user.DoctorId - select user.Id; - - var configDoctorUserIdList = await doctorUserIdQuery.ToListAsync(); - - using (await _mutex.LockAsync()) - { - int maxCodeInt = 0; - - foreach (var subject in subjectList.Where(t => t.IsHaveGeneratedTask == false)) - { - - //组间一致性分析 也用盲态SubjectCode - //处理 Subject 编号 - - var blindSubjectCode = string.Empty; - - var subjectTask = _visitTaskRepository.Where(t => t.SubjectId == subject.SubjectId && t.TrialReadingCriterionId == trialReadingCriterionId && t.IsSelfAnalysis==false).OrderByDescending(t => t.BlindSubjectCode).FirstOrDefault(); - if (subjectTask != null && subjectTask.BlindSubjectCode != String.Empty) - { - blindSubjectCode = subjectTask.BlindSubjectCode; - } - else - { - var maxCodeStr = _visitTaskRepository.Where(t => t.TrialId == subject.TrialId && t.TrialReadingCriterionId == trialReadingCriterionId && t.IsSelfAnalysis == false).OrderByDescending(t => t.BlindSubjectCode).Select(t => t.BlindSubjectCode).FirstOrDefault(); - - if (!string.IsNullOrEmpty(maxCodeStr)) - { - int.TryParse(maxCodeStr.Substring(maxCodeStr.Length - filterObj.BlindSubjectNumberOfPlaces), out maxCodeInt); - - } - - blindSubjectCode = filterObj.BlindTrialSiteCode + (maxCodeInt + 1).ToString($"D{filterObj.BlindSubjectNumberOfPlaces}"); - } - - - - - - - var subjectAddTaskList = new List(); - - - //需要处理的医生 - - var needAddDoctorUserIdList = configDoctorUserIdList.Except(subject.VisitTaskList.Select(t => (Guid)t.DoctorUserId)).ToList(); - - if (needAddDoctorUserIdList.Count == 0) - { - //"请配置一致性分析的医生" - throw new BusinessValidationFailedException(_localizer["TaskConsistent_ConsistencyConfigExists"]); - } - - - foreach (var needAddDoctorUserId in needAddDoctorUserIdList) - { - - //每个医生 都生成处理的任务 - foreach (var task in subject.SubjectTaskVisitList.Take(filterObj.PlanVisitCount)) - { - - subjectAddTaskList.Add(new VisitTaskGroupSimpleDTO() - { - ReadingCategory = task.ReadingCategory, - ReadingTaskState = task.ReadingTaskState, - TaskBlindName = task.TaskBlindName, - TaskName = task.TaskName, - TaskState = task.TaskState, - SubjectId = task.SubjectId, - VisitTaskNum = task.VisitTaskNum, - TrialId = task.TrialId, - DoctorUserId = needAddDoctorUserId, - ArmEnum = Arm.GroupConsistentArm, - SouceReadModuleId = task.SouceReadModuleId, - SourceSubjectVisitId = task.SourceSubjectVisitId, - - TrialReadingCriterionId = task.TrialReadingCriterionId, - - BlindSubjectCode=blindSubjectCode, - BlindTrialSiteCode=filterObj.BlindTrialSiteCode - - - }); - - } - - //最后一个访视添加全局 - - if (filterObj.IsGenerateGlobalTask) - { - var lastTask = (subjectAddTaskList.Take(filterObj.PlanVisitCount).Last()).Clone(); - - - var existGlobal = _visitTaskRepository.Where(t => t.SubjectId == lastTask.SubjectId && t.TrialReadingCriterionId == trialReadingCriterionId && t.TaskState == TaskState.Effect && t.ReadingCategory == ReadingCategory.Global && t.VisitTaskNum == lastTask.VisitTaskNum + ReadingCommon.TaskNumDic[ReadingCategory.Global]).ProjectTo(_mapper.ConfigurationProvider).FirstOrDefault(); - - - if (existGlobal == null) - { - existGlobal = new VisitTaskSimpleDTO() - { - SubjectId = lastTask.SubjectId, - TrialId = lastTask.TrialId, - ReadingCategory = ReadingCategory.Global, - TaskName = lastTask.TaskName + "_Global", - TaskBlindName = lastTask.TaskBlindName + "_Global", - - TrialReadingCriterionId = trialReadingCriterionId, - - BlindSubjectCode = blindSubjectCode, - BlindTrialSiteCode = filterObj.BlindTrialSiteCode - - }; - } - - - existGlobal.BlindSubjectCode = blindSubjectCode; - existGlobal.BlindTrialSiteCode = filterObj.BlindTrialSiteCode; - existGlobal.ArmEnum = Arm.GroupConsistentArm; - existGlobal.DoctorUserId = needAddDoctorUserId; - - subjectAddTaskList.Add(existGlobal); - } - - } - - - await _visitTaskCommonService.AddTaskAsync(new GenerateTaskCommand() - { - TrialId = filterObj.TrialId, - - ReadingCategory = GenerateTaskCategory.GroupConsistent, - - - GenerataGroupConsistentTaskList = subjectAddTaskList - }); - - - await _taskConsistentRuleRepository.SaveChangesAsync(); - } - - } - - - - return ResponseOutput.Ok(); - - - } - - - - - /// - /// 仅仅自身一致性时使用( - /// - /// - /// - /// - /// - private IQueryable GetIQueryableDoctorSelfConsistentSubjectView(TaskConsistentRule filterObj, Guid doctorUserId, List? subejctIdList = null) - { - var trialId = filterObj.TrialId; - - var trialReadingCriterionId = filterObj.TrialReadingCriterionId; - - #region Subejct 维度 - - Expression> comonTaskFilter = u => u.TrialId == trialId && u.IsAnalysisCreate == false && u.TaskState == TaskState.Effect && u.ReadingTaskState == ReadingTaskState.HaveSigned && u.TrialReadingCriterionId== trialReadingCriterionId && - u.SignTime!.Value.AddDays(filterObj.IntervalWeeks * 7) < DateTime.Now && (u.ReReadingApplyState == ReReadingApplyState.Default || u.ReReadingApplyState == ReReadingApplyState.Reject) && u.DoctorUserId == doctorUserId; - - - - - if (subejctIdList != null && subejctIdList?.Count > 0) - { - comonTaskFilter = comonTaskFilter.And(t => subejctIdList.Contains(t.SubjectId)); - } - - - Expression> visitTaskFilter = comonTaskFilter.And(t => t.ReadingCategory == ReadingCategory.Visit); - - ////所选访视数量 的访视 其中必有一个访视后有全局任务 - //if (filterObj.IsHaveReadingPeriod == true) - //{ - // //这里的过滤条件 不能用 where(comonTaskFilter) 会报错,奇怪的问题 只能重新写一遍 - // visitTaskFilter = visitTaskFilter.And(c => c.Subject.SubjectVisitTaskList.Any(t => t.VisitTaskNum == c.VisitTaskNum + ReadingCommon.TaskNumDic[ReadingCategory.Global] && t.ReadingCategory == ReadingCategory.Global && t.IsAnalysisCreate == false && t.TaskState == TaskState.Effect && t.ReadingTaskState == ReadingTaskState.HaveSigned && - // t.SignTime!.Value.AddDays(filterObj.IntervalWeeks * 7) < DateTime.Now && (t.ReReadingApplyState == ReReadingApplyState.Default || t.ReReadingApplyState == ReReadingApplyState.Reject))); - - //} - - - var subjectQuery = _subjectRepository.Where(t => t.TrialId == trialId && - t.SubjectVisitTaskList.AsQueryable().Where(visitTaskFilter).Count() >= filterObj.PlanVisitCount) - .WhereIf(filterObj.IsHaveReadingPeriod == true, u => u.SubjectVisitTaskList.AsQueryable().Where(comonTaskFilter).Where(t => t.ReadingCategory == ReadingCategory.Visit || t.ReadingCategory == ReadingCategory.Global).OrderBy(t => t.VisitTaskNum).Take(filterObj.PlanVisitCount + 1).Any(t => t.ReadingCategory == ReadingCategory.Global)) - ; - - - - var query = subjectQuery.Select(t => new DoctorSelfConsistentSubjectView() - { - TrialId = t.TrialId, - SiteId = t.SiteId, - SubjectCode = t.Code, - TrialSiteCode = t.TrialSite.TrialSiteCode, - SubjectId = t.Id, - - IsReReadingOrBackInfluenceAnalysis=t.IsReReadingOrBackInfluenceAnalysis, - - BlindSubjectCode = t.SubjectVisitTaskList.Where(t => t.IsAnalysisCreate && t.TrialReadingCriterionId == trialReadingCriterionId).OrderByDescending(t => t.BlindSubjectCode).Select(t => t.BlindSubjectCode).FirstOrDefault(), - - IsHaveGeneratedTask = t.SubjectVisitTaskList.Any(c => c.DoctorUserId == doctorUserId && c.IsSelfAnalysis == true && c.TrialReadingCriterionId==trialReadingCriterionId), - - - ValidVisitCount = t.SubjectVisitTaskList.AsQueryable().Where(visitTaskFilter).Count(), - - VisitTaskList = t.SubjectVisitTaskList.AsQueryable().Where(visitTaskFilter).OrderBy(t => t.VisitTaskNum).Select(c => new VisitTaskSimpleDTO() - { - Id = c.Id, - ReadingCategory = c.ReadingCategory, - ReadingTaskState = c.ReadingTaskState, - TaskBlindName = c.TaskBlindName, - TaskCode = c.TaskCode, - TaskName = c.TaskName, - TaskState = c.TaskState, - ArmEnum = c.ArmEnum, - SubjectId = c.SubjectId, - VisitTaskNum = c.VisitTaskNum, - TrialId = c.TrialId, - SourceSubjectVisitId = c.SourceSubjectVisitId, - SouceReadModuleId = c.SouceReadModuleId, - - - - TrialReadingCriterionId=c.TrialReadingCriterionId, - IsClinicalDataSign = c.IsClinicalDataSign, - IsNeedClinicalDataSign = c.IsNeedClinicalDataSign, - - //自身一致性才有意义 - //IsHaveGeneratedTask = c.Subject.SubjectVisitTaskList.Any(t => t.ConsistentAnalysisOriginalTaskId == c.Id), - - GlobalVisitTaskList = c.Subject.SubjectVisitTaskList.AsQueryable().Where(comonTaskFilter).Where(t => t.VisitTaskNum == c.VisitTaskNum + ReadingCommon.TaskNumDic[ReadingCategory.Global]).Select(c => new VisitTaskSimpleDTO() - { - Id = c.Id, - ReadingCategory = c.ReadingCategory, - ReadingTaskState = c.ReadingTaskState, - TaskBlindName = c.TaskBlindName, - TaskCode = c.TaskCode, - TaskName = c.TaskName, - TaskState = c.TaskState, - ArmEnum = c.ArmEnum, - SubjectId = c.SubjectId, - VisitTaskNum = c.VisitTaskNum, - TrialId = c.TrialId, - SourceSubjectVisitId = c.SourceSubjectVisitId, - SouceReadModuleId = c.SouceReadModuleId, - - TrialReadingCriterionId = c.TrialReadingCriterionId, - IsClinicalDataSign = c.IsClinicalDataSign, - IsNeedClinicalDataSign = c.IsNeedClinicalDataSign, - }).ToList(), - - }).ToList() - }); - - return query.OrderByDescending(t => t.IsHaveGeneratedTask); - - #endregion - } - - - - - private async Task> GetGroupConsistentQueryAsync(TaskConsistentRule filterObj, List? subejctIdList = null) - { - - var trialId = filterObj.TrialId; - var trialReadingCriterionId = filterObj.TrialReadingCriterionId; - - //var trialConfig = (await _repository.Where(t => t.Id == trialId).Select(t => new { TrialId = t.Id, t.ReadingType, t.IsReadingTaskViewInOrder }).FirstOrDefaultAsync()).IfNullThrowException(); - - - - Expression> comonTaskFilter = u => u.TrialId == trialId && u.IsAnalysisCreate == false && u.TaskState == TaskState.Effect && u.ReadingTaskState == ReadingTaskState.HaveSigned && u.TrialReadingCriterionId == trialReadingCriterionId - && (u.ReReadingApplyState == ReReadingApplyState.Default || u.ReReadingApplyState == ReReadingApplyState.Reject); - - - if (subejctIdList != null && subejctIdList?.Count > 0) - { - comonTaskFilter = comonTaskFilter.And(t => subejctIdList.Contains(t.SubjectId)); - } - - Expression> visitTaskFilter = comonTaskFilter.And(t => t.ReadingCategory == ReadingCategory.Visit); - - - ////所选访视数量 的访视 其中必有一个访视后有全局任务 - //if (filterObj.IsHaveReadingPeriod == true) - //{ - // //visitTaskFilter = visitTaskFilter.And(t => t.Subject.SubjectVisitTaskList.AsQueryable().Where(comonTaskFilter).Any(u => u.VisitTaskNum == t.VisitTaskNum + ReadingCommon.TaskNumDic[ReadingCategory.Global] && u.ReadingCategory == ReadingCategory.Global)); - - // //这里的过滤条件 不能用 where(comonTaskFilter) 会报错,奇怪的问题 只能重新写一遍 - // visitTaskFilter = visitTaskFilter.And(c => c.Subject.SubjectVisitTaskList.Any(t => t.VisitTaskNum == c.VisitTaskNum + ReadingCommon.TaskNumDic[ReadingCategory.Global] && t.ReadingCategory == ReadingCategory.Global && t.IsAnalysisCreate == false && t.TaskState == TaskState.Effect && t.ReadingTaskState == ReadingTaskState.HaveSigned && - // t.SignTime!.Value.AddDays(filterObj.IntervalWeeks * 7) < DateTime.Now && (t.ReReadingApplyState == ReReadingApplyState.Default || t.ReReadingApplyState == ReReadingApplyState.Reject))); - - //} - - - IQueryable subjectQuery = default; - - //单重阅片没有组件一致性 - - subjectQuery = _subjectRepository.Where(t => t.TrialId == trialId && - t.SubjectVisitTaskList.AsQueryable().Where(comonTaskFilter).Where(t => t.ReadingCategory == ReadingCategory.Visit || t.ReadingCategory == ReadingCategory.Global).Select(t => t.DoctorUserId).Distinct().Count() == 2 && - t.SubjectVisitTaskList.AsQueryable().Where(visitTaskFilter).GroupBy(t => new { t.SubjectId, t.VisitTaskNum }).Where(g => g.Count() == 2).Count() >= filterObj.PlanVisitCount - ) - .WhereIf(filterObj.IsHaveReadingPeriod == true, u => u.SubjectVisitTaskList.AsQueryable().Where(comonTaskFilter).Where(t => t.ReadingCategory == ReadingCategory.Visit || t.ReadingCategory == ReadingCategory.Global).OrderBy(t => t.VisitTaskNum).Take(filterObj.PlanVisitCount * 2 + 2).Any(t => t.ReadingCategory == ReadingCategory.Global)) - - ; - - - - var query = subjectQuery.Select(t => new DoctorGroupConsistentSubjectView() - { - TrialId = t.TrialId, - SiteId = t.SiteId, - SubjectCode = t.Code, - TrialSiteCode = t.TrialSite.TrialSiteCode, - SubjectId = t.Id, - IsReReadingOrBackInfluenceAnalysis = t.IsReReadingOrBackInfluenceAnalysis, - - IsHaveGeneratedTask = t.SubjectVisitTaskList.Any(c => c.IsSelfAnalysis == false && c.TrialReadingCriterionId==trialReadingCriterionId), - - - ValidVisitCount = t.SubjectVisitTaskList.AsQueryable().Where(visitTaskFilter).GroupBy(t => new { t.SubjectId, t.VisitTaskNum }).Where(g => g.Count() == 2).Count(), - - VisitTaskList = t.SubjectVisitTaskList.AsQueryable().Where(visitTaskFilter) - .Select(c => new VisitTaskGroupSimpleDTO() - { - ReadingCategory = c.ReadingCategory, - ReadingTaskState = c.ReadingTaskState, - TaskBlindName = c.TaskBlindName, - TaskName = c.TaskName, - TaskState = c.TaskState, - SubjectId = c.SubjectId, - VisitTaskNum = c.VisitTaskNum, - TrialId = c.TrialId, - DoctorUserId = c.DoctorUserId, - - SourceSubjectVisitId = c.SourceSubjectVisitId, - SouceReadModuleId = c.SouceReadModuleId, - - TrialReadingCriterionId = c.TrialReadingCriterionId, - IsClinicalDataSign = c.IsClinicalDataSign, - IsNeedClinicalDataSign = c.IsNeedClinicalDataSign, - - }).ToList() - - // - }); - - query = query.OrderByDescending(t => t.IsHaveGeneratedTask); - - return query; - } - - - - - [HttpPost] - public async Task GetConsistentRule(TaskConsistentRuleQuery inQuery) - { - return await _taskConsistentRuleRepository.Where(t => t.TrialId == inQuery.TrialId && t.IsSelfAnalysis == inQuery.IsSelfAnalysis && t.TrialReadingCriterionId==inQuery.TrialReadingCriterionId).ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync(); - } - - /// - /// 自身一致性分配 配置+ 统计已经生成数量统计表 - /// - /// - /// - [HttpPost] - public async Task> GetSelfConsistentDoctorStatList(TaskConsistentRuleQuery inQuery) - { - var trialId = inQuery.TrialId; - - var taskConsistentRuleQueryable = from enroll in _repository.Where(t => t.TrialId == trialId && t.EnrollStatus==EnrollStatus.ConfirmIntoGroup) - join user in _repository.Where() on enroll.DoctorId equals user.DoctorId - join taskConsistentRule in _repository.Where(t => t.TrialId == trialId &&t.TrialReadingCriterionId==inQuery.TrialReadingCriterionId && t.IsSelfAnalysis) on enroll.TrialId equals taskConsistentRule.TrialId - select new TaskConsistentRuleView() - { - Id = taskConsistentRule.Id, - CreateTime = taskConsistentRule.CreateTime, - BlindTrialSiteCode = taskConsistentRule.BlindTrialSiteCode, - BlindSubjectNumberOfPlaces = taskConsistentRule.BlindSubjectNumberOfPlaces, - CreateUserId = taskConsistentRule.CreateUserId, - IntervalWeeks = taskConsistentRule.IntervalWeeks, - IsEnable = taskConsistentRule.IsEnable, - PlanSubjectCount = taskConsistentRule.PlanSubjectCount, - Note = taskConsistentRule.Note, - TrialId = taskConsistentRule.TrialId, - UpdateTime = taskConsistentRule.UpdateTime, - UpdateUserId = taskConsistentRule.UpdateUserId, - IsGenerateGlobalTask = taskConsistentRule.IsGenerateGlobalTask, - IsHaveReadingPeriod = taskConsistentRule.IsHaveReadingPeriod, - PlanVisitCount = taskConsistentRule.PlanVisitCount, - - GeneratedSubjectCount = taskConsistentRule.Trial.VisitTaskList.Where(t => t.IsAnalysisCreate && t.TrialReadingCriterionId == inQuery.TrialReadingCriterionId && t.IsSelfAnalysis == true && t.DoctorUserId == user.Id).Select(t => t.SubjectId).Distinct().Count(), - - AnalysisDoctorUser = new UserSimpleInfo() - { - UserId = user.Id, - UserCode = user.UserCode, - FullName = user.FullName, - UserName = user.UserName - } - }; - - - - //if (await _taskConsistentRuleRepository.AnyAsync(t => t.TrialId == inQuery.TrialId)) - //{ - // var rule = await _taskConsistentRuleRepository.Where(t => t.TrialId == inQuery.TrialId).ProjectTo(_mapper.ConfigurationProvider).FirstAsync(); - - // rule.IsBatchAdd = true; - - // await BatchAddOrUpdateTaskConsistentRule(rule); - //} - - //#endregion - - //var taskConsistentRuleQueryable = _taskConsistentRuleRepository.Where(t => t.TrialId == inQuery.TrialId) - // .ProjectTo(_mapper.ConfigurationProvider); - - return await taskConsistentRuleQueryable.ToListAsync(); - } - - - - - [TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })] - - public async Task AddOrUpdateTaskConsistentRule(TaskConsistentRuleAddOrEdit addOrEditTaskConsistentRule) - { - - var verifyExp1 = new EntityVerifyExp() - { - VerifyExp = t => t.TrialId == addOrEditTaskConsistentRule.TrialId && t.IsSelfAnalysis == addOrEditTaskConsistentRule.IsSelfAnalysis && t.TrialReadingCriterionId==addOrEditTaskConsistentRule.TrialReadingCriterionId, - //"已有该项目配置,不允许继续增加" - VerifyMsg = _localizer["TaskConsistent_TaskGenerated"] - }; - - if (await _visitTaskRepository.AnyAsync(t => t.IsSelfAnalysis == addOrEditTaskConsistentRule.IsSelfAnalysis && t.TrialId == addOrEditTaskConsistentRule.TrialId && t.TrialReadingCriterionId == addOrEditTaskConsistentRule.TrialReadingCriterionId)) - { - //"该标准已有Subject 生成了任务,不允许修改配置" - return ResponseOutput.NotOk(_localizer["TaskConsistent_MedicalAuditTaskExists"]); - } - - var entity = await _taskConsistentRuleRepository.InsertOrUpdateAsync(addOrEditTaskConsistentRule, true, verifyExp1); - - return ResponseOutput.Ok(entity.Id.ToString()); - - } - - [TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })] - - [HttpDelete("{taskConsistentRuleId:guid}")] - public async Task DeleteTaskConsistentRule(Guid taskConsistentRuleId) - { - var config = await _taskConsistentRuleRepository.FirstOrDefaultAsync(t => t.Id == taskConsistentRuleId); - - - if (await _visitTaskRepository.AnyAsync(t => t.IsAnalysisCreate && t.TrialId == config.TrialId && t.IsSelfAnalysis == config.IsSelfAnalysis && t.TrialReadingCriterionId==config.TrialReadingCriterionId)) - { - //"该标准已产生一致性分析任务,不允许删除" - throw new BusinessValidationFailedException(_localizer["TaskConsistent_SignedTaskCannotBeInvalidated"]); - } - - - - var success = await _taskConsistentRuleRepository.DeleteFromQueryAsync(t => t.Id == taskConsistentRuleId, true); - return ResponseOutput.Ok(); - } - - - - - - } -} diff --git a/IRaCIS.Core.Application/Service/Allocation/VisitTaskHelpeService.cs b/IRaCIS.Core.Application/Service/Allocation/VisitTaskHelpeService.cs index 0a151eda4..263f052c9 100644 --- a/IRaCIS.Core.Application/Service/Allocation/VisitTaskHelpeService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/VisitTaskHelpeService.cs @@ -34,8 +34,6 @@ namespace IRaCIS.Core.Application.Service private readonly IEasyCachingProvider _provider; private readonly IRepository _subjectVisitRepository; private readonly IRepository _readingJudgeInfoRepository; - private readonly IRepository _taskAllocationRuleRepository; - private readonly IRepository _subjectUserRepository; private readonly IRepository _readModuleRepository; private readonly IRepository _readingTaskQuestionAnswerRepository; private readonly IRepository _readingTableAnswerRowInfoRepository; @@ -51,10 +49,9 @@ namespace IRaCIS.Core.Application.Service private readonly IRepository _trialClinicalDataSetRepository; private readonly IRepository _readingClinicalDataRepository; - private readonly IRepository _subjectCriteriaEvaluationRepository; - public VisitTaskHelpeService(IRepository visitTaskRepository, IRepository subjectUserRepository, IRepository trialRepository, IEasyCachingProvider provider, + public VisitTaskHelpeService(IRepository visitTaskRepository, IRepository trialRepository, IEasyCachingProvider provider, IRepository subjectVisitRepository, IRepository readModuleRepository, IRepository readingTaskQuestionAnswerRepository, @@ -63,9 +60,9 @@ namespace IRaCIS.Core.Application.Service IRepository readingTableQuestionTrialRepository, IRepository readingQuestionTrialRepository, IRepository readingJudgeInfoRepository, - IRepository taskAllocationRuleRepository, IMapper mapper, IUserInfo userInfo, IRepository visitTaskReReadingRepository, - IRepository trialReadingCriterionRepository, IRepository trialClinicalDataSetRepository, IRepository readingClinicalDataRepository, - IRepository subjectCriteriaEvaluationRepository) + IMapper mapper, IUserInfo userInfo, IRepository visitTaskReReadingRepository, + IRepository trialReadingCriterionRepository, IRepository trialClinicalDataSetRepository, IRepository readingClinicalDataRepository + ) { _readingClinicalDataRepository = readingClinicalDataRepository; _trialClinicalDataSetRepository = trialClinicalDataSetRepository; @@ -81,12 +78,9 @@ namespace IRaCIS.Core.Application.Service _provider = provider; _subjectVisitRepository = subjectVisitRepository; this._readingJudgeInfoRepository = readingJudgeInfoRepository; - _taskAllocationRuleRepository = taskAllocationRuleRepository; - _subjectUserRepository = subjectUserRepository; _mapper = mapper; _userInfo = userInfo; _visitTaskReReadingRepository = visitTaskReReadingRepository; - _subjectCriteriaEvaluationRepository = subjectCriteriaEvaluationRepository; _trialReadingCriterionRepository = trialReadingCriterionRepository; } @@ -186,7 +180,6 @@ namespace IRaCIS.Core.Application.Service foreach (var subjectGroup in needGenerateVisit.GroupBy(t => t.SubjectId).Select(g => new { SubjectId = g.Key, SubjectVisitList = g.ToList() })) { - var assignConfigList = await _subjectUserRepository.Where(t => t.TrialId == trialId && t.TrialReadingCriterionId == trialReadingCriterionConfig.TrialReadingCriterionId && t.SubjectId == subjectGroup.SubjectId && t.OrignalSubjectUserId == null && t.IsConfirmed).Select(u => new { u.DoctorUserId, u.ArmEnum }).ToListAsync(); @@ -314,24 +307,6 @@ namespace IRaCIS.Core.Application.Service var defaultState = trialReadingCriterionConfig.FollowVisitAutoAssignDefaultState == TaskAllocateDefaultState.InitAllocated ? TaskAllocationState.InitAllocated : TaskAllocationState.Allocated; - if (assignConfigList.Any(t => t.ArmEnum == Arm.DoubleReadingArm1) && task1 != null) - { - task1.TaskAllocationState = defaultState; - //分配给对应Arm的人 - task1.DoctorUserId = assignConfigList.FirstOrDefault(t => t.ArmEnum == Arm.DoubleReadingArm1).DoctorUserId; - task1.AllocateTime = DateTime.Now; - - task1.SuggesteFinishedTime = GetSuggessFinishTime(true, UrgentType.NotUrget); - } - - if (assignConfigList.Any(t => t.ArmEnum == Arm.DoubleReadingArm2) && task2 != null) - { - task2.TaskAllocationState = defaultState; - task2.DoctorUserId = assignConfigList.FirstOrDefault(t => t.ArmEnum == Arm.DoubleReadingArm2).DoctorUserId; - task2.AllocateTime = DateTime.Now; - task2.SuggesteFinishedTime = GetSuggessFinishTime(true, UrgentType.NotUrget); - } - } else if (trialReadingCriterionConfig.ReadingType == ReadingMethod.Single) { @@ -374,20 +349,6 @@ namespace IRaCIS.Core.Application.Service var defaultState = trialReadingCriterionConfig.FollowVisitAutoAssignDefaultState == TaskAllocateDefaultState.InitAllocated ? TaskAllocationState.InitAllocated : TaskAllocationState.Allocated; - if (assignConfigList.Any(t => t.ArmEnum == Arm.SingleReadingArm)) - { - singleTask.TaskAllocationState = defaultState; - - singleTask.DoctorUserId = assignConfigList.FirstOrDefault(t => t.ArmEnum == Arm.SingleReadingArm).DoctorUserId; - - singleTask.AllocateTime = DateTime.Now; - - singleTask.SuggesteFinishedTime = GetSuggessFinishTime(true, UrgentType.NotUrget); - } - - - - } await _visitTaskRepository.SaveChangesAsync(); @@ -655,7 +616,7 @@ namespace IRaCIS.Core.Application.Service { - var assignConfigList = await _subjectUserRepository.Where(t => t.TrialId == trialId && t.TrialReadingCriterionId == trialReadingCriterionConfig.TrialReadingCriterionId && t.SubjectId == subjectVisit.SubjectId && t.OrignalSubjectUserId == null && t.IsConfirmed).Select(u => new { u.DoctorUserId, u.ArmEnum }).ToListAsync(); + //var assignConfigList = await _subjectUserRepository.Where(t => t.TrialId == trialId && t.TrialReadingCriterionId == trialReadingCriterionConfig.TrialReadingCriterionId && t.SubjectId == subjectVisit.SubjectId && t.OrignalSubjectUserId == null && t.IsConfirmed).Select(u => new { u.DoctorUserId, u.ArmEnum }).ToListAsync(); var blindTaskName = string.Empty; @@ -771,269 +732,7 @@ namespace IRaCIS.Core.Application.Service } else { - //并且配置了医生 - if (assignConfigList.Count > 0 && trialReadingCriterionConfig.IsFollowVisitAutoAssign) - { - - #region 后续访视 未分配的进行再次分配,重置的或者失效的 需要重新生成新的任务 (PM 有序退回 或者PM 有序 申请重阅) - - - if (trialReadingCriterionConfig.IsReadingTaskViewInOrder) - { - //之前有回退到影像上传的访视 那么当前访视一致性核查通过的时候,当前访视生成但是不分配出去(排除失访的) - - var beforeBackVisitTask = await _visitTaskRepository.Where(t => t.TrialId == trialId && t.TrialReadingCriterionId == trialReadingCriterionConfig.TrialReadingCriterionId && t.SubjectId == subjectVisit.SubjectId && t.VisitTaskNum < subjectVisit.VisitNum && t.ReadingCategory == ReadingCategory.Visit && t.SourceSubjectVisit.CheckState != CheckStateEnum.CVPassed && t.SourceSubjectVisit.IsLostVisit == false).OrderBy(t => t.VisitTaskNum).FirstOrDefaultAsync(); - - //之前有回退的,那么当前访视任务生成但是不分配 - if (beforeBackVisitTask != null) - { - //不用进行额外处理 - - //访视2 PM 回退 基线回退 访视2先一致性核查通过,生成访视2任务,但是不分配 - } - else - { - #region 当前访视根据配置规则分配出去 - - var defaultState = trialReadingCriterionConfig.FollowVisitAutoAssignDefaultState == TaskAllocateDefaultState.InitAllocated ? TaskAllocationState.InitAllocated : TaskAllocationState.Allocated; - - if (assignConfigList.Any(t => t.ArmEnum == Arm.DoubleReadingArm1) && task1 != null) - { - task1.TaskAllocationState = defaultState; - //分配给对应Arm的人 - task1.DoctorUserId = assignConfigList.FirstOrDefault(t => t.ArmEnum == Arm.DoubleReadingArm1).DoctorUserId; - task1.AllocateTime = DateTime.Now; - - task1.SuggesteFinishedTime = GetSuggessFinishTime(true, UrgentType.NotUrget); - } - - if (assignConfigList.Any(t => t.ArmEnum == Arm.DoubleReadingArm2) && task2 != null) - { - task2.TaskAllocationState = defaultState; - task2.DoctorUserId = assignConfigList.FirstOrDefault(t => t.ArmEnum == Arm.DoubleReadingArm2).DoctorUserId; - task2.AllocateTime = DateTime.Now; - task2.SuggesteFinishedTime = GetSuggessFinishTime(true, UrgentType.NotUrget); - } - - #endregion - } - - //后续最近的未一致性核查通过的访视任务 - var followBackVisitTask = await _visitTaskRepository.Where(t => t.TrialId == trialId && t.TrialReadingCriterionId == trialReadingCriterionConfig.TrialReadingCriterionId && t.SubjectId == subjectVisit.SubjectId && t.VisitTaskNum > subjectVisit.VisitNum && t.ReadingCategory == ReadingCategory.Visit && t.SourceSubjectVisit.CheckState != CheckStateEnum.CVPassed && t.SourceSubjectVisit.IsLostVisit == false).OrderBy(t => t.VisitTaskNum).FirstOrDefaultAsync(); - - //大于当前访视 同时小于最近的未一致性核查通过的访视任务分配 或者生成 - - //存在退回访视1 又退回基线 这种情况 生成任务 考虑基线先一致性核查通过,但是访视1还未通过时 生成任务 - var followVisitTaskList = await _visitTaskRepository - .Where(t => t.TrialId == trialId && t.TrialReadingCriterionId == trialReadingCriterionConfig.TrialReadingCriterionId && t.SubjectId == subjectVisit.SubjectId && t.VisitTaskNum > subjectVisit.VisitNum && t.SourceSubjectVisit.CheckState == CheckStateEnum.CVPassed && t.ReadingCategory == ReadingCategory.Visit && t.IsAnalysisCreate == false, true) - .WhereIf(followBackVisitTask != null, t => t.VisitTaskNum < followBackVisitTask.VisitTaskNum) - .ToListAsync(); - - var followVisitGroup = followVisitTaskList.GroupBy(t => t.VisitTaskNum); - - //每个访视去判断 是分配还是生成(因为影响哪里有些是取消分配,有些是重阅重置需要重新生成) - foreach (var visitGroup in followVisitGroup) - { - - var visit = await _subjectVisitRepository.Where(x => x.Id == visitGroup.First().SourceSubjectVisitId).Select(x => new - { - x.PDState, - x.IsEnrollmentConfirm, - x.IsUrgent, - }).FirstNotNullAsync(); - - - TaskUrgentType? urgentType = null; - - if (subjectVisitInfo.PDState == PDStateEnum.PDProgress) - { - urgentType = TaskUrgentType.PDProgress; - } - else if (subjectVisitInfo.IsEnrollmentConfirm) - { - urgentType = TaskUrgentType.EnrollmentConfirm; - } - else if (subjectVisitInfo.IsUrgent) - { - urgentType = TaskUrgentType.VisitUrgent; - } - - bool isCanEdit = urgentType == TaskUrgentType.EnrollmentConfirm || urgentType == TaskUrgentType.PDProgress ? false : true; - - //如果后续访视已分配有效 就不用处理 - if (visitGroup.Any(t => t.TaskState == TaskState.Effect && t.TaskAllocationState == TaskAllocationState.Allocated && t.ArmEnum == Arm.DoubleReadingArm1)) - { - //不做处理 - } - else - { - var arm1 = visitGroup.FirstOrDefault(t => t.TaskState == TaskState.Effect && t.TaskAllocationState == TaskAllocationState.NotAllocate && t.DoctorUserId == null && t.ArmEnum == Arm.DoubleReadingArm1); - - if (arm1 != null) - { - - //有可能仅仅只分配了一个Subject 未分配 那么 - if (assignConfigList.Any(t => t.ArmEnum == Arm.DoubleReadingArm1) && task1 != null) - { - arm1.IsUrgent = visit.IsUrgent; - arm1.TaskUrgentType = urgentType; - arm1.IsCanEditUrgentState = isCanEdit; - arm1.TaskAllocationState = TaskAllocationState.Allocated; - arm1.AllocateTime = DateTime.Now; - arm1.DoctorUserId = task1.DoctorUserId; - arm1.SuggesteFinishedTime = GetSuggessFinishTime(true, UrgentType.NotUrget); - } - - } - else - { - var latestTask = visitGroup.Where(t => t.ArmEnum == Arm.DoubleReadingArm1).OrderByDescending(t => t.CreateTime).First(); - - - - - var taskOne = await _visitTaskRepository.AddAsync(new VisitTask() - { - TrialId = trialId, - SubjectId = subjectVisit.SubjectId, - IsUrgent = visit.IsUrgent, - TaskUrgentType = urgentType, - IsCanEditUrgentState = isCanEdit, - ArmEnum = Arm.DoubleReadingArm1,//特殊 - Code = currentMaxCodeInt + 1, - TaskCode = AppSettings.GetCodeStr(currentMaxCodeInt + 1, nameof(VisitTask)), - ReadingCategory = ReadingCategory.Visit, - - SourceSubjectVisitId = latestTask.SourceSubjectVisitId, - VisitTaskNum = latestTask.VisitTaskNum, - TaskBlindName = visitBlindConfig.BlindFollowUpPrefix + " " + visitNumList.IndexOf(latestTask.VisitTaskNum), - TaskName = latestTask.TaskName, - - BlindSubjectCode = latestTask.BlindSubjectCode, - BlindTrialSiteCode = latestTask.BlindTrialSiteCode, - IsAnalysisCreate = latestTask.IsAnalysisCreate, - IsSelfAnalysis = latestTask.IsSelfAnalysis, - TaskAllocationState = TaskAllocationState.Allocated, - AllocateTime = DateTime.Now, - DoctorUserId = task1.DoctorUserId, - SuggesteFinishedTime = GetSuggessFinishTime(true, UrgentType.NotUrget), - TrialReadingCriterionId = latestTask.TrialReadingCriterionId, - IsNeedClinicalDataSign = latestTask.IsNeedClinicalDataSign, - IsClinicalDataSign = latestTask.IsClinicalDataSign - }); - - currentMaxCodeInt = currentMaxCodeInt + 1; - - _provider.Set($"{trialId}_{StaticData.CacheKey.TaskMaxCode}", currentMaxCodeInt, TimeSpan.FromMinutes(30)); - } - - } - - //如果后续访视已分配有效 就不用处理 - if (visitGroup.Any(t => t.TaskState == TaskState.Effect && t.TaskAllocationState == TaskAllocationState.Allocated && t.ArmEnum == Arm.DoubleReadingArm2)) - { - //不做处理 - } - else - { - var arm2 = visitGroup.FirstOrDefault(t => t.TaskState == TaskState.Effect && t.TaskAllocationState == TaskAllocationState.NotAllocate && t.DoctorUserId == null && t.ArmEnum == Arm.DoubleReadingArm2); - if (arm2 != null) - { - //有可能仅仅只分配了一个Subject - if (assignConfigList.Any(t => t.ArmEnum == Arm.DoubleReadingArm2) && task2 != null) - { - arm2.IsUrgent = visit.IsUrgent; - arm2.TaskUrgentType = urgentType; - arm2.IsCanEditUrgentState = isCanEdit; - arm2.TaskAllocationState = TaskAllocationState.Allocated; - arm2.AllocateTime = DateTime.Now; - arm2.DoctorUserId = task2.DoctorUserId; - arm2.SuggesteFinishedTime = GetSuggessFinishTime(true, UrgentType.NotUrget); - } - - } - else - { - var latestTask = visitGroup.Where(t => t.ArmEnum == Arm.DoubleReadingArm2).OrderByDescending(t => t.CreateTime).First(); - - var taskTwo = await _visitTaskRepository.AddAsync(new VisitTask() - { - TrialId = trialId, - SubjectId = subjectVisit.SubjectId, - IsUrgent = visit.IsUrgent, - TaskUrgentType = urgentType, - IsCanEditUrgentState = isCanEdit, - - //CheckPassedTime = subjectVisit.CheckPassedTime, - ArmEnum = Arm.DoubleReadingArm2,//特殊 - Code = currentMaxCodeInt + 1, - TaskCode = AppSettings.GetCodeStr(currentMaxCodeInt + 1, nameof(VisitTask)), - ReadingCategory = ReadingCategory.Visit, - - SourceSubjectVisitId = latestTask.SourceSubjectVisitId, - VisitTaskNum = latestTask.VisitTaskNum, - TaskBlindName = visitBlindConfig.BlindFollowUpPrefix + " " + visitNumList.IndexOf(latestTask.VisitTaskNum), - TaskName = latestTask.TaskName, - - BlindSubjectCode = latestTask.BlindSubjectCode, - BlindTrialSiteCode = latestTask.BlindTrialSiteCode, - IsAnalysisCreate = latestTask.IsAnalysisCreate, - IsSelfAnalysis = latestTask.IsSelfAnalysis, - TaskAllocationState = TaskAllocationState.Allocated, - - AllocateTime = DateTime.Now, - DoctorUserId = task2.DoctorUserId, - SuggesteFinishedTime = GetSuggessFinishTime(true, UrgentType.NotUrget), - - TrialReadingCriterionId = latestTask.TrialReadingCriterionId, - IsNeedClinicalDataSign = latestTask.IsNeedClinicalDataSign, - IsClinicalDataSign = latestTask.IsClinicalDataSign - }); - - currentMaxCodeInt = currentMaxCodeInt + 1; - - _provider.Set($"{trialId}_{StaticData.CacheKey.TaskMaxCode}", currentMaxCodeInt, TimeSpan.FromMinutes(30)); - } - } - - } - - - } - //无序的时候 生成任务并分配出去 - else - { - var defaultState = trialReadingCriterionConfig.FollowVisitAutoAssignDefaultState == TaskAllocateDefaultState.InitAllocated ? TaskAllocationState.InitAllocated : TaskAllocationState.Allocated; - - if (assignConfigList.Any(t => t.ArmEnum == Arm.DoubleReadingArm1) && task1 != null) - { - task1.TaskAllocationState = defaultState; - //分配给对应Arm的人 - task1.DoctorUserId = assignConfigList.FirstOrDefault(t => t.ArmEnum == Arm.DoubleReadingArm1).DoctorUserId; - task1.AllocateTime = DateTime.Now; - - task1.SuggesteFinishedTime = GetSuggessFinishTime(true, UrgentType.NotUrget); - } - - if (assignConfigList.Any(t => t.ArmEnum == Arm.DoubleReadingArm2) && task2 != null) - { - task2.TaskAllocationState = defaultState; - task2.DoctorUserId = assignConfigList.FirstOrDefault(t => t.ArmEnum == Arm.DoubleReadingArm2).DoctorUserId; - task2.AllocateTime = DateTime.Now; - task2.SuggesteFinishedTime = GetSuggessFinishTime(true, UrgentType.NotUrget); - } - - } - - - #endregion - - } - else - //后续访视不自动分配,或者配置的医生数量不足,就不进行分配 - { - - } + } @@ -1101,148 +800,7 @@ namespace IRaCIS.Core.Application.Service //} - //配置了医生 - if (assignConfigList.Count > 0) - { - - #region 重阅/退回的时候,需要将取消分配的访视类型的 任务重新分配 - - if (trialReadingCriterionConfig.IsReadingTaskViewInOrder) - { - //之前有回退到影像上传的访视 那么当前访视一致性核查通过的时候,当前访视生成但是不分配出去(排除失访的) - var beforeBackVisitTask = await _visitTaskRepository.Where(t => t.TrialId == trialId && t.SubjectId == subjectVisit.SubjectId && t.VisitTaskNum < subjectVisit.VisitNum && t.ReadingCategory == ReadingCategory.Visit && t.SourceSubjectVisit.CheckState != CheckStateEnum.CVPassed && t.SourceSubjectVisit.IsLostVisit == false).OrderBy(t => t.VisitTaskNum).FirstOrDefaultAsync(); - - - if (beforeBackVisitTask == null) - { - #region 访视2 PM 回退 基线回退 访视2先一致性核查通过,生成访视2任务,但是不分配 - - var defaultState = trialReadingCriterionConfig.FollowVisitAutoAssignDefaultState == TaskAllocateDefaultState.InitAllocated ? TaskAllocationState.InitAllocated : TaskAllocationState.Allocated; - - - if (assignConfigList.Any(t => t.ArmEnum == Arm.SingleReadingArm)) - { - singleTask.TaskAllocationState = defaultState; - - singleTask.DoctorUserId = assignConfigList.FirstOrDefault(t => t.ArmEnum == Arm.SingleReadingArm).DoctorUserId; - - singleTask.AllocateTime = DateTime.Now; - - singleTask.SuggesteFinishedTime = GetSuggessFinishTime(true, UrgentType.NotUrget); - } - - - #endregion - - - var followBackVisitTask = await _visitTaskRepository.Where(t => t.TrialId == trialId && t.SubjectId == subjectVisit.SubjectId && t.VisitTaskNum > subjectVisit.VisitNum && t.ReadingCategory == ReadingCategory.Visit && t.SourceSubjectVisit.CheckState != CheckStateEnum.CVPassed && t.SourceSubjectVisit.IsLostVisit == false).OrderBy(t => t.VisitTaskNum).FirstOrDefaultAsync(); - - //存在退回访视1 又退回基线 这种情况 生成任务 考虑基线先一致性核查通过,但是访视1还未通过时 生成任务 - var followVisitTaskList = await _visitTaskRepository - .Where(t => t.TrialId == trialId && t.SubjectId == subjectVisit.SubjectId && t.VisitTaskNum > subjectVisit.VisitNum && t.SourceSubjectVisit.CheckState == CheckStateEnum.CVPassed && t.ReadingCategory == ReadingCategory.Visit && t.IsAnalysisCreate == false, true) - .WhereIf(followBackVisitTask != null, t => t.VisitTaskNum < followBackVisitTask.VisitTaskNum) - .ToListAsync(); - - var followVisitGroup = followVisitTaskList.GroupBy(t => t.VisitTaskNum); - - //每个访视去判断 是分配还是生成 - - - foreach (var visitGroup in followVisitGroup) - { - //如果后续访视已分配有效 就不用处理 - if (visitGroup.Any(t => t.TaskState == TaskState.Effect && t.TaskAllocationState == TaskAllocationState.Allocated && t.ArmEnum == Arm.SingleReadingArm)) - { - //不做处理 - } - - else - { - var arm = visitGroup.FirstOrDefault(t => t.TaskState == TaskState.Effect && t.TaskAllocationState == TaskAllocationState.NotAllocate && t.DoctorUserId == null && t.ArmEnum == Arm.SingleReadingArm); - if (arm != null) - { - arm.TaskAllocationState = TaskAllocationState.Allocated; - arm.AllocateTime = DateTime.Now; - arm.DoctorUserId = singleTask.DoctorUserId; - arm.SuggesteFinishedTime = GetSuggessFinishTime(true, UrgentType.NotUrget); - } - else - { - var latestTask = visitGroup.Where(t => t.ArmEnum == Arm.SingleReadingArm).OrderByDescending(t => t.CreateTime).First(); - - var taskOne = await _visitTaskRepository.AddAsync(new VisitTask() - { - TrialId = trialId, - SubjectId = subjectVisit.SubjectId, - IsUrgent = subjectVisit.IsUrgent, - ArmEnum = Arm.SingleReadingArm,//特殊 - Code = currentMaxCodeInt + 1, - TaskCode = AppSettings.GetCodeStr(currentMaxCodeInt + 1, nameof(VisitTask)), - ReadingCategory = ReadingCategory.Visit, - TaskUrgentType = latestTask.TaskUrgentType, - SourceSubjectVisitId = latestTask.SourceSubjectVisitId, - VisitTaskNum = latestTask.VisitTaskNum, - TaskBlindName = visitBlindConfig.BlindFollowUpPrefix + " " + visitNumList.IndexOf(latestTask.VisitTaskNum), - TaskName = latestTask.TaskName, - - BlindSubjectCode = latestTask.BlindSubjectCode, - BlindTrialSiteCode = latestTask.BlindTrialSiteCode, - IsAnalysisCreate = latestTask.IsAnalysisCreate, - IsSelfAnalysis = latestTask.IsSelfAnalysis, - TaskAllocationState = TaskAllocationState.Allocated, - AllocateTime = DateTime.Now, - DoctorUserId = singleTask.DoctorUserId, - SuggesteFinishedTime = GetSuggessFinishTime(true, UrgentType.NotUrget), - - TrialReadingCriterionId = latestTask.TrialReadingCriterionId, - IsNeedClinicalDataSign = latestTask.IsNeedClinicalDataSign, - IsClinicalDataSign = latestTask.IsClinicalDataSign - - }); - - currentMaxCodeInt = currentMaxCodeInt + 1; - - _provider.Set($"{trialId}_{StaticData.CacheKey.TaskMaxCode}", currentMaxCodeInt, TimeSpan.FromMinutes(30)); - } - } - - - } - - } - //之前有回退的 后续访视不生成或者分配 当前访视生成但是不分配出去 - else - { - - //不用进行额外处理 - } - - - - } - //无序的时候 生成任务并分配出去 - else - { - var defaultState = trialReadingCriterionConfig.FollowVisitAutoAssignDefaultState == TaskAllocateDefaultState.InitAllocated ? TaskAllocationState.InitAllocated : TaskAllocationState.Allocated; - - - if (assignConfigList.Any(t => t.ArmEnum == Arm.SingleReadingArm)) - { - singleTask.TaskAllocationState = defaultState; - - singleTask.DoctorUserId = assignConfigList.FirstOrDefault(t => t.ArmEnum == Arm.SingleReadingArm).DoctorUserId; - - singleTask.AllocateTime = DateTime.Now; - - singleTask.SuggesteFinishedTime = GetSuggessFinishTime(true, UrgentType.NotUrget); - } - - - } - - #endregion - - } + } } else @@ -1493,7 +1051,7 @@ namespace IRaCIS.Core.Application.Service case GenerateTaskCategory.Judge: var firstTask = await _visitTaskRepository.Where(x => generateTaskCommand.JudgeVisitTaskIdList.Contains(x.Id)).FirstOrDefaultAsync(); - var subjectUser = await _subjectUserRepository.Where(x => x.SubjectId == firstTask.SubjectId && x.ArmEnum == Arm.JudgeArm && x.IsConfirmed && x.TrialReadingCriterionId == firstTask.TrialReadingCriterionId).FirstOrDefaultAsync(); + VisitTask visitTask = new VisitTask() { @@ -1512,10 +1070,6 @@ namespace IRaCIS.Core.Application.Service TaskCode = AppSettings.GetCodeStr(currentMaxCodeInt + 1, nameof(VisitTask)), TaskState = TaskState.Effect, TaskBlindName = firstTask.TaskBlindName, - DoctorUserId = subjectUser == null ? null : subjectUser.DoctorUserId, - TaskAllocationState = subjectUser == null ? TaskAllocationState.NotAllocate : TaskAllocationState.Allocated, - AllocateTime = subjectUser == null ? null : DateTime.Now, - SuggesteFinishedTime = subjectUser == null ? null : GetSuggessFinishTime(true, UrgentType.NotUrget), TrialReadingCriterionId = firstTask.TrialReadingCriterionId, @@ -1598,8 +1152,7 @@ namespace IRaCIS.Core.Application.Service foreach (var item in generateTaskCommand.ReadingGenerataTaskList) { - //需要 根据标准筛选 - var oncologySubjectUser = await _subjectUserRepository.Where(x => x.SubjectId == item.SubjectId && x.ArmEnum == Arm.TumorArm && x.IsConfirmed && x.TrialReadingCriterionId == originalTaskInfo.TrialReadingCriterionId).FirstOrDefaultAsync(); + item.VisitNum = await _readModuleRepository.Where(x => x.Id == item.ReadModuleId).Select(x => x.SubjectVisit.VisitNum).FirstOrDefaultAsync(); @@ -1618,10 +1171,7 @@ namespace IRaCIS.Core.Application.Service SouceReadModuleId = item.ReadModuleId, TaskBlindName = item.ReadingName, - DoctorUserId = oncologySubjectUser == null ? null : oncologySubjectUser.DoctorUserId, - AllocateTime = oncologySubjectUser == null ? null : DateTime.Now, - TaskAllocationState = oncologySubjectUser == null ? TaskAllocationState.NotAllocate : TaskAllocationState.Allocated, - SuggesteFinishedTime = oncologySubjectUser == null ? null : GetSuggessFinishTime(true, UrgentType.NotUrget), + TaskCode = AppSettings.GetCodeStr(currentMaxCodeInt + 1, nameof(VisitTask)), ReadingCategory = item.ReadingCategory, diff --git a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs index 7f0a3004e..d70a1bcc7 100644 --- a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs @@ -37,9 +37,7 @@ namespace IRaCIS.Core.Application.Service.Allocation private readonly IRepository _visitTaskRepository; private readonly IRepository _trialRepository; private readonly IRepository _subjectVisitRepository; - private readonly IRepository _taskAllocationRuleRepository; private readonly IRepository _subjectRepository; - private readonly IRepository _subjectUserRepository; private readonly IRepository _readModuleRepository; private readonly IRepository _visitTaskReReadingRepository; @@ -47,43 +45,34 @@ namespace IRaCIS.Core.Application.Service.Allocation private readonly IRepository _readingTaskQuestionAnswerRepository; private readonly IRepository _readingClinicalDataReposiotry; - private readonly IRepository _subjectCriteriaEvaluationRepository; - private readonly IRepository _subjectCriteriaEvaluationVisitFilterRepository; + private readonly IRepository _trialReadingCriterionRepository; - private readonly IRepository _subjectCriteriaEvaluationVisitStudyFilterRepository; + private readonly IRepository _PIAuditRepository; public VisitTaskService(IRepository subjectVisitRepository, IRepository visitTaskRepository, IRepository trialRepository, - IRepository subjectRepository, IRepository subjectUserRepository, IRepository taskAllocationRuleRepository, + IRepository subjectRepository, IRepository readModuleRepository, IRepository visitTaskReReadingRepository, IRepository taskMedicalReviewRepository, IRepository readingTaskQuestionAnswerRepository , IRepository trialReadingCriterionRepository, IRepository readingClinicalDataReposiotry, - IRepository subjectCriteriaEvaluationRepository, - IRepository subjectCriteriaEvaluationVisitFilterRepository, - IRepository subjectCriteriaEvaluationVisitStudyFilterRepository, IRepository PIAuditRepository ) { _PIAuditRepository = PIAuditRepository; _readingClinicalDataReposiotry = readingClinicalDataReposiotry; - _taskAllocationRuleRepository = taskAllocationRuleRepository; _visitTaskRepository = visitTaskRepository; _trialRepository = trialRepository; _subjectVisitRepository = subjectVisitRepository; _subjectRepository = subjectRepository; - _subjectUserRepository = subjectUserRepository; _readModuleRepository = readModuleRepository; _visitTaskReReadingRepository = visitTaskReReadingRepository; _taskMedicalReviewRepository = taskMedicalReviewRepository; _readingTaskQuestionAnswerRepository = readingTaskQuestionAnswerRepository; - _trialReadingCriterionRepository = trialReadingCriterionRepository; - _subjectCriteriaEvaluationRepository = subjectCriteriaEvaluationRepository; - _subjectCriteriaEvaluationVisitFilterRepository = subjectCriteriaEvaluationVisitFilterRepository; - _subjectCriteriaEvaluationVisitStudyFilterRepository = subjectCriteriaEvaluationVisitStudyFilterRepository; + } /// @@ -1196,7 +1185,7 @@ namespace IRaCIS.Core.Application.Service.Allocation await SetMedicalReviewInvalidAsync(influenceTaskList, false); - await InfluenceAddtioncalEvaluationCritrionAsync(origenalTask, influenceTaskList.Where(t => t.Id != origenalTask.Id).Where(t => t.SourceSubjectVisitId != null).Select(t => (Guid)t.SourceSubjectVisitId).Distinct().ToList(), false); + } @@ -1597,7 +1586,7 @@ namespace IRaCIS.Core.Application.Service.Allocation if (influenceTask.Id == task.Id) { - await InfluenceAddtioncalEvaluationCritrionAsync(task, influenceTaskList.Where(t => t.Id != task.Id).Where(t => t.SourceSubjectVisitId != null).Select(t => (Guid)t.SourceSubjectVisitId).Distinct().ToList()); + await SetReReadingOrBackInfluenceAnalysisAsync(influenceTask.SubjectId); @@ -1675,65 +1664,7 @@ namespace IRaCIS.Core.Application.Service.Allocation } - /// - /// 基线退回 影响附加评估标准 是否参与评估 - /// - /// - private async Task InfluenceAddtioncalEvaluationCritrionAsync(VisitTask task, List otherVisitIdList, bool isImageBack = true) - { - - var criterion = await _trialReadingCriterionRepository.FindAsync(task.TrialReadingCriterionId); - - if (criterion.CriterionType == CriterionType.RECIST1Point1) - { - //影像回退了|| IR 申请及基线重阅 - if (_subjectVisitRepository.Any(t => t.Id == task.SourceSubjectVisitId && t.IsBaseLine)) - { - await _subjectCriteriaEvaluationRepository.UpdatePartialFromQueryAsync(t => t.TrialReadingCriterion.IsAutoCreate == false && t.SubjectId == task.SubjectId, u => new SubjectCriteriaEvaluation() - { - IsJoinEvaluation = false - }); - - //删除筛选的访视数据 - await _subjectCriteriaEvaluationVisitFilterRepository.BatchDeleteNoTrackingAsync(t => t.TrialReadingCriterion.CriterionType == CriterionType.RECIST1Pointt1_MB && t.SubjectId == task.SubjectId); - - //删除筛选的序列数据 - await _subjectCriteriaEvaluationVisitStudyFilterRepository.BatchDeleteNoTrackingAsync(t => t.TrialReadingCriterion.CriterionType == CriterionType.RECIST1Pointt1_MB && t.SubjectVisit.SubjectId == task.SubjectId); - } - else if (isImageBack) - { - //当前访视筛选状态重置,任务生成状态重置 - if (task.SourceSubjectVisitId != null) - { - await _subjectCriteriaEvaluationVisitFilterRepository.UpdatePartialFromQueryAsync(t => t.TrialReadingCriterion.CriterionType == CriterionType.RECIST1Pointt1_MB && t.SubjectVisit.SubjectId == task.SubjectId && t.SubjectVisitId == task.SourceSubjectVisitId, - t => new SubjectCriteriaEvaluationVisitFilter() - { - ImageFilterState = ImageFilterState.None, - ImageDeterminationResultState = ImageDeterminationResultState.None, - IsGeneratedTask = false - }); - - //删除序列数据 - await _subjectCriteriaEvaluationVisitStudyFilterRepository.BatchDeleteNoTrackingAsync(t => t.TrialReadingCriterion.CriterionType == CriterionType.RECIST1Pointt1_MB && t.SubjectVisit.SubjectId == task.SubjectId && t.SubjectVisitId == task.SourceSubjectVisitId); - } - - - //BM后续访视 ,筛选状态不变,任务生成状态重置(实际该访视任务状态 可能是重阅重置了或者失效了,需要后续生成,或者取消分配了,需要后续重新分配) - await _subjectCriteriaEvaluationVisitFilterRepository.UpdatePartialFromQueryAsync(t => t.TrialReadingCriterion.CriterionType == CriterionType.RECIST1Pointt1_MB && t.SubjectVisit.SubjectId == task.SubjectId && otherVisitIdList.Contains(t.SubjectVisitId), - t => new SubjectCriteriaEvaluationVisitFilter() - { - IsGeneratedTask = false - }); - } - else - { - //IR 端 非基线申请重阅 不影响 - } - } - - - - } + //包括临床数据签名状态 private async Task VisitBackAsync(Guid? subjectVisitId) diff --git a/IRaCIS.Core.Application/Service/Allocation/_MapConfig.cs b/IRaCIS.Core.Application/Service/Allocation/_MapConfig.cs index 3ff2a3733..87f49d9ca 100644 --- a/IRaCIS.Core.Application/Service/Allocation/_MapConfig.cs +++ b/IRaCIS.Core.Application/Service/Allocation/_MapConfig.cs @@ -18,93 +18,30 @@ namespace IRaCIS.Core.Application.Service CreateMap(); - CreateMap() - .ForMember(o => o.UserCode, t => t.MapFrom(u => u.DoctorUser.UserCode)) - .ForMember(o => o.UserName, t => t.MapFrom(u => u.DoctorUser.UserName)) - .ForMember(o => o.FullName, t => t.MapFrom(u => u.DoctorUser.FullName)) - .ForMember(o => o.UserTypeShortName, t => t.MapFrom(u => u.DoctorUser.UserTypeRole.UserTypeShortName)); List subjectIdList = new List(); bool isJudgeDoctor = false; - - CreateMap() - .ForMember(o => o.UserCode, t => t.MapFrom(u => u.DoctorUser.UserCode)) - .ForMember(o => o.UserName, t => t.MapFrom(u => u.DoctorUser.UserName)) - .ForMember(o => o.FullName, t => t.MapFrom(u => u.DoctorUser.FullName)) - .ForMember(o => o.UserTypeShortName, t => t.MapFrom(u => u.DoctorUser.UserTypeRole.UserTypeShortName)) - //.ForMember(o => o.ArmList, t => t.MapFrom(u => u.DoctorVisitTaskList.Where(c => c.TrialId == u.TrialId).Select(t => t.ArmEnum).Distinct())) - .ForMember(o => o.TotalTaskCount, t => t.MapFrom(u => u.Trial.VisitTaskList.Count())) - .ForMember(o => o.SelfUndoTaskCount, t => t.MapFrom(u => u.Trial.VisitTaskList.Count(t => t.DoctorUserId == u.DoctorUserId && t.ReadingTaskState != ReadingTaskState.HaveSigned))) - .ForMember(o => o.TotalSubjectCount, t => t.MapFrom(u => u.Trial.SubjectList.Count())) - .ForMember(o => o.SelfApplyedTaskCount, t => t.MapFrom(u => u.Trial.VisitTaskList.Count(t => t.DoctorUserId == u.DoctorUserId))) - .ForMember(o => o.ApplyedTotalTaskCount, t => t.MapFrom(u => u.Trial.VisitTaskList.Count(t => t.DoctorUserId != null))) - - //.ForMember(o => o.SelfApplyedSubjectCount, t => t.MapFrom(u => u.Trial.SubjectDoctorUserList.Where(t => t.DoctorUserId == u.DoctorUserId && t.SubjectArmVisitTaskList.Any(c => c.DoctorUserId != null)).Count())) - .ForMember(o => o.SelfSubjectCount, t => t.MapFrom(u => u.Trial.SubjectDoctorUserList.Where(t => t.DoctorUserId == u.DoctorUserId).Count())) - - .ForMember(o => o.ApplyedTotalSubjectCount, t => t.MapFrom(u => u.Trial.SubjectList.Count(c => c.SubjectVisitTaskList.Any(d => d.DoctorUserId != null)))) - - - - //该医生未应用Subject 数量 - //.ForMember(o => o.WaitApplySelfSubjectCount, t => t.MapFrom(u => - // subjectIdList.Count == 0 ? u.Trial.SubjectDoctorUserList.Where(t => t.DoctorUserId == u.DoctorUserId && t.SubjectArmVisitTaskList.Where(t => isJudgeDoctor ? t.ArmEnum == Arm.JudgeArm : t.ArmEnum != Arm.JudgeArm).Any(c => c.DoctorUserId == null)).Count() - // : u.Trial.SubjectDoctorUserList.Where(t => t.DoctorUserId == u.DoctorUserId && subjectIdList.Contains(t.SubjectId) && t.SubjectArmVisitTaskList.Where(t => isJudgeDoctor ? t.ArmEnum == Arm.JudgeArm : t.ArmEnum != Arm.JudgeArm).Any(c => c.DoctorUserId == null)).Count() - // )) - - - .ForMember(o => o.WaitApplyTotalSubjectCount, t => t.MapFrom(u => - subjectIdList.Count == 0 ? u.Trial.SubjectList.Where(t => t.SubjectVisitTaskList.Where(t => isJudgeDoctor ? t.ArmEnum == Arm.JudgeArm : t.ArmEnum != Arm.JudgeArm).Any(c => c.DoctorUserId == null)).Count() - : u.Trial.SubjectList.Where(t => subjectIdList.Contains(t.Id) && t.SubjectVisitTaskList.Where(t => isJudgeDoctor ? t.ArmEnum == Arm.JudgeArm : t.ArmEnum != Arm.JudgeArm).Any(c => c.DoctorUserId == null)).Count() - )) - - //.ForMember(o => o.WaitApplySelfTaskCount, t => t.MapFrom(u => - //subjectIdList.Count == 0 ? u.Trial.SubjectDoctorUserList.Where(d => d.DoctorUserId == u.DoctorUserId).SelectMany(t => t.SubjectArmVisitTaskList.Where(t => isJudgeDoctor ? t.ArmEnum == Arm.JudgeArm : t.ArmEnum != Arm.JudgeArm).Where(t => t.DoctorUserId == null)).Count() - //: u.Trial.SubjectDoctorUserList.Where(d => d.DoctorUserId == u.DoctorUserId && subjectIdList.Contains(d.SubjectId)).SelectMany(t => t.SubjectArmVisitTaskList.Where(t => isJudgeDoctor ? t.ArmEnum == Arm.JudgeArm : t.ArmEnum != Arm.JudgeArm).Where(t => t.DoctorUserId == null)).Count() - // )) - - .ForMember(o => o.WaitApplyTotalTaskCount, t => t.MapFrom(u => - subjectIdList.Count == 0 ? u.Trial.VisitTaskList.Where(t => isJudgeDoctor ? t.ArmEnum == Arm.JudgeArm : t.ArmEnum != Arm.JudgeArm).Where(t => t.DoctorUserId == null).Count() - : u.Trial.VisitTaskList.Where(t => isJudgeDoctor ? t.ArmEnum == Arm.JudgeArm : t.ArmEnum != Arm.JudgeArm).Where(t => t.DoctorUserId == null && subjectIdList.Contains(t.SubjectId)).Count())) - - ; - var trialReadingCriterionId = Guid.Empty; - CreateMap() - .ForMember(o => o.DoctorUser, t => t.MapFrom(u => u.Enroll.DoctorUser)) - .ForMember(o => o.CriterionReadingCategoryList, t => t.MapFrom(u => u.Enroll.EnrollReadingCategoryList.Select(t => new TrialCriterionReadingCategory() { EnrollId = t.EnrollId, ReadingCategory = t.ReadingCategory, TrialReadingCriterionId = t.TrialReadingCriterionId }))) - .ForMember(o => o.TrialReadingCriterionList, t => t.MapFrom(u => u.Trial.ReadingQuestionCriterionTrialList.Where(t => t.IsConfirm))) - .ForMember(o => o.ReadingCategoryList, t => t.MapFrom(u => u.Enroll.EnrollReadingCategoryList.Where(t=>t.TrialReadingCriterionId== trialReadingCriterionId).OrderBy(t => t.ReadingCategory).Select(t => t.ReadingCategory).ToList())) - ; CreateMap() .ForMember(t => t.TrialReadingCriterionId, u => u.MapFrom(c => c.Id)) .ForMember(t => t.TrialReadingCriterionName, u => u.MapFrom(c => c.CriterionName)); - CreateMap().IncludeBase() - .ForMember(o => o.AssignedSubjectCount, t => t.MapFrom(u => u.DoctorUser.VisitTaskList.Where(t => t.TrialId == u.TrialId).Select(t => t.SubjectId).Distinct().Count())) - .ForMember(o => o.WaitDealTrialTaskCount, t => t.MapFrom(u => u.DoctorUser.VisitTaskList.Where(t => t.TrialId == u.TrialId).Where(t => t.ReadingTaskState != ReadingTaskState.HaveSigned && t.TaskState == TaskState.Effect).Count())) - .ForMember(o => o.WaitDealAllTaskCount, t => t.MapFrom(u => u.DoctorUser.VisitTaskList.Where(t => t.ReadingTaskState != ReadingTaskState.HaveSigned && t.TaskState == TaskState.Effect).Count())); - - CreateMap() .ForMember(o => o.SubjectId, t => t.MapFrom(u => u.Id)) .ForMember(o => o.TrialSiteCode, t => t.MapFrom(u => u.TrialSite.TrialSiteCode)) .ForMember(o => o.SubjectCode, t => t.MapFrom(u => u.Code)) - .ForMember(o => o.VisitTaskTypeCount, t => t.MapFrom(u => u.SubjectVisitTaskList.Where(t => t.ReadingCategory == ReadingCategory.Visit && t.TrialReadingCriterionId==trialReadingCriterionId && t.TaskState==TaskState.Effect).Select(t => t.VisitTaskNum).Distinct().Count())) + .ForMember(o => o.VisitTaskTypeCount, t => t.MapFrom(u => u.SubjectVisitTaskList.Where(t => t.ReadingCategory == ReadingCategory.Visit && t.TrialReadingCriterionId == trialReadingCriterionId && t.TaskState == TaskState.Effect).Select(t => t.VisitTaskNum).Distinct().Count())) .ForMember(o => o.GlobalTaskTypeCount, t => t.MapFrom(u => u.SubjectVisitTaskList.Where(t => t.ReadingCategory == ReadingCategory.Global && t.TrialReadingCriterionId == trialReadingCriterionId && t.TaskState == TaskState.Effect).Select(t => t.VisitTaskNum).Distinct().Count())) .ForMember(o => o.OncologyTaskTypeCount, t => t.MapFrom(u => u.SubjectVisitTaskList.Where(t => t.ReadingCategory == ReadingCategory.Oncology && t.TrialReadingCriterionId == trialReadingCriterionId && t.TaskState == TaskState.Effect).Select(t => t.VisitTaskNum).Distinct().Count())) - .ForMember(o => o.JudgeTaskTypeCount, t => t.MapFrom(u => u.SubjectVisitTaskList.Where(t => t.ReadingCategory == ReadingCategory.Judge && t.TrialReadingCriterionId == trialReadingCriterionId && t.TaskState == TaskState.Effect).Select(t => t.VisitTaskNum).Distinct().Count())) - .ForMember(o => o.DoctorUserList, t => t.MapFrom(u => u.SubjectDoctorList.Where(t=>t.TrialReadingCriterionId== trialReadingCriterionId))); + .ForMember(o => o.JudgeTaskTypeCount, t => t.MapFrom(u => u.SubjectVisitTaskList.Where(t => t.ReadingCategory == ReadingCategory.Judge && t.TrialReadingCriterionId == trialReadingCriterionId && t.TaskState == TaskState.Effect).Select(t => t.VisitTaskNum).Distinct().Count())); - CreateMap() - .ForMember(o => o.DoctorUser, t => t.MapFrom(u => u.DoctorUser)); + - CreateMap().IncludeBase() - .ForMember(o => o.IsHaveReading, t => t.MapFrom(u => u.Subject.SubjectVisitTaskList.Any(t => t.ReadingTaskState != ReadingTaskState.WaitReading && t.TrialReadingCriterionId==u.TrialReadingCriterionId && t.DoctorUserId==u.DoctorUserId))); + CreateMap(); @@ -154,9 +91,7 @@ namespace IRaCIS.Core.Application.Service - CreateMap(); - - CreateMap(); + @@ -189,22 +124,17 @@ namespace IRaCIS.Core.Application.Service .ForMember(o => o.SubjectId, t => t.MapFrom(u => u.Id)) .ForMember(o => o.TrialSiteCode, t => t.MapFrom(u => u.TrialSite.TrialSiteCode)) .ForMember(o => o.SubjectCode, t => t.MapFrom(u => u.Code)) - .ForMember(o => o.IsJudge, t => t.MapFrom(u => isJudgeDoctor)) - .ForMember(o => o.IsAssignedDoctorUser, t => t.MapFrom(u => u.SubjectDoctorList.Where(t => isJudgeDoctor ? t.ArmEnum == Arm.JudgeArm : t.ArmEnum != Arm.JudgeArm).Any())) + .ForMember(o => o.IsJudge, t => t.MapFrom(u => isJudgeDoctor)); + - .ForMember(o => o.TotalDoctorUserList, t => t.MapFrom(u => u.SubjectDoctorList.Where(t => isJudgeDoctor ? true : t.ArmEnum != Arm.JudgeArm).OrderBy(t => t.ArmEnum))); - - CreateMap() - //.ForMember(o => o.AssignTime, t => t.MapFrom(u => u.AssignTime)) - .ForMember(o => o.UserCode, t => t.MapFrom(u => u.DoctorUser.UserCode)) - .ForMember(o => o.UserName, t => t.MapFrom(u => u.DoctorUser.UserName)) - .ForMember(o => o.FullName, t => t.MapFrom(u => u.DoctorUser.FullName)) - .ForMember(o => o.UserTypeShortName, t => t.MapFrom(u => u.DoctorUser.UserTypeRole.UserTypeShortName)); + - CreateMap(); + + + CreateMap() @@ -292,11 +222,6 @@ namespace IRaCIS.Core.Application.Service //CreateMap() // .ForMember(o => o.GeneratedSubjectCount, t => t.MapFrom(u => u.DoctorVisitTaskList.Where(t => t.IsAnalysisCreate && t.TaskConsistentRuleId == u.Id).Select(t => t.SubjectId).Distinct().Count())) ; - CreateMap(); - - CreateMap(); - - CreateMap().ForMember(t => t.Id, u => u.Ignore()).ReverseMap(); CreateMap() diff --git a/IRaCIS.Core.Application/Service/Common/DictionaryService.cs b/IRaCIS.Core.Application/Service/Common/DictionaryService.cs index cc5bf300d..9d5aa7e7f 100644 --- a/IRaCIS.Core.Application/Service/Common/DictionaryService.cs +++ b/IRaCIS.Core.Application/Service/Common/DictionaryService.cs @@ -16,9 +16,7 @@ namespace IRaCIS.Application.Services public class DictionaryService : BaseService, IDictionaryService { private readonly IRepository _dicRepository; - private readonly IRepository _doctorDictionaryRepository; private readonly IRepository _trialDictionaryRepository; - private readonly IRepository _doctorRepository; private readonly IRepository _trialRepository; private readonly IRepository _systemCriterionDictionaryCodeRepository; private readonly IRepository _trialCriterionDictionaryCodeRepository; @@ -29,8 +27,8 @@ namespace IRaCIS.Application.Services private readonly IRepository _readingQuestionCriterionTrial; private readonly IReadingQuestionService _readingQuestionService; - public DictionaryService(IRepository sysDicRepository, IRepository doctorDictionaryRepository, IRepository trialDictionaryRepository, - IRepository doctorRepository, IRepository trialRepository, + public DictionaryService(IRepository sysDicRepository, IRepository trialDictionaryRepository, + IRepository trialRepository, IRepository systemCriterionDictionaryCodeRepository, IRepository trialCriterionDictionaryCodeRepository, @@ -44,9 +42,9 @@ namespace IRaCIS.Application.Services ) { _dicRepository = sysDicRepository; - _doctorDictionaryRepository = doctorDictionaryRepository; + _trialDictionaryRepository = trialDictionaryRepository; - _doctorRepository = doctorRepository; + _trialRepository = trialRepository; this._systemCriterionDictionaryCodeRepository = systemCriterionDictionaryCodeRepository; this._trialCriterionDictionaryCodeRepository = trialCriterionDictionaryCodeRepository; @@ -229,14 +227,6 @@ namespace IRaCIS.Application.Services return ResponseOutput.NotOk(_localizer["Dictionary_SubitemDeletion"]); } - if ((await _doctorDictionaryRepository.AnyAsync(t => t.DictionaryId == id)) || - (await _doctorRepository.AnyAsync(t => t.SpecialityId == id || t.PositionId == id || t.DepartmentId == id || t.RankId == id)) - - ) - { - //---当前条目已经在阅片人的简历中被引用。 - return ResponseOutput.NotOk(_localizer["Dictionary_ResumeReference"]); - } if (await _trialDictionaryRepository.AnyAsync(t => t.DictionaryId == id) || await _trialRepository.AnyAsync(t => t.ReviewModeId == id)) diff --git a/IRaCIS.Core.Application/Service/Common/FileService.cs b/IRaCIS.Core.Application/Service/Common/FileService.cs index ecbce02cd..492b460f3 100644 --- a/IRaCIS.Core.Application/Service/Common/FileService.cs +++ b/IRaCIS.Core.Application/Service/Common/FileService.cs @@ -11,180 +11,25 @@ namespace IRaCIS.Application.Services public class FileService : IFileService { - private readonly IDoctorService _doctorService; - private readonly IAttachmentService _attachmentService; + private readonly IWebHostEnvironment _hostEnvironment; private string defaultUploadFilePath = string.Empty; private readonly ILogger _logger; - public FileService(IDoctorService doctorService, IAttachmentService attachmentService, + public FileService( IWebHostEnvironment hostEnvironment, ILogger logger) { - _doctorService = doctorService; - _attachmentService = attachmentService; + _hostEnvironment = hostEnvironment; defaultUploadFilePath = FileStoreHelper.GetIRaCISRootPath(_hostEnvironment); _logger = logger; } - /// - /// 打包医生官方简历 - /// - /// - /// - /// - public async Task CreateOfficialResumeZip(int language, Guid[] doctorIds) - { - - //准备下载文件的临时路径 - var guidStr = Guid.NewGuid().ToString(); - - string uploadFolderPath = Path.Combine(FileStoreHelper.GetIRaCISRootDataFolder(_hostEnvironment), "UploadFile"); - - - - var tempSavePath = Path.Combine(uploadFolderPath, "temp", guidStr); //待压缩的文件夹,将需要下载的文件拷贝到此文件夹 - if (!Directory.Exists(tempSavePath)) - { - Directory.CreateDirectory(tempSavePath); - } - - //找到服务器简历路径 循环拷贝简历到临时路径 - foreach (var doctorId in doctorIds) - { - var doctor = await _doctorService.GetBasicInfo(doctorId); - var doctorName = doctor.FirstName + "_" + doctor.LastName; - - //找官方简历存在服务器的相对路径 - var sourceCvPath = await _attachmentService.GetDoctorOfficialCV(language, doctorId); - if (!string.IsNullOrWhiteSpace(sourceCvPath)) - { - //服务器简历文件实际路径 - //var sourceCvFullPath = HostingEnvironment.MapPath(sourceCvPath); - var sourceCvPathTemp = sourceCvPath.Substring(1, sourceCvPath.Length - 1);//.Replace('/','\\'); - string sourceCvFullPath = Path.Combine(defaultUploadFilePath, sourceCvPathTemp); - - var arr = sourceCvPath.Split('.'); - string extensionName = arr[arr.Length - 1]; //得到扩展名 - - //需要拷贝到的路径 - var doctorPath = Path.Combine(tempSavePath, doctor.ReviewerCode.ToString() + "_" + doctorName + "." + extensionName); - - if (File.Exists(sourceCvFullPath)) - { - File.Copy(sourceCvFullPath, doctorPath, true); - } - } - } - - //创建ZIP - DateTime now = DateTime.Now; - StringBuilder sb = new StringBuilder(); - sb.Append(now.Year).Append(now.Month.ToString().PadLeft(2, '0')).Append(now.Day.ToString().PadLeft(2, '0')) - .Append(now.Hour.ToString().PadLeft(2, '0')).Append(now.Minute.ToString().PadLeft(2, '0')) - .Append(now.Second.ToString().PadLeft(2, '0')).Append(now.Millisecond.ToString().PadLeft(3, '0')); - - string targetZipPath = Path.Combine(uploadFolderPath, "CV_" + sb.ToString() + ".zip"); - ZipHelper.CreateZip(tempSavePath, targetZipPath); - - //返回Zip路径 - return Path.Combine("/IRaCISData/UploadFile/", "CV_" + sb.ToString() + ".zip"); - } - - /// - /// 打包医生的所有附件 - /// - /// - /// - public async Task CreateDoctorsAllAttachmentZip(Guid[] doctorIds) - { - //准备下载文件的临时路径 - var guidStr = Guid.NewGuid().ToString(); - //string uploadFolderPath = HostingEnvironment.MapPath("/UploadFile/"); - string uploadFolderPath = Path.Combine(FileStoreHelper.GetIRaCISRootDataFolder(_hostEnvironment), "UploadFile"); - var tempSavePath = Path.Combine(uploadFolderPath, "temp", guidStr); //待压缩的文件夹,将需要下载的文件拷贝到此文件夹 - if (!Directory.Exists(tempSavePath)) - { - Directory.CreateDirectory(tempSavePath); - } + - foreach (var doctorId in doctorIds) - { - //获取医生基本信息 - var doctor = await _doctorService.GetBasicInfo(doctorId); - var doctorName = doctor.FirstName + "_" + doctor.LastName; - var doctorCode = doctor.ReviewerCode; - var doctorDestPath = Path.Combine(tempSavePath, doctorCode + "_" + doctorName); - if (!Directory.Exists(doctorDestPath)) - { - Directory.CreateDirectory(doctorDestPath); - } - - //服务器上传后的源路径 - string doctorFileSourcePath = Path.Combine(uploadFolderPath, doctorId.ToString()); - - if (Directory.Exists(doctorFileSourcePath)) - { - CopyDirectory(doctorFileSourcePath, doctorDestPath); - } - } - string target = Guid.NewGuid().ToString(); - string targetPath = Path.Combine(uploadFolderPath, target + ".zip"); - ZipHelper.CreateZip(tempSavePath, targetPath); - return Path.Combine("/IRaCISData/UploadFile/", target + ".zip"); - } - - - public async Task CreateZipPackageByAttachment(Guid doctorId, Guid[] attachmentIds) - { - var doctor = await _doctorService.GetBasicInfo(doctorId); - var doctorName = doctor.FirstName + "_" + doctor.LastName; - - Guid temp = Guid.NewGuid(); - //string root = HostingEnvironment.MapPath("/UploadFile/"); //文件根目录 - string root = Path.Combine(defaultUploadFilePath, "UploadFile"); - - var tempPath = Path.Combine(root, "temp", temp.ToString(), doctor.ReviewerCode + doctorName); //待压缩的文件夹,将需要下载的文件拷贝到此文件夹 - var packagePath = Path.Combine(root, "temp", temp.ToString()); //打包目录 - if (!Directory.Exists(tempPath)) - { - Directory.CreateDirectory(tempPath); - } - var attachemnts = (await _attachmentService.GetAttachments(doctorId)).Where(a => attachmentIds.Contains(a.Id)); - - foreach (var item in attachemnts) - { - var arr = item.Path.Trim().Split('/'); - var myPath = string.Empty; - var myFile = string.Empty; - //需要改进 - if (arr.Length > 0) - { - myFile = arr[arr.Length - 1]; - foreach (var arrItem in arr) - { - if (arrItem != string.Empty && !"UploadFile".Equals(arrItem)) - { - myPath += (arrItem + "/"); - } - } - myPath = myPath.TrimEnd('/'); - } - var sourcePath = Path.Combine(root, myPath); - - if (!string.IsNullOrWhiteSpace(sourcePath) && File.Exists(sourcePath)) - { - File.Copy(sourcePath, Path.Combine(tempPath, myFile), true); - } - } - string target = Guid.NewGuid().ToString(); - string targetPath = Path.Combine(root, target + ".zip"); - ZipHelper.CreateZip(packagePath, targetPath); - - return Path.Combine("/IRaCISData/UploadFile/", target + ".zip"); - } + private static void CopyDirectory(string srcPath, string destPath) { diff --git a/IRaCIS.Core.Application/Service/Common/Interface/IFileService.cs b/IRaCIS.Core.Application/Service/Common/Interface/IFileService.cs index 10c6c072a..de11278f9 100644 --- a/IRaCIS.Core.Application/Service/Common/Interface/IFileService.cs +++ b/IRaCIS.Core.Application/Service/Common/Interface/IFileService.cs @@ -8,10 +8,10 @@ namespace IRaCIS.Application.Interfaces //IResponseOutput DownloadOfficialResume(Guid[] doctorIds); - Task CreateOfficialResumeZip(int language, Guid[] doctorIds); + - Task CreateDoctorsAllAttachmentZip(Guid[] doctorIds); + - Task CreateZipPackageByAttachment(Guid doctorId, Guid[] attachmentIds); + } } diff --git a/IRaCIS.Core.Application/Service/Common/MailService.cs b/IRaCIS.Core.Application/Service/Common/MailService.cs index 5f6e58120..2a4e0bb2d 100644 --- a/IRaCIS.Core.Application/Service/Common/MailService.cs +++ b/IRaCIS.Core.Application/Service/Common/MailService.cs @@ -32,7 +32,7 @@ namespace IRaCIS.Application.Services Task ExternalUserJoinEmail(Guid trialId, Guid userId, string baseUrl, string rootUrl); - Task DoctorJoinTrialEmail(Guid trialId, Guid doctorId, string baseUrl, string rootUrl); + } @@ -53,7 +53,7 @@ namespace IRaCIS.Application.Services private readonly IRepository _trialRepository; private readonly IRepository _userTypeRepository; - private readonly IRepository _doctorTypeRepository; + private readonly AsyncLock _mutex = new AsyncLock(); @@ -68,7 +68,6 @@ namespace IRaCIS.Application.Services ITokenService tokenService, IRepository trialRepository, IRepository userTypeRepository, - IRepository doctorTypeRepository, IMapper mapper, IOptionsMonitor systemEmailConfig) { _systemEmailConfig = systemEmailConfig.CurrentValue; @@ -84,7 +83,6 @@ namespace IRaCIS.Application.Services _trialRepository = trialRepository; _userTypeRepository = userTypeRepository; - _doctorTypeRepository = doctorTypeRepository; } @@ -598,122 +596,6 @@ namespace IRaCIS.Application.Services } - //医生生成账号加入 或者已存在账号加入到项目中 - public async Task DoctorJoinTrialEmail(Guid trialId, Guid doctorId, string baseUrl, string rootUrl) - { - var doctor = await _doctorTypeRepository.FindAsync(doctorId); - User sysUserInfo = null; - - var userType = await _userTypeRepository.FirstAsync(t => t.UserTypeEnum == UserTypeEnum.IndependentReviewer); - - using (await _mutex.LockAsync()) - { - var isDoctorHaveAccount = await _userRepository.AnyAsync(t => t.DoctorId == doctorId); - - - if (!isDoctorHaveAccount) - { - - var saveItem = new User() { FirstName = doctor.FirstName, LastName = doctor.LastName, EMail = doctor.EMail }; - - var trialType = await _trialRepository.Where(t => t.Id == trialId).Select(t => t.TrialType).FirstOrDefaultAsync(); - - if (trialType == TrialType.NoneOfficial) - { - saveItem.IsTestUser = true; - } - - - saveItem.Code = _userRepository.Select(t => t.Code).DefaultIfEmpty().Max() + 1; - - saveItem.UserCode = AppSettings.GetCodeStr(saveItem.Code, nameof(User)); - - saveItem.UserName = saveItem.UserCode; - - saveItem.UserTypeEnum = UserTypeEnum.IndependentReviewer; - - saveItem.DoctorId = doctorId; - saveItem.UserTypeId = userType.Id; - - var savedUser = await _userRepository.AddAsync(saveItem); - - //下面获取Token 需要这部分信息 - sysUserInfo = savedUser.Clone(); - - sysUserInfo.UserTypeRole = userType; - - await _userRepository.SaveChangesAsync(); - - } - else - { - sysUserInfo = (await _userRepository.Where(t => t.DoctorId == doctorId).Include(t => t.UserTypeRole).FirstOrDefaultAsync()).IfNullThrowException(); - } - } - - - var trialInfo = await _trialRepository.FirstOrDefaultAsync(t => t.Id == trialId); - - var messageToSend = new MimeMessage(); - //发件地址 - messageToSend.From.Add(new MailboxAddress(_systemEmailConfig.FromName, _systemEmailConfig.FromEmail)); - //收件地址 - messageToSend.To.Add(new MailboxAddress(doctor.FullName, doctor.EMail)); - //主题 - // $"[来自展影IRC] [{trialInfo.ResearchProgramNo}]邀请信"; - messageToSend.Subject = _localizer["Mail_InvitationEmail", trialInfo.ResearchProgramNo]; - - - var builder = new BodyBuilder(); - - - var basicInfo = IRaCISClaims.Create(_mapper.Map(sysUserInfo)); - - ////第一次添加的时候 注意赋值 - //basicInfo.PermissionStr = userType.PermissionStr; - //basicInfo.UserTypeShortName = userType.UserTypeShortName; - - var token = _tokenService.GetToken(basicInfo); - - if (sysUserInfo.IsFirstAdd) - { - await _userRepository.BatchUpdateNoTrackingAsync(t => t.Id == sysUserInfo.Id, u => new User() { EmailToken = token }); - } - - - var pathToFile = _hostEnvironment.WebRootPath - + Path.DirectorySeparatorChar.ToString() - + "EmailTemplate" - + Path.DirectorySeparatorChar.ToString() - + (sysUserInfo.IsFirstAdd ? (_userInfo.IsEn_Us ? "TrialDoctorFirstJoin_US.html" : "TrialDoctorFirstJoin.html") : (_userInfo.IsEn_Us ? "TrialDoctorExistJoin_US.html" : "TrialDoctorExistJoin.html") ); - - using (StreamReader SourceReader = System.IO.File.OpenText(pathToFile)) - { - var templateInfo = SourceReader.ReadToEnd(); - - var routeUrl = rootUrl + "?UserId=" + sysUserInfo.Id + "&Email=" + sysUserInfo.EMail + "&UserName=" + sysUserInfo.UserName + "&UserType=" + userType.UserTypeShortName + "&lang=" + (_userInfo.IsEn_Us ? "en" : "zh") + "&access_token=" + token; - - var domain = baseUrl.Substring(0, baseUrl.IndexOf("/login")); - - var redirectUrl = $"{domain}/api/User/UserRedirect?url={System.Web.HttpUtility.UrlEncode(routeUrl)}"; - - builder.HtmlBody = string.Format(templateInfo, - sysUserInfo.FullName, - trialInfo.ExperimentName, - trialInfo.ResearchProgramNo, - trialInfo.TrialCode, - sysUserInfo.UserName, - userType.UserTypeShortName, - sysUserInfo.IsFirstAdd ? redirectUrl : baseUrl - ); - } - - messageToSend.Body = builder.ToMessageBody(); - - await SendEmailHelper.SendEmailAsync(messageToSend, _systemEmailConfig, null); - - return sysUserInfo.Id; - } diff --git a/IRaCIS.Core.Application/Service/Doctor/AttachmentService.cs b/IRaCIS.Core.Application/Service/Doctor/AttachmentService.cs deleted file mode 100644 index 0d1f65194..000000000 --- a/IRaCIS.Core.Application/Service/Doctor/AttachmentService.cs +++ /dev/null @@ -1,254 +0,0 @@ -using IRaCIS.Application.Interfaces; -using IRaCIS.Application.Contracts; -using IRaCIS.Core.Infra.EFCore; -using IRaCIS.Core.Domain.Models; -using IRaCIS.Core.Infrastructure.Extention; -using Microsoft.AspNetCore.Mvc; -using Panda.DynamicWebApi.Attributes; - -namespace IRaCIS.Application.Services -{ - /// - /// 医生文档关联关系维护 - /// - [ApiExplorerSettings(GroupName = "Reviewer")] - public class AttachmentService : BaseService, IAttachmentService - { - private readonly IRepository _attachmentrepository; - - public AttachmentService(IRepository attachmentrepository) - { - this._attachmentrepository = attachmentrepository; - } - - /// - /// 删除附件 - /// - /// - /// - - public async Task DeleteAttachment([FromBody]AttachementCommand param) - { - //var attachment = _doctorAttachmentApp.GetDetailById(id); - //string file = HostingEnvironment.MapPath(attachment.Path); - - //if (File.Exists(file)) - //{ - // File.Delete(file); - //} - //var temp = HostingEnvironment.MapPath(param.Path); - //if (File.Exists(temp)) - //{ - // File.Delete(temp); - //} - - var success =await _attachmentrepository.BatchDeleteNoTrackingAsync(a => a.Id == param.Id); - return ResponseOutput.Result(success); - } - - - /// - /// 根据医生Id 和 附件类型,获取记录 - /// - /// 医生Id - /// 附件类型 - /// - [HttpGet("{doctorId:guid}/{type}")] - public async Task> GetAttachmentByType(Guid doctorId, string type) - { - var attachmentList = await _attachmentrepository.Where(a => a.DoctorId == doctorId && a.Type.Equals(type)).ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); - attachmentList.ForEach(t => t.FullPath = t.Path + "?access_token=" + _userInfo.UserToken); - - return attachmentList; - } - - /// - /// 获取单个医生的多种证书附件 - /// - /// 医生Id - /// 类型数组 - /// - [HttpPost("{doctorId:guid}")] - public async Task> GetAttachmentByTypes(Guid doctorId, string[] types) - { - - var attachmentList =await _attachmentrepository.Where(a => a.DoctorId == doctorId && types.Contains(a.Type)).OrderBy(s => s.Type).ThenBy(m => m.CreateTime).ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); - attachmentList.ForEach(t => t.FullPath = t.Path + "?access_token=" + _userInfo.UserToken); - - return attachmentList; - } - - /// - /// 根据医生Id获取医生附件 - /// - /// 医生Id - /// - [HttpGet("{doctorId:guid}")] - public async Task> GetAttachments(Guid doctorId) - { - var attachmentList =await _attachmentrepository.Where(a => a.DoctorId == doctorId).OrderBy(s => s.Type).ThenBy(m => m.CreateTime).ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); - attachmentList.ForEach(t => t.FullPath = t.Path + "?access_token=" + _userInfo.UserToken); - - return attachmentList; - } - - [NonDynamicMethod] - public async Task GetDetailById(Guid attachmentId) - { - var attachment = await _attachmentrepository.FirstOrDefaultAsync(a => a.Id == attachmentId).IfNullThrowException(); - var temp= _mapper.Map(attachment); - temp.FullPath = temp.Path + "?access_token=" + _userInfo.UserToken; - return temp; - } - - /// - /// 保存多个附件 - /// - /// - /// - public async Task> SaveAttachments(IEnumerable attachmentList) - { - var attachments = _mapper.Map>(attachmentList).ToList(); - - //1 是中文 2是英文 中英文第一份简历默认设置为官方 - - var zhCount = attachments.Count(t => t.Language == 1); - var usCount = attachments.Count(t => t.Language == 2); - - if (zhCount == 1) - { - var k = attachments.First(t => t.Language == 1); - k.IsOfficial = true; - } - if (usCount == 1) - { - var k = attachments.First(t => t.Language == 2); - k.IsOfficial = true; - } - - - //处理重传 - var reUpload = attachmentList.FirstOrDefault(t => t.ReUpload == true); - if (reUpload != null) - { - //因为界面现实的列表用了 接口返回的列表,所以要把返回的模型对应的字段也要更改 - var attach = attachments.First(t => t.Id == reUpload.Id); - attach.CreateTime = DateTime.Now; - - - //重传的时候,发现 相同语言的官方简历数量为2 那么将重传的简历设置为非官方 - if (attachments.Count(t => t.Language == reUpload.Language && t.IsOfficial) == 2) - { - await _attachmentrepository.BatchUpdateNoTrackingAsync(t => t.Id == reUpload.Id, u => new Attachment() - { - Path = reUpload.Path, - CreateTime = DateTime.Now, - Language = reUpload.Language, - IsOfficial = false - }); - attach.IsOfficial = false; - } - else //相同语言的重传 - { - await _attachmentrepository.BatchUpdateNoTrackingAsync(t => t.Id == reUpload.Id, u => new Attachment() - { - Path = reUpload.Path, - CreateTime = DateTime.Now, - Language = reUpload.Language - }); - - } - - } - - - var newAttachment = attachments.Where(t => t.Id == Guid.Empty); - - await _repository.AddRangeAsync(newAttachment); - await _repository.SaveChangesAsync(); - - //_doctorAttachmentRepository.AddRange(newAttachment); - //_doctorAttachmentRepository.SaveChanges(); - - var list = _mapper.Map>(attachments).ToList(); - - list.ForEach(t => t.FullPath = t.Path + "?access_token=" + _userInfo.UserToken); - - return list; - } - - public async Task> AddAttachment(AttachmentDTO attachment) - { - - var newAttachment = _mapper.Map(attachment); - //如果这个医生不存在 这个语言的官方简历 就设置为官方简历 - if (! await _attachmentrepository.AnyAsync(t => t.Type == "Resume" && t.DoctorId == attachment.DoctorId && t.Language == attachment.Language && t.IsOfficial)) - { - newAttachment.IsOfficial = true; - - attachment.IsOfficial = true; - } - - await _repository.AddAsync(newAttachment); - var success = await _repository.SaveChangesAsync(); - return ResponseOutput.Result(success, attachment); - } - - - [NonDynamicMethod] - public async Task GetDoctorOfficialCV(int language, Guid doctorId) - { - var result = await _attachmentrepository.FirstOrDefaultAsync(a => a.DoctorId == doctorId && - a.IsOfficial && a.Type.Equals("Resume") && a.Language == language); - if (result != null) - { - return result.Path; - } - return string.Empty; - } - - - /// - /// 将简历设置为官方简历 - /// - /// - /// - /// - /// - - [HttpPost("{doctorId:guid}/{attachmentId:guid}/{language}")] - public async Task SetOfficial(Guid doctorId, Guid attachmentId, int language) - { - var resumeList = await _attachmentrepository.Where(t => t.DoctorId == doctorId && t.Type == "Resume" && t.Language == language).ToListAsync(); - foreach (var item in resumeList) - { - if (item.Id == attachmentId) item.IsOfficial = true; - else item.IsOfficial = false; - await _repository.UpdateAsync(item); - } - - return ResponseOutput.Result(await _repository.SaveChangesAsync()); - } - - /// - /// 设置简历的语言类型 - /// - /// - /// - /// 0-未设置,1-中文,2-英文 - /// - - [HttpPost("{doctorId:guid}/{attachmentId:guid}/{language}")] - public async Task SetLanguage(Guid doctorId, Guid attachmentId, int language) - { - bool result =await _attachmentrepository.BatchUpdateNoTrackingAsync(t => t.Id == attachmentId, a => new Attachment - { - Language = language, - IsOfficial = false - }); - return ResponseOutput.Result(result); - } - - - } -} diff --git a/IRaCIS.Core.Application/Service/Doctor/DTO/AttachmentModel.cs b/IRaCIS.Core.Application/Service/Doctor/DTO/AttachmentModel.cs deleted file mode 100644 index 1eb34fc03..000000000 --- a/IRaCIS.Core.Application/Service/Doctor/DTO/AttachmentModel.cs +++ /dev/null @@ -1,64 +0,0 @@ -namespace IRaCIS.Application.Contracts -{ - public class AttachmentDTO - { - public Guid Id { get; set; } - public Guid DoctorId { get; set; } - public bool IsOfficial { get; set; } - public string Type { get; set; } = string.Empty; - public string Path { get; set; } = string.Empty; - public string FullPath { get; set; } = string.Empty; - public string FileName { get; set; } = string.Empty; - public DateTime? CreateTime { get; set; } - public int Language { get; set; } - - public bool ReUpload { get; set; } = false; - } - - public class ReviewerAckDTO - { - public Guid Id { get; set; } - public Guid DoctorId { get; set; } - public string Type { get; set; } = string.Empty; - public string Path { get; set; } = string.Empty; - public string FullPath => Path; - public string FileName { get; set; } = string.Empty; - } - - - - - - public class TrialSOWPathDTO - { - public Guid TrialId { get; set; } - - public string SowName { get; set; } = string.Empty; - public string SowPath { get; set; } = string.Empty; - } - - public class DeleteSowPathDTO - { - public Guid TrialId { get; set; } - public string Path { get; set; } = string.Empty; - - } - - public class UploadAgreementAttachmentDTO - { - public Guid Id { get; set; } - - public Guid DoctorId { get; set; } - public string Type { get; set; } = string.Empty; - public string Path { get; set; } = string.Empty; - public string FullPath => Path; - - public string FileName { get; set; } = string.Empty; - } - - public class AttachementCommand - { - public Guid Id { get; set; } - public string Path { get; set; } = string.Empty; - } -} diff --git a/IRaCIS.Core.Application/Service/Doctor/DTO/DoctorAccountRegisterModel.cs b/IRaCIS.Core.Application/Service/Doctor/DTO/DoctorAccountRegisterModel.cs deleted file mode 100644 index 456a61b78..000000000 --- a/IRaCIS.Core.Application/Service/Doctor/DTO/DoctorAccountRegisterModel.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; - -namespace IRaCIS.Application.Contracts -{ - public class DoctorAccountRegisterModel : DoctorAccountLoginDTO - { - public string FirstName { get; set; } = string.Empty; - public string LastName { get; set; } = string.Empty; - public string EMail { get; set; } = string.Empty; - public DateTime RegisterTime { get; set; } - } -} \ No newline at end of file diff --git a/IRaCIS.Core.Application/Service/Doctor/DTO/DoctorModel.cs b/IRaCIS.Core.Application/Service/Doctor/DTO/DoctorModel.cs index 890447734..1ecde5cb8 100644 --- a/IRaCIS.Core.Application/Service/Doctor/DTO/DoctorModel.cs +++ b/IRaCIS.Core.Application/Service/Doctor/DTO/DoctorModel.cs @@ -244,12 +244,10 @@ namespace IRaCIS.Application.Contracts public DoctorBasicInfoDTO BasicInfoView { get; set; } public EmploymentDTO EmploymentView { get; set; } public SpecialtyDTO SpecialtyView { get; set; } - public IEnumerable EducationList { get; set; } - public IEnumerable PostgraduateList { get; set; } - public ResearchPublicationDTO ResearchPublicationView { get; set; } - public TrialExperienceModel TrialExperienceView { get; set; } + + public ResumeConfirmDTO AuditView { get; set; } - public IEnumerable AttachmentList { get; set; } + public List SowList { get; set; } public List AckSowList { get; set; } @@ -262,12 +260,9 @@ namespace IRaCIS.Application.Contracts BasicInfoView = new DoctorBasicInfoDTO(); EmploymentView = new EmploymentDTO(); SpecialtyView = new SpecialtyDTO(); - EducationList = new List(); - PostgraduateList = new List(); - ResearchPublicationView = new ResearchPublicationDTO(); - TrialExperienceView = new TrialExperienceModel(); + AuditView = new ResumeConfirmDTO(); - AttachmentList = new List(); + IntoGroupInfo = new DoctorEnrollInfoDTO(); SowList = new List(); AckSowList = new List(); diff --git a/IRaCIS.Core.Application/Service/Doctor/DTO/EducationModel.cs b/IRaCIS.Core.Application/Service/Doctor/DTO/EducationModel.cs deleted file mode 100644 index f9fdbdee8..000000000 --- a/IRaCIS.Core.Application/Service/Doctor/DTO/EducationModel.cs +++ /dev/null @@ -1,89 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace IRaCIS.Application.Contracts -{ - public class EducationCommand - { - public Guid? Id { get; set; } - public Guid DoctorId { get; set; } - public DateTime BeginDate { get; set; } - public DateTime EndDate { get; set; } - public string Degree { get; set; } = String.Empty; - public string Major { get; set; } = String.Empty; - public string Organization { get; set; } = String.Empty; - public string Country { get; set; } = String.Empty; - public string Province { get; set; } = String.Empty; - public string City { get; set; } = String.Empty; - - public string DegreeCN { get; set; } = String.Empty; - public string MajorCN { get; set; } = String.Empty; - public string OrganizationCN { get; set; } = String.Empty; - public string CountryCN { get; set; } = String.Empty; - public string ProvinceCN { get; set; } = String.Empty; - public string CityCN { get; set; } = String.Empty; - - } - - public class EducationInfoViewModel : EducationCommand - { - public DateTime? CreateTime { get; set; } - public string BeginDateStr => BeginDate.ToString("yyyy-MM"); - public string EndDateStr => EndDate.ToString("yyyy-MM"); - - } - public class PostgraduateCommand - { - public Guid? Id { get; set; } - public Guid DoctorId { get; set; } - - public DateTime BeginDate { get; set; } - - public DateTime EndDate { get; set; } - - public string Training { get; set; } = String.Empty; - - public string Major { get; set; } = String.Empty; - - public string Hospital { get; set; } = String.Empty; - - public string School { get; set; } = String.Empty; - - public string Country { get; set; } = String.Empty; - - public string Province { get; set; } = String.Empty; - - public string City { get; set; } = String.Empty; - - public string TrainingCN { get; set; } = String.Empty; - - public string MajorCN { get; set; } = String.Empty; - - public string HospitalCN { get; set; } = String.Empty; - - public string SchoolCN { get; set; } = String.Empty; - - public string CountryCN { get; set; } = String.Empty; - - public string ProvinceCN { get; set; } = String.Empty; - - public string CityCN { get; set; } = String.Empty; - - } - - - public class PostgraduateViewModel: PostgraduateCommand - { - public DateTime? CreateTime { get; set; } - public string BeginDateStr => BeginDate.ToString("yyyy-MM"); - - public string EndDateStr => EndDate.ToString("yyyy-MM"); - } - public class DoctorEducationExperienceDTO - { - public IEnumerable EducationList=new List(); - - public IEnumerable PostgraduateList = new List(); - } - -} \ No newline at end of file diff --git a/IRaCIS.Core.Application/Service/Doctor/DTO/HolidayModel.cs b/IRaCIS.Core.Application/Service/Doctor/DTO/HolidayModel.cs deleted file mode 100644 index 8635d431a..000000000 --- a/IRaCIS.Core.Application/Service/Doctor/DTO/HolidayModel.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; - -namespace IRaCIS.Application.Contracts -{ - public class VacationCommand - { - public Guid? Id { get; set; } - public Guid DoctorId { get; set; } - public DateTime StartDate { get; set; } - public DateTime EndDate { get; set; } - public int Status { get; set; } = 1; - } -} diff --git a/IRaCIS.Core.Application/Service/Doctor/DTO/ResearchPublicationModel.cs b/IRaCIS.Core.Application/Service/Doctor/DTO/ResearchPublicationModel.cs deleted file mode 100644 index d5a61a587..000000000 --- a/IRaCIS.Core.Application/Service/Doctor/DTO/ResearchPublicationModel.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; - -namespace IRaCIS.Application.Contracts -{ - public class ResearchPublicationDTO - { - public Guid? Id { get; set; } - public Guid DoctorId { get; set; } - public string Research { get; set; } = String.Empty; - public string Grants { get; set; } = String.Empty; - public string Publications { get; set; } = String.Empty; - public string AwardsHonors { get; set; } = String.Empty; - - public string ResearchCN { get; set; } = String.Empty; - public string GrantsCN { get; set; } = String.Empty; - public string PublicationsCN { get; set; } = String.Empty; - public string AwardsHonorsCN { get; set; } = String.Empty; - - - } -} \ No newline at end of file diff --git a/IRaCIS.Core.Application/Service/Doctor/DTO/TrialExperienceModel.cs b/IRaCIS.Core.Application/Service/Doctor/DTO/TrialExperienceModel.cs deleted file mode 100644 index 4ed924c61..000000000 --- a/IRaCIS.Core.Application/Service/Doctor/DTO/TrialExperienceModel.cs +++ /dev/null @@ -1,87 +0,0 @@ -namespace IRaCIS.Application.Contracts -{ - public class TrialExperienceCommand - { - public Guid? Id { get; set; } - - public Guid DoctorId { get; set; } - - public Guid? PhaseId { get; set; } - - public DateTime? StartTime { get; set; } - - public DateTime? EndTime { get; set; } - - public string EvaluationContent { get; set; } = String.Empty; - - public int VisitReadingCount { get; set; } - - //public string Term { get; set; } - - //public string EvaluationCriteria { get; set; } - - public List EvaluationCriteriaIdList { get; set; } = new List(); - - - } - - public class TrialExperienceListDTO: TrialExperienceCommand - { - public string Phase { get; set; } = String.Empty; - - public List EvaluationCriteriaList { get; set; } = new List(); - - } - - //public class EvaluationCriteriaDTO - //{ - // public Guid EvaluationCriteriaId { get; set; } - // public string EvaluationCriteria { get; set; } - //} - - - public class TrialExperienceModel : GcpAndOtherExperienceDTO - { - public List ClinicalTrialExperienceList = new List(); - - public string ExpiryDateStr { get; set; } = string.Empty; - public string GCPFullPath { get; set; } = String.Empty; - - } - - - public class GcpAndOtherExperienceDTO - { - public Guid Id { get; set; } - - public int GCP { get; set; } - - public Guid? GCPId { get; set; } - - public string OtherClinicalExperience { get; set; }=String.Empty; - public string OtherClinicalExperienceCN { get; set; } = String.Empty; - - public string Type { get; set; } = string.Empty; - - public string Path { get; set; } = string.Empty; - - public string FileName { get; set; } = string.Empty; - - } - - public class GCPExperienceCommand - { - public Guid Id { get; set; } - public int GCP { get; set; } - - public Guid? GCPId { get; set; } - } - - public class ClinicalExperienceCommand - { - public Guid DoctorId { get; set; } - - public string OtherClinicalExperience { get; set; } = String.Empty; - public string OtherClinicalExperienceCN { get; set; } = String.Empty; - } -} \ No newline at end of file diff --git a/IRaCIS.Core.Application/Service/Doctor/DoctorListService.cs b/IRaCIS.Core.Application/Service/Doctor/DoctorListService.cs deleted file mode 100644 index d1344f775..000000000 --- a/IRaCIS.Core.Application/Service/Doctor/DoctorListService.cs +++ /dev/null @@ -1,279 +0,0 @@ -using IRaCIS.Application.Interfaces; -using IRaCIS.Application.Contracts; -using IRaCIS.Core.Domain.Share; -using System.Linq.Dynamic.Core; -using IRaCIS.Core.Infra.EFCore; -using Microsoft.AspNetCore.Mvc; - -namespace IRaCIS.Application.Services -{ - [ApiExplorerSettings(GroupName = "Reviewer")] - public class DoctorListService : BaseService, IDoctorListQueryService - { - private readonly IRepository _doctorRepository; - - public DoctorListService(IRepository doctorRepository) - { - _doctorRepository = doctorRepository; - } - - /// - /// Reviewer列表分页查询 - /// - [HttpPost] - public async Task> GetDoctorSearchList(DoctorSearchDTO doctorSearch) - { - - // 项目经验 多选 - var evaluationCriteriaCount = doctorSearch.EvaluationCriteriaIdList.Count(); - - // 搜索条件 ReadingType 、Subspeciality、Title 多选 - var count = doctorSearch.ReadingTypeIdList.Count + doctorSearch.TitleIdList.Count + doctorSearch.SubspecialityIdList.Count; - - var guidList = doctorSearch.ReadingTypeIdList.Concat(doctorSearch.SubspecialityIdList).Concat(doctorSearch.TitleIdList); - - - var query = _doctorRepository.AsQueryable() - .WhereIf(doctorSearch.DepartmentId != null, t => t.DepartmentId == doctorSearch.DepartmentId) - .WhereIf(doctorSearch.SpecialityId != null, t => t.SpecialityId == doctorSearch.SpecialityId) - .WhereIf(doctorSearch.HospitalId != null, t => t.HospitalId == doctorSearch.HospitalId) - .WhereIf(doctorSearch.PositionId != null, t => t.PositionId == doctorSearch.PositionId) - .WhereIf(doctorSearch.RankId != null, t => t.RankId == doctorSearch.RankId) - .WhereIf(doctorSearch.ContractorStatus != null, t => t.CooperateStatus == doctorSearch.ContractorStatus) - .WhereIf(doctorSearch.InformationConfirmed != null, t => t.ResumeStatus == doctorSearch.InformationConfirmed) - .WhereIf(doctorSearch.AcceptingNewTrial != null, t => t.AcceptingNewTrial == doctorSearch.AcceptingNewTrial) - .WhereIf(!string.IsNullOrWhiteSpace(doctorSearch.Name), t => t.ChineseName.Contains(doctorSearch.Name) || (t.LastName + t.FirstName).Contains(doctorSearch.Name)) - .WhereIf(doctorSearch.Nation != null, t => t.Nation == doctorSearch.Nation) - .WhereIf(evaluationCriteriaCount > 0, t => t.TrialExperienceCriteriaList.Count(t => doctorSearch.EvaluationCriteriaIdList.Contains(t.EvaluationCriteriaId)) == evaluationCriteriaCount) - ////用户类型 看到简历的范围这里需要确认 - //.WhereIf(_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ReviewerCoordinator, t => t.UserList.Any(u => u.UserId == _userInfo.Id)) - .WhereIf(count > 0, t => t.DoctorDicRelationList.Count(u => guidList.Contains(u.DictionaryId)) == count) - .WhereIf(doctorSearch.EnrollStatus != null && doctorSearch.EnrollStatus == (int)ReviewerEnrollStatus.Yes, t => t.EnrollList.Any(u => u.EnrollStatus == EnrollStatus.DoctorReading)) - - .ProjectTo(_mapper.ConfigurationProvider); - - return await query.ToPagedListAsync(doctorSearch.PageIndex, doctorSearch.PageSize, doctorSearch.SortField == string.Empty ? "CreateTime" : doctorSearch.SortField, doctorSearch.Asc); - - - } - - - #region 入组查询相关 - /// - /// 获取可筛选筛选及已经筛选的医生列表 - /// - [HttpPost] - public async Task> GetSelectionReviewerList( - ReviewerSelectionQueryDTO selectionQuery) - { - //项目配置需要的医生过滤 2表示混合 - var trialConfig = await _repository.Where(s => s.Id == selectionQuery.TrialId).Select(t=>new { t.AttendedReviewerTypeEnumList ,t.TrialType} ).FirstOrDefaultAsync().IfNullThrowException(); - - //var nation = trialConfig.AttendedReviewerType; - // 临床项目经验 多选 - var evaluationCriteriaCount = selectionQuery.EvaluationCriteriaIdList.Count(); - - // 搜索条件 ReadingType 、Subspeciality、Title 多选 - var count = selectionQuery.ReadingTypeIdList.Count + selectionQuery.TitleIdList.Count + selectionQuery.SubspecialityIdList.Count; - - var guidList = selectionQuery.ReadingTypeIdList.Concat(selectionQuery.SubspecialityIdList).Concat(selectionQuery.TitleIdList); - - var query = _doctorRepository/*.WhereIf(nation != AttendedReviewerType.USAndCN, t => t.Nation ==(int) nation)*/ - - .WhereIf(selectionQuery.DepartmentId != null, t => t.DepartmentId == selectionQuery.DepartmentId) - .WhereIf(selectionQuery.SpecialityId != null, t => t.SpecialityId == selectionQuery.SpecialityId) - .WhereIf(trialConfig.TrialType == TrialType.NoneOfficial, t => t.IsVirtual ==true) - .WhereIf(trialConfig.TrialType != TrialType.NoneOfficial, t => t.IsVirtual == false) - .WhereIf(selectionQuery.HospitalId != null, t => t.HospitalId == selectionQuery.HospitalId) - .WhereIf(selectionQuery.PositionId != null, t => t.PositionId == selectionQuery.PositionId) - .WhereIf(selectionQuery.RankId != null, t => t.RankId == selectionQuery.RankId) - .WhereIf(selectionQuery.ContractorStatus != null, t => t.CooperateStatus == selectionQuery.ContractorStatus ) - .WhereIf(selectionQuery.InformationConfirmed != null, t => t.ResumeStatus == selectionQuery.InformationConfirmed) - .WhereIf(selectionQuery.AcceptingNewTrial != null, t => t.AcceptingNewTrial == selectionQuery.AcceptingNewTrial) - .WhereIf(!string.IsNullOrWhiteSpace(selectionQuery.Name), t => t.ChineseName.Contains(selectionQuery.Name) || (t.LastName + t.FirstName).Contains(selectionQuery.Name)) - .WhereIf(evaluationCriteriaCount > 0, t => t.TrialExperienceCriteriaList.Count(t => selectionQuery.EvaluationCriteriaIdList.Contains(t.EvaluationCriteriaId)) == evaluationCriteriaCount) - //用户类型 看到简历的范围这里需要确认 - //.WhereIf(_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ReviewerCoordinator, t => t.UserList.Any(u => u.UserId == _userInfo.Id)) - .WhereIf(count > 0, t => t.DoctorDicRelationList.Count(u => guidList.Contains(u.DictionaryId)) == count) - .WhereIf(selectionQuery.EnrollStatus != null && selectionQuery.EnrollStatus == (int)ReviewerEnrollStatus.Yes, t => t.EnrollList.Any(u => u.EnrollStatus == EnrollStatus.DoctorReading)) - - .ProjectTo(_mapper.ConfigurationProvider); - - var result = await query.ToPagedListAsync(selectionQuery.PageIndex, selectionQuery.PageSize, selectionQuery.SortField == string.Empty ? "ReviewerCode" : selectionQuery.SortField, selectionQuery.Asc); - - //是否已申请 申请时间 申请人 - var doctorStateList = await _repository.Where(x => x.TrialId == selectionQuery.TrialId && x.EnrollStatus == EnrollStatus.HasApplyDownloadResume) - .ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); - - result.CurrentPageData.ToList().ForEach(doctor => - { - //简历申请列表 --处理已经申请的 - var doctorState = doctorStateList.FirstOrDefault(t => t.DoctorId == doctor.Id && t.IntoGroupState == (int)EnrollStatus.HasApplyDownloadResume); - if (doctorState != null) - { - doctor.DoctorTrialState = (int)EnrollStatus.HasApplyDownloadResume; - doctor.OptTime = doctorState.OptTime; - doctor.OptUserName = doctorState.OptUserName; - } - }); - - return result; - - - } - - /// - /// 获取提交CRO或者CRO审核的Reviewer列表 - /// - /// - /// 根据状态获取医生列表,入组 相关接口 (提交CRO-1) CRO确认-4 - /// - [HttpPost] - public async Task> GetSubmissionOrApprovalReviewerList( - ReviewerSubmissionQueryDTO param) - { - - var doctorQuery = _repository.Where(x => x.TrialId == param.TrialId) - //提交CRO 以及下载简历列表 - .WhereIf(param.IntoGroupSearchState == 1, t => t.EnrollStatus >= EnrollStatus.HasApplyDownloadResume) - //CRO确认列表 状态为 已提交CRO - .WhereIf(param.IntoGroupSearchState == 4, t => t.EnrollStatus >= EnrollStatus.HasCommittedToCRO) - .ProjectTo(_mapper.ConfigurationProvider); - - var doctorPageList = await doctorQuery.ToPagedListAsync(param.PageIndex, param.PageSize, param.SortField == "" ? "Code" : param.SortField, param.Asc); - - - var enrollStateList = await _repository.Where(x => x.TrialId == param.TrialId) - //提交CRO 以及下载简历列表 - .WhereIf(param.IntoGroupSearchState == 1, t => t.EnrollStatus == EnrollStatus.HasCommittedToCRO) - //CRO确认列表 状态为 已提交CRO - .WhereIf(param.IntoGroupSearchState == 4, t => t.EnrollStatus == EnrollStatus.InviteIntoGroup) - .ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); - - - - - doctorPageList.CurrentPageData.ToList().ForEach(u => - { - var opt = enrollStateList.FirstOrDefault(t => t.DoctorId == u.Id); - if (opt != null) - { - u.DoctorTrialState = param.IntoGroupSearchState == 1 ? (int)EnrollStatus.HasCommittedToCRO : (int)EnrollStatus.InviteIntoGroup; - u.OptTime = opt.OptTime; - u.OptUserName = opt.OptUserName; - } - else - { - u.DoctorTrialState = param.IntoGroupSearchState == 1 ? (int)EnrollStatus.HasDownloadResume : (int)EnrollStatus.HasCommittedToCRO; - } - }); - - if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.SPM) - { - //SPM 要看到提交的时间 提交人 - var enrollCommitList = await _repository.Where(x => x.TrialId == param.TrialId) - //提交CRO 以及下载简历列表 - .WhereIf(param.IntoGroupSearchState == 4, t => t.EnrollStatus == EnrollStatus.HasCommittedToCRO) - .ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); - - - doctorPageList.CurrentPageData.ToList().ForEach(u => - { - var opt = enrollCommitList.FirstOrDefault(t => t.DoctorId == u.Id); - if (opt != null) - { - - u.SubmmitTime = opt.OptTime; - u.SubmmitUserName = opt.OptUserName; - } - }); - - } - - return doctorPageList; - - - - } - - - //public async Task> GetSPMSubmissionOrApprovalReviewerList( - // ReviewerSubmissionQueryDTO param) - //{ - // var doctorQuery = _repository.Where(x => x.TrialId == param.TrialId) - // //提交CRO 以及下载简历列表 - // .WhereIf(param.IntoGroupSearchState == 1, t => t.EnrollStatus >= (int)EnrollStatus.HasApplyDownloadResume) - // //CRO确认列表 状态为 已提交CRO - // .WhereIf(param.IntoGroupSearchState == 4, t => t.EnrollStatus >= (int)EnrollStatus.HasCommittedToCRO) - // .ProjectTo(_mapper.ConfigurationProvider); - - // var doctorPageList = await doctorQuery.ToPagedListAsync(param.PageIndex, param.PageSize, param.SortField == "" ? "Code" : param.SortField, param.Asc); - - - // var enrollStateList = await _repository.Where(x => x.TrialId == param.TrialId) - // //提交CRO 以及下载简历列表 - // .WhereIf(param.IntoGroupSearchState == 1, t => t.EnrollStatus == (int)EnrollStatus.HasCommittedToCRO) - // //CRO确认列表 状态为 已提交CRO - // .WhereIf(param.IntoGroupSearchState == 4, t => t.EnrollStatus == (int)EnrollStatus.InviteIntoGroup) - // .ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); - - - // doctorPageList.CurrentPageData.ToList().ForEach(u => - // { - // var opt = enrollStateList.FirstOrDefault(t => t.DoctorId == u.Id); - // if (opt != null) - // { - // u.DoctorTrialState = param.IntoGroupSearchState == 1 ? (int)EnrollStatus.HasCommittedToCRO : (int)EnrollStatus.InviteIntoGroup; - // u.OptTime = opt.OptTime; - // u.OptUserName = opt.OptUserName; - // } - // }); - - // return doctorPageList; - //} - - /// - /// 获取项目下医生入组状态列表[Confirmation] - /// - [HttpPost] - public async Task> GetConfirmationReviewerList( - ReviewerConfirmationQueryDTO param) - { - - - var doctorQuery = _repository.Where(x => x.TrialId == param.TrialId && x.EnrollStatus >= EnrollStatus.InviteIntoGroup) - .ProjectTo(_mapper.ConfigurationProvider); - - var doctorPageList = await doctorQuery.ToPagedListAsync(param.PageIndex, param.PageSize, param.SortField == "" ? "Code" : param.SortField, param.Asc); - - var enrollStateList = await _repository.Where(x => x.TrialId == param.TrialId && x.EnrollStatus > EnrollStatus.InviteIntoGroup) - .ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); - - - - doctorPageList.CurrentPageData.ToList().ForEach(u => - { - u.DoctorTrialState = (int)EnrollStatus.InviteIntoGroup; - var opt = enrollStateList.FirstOrDefault(t => t.DoctorId == u.Id); - if (opt != null) - { - u.DoctorTrialState = opt.IntoGroupState; - u.OptTime = opt.OptTime; - u.OptUserName = opt.OptUserName; - } - }); - - return doctorPageList; - - } - - - - #endregion - - - - - } -} - diff --git a/IRaCIS.Core.Application/Service/Doctor/DoctorService.cs b/IRaCIS.Core.Application/Service/Doctor/DoctorService.cs deleted file mode 100644 index bb8df3f3a..000000000 --- a/IRaCIS.Core.Application/Service/Doctor/DoctorService.cs +++ /dev/null @@ -1,628 +0,0 @@ -using IRaCIS.Application.Interfaces; -using IRaCIS.Application.Contracts; -using IRaCIS.Core.Infra.EFCore; -using IRaCIS.Core.Domain.Share; -using IRaCIS.Core.Infrastructure; -using Microsoft.AspNetCore.Mvc; -using System.Linq.Expressions; - -namespace IRaCIS.Application.Services -{ - [ApiExplorerSettings(GroupName = "Reviewer")] - public class DoctorService : BaseService, IDoctorService - { - private readonly IRepository _doctorRepository; - private readonly IRepository _messageRepository; - private readonly IRepository _enrollRepository; - private readonly IRepository _doctorDictionaryRepository; - private readonly IRepository _attachmentRepository; - private readonly IRepository _doctorCriterionFileRepository; - private readonly IRepository _userDoctorRepository; - private readonly IRepository _trialRepository; - private readonly IRepository _trialExtRepository; - private readonly IRepository _vacationRepository; - - - - public DoctorService(IRepository doctorInfoRepository, - IRepository dictionaryRepository, - IRepository sysMessageRepository, IRepository intoGroupRepository, - IRepository doctorDictionaryRepository, - IRepository attachmentRepository, - IRepository doctorCriterionFileRepository, - IRepository userDoctorRepository, - IRepository trialRepository, - IRepository trialExtRepository, IRepository vacationRepository) - { - _doctorRepository = doctorInfoRepository; - _messageRepository = sysMessageRepository; - _enrollRepository = intoGroupRepository; - _doctorDictionaryRepository = doctorDictionaryRepository; - _attachmentRepository = attachmentRepository; - this._doctorCriterionFileRepository = doctorCriterionFileRepository; - _userDoctorRepository = userDoctorRepository; - _trialRepository = trialRepository; - _trialExtRepository = trialExtRepository; - _vacationRepository = vacationRepository; - } - - - - - #region 医生基本信息--查询、新增、更新 - - /// - /// 添加/更新 医生基本信息 BasicInfo - /// - - [HttpPost] - public async Task> AddOrUpdateDoctorBasicInfo(DoctorBasicInfoCommand basicInfoModel) - { - Expression> verifyExp = t => t.Phone == basicInfoModel.Phone || t.EMail == basicInfoModel.EMail; - - //---current phone or email number already existed - var verifyPair = new KeyValuePair>, string>(verifyExp, _localizer["Doctor_DupPhoneOrEmail"]); - - if (basicInfoModel.Id == Guid.Empty || basicInfoModel.Id == null) - { - - var doctor = _mapper.Map(basicInfoModel); - - //验证用户手机号 - if (await _doctorRepository.AnyAsync(t => t.Phone == doctor.Phone)) - { - //---The current phone number already existed! - return ResponseOutput.NotOk(_localizer["Doctor_DupPhone"], new DoctorBasicInfoCommand()); - } - - if (await _doctorRepository.AnyAsync(t => t.EMail == doctor.EMail)) - { - //---The current email already existed! - return ResponseOutput.NotOk(_localizer["Doctor_DupEmail"], new DoctorBasicInfoCommand()); - } - - doctor.Code = (await _doctorRepository.MaxAsync(t => t.Code)) + 1; - - doctor.ReviewerCode = AppSettings.GetCodeStr(doctor.Code, nameof(Doctor)); - - doctor.Password = MD5Helper.Md5(doctor.Phone); - - //插入中间表 - basicInfoModel.TitleIds.ForEach(titleId => doctor.DoctorDicRelationList.Add(new DoctorDictionary() { DoctorId = doctor.Id, KeyName = StaticData.Title, DictionaryId = titleId })); - - - await _doctorRepository.AddAsync(doctor); - //_doctorRepository.Add(doctor); - - //await _repository.AddAsync(new UserDoctor() { DoctorId = doctor.Id, UserId = _userInfo.Id }); - //_userDoctorRepository.Add(new UserDoctor() { DoctorId = doctor.Id, UserId = _userInfo.Id }); - - var success = await _repository.SaveChangesAsync(); - return ResponseOutput.Result(success, _mapper.Map(doctor)); - - } - else - { - var updateModel = basicInfoModel; - - var phone = updateModel.Phone.Trim(); - if ((await _doctorRepository.FirstOrDefaultAsync(t => t.Phone == phone && t.Id != updateModel.Id)) != null) - { - //---The current phone number already existed! - return ResponseOutput.NotOk(_localizer["Doctor_DupPhone"], new DoctorBasicInfoCommand()); - } - var email = updateModel.EMail.Trim(); - if (await _doctorRepository.AnyAsync(t => t.EMail == email && t.Id != updateModel.Id)) - { - //---The current email already existed! - return ResponseOutput.NotOk(_localizer["Doctor_DupEmail"], new DoctorBasicInfoCommand()); - } - - var doctor = await _doctorRepository.FirstOrDefaultAsync(t => t.Id == updateModel.Id).IfNullThrowException(); - - //删除中间表 Title对应的记录 - await _repository.BatchDeleteAsync(t => t.DoctorId == updateModel.Id && t.KeyName == StaticData.Title); - - - var adddata = new List(); - //重新插入新的 Title记录 - updateModel.TitleIds.ForEach(titleId => adddata.Add(new DoctorDictionary() { DoctorId = updateModel.Id.Value, KeyName = StaticData.Title, DictionaryId = titleId })); - - await _repository.AddRangeAsync(adddata); - - _mapper.Map(basicInfoModel, doctor); - - var success = await _repository.SaveChangesAsync(); - - return ResponseOutput.Result(success, basicInfoModel); - - } - - } - - - /// - ///详情、编辑-获取 医生基本信息 BasicInfo - /// - /// ReviewerID - /// - - [HttpGet("{doctorId:guid}")] - public async Task GetBasicInfo(Guid doctorId) - { - - #region 用导航属性直接查询 - - //SELECT[t].[Id], [t].[Code], [t].[ChineseName], [t].[EMail], [t].[FirstName], [t].[Introduction], [t].[LastName], [t].[Phone], [t].[Sex], [t].[WeChat], [t].[Nation], [t0].[Title], [t0].[TitleCN], [t0].[TitleId], [t0].[ShowOrder], [t0].[Id], [t0].[Id0] - //FROM( - // SELECT TOP(1)[d].[Id], [d].[Code], [d].[ChineseName], [d].[EMail], [d].[FirstName], [d].[Introduction], [d].[LastName], [d].[Phone], [d].[Sex], [d].[WeChat], [d].[Nation] - // FROM[Doctor] AS[d] WITH(NOLOCK) - // WHERE[d].[Id] = @__doctorId_0 - //) AS[t] - //LEFT JOIN( - // SELECT[d1].[Value] AS[Title], [d1].[ValueCN] AS[TitleCN], [d0].[DictionaryId] AS[TitleId], [d1].[ShowOrder], [d0].[Id], [d1].[Id] AS[Id0], [d0].[DoctorId] - // FROM [DoctorDictionary] AS [d0] WITH (NOLOCK) - // INNER JOIN[Dictionary] AS [d1] WITH (NOLOCK) ON [d0].[DictionaryId] = [d1].[Id] - // WHERE[d0].[KeyName] = N'Title' - //) AS[t0] ON[t].[Id] = [t0].[DoctorId] - //ORDER BY[t].[Id], [t0].[ShowOrder], [t0].[Id] - - //var doctorQueryable = _doctorRepository - // .Find(t => t.Id == doctorId) - // .Select(doctor => new DoctorBasicInfoDTO() - // { - // Id = doctor.Id, - // Code = doctor.Code, - // ChineseName = doctor.ChineseName, - // EMail = doctor.EMail, - // FirstName = doctor.FirstName, - // Introduction = doctor.Introduction, - // LastName = doctor.LastName, - // Phone = doctor.Phone, - // Sex = doctor.Sex, - // WeChat = doctor.WeChat, - // Nation = doctor.Nation, - - // //不要分三个属性查询,会做三次左连接,这样 只会一个左连接 - // TempObjList = doctor.DoctorDicList.Where(t => t.KeyName == StaticData.Title) - // .Select(t => new TempObj { Title = t.Dictionary.Value, TitleCN = t.Dictionary.ValueCN, TitleId = t.DictionaryId, ShowOrder = t.Dictionary.ShowOrder }).OrderBy(k => k.ShowOrder).ToList(), - // }); - - //var doctorBasicInfo = doctorQueryable.FirstOrDefault(); - - - - - #endregion - - var doctorBasicInfo = (await _doctorRepository.Where(t => t.Id == doctorId) - .ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync()).IfNullThrowException(); - - return doctorBasicInfo; - - - } - - #endregion - - #region Employment信息--查询和更新 - /// - /// 详情、编辑-获取医生工作信息 Employment - /// - [HttpGet("{doctorId:Guid}")] - public async Task GetEmploymentInfo(Guid doctorId) - { - - #region init EF select 废弃 - //var dic = GetDictionary(); - - //var employmentQueryable = from doctorItem in _doctorRepository - // .Where(t => t.Id == doctorId) - // join hospitalItem in _hospitalRepository.AsQueryable() on doctorItem.HospitalId equals hospitalItem.Id into g - // from hospital in g.DefaultIfEmpty() - // select new EmploymentDTO() - // { - // Id = doctorItem.Id, - // //部门 - // DepartmentId = doctorItem.DepartmentId, - // DepartmentOther = doctorItem.DepartmentOther, - // DepartmentOtherCN = doctorItem.DepartmentOtherCN, - - // //医院 - // HospitalId = doctorItem.HospitalId, - - // PositionId = doctorItem.PositionId, - // PositionOther = doctorItem.PositionOther, - // PositionOtherCN = doctorItem.PositionOtherCN, - - // RankId = doctorItem.RankId, - // RankOther = doctorItem.RankOther, - // RankOtherCN = doctorItem.RankOtherCN, - - // City = hospital.City, - // Country = hospital.Country, - // UniversityAffiliated = hospital.UniversityAffiliated, - // HospitalName = hospital.HospitalName, - // Province = hospital.Province, - - // CityCN = hospital.CityCN, - // CountryCN = hospital.CountryCN, - // UniversityAffiliatedCN = hospital.UniversityAffiliatedCN, - // HospitalNameCN = hospital.HospitalNameCN, - // ProvinceCN = hospital.ProvinceCN - // }; - - //var employmentInfo = employmentQueryable.FirstOrDefault(); - - //if (employmentInfo != null) - //{ - // //医院信息设置 - // if (employmentInfo.HospitalId == Guid.Empty) - // { - // employmentInfo.City = string.Empty; - // employmentInfo.Country = string.Empty; - // employmentInfo.UniversityAffiliated = string.Empty; - // employmentInfo.HospitalName = string.Empty; - // employmentInfo.Province = string.Empty; - // } - // employmentInfo.Department = employmentInfo.DepartmentId == Guid.Empty ? employmentInfo.DepartmentOther : dic.FirstOrDefault(o => o.Id == employmentInfo.DepartmentId)?.Value ?? ""; - - // employmentInfo.Rank = employmentInfo.RankId == Guid.Empty ? employmentInfo.RankOther : dic.FirstOrDefault(o => o.Id == employmentInfo.RankId)?.Value ?? ""; - - // employmentInfo.Position = employmentInfo.PositionId == Guid.Empty ? employmentInfo.PositionOther : dic.FirstOrDefault(o => o.Id == employmentInfo.PositionId)?.Value ?? ""; - - - // employmentInfo.DepartmentCN = employmentInfo.DepartmentId == Guid.Empty ? employmentInfo.DepartmentOther : dic.FirstOrDefault(o => o.Id == employmentInfo.DepartmentId)?.ValueCN ?? ""; - - // employmentInfo.RankCN = employmentInfo.RankId == Guid.Empty ? employmentInfo.RankOther : dic.FirstOrDefault(o => o.Id == employmentInfo.RankId)?.ValueCN ?? ""; - - // employmentInfo.PositionCN = employmentInfo.PositionId == Guid.Empty ? employmentInfo.PositionOther : dic.FirstOrDefault(o => o.Id == employmentInfo.PositionId)?.ValueCN ?? ""; - //} - #endregion - - var query = _doctorRepository.Where(t => t.Id == doctorId) - .ProjectTo(_mapper.ConfigurationProvider); - - var employmentInfo = (await query.FirstOrDefaultAsync()).IfNullThrowException(); - - return employmentInfo; - } - - [HttpPost] - - public async Task UpdateEmploymentInfo(EmploymentCommand doctorWorkInfoModel) - { - #region 废弃 - //var success = _doctorRepository.Update(d => d.Id == doctorWorkInfoModel.Id, u => new Doctor() - //{ - // DepartmentId = doctorWorkInfoModel.DepartmentId, - // DepartmentOther = doctorWorkInfoModel.DepartmentOther, - // DepartmentOtherCN = doctorWorkInfoModel.DepartmentOtherCN, - - // SpecialityId = doctorWorkInfoModel.DepartmentId, - // SpecialityOther = doctorWorkInfoModel.DepartmentOther, - // SpecialityOtherCN = doctorWorkInfoModel.DepartmentOtherCN, - - // RankId = doctorWorkInfoModel.RankId, - // RankOther = doctorWorkInfoModel.RankOther, - // RankOtherCN = doctorWorkInfoModel.RankOtherCN, - - // PositionId = doctorWorkInfoModel.PositionId, - // PositionOther = doctorWorkInfoModel.PositionOther, - // PositionOtherCN = doctorWorkInfoModel.PositionOtherCN, - - // HospitalId = doctorWorkInfoModel.HospitalId, - // UpdateTime = DateTime.Now - //}); - - //var doctor = _doctorRepository.FirstOrDefault(d => d.Id == doctorWorkInfoModel.Id); - //_mapper.Map(doctorWorkInfoModel, doctor); - //var success = _doctorRepository.SaveChanges(); - #endregion - - - var entity = await _repository.InsertOrUpdateAsync(doctorWorkInfoModel, true); - - - return ResponseOutput.Ok(); - } - - #endregion - - - #region 医生技能信息 查询和 更新 - [HttpGet, Route("{doctorId:Guid}")] - public async Task GetSpecialtyInfo(Guid doctorId) - { - - #region 利用导航属性直接查询出来 生成的sql ok 废弃 - - //var specialtyQueryable = _doctorRepository - // .Where(t => t.Id == doctorId).Include(u => u.DoctorDicRelationList) - // .Select(specialty => new SpecialtyDTO() - // { - // Id = specialty.Id, - // ReadingTypeOther = specialty.ReadingTypeOther, - // ReadingTypeOtherCN = specialty.ReadingTypeOtherCN, - - // SubspecialityOther = specialty.SubspecialityOther, - // SubspecialityOtherCN = specialty.SubspecialityOtherCN, - - - // DictionaryList = specialty.DoctorDicRelationList.Where(t => t.KeyName == StaticData.ReadingType || t.KeyName == StaticData.Subspeciality) - // .Select(t => new SpecialtyDTO.DoctorDictionaryView() { DictionaryId = t.DictionaryId, Value = t.Dictionary.Value, ValueCN = t.Dictionary.ValueCN, ShowOrder = t.Dictionary.ShowOrder, KeyName = t.Dictionary.KeyName }) - // .OrderBy(t => t.ShowOrder).ToList(), - - // SpecialityId = specialty.SpecialityId, - // Speciality = specialty.Speciality.Value, - // SpecialityCN = specialty.Speciality.ValueCN, - - // SpecialityOther = specialty.SpecialityOther, - // SpecialityOtherCN = specialty.SpecialityOtherCN - // }); - - //var specialtyInfo = specialtyQueryable.FirstOrDefault(); - - //return specialtyInfo; - - #endregion - - - var test = await (_doctorRepository.Where(t => t.Id == doctorId) - .ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync()).IfNullThrowException(); - - return test; - } - - - [HttpPost] - public async Task UpdateSpecialtyInfo(SpecialtyCommand specialtyUpdateModel) - { - var doctor = await _doctorRepository.FirstOrDefaultAsync(t => t.Id == specialtyUpdateModel.Id); - - if (doctor == null) return Null404NotFound(doctor); - - - - ////删除中间表 - //_doctorDictionaryRepository.Delete(t => - // t.DoctorId == specialtyUpdateModel.Id && t.KeyName == StaticData.Subspeciality); - //_doctorDictionaryRepository.Delete(t => - // t.DoctorId == specialtyUpdateModel.Id && t.KeyName == StaticData.ReadingType); - - await _repository.BatchDeleteAsync(t => - t.DoctorId == specialtyUpdateModel.Id && (t.KeyName == StaticData.Subspeciality || t.KeyName == StaticData.ReadingType)); - - - - - - //重新插入新的 - var adddata = new List(); - specialtyUpdateModel.ReadingTypeIds.ForEach(readingTypeId => adddata.Add( - new DoctorDictionary() - { - DoctorId = specialtyUpdateModel.Id, - KeyName = StaticData.ReadingType, - DictionaryId = readingTypeId - })); - specialtyUpdateModel.SubspecialityIds.ForEach(subspecialityId => adddata.Add( - new DoctorDictionary() - { - DoctorId = specialtyUpdateModel.Id, - KeyName = StaticData.Subspeciality, - DictionaryId = subspecialityId - })); - - await _repository.AddRangeAsync(adddata); - - _mapper.Map(specialtyUpdateModel, doctor); - - var success = await _repository.SaveChangesAsync(); - return ResponseOutput.Result(success); - - - } - #endregion - - #region 简历审核 - - [HttpPost] - public async Task UpdateAuditResume(ResumeConfirmCommand auditResumeParam) - { - var userId = _userInfo.Id; - //判断 合作协议、正式简历 是否有。如果没有,显示提示信息,并且不能保存 - var attachmentList = await _attachmentRepository.Where(u => u.DoctorId == auditResumeParam.Id) - .Select(u => u.Type).ToListAsync(); - if (auditResumeParam.ResumeStatus == ResumeStatusEnum.Pass && ((!attachmentList.Contains("Resume")) || (!attachmentList.Contains("Consultant Agreement")))) - { - //---Resume & Consultant Agreement must be upload - return ResponseOutput.NotOk(_localizer["Doctor_RequiredDocumentsError"]); - } - var success = await _doctorRepository.BatchUpdateNoTrackingAsync(o => o.Id == auditResumeParam.Id, u => new Doctor() - { - CooperateStatus = auditResumeParam.CooperateStatus, - ResumeStatus = auditResumeParam.ResumeStatus, - AdminComment = auditResumeParam.AdminComment, - ReviewStatus = auditResumeParam.ReviewStatus, - AcceptingNewTrial = auditResumeParam.AcceptingNewTrial, - ActivelyReading = auditResumeParam.ActivelyReading, - IsVirtual = auditResumeParam.IsVirtual, - BlindName = auditResumeParam.BlindName, - BlindNameCN = auditResumeParam.BlindNameCN, - BlindPublications = auditResumeParam.BlindPublications, - AuditTime = DateTime.Now, - AuditUserId = userId - }); - - if (success) - { - if (!string.IsNullOrWhiteSpace(auditResumeParam.MessageContent)) - { - var message = new Message - { - FromUserId = userId, - ToDoctorId = auditResumeParam.Id, - Title = "Resume review results", - Content = auditResumeParam.MessageContent, - HasRead = false, - MessageTime = DateTime.Now - }; - await _repository.AddAsync(message); - success = await _repository.SaveChangesAsync(); - } - } - - return ResponseOutput.Result(success); - } - - /// - /// 添加修改医生标准文件 - /// - /// - /// - [HttpPost] - public async Task AddDoctorCriterionFile(AddDoctorCriterionFileDto inDto) - { - - if (await _doctorCriterionFileRepository.AnyAsync(x => inDto.IsEnable && x.DoctorId == inDto.DoctorId && x.FileType == inDto.FileType && x.TrialId==inDto.TrialId &&x.TrialReadingCriterionId==inDto.TrialReadingCriterionId && x.IsEnable && x.CriterionType == inDto.CriterionType && x.Id != inDto.Id)) - { - //-----------当前标准已添加过此类型文件 - throw new BusinessValidationFailedException(_localizer["Doctor_StandardDuplicateFileTypeError"]); - } - - - var entity = await _doctorCriterionFileRepository.InsertOrUpdateAsync(inDto); - - if (inDto.TrialId != null) - { - entity.Remark = await _trialRepository.Where(t => t.Id == inDto.TrialId).Select(t => t.TrialCode).FirstOrDefaultAsync(); - } - - - await _doctorCriterionFileRepository.SaveChangesAsync(); - - return ResponseOutput.Ok(entity.Id.ToString()); - - } - - /// - /// 删除医生标准文件 - /// - /// - /// - [HttpPost] - public async Task DeleteDoctorCriterionFile(DeleteDoctorCriterionFile inDto) - { - var result = await _doctorCriterionFileRepository.DeleteFromQueryAsync(inDto.Id, true); - return ResponseOutput.Ok(result.Id.ToString()); - } - - /// - /// 获取医生标准文件 - /// - /// - /// - [HttpPost] - public async Task> GetDoctorCriterionFile(GetDoctorCriterionFileInDto inDto) - { - var result = await _doctorCriterionFileRepository.Where(x => x.DoctorId == inDto.DoctorId) - .WhereIf(inDto.CriterionType != null, x => x.CriterionType == inDto.CriterionType) - .WhereIf(inDto.FileType != null, x => x.FileType == inDto.FileType) - .ProjectTo(_mapper.ConfigurationProvider) - .ToListAsync(); - return result; - } - - - [HttpGet("{doctorId:guid}")] - public async Task GetAuditState(Guid doctorId) - { - var doctor = (await _doctorRepository - .ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync(t => t.Id == doctorId)).IfNullThrowException(); - - doctor.InHoliday = (await _repository.CountAsync(x => x.DoctorId == doctorId && x.EndDate <= DateTime.Now && x.StartDate <= DateTime.Now)) > 0; - - return doctor; - } - - - /// - /// 获取医生入组信息 正在提交的数量 已同意入组项目个数 正在读的 - /// - [HttpPost, Route("{doctorId:guid}")] - public DoctorEnrollInfoDTO GetDoctorIntoGroupInfo(Guid doctorId) - { - var doctorQueryable = - from doctor in _doctorRepository.Where(t => t.Id == doctorId) - join intoGroupItem in _enrollRepository.AsQueryable() on doctor.Id equals intoGroupItem.DoctorId - into t - from intoGroupItem in t.DefaultIfEmpty() - group intoGroupItem by intoGroupItem.DoctorId - into g - select new DoctorEnrollInfoDTO - { - DoctorId = g.Key, - - //Submitted = g.Sum(t => - // t.EnrollStatus == (int)EnrollStatus.HasCommittedToCRO ? 1 : 0), - //Approved = g.Sum(t => - // t.EnrollStatus == (int)EnrollStatus.InviteIntoGroup ? 1 : 0), - //Reading = g.Sum(t => - // t.EnrollStatus == (int)EnrollStatus.DoctorReading ? 1 : 0) - - Submitted = g.Count(t => - t.EnrollStatus == EnrollStatus.HasCommittedToCRO), - Approved = g.Count(t => - t.EnrollStatus == EnrollStatus.InviteIntoGroup), - Reading = g.Count(t => - t.EnrollStatus == EnrollStatus.DoctorReading) - }; - - return doctorQueryable.FirstOrDefault().IfNullThrowException(); - } - - - /// - /// Get Statement of Work list.[New] - /// - [HttpGet("{doctorId:guid}")] - public List GetDoctorSowList(Guid doctorId) - { - var query = from enroll in _enrollRepository.Where(u => u.DoctorId == doctorId && u.EnrollStatus >= EnrollStatus.ConfirmIntoGroup) - join trialExt in _trialExtRepository.AsQueryable() on enroll.TrialId equals trialExt.TrialId - join trial in _trialRepository.AsQueryable() on enroll.TrialId equals trial.Id - select new SowDTO - { - FileName = trialExt.SowName, - FilePath = trialExt.SowPath, - TrialCode = trial.TrialCode, - CreateTime = trialExt.CreateTime - }; - return query.ToList().Where(u => !string.IsNullOrWhiteSpace(u.FileName)).ToList(); - } - - /// - /// Get Ack Statement of Work[New] - /// - [HttpGet("{doctorId:guid}")] - public List GetDoctorAckSowList(Guid doctorId) - { - var query = from enroll in _enrollRepository.Where(u => u.DoctorId == doctorId) - join attachment in _attachmentRepository.Where(u => u.DoctorId == doctorId) - on enroll.AttachmentId equals attachment.Id - join trial in _trialRepository.AsQueryable() on enroll.TrialId equals trial.Id - select new SowDTO - { - FileName = attachment.FileName, - FilePath = attachment.Path, - TrialCode = trial.TrialCode, - CreateTime = attachment.CreateTime - }; - return query.ToList(); - } - - #endregion - - } -} diff --git a/IRaCIS.Core.Application/Service/Doctor/EducationService.cs b/IRaCIS.Core.Application/Service/Doctor/EducationService.cs deleted file mode 100644 index 05273e9da..000000000 --- a/IRaCIS.Core.Application/Service/Doctor/EducationService.cs +++ /dev/null @@ -1,140 +0,0 @@ - -using IRaCIS.Application.Interfaces; -using IRaCIS.Application.Contracts; -using IRaCIS.Core.Infra.EFCore; -using IRaCIS.Core.Domain.Share; -using IRaCIS.Core.Application.Filter; -using IRaCIS.Core.Infrastructure.Extention; -using Microsoft.AspNetCore.Mvc; - -namespace IRaCIS.Application.Services -{ - [ApiExplorerSettings(GroupName = "Reviewer")] - public class EducationService : BaseService, IEducationService - { - private readonly IRepository _postgraduateRepository; - private readonly IRepository _educationRepository; - - public EducationService(IRepository doctorNormalEducationRepository, - IRepository doctorContinueLearningRepository) - { - _educationRepository = doctorNormalEducationRepository; - _postgraduateRepository = doctorContinueLearningRepository; - } - - /// - /// 根据医生Id获取医生教育经历和继续学习经历列表 - /// - [HttpGet("{doctorId:Guid}")] - public async Task GetEducation(Guid doctorId) - { - var educationList = await _educationRepository.Where(o => o.DoctorId == doctorId) - .OrderBy(t => t.CreateTime).ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); - - var postgraduateList = await _postgraduateRepository.Where(o => o.DoctorId == doctorId) - .OrderBy(t => t.CreateTime).ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); - - - return new DoctorEducationExperienceDTO() - { - EducationList = educationList, - PostgraduateList = postgraduateList - }; - - } - /// - /// 新增医生教育经历 - /// - /// - /// - [HttpPost] - public async Task AddOrUpdateEducationInfo(EducationCommand educationInfoViewModel) - { - if (educationInfoViewModel.Id == Guid.Empty || educationInfoViewModel.Id == null) - { - var doctorEducationInfo = _mapper.Map(educationInfoViewModel); - switch (educationInfoViewModel.Degree) - { - case StaticData.ReviewerDegree.Bachelor: - doctorEducationInfo.ShowOrder = 1; - break; - case StaticData.ReviewerDegree.Master: - doctorEducationInfo.ShowOrder = 2; - break; - case StaticData.ReviewerDegree.Doctorate: - doctorEducationInfo.ShowOrder = 3; - break; - } - await _educationRepository.AddAsync(doctorEducationInfo); - var success = await _repository.SaveChangesAsync(); - - return ResponseOutput.Result(success, doctorEducationInfo.Id.ToString()); - } - - else - { - var needUpdate = await _educationRepository.FirstOrDefaultAsync(t => t.Id == educationInfoViewModel.Id); - - if (needUpdate == null) return Null404NotFound(needUpdate); - - _mapper.Map(educationInfoViewModel, needUpdate); - - var success = await _repository.SaveChangesAsync(); - - return ResponseOutput.Ok(success); - - } - //_educationRepository.Update(needUpdate); - - - } - - [HttpDelete, Route("{doctorId:guid}")] - public async Task DeleteEducationInfo(Guid id) - { - var success = await _educationRepository.BatchDeleteNoTrackingAsync(o => o.Id == id); - - return ResponseOutput.Result(success); - } - /// 添加/更新医生继续学习经历 - - [HttpPost] - public async Task AddOrUpdatePostgraduateInfo(PostgraduateCommand postgraduateViewModel) - { - #region 封装前 - - //if (postgraduateViewModel.Id == Guid.Empty || postgraduateViewModel.Id == null) - //{ - // var doctorContinueLearning = _mapper.Map(postgraduateViewModel); - // _postgraduateRepository.Add(doctorContinueLearning); - // var success = _postgraduateRepository.SaveChanges(); - - // return ResponseOutput.Result(success, doctorContinueLearning.Id.ToString()); - //} - //else - //{ - // _postgraduateRepository.Update(_mapper.Map(postgraduateViewModel)); - // var success = _postgraduateRepository.SaveChanges(); - - // return ResponseOutput.Result(success); - - //} - #endregion - - var entity = await _repository.InsertOrUpdateAsync(postgraduateViewModel, true); - return ResponseOutput.Ok(entity.Id); - } - /// - /// 删除医生继续学习经历 - /// - /// 医生Id - /// - - [HttpDelete("{doctorId:guid}")] - public async Task DeletePostgraduateInfo(Guid doctorId) - { - var success = await _repository.BatchDeleteAsync(o => o.Id == doctorId); - return ResponseOutput.Result(success); - } - } -} \ No newline at end of file diff --git a/IRaCIS.Core.Application/Service/Doctor/Interface/IAttachmentService.cs b/IRaCIS.Core.Application/Service/Doctor/Interface/IAttachmentService.cs deleted file mode 100644 index f93c4786e..000000000 --- a/IRaCIS.Core.Application/Service/Doctor/Interface/IAttachmentService.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; -using System.Collections.Generic; - -using IRaCIS.Application.Contracts; - -using IRaCIS.Core.Infrastructure.Extention; - -namespace IRaCIS.Application.Interfaces -{ - public interface IAttachmentService - { - Task> SaveAttachments(IEnumerable attachmentList); - - - Task> AddAttachment(AttachmentDTO attachment); - Task DeleteAttachment(AttachementCommand param); - Task GetDetailById(Guid attachmentId); - Task> GetAttachmentByType(Guid doctorId, string type); - Task> GetAttachmentByTypes(Guid doctorId, string[] types); - Task> GetAttachments(Guid doctorId); - Task GetDoctorOfficialCV(int language, Guid doctorId); - - Task SetOfficial(Guid doctorId, Guid attachmentId, int language); - - Task SetLanguage(Guid doctorId, Guid attachmentId, int language); - } -} diff --git a/IRaCIS.Core.Application/Service/Doctor/Interface/IDoctorAccountService.cs b/IRaCIS.Core.Application/Service/Doctor/Interface/IDoctorAccountService.cs deleted file mode 100644 index 44d21496f..000000000 --- a/IRaCIS.Core.Application/Service/Doctor/Interface/IDoctorAccountService.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; - -using IRaCIS.Application.Contracts; -using IRaCIS.Core.Infrastructure.Extention; - -namespace IRaCIS.Application.Interfaces -{ - public interface IDoctorAccountService - { - IResponseOutput Register(DoctorAccountRegisterModel doctorAccount); - DoctorAccountDTO Login(DoctorAccountLoginDTO doctorAccount); - IResponseOutput UpdatePassword(DoctorAccountUpdatePasswordCommand doctorAccount); - } -} diff --git a/IRaCIS.Core.Application/Service/Doctor/Interface/IDoctorListQueryService.cs b/IRaCIS.Core.Application/Service/Doctor/Interface/IDoctorListQueryService.cs deleted file mode 100644 index 8c8faf99e..000000000 --- a/IRaCIS.Core.Application/Service/Doctor/Interface/IDoctorListQueryService.cs +++ /dev/null @@ -1,32 +0,0 @@ -using IRaCIS.Application.Contracts; - -namespace IRaCIS.Application.Interfaces -{ - public interface IDoctorListQueryService - { - /// - /// 医生多条件查询 - /// - Task> GetDoctorSearchList(DoctorSearchDTO param); - - /// - /// 筛选医生列表 - /// - /// - /// - // - Task> GetSelectionReviewerList( - ReviewerSelectionQueryDTO doctorSearchModel); - - /// - /// //入组 相关接口 (提交CRO-1) CRO确认-4 - /// - Task> GetSubmissionOrApprovalReviewerList( - ReviewerSubmissionQueryDTO doctorIntoGroupSearchModel); - - - //医生确认状态列表 - Task> GetConfirmationReviewerList( - ReviewerConfirmationQueryDTO trialIdPageModel); - } -} diff --git a/IRaCIS.Core.Application/Service/Doctor/Interface/IDoctorService.cs b/IRaCIS.Core.Application/Service/Doctor/Interface/IDoctorService.cs deleted file mode 100644 index cffc2524c..000000000 --- a/IRaCIS.Core.Application/Service/Doctor/Interface/IDoctorService.cs +++ /dev/null @@ -1,74 +0,0 @@ -using System; -using System.Collections.Generic; -using IRaCIS.Application.Contracts; -using IRaCIS.Core.Infrastructure.Extention; - -namespace IRaCIS.Application.Interfaces -{ - public interface IDoctorService - { - #region 医生 基本信息 - - /// - /// 基本信息详情展示、编辑使用 - /// - /// - /// - Task GetBasicInfo(Guid doctorId); - - /// - /// 添加医生基本信息 - /// - /// - /// - Task> AddOrUpdateDoctorBasicInfo(DoctorBasicInfoCommand addBasicInfoParam); - - #endregion - - #region 医生 工作信息 - - /// - /// 获取医生 工作信息 - /// - /// - /// - Task GetEmploymentInfo(Guid doctorId); - /// - /// 更新医生 工作信息 - /// - /// - /// - Task UpdateEmploymentInfo(EmploymentCommand updateDoctorWorkInfoViewModel); - - #endregion - - /// - /// 获取医生技能信息 - /// - Task GetSpecialtyInfo(Guid doctorId); - - /// - /// 更新医生技能信息 - /// - Task UpdateSpecialtyInfo(SpecialtyCommand specialtyUpdateModel); - - /// - /// 获取医生 审核状态 - /// - Task GetAuditState(Guid doctorId); - - /// - /// 审核简历 和合作关系 - /// - Task UpdateAuditResume(ResumeConfirmCommand auditResumeParam); - - /// 医生详情 入组信息 - DoctorEnrollInfoDTO GetDoctorIntoGroupInfo(Guid doctorId); - - /// 获取医生参与项目的Sow协议 - List GetDoctorSowList(Guid doctorId); - - /// 获取医生入组的 ack Sow - List GetDoctorAckSowList(Guid doctorId); - } -} diff --git a/IRaCIS.Core.Application/Service/Doctor/Interface/IEducationService.cs b/IRaCIS.Core.Application/Service/Doctor/Interface/IEducationService.cs deleted file mode 100644 index 958fdaed3..000000000 --- a/IRaCIS.Core.Application/Service/Doctor/Interface/IEducationService.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; -using IRaCIS.Application.Contracts; -using IRaCIS.Core.Infrastructure.Extention; - -namespace IRaCIS.Application.Interfaces -{ - public interface IEducationService - { - - Task GetEducation(Guid doctorId); - - #region 教育经历 - Task AddOrUpdateEducationInfo(EducationCommand doctorEducationInfoViewModel); - - Task DeleteEducationInfo(Guid doctorId); - - #endregion - - #region 继续教育经历 - Task AddOrUpdatePostgraduateInfo(PostgraduateCommand doctorContinueLearningViewModel); - Task DeletePostgraduateInfo(Guid doctorId); - - #endregion - - } -} \ No newline at end of file diff --git a/IRaCIS.Core.Application/Service/Doctor/Interface/IResearchPublicationService.cs b/IRaCIS.Core.Application/Service/Doctor/Interface/IResearchPublicationService.cs deleted file mode 100644 index ba983dede..000000000 --- a/IRaCIS.Core.Application/Service/Doctor/Interface/IResearchPublicationService.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using IRaCIS.Application.Contracts; -using IRaCIS.Core.Infrastructure.Extention; - -namespace IRaCIS.Application.Interfaces -{ - public interface IResearchPublicationService - { - Task GetResearchPublication(Guid doctorId); - - Task AddOrUpdateResearchPublication(ResearchPublicationDTO param); - } -} \ No newline at end of file diff --git a/IRaCIS.Core.Application/Service/Doctor/Interface/ITrialExperienceService.cs b/IRaCIS.Core.Application/Service/Doctor/Interface/ITrialExperienceService.cs deleted file mode 100644 index bb803c376..000000000 --- a/IRaCIS.Core.Application/Service/Doctor/Interface/ITrialExperienceService.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using IRaCIS.Application.Contracts; -using IRaCIS.Core.Infrastructure.Extention; - -namespace IRaCIS.Application.Interfaces -{ - public interface ITrialExperienceService - { - Task GetTrialExperience(Guid doctorId); - Task AddOrUpdateTrialExperience(TrialExperienceCommand model); - Task DeleteTrialExperience(Guid id); - Task UpdateGcpExperience(GCPExperienceCommand model); - Task UpdateOtherExperience(ClinicalExperienceCommand updateOtherClinicalExperience); - } -} \ No newline at end of file diff --git a/IRaCIS.Core.Application/Service/Doctor/Interface/IVacationService.cs b/IRaCIS.Core.Application/Service/Doctor/Interface/IVacationService.cs deleted file mode 100644 index 834864a99..000000000 --- a/IRaCIS.Core.Application/Service/Doctor/Interface/IVacationService.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; -using System.Collections.Generic; - -using IRaCIS.Application.Contracts; - -using IRaCIS.Core.Infrastructure.Extention; - -namespace IRaCIS.Application.Interfaces -{ - public interface IVacationService - { - Task AddOrUpdateVacation(VacationCommand vacationViewModel); - Task DeleteVacation(Guid id); - Task> GetVacationList(Guid doctorId, int pageIndex, int pageSize); - - /// 判断当前时间是否在休假 - Task OnVacation(Guid reviewerId); - } -} diff --git a/IRaCIS.Core.Application/Service/Doctor/ResearchPublicationService.cs b/IRaCIS.Core.Application/Service/Doctor/ResearchPublicationService.cs deleted file mode 100644 index 67925dce8..000000000 --- a/IRaCIS.Core.Application/Service/Doctor/ResearchPublicationService.cs +++ /dev/null @@ -1,41 +0,0 @@ -using IRaCIS.Application.Interfaces; -using IRaCIS.Application.Contracts; -using Microsoft.AspNetCore.Mvc; - -namespace IRaCIS.Application.Services -{ - [ApiExplorerSettings(GroupName = "Reviewer")] - public class ResearchPublicationService : BaseService, IResearchPublicationService - { - private readonly IRepository researchPublicationRepository; - - public ResearchPublicationService(IRepository _researchPublicationRepository) - { - researchPublicationRepository = _researchPublicationRepository; - } - - /// - /// 查询-医生科学研究信息 - /// - /// 医生Id - /// - [HttpGet("{doctorId:guid}")] - public async Task GetResearchPublication(Guid doctorId) - { - var doctorScientificResearchInfo = await researchPublicationRepository.Where(o => o.DoctorId == doctorId) - .ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync(); - - return doctorScientificResearchInfo; - } - - - [HttpPost] - public async Task AddOrUpdateResearchPublication(ResearchPublicationDTO param) - { - - var entity = await _repository.InsertOrUpdateAsync(param, true); - - return ResponseOutput.Ok(entity.Id); - } - } -} \ No newline at end of file diff --git a/IRaCIS.Core.Application/Service/Doctor/TrialExperienceService.cs b/IRaCIS.Core.Application/Service/Doctor/TrialExperienceService.cs deleted file mode 100644 index 6f629e9db..000000000 --- a/IRaCIS.Core.Application/Service/Doctor/TrialExperienceService.cs +++ /dev/null @@ -1,179 +0,0 @@ -using IRaCIS.Application.Interfaces; -using IRaCIS.Application.Contracts; -using Microsoft.AspNetCore.Mvc; - -namespace IRaCIS.Application.Services -{ - [ApiExplorerSettings(GroupName = "Reviewer")] - public class TrialExperienceService : BaseService, ITrialExperienceService - { - private readonly IRepository _trialExperienceRepository; - private readonly IRepository _doctorRepository; - private readonly IRepository _attachmentRepository; - private readonly IRepository _trialExperienceCriteriaRepository; - - - - public TrialExperienceService(IRepository trialExperienceRepository, IRepository doctorRepository, IRepository attachmentRepository, - IRepository trialExperienceCriteriaRepository) - { - _trialExperienceRepository = trialExperienceRepository; - _doctorRepository = doctorRepository; - _attachmentRepository = attachmentRepository; - _trialExperienceCriteriaRepository = trialExperienceCriteriaRepository; - - } - - - /// - /// 根据医生Id,获取临床试验经历 界面所有数据 - /// - [HttpGet("{doctorId:guid}")] - public async Task GetTrialExperience(Guid doctorId) - { - var trialExperience = new TrialExperienceModel(); - - var doctor = await _doctorRepository.Where(o => o.Id == doctorId) - .ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync(); - - trialExperience.ClinicalTrialExperienceList = await GetTrialExperienceList(doctorId); - - if (doctor != null) - { - trialExperience.GCP = doctor.GCP; - trialExperience.Id = doctor.Id; - trialExperience.OtherClinicalExperience = doctor.OtherClinicalExperience ?? ""; - trialExperience.OtherClinicalExperienceCN = doctor.OtherClinicalExperienceCN ?? ""; - var attachment = await _attachmentRepository.FirstOrDefaultAsync(t => t.Id == doctor.GCPId); - if (attachment != null) - { - trialExperience.ExpiryDateStr = attachment.ExpiryDate == null ? "" : attachment.ExpiryDate.Value.ToString("yyyy-MM-dd HH:mm"); - - trialExperience.Path = attachment.Path; - trialExperience.GCPFullPath = attachment.Path + "?access_token=" + _userInfo.UserToken; - trialExperience.Type = attachment.Type; - trialExperience.FileName = attachment.FileName; - trialExperience.GCPId = attachment.Id; - } - } - - return trialExperience; - } - - private async Task> GetTrialExperienceList(Guid doctorId) - { - var doctorClinicalTrialExperienceList = await _trialExperienceRepository.Where(o => o.DoctorId == doctorId).OrderBy(t => t.CreateTime) - .ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); - - return doctorClinicalTrialExperienceList; - - } - /// 添加或更新医生临床经验列表项 - - [HttpPost] - public async Task AddOrUpdateTrialExperience(TrialExperienceCommand trialExperienceViewModel) - { - if (trialExperienceViewModel.Id == Guid.Empty || trialExperienceViewModel.Id == null) - { - var trialExperience = - _mapper.Map(trialExperienceViewModel); - - trialExperience = await _repository.AddAsync(trialExperience); - - List criteriaList = new List(); - trialExperienceViewModel.EvaluationCriteriaIdList.ForEach(t => criteriaList.Add(new TrialExperienceCriteria() - { - DoctorId = trialExperienceViewModel.DoctorId, - //EvaluationCriteria = t.EvaluationCriteria, - EvaluationCriteriaId = t, - TrialExperienceId = trialExperience.Id - })); - - await _repository.AddRangeAsync(criteriaList); - - - var success = await _repository.SaveChangesAsync(); - return ResponseOutput.Result(success, trialExperience.Id); - } - else - { - var needUpdate = await _trialExperienceRepository.FirstOrDefaultAsync(t => t.Id == trialExperienceViewModel.Id); - - if (needUpdate == null) return Null404NotFound(needUpdate); - - _mapper.Map(trialExperienceViewModel, needUpdate); - await _repository.UpdateAsync(needUpdate); - - await _repository.BatchDeleteAsync(t => t.TrialExperienceId == needUpdate.Id); - - List criteriaList = new List(); - - trialExperienceViewModel.EvaluationCriteriaIdList.ForEach(t => criteriaList.Add(new TrialExperienceCriteria() - { - DoctorId = trialExperienceViewModel.DoctorId, - EvaluationCriteriaId = t, - TrialExperienceId = needUpdate.Id - })); - - await _repository.AddRangeAsync(criteriaList); - - - var success = await _repository.SaveChangesAsync(); - return ResponseOutput.Result(success, trialExperienceViewModel.Id); - } - } - - /// - /// 删除临床经验 - /// - - [HttpDelete, Route("{doctorId:guid}")] - public async Task DeleteTrialExperience(Guid doctorId) - { - var success = await _repository.BatchDeleteAsync(o => o.Id == doctorId); - return ResponseOutput.Result(success); - } - /// - /// 更新-GCP和其他临床经验 - /// - /// - /// - - [HttpPost] - public async Task UpdateGcpExperience(GCPExperienceCommand updateGCPExperienceParam) - { - //_attachmentRepository.Delete(t => t.DoctorId == updateGCPExperienceParam.Id && t.Type == StaticData.GCP); - - var successs = await _repository.BatchUpdateAsync(o => o.Id == updateGCPExperienceParam.Id, u => new Doctor() - { - GCP = updateGCPExperienceParam.GCP, - GCPId = updateGCPExperienceParam.GCP==0&&updateGCPExperienceParam.GCPId==null?Guid.Empty: updateGCPExperienceParam.GCPId!.Value - }); - - if (updateGCPExperienceParam.GCP == 0 && updateGCPExperienceParam.GCPId != null) - { - await _repository.BatchDeleteAsync(a => a.Id == updateGCPExperienceParam.GCPId); - } - - return ResponseOutput.Result(successs, updateGCPExperienceParam.GCPId.ToString()); - - } - - /// - /// 更新其他技能经验 - /// - - [HttpPost] - public async Task UpdateOtherExperience(ClinicalExperienceCommand updateOtherClinicalExperience) - { - var success = await _repository.BatchUpdateAsync(o => o.Id == updateOtherClinicalExperience.DoctorId, u => new Doctor() - { - OtherClinicalExperience = updateOtherClinicalExperience.OtherClinicalExperience ?? string.Empty, - OtherClinicalExperienceCN = updateOtherClinicalExperience.OtherClinicalExperienceCN ?? string.Empty - }); - - return ResponseOutput.Result(success); - } - - } -} \ No newline at end of file diff --git a/IRaCIS.Core.Application/Service/Doctor/VacationService.cs b/IRaCIS.Core.Application/Service/Doctor/VacationService.cs deleted file mode 100644 index 54f7b4ba0..000000000 --- a/IRaCIS.Core.Application/Service/Doctor/VacationService.cs +++ /dev/null @@ -1,88 +0,0 @@ -using IRaCIS.Application.Interfaces; -using IRaCIS.Application.Contracts; -using IRaCIS.Core.Infra.EFCore; -using Microsoft.AspNetCore.Mvc; -using Panda.DynamicWebApi.Attributes; - -namespace IRaCIS.Application.Services -{ - [ ApiExplorerSettings(GroupName = "Reviewer")] - public class VacationService : BaseService, IVacationService - { - private readonly IRepository _vacationRepository; - - public VacationService(IRepository vacationRepository) - { - _vacationRepository = vacationRepository; - } - /// - /// 添加休假时间段 - /// - /// Status不传 - /// - - [HttpPost] - public async Task AddOrUpdateVacation(VacationCommand param) - { - if (param.Id == Guid.Empty|| param.Id ==null) - { - var result = await _vacationRepository.AddAsync(_mapper.Map(param)); - - var success = await _repository.SaveChangesAsync(); - - return ResponseOutput.Result(success, result.Id); - - } - else - { - var success = await _vacationRepository.BatchUpdateNoTrackingAsync(u => u.Id == param.Id, - h => new Vacation - { - StartDate = param.StartDate, - EndDate = param.EndDate - }); - - return ResponseOutput.Result(success); - - } - - } - /// - /// 删除休假时间段 - /// - /// 记录Id - /// - - [HttpDelete("{holidayId:guid}")] - public async Task DeleteVacation(Guid holidayId) - { - var success = await _vacationRepository.BatchDeleteNoTrackingAsync(u => u.Id == holidayId); - - return ResponseOutput.Result(success); - - } - - /// - /// 获取休假时间段列表 - /// - /// - [HttpGet("{doctorId:guid}/{pageIndex:int}/{pageSize:int}")] - public async Task> GetVacationList(Guid doctorId, int pageIndex, int pageSize) - { - var query = _vacationRepository.Where(u => u.DoctorId == doctorId) - .ProjectTo(_mapper.ConfigurationProvider); - - return await query.ToPagedListAsync(pageIndex, pageSize, "StartDate"); - - } - - [NonDynamicMethod] - public async Task OnVacation(Guid doctorId) - { - var count = await _vacationRepository.CountAsync(u => u.DoctorId == doctorId && u.EndDate >= DateTime.Now && u.StartDate <= DateTime.Now); - - return ResponseOutput.Result(count > 0); - } - - } -} diff --git a/IRaCIS.Core.Application/Service/Doctor/_MapConfig.cs b/IRaCIS.Core.Application/Service/Doctor/_MapConfig.cs deleted file mode 100644 index 54928729e..000000000 --- a/IRaCIS.Core.Application/Service/Doctor/_MapConfig.cs +++ /dev/null @@ -1,159 +0,0 @@ -using AutoMapper; -using AutoMapper.EquivalencyExpression; -using IRaCIS.Application.Contracts; -using IRaCIS.Application.Contracts.Pay; -using IRaCIS.Core.Domain.Models; -using IRaCIS.Core.Domain.Share; - -namespace IRaCIS.Core.Application.Service -{ - public class DoctorConfig : Profile - { - public DoctorConfig() - { - #region reviewer - - //基本信息 工作信息 添加时转换使用 - CreateMap().EqualityComparison((odto, o) => odto.Id == o.Id); - - //学习经历 添加时转换使用 - CreateMap().EqualityComparison((odto, o) => odto.Id == o.Id); - CreateMap().EqualityComparison((odto, o) => odto.Id == o.Id); - CreateMap().EqualityComparison((odto, o) => odto.Id == o.Id); - CreateMap().EqualityComparison((odto, o) => odto.Id == o.Id); - - //医生账户 - CreateMap(); - CreateMap(); - - CreateMap().EqualityComparison((odto, o) => odto.Id == o.Id); - - - CreateMap().EqualityComparison((odto, o) => odto.Id == o.Id); - - CreateMap().EqualityComparison((odto, o) => odto.Id == o.Id); - - CreateMap(); - CreateMap(); - CreateMap(); - CreateMap(); - - CreateMap(); - CreateMap(); - CreateMap(); - CreateMap(); - CreateMap(); - CreateMap(); - - CreateMap(); - - CreateMap(); - CreateMap(); - - CreateMap(); - - #endregion - CreateMap(); - - CreateMap(); - - CreateMap().ReverseMap(); - - //医生列表、项目显示列表模型转换 - CreateMap(); - - CreateMap() - .ForMember(d => d.UserTypeShortName, u => u.MapFrom(t => t.UserTypeRole.UserTypeShortName)) - .ForMember(d => d.Code, u => u.MapFrom(t => t.UserCode)) - .ForMember(d => d.PermissionStr, u => u.MapFrom(t => t.UserTypeRole.PermissionStr)) - .ForMember(d => d.RealName, u => u.MapFrom(user => string.IsNullOrEmpty(user.FirstName) ? user.LastName : user.LastName + " / " + user.FirstName)); - - CreateMap() - .ForMember(d => d.Phase, u => u.MapFrom(t => t.Phase.Value)) - .ForMember(d => d.EvaluationCriteriaList, u => u.MapFrom(t => t.ExperienceCriteriaList.Select(t => t.EvaluationCriteria.Value))) - .ForMember(d => d.EvaluationCriteriaIdList, u => u.MapFrom(t => t.ExperienceCriteriaList.Select(t => t.EvaluationCriteriaId))); - - CreateMap() - .ForMember(d => d.Code, u => u.MapFrom(t => t.ReviewerCode)) - .ForMember(d => d.RealName, u => u.MapFrom(t => t.ChineseName)) - .ForMember(d => d.IsReviewer, u => u.MapFrom(t => true)) - .ForMember(d => d.UserName, u => u.MapFrom(doctor => doctor.LastName + " / " + doctor.FirstName)); - - #region 医生基本信息 - CreateMap(); - CreateMap().IncludeMembers(t => t.Hospital).Include() - .ForMember(d => d.AccountUserName, u => u.MapFrom(s => s.EnrollList.Where(t=>t.DoctorUserId!=null).Select(c=>c.DoctorUser.UserName).FirstOrDefault())) - .ForMember(d => d.Department, u => u.MapFrom(s => s.Department.Value)) - .ForMember(d => d.DepartmentCN, u => u.MapFrom(s => s.Department.ValueCN)) - .ForMember(d => d.Position, u => u.MapFrom(s => s.Position.Value)) - .ForMember(d => d.PositionCN, u => u.MapFrom(s => s.Position.ValueCN)) - .ForMember(d => d.Rank, u => u.MapFrom(s => s.Rank.Value)) - .ForMember(d => d.RankCN, u => u.MapFrom(s => s.Rank.ValueCN)) - .ForMember(d => d.Speciality, u => u.MapFrom(s => s.Speciality.Value)) - .ForMember(d => d.SpecialityCN, u => u.MapFrom(s => s.Speciality.ValueCN)) - .ForMember(d => d.HasResume, u => u.MapFrom(s => s.AttachmentList.Any(u => u.Type == "Resume" && u.IsOfficial))) - .ForMember(d => d.Submitted, u => u.MapFrom(s => s.EnrollList.Count(t => t.EnrollStatus == EnrollStatus.HasCommittedToCRO))) - .ForMember(d => d.Approved, u => u.MapFrom(s => s.EnrollList.Count(t => t.EnrollStatus == EnrollStatus.InviteIntoGroup))) - .ForMember(d => d.Reading, u => u.MapFrom(s => s.EnrollList.Count(t => t.EnrollStatus == EnrollStatus.DoctorReading))) - .ForMember(d => d.Finished, u => u.MapFrom(s => s.EnrollList.Count(t => t.EnrollStatus == EnrollStatus.Finished))) - .ForMember(d => d.Reconfirmed, u => u.MapFrom(s => s.ReviewStatus == ReviewerInformationConfirmStatus.ConfirmPass)) - .ForMember(o => o.DictionaryList, t => t.MapFrom(u => u.DoctorDicRelationList.Where(t => t.KeyName == StaticData.ReadingType || t.KeyName == StaticData.Subspeciality).Select(t => t.Dictionary).OrderBy(t => t.ShowOrder))); - CreateMap(); - - CreateMap(); - - - //这样会左连接三次 - // CreateMap() - //.ForMember(d => d.TitleCNList, u => u.MapFrom(s => s.DoctorDicRelationList.Where(t => t.KeyName == StaticData.Title) - //.Select(t => new { TitleCN = t.Dictionary.ValueCN, ShowOrder = t.Dictionary.ShowOrder }).OrderBy(k => k.ShowOrder).Select(t => t.TitleCN))) - // .ForMember(d => d.TitleList, u => u.MapFrom(s => s.DoctorDicRelationList.Where(t => t.KeyName == StaticData.Title) - //.Select(t => new { Title = t.Dictionary.Value, ShowOrder = t.Dictionary.ShowOrder }).OrderBy(k => k.ShowOrder).Select(t => t.Title))) - // .ForMember(d => d.TitleIds, u => u.MapFrom(s => s.DoctorDicRelationList.Where(t => t.KeyName == StaticData.Title) - //.Select(t => new { TitleId = t.Dictionary.Id, ShowOrder = t.Dictionary.ShowOrder }).OrderBy(k => k.ShowOrder).Select(t => t.TitleId))); - - //这样只会查询一次 - CreateMap() - .ForMember(o => o.DoctorDicViewDtos, t => t.MapFrom(u => u.DoctorDicRelationList.Where(t => t.KeyName == StaticData.Title).Select(t => t.Dictionary).OrderBy(t => t.ShowOrder))); - CreateMap() - .ForMember(t=>t.ParentCode,u=>u.MapFrom(c=>c.Parent.Code)); - //CreateMap(); - - CreateMap() - .ForMember(o => o.Speciality, t => t.MapFrom(u => u.Speciality.Value)) - .ForMember(o => o.DictionaryList, t => t.MapFrom(u => u.DoctorDicRelationList.Where(t => t.KeyName == StaticData.ReadingType || t.KeyName == StaticData.Subspeciality).Select(t => t.Dictionary).OrderBy(t => t.ShowOrder))); - CreateMap(); - - //医生职业信息 - CreateMap().IncludeMembers(t => t.Hospital) - .ForMember(d => d.Department, u => u.MapFrom(s => s.Department.Value)) - .ForMember(d => d.DepartmentCN, u => u.MapFrom(s => s.Department.ValueCN)) - .ForMember(d => d.Position, u => u.MapFrom(s => s.Position.Value)) - .ForMember(d => d.PositionCN, u => u.MapFrom(s => s.Position.ValueCN)) - .ForMember(d => d.Rank, u => u.MapFrom(s => s.Rank.Value)) - .ForMember(d => d.RankCN, u => u.MapFrom(s => s.Rank.ValueCN)); - CreateMap(); - - CreateMap() - .ForMember(d => d.IntoGroupState, u => u.MapFrom(s => s.EnrollStatus)) - .ForMember(d => d.OptTime, u => u.MapFrom(s => s.CreateTime)) - .ForMember(d => d.OptUserName, u => u.MapFrom(s => s.CreateUser.UserName)); - - CreateMap().IncludeMembers(t => t.Doctor, t => t.Doctor.Hospital) - .ForMember(o => o.DictionaryList, t => t.MapFrom(u => u.Doctor.DoctorDicRelationList.Where(t => t.KeyName == StaticData.ReadingType || t.KeyName == StaticData.Subspeciality).Select(t => t.Dictionary).OrderBy(t => t.ShowOrder))) - .ForMember(d => d.Speciality, u => u.MapFrom(s => s.Doctor.Speciality.Value)) - .ForMember(d => d.SpecialityCN, u => u.MapFrom(s => s.Doctor.Speciality.ValueCN)) - .ForMember(d => d.Id, u => u.MapFrom(s => s.Doctor.Id)) - .ForMember(d => d.Code, u => u.MapFrom(s => s.DoctorUser.UserName)) - ; - CreateMap(); - CreateMap(); - - - #endregion - - - } - } - -} diff --git a/IRaCIS.Core.Application/Service/Financial/CalculateService.cs b/IRaCIS.Core.Application/Service/Financial/CalculateService.cs deleted file mode 100644 index 4fdc05643..000000000 --- a/IRaCIS.Core.Application/Service/Financial/CalculateService.cs +++ /dev/null @@ -1,715 +0,0 @@ -using AutoMapper; -using IRaCIS.Application.Interfaces; -using IRaCIS.Application.Contracts; -using IRaCIS.Application.Contracts.Pay; -using IRaCIS.Core.Domain.Share; -using System.Linq.Expressions; -using IRaCIS.Core.Infra.EFCore; -using IRaCIS.Core.Domain.Models; -using IRaCIS.Core.Infrastructure.Extention; -using Panda.DynamicWebApi.Attributes; - -namespace IRaCIS.Application.Services -{ - public class CalculateService :BaseService, ICalculateService - { - private readonly IRepository _paymentRepository; - private readonly IRepository _trialPaymentRepository; - private readonly IRepository _doctorPayInfoRepository; - private readonly IRepository _trialRepository; - private readonly IRepository _doctorRepository; - private readonly IRepository _doctorWorkloadRepository; - private readonly IRepository _rankPriceRepository; - private readonly IRepository _paymentDetailRepository; - private readonly IVolumeRewardService _volumeRewardPriceService; - private readonly IRepository _exchangeRateRepository; - private readonly IRepository _payAdjustmentRepository; - private readonly IRepository _enrollRepository; - private readonly IMapper _mapper; - - public CalculateService(IRepository paymentRepository, IRepository trialPaymentPriceRepository, - IRepository reviewerPayInfoRepository, - IRepository trialRepository, - IRepository doctorRepository, - IRepository workloadRepository, - IRepository rankPriceRepository, - IRepository paymentDetailRepository, - IVolumeRewardService volumeRewardService, - IRepository exchangeRateRepository, - IRepository EnrollRepository, - IRepository paymentAdjustmentRepository, IMapper mapper) - { - _paymentRepository = paymentRepository; - _trialPaymentRepository = trialPaymentPriceRepository; - _doctorPayInfoRepository = reviewerPayInfoRepository; - _trialRepository = trialRepository; - _doctorRepository = doctorRepository; - _doctorWorkloadRepository = workloadRepository; - _rankPriceRepository = rankPriceRepository; - _paymentDetailRepository = paymentDetailRepository; - _volumeRewardPriceService = volumeRewardService; - _exchangeRateRepository = exchangeRateRepository; - _payAdjustmentRepository = paymentAdjustmentRepository; - this._enrollRepository = EnrollRepository; - _mapper = mapper; - } - - /// - /// 获取某个月下的某些医生最终确认的工作量,用于计算月度费用 - /// - private async Task< List> GetFinalConfirmedWorkloadAndPayPriceList(CalculateDoctorAndMonthDTO calculateFeeParam) - { - Expression> workloadLambda = x => true; - - DateTime bTime = new DateTime(calculateFeeParam.CalculateMonth.Year, calculateFeeParam.CalculateMonth.Month, 1); - var eTime = bTime.AddMonths(1); - workloadLambda = workloadLambda.And(t => - t.WorkTime >= bTime && t.WorkTime < eTime); - - workloadLambda = workloadLambda.And(t => calculateFeeParam.NeedCalculateReviewers.Contains(t.DoctorId) && t.DataFrom == (int)WorkLoadFromStatus.FinalConfirm); - var workLoadQueryable = from doctor in _doctorRepository.AsQueryable() - join workLoad in _doctorWorkloadRepository.Where(workloadLambda) on - doctor.Id equals workLoad.DoctorId - join trial in _trialRepository.AsQueryable() on workLoad.TrialId equals trial.Id - join trialPay in _trialPaymentRepository.AsQueryable() on trial.Id equals trialPay.TrialId - into temp - from trialPay in temp.DefaultIfEmpty() - join doctorPayInfo in _doctorPayInfoRepository.AsQueryable() on doctor.Id equals doctorPayInfo.DoctorId - join rankPrice in _rankPriceRepository.AsQueryable() on doctorPayInfo.RankId equals rankPrice.Id - select new CalculatePaymentDTO() - { - Id = workLoad.Id, - DoctorId = workLoad.DoctorId, - WorkTime = workLoad.WorkTime, - DataFrom = workLoad.DataFrom, - TrialId = workLoad.TrialId, - TrialCode = trial.TrialCode, - - Timepoint = workLoad.Timepoint, - TimepointIn24H = workLoad.TimepointIn24H, - TimepointIn48H = workLoad.TimepointIn48H, - Global = workLoad.Global, - Adjudication = workLoad.Adjudication, - AdjudicationIn24H = workLoad.AdjudicationIn24H, - AdjudicationIn48H = workLoad.AdjudicationIn48H, - Training = workLoad.Training, - RefresherTraining = workLoad.RefresherTraining, - Downtime = workLoad.Downtime, - - TrialAdditional = trialPay.TrialAdditional, - PersonalAdditional = doctorPayInfo.Additional, - AdjustmentMultiple = trialPay.AdjustmentMultiple, - - TimepointPrice = rankPrice.Timepoint, - TimepointIn24HPrice = rankPrice.TimepointIn24H, - TimepointIn48HPrice = rankPrice.TimepointIn48H, - AdjudicationPrice = rankPrice.Adjudication, - AdjudicationIn24HPrice = rankPrice.AdjudicationIn24H, - AdjudicationIn48HPrice = rankPrice.AdjudicationIn48H, - DowntimePrice = rankPrice.Downtime, - GlobalPrice = rankPrice.Global, - TrainingPrice = rankPrice.Training, - RefresherTrainingPrice = rankPrice.RefresherTraining - }; - - return await workLoadQueryable.ToListAsync(); - } - - /// - /// 计算月度费用,并调用AddOrUpdateMonthlyPayment和AddOrUpdateMonthlyPaymentDetail方法, - /// 将费用计算的月度数据及详情保存 - /// - [NonDynamicMethod] - public async Task CalculateMonthlyPayment(CalculateDoctorAndMonthDTO param, string token) - { - var yearMonth = param.CalculateMonth.ToString("yyyy-MM"); - var rate = await _exchangeRateRepository.FirstOrDefaultAsync(u => u.YearMonth == yearMonth); - - decimal exchangeRate = rate?.Rate ?? 0; - - var workLoadAndPayPriceList = await GetFinalConfirmedWorkloadAndPayPriceList(param); - var volumeRewardPriceList = await _volumeRewardPriceService.GetVolumeRewardPriceList(); - - #region 奖励数据校验 - for (int i = 0; i < volumeRewardPriceList.Count; i++) - { - if (i == 0 && volumeRewardPriceList[i].Min != 0) - { - //---Volume reward data error. - return ResponseOutput.NotOk(_localizer["Cal_VolDataErr"]); - } - if (i > 0) - { - if (volumeRewardPriceList[i - 1].Max + 1 != volumeRewardPriceList[i].Min) - //---Volume reward data error. - return ResponseOutput.NotOk(_localizer["Cal_VolDataErr"]); - } - } - - - #endregion - - - List paymentList = new List(); - List reviewerPaymentUSDList = new List(); - - // 获取所有医生费用 一次从数据库里面全部取出来 - - var allDoctorList = workLoadAndPayPriceList.Where(x => param.NeedCalculateReviewers.Contains(x.DoctorId)).ToList(); - var allDoctorIds = allDoctorList.Select(x => x.DoctorId).Distinct().ToList(); - var listTrialId = allDoctorList.Select(x => x.TrialId).Distinct().ToList(); - - var trialDoctorlist= await (from enroll in _enrollRepository.Where(x=> listTrialId.Contains(x.TrialId)|| allDoctorIds.Contains(x.DoctorId)) - join price in _trialPaymentRepository.Where() on enroll.TrialId equals price.TrialId - select new DoctorPrice() - { - IsNewTrial = price.IsNewTrial, - AdjustmentMultiple = enroll.AdjustmentMultiple, - TrialId=enroll.TrialId, - DoctorId = enroll.DoctorId, - Training=enroll.Training, - Adjudication=enroll.Adjudication, - Adjudication24H=enroll.Adjudication24H, - Adjudication48H= enroll.Adjudication48H, - Downtime=enroll.Downtime, - Global=enroll.Global, - RefresherTraining=enroll.RefresherTraining, - Timepoint= enroll.Timepoint, - Timepoint24H=enroll.Timepoint24H, - Timepoint48H=enroll.Timepoint48H, - }).ToListAsync(); - - - foreach (var doctor in param.NeedCalculateReviewers) - { - if (await _paymentRepository.AnyAsync(u => u.DoctorId == doctor && u.YearMonth == yearMonth && u.IsLock)) - { - break; - } - List paymentDetailList = new List(); - decimal totalNormal = 0; - - //计算单个医生费用统,并且插入到统计表 - var doctorWorkloadAndPayPriceList = workLoadAndPayPriceList.Where(u => u.DoctorId == doctor).ToList(); - - //阅片数量 计算奖励费用 - int readCount = 0; - - int codeOrder = 0; - - //这里需要改 - - foreach (var item in doctorWorkloadAndPayPriceList) - { - var doctordata = trialDoctorlist.Where(x => x.IsNewTrial ?? false && x.Training == item.Training && x.DoctorId == item.DoctorId).FirstOrDefault(); - - if (doctordata != null) - { - item.Training = doctordata.Training??0; - item.Adjudication = doctordata.Adjudication??0; - item.AdjudicationIn24H = doctordata.Adjudication24H??0; - item.AdjudicationIn48H = doctordata.Adjudication48H??0; - item.Downtime = doctordata.Downtime??0; - item.Global = doctordata.Global??0; - item.RefresherTraining = doctordata.RefresherTraining??0; - item.Timepoint = doctordata.Timepoint??0; - item.TimepointIn24H = doctordata.Timepoint24H??0; - item.TimepointIn48H = doctordata.Timepoint48H??0; - item.PersonalAdditional = 0; - } - ++codeOrder; - readCount += (item.Timepoint + item.TimepointIn24H + item.TimepointIn48H - + item.Adjudication + item.AdjudicationIn24H + item.AdjudicationIn48H); - decimal trainingTotal = item.Training * item.TrainingPrice; - decimal refresherTrainingTotal = item.RefresherTraining * item.RefresherTrainingPrice; - decimal downtimeTotal = item.Downtime * item.DowntimePrice; - //规则定义 global 的价格是Tp和个人附加的一半 - decimal globalTotal = item.Global * (item.TimepointPrice / 2 + item.PersonalAdditional / 2); - - //项目如果没有添加附加数据 默认为0 - decimal timePointTotal = item.Timepoint * (item.TimepointPrice * item.AdjustmentMultiple + item.PersonalAdditional + (item.TrialAdditional == null ? 0 : (decimal)item.TrialAdditional)); - - decimal timePointIn24HTotal = item.TimepointIn24H * (item.TimepointIn24HPrice * item.AdjustmentMultiple + item.PersonalAdditional); - decimal timePointIn48HTotal = item.TimepointIn48H * (item.TimepointIn48HPrice * item.AdjustmentMultiple + item.PersonalAdditional); - decimal adjudicationTotal = item.Adjudication * (item.AdjudicationPrice * item.AdjustmentMultiple + item.PersonalAdditional + (item.TrialAdditional == null ? 0 : (decimal)item.TrialAdditional)); - decimal adjudicationIn24HTotal = item.AdjudicationIn24H * (item.AdjudicationIn24HPrice * item.AdjustmentMultiple + item.PersonalAdditional); - decimal adjudicationIn48HTotal = item.AdjudicationIn48H * (item.AdjudicationIn48HPrice * item.AdjustmentMultiple + item.PersonalAdditional); - - totalNormal += (trainingTotal + refresherTrainingTotal + downtimeTotal + globalTotal + timePointTotal + timePointIn24HTotal - + timePointIn48HTotal + adjudicationTotal + adjudicationIn24HTotal + adjudicationIn48HTotal); - - #region 统计明细信息 - - paymentDetailList.Add(new PaymentDetailCommand - { - TrialCode = item.TrialCode, - PaymentType = "Training", - Count = item.Training, - BasePrice = item.TrainingPrice, - PersonalAdditional = 0, - TrialAdditional = 0, - PaymentId = Guid.Empty, - DoctorId = item.DoctorId, - TrialId = item.TrialId, - ShowTypeOrder = 1, - ShowCodeOrder = codeOrder, - ExchangeRate = exchangeRate, - YearMonth = yearMonth, - PaymentUSD = item.Training * item.TrainingPrice, - PaymentCNY = item.Training * item.TrainingPrice * exchangeRate - }); - paymentDetailList.Add(new PaymentDetailCommand - { - TrialCode = item.TrialCode, - PaymentType = "Refresher Training", - Count = item.RefresherTraining, - BasePrice = item.RefresherTrainingPrice, - PersonalAdditional = 0, - TrialAdditional = 0, - PaymentId = Guid.Empty, - DoctorId = item.DoctorId, - TrialId = item.TrialId, - ShowTypeOrder = 2, - ShowCodeOrder = codeOrder, - ExchangeRate = exchangeRate, - YearMonth = yearMonth, - PaymentUSD = item.RefresherTraining * item.RefresherTrainingPrice, - PaymentCNY = item.RefresherTraining * item.RefresherTrainingPrice * exchangeRate - }); - paymentDetailList.Add(new PaymentDetailCommand - { - TrialCode = item.TrialCode, - PaymentType = "Downtime", - Count = item.Downtime, - BasePrice = item.DowntimePrice, - PersonalAdditional = 0, - TrialAdditional = 0, - PaymentId = Guid.Empty, - DoctorId = item.DoctorId, - TrialId = item.TrialId, - ShowTypeOrder = 3, - ShowCodeOrder = codeOrder, - ExchangeRate = exchangeRate, - YearMonth = yearMonth, - PaymentUSD = item.Downtime * item.DowntimePrice, - PaymentCNY = item.Downtime * item.DowntimePrice * exchangeRate - }); - - paymentDetailList.Add(new PaymentDetailCommand - { - TrialCode = item.TrialCode, - PaymentType = "Timepoint Regular", - Count = item.Timepoint, - BasePrice = item.TimepointPrice, - PersonalAdditional = doctordata!=null?0: item.PersonalAdditional, - TrialAdditional = doctordata != null ? 0 : item.TimepointPrice * (item.AdjustmentMultiple - 1) + (item.TrialAdditional == null ? 0 : (decimal)item.TrialAdditional), - PaymentId = Guid.Empty, - DoctorId = item.DoctorId, - TrialId = item.TrialId, - ShowTypeOrder = 4, - ShowCodeOrder = codeOrder, - ExchangeRate = exchangeRate, - YearMonth = yearMonth, - PaymentUSD = item.Timepoint * (item.TimepointPrice * item.AdjustmentMultiple + item.PersonalAdditional + (item.TrialAdditional == null ? 0 : (decimal)item.TrialAdditional)), - PaymentCNY = item.Timepoint * (item.TimepointPrice * item.AdjustmentMultiple + item.PersonalAdditional + (item.TrialAdditional == null ? 0 : (decimal)item.TrialAdditional)) * exchangeRate - }); - - paymentDetailList.Add(new PaymentDetailCommand - { - TrialCode = item.TrialCode, - PaymentType = "Timepoint 48-Hour", - Count = item.TimepointIn48H, - BasePrice = item.TimepointIn48HPrice, - PersonalAdditional = doctordata != null ? 0 : item.PersonalAdditional, - TrialAdditional = doctordata != null ? 0 : item.TimepointIn48HPrice * (item.AdjustmentMultiple - 1) + 0,//48小时不加项目附加 - PaymentId = Guid.Empty, - DoctorId = item.DoctorId, - TrialId = item.TrialId, - ShowTypeOrder = 5, - ShowCodeOrder = codeOrder, - ExchangeRate = exchangeRate, - YearMonth = yearMonth, - PaymentUSD = item.TimepointIn48H * (item.TimepointIn48HPrice * item.AdjustmentMultiple + 0 + item.PersonalAdditional), - PaymentCNY = item.TimepointIn48H * (item.TimepointIn48HPrice * item.AdjustmentMultiple + 0 + item.PersonalAdditional) * exchangeRate - }); - paymentDetailList.Add(new PaymentDetailCommand - { - TrialCode = item.TrialCode, - PaymentType = "Timepoint 24-Hour", - Count = item.TimepointIn24H, - BasePrice = item.TimepointIn24HPrice, - PersonalAdditional = doctordata != null ? 0 : item.PersonalAdditional, - TrialAdditional = doctordata != null ? 0 : item.TimepointIn24HPrice * (item.AdjustmentMultiple - 1) + 0, - PaymentId = Guid.Empty, - DoctorId = item.DoctorId, - TrialId = item.TrialId, - ShowTypeOrder = 6, - ShowCodeOrder = codeOrder, - ExchangeRate = exchangeRate, - YearMonth = yearMonth, - PaymentUSD = item.TimepointIn24H * (item.TimepointIn24HPrice * item.AdjustmentMultiple + 0 + item.PersonalAdditional), - PaymentCNY = item.TimepointIn24H * (item.TimepointIn24HPrice * item.AdjustmentMultiple + 0 + item.PersonalAdditional) * exchangeRate - }); - paymentDetailList.Add(new PaymentDetailCommand - { - TrialCode = item.TrialCode, - PaymentType = "Adjudication Regular", - Count = item.Adjudication, - BasePrice = item.AdjudicationPrice, - PersonalAdditional = doctordata != null ? 0 : item.PersonalAdditional, - TrialAdditional = doctordata != null ? 0 : item.AdjudicationPrice * (item.AdjustmentMultiple - 1) + (item.TrialAdditional == null ? 0 : (decimal)item.TrialAdditional), - PaymentId = Guid.Empty, - DoctorId = item.DoctorId, - TrialId = item.TrialId, - ShowTypeOrder = 7, - ShowCodeOrder = codeOrder, - ExchangeRate = exchangeRate, - YearMonth = yearMonth, - PaymentUSD = item.Adjudication * (item.AdjudicationPrice * item.AdjustmentMultiple + item.PersonalAdditional + (item.TrialAdditional == null ? 0 : (decimal)item.TrialAdditional)), - PaymentCNY = item.Adjudication * (item.AdjudicationPrice * item.AdjustmentMultiple + item.PersonalAdditional + (item.TrialAdditional == null ? 0 : (decimal)item.TrialAdditional)) * exchangeRate - }); - - paymentDetailList.Add(new PaymentDetailCommand - { - TrialCode = item.TrialCode, - PaymentType = "Adjudication 48-Hour", - Count = item.AdjudicationIn48H, - BasePrice = item.AdjudicationIn48HPrice, - PersonalAdditional = doctordata != null ? 0 : item.PersonalAdditional, - TrialAdditional = doctordata != null ? 0 : item.AdjudicationIn48HPrice * (item.AdjustmentMultiple - 1) + 0, - PaymentId = Guid.Empty, - DoctorId = item.DoctorId, - TrialId = item.TrialId, - ShowTypeOrder = 8, - ShowCodeOrder = codeOrder, - ExchangeRate = exchangeRate, - YearMonth = yearMonth, - PaymentUSD = item.AdjudicationIn48H * (item.AdjudicationIn48HPrice * item.AdjustmentMultiple + item.PersonalAdditional + 0), - PaymentCNY = item.AdjudicationIn48H * (item.AdjudicationIn48HPrice * item.AdjustmentMultiple + item.PersonalAdditional + 0) * exchangeRate - }); - paymentDetailList.Add(new PaymentDetailCommand - { - TrialCode = item.TrialCode, - PaymentType = "Adjudication 24-Hour", - Count = item.AdjudicationIn24H, - BasePrice = item.AdjudicationIn24HPrice, - PersonalAdditional = doctordata != null ? 0 : item.PersonalAdditional, - TrialAdditional = doctordata != null ? 0 : item.AdjudicationIn24HPrice * (item.AdjustmentMultiple - 1) + 0, - PaymentId = Guid.Empty, - DoctorId = item.DoctorId, - TrialId = item.TrialId, - ShowTypeOrder = 9, - ShowCodeOrder = codeOrder, - ExchangeRate = exchangeRate, - YearMonth = yearMonth, - PaymentUSD = item.AdjudicationIn24H * (item.AdjudicationIn24HPrice * item.AdjustmentMultiple + 0 + item.PersonalAdditional), - PaymentCNY = item.AdjudicationIn24H * (item.AdjudicationIn24HPrice * item.AdjustmentMultiple + 0 + item.PersonalAdditional) * exchangeRate - }); - paymentDetailList.Add(new PaymentDetailCommand - { - TrialCode = item.TrialCode, - PaymentType = "Global", - Count = item.Global, - BasePrice = item.TimepointPrice / 2,//item.GlobalPrice, - PersonalAdditional = doctordata != null ? 0 : item.PersonalAdditional / 2, - TrialAdditional = 0, - PaymentId = Guid.Empty, - DoctorId = item.DoctorId, - TrialId = item.TrialId, - ShowTypeOrder = 10, - ShowCodeOrder = codeOrder, - ExchangeRate = exchangeRate, - YearMonth = yearMonth, - PaymentUSD = item.Global * (item.TimepointPrice / 2 + item.PersonalAdditional / 2), - PaymentCNY = item.Global * (item.TimepointPrice / 2 + item.PersonalAdditional / 2) * exchangeRate - }); - #endregion - } - - int typeOrder = 0; - if (readCount > 0) - { - paymentDetailList.Add(new PaymentDetailCommand - { - TrialCode = "Volume Reward", - PaymentType = "Total TP & AD", - Count = readCount, - BasePrice = 0, - PersonalAdditional = 0, - TrialAdditional = 0, - PaymentId = Guid.Empty, - DoctorId = doctor, - TrialId = Guid.Empty, - ShowTypeOrder = typeOrder, - ShowCodeOrder = (++codeOrder), - ExchangeRate = exchangeRate, - YearMonth = yearMonth, - PaymentUSD = 0, - PaymentCNY = 0 - }); - - foreach (var awardItem in volumeRewardPriceList) - { - ++typeOrder; - if ((readCount - awardItem.Min + 1) < 0) - { - break; - } - if (awardItem.Min == 0) - { - paymentDetailList.Add(new PaymentDetailCommand - { - TrialCode = "Volume Reward", - PaymentType = awardItem.Min + "-" + awardItem.Max, - Count = readCount >= awardItem.Max ? - (awardItem.Max - awardItem.Min) : (readCount - awardItem.Min), - BasePrice = awardItem.Price, - PersonalAdditional = 0, - TrialAdditional = 0, - PaymentId = Guid.Empty,//result.Data, - DoctorId = doctor, - TrialId = Guid.Empty, - ShowTypeOrder = typeOrder, - ShowCodeOrder = (++codeOrder), - ExchangeRate = exchangeRate, - YearMonth = yearMonth, - PaymentUSD = (readCount >= awardItem.Max ? - (awardItem.Max - awardItem.Min) : (readCount - awardItem.Min)) * awardItem.Price, - PaymentCNY = (readCount >= awardItem.Max ? - (awardItem.Max - awardItem.Min) : (readCount - awardItem.Min)) * awardItem.Price * exchangeRate - }); - } - else - { - paymentDetailList.Add(new PaymentDetailCommand - { - TrialCode = "Volume Reward", - PaymentType = awardItem.Min + "-" + awardItem.Max, - Count = readCount >= awardItem.Max ? - (awardItem.Max - awardItem.Min + 1) : (readCount - awardItem.Min + 1), - BasePrice = awardItem.Price, - PersonalAdditional = 0, - TrialAdditional = 0, - PaymentId = Guid.Empty, - DoctorId = doctor, - TrialId = Guid.Empty, - ShowTypeOrder = typeOrder, - ShowCodeOrder = (++codeOrder), - ExchangeRate = exchangeRate, - YearMonth = yearMonth, - PaymentUSD = (readCount >= awardItem.Max ? - (awardItem.Max - awardItem.Min + 1) : (readCount - awardItem.Min + 1)) * awardItem.Price, - PaymentCNY = (readCount >= awardItem.Max ? - (awardItem.Max - awardItem.Min + 1) : (readCount - awardItem.Min + 1)) * awardItem.Price * exchangeRate - }); - } - } - - } - decimal award = 0; - volumeRewardPriceList = volumeRewardPriceList.OrderBy(u => u.Min).ToList(); - - var levelTemp = -1; //用来计算属于哪一个挡位 - foreach (var awarPriceitem in volumeRewardPriceList) - { - if (awarPriceitem.Min == 0) - { - if (readCount > awarPriceitem.Max) - { - ++levelTemp; - award += (awarPriceitem.Max - awarPriceitem.Min) * awarPriceitem.Price; - } - if (awarPriceitem.Min < readCount && readCount < awarPriceitem.Max) - { - ++levelTemp; - award += (readCount - awarPriceitem.Min) * awarPriceitem.Price; - break; ; - } - } - else - { - if (readCount > awarPriceitem.Max) - { - ++levelTemp; - award += (awarPriceitem.Max - awarPriceitem.Min + 1) * awarPriceitem.Price; - } - if (awarPriceitem.Min < readCount && readCount < awarPriceitem.Max) - { - ++levelTemp; - award += (readCount - awarPriceitem.Min + 1) * awarPriceitem.Price; - break; ; - } - } - } - decimal totalUSD = award + totalNormal;//总费用 - - var result = await AddOrUpdateMonthlyPayment(new PaymentCommand - { - DoctorId = doctor, - Year = param.CalculateMonth.Year, - Month = param.CalculateMonth.Month, - PaymentUSD = totalUSD, - CalculateUser = token, - CalculateTime = DateTime.Now, - ExchangeRate = exchangeRate, - PaymentCNY = exchangeRate * totalUSD, - }); - - - reviewerPaymentUSDList.Add(new ReviewerPaymentUSD { DoctorId = doctor, PaymentUSD = totalUSD, RecordId = result.Data }); - foreach (var detail in paymentDetailList) - { - //var data = trialDoctorlist.FirstOrDefault(x => x.DoctorId == detail.DoctorId && x.TrialId == detail.TrialId && x.IsNewTrial == true && (x.AdjustmentMultiple??0) != 0); - //if (data != null) - //{ - // detail.BasePrice = data.AdjustmentMultiple??0; - // detail.PersonalAdditional = 0; - // detail.TrialAdditional = 0; - //} - - detail.PaymentId = result.Data; - } - await AddOrUpdateMonthlyPaymentDetail(paymentDetailList, result.Data); - - await UpdatePaymentAdjustment(doctor, yearMonth); - } - return ResponseOutput.Ok(reviewerPaymentUSDList); - } - - - - - // 重新计算调整费用 - - private async Task UpdatePaymentAdjustment(Guid reviewerId, string yearMonth) - { - var adjustList = await _payAdjustmentRepository.Where(u => u.YearMonth == yearMonth && - !u.IsLock && u.ReviewerId == reviewerId).ToListAsync(); - - - var needUpdatePayment = adjustList.GroupBy(t => t.ReviewerId).Select(g => new - { - ReviewerId = g.Key, - AdjustCNY = g.Sum(t => t.AdjustmentCNY), - AdjustUSD = g.Sum(t => t.AdjustmentUSD) - }); - - foreach (var reviewer in needUpdatePayment) - { - await _paymentRepository.BatchUpdateNoTrackingAsync(u => u.YearMonth == yearMonth && - !u.IsLock && u.DoctorId == reviewer.ReviewerId, t => new Payment() - { - AdjustmentUSD = reviewer.AdjustUSD, - AdjustmentCNY = reviewer.AdjustCNY - - }); - } - } - - /// - /// 保存费用计算的月度数据 - /// - private async Task> AddOrUpdateMonthlyPayment(PaymentCommand addOrUpdateModel) - { - var success = false; - var paymentModel = await _paymentRepository.FirstOrDefaultAsync(t => - t.DoctorId == addOrUpdateModel.DoctorId && t.YearMonth == addOrUpdateModel.YearMonth); - - - - //var taxCNY = GetTax(addOrUpdateModel.PaymentCNY); - //var actuallyPaidCNY = addOrUpdateModel.PaymentCNY - taxCNY; - //var bankTransferCNY = addOrUpdateModel.PaymentCNY - taxCNY; - - if (paymentModel == null) - { - var payment = _mapper.Map(addOrUpdateModel); - - //payment.BankTransferCNY = bankTransferCNY; - //payment.TaxCNY= taxCNY; - //payment.BankTransferCNY = bankTransferCNY; - payment.YearMonthDate = DateTime.Parse(payment.YearMonth); - - payment =await _paymentRepository.AddAsync(payment); - success =await _paymentRepository.SaveChangesAsync(); - return ResponseOutput.Result(success, payment.Id); - } - else - { - // 如果是 当月计算的工作量费用 和 调整费用都为0,则删除该行记录 - if (addOrUpdateModel.PaymentUSD == 0 && paymentModel.AdjustmentUSD == 0) - { - success =await _paymentRepository.BatchDeleteNoTrackingAsync(u => u.Id == paymentModel.Id); - //_paymentDetailRepository.Delete(u=>u.PaymentId==paymentModel.Id); - } - else - { - success = await _paymentRepository.BatchUpdateNoTrackingAsync(t => t.Id == paymentModel.Id, u => new Payment() - { - PaymentUSD = addOrUpdateModel.PaymentUSD, - CalculateTime = addOrUpdateModel.CalculateTime, - CalculateUser = addOrUpdateModel.CalculateUser, - //TaxCNY = taxCNY, - //ActuallyPaidCNY = actuallyPaidCNY, - //BankTransferCNY = bankTransferCNY, - PaymentCNY = addOrUpdateModel.PaymentCNY, - ExchangeRate = addOrUpdateModel.ExchangeRate - }); - } - - return ResponseOutput.Result(success, paymentModel.Id); - } - - } - - - - - /// - /// 保存费用计算的月度详情 - /// - private async Task AddOrUpdateMonthlyPaymentDetail(List addOrUpdateList, Guid paymentId) - { - //var paymentDetailIds = addOrUpdateList.Select(t => t.PaymentId).ToList(); - await _paymentDetailRepository.BatchDeleteNoTrackingAsync(t => t.PaymentId == paymentId); - await _paymentDetailRepository.AddRangeAsync(_mapper.Map>(addOrUpdateList)); - return await _paymentDetailRepository.SaveChangesAsync(); - } - - - - /// - /// 获取待计算费用的Reviewer对应的月份列表 - /// - public async Task> GetNeedCalculateReviewerList(Guid reviewerId, string yearMonth) - { - Expression> calculateLambda = u => !u.IsLock; - if (reviewerId != Guid.Empty) - { - calculateLambda = calculateLambda.And(u => u.DoctorId == reviewerId); - } - if (!string.IsNullOrWhiteSpace(yearMonth)) - { - calculateLambda = calculateLambda.And(u => u.YearMonth == yearMonth); - } - return await _paymentRepository.Where(calculateLambda).ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); - } - - /// - /// 查询Reviewer某个月的费用是否被锁定 - /// - public async Task IsLock(Guid reviewerId, string yearMonth) - { - return await _paymentRepository.AnyAsync(u => u.DoctorId == reviewerId && u.YearMonth == yearMonth && u.IsLock); - } - - //public bool ResetMonthlyPayment(Guid reviewerId, Guid trialId, string yearMonth) - //{ - // var payment = _paymentRepository.FindSingleOrDefault(u => u.DoctorId == reviewerId && u.YearMonth == yearMonth); - // payment.PaymentCNY = 0; - // payment.PaymentUSD = 0; - // _paymentRepository.Update(payment); - // _paymentDetailRepository.Delete(u=>u.DoctorId==reviewerId && u.TrialId==trial) - //} - } -} diff --git a/IRaCIS.Core.Application/Service/Financial/DTO/AwardPriceModel.cs b/IRaCIS.Core.Application/Service/Financial/DTO/AwardPriceModel.cs deleted file mode 100644 index 2dfffd2fc..000000000 --- a/IRaCIS.Core.Application/Service/Financial/DTO/AwardPriceModel.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System; -using IRaCIS.Application.Contracts; -using IRaCIS.Core.Infrastructure.Extention; - -namespace IRaCIS.Application.Interfaces -{ - public class AwardPriceDTO: AwardPriceCalculateDTO - { - public Guid Id { get; set; } - } - - public class AwardPriceCalculateDTO - { - public decimal Price { get; set; } - public int Max { get; set; } - public int Min { get; set; } - } - - public class AwardPriceCommand - { - //public Guid Id { get; set; } - public decimal Price { get; set; } - public int Min { get; set; } - public int Max { get; set; } - public Guid OptUserId { get; set; } - } - - public class AwardPriceQueryDTO : PageInput - { - } - - public class ExchangeRateQueryDTO : PageInput - { - public DateTime? SearchMonth { get; set; } - } - -} \ No newline at end of file diff --git a/IRaCIS.Core.Application/Service/Financial/DTO/CalculateModel.cs b/IRaCIS.Core.Application/Service/Financial/DTO/CalculateModel.cs deleted file mode 100644 index 4d82f7425..000000000 --- a/IRaCIS.Core.Application/Service/Financial/DTO/CalculateModel.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System; - -namespace IRaCIS.Application.Contracts -{ - public class CalculateNeededDTO - { - public Guid Id { get; set; } - public Guid DoctorId { get; set; } - public string YearMonth { get; set; } = String.Empty; - public bool IsLock { get; set; } - } - - public class DoctorPrice - { - public decimal? AdjustmentMultiple { get; set; } - - public Guid? DoctorId { get; set; } - - public Guid? TrialId { get; set; } - - public bool? IsNewTrial { get; set; } - - public int? Training { get; set; } - - public int? RefresherTraining { get; set; } - - public int? Timepoint { get; set; } - - public int? Timepoint48H { get; set; } - - public int? Timepoint24H { get; set; } - - public int? Adjudication { get; set; } - - public int? Adjudication48H { get; set; } - - public int? Adjudication24H { get; set; } - - public int? Global { get; set; } - - - public int? Downtime { get; set; } - } -} diff --git a/IRaCIS.Core.Application/Service/Financial/DTO/ExchangeRateModel.cs b/IRaCIS.Core.Application/Service/Financial/DTO/ExchangeRateModel.cs deleted file mode 100644 index a56b4c166..000000000 --- a/IRaCIS.Core.Application/Service/Financial/DTO/ExchangeRateModel.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; - -namespace IRaCIS.Application.Contracts -{ - public class ExchangeRateCommand - { - public Guid? Id { get; set; } - public string YearMonth { get; set; }=String.Empty; - public decimal Rate { get; set; } - - public DateTime UpdateTime { get; set; } - } -} diff --git a/IRaCIS.Core.Application/Service/Financial/DTO/PaymentAdjustmentModel.cs b/IRaCIS.Core.Application/Service/Financial/DTO/PaymentAdjustmentModel.cs deleted file mode 100644 index 1a399238d..000000000 --- a/IRaCIS.Core.Application/Service/Financial/DTO/PaymentAdjustmentModel.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System; -using IRaCIS.Core.Infrastructure.Extention; - -namespace IRaCIS.Application.Contracts.Pay -{ - public class PaymentAdjustmentCommand - { - public Guid? Id { get; set; } - public Guid ReviewerId { get; set; } - public DateTime YearMonth { get; set; } - public decimal AdjustPaymentUSD { get; set; } - public decimal AdjustPaymentCNY { get; set; } - public string Note { get; set; } = string.Empty; - } - - public class PaymentAdjustmentDTO - { - public Guid Id { get; set; } - public Guid ReviewerId { get; set; } - public string YearMonth { get; set; }=String.Empty; - public DateTime YearMonthDate { get; set; } - public bool IsLock { get; set; } - public decimal AdjustPaymentUSD { get; set; } - public decimal AdjustPaymentCNY { get; set; } - public string Note { get; set; } = String.Empty; - } - - public class PaymentAdjustmentDetailDTO: PaymentAdjustmentDTO - { - public string ReviewerCode { get; set; } = String.Empty; - public string FirstName { get; set; } = String.Empty; - public string LastName { get; set; } = String.Empty; - public string FullName => LastName + " / " + FirstName; - public string ChineseName { get; set; } = String.Empty; - } - - public class PaymentAdjustmentQueryDTO:PageInput - { - public string TrialCode { get; set; } = string.Empty; - public string Reviewer { get; set; } = string.Empty; - public DateTime BeginMonth { get; set; } - public DateTime EndMonth { get; set; } - } - - public class DoctorSelectDTO - { - public Guid Id { get; set; } - public string Code { get; set; } = string.Empty; - public string FirstName { get; set; } = String.Empty; - public string LastName { get; set; } = String.Empty; - public string FullName => LastName + " / " + FirstName; - public string ChineseName { get; set; } = String.Empty; - } -} \ No newline at end of file diff --git a/IRaCIS.Core.Application/Service/Financial/DTO/PaymentDetailModel.cs b/IRaCIS.Core.Application/Service/Financial/DTO/PaymentDetailModel.cs deleted file mode 100644 index ae8aaa057..000000000 --- a/IRaCIS.Core.Application/Service/Financial/DTO/PaymentDetailModel.cs +++ /dev/null @@ -1,195 +0,0 @@ -using IRaCIS.Core.Infrastructure.Extention; - -namespace IRaCIS.Application.Contracts.Pay -{ - public class PaymentDetailDTO - { - public Guid Id { get; set; } - public Guid PaymentId { get; set; } - public string YearMonth { get; set; } = String.Empty; - public Guid DoctorId { get; set; } - public Guid TrialId { get; set; } - public string TrialCode { get; set; } = String.Empty; - public string PaymentType { get; set; } = String.Empty; - public int Count { get; set; } - public decimal BasePrice { get; set; } - public decimal PersonalAdditional { get; set; } - - public decimal? NewPersonalAdditional { get; set; } - public decimal TrialAdditional { get; set; } - public int ShowTypeOrder { get; set; } - public int ShowCodeOrder { get; set; } - - public decimal ExchangeRate { get; set; } - - public decimal PaymentUSD { get; set; } - public decimal PaymentCNY { get; set; } - - public bool? IsNewTrial { get; set; } - - public decimal TotalUnitPrice => BasePrice + PersonalAdditional + TrialAdditional; - - public AdjustmentDTO AdjustmentView { get; set; } = new AdjustmentDTO(); - - } - - public class AdjustmentDTO - { - public decimal AdjustPaymentUSD { get; set; } - - public decimal AdjustPaymentCNY { get; set; } - - public string AdjustType - { - get - { - if (AdjustPaymentUSD > 0) - { - return "+"; - } - else if (AdjustPaymentUSD < 0) - { - return "-"; - } - else { return string.Empty; } - } - } - public string Note { get; set; } = String.Empty; - } - - - public class PaymentDetailCommand : PaymentDetailDTO - { - - } - - public class PayDetailDTO - { - public IEnumerable DetailList { get; set; } = new List(); - public DoctorPayInfo DoctorInfo { get; set; } = new DoctorPayInfo(); - } - - public class LockPaymentDTO - { - public List ReviewerIdList { get; set; }=new List(); - public DateTime Month { get; set; } - - public bool IsLock { get; set; } = true; - } - - public class DoctorPayInfo - { - public Guid DoctorId { get; set; } - public string ChineseName { get; set; } = String.Empty; - public string FirstName { get; set; } = String.Empty; - public string LastName { get; set; } = String.Empty; - public string Phone { get; set; } = String.Empty; - public string PayTitle { get; set; } = String.Empty; - public string Code { get; set; } = String.Empty; - public string YearMonth { get; set; } = String.Empty; - } - - - - - - - - public class ReviewerPaymentUSD - { - public Guid RecordId { get; set; } - public Guid DoctorId { get; set; } - public decimal PaymentUSD { get; set; } - } - - public class PaymentQueryDTO : PageInput - { - public string Reviewer { get; set; } = String.Empty; - public DateTime BeginMonth { get; set; } - public DateTime EndMonth { get; set; } - public int? Nation { get; set; } - } - public class MonthlyPaymentDTO - { - public Guid ReviewerId { get; set; } - public string ReviewerCode { get; set; } = String.Empty; - public string ChineseName { get; set; } = String.Empty; - public string FirstName { get; set; } = String.Empty; - public string LastName { get; set; } = String.Empty; - - public string FullName { get; set; } = String.Empty; - - public decimal AdjustmentUSD { get; set; } - public decimal AdjustmentCNY { get; set; } - public decimal PaymentUSD { get; set; } - public decimal PaymentCNY { get; set; } - - public decimal TotalUSD { get; set; } - public decimal TotalCNY { get; set; } - - } - - public class VolumeStatisticsDTO - { - public Guid StatisticsId { get; set; } - public string Month { get; set; } = String.Empty; - public decimal VolumeReward { get; set; } - public decimal ExchangeRate { get; set; } - - public decimal AdjustmentUSD { get; set; } - public decimal AdjustmentCNY { get; set; } - public decimal PaymentUSD { get; set; } - public decimal PaymentCNY { get; set; } - public decimal TotalCNY => AdjustmentCNY + PaymentCNY; - public decimal TotalUSD => AdjustmentUSD + PaymentUSD; - - public List TrialPaymentList = new List(); - } - - public class TrialPaymentDTO - { - public Guid TrialId { get; set; } - public string TrialCode { get; set; } = String.Empty; - public decimal TrialPayment { get; set; } - - } - public class VolumeQueryDTO - { - public DateTime BeginMonth { get; set; } - public DateTime EndMonth { get; set; } - public Guid ReviewerId { get; set; } - } - - public class RevenuesDTO - { - public List MissingTrialCodes = new List(); - public Guid Id { get; set; } - public string TrialCode { get; set; } = String.Empty; - public Guid TrialId { get; set; } - public string Indication { get; set; } = String.Empty; - public Guid? CroId { get; set; } - public string Cro { get; set; } = string.Empty; - - public int Expedited { get; set; } - public string ChineseName { get; set; } = string.Empty; - - public string FirstName { get; set; } = string.Empty; - public string LastName { get; set; } = string.Empty; - public string ReviewerCode { get; set; } = string.Empty; - - public decimal Training { get; set; } - public decimal Downtime { get; set; } - public decimal Timepoint { get; set; } - public decimal TimepointIn24H { get; set; } - public decimal TimepointIn48H { get; set; } - public decimal Adjudication { get; set; } - public decimal AdjudicationIn24H { get; set; } - public decimal AdjudicationIn48H { get; set; } - public decimal Global { get; set; } - public decimal Total { get; set; } - - public string YearMonth { get; set; } = String.Empty; - } - - -} \ No newline at end of file diff --git a/IRaCIS.Core.Application/Service/Financial/DTO/PaymentModel.cs b/IRaCIS.Core.Application/Service/Financial/DTO/PaymentModel.cs deleted file mode 100644 index 3b70b23fd..000000000 --- a/IRaCIS.Core.Application/Service/Financial/DTO/PaymentModel.cs +++ /dev/null @@ -1,179 +0,0 @@ -using System; -using IRaCIS.Core.Domain.Share; -using IRaCIS.Core.Infrastructure.Extention; - -namespace IRaCIS.Application.Contracts -{ - public class PaymentDTO - { - public PageOutput CostList { get; set; }=new PageOutput(); - public decimal ExchangeRate { get; set; } - } - public class PaymentModel - { - public Guid Id { get; set; } - public string RankName { get; set; } = String.Empty; - public Guid DoctorId { get; set; } - public string YearMonth { get; set; } = String.Empty; - public DateTime YearMonthDate { get; set; } - public DateTime? CalculateTime { get; set; } - public string CalculateUser { get; set; } = String.Empty; - - //额外信息 - public string Code { get; set; } = String.Empty; - public string FirstName { get; set; } = String.Empty; - public string LastName { get; set; } = String.Empty; - - public string ChineseName { get; set; } = String.Empty; - public string Phone { get; set; } = String.Empty; - public string DoctorNameInBank { get; set; } = String.Empty; - public string IDCard { get; set; } = String.Empty; - public string BankCardNumber { get; set; } = String.Empty; - public string BankName { get; set; } = String.Empty; - - public bool IsLock { get; set; } = false; - - public decimal ExchangeRate { get; set; } - - public decimal PaymentCNY { get; set; } - - public decimal AdjustPaymentCNY { get; set; } - public decimal TotalPaymentCNY { get; set; } - public decimal PaymentUSD { get; set; } - - public decimal AdjustPaymentUSD { get; set; } - public decimal TotalPaymentUSD { get; set; } - } - - public class PaymentCommand - { - public Guid Id { get; set; } - public Guid DoctorId { get; set; } - public string YearMonth => new DateTime(Year, Month, 1).ToString("yyyy-MM"); - public int Year { get; set; } - public int Month { get; set; } - public decimal PaymentUSD { get; set; } - public DateTime CalculateTime { get; set; } - public decimal PaymentCNY { get; set; } - public decimal ExchangeRate { get; set; } - public string CalculateUser { get; set; } = String.Empty; - } - - public class MonthlyPaymentQueryDTO : PageInput - { - public DateTime StatisticsDate { get; set; } - public string KeyWord { get; set; } = String.Empty; - public int? Nation { get; set; } - } - - public class MonthlyPaymentDetailQuery - { - public Guid PaymentId { get; set; } - public Guid ReviewerId { get; set; } - - public DateTime YearMonth { get; set; } - } - - //public class LaborPaymentQuery - //{ - // public Guid PaymentId { get; set; } - // public Guid ReviewerId { get; set; } - - // public DateTime YearMonth { get; set; } - //} - - - public class TrialAnalysisDTO - { - public Guid TrialId { get; set; } - public string Indication { get; set; } = String.Empty; - - public string TrialCode { get; set; } = String.Empty; - public string Cro { get; set; } = string.Empty; - - public int Expedited { get; set; } - - public string Type { get; set; } = String.Empty; - - public decimal PaymentUSD { get; set; } - public decimal RevenusUSD { get; set; } - public decimal GrossProfit => RevenusUSD - PaymentUSD; - public decimal GrossProfitMargin - { - get { - if (RevenusUSD == 0) - return 0; - else - { - return GrossProfit / RevenusUSD; - } - } - } - - } - - public class LaborPayment - { - public string ChineseName { get; set; } = String.Empty; - public string FirstName { get; set; } = String.Empty; - public string LastName { get; set; } = String.Empty; - - public string ResidentId { get; set; } = String.Empty; - - public string Phone { get; set; } = String.Empty; - - public string AccountNumber { get; set; } = String.Empty; - - public string Bank { get; set; } = String.Empty; - public string YearMonth { get; set; } = String.Empty; - - public decimal PaymentCNY { get; set; } - public decimal TaxCNY { get; set; } - public decimal ActuallyPaidCNY { get; set; } - public decimal BankTransferCNY { get; set; } - } - public class ReviewerAnalysisDTO - { - public List MissingTrialCodes = new List(); - public string ChineseName { get; set; } = String.Empty; - public string FirstName { get; set; } = String.Empty; - public string LastName { get; set; } = String.Empty; - - public Guid ReviewerId { get; set; } - public string ReviewerCode { get; set; } = String.Empty; - - public decimal PaymentUSD { get; set; } - public decimal RevenusUSD { get; set; } - public decimal GrossProfit => RevenusUSD - PaymentUSD; - - public decimal GrossProfitMargin - { - get { - if (RevenusUSD == 0) - return 0; - else - { - return GrossProfit / RevenusUSD; - } - } - } - } - public class AnalysisQueryDTO - { - public string Reviewer { get; set; } = String.Empty; - public DateTime BeginDate { get; set; } - public DateTime EndDate { get; set; } - - public int? Nation { get; set; } - } - - public class TrialAnalysisQueryDTO - { - public Guid? CroId { get; set; } - public string TrialCode { get; set; } = String.Empty; - public DateTime BeginDate { get; set; } - public DateTime EndDate { get; set; } - - //public AttendedReviewerType? AttendedReviewerType { get; set; } - } -} \ No newline at end of file diff --git a/IRaCIS.Core.Application/Service/Financial/DTO/RankPriceModel.cs b/IRaCIS.Core.Application/Service/Financial/DTO/RankPriceModel.cs deleted file mode 100644 index 4e39bdc04..000000000 --- a/IRaCIS.Core.Application/Service/Financial/DTO/RankPriceModel.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System; -using IRaCIS.Core.Infrastructure.Extention; - -namespace IRaCIS.Application.Contracts -{ - public class RankPriceDTO - { - public Guid Id { get; set; } - public string RankName { get; set; } = string.Empty; - public decimal Timepoint { get; set; } - public decimal TimepointIn24H { get; set; } - public decimal TimepointIn48H { get; set; } - public decimal Adjudication { get; set; } - public decimal AdjudicationIn24H { get; set; } - public decimal AdjudicationIn48H { get; set; } - public decimal Global { get; set; } - public decimal Training { get; set; } - public decimal Downtime { get; set; } - - public decimal RefresherTraining { get; set; } - public int ShowOrder { get; set; } - } - - public class RankDic - { - public Guid Id { get; set; } - public string RankName { get; set; } = string.Empty; - } - - public class RankPriceCommand - { - public Guid? Id { get; set; } - public string RankName { get; set; } = string.Empty; - public decimal Timepoint { get; set; } - public decimal TimepointIn24H { get; set; } - public decimal TimepointIn48H { get; set; } - public decimal Adjudication { get; set; } - public decimal AdjudicationIn24H { get; set; } - public decimal AdjudicationIn48H { get; set; } - public decimal Global { get; set; } - public decimal Training { get; set; } - public decimal Downtime { get; set; } - public decimal RefresherTraining { get; set; } - - - } - public class RankPriceQueryDTO : PageInput - { - } -} \ No newline at end of file diff --git a/IRaCIS.Core.Application/Service/Financial/DTO/ReviewerPayInfoModel.cs b/IRaCIS.Core.Application/Service/Financial/DTO/ReviewerPayInfoModel.cs deleted file mode 100644 index 12e7de8be..000000000 --- a/IRaCIS.Core.Application/Service/Financial/DTO/ReviewerPayInfoModel.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System; - -namespace IRaCIS.Application.Contracts -{ - public class ReviewerPayInfoQueryDTO - { - public Guid DoctorId { get; set; } - public string FirstName { get; set; } = String.Empty; - public string LastName { get; set; } = String.Empty; - public string ChineseName { get; set; } = String.Empty; - public string Code { get; set; } = String.Empty; - public string Phone { get; set; } = String.Empty; - public string DoctorNameInBank { get; set; } = String.Empty; - public string IDCard { get; set; } = String.Empty; - public string BankCardNumber { get; set; } = String.Empty; - public string BankName { get; set; } = String.Empty; - public Guid? RankId { get; set; } - public decimal? Additional { get; set; } - public DateTime? CreateTime { get; set; } - } - - public class DoctorPayInfoQueryListDTO : ReviewerPayInfoQueryDTO - { - public string Hospital { get; set; } = String.Empty; - public string RankName { get; set; } = String.Empty; - } - - public class ReviewerPayInfoCommand - { - //public Guid Id { get; set; } - public Guid DoctorId { get; set; } - public string DoctorNameInBank { get; set; } = String.Empty; - public string IDCard { get; set; } = String.Empty; - public string BankCardNumber { get; set; } = String.Empty; - public string BankName { get; set; } = String.Empty; - public Guid RankId { get; set; } - public decimal? Additional { get; set; } - } -} - diff --git a/IRaCIS.Core.Application/Service/Financial/DTO/TrialPaymentPriceModel.cs b/IRaCIS.Core.Application/Service/Financial/DTO/TrialPaymentPriceModel.cs deleted file mode 100644 index f05cc3bc8..000000000 --- a/IRaCIS.Core.Application/Service/Financial/DTO/TrialPaymentPriceModel.cs +++ /dev/null @@ -1,46 +0,0 @@ -using IRaCIS.Core.Domain.Share; -using System; - -namespace IRaCIS.Application.Contracts -{ - - public class DtoDoctorList - { - public Guid TrialId { get; set; } - - public string Name { get; set; } - } - - public class TrialPaymentPriceDTO - { - public Guid TrialId { get; set; } - public string TrialCode { get; set; } = String.Empty; - public string Indication { get; set; } = String.Empty; - public string Cro { get; set; } = String.Empty; - public int Expedited { get; set; } - - public bool? IsNewTrial { get; set; } - public decimal? TrialAdditional { get; set; } - public DateTime? CreateTime { get; set; } - public string SowName { get; set; } = String.Empty; - public string SowPath { get; set; } = String.Empty; - public string SowFullPath => SowPath; - public decimal AdjustmentMultiple { get; set; } = 1; - - public string DoctorsNames{ get; set; }=String.Empty; - - public string ReviewMode { get; set; } = String.Empty; - - - } - - public class TrialPaymentPriceCommand - { - public Guid TrialId { get; set; } - public decimal TrialAdditional { get; set; } - public decimal AdjustmentMultiple { get; set; } - - public bool? IsNewTrial { get; set; } - - } -} diff --git a/IRaCIS.Core.Application/Service/Financial/DTO/TrialRevenuesPriceModel.cs b/IRaCIS.Core.Application/Service/Financial/DTO/TrialRevenuesPriceModel.cs deleted file mode 100644 index afe5207cc..000000000 --- a/IRaCIS.Core.Application/Service/Financial/DTO/TrialRevenuesPriceModel.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System; -using IRaCIS.Core.Infrastructure.Extention; - -namespace IRaCIS.Application.Contracts -{ - public class TrialRevenuesPriceDTO - { - - public Guid TrialId { get; set; } - public decimal Timepoint { get; set; } - public decimal TimepointIn24H { get; set; } - public decimal TimepointIn48H { get; set; } - public decimal Adjudication { get; set; } - public decimal AdjudicationIn24H { get; set; } - public decimal AdjudicationIn48H { get; set; } - public decimal RefresherTraining { get; set; } - - public decimal Global { get; set; } - public decimal Training { get; set; } - public decimal Downtime { get; set; } - } - - public class TrialRevenuesPriceDetialDTO : TrialRevenuesPriceDTO - { - public Guid Id { get; set; } - public string TrialCode { get; set; } = String.Empty; - public string Indication { get; set; } = string.Empty; - public int Expedited { get; set; } - public string ReviewMode { get; set; } = String.Empty; - public string Cro { get; set; } = String.Empty; - } - public class TrialRevenuesPriceQueryDTO : PageInput - { - public string KeyWord { get; set; } = String.Empty; - public Guid? CroId { get; set; } - } -} diff --git a/IRaCIS.Core.Application/Service/Financial/DTO/TrialRevenuesPriceVerificationDTO.cs b/IRaCIS.Core.Application/Service/Financial/DTO/TrialRevenuesPriceVerificationDTO.cs deleted file mode 100644 index 4492ed0e8..000000000 --- a/IRaCIS.Core.Application/Service/Financial/DTO/TrialRevenuesPriceVerificationDTO.cs +++ /dev/null @@ -1,72 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace IRaCIS.Core.Application.Contracts -{ - public class RevenusVerifyQueryDTO - { - public DateTime BeginDate { get; set; } = DateTime.Now; - public DateTime EndDate { get; set; } = DateTime.Now; - - } - - public class AnalysisVerifyQueryDTO - { - public DateTime BeginDate { get; set; } = DateTime.Now; - public DateTime EndDate { get; set; } = DateTime.Now; - } - - - public class AnalysisNeedLockDTO - { - public string YearMonth { get; set; } = string.Empty; - - public string ReviewerCode { get; set; } = string.Empty; - - public string ReviewerName { get; set; } = string.Empty; - - public string ReviewerNameCN { get; set; } = string.Empty; - } - - public class AnalysisVerifyResultDTO - { - public List MonthVerifyResult = new List(); - - public List RevenuesVerifyList = new List(); - } - - - - public class MonthlyResult - { - public string YearMonth { get; set; } = string.Empty; - public List ReviewerNameList = new List(); - public List ReviewerNameCNList = new List(); - public List ReviewerCodeList = new List(); - } - - - public class RevenusVerifyDTO - { - public string TrialCode { get; set; } = string.Empty; - - public bool Training { get; set; } = false; - - public bool Downtime { get; set; } = false; - - public bool Global { get; set; } = false; - - public bool Timepoint { get; set; } = false; - - public bool TimepointIn24H { get; set; } = false; - - public bool TimepointIn48H { get; set; } = false; - - public bool Adjudication { get; set; } = false; - - public bool AdjudicationIn24H { get; set; } = false; - - public bool AdjudicationIn48H { get; set; } = false; - - } -} \ No newline at end of file diff --git a/IRaCIS.Core.Application/Service/Financial/ExchangeRateService.cs b/IRaCIS.Core.Application/Service/Financial/ExchangeRateService.cs deleted file mode 100644 index 1b686ac17..000000000 --- a/IRaCIS.Core.Application/Service/Financial/ExchangeRateService.cs +++ /dev/null @@ -1,117 +0,0 @@ -using IRaCIS.Application.Interfaces; -using IRaCIS.Application.Contracts; -using IRaCIS.Core.Application.Filter; -using IRaCIS.Core.Infra.EFCore; -using IRaCIS.Core.Domain.Models; -using IRaCIS.Core.Infrastructure.Extention; -using Microsoft.AspNetCore.Mvc; -using Panda.DynamicWebApi.Attributes; - -namespace IRaCIS.Application.Services -{ - - [ApiExplorerSettings(GroupName = "Financial")] - public class ExchangeRateService : BaseService, IExchangeRateService - { - private readonly IRepository _exchangeRateRepository; - private readonly IRepository _paymentRepository; - - public ExchangeRateService(IRepository exchangeRateRepository, IRepository paymentRepository) - { - _exchangeRateRepository = exchangeRateRepository; - _paymentRepository = paymentRepository; - } - - [NonDynamicMethod] - public async Task AddOrUpdateExchangeRate(ExchangeRateCommand model) - { - if (model.Id == Guid.Empty || model.Id == null) - { - var existItem = await _exchangeRateRepository.FirstOrDefaultAsync(u => u.YearMonth == model.YearMonth); - if (existItem != null) - { - //---The exchange rate of the same month already existed. - return ResponseOutput.NotOk(_localizer["ExR_SameMthExist"]); - } - var rate = _mapper.Map(model); - rate = await _exchangeRateRepository.AddAsync(rate); - if (await _exchangeRateRepository.SaveChangesAsync()) - { - return ResponseOutput.Ok(rate.Id.ToString()); - } - else - { - return ResponseOutput.NotOk(); - } - - } - else - { - var success = await _exchangeRateRepository.BatchUpdateNoTrackingAsync(t => t.Id == model.Id, u => new ExchangeRate() - { - //YearMonth = model.YearMonth, - Rate = model.Rate, - UpdateTime = DateTime.Now - }); - return ResponseOutput.Result(success); - } - } - - /// - /// 根据记录Id,删除汇率记录 - /// - /// 汇率记录Id - - [HttpDelete("{id:guid}")] - public async Task DeleteExchangeRate(Guid id) - { - var monthInfo = await _exchangeRateRepository.FirstOrDefaultAsync(t => t.Id == id); - - if (await _paymentRepository.AnyAsync(t => t.YearMonth == monthInfo.YearMonth)) - { - //---The exchange rate has been used in monthly payment - return ResponseOutput.NotOk(_localizer["ExR_MthPymtRate"]); - } - - - var success = await _exchangeRateRepository.BatchDeleteNoTrackingAsync(t => t.Id == id); - - return ResponseOutput.Ok(success); - } - - - [NonDynamicMethod] - public async Task GetExchangeRateByMonth(string month) - { - //var rate = _exchangeRateRepository.FindSingleOrDefault(u => u.YearMonth.Equals(month)); - //if (rate == null) - //{ - // return 0; - //} - //return rate.Rate; - - var rate = await _exchangeRateRepository.FirstOrDefaultAsync(t => t.YearMonth == month); - if (rate == null) - { - return 0; - } - return rate.Rate; - } - - [HttpPost] - public async Task> GetExchangeRateList(ExchangeRateQueryDTO queryParam) - { - - var yearMonth = queryParam.SearchMonth?.ToString("yyyy-MM"); - - var exchangeRateQueryable = _exchangeRateRepository.AsQueryable() - .WhereIf(queryParam.SearchMonth != null, o => o.YearMonth == yearMonth) - .ProjectTo(_mapper.ConfigurationProvider); - - return await exchangeRateQueryable.ToPagedListAsync(queryParam.PageIndex, queryParam.PageSize, "YearMonth", false); - - - - } - } -} diff --git a/IRaCIS.Core.Application/Service/Financial/FinancialService.cs b/IRaCIS.Core.Application/Service/Financial/FinancialService.cs deleted file mode 100644 index 7ddd39012..000000000 --- a/IRaCIS.Core.Application/Service/Financial/FinancialService.cs +++ /dev/null @@ -1,1314 +0,0 @@ -using IRaCIS.Application.Interfaces; -using IRaCIS.Application.Contracts; -using IRaCIS.Application.Contracts.Pay; -using IRaCIS.Core.Domain.Share; -using System.Linq.Expressions; -using Microsoft.AspNetCore.Mvc; -using Panda.DynamicWebApi.Attributes; -using System.Linq.Dynamic.Core; - -namespace IRaCIS.Application.Services -{ - [ ApiExplorerSettings(GroupName = "Financial")] - public class FinancialService : BaseService, IPaymentService - { - private readonly IRepository _paymentRepository; - private readonly IRepository _doctorPayInfoRepository; - private readonly IRepository _TrialPaymentPriceRepository; - private readonly IRepository _trialRepository; - private readonly IRepository _doctorRepository; - private readonly IRepository _rankPriceRepository; - private readonly IRepository _paymentDetailRepository; - private readonly IRepository _croRepository; - private readonly IRepository _workloadRepository; - private readonly IRepository _trialRevenuePriceRepository; - private readonly IRepository _payAdjustmentRepository; - - private readonly IRepository _enrollRepository; - - private readonly IRepository _doctorWorkloadRepository; - - public FinancialService(IRepository costStatisticsRepository, - IRepository doctorPayInfoRepository, - IRepository trialRepository, - IRepository doctorRepository, - IRepository rankPriceRepository, - IRepository costStatisticsDetailRepository, - IRepository croCompanyRepository, - IRepository workloadRepository, - IRepository intoGroupRepository, - IRepository trialPaymentPriceRepository, - IRepository trialCostRepository, - IRepository costAdjustmentRepository, - IRepository doctoWorkloadRepository - ) - { - _TrialPaymentPriceRepository = trialPaymentPriceRepository; - _paymentRepository = costStatisticsRepository; - _doctorPayInfoRepository = doctorPayInfoRepository; - _trialRepository = trialRepository; - _doctorRepository = doctorRepository; - _rankPriceRepository = rankPriceRepository; - _paymentDetailRepository = costStatisticsDetailRepository; - _croRepository = croCompanyRepository; - _enrollRepository = intoGroupRepository; - _workloadRepository = workloadRepository; - _trialRevenuePriceRepository = trialCostRepository; - _payAdjustmentRepository = costAdjustmentRepository; - - _doctorWorkloadRepository = doctoWorkloadRepository; - } - - /// - /// Financials /MonthlyPayment 列表查询接口 - /// - [NonDynamicMethod] - public async Task> GetMonthlyPaymentList(MonthlyPaymentQueryDTO queryParam) - { - //var year = queryParam.StatisticsDate.Year; - //var month = queryParam.StatisticsDate.Month; - //var searchBeginDateTime = queryParam.StatisticsDate; - //Expression> workloadLambda = t => t.DataFrom == (int)WorkLoadFromStatus.FinalConfirm; - //workloadLambda = workloadLambda.And(t => - // t.WorkTime >= queryParam.StatisticsDate && t.WorkTime <= queryParam.StatisticsDate); - //var rate = _exchangeRateRepository.FindSingleOrDefault(u => u.YearMonth == yearMonth); - //var exchangeRate = rate == null ? 0 : rate.Rate; - - var yearMonth = queryParam.StatisticsDate.ToString("yyyy-MM"); - - Expression> doctorLambda = x => true; - if (!string.IsNullOrWhiteSpace(queryParam.KeyWord)) - { - var reviewer = queryParam.KeyWord.Trim(); - doctorLambda = doctorLambda.And(u => u.ChineseName.Contains(reviewer) - || u.FirstName.Contains(reviewer) - || u.LastName.Contains(reviewer) - || u.ReviewerCode.Contains(reviewer)); - } - - if (queryParam.Nation != null) - { - doctorLambda = doctorLambda.And(u => u.Nation == queryParam.Nation); - } - - var costStatisticsQueryable = - - from monthlyPayment in _paymentRepository.Where(t => t.YearMonth == yearMonth) - join payInfo in _doctorPayInfoRepository.AsQueryable() on monthlyPayment.DoctorId equals payInfo.DoctorId - into cc - from payInfo in cc.DefaultIfEmpty() - join doctor in _doctorRepository.Where(doctorLambda) on monthlyPayment.DoctorId equals doctor.Id - join rankPrice in _rankPriceRepository.AsQueryable() on payInfo.RankId equals rankPrice.Id into dd - from rankPriceItem in dd.DefaultIfEmpty() - select new PaymentModel() - { - Id = monthlyPayment.Id, - DoctorId = monthlyPayment.DoctorId, - YearMonth = monthlyPayment.YearMonth, - PaymentUSD = monthlyPayment.PaymentUSD, - CalculateTime = monthlyPayment.CalculateTime, - CalculateUser = monthlyPayment.CalculateUser, - IsLock = monthlyPayment.IsLock, - ExchangeRate = monthlyPayment.ExchangeRate, - PaymentCNY = monthlyPayment.PaymentCNY, - AdjustPaymentCNY = monthlyPayment.AdjustmentCNY, - AdjustPaymentUSD = monthlyPayment.AdjustmentUSD, - - TotalPaymentCNY = monthlyPayment.AdjustmentCNY + monthlyPayment.PaymentCNY, - TotalPaymentUSD = monthlyPayment.AdjustmentUSD + monthlyPayment.PaymentUSD, - - - Code = doctor.ReviewerCode, - FirstName = doctor.FirstName, - LastName = doctor.LastName, - ChineseName = doctor.ChineseName, - Phone = doctor.Phone, - DoctorNameInBank = payInfo.DoctorNameInBank, - RankName = rankPriceItem.RankName, - IDCard = payInfo.IDCard, - BankCardNumber = payInfo.BankCardNumber, - BankName = payInfo.BankName - }; - - - - return await costStatisticsQueryable.ToPagedListAsync(queryParam.PageIndex, queryParam.PageSize, string.IsNullOrWhiteSpace(queryParam.SortField) ? "Code" : queryParam.SortField, queryParam.Asc); - - //var propName = string.IsNullOrWhiteSpace(queryParam.SortField) ? "Code" : queryParam.SortField; - //costStatisticsQueryable = queryParam.Asc ? costStatisticsQueryable.OrderBy(propName).ThenBy(u => u.Code) - // : costStatisticsQueryable.OrderByDescending(propName).ThenBy(u => u.Code); - //var count = costStatisticsQueryable.Count(); - //costStatisticsQueryable = costStatisticsQueryable.Skip((queryParam.PageIndex - 1) * queryParam.PageSize).Take(queryParam.PageSize); - //var costStatisticsList = await costStatisticsQueryable.ToListAsync(); - //return new PageOutput(queryParam.PageIndex, queryParam.PageSize, count, costStatisticsList); - - - #region 增加调整费用总计字段之前 - //var doctorIds = costStatisticsList.Select(t => t.DoctorId).ToList(); - - //var adjList = _payAdjustmentRepository.GetAll() - // .Where(t => t.YearMonth == yearMonth && doctorIds.Contains(t.ReviewerId)) - // .GroupBy(t => t.ReviewerId).Select(g => new - // { - // ReviewerId = g.Key, - // AdjustPaymentCNY = g.Sum(t => t.AdjustPaymentCNY), - // AdjustPaymentUSD = g.Sum(t => t.AdjustPaymentUSD) - // }).ToList(); - - //costStatisticsList.ForEach(t => - //{ - // var tempAdj = adjList.FirstOrDefault(u => u.ReviewerId == t.DoctorId); - // if (tempAdj != null) - // { - // t.AdjustPaymentUSD = tempAdj.AdjustPaymentUSD; - // t.AdjustPaymentCNY = tempAdj.AdjustPaymentCNY; - - // } - //}); - - - #endregion - - } - - /// - /// Financials /MonthlyPaymentDetail 详情查询接口 - /// - [HttpPost("{paymentId:guid}/{doctorId:guid}/{yearMonth:datetime}")] - public async Task GetMonthlyPaymentDetailList(Guid paymentId, Guid reviewerId, DateTime yearMonth) - { - var returnModel = new PayDetailDTO(); - var yearMonthStr = yearMonth.ToString("yyyy-MM"); - - List detailList = new List(); - //有详细表的数据 先查出来 - if (paymentId != Guid.Empty) - { - - //from enroll in _enrollRepository.Where(t => t.TrialId == challengeQuery.TrialId) - //join dociorc in _doctorRepository.Where() on enroll.DoctorId equals dociorc.Id - //join price in _TrialPaymentPriceRepository.Where() on enroll.TrialId equals price.TrialId - - - //select new EnrollViewModel() - //{ - // ChineseName = dociorc.ChineseName, - // AdjustmentMultiple = enroll.AdjustmentMultiple, - // FirstName = dociorc.FirstName, - // LastName = dociorc.LastName, - // DoctorId = dociorc.Id, - // TrialId = challengeQuery.TrialId - - //}; - //detailList = _paymentDetailRepository.AsQueryable() - // .Where(t => t.PaymentId == paymentId) - // .OrderBy(t => t.ShowCodeOrder).ThenBy(t => t.ShowTypeOrder).ProjectTo(_mapper.ConfigurationProvider).ToList(); - - - detailList = await (from pay in _paymentDetailRepository.Where(t => t.PaymentId == paymentId) - join enroll in _enrollRepository.Where() on new { pay.DoctorId, pay.TrialId } equals new { enroll.DoctorId, enroll.TrialId } - join price in _TrialPaymentPriceRepository.Where() on pay.TrialId equals price.TrialId - orderby pay.ShowCodeOrder - orderby pay.ShowTypeOrder - select new PaymentDetailDTO() - { - Id=pay.Id, - ShowCodeOrder = pay.ShowCodeOrder, - ShowTypeOrder = pay.ShowTypeOrder, - PaymentUSD = pay.PaymentUSD, - BasePrice = pay.BasePrice, - PersonalAdditional = pay.PersonalAdditional, - TrialAdditional = pay.TrialAdditional, - TrialCode = pay.TrialCode, - PaymentCNY = pay.PaymentCNY, - DoctorId = pay.DoctorId, - ExchangeRate = pay.ExchangeRate, - IsNewTrial = price.IsNewTrial, - NewPersonalAdditional= enroll.AdjustmentMultiple, - - }).ToListAsync(); - - } - //费用调整 - //_payAdjustmentRepository.Where(t => t.YearMonth == yearMonthStr && t.ReviewerId == reviewerId) - var adjList = - await (from costAdjustment in _payAdjustmentRepository.Where(t => t.YearMonth == yearMonthStr&& t.ReviewerId == paymentId) - join enroll in _enrollRepository.Where() on new { costAdjustment.ReviewerId, costAdjustment.TrialId } equals new { ReviewerId= enroll.DoctorId, enroll.TrialId } - join price in _TrialPaymentPriceRepository.Where() on costAdjustment.TrialId equals price.TrialId - - - select new PaymentDetailDTO() - { - Id=costAdjustment.Id, - TrialCode = "Adjustment", - PaymentCNY = costAdjustment.AdjustmentCNY, - PaymentUSD = costAdjustment.AdjustmentUSD, - DoctorId = costAdjustment.ReviewerId, - ExchangeRate = costAdjustment.ExchangeRate, - AdjustmentView = new AdjustmentDTO() - { - AdjustPaymentUSD = costAdjustment.AdjustmentUSD, - AdjustPaymentCNY = costAdjustment.AdjustmentCNY, - Note = costAdjustment.Note - }, - IsNewTrial = price.IsNewTrial, - NewPersonalAdditional = enroll.AdjustmentMultiple, - - }).ToListAsync(); - - - - - detailList.AddRange(adjList); - - detailList.ForEach(x => - { - x.PersonalAdditional = x.IsNewTrial == true && x.NewPersonalAdditional != null ? 0 : x.PersonalAdditional; - x.TrialAdditional = x.IsNewTrial == true && x.NewPersonalAdditional != null ? 0 : x.TrialAdditional; - x.BasePrice = x.IsNewTrial == true && x.NewPersonalAdditional != null ? x.NewPersonalAdditional.Value : x.BasePrice; - - }); - - returnModel.DetailList = detailList; - - - - var doctorId = returnModel.DetailList.FirstOrDefault()?.DoctorId; - var query = from doctor in _doctorRepository.AsQueryable() - .Where(t => t.Id == doctorId) - join payInfo in _doctorPayInfoRepository.AsQueryable() on doctor.Id equals payInfo.DoctorId - join rank in _rankPriceRepository.AsQueryable() on payInfo.RankId equals rank.Id - select new DoctorPayInfo() - { - Code = doctor.ReviewerCode, - ChineseName = doctor.ChineseName, - FirstName = doctor.FirstName, - LastName = doctor.LastName, - Phone = doctor.Phone, - DoctorId = doctor.Id, - PayTitle = rank.RankName, - YearMonth = yearMonthStr - }; - - returnModel.DoctorInfo =(await query.FirstOrDefaultAsync()).IfNullThrowException(); - - return returnModel; - } - - /// - /// NEW 导出Excel压缩包 数据获取 - /// - [HttpPost] - public async Task> GetReviewersMonthlyPaymentDetail(List manyReviewers) - { - List result = new List(); - foreach (var t in manyReviewers) - { - result.Add(await GetMonthlyPaymentDetailList(t.PaymentId, t.ReviewerId, t.YearMonth)); - } - - - return result; - - } - - - /// - /// Financials / Payment History 列表查询接口(已经支付锁定的数据,包含调整的)[New] - /// - [HttpPost] - public async Task> GetPaymentHistoryList(PaymentQueryDTO queryParam) - { - Expression> doctorLambda = x => true; - if (!string.IsNullOrWhiteSpace(queryParam.Reviewer)) - { - var reviewer = queryParam.Reviewer.Trim(); - doctorLambda = doctorLambda.And(u => u.ChineseName.Contains(reviewer) - || u.FirstName.Contains(reviewer) - || u.LastName.Contains(reviewer) - || u.ReviewerCode.Contains(reviewer)); - } - if (queryParam.Nation != null) - { - doctorLambda = doctorLambda.And(u => u.Nation == queryParam.Nation); - } - - Expression> paymentLambda = x => x.IsLock && x.YearMonthDate >= queryParam.BeginMonth && x.YearMonthDate <= queryParam.EndMonth; - - #region 在 payment表加 调整总计前 - - //var paymentQueryable = _paymentRepository.Find(paymentLambda) - // .Select( - // t => new - // { - // ReviewerId = t.DoctorId, - // t.YearMonth, - // t.PaymentUSD, - // t.PaymentCNY, - // t.AdjustPaymentCNY, - // t.AdjustPaymentUSD - // }); - - //Expression> payAdjustmentLambda = x => x.IsLock && x.AdjustedYearMonth >= param.BeginMonth && x.AdjustedYearMonth <= param.EndMonth; - - //var adjQueryable = _payAdjustmentRepository.GetAll() - // .Where(payAdjustmentLambda) - // .GroupBy(t => new { t.ReviewerId, t.YearMonth }).Select(g => new - // { - // g.Key.ReviewerId, - // g.Key.YearMonth, - // PaymentUSD = 0, - // PaymentCNY = 0, - // AdjustPaymentCNY = g.Sum(t => t.AdjustPaymentCNY), - // AdjustPaymentUSD = g.Sum(t => t.AdjustPaymentUSD) - // }); - - //var query = from pay in (from paymentCost in paymentQueryable - // join adjCost in adjQueryable on new { paymentCost.YearMonth, paymentCost.ReviewerId } equals new { adjCost.YearMonth, adjCost.ReviewerId } into a - // from adjCost in a.DefaultIfEmpty() - // select new - // { - // paymentCost.ReviewerId, - // paymentCost.PaymentUSD, - // paymentCost.PaymentCNY, - // AdjustmentCNY = adjCost == null ? 0 : adjCost.AdjustPaymentCNY, - // AdjustmentUSD = adjCost == null ? 0 : adjCost.AdjustPaymentUSD - // } - // ).Union( - // from adjCost in adjQueryable - // join paymentCost in paymentQueryable on new { adjCost.YearMonth, adjCost.ReviewerId } equals new { paymentCost.YearMonth, paymentCost.ReviewerId } into a - // from paymentCost in a.DefaultIfEmpty() - // select new - // { - // ReviewerId = adjCost.ReviewerId, - // PaymentUSD = paymentCost == null ? 0 : paymentCost.PaymentUSD, - // PaymentCNY = paymentCost == null ? 0 : paymentCost.PaymentCNY, - // AdjustmentCNY = adjCost.AdjustPaymentCNY, - // AdjustmentUSD = adjCost.AdjustPaymentUSD - // } - // ) - - #endregion - - var query = from monthlyPay in _paymentRepository.Where(paymentLambda) - .GroupBy(t => t.DoctorId).Select(g => new - { - ReviewerId = g.Key, - PaymentUSD = g.Sum(u => u.PaymentUSD), - PaymentCNY = g.Sum(u => u.PaymentCNY), - AdjustmentCNY = g.Sum(u => u.AdjustmentCNY), - AdjustmentUSD = g.Sum(u => u.AdjustmentCNY) - }) - join doctor in _doctorRepository.Where(doctorLambda) on monthlyPay.ReviewerId equals doctor.Id - select new MonthlyPaymentDTO - { - ReviewerId = doctor.Id, - ChineseName = doctor.ChineseName, - FirstName = doctor.FirstName, - LastName = doctor.LastName, - FullName= doctor.FullName, - ReviewerCode = doctor.ReviewerCode, - PaymentUSD = monthlyPay.PaymentUSD, - PaymentCNY = monthlyPay.PaymentCNY, - AdjustmentCNY = monthlyPay.AdjustmentCNY, - AdjustmentUSD = monthlyPay.AdjustmentUSD, - TotalCNY = monthlyPay.AdjustmentCNY + monthlyPay.PaymentCNY, - TotalUSD = monthlyPay.AdjustmentUSD + monthlyPay.PaymentUSD - }; - - return await query.ToPagedListAsync(queryParam.PageIndex, queryParam.PageSize, string.IsNullOrWhiteSpace(queryParam.SortField) ? "ReviewerCode" : queryParam.SortField, queryParam.Asc); - - //var propName = queryParam.SortField == string.Empty ? "ReviewerCode" : queryParam.SortField; - //query = queryParam.Asc ? query.OrderBy(propName).ThenBy(u => u.ReviewerCode) : query.OrderByDescending(propName).ThenBy(u => u.ReviewerCode); - //if (propName == "FirstName" || propName == "LastName") - //{ - // query = queryParam.Asc ? query.OrderBy(t => t.LastName).ThenBy(t => t.FirstName) - // : query.OrderByDescending(t => t.LastName).ThenBy(t => t.FirstName); - //} - //var count = await query.CountAsync(); - //query = query.Skip((queryParam.PageIndex - 1) * queryParam.PageSize).Take(queryParam.PageSize); - //var list = await query.ToListAsync(); - //return new PageOutput(queryParam.PageIndex, queryParam.PageSize, count, list); - - } - - /// - /// Financials / Payment History 详情接口[New] - /// - [HttpPost] - public async Task> GetPaymentHistoryDetailList(VolumeQueryDTO param) - { - var beginDate = new DateTime(param.BeginMonth.Year, param.BeginMonth.Month, 1); - var endDate = new DateTime(param.EndMonth.Year, param.EndMonth.Month, 1); - - Expression> monthlyPayLambda = x => x.IsLock && x.DoctorId == param.ReviewerId && x.YearMonthDate >= beginDate && x.YearMonthDate <= endDate; - - var query = - from monthlyPayment in _paymentRepository.Where(monthlyPayLambda) - - select new VolumeStatisticsDTO - { - StatisticsId = monthlyPayment.Id, - Month = monthlyPayment.YearMonth, - ExchangeRate = monthlyPayment.ExchangeRate, - PaymentUSD = monthlyPayment.PaymentUSD, - PaymentCNY = monthlyPayment.PaymentCNY, - AdjustmentCNY = monthlyPayment.AdjustmentCNY, - AdjustmentUSD = monthlyPayment.AdjustmentUSD, - VolumeReward = 0 - }; - - var payDetailList = await query.OrderBy(t => t.Month).ToListAsync(); - - List statisticsIdList = payDetailList.Select(t => t.StatisticsId).ToList(); - - var monthlyPayDetailList = await _paymentDetailRepository.Where(u => - statisticsIdList.Contains(u.PaymentId)).Select(t => new - { - PaymentId = t.PaymentId, - t.PaymentUSD, - t.TrialCode, - t.PaymentCNY, - t.YearMonth - }).ToListAsync(); - - payDetailList.ForEach(t => - { - t.VolumeReward = monthlyPayDetailList - .Where(u => u.PaymentId == t.StatisticsId && u.TrialCode == "Volume Reward") - .Sum(k => k.PaymentUSD); - - t.TrialPaymentList = monthlyPayDetailList - .Where(u => u.PaymentId == t.StatisticsId && u.TrialCode != "Volume Reward" && u.YearMonth == t.Month) - .GroupBy(u => u.TrialCode).Select(g => new TrialPaymentDTO - { - TrialPayment = g.Sum(k => k.PaymentUSD), - TrialCode = g.Key - }).ToList(); - }); - - - #region 改表之前 - - //var tempVolume = _costStatisticsDetailRepository.Find(u => - // statisticsIdList.Contains(u.PaymentId)).ToList(); - - //foreach (var item in payDetailList) - //{ - // var temp = tempVolume.Where(u => u.PaymentId == item.StatisticsId && u.TrialCode == "Volume Reward"); - // var Volume = 0.0; - // foreach (var t in temp) - // { - // Volume += (t.BasePrice * t.Count); - // } - // item.VolumeReward = Volume; - - // var trialCodes = tempVolume.Where(u => u.PaymentId == item.StatisticsId - // && u.TrialCode != "Volume Reward").GroupBy(u => u.TrialCode).Select(u => u.Key).Distinct(); - - // foreach (var trial in trialCodes) - // { - // var trialFee = 0.0; - // var aa = tempVolume.Where(u => u.PaymentId == item.StatisticsId && u.TrialCode == trial - // ).ToList(); - - // foreach (var a in aa) - // { - // trialFee += (a.Count * (a.BasePrice + a.PersonalAdditional + a.TrialAdditional)); - // } - // item.TrialFeeList.Add(new TrialFeeViewModel - // { - // TrialCode = trial, - // TrialFee = trialFee - // }); - // } - - //} - - #endregion - - return payDetailList; - } - - /// - /// Revenues列表接口,收入统计[New] 0是Detail 1是按照项目 2是按照人 3按照月份 - /// - [HttpPost] - public async Task> GetRevenuesStatistics(StatisticsQueryDTO queryParam) - { - var bDate = new DateTime(queryParam.BeginDate.Year, queryParam.BeginDate.Month, 1); - var eDate = new DateTime(queryParam.EndDate.Year, queryParam.EndDate.Month, 1); - Expression> workloadLambda = x => x.DataFrom == (int)WorkLoadFromStatus.FinalConfirm; - workloadLambda = workloadLambda.And(x => x.WorkTime >= bDate && x.WorkTime <= eDate); - - Expression> trialLambda = x => true; - if (Guid.Empty != queryParam.CroId && queryParam.CroId != null) - { - trialLambda = trialLambda.And(u => u.CROId == queryParam.CroId); - } - if (!string.IsNullOrWhiteSpace(queryParam.TrialCode)) - { - var trialCode = queryParam.TrialCode.Trim(); - trialLambda = trialLambda.And(u => u.TrialCode.Contains(trialCode)); - } - - //if (queryParam.AttendedReviewerType != null) - //{ - // trialLambda = trialLambda.And(u => u.AttendedReviewerType == queryParam.AttendedReviewerType); - //} - - - - Expression> doctorLambda = x => true; - - if (!string.IsNullOrWhiteSpace(queryParam.Reviewer)) - { - var reviewer = queryParam.Reviewer.Trim(); - doctorLambda = doctorLambda.And(u => u.ChineseName.Contains(reviewer) - || u.FirstName.Contains(reviewer) - || u.LastName.Contains(reviewer) - || u.ReviewerCode.Contains(reviewer)); - } - if (queryParam.Nation != null) - { - doctorLambda = doctorLambda.And(u => u.Nation == queryParam.Nation); - } - - List incomeList = new List(); - IQueryable? query=null ; - var propName = string.Empty; - var count = 0; - - #region 按照详细维度 ReviewId TrialId - - if (queryParam.StatType == 0) - { - query = from workLoad in _workloadRepository.Where(workloadLambda) - join doctor in _doctorRepository.Where(doctorLambda) - on workLoad.DoctorId equals doctor.Id - join trial in _trialRepository.Where(trialLambda) - on workLoad.TrialId equals trial.Id - join cro in _croRepository.AsQueryable() on trial.CROId equals cro.Id into ttt - from croItem in ttt.DefaultIfEmpty() - join trialCost in _trialRevenuePriceRepository.AsQueryable() on workLoad.TrialId equals trialCost.TrialId into c - from trialCost in c.DefaultIfEmpty() - select new RevenuesDTO - { - - TrialId = workLoad.TrialId, - Cro = croItem.CROName, - ReviewerCode = doctor.ReviewerCode, - ChineseName = doctor.ChineseName, - FirstName = doctor.FirstName, - LastName = doctor.LastName, - - Indication = trial.Indication, - TrialCode = trial.TrialCode, - Expedited = trial.Expedited, - CroId = trial.CROId, - - Downtime = workLoad.Downtime * trialCost.Downtime, - Training = workLoad.Training * trialCost.Training, - Timepoint = workLoad.Timepoint * trialCost.Timepoint, - TimepointIn24H = workLoad.TimepointIn24H * trialCost.TimepointIn24H, - TimepointIn48H = workLoad.TimepointIn48H * trialCost.TimepointIn48H, - Global = workLoad.Global * trialCost.Global, - Adjudication = workLoad.Adjudication * trialCost.Adjudication, - AdjudicationIn24H = - workLoad.AdjudicationIn24H * trialCost.AdjudicationIn24H, - AdjudicationIn48H = workLoad.AdjudicationIn48H * trialCost.AdjudicationIn48H, - - YearMonth = workLoad.YearMonth, - - Total = (workLoad.Downtime * trialCost.Downtime + - workLoad.Training * trialCost.Training + - workLoad.Timepoint * trialCost.Timepoint + - workLoad.TimepointIn24H * trialCost.TimepointIn24H + - workLoad.TimepointIn48H * trialCost.TimepointIn48H + - workLoad.Global * trialCost.Global + - workLoad.Adjudication * trialCost.Adjudication + - workLoad.AdjudicationIn24H * trialCost.AdjudicationIn24H + - workLoad.AdjudicationIn48H * trialCost.AdjudicationIn48H + - workLoad.RefresherTraining * trialCost.RefresherTraining - ) - - }; - - //处理排序字段 - propName = queryParam.SortField == "" ? "ReviewerCode" : queryParam.SortField; - - } - //按照项目维度 - if (queryParam.StatType == 1) - { - - var workloadQuery = from workLoad in _workloadRepository.Where(workloadLambda) - - group workLoad by workLoad.TrialId - into gWorkLoad - select new - { - TrialId = gWorkLoad.Key, - Downtime = gWorkLoad.Sum(t => t.Downtime), - Training = gWorkLoad.Sum(t => t.Training), - Timepoint = gWorkLoad.Sum(t => t.Timepoint), - TimepointIn24H = gWorkLoad.Sum(t => t.TimepointIn24H), - TimepointIn48H = gWorkLoad.Sum(t => t.TimepointIn48H), - Global = gWorkLoad.Sum(t => t.Global), - Adjudication = gWorkLoad.Sum(t => t.Adjudication), - AdjudicationIn24H = gWorkLoad.Sum(t => t.AdjudicationIn24H), - AdjudicationIn48H = gWorkLoad.Sum(t => t.AdjudicationIn48H), - RefresherTraining = gWorkLoad.Sum(t => t.RefresherTraining), - }; - - query = from workLoad in workloadQuery - join trialCost in _trialRevenuePriceRepository.AsQueryable() on workLoad.TrialId equals trialCost.TrialId - into c - from trialCost in c.DefaultIfEmpty() - join trial in _trialRepository.Where(trialLambda) on workLoad.TrialId equals trial.Id - join cro in _croRepository.AsQueryable() on trial.CROId equals cro.Id into ttt - from croItem in ttt.DefaultIfEmpty() - select new RevenuesDTO - { - - TrialId = trial.Id, - Indication = trial.Indication, - TrialCode = trial.TrialCode, - Expedited = trial.Expedited, - CroId = trial.CROId, - Cro = croItem.CROName, - Training = workLoad.Training * trialCost.Training, - Timepoint = workLoad.Timepoint * trialCost.Timepoint, - TimepointIn24H = workLoad.TimepointIn24H * trialCost.TimepointIn24H, - TimepointIn48H = workLoad.TimepointIn48H * trialCost.TimepointIn48H, - Adjudication = workLoad.Adjudication * trialCost.Adjudication, - AdjudicationIn24H = workLoad.AdjudicationIn24H * trialCost.AdjudicationIn24H, - AdjudicationIn48H = workLoad.AdjudicationIn48H * trialCost.AdjudicationIn48H, - Global = workLoad.Global * trialCost.Global, - Downtime = workLoad.Downtime * trialCost.Downtime, - - Total = (workLoad.Downtime * trialCost.Downtime + - workLoad.Training * trialCost.Training + - workLoad.Timepoint * trialCost.Timepoint + - workLoad.TimepointIn24H * trialCost.TimepointIn24H + - workLoad.TimepointIn48H * trialCost.TimepointIn48H + - workLoad.Global * trialCost.Global + - workLoad.Adjudication * trialCost.Adjudication + - workLoad.AdjudicationIn24H * trialCost.AdjudicationIn24H + - workLoad.AdjudicationIn48H * trialCost.AdjudicationIn48H + - workLoad.RefresherTraining * trialCost.RefresherTraining - ) - }; - - //处理排序字段 - propName = queryParam.SortField == "" ? "TrialCode" : queryParam.SortField; - - } - - //按照人的维度 - if (queryParam.StatType == 2) - { - var workloadQuery = from workLoad in _workloadRepository.Where(workloadLambda) - join doctor in _doctorRepository.Where(doctorLambda) - on workLoad.DoctorId equals doctor.Id - join trial in _trialRepository.Where(trialLambda) on workLoad.TrialId equals trial.Id - join trialCost in _trialRevenuePriceRepository.AsQueryable() on workLoad.TrialId equals trialCost.TrialId into c - from trialCost in c.DefaultIfEmpty() - - select new - { - DoctorId = workLoad.DoctorId, - Downtime = workLoad.Downtime * trialCost.Downtime, - Training = workLoad.Training * trialCost.Training, - Timepoint = workLoad.Timepoint * trialCost.Timepoint, - TimepointIn24H = workLoad.TimepointIn24H * trialCost.TimepointIn24H, - TimepointIn48H = workLoad.TimepointIn48H * trialCost.TimepointIn48H, - Global = workLoad.Global * trialCost.Global, - Adjudication = workLoad.Adjudication * trialCost.Adjudication, - AdjudicationIn24H = - workLoad.AdjudicationIn24H * trialCost.AdjudicationIn24H, - AdjudicationIn48H = workLoad.AdjudicationIn48H * trialCost.AdjudicationIn48H, - RefresherTraining = workLoad.RefresherTraining * trialCost.RefresherTraining, - ReviewerCode = doctor.ReviewerCode, - ChineseName = doctor.ChineseName, - FirstName = doctor.FirstName, - LastName = doctor.LastName, - - }; - - - query = workloadQuery.GroupBy(t => new { t.DoctorId, t.ReviewerCode, t.ChineseName, t.FirstName, t.LastName }).Select(gWorkLoad => new RevenuesDTO - { - ReviewerCode = gWorkLoad.Key.ReviewerCode, - ChineseName = gWorkLoad.Key.ChineseName, - FirstName = gWorkLoad.Key.FirstName, - LastName = gWorkLoad.Key.LastName, - - Downtime = gWorkLoad.Sum(t => t.Downtime), - Training = gWorkLoad.Sum(t => t.Training), - Timepoint = gWorkLoad.Sum(t => t.Timepoint), - TimepointIn24H = gWorkLoad.Sum(t => t.TimepointIn24H), - TimepointIn48H = gWorkLoad.Sum(t => t.TimepointIn48H), - Global = gWorkLoad.Sum(t => t.Global), - Adjudication = gWorkLoad.Sum(t => t.Adjudication), - AdjudicationIn24H = gWorkLoad.Sum(t => t.AdjudicationIn24H), - AdjudicationIn48H = gWorkLoad.Sum(t => t.AdjudicationIn48H), - - Total = gWorkLoad.Sum(t => t.Downtime) + - gWorkLoad.Sum(t => t.Training) + - gWorkLoad.Sum(t => t.Timepoint) + - gWorkLoad.Sum(t => t.TimepointIn24H) + - gWorkLoad.Sum(t => t.TimepointIn48H) + - gWorkLoad.Sum(t => t.Global) + - gWorkLoad.Sum(t => t.Adjudication) + - gWorkLoad.Sum(t => t.AdjudicationIn24H) + - gWorkLoad.Sum(t => t.AdjudicationIn48H) + - gWorkLoad.Sum(t => t.RefresherTraining) - - }); - - propName = queryParam.SortField == string.Empty ? "ReviewerCode" : queryParam.SortField; - - - } - - //按照月份维度 - if (queryParam.StatType == 3) - { - var workloadQuery = from workLoad in _workloadRepository.Where(workloadLambda) - join trial in _trialRepository.Where(trialLambda) - on workLoad.TrialId equals trial.Id - join doctor in _doctorRepository.Where(doctorLambda) - on workLoad.DoctorId equals doctor.Id - join trialCost in _trialRevenuePriceRepository.AsQueryable() on workLoad.TrialId equals trialCost.TrialId into c - from trialCost in c.DefaultIfEmpty() - - select new - { - workLoad.YearMonth, - Downtime = workLoad.Downtime * trialCost.Downtime, - Training = workLoad.Training * trialCost.Training, - Timepoint = workLoad.Timepoint * trialCost.Timepoint, - TimepointIn24H = workLoad.TimepointIn24H * trialCost.TimepointIn24H, - TimepointIn48H = workLoad.TimepointIn48H * trialCost.TimepointIn48H, - Global = workLoad.Global * trialCost.Global, - Adjudication = workLoad.Adjudication * trialCost.Adjudication, - AdjudicationIn24H = - workLoad.AdjudicationIn24H * trialCost.AdjudicationIn24H, - AdjudicationIn48H = workLoad.AdjudicationIn48H * trialCost.AdjudicationIn48H, - RefresherTraining = workLoad.RefresherTraining * trialCost.RefresherTraining, - - }; - - query = workloadQuery.GroupBy(t => t.YearMonth).Select(gWorkLoad => new RevenuesDTO - { - - YearMonth = gWorkLoad.Key, - Downtime = gWorkLoad.Sum(t => t.Downtime), - Training = gWorkLoad.Sum(t => t.Training), - Timepoint = gWorkLoad.Sum(t => t.Timepoint), - TimepointIn24H = gWorkLoad.Sum(t => t.TimepointIn24H), - TimepointIn48H = gWorkLoad.Sum(t => t.TimepointIn48H), - Global = gWorkLoad.Sum(t => t.Global), - Adjudication = gWorkLoad.Sum(t => t.Adjudication), - AdjudicationIn24H = gWorkLoad.Sum(t => t.AdjudicationIn24H), - AdjudicationIn48H = gWorkLoad.Sum(t => t.AdjudicationIn48H), - Total = gWorkLoad.Sum(t => t.Downtime) + - gWorkLoad.Sum(t => t.Training) + - gWorkLoad.Sum(t => t.Timepoint) + - gWorkLoad.Sum(t => t.TimepointIn24H) + - gWorkLoad.Sum(t => t.TimepointIn48H) + - gWorkLoad.Sum(t => t.Global) + - gWorkLoad.Sum(t => t.Adjudication) + - gWorkLoad.Sum(t => t.AdjudicationIn24H) + - gWorkLoad.Sum(t => t.AdjudicationIn48H) + - gWorkLoad.Sum(t => t.RefresherTraining) - - }); - propName = queryParam.SortField == string.Empty ? "YearMonth" : queryParam.SortField; - } - - - #endregion - //if (propName == "FirstName" || propName == "LastName") - //{ - // query = param.Asc - // ? query.OrderBy(t => t.LastName).ThenBy(t => t.FirstName) - // : query.OrderByDescending(t => t.LastName).ThenBy(t => t.FirstName); - //} - - //非详细 只用单字段排序 - if (queryParam.StatType != 0) - { - query = queryParam.Asc ? query.OrderBy(propName) : query.OrderBy(propName + " desc"); - } - //详情 多字段排序 - if (queryParam.StatType == 0) - { - query = queryParam.Asc ? query.OrderBy(propName).ThenBy(t => t.TrialId).ThenBy(t => t.YearMonth).ThenBy(t => t.ReviewerCode) : - query.OrderBy(propName + " desc").ThenBy(t => t.TrialId).ThenBy(t => t.YearMonth).ThenBy(t => t.ReviewerCode) - ; - } - - - count = query!.Count(); - query = query!.Skip((queryParam.PageIndex - 1) * queryParam.PageSize).Take(queryParam.PageSize); - - incomeList = await query.ToListAsync(); - - #region 处理缺失项目价格 按照医生 或者月份维度 - - if (queryParam.StatType == 2 || queryParam.StatType == 3) - { - var hasIncomePriceTrialIds = await _trialRevenuePriceRepository.Select(t => t.TrialId).ToListAsync(); - - workloadLambda = workloadLambda.And(t => !hasIncomePriceTrialIds.Contains(t.TrialId)); - var doctorMissingTrialCodesQuery = (from workLoad in _workloadRepository.Where(workloadLambda) - join trial in _trialRepository.AsQueryable() on workLoad.TrialId equals trial.Id - select new - { - DoctorId = workLoad.DoctorId, - Month = workLoad.YearMonth, - TrialCode = trial.TrialCode - }).Distinct(); - - var doctorMissingTrialCodes = ((await doctorMissingTrialCodesQuery.ToListAsync()).GroupBy(t => t.DoctorId).Select(g => new - { - DoctorId = g.Key, - TrialCodes = g.Select(u => u.TrialCode).Distinct().ToList() - })).ToList(); - - var monthMissingTrialCode = ((await doctorMissingTrialCodesQuery.ToListAsync()).GroupBy(t => t.Month).Select(g => new - { - Month = g.Key, - TrialCodes = g.Select(u => u.TrialCode).Distinct().ToList() - })).ToList(); - - incomeList.ForEach(income => - { - var doctor = doctorMissingTrialCodes.FirstOrDefault(t => t.DoctorId == income.Id); - var month = monthMissingTrialCode.FirstOrDefault(t => t.Month == income.YearMonth); - - if (queryParam.StatType == 2) - { - income.MissingTrialCodes = doctor == null ? new List() : doctor.TrialCodes; - } - else - { - income.MissingTrialCodes = month == null ? new List() : month.TrialCodes; - } - }); - } - - if (queryParam.StatType == 0 || queryParam.StatType == 1) - { - incomeList.ForEach(income => - { - List temp = new List(); - - - - if (Math.Abs(income.Total) < 0.001m) - { - temp.Add(income.TrialCode); - income.MissingTrialCodes = temp; - } - - }); - } - #endregion - - return new PageOutput(queryParam.PageIndex, queryParam.PageSize, count, incomeList); - - } - - /// - /// 收入支出分析接口,按照项目维度分析统计 - /// - [HttpPost] - public async Task> GetTrialAnalysisList(TrialAnalysisQueryDTO param) - { - var bDate = new DateTime(param.BeginDate.Year, param.BeginDate.Month, 1); - var eDate = new DateTime(param.EndDate.Year, param.EndDate.Month, 1); - - Expression> workloadLambda = x => x.DataFrom == (int)WorkLoadFromStatus.FinalConfirm; - - Expression> trialLambda = x => true; - if (Guid.Empty != param.CroId && param.CroId != null) - { - trialLambda = trialLambda.And(u => u.CROId == param.CroId); - } - - if (!string.IsNullOrWhiteSpace(param.TrialCode)) - { - var trialCode = param.TrialCode.Trim(); - trialLambda = trialLambda.And(u => u.TrialCode.Contains(trialCode)); - } - - //if (param.AttendedReviewerType != null) - //{ - // trialLambda = trialLambda.And(u => u.AttendedReviewerType == param.AttendedReviewerType); - //} - - var lockedPaymentIdAndYearMonth = _paymentRepository.Where(t => t.IsLock && t.YearMonthDate >= bDate && t.YearMonthDate <= eDate).Select(t => new { PaymentId = t.Id, t.YearMonth, t.DoctorId }); - - var costStatisticsIds = await lockedPaymentIdAndYearMonth.Select(t => t.PaymentId).ToListAsync(); - - var lockedDoctorIdAndYearMonthQueryable = lockedPaymentIdAndYearMonth.Select(t => new { t.YearMonth, t.DoctorId }); - - - ////工作量过滤查询 锁定得月份 - //workloadLambda = workloadLambda.And(x => lockedDoctorIdAndYearMonthQueryable.Contains()); - - var trialPayQuery = from costStatisticsDetail in _paymentDetailRepository.AsQueryable() - .Where(t => costStatisticsIds.Contains(t.PaymentId) && t.TrialCode != "Volume Reward") - group costStatisticsDetail by costStatisticsDetail.TrialId - into g - select new - { - TrialId = g.Key, - PaymentUSD = g.Sum(t => t.PaymentUSD) - }; - - - var workloadQuery = from workLoad in _workloadRepository.Where(workloadLambda) - join lockedDoctorAndMonth in lockedDoctorIdAndYearMonthQueryable on new { workLoad.DoctorId, YearMonth = workLoad.YearMonth } equals new { lockedDoctorAndMonth.DoctorId, lockedDoctorAndMonth.YearMonth } - group workLoad by workLoad.TrialId - - into gWorkLoad - select new - { - TrialId = gWorkLoad.Key, - Downtime = gWorkLoad.Sum(t => t.Downtime), - Training = gWorkLoad.Sum(t => t.Training), - Timepoint = gWorkLoad.Sum(t => t.Timepoint), - TimepointIn24H = gWorkLoad.Sum(t => t.TimepointIn24H), - TimepointIn48H = gWorkLoad.Sum(t => t.TimepointIn48H), - Global = gWorkLoad.Sum(t => t.Global), - Adjudication = gWorkLoad.Sum(t => t.Adjudication), - AdjudicationIn24H = gWorkLoad.Sum(t => t.AdjudicationIn24H), - AdjudicationIn48H = gWorkLoad.Sum(t => t.AdjudicationIn48H) - - }; - - var workloadIncomeQuery = from workLoad in workloadQuery - join trialCost in _trialRevenuePriceRepository.AsQueryable() on workLoad.TrialId equals trialCost.TrialId - into c - from trialCost in c.DefaultIfEmpty() - join trial in _trialRepository.Where(trialLambda) on workLoad.TrialId equals trial.Id into t - from trial in t.DefaultIfEmpty() - join cro in _croRepository.AsQueryable() on trial.CROId equals cro.Id into ttt - from croItem in ttt.DefaultIfEmpty() - select new TrialAnalysisDTO - { - TrialId = trial.Id, - Indication = trial.Indication, - TrialCode = trial.TrialCode, - Expedited = trial.Expedited, - Cro = croItem == null ? "" : croItem.CROName, - - Type = "Trial", - - RevenusUSD = (workLoad.Downtime * trialCost.Downtime) + - (workLoad.Training * trialCost.Training) + - (workLoad.Timepoint * trialCost.Timepoint) - + (workLoad.TimepointIn24H * trialCost.TimepointIn24H) - + (workLoad.TimepointIn48H * trialCost.TimepointIn48H) - + (workLoad.Adjudication * trialCost.Adjudication) - + (workLoad.AdjudicationIn24H * trialCost.AdjudicationIn24H) - + (workLoad.AdjudicationIn48H * trialCost.AdjudicationIn48H) - + (workLoad.Global * trialCost.Global), - - }; - - - var trialPayList = await trialPayQuery.OrderBy(t => t.PaymentUSD).ToListAsync(); - var workloadIncomeList = await workloadIncomeQuery.ToListAsync(); - var returnList = workloadIncomeList; - returnList.ForEach(t => - { - var pay = trialPayList.FirstOrDefault(u => u.TrialId == t.TrialId); - t.PaymentUSD = pay == null ? 0 : pay.PaymentUSD; - }); - - if ((Guid.Empty == param.CroId || null == param.CroId) && string.IsNullOrWhiteSpace(param.TrialCode)) - { - var volumeReward = _paymentDetailRepository.AsQueryable() - .Where(t => costStatisticsIds.Contains(t.PaymentId) && t.TrialCode == "Volume Reward") - .Sum(t => (decimal?)t.PaymentUSD) ?? 0; - - var adjustment = _payAdjustmentRepository.AsQueryable() - .Where(t => t.YearMonthDate >= param.BeginDate - && t.YearMonthDate <= param.EndDate && t.IsLock) - .Sum(u => (decimal?)u.AdjustmentUSD) ?? 0; - - returnList.Add(new TrialAnalysisDTO() - { - Type = "Volume Reward", - RevenusUSD = 0, - PaymentUSD = volumeReward - }); - returnList.Add(new TrialAnalysisDTO() - { - Type = "Adjustment", - RevenusUSD = 0, - PaymentUSD = adjustment - }); - } - return returnList; - } - - /// - /// 收入支出分析接口,按照医生维度分析统计 - /// - [HttpPost] - public async Task> GetReviewerAnalysisList(AnalysisQueryDTO param) - { - var beginDate = new DateTime(param.BeginDate.Year, param.BeginDate.Month, 1); - var endDate = new DateTime(param.EndDate.Year, param.EndDate.Month, 1); - - Expression> workloadLambda = x => x.DataFrom == (int)WorkLoadFromStatus.FinalConfirm; - - Expression> doctorLambda = x => true; - if (!string.IsNullOrWhiteSpace(param.Reviewer)) - { - var reviewer = param.Reviewer.Trim(); - doctorLambda = doctorLambda.And(u => u.ChineseName.Contains(reviewer) - || u.FirstName.Contains(reviewer) - || u.LastName.Contains(reviewer) - || u.ReviewerCode.Contains(reviewer)); - } - if (param.Nation != null) - { - doctorLambda = doctorLambda.And(u => u.Nation == param.Nation); - } - - var lockedPaymentIdAndYearMonth = _paymentRepository.Where(t => t.IsLock && t.YearMonthDate >= param.BeginDate && t.YearMonthDate <= param.EndDate).Select(t => new { PaymentId = t.Id, t.YearMonth, t.DoctorId }); - - var lockedDoctorIdAndYearMonthQueryable = lockedPaymentIdAndYearMonth.Select(t => new { t.YearMonth, t.DoctorId }); - - - - Expression> monthlyPayLambda = x => x.IsLock && x.YearMonthDate >= beginDate && x.YearMonthDate <= endDate; - var payQuery = - from monthlyPayment in _paymentRepository.Where(monthlyPayLambda) - .GroupBy(t => t.DoctorId).Select(g => new - { - ReviewerId = g.Key, - PaymentUSD = g.Sum(u => u.PaymentUSD), - PaymentCNY = g.Sum(u => u.PaymentCNY), - AdjustmentCNY = g.Sum(u => u.AdjustmentCNY), - AdjustmentUSD = g.Sum(u => u.AdjustmentUSD) - }) - join doctor in _doctorRepository.Where(doctorLambda) on monthlyPayment.ReviewerId equals doctor.Id - select new MonthlyPaymentDTO - { - ReviewerId = doctor.Id, - ChineseName = doctor.ChineseName, - FirstName = doctor.FirstName, - LastName = doctor.LastName, - ReviewerCode = doctor.ReviewerCode, - PaymentUSD = monthlyPayment.PaymentUSD, - PaymentCNY = monthlyPayment.PaymentCNY, - AdjustmentCNY = monthlyPayment.AdjustmentCNY, - AdjustmentUSD = monthlyPayment.AdjustmentUSD, - TotalUSD = monthlyPayment.AdjustmentUSD + monthlyPayment.PaymentUSD, - TotalCNY = monthlyPayment.AdjustmentCNY + monthlyPayment.PaymentCNY, - }; - - //获取工作量收入 workloadLambda 已经加入过滤 payment锁定月份 - - ////工作量过滤查询 锁定得月份 - - var workloadIncomeQuery = from workLoad in _workloadRepository.Where(workloadLambda) - join doctor in _doctorRepository.Where(doctorLambda) - on workLoad.DoctorId equals doctor.Id - join lockedDoctorAndMonth in lockedDoctorIdAndYearMonthQueryable on new { workLoad.DoctorId, workLoad.YearMonth } equals new { lockedDoctorAndMonth.DoctorId, lockedDoctorAndMonth.YearMonth } - join trialCost in _trialRevenuePriceRepository.AsQueryable() on workLoad.TrialId equals trialCost.TrialId into c - from trialCost in c.DefaultIfEmpty() - - select new - { - DoctorId = workLoad.DoctorId, - Downtime = workLoad.Downtime * trialCost.Downtime, - Training = workLoad.Training * trialCost.Training, - Timepoint = workLoad.Timepoint * trialCost.Timepoint, - TimepointIn24H = workLoad.TimepointIn24H * trialCost.TimepointIn24H, - TimepointIn48H = workLoad.TimepointIn48H * trialCost.TimepointIn48H, - Global = workLoad.Global * trialCost.Global, - Adjudication = workLoad.Adjudication * trialCost.Adjudication, - AdjudicationIn24H = workLoad.AdjudicationIn24H * trialCost.AdjudicationIn24H, - AdjudicationIn48H = workLoad.AdjudicationIn48H * trialCost.AdjudicationIn48H - - - }; - - //工作量收入按照人分组统计 - var workloadIncomeList = await workloadIncomeQuery.GroupBy(t => t.DoctorId).Select(gWorkLoad => new - { - - DoctorId = gWorkLoad.Key, - //TrialId = Guid.Empty, - Downtime = gWorkLoad.Sum(t => t.Downtime), - Training = gWorkLoad.Sum(t => t.Training), - Timepoint = gWorkLoad.Sum(t => t.Timepoint), - TimepointIn24H = gWorkLoad.Sum(t => t.TimepointIn24H), - TimepointIn48H = gWorkLoad.Sum(t => t.TimepointIn48H), - Global = gWorkLoad.Sum(t => t.Global), - Adjudication = gWorkLoad.Sum(t => t.Adjudication), - AdjudicationIn24H = gWorkLoad.Sum(t => t.AdjudicationIn24H), - AdjudicationIn48H = gWorkLoad.Sum(t => t.AdjudicationIn48H), - }).ToListAsync(); - var workloadPayList = payQuery.ToList(); - //var workloadIncomeList = workloadIncomeQuery.ToList(); - - var returnList = new List(); - - #region 处理找到缺失的项目 - - //有项目价格的trial Id 集合 - var hasIncomePriceTrialIds = await _trialRevenuePriceRepository.Select(t => t.TrialId).ToListAsync(); - - workloadLambda = workloadLambda.And(t => !hasIncomePriceTrialIds.Contains(t.TrialId)); - var doctorMissingTrialCodesQuery = (from workLoad in _workloadRepository.Where(workloadLambda) - join trial in _trialRepository.AsQueryable() on workLoad.TrialId equals trial.Id - select new - { - DoctorId = workLoad.DoctorId, - TrialCode = trial.TrialCode - }).Distinct(); - - var doctorMissingTrialCodes = ((await doctorMissingTrialCodesQuery.ToListAsync()).GroupBy(t => t.DoctorId).Select(g => new - { - DoctorId = g.Key, - TrialCodes = g.Select(u => u.TrialCode).ToList() - })).ToList(); - - - #endregion - - workloadPayList.ForEach(pay => - { - var doctor = workloadIncomeList.FirstOrDefault(t => t.DoctorId == pay.ReviewerId); - - var doctorMissingCode = doctorMissingTrialCodes.FirstOrDefault(t => t.DoctorId == pay.ReviewerId); - - returnList.Add(new ReviewerAnalysisDTO() - { - ReviewerId = pay.ReviewerId, - ChineseName = pay.ChineseName, - FirstName = pay.FirstName, - LastName = pay.LastName, - ReviewerCode = pay.ReviewerCode, - PaymentUSD = pay.PaymentUSD + pay.AdjustmentUSD, - - //付费表的医生数量肯定事全的 工作量的不一定全 (只有调整) - RevenusUSD = doctor != null - ? doctor.Adjudication + doctor.AdjudicationIn24H + doctor.AdjudicationIn48H + doctor.Global + - doctor.Downtime + doctor.Training + - doctor.Timepoint + doctor.TimepointIn24H + doctor.TimepointIn48H - : 0, - MissingTrialCodes = doctorMissingCode != null ? doctorMissingCode.TrialCodes : new List() - }); - }); - return returnList.OrderBy(t => t.ReviewerCode).ToList(); - } - - /// - /// 获取劳务费用列表 - /// - [HttpPost] - public async Task> GetLaborPaymentList(List paymentIds) - { - var query = from payment in _paymentRepository.Where(t => paymentIds.Contains(t.Id)) - join reviewer in _doctorRepository.AsQueryable() on payment.DoctorId equals reviewer.Id - join payInfo in _doctorPayInfoRepository.AsQueryable() on payment.DoctorId equals payInfo.DoctorId - select new LaborPayment() - { - - ChineseName = reviewer.ChineseName, - FirstName = reviewer.FirstName, - LastName = reviewer.LastName, - ResidentId = payInfo.IDCard, - PaymentCNY = payment.PaymentCNY + payment.AdjustmentCNY, - YearMonth = payment.YearMonth, - Phone = reviewer.Phone, - AccountNumber = payInfo.BankCardNumber, - Bank = payInfo.BankName - - //TaxCNY = payment.TaxCNY, - //ActuallyPaidCNY = payment.ActuallyPaidCNY, - //BankTransferCNY = payment.BankTransferCNY, - }; - var result = await query.ToListAsync(); - - result.ForEach(t => - { - t.TaxCNY =GetTax2(t.PaymentCNY); - - t.ActuallyPaidCNY = t.PaymentCNY - t.TaxCNY; - t.BankTransferCNY = t.PaymentCNY - t.TaxCNY; - }); - - return result; - - } - - /// - /// 锁定医生费用,锁定后,无法变更该医生对应月份的费用和工作量[New] - /// - [HttpPost] - public async Task LockMonthlyPayment(LockPaymentDTO param) - { - var reviewerIds = param.ReviewerIdList; - var yearMonth = param.Month.ToString("yyyy-MM"); - var isLock = param.IsLock; - - - var paymentLockSuccess = await _paymentRepository.BatchUpdateNoTrackingAsync(u => reviewerIds.Contains(u.DoctorId) && u.YearMonth == yearMonth, t => new Payment - { - IsLock = isLock - }); - - var adjustmentLockSuccess = await _payAdjustmentRepository.BatchUpdateNoTrackingAsync( - t => t.YearMonth == yearMonth && reviewerIds.Contains(t.ReviewerId), u => - new PaymentAdjustment() - { - IsLock = true - }); - await _doctorWorkloadRepository.BatchUpdateNoTrackingAsync(u => reviewerIds.Contains(u.DoctorId) && u.YearMonth == yearMonth, - t => new Workload { IsLock = true }); - - return ResponseOutput.Result(paymentLockSuccess || adjustmentLockSuccess); - } - - [NonDynamicMethod] - private static decimal GetTax2(decimal paymentCNY) - { - if (paymentCNY >= 0 && paymentCNY <= 800) - { - return 0; - } - - var calculateTaxPart = paymentCNY <= 4000 ? paymentCNY - 800 : paymentCNY * (1 - 0.2m); - - - if (calculateTaxPart <= 20000) - { - return calculateTaxPart * 0.2m; - } - - else if (calculateTaxPart > 20000 && calculateTaxPart <= 50000) - { - return calculateTaxPart * 0.3m - 2000; - } - - else - { - return calculateTaxPart * 0.4m - 7000; - } - - - } - } -} \ No newline at end of file diff --git a/IRaCIS.Core.Application/Service/Financial/Interface/ICalculateService.cs b/IRaCIS.Core.Application/Service/Financial/Interface/ICalculateService.cs deleted file mode 100644 index 0e4ab8eea..000000000 --- a/IRaCIS.Core.Application/Service/Financial/Interface/ICalculateService.cs +++ /dev/null @@ -1,16 +0,0 @@ -using IRaCIS.Application.Contracts; -using System; -using System.Collections.Generic; -using IRaCIS.Core.Infrastructure.Extention; - -namespace IRaCIS.Application.Interfaces -{ - public interface ICalculateService - { - Task CalculateMonthlyPayment(CalculateDoctorAndMonthDTO param, string token); - //IResponseOutput LockMonthlyPayment(LockPaymentDTO param); - Task> GetNeedCalculateReviewerList(Guid reviewerId, string yearMonth); - Task IsLock(Guid reviewerId, string yearMonth); - //bool ResetMonthlyPayment(Guid reviewerId, Guid trialId,string yearMonth); - } -} diff --git a/IRaCIS.Core.Application/Service/Financial/Interface/IDoctorPayInfoService.cs b/IRaCIS.Core.Application/Service/Financial/Interface/IDoctorPayInfoService.cs deleted file mode 100644 index 87aae6d3d..000000000 --- a/IRaCIS.Core.Application/Service/Financial/Interface/IDoctorPayInfoService.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; - -using IRaCIS.Application.Contracts; -using IRaCIS.Core.Infrastructure.Extention; - -namespace IRaCIS.Application.Interfaces -{ - public interface IReviewerPayInfoService - { - Task AddOrUpdateReviewerPayInfo(ReviewerPayInfoCommand addOrUpdateModel, Guid userId); - Task> GetReviewerPayInfoList(DoctorPaymentInfoQueryDTO queryParam); - Task GetReviewerPayInfo(Guid doctorId); - Task> GetReviewerIdByRankId(Guid rankId); - } -} diff --git a/IRaCIS.Core.Application/Service/Financial/Interface/IExchangeRateService.cs b/IRaCIS.Core.Application/Service/Financial/Interface/IExchangeRateService.cs deleted file mode 100644 index de5b56b9d..000000000 --- a/IRaCIS.Core.Application/Service/Financial/Interface/IExchangeRateService.cs +++ /dev/null @@ -1,15 +0,0 @@ -using IRaCIS.Application.Contracts; -using System; -using IRaCIS.Core.Infrastructure.Extention; - -namespace IRaCIS.Application.Interfaces -{ - public interface IExchangeRateService - { - Task AddOrUpdateExchangeRate(ExchangeRateCommand model); - Task GetExchangeRateByMonth(string month); - Task> GetExchangeRateList(ExchangeRateQueryDTO queryParam); - - Task DeleteExchangeRate(Guid id); - } -} diff --git a/IRaCIS.Core.Application/Service/Financial/Interface/IPaymentAdjustmentService.cs b/IRaCIS.Core.Application/Service/Financial/Interface/IPaymentAdjustmentService.cs deleted file mode 100644 index 4cf964082..000000000 --- a/IRaCIS.Core.Application/Service/Financial/Interface/IPaymentAdjustmentService.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; -using IRaCIS.Application.Contracts.Pay; -using IRaCIS.Core.Infrastructure.Extention; - -namespace IRaCIS.Application.Interfaces -{ - public interface IPaymentAdjustmentService - { - Task> GetPaymentAdjustmentList(PaymentAdjustmentQueryDTO queryParam); - Task AddOrUpdatePaymentAdjustment(PaymentAdjustmentCommand addOrUpdateModel); - Task DeletePaymentAdjustment(Guid id); - Task CalculateCNY(string yearMonth, decimal rate); - Task> GetReviewerSelectList(); - } -} \ No newline at end of file diff --git a/IRaCIS.Core.Application/Service/Financial/Interface/IPaymentService.cs b/IRaCIS.Core.Application/Service/Financial/Interface/IPaymentService.cs deleted file mode 100644 index 8ddbf2b4d..000000000 --- a/IRaCIS.Core.Application/Service/Financial/Interface/IPaymentService.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System; -using System.Collections.Generic; -using IRaCIS.Application.Contracts; -using IRaCIS.Application.Contracts.Pay; -using IRaCIS.Core.Infrastructure.Extention; - -namespace IRaCIS.Application.Interfaces -{ - public interface IPaymentService - { - Task LockMonthlyPayment(LockPaymentDTO param); - - Task> GetMonthlyPaymentList(MonthlyPaymentQueryDTO queryParam); - Task GetMonthlyPaymentDetailList(Guid PaymentId, Guid doctorId, DateTime yearMonth); - - Task> GetLaborPaymentList(List paymentId); - - //导出多个医生的付费详细 - Task> GetReviewersMonthlyPaymentDetail(List manyReviewers); - - Task> GetPaymentHistoryList(PaymentQueryDTO param); - Task> GetPaymentHistoryDetailList(VolumeQueryDTO param); - - Task> GetRevenuesStatistics(StatisticsQueryDTO param); - Task> GetTrialAnalysisList(TrialAnalysisQueryDTO param); - Task> GetReviewerAnalysisList(AnalysisQueryDTO param); - - - - - } -} \ No newline at end of file diff --git a/IRaCIS.Core.Application/Service/Financial/Interface/IRankPriceService.cs b/IRaCIS.Core.Application/Service/Financial/Interface/IRankPriceService.cs deleted file mode 100644 index 93ddbdbc5..000000000 --- a/IRaCIS.Core.Application/Service/Financial/Interface/IRankPriceService.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.Collections.Generic; -using IRaCIS.Application.Contracts; -using IRaCIS.Core.Infrastructure.Extention; - -namespace IRaCIS.Application.Interfaces -{ - public interface IRankPriceService - { - Task AddOrUpdateRankPrice(RankPriceCommand addOrUpdateModel, Guid userId); - - Task> GetRankPriceList(RankPriceQueryDTO queryParam); - - Task DeleteRankPrice( Guid id); - - Task> GetRankDic(); - } -} \ No newline at end of file diff --git a/IRaCIS.Core.Application/Service/Financial/Interface/ITrialPaymentPriceService.cs b/IRaCIS.Core.Application/Service/Financial/Interface/ITrialPaymentPriceService.cs deleted file mode 100644 index 6ce2a42c0..000000000 --- a/IRaCIS.Core.Application/Service/Financial/Interface/ITrialPaymentPriceService.cs +++ /dev/null @@ -1,21 +0,0 @@ -using IRaCIS.Application.Contracts; -using IRaCIS.Core.Infrastructure.Extention; - -namespace IRaCIS.Application.Interfaces -{ - public interface ITrialPaymentPriceService - { - Task AddOrUpdateTrialPaymentPrice(TrialPaymentPriceCommand addOrUpdateModel);//新增也不需要返回Id,TrialId 也是唯一 - Task> GetTrialPaymentPriceList(TrialPaymentPriceQueryDTO queryParam); - - - /// - /// 上传入组后的Ack-SOW - /// - Task UploadTrialSOW( TrialSOWPathDTO trialSowPath); - - - - Task DeleteTrialSOW( DeleteSowPathDTO trialSowPath); - } -} diff --git a/IRaCIS.Core.Application/Service/Financial/Interface/ITrialRevenuesPriceService.cs b/IRaCIS.Core.Application/Service/Financial/Interface/ITrialRevenuesPriceService.cs deleted file mode 100644 index f4d0c44f0..000000000 --- a/IRaCIS.Core.Application/Service/Financial/Interface/ITrialRevenuesPriceService.cs +++ /dev/null @@ -1,14 +0,0 @@ -using IRaCIS.Application.Contracts; -using System; -using IRaCIS.Core.Infrastructure.Extention; - -namespace IRaCIS.Application.Interfaces -{ - public interface ITrialRevenuesPriceService - { - Task AddOrUpdateTrialRevenuesPrice(TrialRevenuesPriceDTO model); - Task DeleteTrialCost(Guid Id); - Task> GetTrialRevenuesPriceList(TrialRevenuesPriceQueryDTO param); - - } -} diff --git a/IRaCIS.Core.Application/Service/Financial/Interface/ITrialRevenuesPriceVerificationService.cs b/IRaCIS.Core.Application/Service/Financial/Interface/ITrialRevenuesPriceVerificationService.cs deleted file mode 100644 index 19355c7fe..000000000 --- a/IRaCIS.Core.Application/Service/Financial/Interface/ITrialRevenuesPriceVerificationService.cs +++ /dev/null @@ -1,17 +0,0 @@ - -using IRaCIS.Core.Application.Contracts; -using System.Collections.Generic; - - - -namespace IRaCIS.Application.Interfaces -{ - public interface ITrialRevenuesPriceVerificationService - { - //List GetRevenuesVerifyResultList(RevenusVerifyQueryDTO param); - - Task GetAnalysisVerifyList(RevenusVerifyQueryDTO param); - - Task> GetRevenuesVerifyList(RevenusVerifyQueryDTO param); - } -} \ No newline at end of file diff --git a/IRaCIS.Core.Application/Service/Financial/Interface/IVolumeRewardService.cs b/IRaCIS.Core.Application/Service/Financial/Interface/IVolumeRewardService.cs deleted file mode 100644 index fa25acd57..000000000 --- a/IRaCIS.Core.Application/Service/Financial/Interface/IVolumeRewardService.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System.Collections.Generic; -using IRaCIS.Core.Infrastructure.Extention; - -namespace IRaCIS.Application.Interfaces -{ - public interface IVolumeRewardService - { - Task AddOrUpdateVolumeRewardPriceList(IEnumerable addOrUpdateModels); - Task> GetVolumeRewardPriceList(AwardPriceQueryDTO queryParam); - Task> GetVolumeRewardPriceList(); - } -} \ No newline at end of file diff --git a/IRaCIS.Core.Application/Service/Financial/PaymentAdjustmentService.cs b/IRaCIS.Core.Application/Service/Financial/PaymentAdjustmentService.cs deleted file mode 100644 index 754ec091a..000000000 --- a/IRaCIS.Core.Application/Service/Financial/PaymentAdjustmentService.cs +++ /dev/null @@ -1,314 +0,0 @@ -using AutoMapper; -using IRaCIS.Application.Interfaces; -using IRaCIS.Application.Contracts.Pay; -using IRaCIS.Core.Domain.Share; -using Microsoft.AspNetCore.Mvc; -using Panda.DynamicWebApi.Attributes; - -namespace IRaCIS.Application.Services -{ - [ApiExplorerSettings(GroupName = "Financial")] - public class PaymentAdjustmentService : BaseService, IPaymentAdjustmentService - { - private readonly IRepository _payAdjustmentRepository; - private readonly IRepository _doctorRepository; - private readonly IRepository _exchangeRateRepository; - private readonly IRepository _paymentRepository; - - - public PaymentAdjustmentService(IRepository costAdjustmentRepository, IRepository doctorRepository, - IRepository exchangeRateRepository, IRepository paymentRepository, IMapper mapper) - { - _payAdjustmentRepository = costAdjustmentRepository; - _doctorRepository = doctorRepository; - _exchangeRateRepository = exchangeRateRepository; - _paymentRepository = paymentRepository; - - } - - /// - /// 添加或更新费用调整[AUTH] - /// - - [HttpPost] - public async Task AddOrUpdatePaymentAdjustment(PaymentAdjustmentCommand addOrUpdateModel) - { - - var yearMonthDate = new DateTime(addOrUpdateModel.YearMonth.Year, addOrUpdateModel.YearMonth.Month, 1); - var yearMonth = addOrUpdateModel.YearMonth.ToString("yyyy-MM"); - - var payment = await _paymentRepository.FirstOrDefaultAsync(u => u.DoctorId == addOrUpdateModel.ReviewerId - && u.YearMonth == yearMonth); - - //判断付费表中是否有记录 - if (payment == null) - { - //没有 添加仅有的调整费用记录 - payment = new Payment - { - DoctorId = addOrUpdateModel.ReviewerId, - YearMonth = yearMonth, - YearMonthDate = yearMonthDate, - PaymentCNY = 0, - PaymentUSD = 0, - AdjustmentCNY = 0, - AdjustmentUSD = 0 - }; - await _paymentRepository.AddAsync(payment); - await _paymentRepository.SaveChangesAsync(); - } - else - { - if (payment.IsLock) - { - //---Doctor payment has confirmed lock - return ResponseOutput.NotOk(_localizer["PayAdj_DocPymtLock"]); - } - } - - var exchangeRate = await _exchangeRateRepository.FirstOrDefaultAsync(t => t.YearMonth == yearMonth); - if (addOrUpdateModel.Id == Guid.Empty || addOrUpdateModel.Id == null) - { - var costAdjustment = _mapper.Map(addOrUpdateModel); - - //视图模型和领域模型没对应 重新赋值 - costAdjustment.ExchangeRate = exchangeRate?.Rate ?? 0; - costAdjustment.AdjustmentCNY = addOrUpdateModel.AdjustPaymentUSD * (exchangeRate?.Rate ?? 0); - costAdjustment.AdjustmentUSD = addOrUpdateModel.AdjustPaymentUSD; - - await _payAdjustmentRepository.AddAsync(costAdjustment); - - //添加的时候,每个月调整汇总费用 需要加上本次调整的费用 - payment.AdjustmentCNY += costAdjustment.AdjustmentCNY; - payment.AdjustmentUSD += costAdjustment.AdjustmentUSD; - - //await _paymentRepository.UpdateAsync(payment); - - await _paymentRepository.UpdateAsync(payment, u => new Payment() - { - AdjustmentCNY = payment.AdjustmentCNY + costAdjustment.AdjustmentCNY, - AdjustmentUSD = payment.AdjustmentUSD + costAdjustment.AdjustmentUSD - }); - - await _payAdjustmentRepository.SaveChangesAsync(); - - - return ResponseOutput.Ok(costAdjustment.Id.ToString()); - - } - else - { - - - - // 更新的时候,先查出来,更新前的调整费用数据 - - var paymentAdjust = await _payAdjustmentRepository.FirstOrDefaultAsync(t => t.Id == addOrUpdateModel.Id); - - - _mapper.Map(addOrUpdateModel, paymentAdjust); - - paymentAdjust.ExchangeRate = exchangeRate?.Rate ?? 0; - paymentAdjust.AdjustmentUSD = addOrUpdateModel.AdjustPaymentUSD; - paymentAdjust.AdjustmentCNY = addOrUpdateModel.AdjustPaymentUSD * (exchangeRate?.Rate ?? 0); - - //await _payAdjustmentRepository.UpdateAsync(paymentAdjust); - - var success = await _payAdjustmentRepository.SaveChangesAsync(); - - if (success) - { - - var adjustmentList = await _payAdjustmentRepository.Where(u => u.ReviewerId == addOrUpdateModel.ReviewerId && u.YearMonth == yearMonth).ToListAsync(); - - - await _paymentRepository.UpdateAsync(payment, u => new Payment() - { - AdjustmentCNY = adjustmentList.Sum(t => t.AdjustmentCNY), - AdjustmentUSD = adjustmentList.Sum(t => t.AdjustmentUSD) - }); - - //payment.AdjustmentCNY = adjustmentList.Sum(t => t.AdjustmentCNY); - //payment.AdjustmentUSD = adjustmentList.Sum(t => t.AdjustmentUSD); - - //await _paymentRepository.UpdateAsync(payment); - - await _paymentRepository.SaveChangesAsync(); - } - - //查询得到历史汇总 - - - - return ResponseOutput.Ok(success); - - #region 逻辑存在错误 问题待查 - - //// 更新的时候,先查出来,更新前的调整费用数据 - //var paymentAdjust = _payAdjustmentRepository.FindSingleOrDefault(t => t.Id == addOrUpdateModel.Id); - - ////减去数据库本条记录的值 - //payment.AdjustmentCNY = -paymentAdjust.AdjustmentCNY; - //payment.AdjustmentUSD = -paymentAdjust.AdjustmentUSD; - - //_mapper.Map(addOrUpdateModel, paymentAdjust); - - //paymentAdjust.ExchangeRate = exchangeRate?.Rate ?? 0; - //paymentAdjust.AdjustmentUSD = addOrUpdateModel.AdjustPaymentUSD; - //paymentAdjust.AdjustmentCNY = addOrUpdateModel.AdjustPaymentUSD * (exchangeRate?.Rate ?? 0); - - //_payAdjustmentRepository.Update(paymentAdjust); - - ////查询得到历史汇总 - //var adjustment = _payAdjustmentRepository.Find(u => u.ReviewerId == addOrUpdateModel.ReviewerId && u.YearMonth == yearMonth) - // .GroupBy(u => new { u.ReviewerId, u.YearMonth }).Select(g => new - // { - // AdjustCNY = g.Sum(t => t.AdjustmentCNY), - // AdjustUSD = g.Sum(t => t.AdjustmentUSD) - // }).FirstOrDefault(); - - ////最终的值 等于历史汇总 减去更新前的加上当前更新的值 - //payment.AdjustmentCNY += (adjustment.AdjustCNY + paymentAdjust.AdjustmentCNY); - //payment.AdjustmentUSD += (adjustment.AdjustUSD + paymentAdjust.AdjustmentUSD); - - //_paymentRepository.Update(payment); - - //var success = _payAdjustmentRepository.SaveChanges(); - //return ResponseOutput.Result(success, success ? string.Empty : StaticData.UpdateFailed); - - #endregion - - - - } - } - /// - /// 删除费用调整记录 - /// - - [HttpDelete("{id:guid}")] - public async Task DeletePaymentAdjustment(Guid id) - { - var adjustPayment = await _payAdjustmentRepository.FirstOrDefaultAsync(u => u.Id == id); - - - await _payAdjustmentRepository.DeleteAsync(new PaymentAdjustment() { Id = id }); - - var success = await _payAdjustmentRepository.SaveChangesAsync(); - - if (success) - { - - var adjustmentList = await _payAdjustmentRepository.Where(u => - u.ReviewerId == adjustPayment.ReviewerId && u.YearMonth == adjustPayment.YearMonth).ToListAsync(); - - - var monthPay = await _paymentRepository.FirstOrDefaultAsync(t => - t.DoctorId == adjustPayment.ReviewerId && t.YearMonth == adjustPayment.YearMonth); - - - - await _paymentRepository.UpdateAsync(monthPay, u => new Payment() - { - AdjustmentCNY = adjustmentList.Sum(t => t.AdjustmentCNY), - AdjustmentUSD = adjustmentList.Sum(t => t.AdjustmentUSD) - }); - - - //monthPay.AdjustmentCNY = adjustmentList.Sum(t => t.AdjustmentCNY); - //monthPay.AdjustmentUSD = adjustmentList.Sum(t => t.AdjustmentUSD); - //await _paymentRepository.UpdateAsync(monthPay); - - await _paymentRepository.SaveChangesAsync(); - } - - - - return ResponseOutput.Result(success); - } - - /// - /// 获取费用调整列表 - /// - [HttpPost] - public async Task> GetPaymentAdjustmentList(PaymentAdjustmentQueryDTO queryParam) - { - - var beginYearMonth = queryParam.BeginMonth.AddDays(1 - queryParam.BeginMonth.Day); - var endYearMonth = queryParam.EndMonth.AddDays(1 - queryParam.EndMonth.Day).AddMonths(1).AddDays(-1); - - var costAdjustmentQueryable = from costAdjustment in _payAdjustmentRepository - .Where(t => t.YearMonthDate >= beginYearMonth && t.YearMonthDate <= endYearMonth) - join doctor in _doctorRepository.AsQueryable(). - WhereIf(!string.IsNullOrWhiteSpace(queryParam.Reviewer), - u => u.ChineseName.Contains(queryParam.Reviewer) || - (u.LastName + u.FirstName).Contains(queryParam.Reviewer) || - u.ReviewerCode.Contains(queryParam.Reviewer)) - on costAdjustment.ReviewerId equals doctor.Id - - select new PaymentAdjustmentDetailDTO() - { - AdjustPaymentCNY = costAdjustment.AdjustmentCNY, - AdjustPaymentUSD = costAdjustment.AdjustmentUSD, - IsLock = costAdjustment.IsLock, - Id = costAdjustment.Id, - YearMonth = costAdjustment.YearMonth, - YearMonthDate = costAdjustment.YearMonthDate, - Note = costAdjustment.Note, - ReviewerId = costAdjustment.ReviewerId, - ReviewerCode = doctor.ReviewerCode, - FirstName = doctor.FirstName, - LastName = doctor.LastName, - ChineseName = doctor.ChineseName - }; - - return await costAdjustmentQueryable.ToPagedListAsync(queryParam.PageIndex, queryParam.PageSize, string.IsNullOrWhiteSpace(queryParam.SortField) ? "YearMonthDate" : queryParam.SortField, queryParam.Asc); - - - } - - public async Task> GetReviewerSelectList() - { - return await _doctorRepository.Where(t => t.CooperateStatus == ContractorStatusEnum.Cooperation && t.ResumeStatus == ResumeStatusEnum.Pass).ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); - } - - [NonDynamicMethod] - public async Task CalculateCNY(string yearMonth, decimal rate) - { - - //如果是double 不会保留两位小数 - await _payAdjustmentRepository.BatchUpdateNoTrackingAsync(u => u.YearMonth == yearMonth && - !u.IsLock, t => new PaymentAdjustment - { - AdjustmentCNY = t.AdjustmentUSD * rate, - ExchangeRate = rate, - UpdateTime = DateTime.Now - }); - - var adjustList = await _payAdjustmentRepository.Where(u => u.YearMonth == yearMonth && - !u.IsLock).ToListAsync(); - - - - var needUpdatePayment = adjustList.GroupBy(t => t.ReviewerId).Select(g => new - { - ReviewerId = g.Key, - AdjustCNY = g.Sum(t => t.AdjustmentCNY), - AdjustUSD = g.Sum(t => t.AdjustmentUSD) - }); - - foreach (var reviewer in needUpdatePayment) - { - await _paymentRepository.BatchUpdateNoTrackingAsync(u => u.YearMonth == yearMonth && - !u.IsLock && u.DoctorId == reviewer.ReviewerId, t => new Payment() - { - AdjustmentUSD = reviewer.AdjustUSD, - AdjustmentCNY = reviewer.AdjustCNY - - }); - } - - - } - } -} diff --git a/IRaCIS.Core.Application/Service/Financial/RankPriceService.cs b/IRaCIS.Core.Application/Service/Financial/RankPriceService.cs deleted file mode 100644 index b5bb009b7..000000000 --- a/IRaCIS.Core.Application/Service/Financial/RankPriceService.cs +++ /dev/null @@ -1,105 +0,0 @@ -using AutoMapper; -using IRaCIS.Application.Interfaces; -using IRaCIS.Application.Contracts; -using IRaCIS.Core.Application.Filter; -using IRaCIS.Core.Infra.EFCore; -using IRaCIS.Core.Domain.Models; -using IRaCIS.Core.Infrastructure.Extention; -using Microsoft.AspNetCore.Mvc; -using Panda.DynamicWebApi.Attributes; - -namespace IRaCIS.Application.Services -{ - [ ApiExplorerSettings(GroupName = "Financial")] - public class RankPriceService : BaseService, IRankPriceService - { - private readonly IRepository _rankPriceRepository; - private readonly IRepository _reviewerPayInfoRepository; - - - public RankPriceService(IRepository rankPriceRepository, IRepository reviewerPayInfoRepository,IMapper mapper) - { - _rankPriceRepository = rankPriceRepository; - _reviewerPayInfoRepository = reviewerPayInfoRepository; - - } - - [NonDynamicMethod] - public async Task AddOrUpdateRankPrice(RankPriceCommand addOrUpdateModel, Guid userId) - { - if (addOrUpdateModel.Id == Guid.Empty|| addOrUpdateModel.Id ==null) - { - var rankPrice = _mapper.Map(addOrUpdateModel); - rankPrice = await _rankPriceRepository.AddAsync(rankPrice); - if (await _rankPriceRepository.SaveChangesAsync()) - { - return ResponseOutput.Ok(rankPrice.Id.ToString()); - } - else - { - return ResponseOutput.NotOk(); - } - - } - else - { - var success =await _rankPriceRepository.BatchUpdateNoTrackingAsync(t => t.Id == addOrUpdateModel.Id, u => new RankPrice() - { - UpdateUserId = userId, - UpdateTime = DateTime.Now, - RefresherTraining=addOrUpdateModel.RefresherTraining, - RankName = addOrUpdateModel.RankName, - Timepoint = addOrUpdateModel.Timepoint, - TimepointIn24H = addOrUpdateModel.TimepointIn24H, - TimepointIn48H = addOrUpdateModel.TimepointIn48H, - Adjudication = addOrUpdateModel.Adjudication, - AdjudicationIn24H = addOrUpdateModel.AdjudicationIn24H, - AdjudicationIn48H = addOrUpdateModel.AdjudicationIn48H, - Global = addOrUpdateModel.Global, - Training = addOrUpdateModel.Training, - Downtime = addOrUpdateModel.Downtime - - }); - - - return ResponseOutput.Result(success); - } - } - - - [HttpDelete("{id:guid}")] - public async Task DeleteRankPrice(Guid id) - { - - if (await _reviewerPayInfoRepository.AnyAsync(t => t.RankId == id)) - { - //---This title has been used by reviewer payment information - return ResponseOutput.NotOk(_localizer["RP_TitleUsedByRev"]); - } - - var success = await _rankPriceRepository.BatchDeleteNoTrackingAsync(t => t.Id == id); - - return ResponseOutput.Result(success); - } - - /// - /// 获取职称单价列表 - /// - [HttpPost] - public async Task> GetRankPriceList(RankPriceQueryDTO queryParam) - { - var rankPriceQueryable = _rankPriceRepository.ProjectTo(_mapper.ConfigurationProvider); - return await rankPriceQueryable.ToPagedListAsync(queryParam.PageIndex, queryParam.PageSize, "ShowOrder", queryParam.Asc); - - } - - - public async Task> GetRankDic() - { - var rankQueryable = _rankPriceRepository.ProjectTo(_mapper.ConfigurationProvider); - return await rankQueryable.ToListAsync(); - - } - - } -} diff --git a/IRaCIS.Core.Application/Service/Financial/ReviewerPayInfoService.cs b/IRaCIS.Core.Application/Service/Financial/ReviewerPayInfoService.cs deleted file mode 100644 index 3f12a31f6..000000000 --- a/IRaCIS.Core.Application/Service/Financial/ReviewerPayInfoService.cs +++ /dev/null @@ -1,144 +0,0 @@ -using AutoMapper; -using IRaCIS.Application.Interfaces; -using IRaCIS.Application.Contracts; -using System.Linq.Expressions; -using IRaCIS.Core.Infra.EFCore; -using IRaCIS.Core.Domain.Models; -using IRaCIS.Core.Infrastructure.Extention; -using Microsoft.AspNetCore.Mvc; -using Panda.DynamicWebApi.Attributes; - -namespace IRaCIS.Application.Services -{ - [ ApiExplorerSettings(GroupName = "Financial")] - public class ReviewerPayInfoService : BaseService, IReviewerPayInfoService - { - private readonly IRepository _doctorPayInfoRepository; - private readonly IRepository _doctorRepository; - private readonly IRepository _rankPriceRepository; - private readonly IRepository _hospitalRepository; - - - public ReviewerPayInfoService(IRepository doctorRepository, IRepository doctorPayInfoRepository, - IRepository rankPriceRepository, IRepository hospitalRepository, IMapper mapper) - { - _doctorPayInfoRepository = doctorPayInfoRepository; - _doctorRepository = doctorRepository; - _rankPriceRepository = rankPriceRepository; - _hospitalRepository = hospitalRepository; - - } - [NonDynamicMethod] - public async Task AddOrUpdateReviewerPayInfo(ReviewerPayInfoCommand addOrUpdateModel, Guid userId) - { - var success = false; - var doctorPayInfoExistedItem = await _doctorPayInfoRepository.FirstOrDefaultAsync(u => u.DoctorId == addOrUpdateModel.DoctorId); - if (doctorPayInfoExistedItem == null)//insert - { - - await _doctorPayInfoRepository.InsertFromDTOAsync(addOrUpdateModel); - - } - else//update - { - await _doctorPayInfoRepository.UpdateFromDTOAsync(addOrUpdateModel); - - } - success = await _doctorPayInfoRepository.SaveChangesAsync(); - return ResponseOutput.Result(success); - } - - /// - /// 获取医生支付信息列表 - /// - [HttpPost] - public async Task> GetReviewerPayInfoList(DoctorPaymentInfoQueryDTO queryParam) - { - - - var doctorQueryable = from doctor in _doctorRepository.AsQueryable() - .WhereIf(queryParam.HospitalId != null, o => o.HospitalId == queryParam.HospitalId) - .WhereIf(!string.IsNullOrEmpty(queryParam.SearchName), - u => u.ChineseName.Contains(queryParam.SearchName)|| (u.LastName+ u.FirstName).Contains(queryParam.SearchName)) - join hospitalItem in _hospitalRepository.AsQueryable() on doctor.HospitalId equals hospitalItem.Id into gt - from hospital in gt.DefaultIfEmpty() - join trialPayInfo in _doctorPayInfoRepository.Where() - on doctor.Id equals trialPayInfo.DoctorId into payInfo - from doctorPayInfo in payInfo.DefaultIfEmpty() - join rankPrice in _rankPriceRepository.Where() - on doctorPayInfo.RankId equals rankPrice.Id into rankPriceInfo - from rankPrice in rankPriceInfo.DefaultIfEmpty() - select new DoctorPayInfoQueryListDTO - { - //Id = doctorPayInfo.Id, - DoctorId = doctor.Id, - Code = doctor.ReviewerCode, - LastName = doctor.LastName, - FirstName = doctor.FirstName, - ChineseName = doctor.ChineseName, - Phone = doctor.Phone, - DoctorNameInBank = doctorPayInfo.DoctorNameInBank, - IDCard = doctorPayInfo.IDCard, - BankCardNumber = doctorPayInfo.BankCardNumber, - BankName = doctorPayInfo.BankName, - RankId = doctorPayInfo.RankId, - RankName = rankPrice.RankName, - Additional = doctorPayInfo.Additional, - Hospital = hospital.HospitalName, - CreateTime = doctor.CreateTime - }; - - return await doctorQueryable.ToPagedListAsync(queryParam.PageIndex, queryParam.PageSize, "Code", queryParam.Asc); - - - } - - - /// - /// 根据医生Id获取支付信息 - /// - /// 医生Id - /// - [HttpGet("{doctorId:guid}")] - public async Task GetReviewerPayInfo(Guid doctorId) - { - var doctorQueryable = from doctor in _doctorRepository.Where(u => u.Id == doctorId) - join trialPayInfo in _doctorPayInfoRepository.Where() - on doctor.Id equals trialPayInfo.DoctorId into payInfo - from doctorPayInfo in payInfo.DefaultIfEmpty() - join rankPrice in _rankPriceRepository.Where() - on doctorPayInfo.RankId equals rankPrice.Id into rankPriceInfo - from rankPrice in rankPriceInfo.DefaultIfEmpty() - select new DoctorPayInfoQueryListDTO - { - //Id = doctorPayInfo.Id, - DoctorId = doctor.Id, - Code = doctor.ReviewerCode, - LastName = doctor.LastName, - FirstName = doctor.FirstName, - ChineseName = doctor.ChineseName, - Phone = doctor.Phone, - DoctorNameInBank = doctorPayInfo.DoctorNameInBank, - IDCard = doctorPayInfo.IDCard, - BankCardNumber = doctorPayInfo.BankCardNumber, - BankName = doctorPayInfo.BankName, - RankId = doctorPayInfo.RankId, - RankName = rankPrice.RankName, - Additional = doctorPayInfo.Additional, - CreateTime = doctor.CreateTime - }; - - return (await doctorQueryable.FirstOrDefaultAsync()).IfNullThrowException(); - } - - /// - /// 根据rankId 获取ReviewerId,用于当Rank的单价信息改变时,触发费用计算 - /// - /// - /// - public async Task> GetReviewerIdByRankId(Guid rankId) - { - return await _doctorPayInfoRepository.Where(u => u.RankId == rankId).Select(u => u.DoctorId).ToListAsync(); - } - } -} diff --git a/IRaCIS.Core.Application/Service/Financial/TrialPaymentPriceService.cs b/IRaCIS.Core.Application/Service/Financial/TrialPaymentPriceService.cs deleted file mode 100644 index 3f8091bdf..000000000 --- a/IRaCIS.Core.Application/Service/Financial/TrialPaymentPriceService.cs +++ /dev/null @@ -1,188 +0,0 @@ -using AutoMapper; -using IRaCIS.Application.Interfaces; -using IRaCIS.Application.Contracts; -using IRaCIS.Core.Infra.EFCore; -using Microsoft.AspNetCore.Mvc; -using Panda.DynamicWebApi.Attributes; - -namespace IRaCIS.Application.Services -{ - [ApiExplorerSettings(GroupName = "Financial")] - public class TrialPaymentPriceService : BaseService, ITrialPaymentPriceService - { - private readonly IRepository _trialExtRepository; - private readonly IRepository _enrollRepository; - private readonly IRepository _doctorRepository; - private readonly IRepository _croRepository; - - - private readonly IRepository _trialRepository; - public TrialPaymentPriceService(IRepository trialRepository, IRepository trialExtRepository, - IRepository enrollRepository, - IRepository doctorRepository, - IRepository croCompanyRepository, IMapper mapper) - { - _trialExtRepository = trialExtRepository; - _croRepository = croCompanyRepository; - _enrollRepository = enrollRepository; - _doctorRepository = doctorRepository; - - _trialRepository = trialRepository; - } - - /// - /// 添加或更新项目支付价格信息 - /// - [NonDynamicMethod] - public async Task AddOrUpdateTrialPaymentPrice(TrialPaymentPriceCommand addOrUpdateModel) - { - - var trialExistedItem = await _trialExtRepository.FirstOrDefaultAsync(u => u.TrialId == addOrUpdateModel.TrialId); - if (trialExistedItem == null)//insert - { - - await _trialExtRepository.InsertFromDTOAsync(addOrUpdateModel); - - } - else//update - { - await _trialExtRepository.UpdateFromDTOAsync(addOrUpdateModel); - - } - var success = await _trialExtRepository.SaveChangesAsync(); - return ResponseOutput.Result(success); - } - - - [HttpPost] - public async Task UploadTrialSOW(TrialSOWPathDTO trialSowPath) - { - var trialPaymentPrice = await _trialExtRepository.FirstOrDefaultAsync(u => u.TrialId == trialSowPath.TrialId); - - if (trialPaymentPrice == null)//添加 - { - await _trialExtRepository.InsertFromDTOAsync(trialSowPath); - } - else//更新 - { - await _trialExtRepository.UpdateFromDTOAsync(trialSowPath); - } - - var success = await _trialExtRepository.SaveChangesAsync(); - - return ResponseOutput.Result(success); - } - - - [HttpPost] - public async Task DeleteTrialSOW(DeleteSowPathDTO trialSowPath) - { - var success = await _trialExtRepository.BatchUpdateNoTrackingAsync(u => u.TrialId == trialSowPath.TrialId, s => new TrialPaymentPrice - { - SowPath = "", - SowName = "", - UpdateTime = DateTime.Now, - UpdateUserId = _userInfo.Id - }); - - return ResponseOutput.Result(success); - } - - /// - /// 获取项目支付价格信息列表 - /// - [HttpPost] - public async Task> GetTrialPaymentPriceList(TrialPaymentPriceQueryDTO queryParam) - { - #region hwt - //var trialQueryable = from trial in _trialRepository.AsQueryable() - // .WhereIf(queryParam.CroId != null, o => o.CROId == queryParam.CroId) - // .WhereIf(!string.IsNullOrEmpty(queryParam.KeyWord), o => o.TrialCode.Contains(queryParam.KeyWord) || o.Indication.Contains(queryParam.KeyWord)) - // join cro in _croRepository.AsQueryable() on trial.CROId equals cro.Id into CRO - // from croInfo in CRO.DefaultIfEmpty() - // join trialExt in _trialExtRepository.Where() - // on trial.Id equals trialExt.TrialId into trialInfo - // from trialExt in trialInfo.DefaultIfEmpty() - // select new TrialPaymentPriceDTO - // { - // //Id = trialExt.Id , - // IsNewTrial = trialExt.IsNewTrial, - // TrialId = trial.Id, - // TrialCode = trial.TrialCode, - // Cro = croInfo.CROName, - // Indication = trial.Indication, - // Expedited = trial.Expedited, - // TrialAdditional = trialExt.TrialAdditional, - // AdjustmentMultiple = trialExt.AdjustmentMultiple, - // SowName = trialExt.SowName, - // SowPath = trialExt.SowPath, - // CreateTime = trial.CreateTime, - // }; - - //var namelist = (from enroll in _enrollRepository.AsQueryable() - // join doctor in _doctorRepository.Where() on enroll.DoctorId equals doctor.Id - // select new DtoDoctorList() - // { - // TrialId = enroll.TrialId, - // Name = doctor.ChineseName - // }).ToList().GroupBy(x => new { x.TrialId }, - //(key, lst) => new DtoDoctorList - //{ - // TrialId = key.TrialId, - // Name = string.Join(',', lst.Select(x => x.Name)) - //}); - - //var returndata = trialQueryable.ToPagedList(queryParam.PageIndex, queryParam.PageSize, "CreateTime", queryParam.Asc); - - //returndata.CurrentPageData.ForEach(x => { - // x.DoctorsNames = namelist.Where(y => y.TrialId == x.TrialId).Select(y => y.Name).FirstOrDefault() ?? string.Empty; - //}); - //return returndata; - - #endregion - - #region byzhouhang 方式一 - - //var trialQueryable = _trialExtRepository.Where(t => t.Trial.IsDeleted == false) - // .WhereIf(queryParam.CroId != null, o => o.Trial.CROId == queryParam.CroId) - // .WhereIf(!string.IsNullOrEmpty(queryParam.KeyWord), o => o.Trial.TrialCode.Contains(queryParam.KeyWord) || o.Trial.Indication.Contains(queryParam.KeyWord)) - // .Select(trialExt => new TrialPaymentPriceDTO() - // { - // TrialCode = trialExt.Trial.TrialCode, - // Cro = trialExt.Trial.CRO.CROName, - // Indication = trialExt.Trial.Indication, - // Expedited = trialExt.Trial.Expedited, - - // TrialId = trialExt.TrialId, - // IsNewTrial = trialExt.IsNewTrial, - // SowName = trialExt.SowName, - // SowPath = trialExt.SowPath, - // TrialAdditional = trialExt.TrialAdditional, - // AdjustmentMultiple = trialExt.AdjustmentMultiple, - // CreateTime = trialExt.CreateTime, - // DoctorsNames = string.Join(',', trialExt.Trial.EnrollList.Select(t => t.Doctor.ChineseName)) - // }); - - //return trialQueryable.ToPagedList(queryParam.PageIndex, queryParam.PageSize, string.IsNullOrEmpty(queryParam.SortField) ? "CreateTime" : queryParam.SortField, queryParam.Asc); - - #endregion - - - #region byzhouhang 方式二 - - var trialQueryable2 = _trialExtRepository.Where(t => t.Trial.IsDeleted == false) - .WhereIf(queryParam.CroId != null, o => o.Trial.CROId == queryParam.CroId) - .WhereIf(!string.IsNullOrEmpty(queryParam.KeyWord), o => o.Trial.TrialCode.Contains(queryParam.KeyWord) || o.Trial.Indication.Contains(queryParam.KeyWord)) - .ProjectTo(_mapper.ConfigurationProvider); - - return await trialQueryable2.ToPagedListAsync(queryParam.PageIndex, queryParam.PageSize, string.IsNullOrEmpty(queryParam.SortField) ? "CreateTime" : queryParam.SortField, queryParam.Asc); - - #endregion - - - - } - - - } -} diff --git a/IRaCIS.Core.Application/Service/Financial/TrialRevenuesPriceService.cs b/IRaCIS.Core.Application/Service/Financial/TrialRevenuesPriceService.cs deleted file mode 100644 index 28d088a11..000000000 --- a/IRaCIS.Core.Application/Service/Financial/TrialRevenuesPriceService.cs +++ /dev/null @@ -1,152 +0,0 @@ -using AutoMapper; -using IRaCIS.Application.Interfaces; -using IRaCIS.Application.Contracts; -using System.Linq.Expressions; -using IRaCIS.Core.Infra.EFCore; -using IRaCIS.Core.Domain.Models; -using IRaCIS.Core.Infrastructure.Extention; -using Microsoft.AspNetCore.Mvc; -using Panda.DynamicWebApi.Attributes; - -namespace IRaCIS.Application.Services -{ - [ ApiExplorerSettings(GroupName = "Financial")] - public class TrialRevenuesPriceService : BaseService, ITrialRevenuesPriceService - { - private readonly IRepository _trialRepository; - private readonly IRepository _trialRevenuesPriceRepository; - private readonly IRepository _croRepository; - private readonly IRepository _dictionaryRepository; - private readonly IRepository _trialRevenuesPriceVerificationRepository; - - - public TrialRevenuesPriceService(IRepository trialRepository, IRepository trialCostRepository, IRepository croCompanyRepository, IRepository dictionaryRepository, IRepository trialRevenuesPriceVerificationRepository, IMapper mapper) - { - _trialRepository = trialRepository; - _trialRevenuesPriceRepository = trialCostRepository; - _croRepository = croCompanyRepository; - _dictionaryRepository = dictionaryRepository; - _trialRevenuesPriceVerificationRepository = trialRevenuesPriceVerificationRepository; - - } - - public async Task AddOrUpdateTrialRevenuesPrice(TrialRevenuesPriceDTO model) - { - var count = model.Timepoint + - model.TimepointIn24H + - model.TimepointIn48H + - model.Adjudication + - model.AdjudicationIn24H + - model.AdjudicationIn48H + - model.Downtime + - model.Global + - model.Training; - - if (count <= 0) - { - //---Please add meaningful data - return ResponseOutput.NotOk(_localizer["TRP_AddMeaningful"]); - } - var trialExistedItem = await _trialRevenuesPriceRepository.FirstOrDefaultAsync(u => u.TrialId == model.TrialId); - if (trialExistedItem == null)//insert - { - var trialCost = _mapper.Map(model); - await _trialRevenuesPriceRepository.AddAsync(trialCost); - var success = await _trialRevenuesPriceRepository.SaveChangesAsync(); - return ResponseOutput.Result(success, trialCost.Id.ToString()); - } - else//update - { - //var trialRevenuesPrice = (await _trialRevenuesPriceRepository.AsQueryable().FirstOrDefaultAsync(u => u.TrialId == model.TrialId)).IfNullThrowException(); - - await _trialRevenuesPriceRepository.UpdateFromDTOAsync(model); - - // 完善价格的 将对应的列设置为true 变更为有价格了 - - var aaa = await _trialRevenuesPriceVerificationRepository.BatchUpdateNoTrackingAsync(t => t.TrialId == model.TrialId, u => new TrialRevenuesPriceVerification() - { - //有价格 则设置为true 否则 该列不变 - Timepoint = model.Timepoint > 0 || u.Timepoint, - TimepointIn24H = model.TimepointIn24H > 0 || u.TimepointIn24H, - TimepointIn48H = model.TimepointIn48H > 0 || u.TimepointIn48H, - Adjudication = model.Adjudication > 0 || u.Adjudication, - AdjudicationIn24H = - model.AdjudicationIn24H > 0 || u.AdjudicationIn24H, - AdjudicationIn48H = - model.AdjudicationIn48H > 0 || u.AdjudicationIn48H, - Global = model.Global > 0 || u.Global, - Downtime = model.Downtime > 0 || u.Downtime, - Training = model.Training > 0 || u.Training, - RefresherTraining = model.RefresherTraining > 0 || u.RefresherTraining, - }); - - //删除所有有价格的记录 为true 表示有价格或者不需要价格 缺价格的为false - await _trialRevenuesPriceVerificationRepository.BatchDeleteNoTrackingAsync(t => t.TrialId == model.TrialId && - t.Timepoint&& - t.TimepointIn24H&& - t.TimepointIn48H && - t.Adjudication && - t.AdjudicationIn24H && - t.AdjudicationIn48H && - t.Global && - t.Training &&t.RefresherTraining); - - - - var success = await _trialRevenuesPriceRepository.SaveChangesAsync(); - return ResponseOutput.Result(success); - } - } - - [NonDynamicMethod] - public async Task DeleteTrialCost(Guid id) - { - return await _trialRevenuesPriceRepository.BatchDeleteNoTrackingAsync(u => u.Id == id); - } - - /// - /// 获取项目收入费用信息列表[New] - /// - [HttpPost] - public async Task> GetTrialRevenuesPriceList(TrialRevenuesPriceQueryDTO queryParam) - { - - var trialQueryable = from trial in _trialRepository.AsQueryable() - .Where(u => u.TrialCode.Contains(queryParam.KeyWord)|| u.Indication.Contains(queryParam.KeyWord)) - .WhereIf(queryParam.CroId != null, o => o.CROId == queryParam.CroId) - join cro in _croRepository.AsQueryable() on trial.CROId equals cro.Id into CRO - from croInfo in CRO.DefaultIfEmpty() - join dic in _dictionaryRepository.AsQueryable() on trial.ReviewModeId equals dic.Id into dict - from dic in dict.DefaultIfEmpty() - join trialCost in _trialRevenuesPriceRepository.AsQueryable() - on trial.Id equals trialCost.TrialId into trialInfo - from trialCostItem in trialInfo.DefaultIfEmpty() - select new TrialRevenuesPriceDetialDTO - { - Id = trialCostItem == null ? Guid.Empty : trialCostItem.Id, - TrialId = trial.Id, - TrialCode = trial.TrialCode, - Indication = trial.Indication, - Cro = croInfo == null ? string.Empty : croInfo.CROName, - ReviewMode = dic == null ? string.Empty : dic.Value, - Timepoint = trialCostItem == null ? 0 : trialCostItem.Timepoint, - TimepointIn24H = trialCostItem == null ? 0 : trialCostItem.TimepointIn24H, - TimepointIn48H = trialCostItem == null ? 0 : trialCostItem.TimepointIn48H, - Adjudication = trialCostItem == null ? 0 : trialCostItem.Adjudication, - AdjudicationIn24H = trialCostItem == null ? 0 : trialCostItem.AdjudicationIn24H, - AdjudicationIn48H = trialCostItem == null ? 0 : trialCostItem.AdjudicationIn48H, - Downtime = trialCostItem == null ? 0 : trialCostItem.Downtime, - Global = trialCostItem == null ? 0 : trialCostItem.Global, - Training = trialCostItem == null ? 0 : trialCostItem.Training, - RefresherTraining= trialCostItem == null ? 0 : trialCostItem.RefresherTraining, - Expedited = trial.Expedited - - }; - - return await trialQueryable.ToPagedListAsync(queryParam.PageIndex, queryParam.PageSize, "TrialCode", queryParam.Asc); - - } - - - } -} diff --git a/IRaCIS.Core.Application/Service/Financial/TrialRevenuesPriceVerificationService.cs b/IRaCIS.Core.Application/Service/Financial/TrialRevenuesPriceVerificationService.cs deleted file mode 100644 index f197f8bec..000000000 --- a/IRaCIS.Core.Application/Service/Financial/TrialRevenuesPriceVerificationService.cs +++ /dev/null @@ -1,197 +0,0 @@ -using IRaCIS.Application.Interfaces; -using IRaCIS.Core.Domain.Models; -using System.Linq.Expressions; -using Microsoft.AspNetCore.Mvc; -using IRaCIS.Core.Infra.EFCore; -using IRaCIS.Core.Application.Contracts; - -namespace IRaCIS.Core.Application.Services -{ - /// - /// Financial---项目收入价格验证 - /// - [ ApiExplorerSettings(GroupName = "Financial")] - public class TrialRevenuesPriceVerificationService : BaseService, ITrialRevenuesPriceVerificationService - { - private readonly IRepository _trialRevenuesPriceVerificationRepository; - private readonly IRepository _trialRepository; - private readonly IRepository _doctorRepository; - private readonly IRepository _paymentRepository; - - public TrialRevenuesPriceVerificationService(IRepository trialRevenuesPriceVerificationRepository, - IRepository trialRepository,IRepository doctorRepository,IRepository paymentRepository) - { - _trialRevenuesPriceVerificationRepository = trialRevenuesPriceVerificationRepository; - _trialRepository = trialRepository; - _doctorRepository = doctorRepository; - _paymentRepository = paymentRepository; - } - [HttpPost] - public async Task GetAnalysisVerifyList(RevenusVerifyQueryDTO param) - { - AnalysisVerifyResultDTO result=new AnalysisVerifyResultDTO(); - result.RevenuesVerifyList = await GetRevenuesVerifyList(param); - - - var bDate = new DateTime(param.BeginDate.Year, param.BeginDate.Month, 1); - var eDate = new DateTime(param.EndDate.Year, param.EndDate.Month, 1); - eDate = eDate.AddMonths(1).AddSeconds(-1); - - Expression> paymentLambda = x => x.YearMonthDate >= bDate && x.YearMonthDate <= eDate&&!x.IsLock; - - var query = from payment in _paymentRepository.Where(paymentLambda) - join doctor in _doctorRepository.AsQueryable() on payment.DoctorId equals doctor.Id - select new AnalysisNeedLockDTO() - { - YearMonth = payment.YearMonth, - ReviewerCode = doctor.ReviewerCode, - ReviewerName = doctor.LastName + " / " + doctor.FirstName, - ReviewerNameCN = doctor.ChineseName - }; - - result.MonthVerifyResult = (await query.ToListAsync()).GroupBy(t => t.YearMonth).Select(g => new MonthlyResult - { - YearMonth = g.Key, - ReviewerNameList = g.Select(t => t.ReviewerName).ToList(), - ReviewerNameCNList = g.Select(t => t.ReviewerNameCN).ToList(), - ReviewerCodeList = g.Select(t => t.ReviewerCode).ToList() - - }).OrderBy(t=>t.YearMonth).ToList(); - - return result; - } - - - [HttpPost] - public async Task> GetRevenuesVerifyList(RevenusVerifyQueryDTO param) - { - var bDate = new DateTime(param.BeginDate.Year, param.BeginDate.Month, 1); - var eDate = new DateTime(param.EndDate.Year, param.EndDate.Month, 1); - Expression> trialRevenuesPriceVerificationLambda = x => x.WorkLoadDate >= bDate && x.WorkLoadDate <= eDate; - - var query = (from trialVerify in _trialRevenuesPriceVerificationRepository.Where(trialRevenuesPriceVerificationLambda) - join trail in _trialRepository.AsQueryable() on trialVerify.TrialId equals trail.Id - select new RevenusVerifyDTO - { - TrialCode = trail.TrialCode, - Timepoint = trialVerify.Timepoint, - TimepointIn24H = trialVerify.TimepointIn24H, - TimepointIn48H = trialVerify.TimepointIn48H, - Adjudication = trialVerify.Adjudication, - AdjudicationIn24H = trialVerify.AdjudicationIn24H, - AdjudicationIn48H = trialVerify.AdjudicationIn48H, - Global = trialVerify.Global, - Downtime = trialVerify.Downtime, - Training = trialVerify.Training - }).Distinct(); - - - return await query.ToListAsync(); - } - - - - //废弃 - [Obsolete] - public async Task> GetRevenuesVerifyResultList(RevenusVerifyQueryDTO param) - { - var bDate = new DateTime(param.BeginDate.Year, param.BeginDate.Month, 1); - var eDate = new DateTime(param.EndDate.Year, param.EndDate.Month, 1); - Expression> trialRevenuesPriceVerificationLambda = x => x.WorkLoadDate >= bDate && x.WorkLoadDate <= eDate; - - var query = (from trialVerify in _trialRevenuesPriceVerificationRepository.Where(trialRevenuesPriceVerificationLambda) - join trail in _trialRepository.AsQueryable() on trialVerify.TrialId equals trail.Id - select new RevenusVerifyDTO - { - TrialCode = trail.TrialCode, - Timepoint = trialVerify.Timepoint, - TimepointIn24H = trialVerify.TimepointIn24H, - TimepointIn48H = trialVerify.TimepointIn48H, - Adjudication = trialVerify.Adjudication, - AdjudicationIn24H = trialVerify.AdjudicationIn24H, - AdjudicationIn48H = trialVerify.AdjudicationIn48H, - Global = trialVerify.Global, - Downtime = trialVerify.Downtime, - Training = trialVerify.Training - }).Distinct(); - - - return await query.ToListAsync(); - #region 提示 old - //query = from trialVerify in _trialRevenuesPriceVerificationRepository.GetAll() - // join trail in _trialRepository.GetAll() on trialVerify.TrialId equals trail.Id - // join reviewer in _doctorRepository.GetAll() on trialVerify.ReviewerId equals reviewer.Id - // select new RevenusVerifyDTO() - // { - // ReviewerCode = reviewer.Code, - // TrialCode = trail.Code, - // YearMonth = trialVerify.YearMonth - // }; - - - - - - - - - - - ////0是Detail 1是按照项目 2是按照人 3按照月份 - //if (param.StatType == 0) - //{ - // query = from trialVerify in _trialRevenuesPriceVerificationRepository.GetAll() - // join trail in _trialRepository.GetAll() on trialVerify.TrialId equals trail.Id - // join reviewer in _doctorRepository.GetAll() on trialVerify.ReviewerId equals reviewer.Id - // select new RevenusVerifyDTO() - // { - // ReviewerCode = reviewer.Code, - // TrialCode = trail.Code, - // YearMonth = trialVerify.YearMonth - // }; - - //} - //else if (param.StatType == 1) - //{ - // query = (from trialVerify in _trialRevenuesPriceVerificationRepository.GetAll() - // join trail in _trialRepository.GetAll() on trialVerify.TrialId equals trail.Id - // select new RevenusVerifyDTO() - // { - // ReviewerCode = "", - // TrialCode = trail.Code, - // YearMonth = "" - // }).Distinct(); - //} - //else if (param.StatType == 2) - //{ - // query = (from trialVerify in _trialRevenuesPriceVerificationRepository.GetAll() - // join trail in _trialRepository.GetAll() on trialVerify.TrialId equals trail.Id - // join reviewer in _doctorRepository.GetAll() on trialVerify.ReviewerId equals reviewer.Id - // select new RevenusVerifyDTO() - // { - // ReviewerCode = reviewer.Code, - // TrialCode = trail.Code, - // YearMonth = "" - // }).Distinct(); - //} - //else - //{ - // query = from trialVerify in _trialRevenuesPriceVerificationRepository.GetAll() - // join trail in _trialRepository.GetAll() on trialVerify.TrialId equals trail.Id - // join reviewer in _doctorRepository.GetAll() on trialVerify.ReviewerId equals reviewer.Id - // select new RevenusVerifyDTO() - // { - // ReviewerCode = reviewer.Code, - // TrialCode = trail.Code, - // YearMonth = trialVerify.YearMonth - // }; - //} - - - #endregion - - - - } - } -} \ No newline at end of file diff --git a/IRaCIS.Core.Application/Service/Financial/VolumeRewardService.cs b/IRaCIS.Core.Application/Service/Financial/VolumeRewardService.cs deleted file mode 100644 index 35fc890d6..000000000 --- a/IRaCIS.Core.Application/Service/Financial/VolumeRewardService.cs +++ /dev/null @@ -1,61 +0,0 @@ -using AutoMapper; -using AutoMapper.QueryableExtensions; -using IRaCIS.Application.Interfaces; -using IRaCIS.Core.Domain.Share; -using IRaCIS.Core.Infra.EFCore; -using IRaCIS.Core.Domain.Models; -using IRaCIS.Core.Infrastructure.Extention; -using Microsoft.AspNetCore.Mvc; -using Panda.DynamicWebApi.Attributes; - -namespace IRaCIS.Application.Services -{ - [ ApiExplorerSettings(GroupName = "Financial")] - public class VolumeRewardService : BaseService, IVolumeRewardService - { - private readonly IRepository _volumeRewardRepository; - - - public VolumeRewardService(IRepository volumeRewardRepository,IMapper mapper) - { - _volumeRewardRepository = volumeRewardRepository; - - } - /// - /// 批量添加或更新奖励费用单价 - /// - [NonDynamicMethod] - public async Task AddOrUpdateVolumeRewardPriceList(IEnumerable addOrUpdateModel) - { - await _volumeRewardRepository.BatchDeleteNoTrackingAsync(t => t.Id != Guid.Empty); - var temp = _mapper.Map>(addOrUpdateModel); - - await _volumeRewardRepository.AddRangeAsync(temp); - var success = await _volumeRewardRepository.SaveChangesAsync(); - - return ResponseOutput.Result(success); - } - - - /// - /// 获取所有奖励单价列表-用于计算时,一次性获取所有 - /// - [NonDynamicMethod] - public async Task> GetVolumeRewardPriceList() - { - return await _volumeRewardRepository.ProjectTo(_mapper.ConfigurationProvider).OrderBy(t => t.Min).ToListAsync(); - } - - /// - /// 分页获取奖励单价列表 - /// - [HttpPost] - public async Task> GetVolumeRewardPriceList(AwardPriceQueryDTO queryParam) - { - var awardPriceQueryable = _volumeRewardRepository.ProjectTo(_mapper.ConfigurationProvider); - - return await awardPriceQueryable.ToPagedListAsync(queryParam.PageIndex, queryParam.PageSize, "Min"); - - } - } -} \ No newline at end of file diff --git a/IRaCIS.Core.Application/Service/Financial/_MapConfig.cs b/IRaCIS.Core.Application/Service/Financial/_MapConfig.cs deleted file mode 100644 index 16d342ddc..000000000 --- a/IRaCIS.Core.Application/Service/Financial/_MapConfig.cs +++ /dev/null @@ -1,62 +0,0 @@ -using AutoMapper; -using IRaCIS.Application.Contracts; -using IRaCIS.Application.Contracts.Pay; -using IRaCIS.Application.Interfaces; -using IRaCIS.Core.Domain.Models; - -namespace IRaCIS.Core.Application.Service -{ - public class FinancialConfig : Profile - { - public FinancialConfig() - { - CreateMap() - .ForMember(t => t.YearMonthDate, u => u.MapFrom(t => t.YearMonth)) - .ForMember(t => t.YearMonth, u => u.MapFrom(t => t.YearMonth.ToString("yyyy-MM"))); - - CreateMap(); - CreateMap(); - - CreateMap(); - - CreateMap(); - - CreateMap(); - - CreateMap(); - CreateMap(); - - CreateMap(); - - CreateMap(); - - CreateMap(); - - - CreateMap(); - CreateMap(); - CreateMap(); - CreateMap(); - CreateMap(); - - CreateMap(); - CreateMap(); - - CreateMap(); - - - CreateMap() - .ForMember(t => t.TrialCode, u => u.MapFrom(t => t.Trial.Code)) - .ForMember(t => t.ReviewMode, u => u.MapFrom(t => t.Trial.ReviewMode.Value)) - .ForMember(t => t.Cro, u => u.MapFrom(t => t.Trial.CRO.CROName)) - .ForMember(t => t.Indication, u => u.MapFrom(t => t.Trial.Indication)) - .ForMember(t => t.Expedited, u => u.MapFrom(t => t.Trial.Expedited)) - .ForMember(t => t.DoctorsNames, u => u.MapFrom(t => string.Join(',', t.Trial.EnrollList.Select(t => t.Doctor.ChineseName)))) - - - ; - - } - } - -} diff --git a/IRaCIS.Core.Application/Service/Institution/HospitalService.cs b/IRaCIS.Core.Application/Service/Institution/HospitalService.cs index 2707fb556..58fec58d1 100644 --- a/IRaCIS.Core.Application/Service/Institution/HospitalService.cs +++ b/IRaCIS.Core.Application/Service/Institution/HospitalService.cs @@ -10,12 +10,11 @@ namespace IRaCIS.Application.Services public class HospitalService : BaseService, IHospitalService { private readonly IRepository _hospitalRepository; - private readonly IRepository _doctorRepository; - public HospitalService(IRepository hospitalRepository, IRepository doctorRepository) + public HospitalService(IRepository hospitalRepository ) { _hospitalRepository = hospitalRepository; - this._doctorRepository = doctorRepository; + } /// 获取所有医院列表 @@ -55,11 +54,7 @@ namespace IRaCIS.Application.Services [HttpDelete("{hospitalId:guid}")] public async Task DeleteHospital(Guid hospitalId) { - if (await _doctorRepository.AnyAsync(t => t.Id == hospitalId)) - { - //---该医院下已经注册有医生,不可以删除。 - return ResponseOutput.NotOk(_localizer["Hospital_HasDoctors"]); - } + //if (_userRepository.Find().Any(t => t.OrganizationId == hospitalId)) //{ // return ResponseOutput.NotOk("该医院下存在用户,暂时无法删除。"); diff --git a/IRaCIS.Core.Application/Service/Management/UserService.cs b/IRaCIS.Core.Application/Service/Management/UserService.cs index c6540c7f4..df02f5c8d 100644 --- a/IRaCIS.Core.Application/Service/Management/UserService.cs +++ b/IRaCIS.Core.Application/Service/Management/UserService.cs @@ -21,7 +21,6 @@ namespace IRaCIS.Application.Services private readonly IRepository _userRepository; private readonly IMailVerificationService _mailVerificationService; private readonly IRepository _verificationCodeRepository; - private readonly IRepository _doctorRepository; private readonly IRepository _userTrialRepository; private readonly IRepository _userLogRepository; @@ -35,7 +34,6 @@ namespace IRaCIS.Application.Services IMailVerificationService mailVerificationService, IRepository verificationCodeRepository, - IRepository doctorRepository, IMemoryCache cache, IRepository userTrialRepository, IOptionsMonitor verifyConfig, @@ -49,7 +47,7 @@ namespace IRaCIS.Application.Services _userRepository = userRepository; _mailVerificationService = mailVerificationService; _verificationCodeRepository = verificationCodeRepository; - _doctorRepository = doctorRepository; + _userTrialRepository = userTrialRepository; _userLogRepository = userLogRepository; } diff --git a/IRaCIS.Core.Application/Service/Reading/AdditionalEvaluate/DTO/SubjectCriteriaEvaluationVisitFilterViewModel.cs b/IRaCIS.Core.Application/Service/Reading/AdditionalEvaluate/DTO/SubjectCriteriaEvaluationVisitFilterViewModel.cs index e13fe0404..4823beee5 100644 --- a/IRaCIS.Core.Application/Service/Reading/AdditionalEvaluate/DTO/SubjectCriteriaEvaluationVisitFilterViewModel.cs +++ b/IRaCIS.Core.Application/Service/Reading/AdditionalEvaluate/DTO/SubjectCriteriaEvaluationVisitFilterViewModel.cs @@ -10,54 +10,8 @@ using System.ComponentModel.DataAnnotations; namespace IRaCIS.Core.Application.ViewModel { - /// SubjectCriteriaEvaluationVisitFilterView 列表视图模型 - public class SubjectCriteriaEvaluationVisitFilterView - { - public DateTime? CreateTime { get; set; } - public Guid? CreateUserId { get; set; } - public Guid? UpdateUserId { get; set; } - public DateTime? UpdateTime { get; set; } - public Guid? Id { get; set; } - - public Guid TrialId { get; set; } - public Guid SubjectId { get; set; } - - public Guid SiteId { get; set; } - - public string SubjectCode { get; set; } - public Guid TrialReadingCriterionId { get; set; } - public Guid SubjectVisitId { get; set; } - - public ImageFilterState? ImageFilterState { get; set; } - public ImageDeterminationResultState? ImageDeterminationResultState { get; set; } - - - public bool? IsGeneratedTask { get; set; } - - public decimal VisitNum { get; set; } - public string VisitName { get; set; } - public DateTime? EarliestScanDate { get; set; } - public DateTime? LatestScanDate { get; set; } - } - - ///SubjectCriteriaEvaluationVisitFilterQuery 列表查询参数模型 - public class SubjectCriteriaEvaluationVisitFilterQuery - { - [NotDefault] - public Guid TrialReadingCriterionId { get; set; } - - - [NotDefault] - public Guid SubjectId { get; set; } - - - public ImageFilterState? ImageFilterState { get; set; } - - public ImageDeterminationResultState? ImageDeterminationResultState { get; set; } - - public bool? IsGeneratedTask { get; set; } - } + public class HaveGeneratedTaskQuery : PageInput { diff --git a/IRaCIS.Core.Application/Service/Reading/AdditionalEvaluate/Interface/ISubjectCriteriaEvaluationService.cs b/IRaCIS.Core.Application/Service/Reading/AdditionalEvaluate/Interface/ISubjectCriteriaEvaluationService.cs deleted file mode 100644 index 821834fd6..000000000 --- a/IRaCIS.Core.Application/Service/Reading/AdditionalEvaluate/Interface/ISubjectCriteriaEvaluationService.cs +++ /dev/null @@ -1,25 +0,0 @@ -//-------------------------------------------------------------------- -// 此代码由T4模板自动生成 byzhouhang 20210918 -// 生成时间 2023-03-17 11:58:54 -// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。 -//-------------------------------------------------------------------- - -using IRaCIS.Core.Application.ViewModel; -namespace IRaCIS.Core.Application.Interfaces -{ - /// - /// ISubjectCriteriaEvaluationService - /// - public interface ISubjectCriteriaEvaluationService - { - - - //Task> GetSubjectCriteriaEvaluationList(SubjectCriteriaEvaluationQuery inQuery); - - //Task AddOrUpdateSubjectCriteriaEvaluation(SubjectCriteriaEvaluationAddOrEdit addOrEditSubjectCriteriaEvaluation); - - //Task DeleteSubjectCriteriaEvaluation(Guid subjectCriteriaEvaluationId); - - Task AutoSubjectCriteriaEvaluationVisitFilter(Guid subjectId, Guid subjectVisitId, Guid trialReadingCriterionId); - } -} diff --git a/IRaCIS.Core.Application/Service/Reading/AdditionalEvaluate/SubjectCriteriaEvaluationService.cs b/IRaCIS.Core.Application/Service/Reading/AdditionalEvaluate/SubjectCriteriaEvaluationService.cs deleted file mode 100644 index ff72f893e..000000000 --- a/IRaCIS.Core.Application/Service/Reading/AdditionalEvaluate/SubjectCriteriaEvaluationService.cs +++ /dev/null @@ -1,776 +0,0 @@ -//-------------------------------------------------------------------- -// 此代码由T4模板自动生成 byzhouhang 20210918 -// 生成时间 2023-03-17 11:58:57 -// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。 -//-------------------------------------------------------------------- - -using IRaCIS.Core.Domain.Models; -using Microsoft.AspNetCore.Mvc; -using IRaCIS.Core.Application.Interfaces; -using IRaCIS.Core.Application.ViewModel; -using IRaCIS.Core.Application.Contracts.DTO; -using System.Linq; -using System.Linq.Dynamic.Core; -using IRaCIS.Core.Domain.Share; -using IRaCIS.Core.Application.Contracts; -using DocumentFormat.OpenXml.Spreadsheet; -using Panda.DynamicWebApi.Attributes; -using IRaCIS.Core.Domain.Share.Reading; -using System.Runtime.InteropServices; -using DocumentFormat.OpenXml.Bibliography; -using System.Linq.Expressions; -using MathNet.Numerics.Statistics.Mcmc; - -namespace IRaCIS.Core.Application.Service -{ - /// - /// SubjectCriteriaEvaluationService - /// - [ApiExplorerSettings(GroupName = "Trial")] - public class SubjectCriteriaEvaluationService : BaseService, ISubjectCriteriaEvaluationService - { - - private readonly IRepository _subjectCriteriaEvaluationRepository; - private readonly IRepository _subjectRepository; - private readonly IRepository _subjectVisitRepository; - private readonly IRepository _subjectCriteriaEvaluationVisitFilterRepository; - private readonly IRepository _subjectCriteriaEvaluationVisitStudyFilterRepository; - - private readonly IRepository _trialReadingCriterionRepository; - - private readonly IRepository _trialReadingQuestionRepository; - - private readonly IRepository _visitTaskRepository; - - private readonly IVisitTaskHelpeService _IVisitTaskHelpeService; - private readonly IRepository _taskMedicalReviewRepository; - private readonly IRepository _visitTaskReReadingRepository; - - public SubjectCriteriaEvaluationService(IRepository subjectCriteriaEvaluationRepository, IRepository subjectRepository, - IRepository subjectCriteriaEvaluationVisitFilterRepository, IRepository subjectVisitRepository, - IRepository subjectCriteriaEvaluationVisitStudyFilterRepository, - IRepository trialReadingCriterionRepository, IVisitTaskHelpeService IVisitTaskHelpeService, IRepository trialReadingQuestionRepository, IRepository visitTaskRepository, IRepository taskMedicalReviewRepository, IRepository visitTaskReReadingRepository) - { - _subjectCriteriaEvaluationRepository = subjectCriteriaEvaluationRepository; - _subjectRepository = subjectRepository; - _subjectCriteriaEvaluationVisitFilterRepository = subjectCriteriaEvaluationVisitFilterRepository; - _subjectVisitRepository = subjectVisitRepository; - _subjectCriteriaEvaluationVisitStudyFilterRepository = subjectCriteriaEvaluationVisitStudyFilterRepository; - _trialReadingCriterionRepository = trialReadingCriterionRepository; - - _IVisitTaskHelpeService = IVisitTaskHelpeService; - - _trialReadingQuestionRepository = trialReadingQuestionRepository; - _visitTaskRepository = visitTaskRepository; - _taskMedicalReviewRepository = taskMedicalReviewRepository; - _visitTaskReReadingRepository = visitTaskReReadingRepository; - } - - - /// - /// subject 某标准 是否评估列表 - /// - /// - /// - [HttpPost] - public async Task> > GetSubjectCriteriaEvaluationList(SubjectCriteriaEvaluationQuery inQuery) - { - - var trialReadingCritionList = _trialReadingCriterionRepository.Where(t => t.TrialId == inQuery.TrialId).ToList(); - - var resultTrialReadingCriterionId = Guid.Empty; - - var resultTrialReadingCriterion = trialReadingCritionList.First(); - - var curentCriterionType = CriterionType.NoCriterion; - - - //BM 需要找基线 两个人做的结果 - if (trialReadingCritionList.First(t => t.Id == inQuery.TrialReadingCriterionId).CriterionType == CriterionType.RECIST1Pointt1_MB) - { - - resultTrialReadingCriterion = trialReadingCritionList.First(t => t.CriterionType == CriterionType.RECIST1Point1); - resultTrialReadingCriterionId = resultTrialReadingCriterion.Id; - - curentCriterionType = CriterionType.RECIST1Pointt1_MB; - } - - var addtionalQustionInfoList = _trialReadingQuestionRepository.Where(t => t.ReadingQuestionCriterionTrialId == resultTrialReadingCriterionId && t.IsAdditional == true && t.Type != "group").IgnoreQueryFilters().Select(t => new - { - QuestionId = t.Id, - t.QuestionEnName, - t.QuestionName - }).ToList(); - - var questionIdList = addtionalQustionInfoList.Select(t => t.QuestionId).ToList(); - - - var subjectCriteriaEvaluationQueryable = from subject in _subjectRepository.Where(t => t.TrialId == inQuery.TrialId) - .WhereIf(!string.IsNullOrWhiteSpace(inQuery.SubjectCode), t => t.Code.Contains(inQuery.SubjectCode)) - .WhereIf(!string.IsNullOrWhiteSpace(inQuery.TrialSiteCode), t => t.TrialSite.TrialSiteCode.Contains(inQuery.TrialSiteCode)) - .WhereIf(inQuery.SubjectStatus != null, t => t.Status == inQuery.SubjectStatus) - - join subjectCriteriaEvaluation in _subjectCriteriaEvaluationRepository - .Where(t => t.TrialReadingCriterionId == inQuery.TrialReadingCriterionId) - - on subject.Id equals subjectCriteriaEvaluation.SubjectId into d - from subjectCriteriaEvaluation in d.DefaultIfEmpty() - - select new SubjectCriteriaEvaluationView() - { - SubjectCode = subject.Code, - SubjectId = subject.Id, - SubjectStatus = subject.Status, - TrialSiteCode = subject.TrialSite.TrialSiteCode, - - Id = subjectCriteriaEvaluation.Id, - TrialReadingCriterionId = inQuery.TrialReadingCriterionId, - - IsImageFiltering = subject.SubjectCriteriaEvaluationVisitFilterList.Any(t => t.TrialReadingCriterionId== inQuery.TrialReadingCriterionId - && t.ImageFilterState == ImageFilterState.None), - - IsJoinEvaluation = subjectCriteriaEvaluation.IsJoinEvaluation, - - - ReadingEvaluationList = subject.ReadingTaskQuestionAnswerList.AsQueryable().IgnoreQueryFilters() - .Where(t => t.ReadingQuestionCriterionTrialId == resultTrialReadingCriterionId && - questionIdList.Contains(t.ReadingQuestionTrialId) - && t.VisitTask.TaskState == TaskState.Effect) - .Select(u => new EvaluationInfo() - { - QuestionId = u.ReadingQuestionTrialId, - Answer = u.Answer, - ArmEnum = u.VisitTask.ArmEnum, - FinalTranslateDictionaryCode = u.ReadingQuestionTrial.DictionaryCode - }).ToList() - - }; - - var pageList = await subjectCriteriaEvaluationQueryable - .WhereIf(inQuery.IsImageFiltering != null, t => t.IsImageFiltering == inQuery.IsImageFiltering) - .WhereIf(inQuery.IsJoinEvaluation != null, t => t.IsJoinEvaluation == inQuery.IsJoinEvaluation) - .ToPagedListAsync(inQuery.PageIndex, inQuery.PageSize, inQuery.SortField == string.Empty ? nameof(SubjectCriteriaEvaluationView.SubjectCode) : inQuery.SortField, inQuery.Asc); - - - foreach (var item in pageList.CurrentPageData) - { - switch (curentCriterionType) - { - - case CriterionType.RECIST1Pointt1_MB: - - if (resultTrialReadingCriterion.ReadingType == ReadingMethod.Double) - { - if (item.ReadingEvaluationList.Count == 2) - { - if (item.ReadingEvaluationList.All(t => t.Answer == 1.ToString())) - { - item.FinalEvaluationList.Add(new EvaluationInfo() - { - QuestionId = item.ReadingEvaluationList.First().QuestionId, - Answer = ((int)BrainMetastasisResult.Yes).ToString(), - FinalTranslateDictionaryCode = nameof(BrainMetastasisResult) - }); - } - else if (item.ReadingEvaluationList.All(t => t.Answer == 0.ToString())) - { - item.FinalEvaluationList.Add(new EvaluationInfo() - { - QuestionId = item.ReadingEvaluationList.First().QuestionId, - Answer = ((int)BrainMetastasisResult.No).ToString(), - FinalTranslateDictionaryCode = nameof(BrainMetastasisResult) - }); - } - else if (item.ReadingEvaluationList.First().Answer != item.ReadingEvaluationList.Last().Answer && item.ReadingEvaluationList.Any(t => t.Answer == 1.ToString())) - { - item.FinalEvaluationList.Add(new EvaluationInfo() { QuestionId = item.ReadingEvaluationList.First().QuestionId, Answer = ((int)BrainMetastasisResult.Maybe).ToString(), FinalTranslateDictionaryCode = nameof(BrainMetastasisResult) }); - } - else - { - item.FinalEvaluationList.Add(new EvaluationInfo() { QuestionId = addtionalQustionInfoList.FirstOrDefault()?.QuestionId, Answer = ((int)BrainMetastasisResult.Unknown).ToString(), FinalTranslateDictionaryCode = nameof(BrainMetastasisResult) }); - } - - } - else - { - item.FinalEvaluationList.Add(new EvaluationInfo() { QuestionId = addtionalQustionInfoList.FirstOrDefault()?.QuestionId, Answer = ((int)BrainMetastasisResult.Unknown).ToString(), FinalTranslateDictionaryCode = nameof(BrainMetastasisResult) }); - } - } - else if (resultTrialReadingCriterion.ReadingType == ReadingMethod.Single) - { - - if (item.ReadingEvaluationList.Count == 1) - { - if (item.ReadingEvaluationList.All(t => t.Answer == 1.ToString())) - { - item.FinalEvaluationList.Add(new EvaluationInfo() { QuestionId = item.ReadingEvaluationList.First().QuestionId, Answer = ((int)BrainMetastasisResult.Yes).ToString(), FinalTranslateDictionaryCode = nameof(BrainMetastasisResult) }); - } - else if (item.ReadingEvaluationList.All(t => t.Answer == 0.ToString())) - { - item.FinalEvaluationList.Add(new EvaluationInfo() { QuestionId = item.ReadingEvaluationList.First().QuestionId, Answer = ((int)BrainMetastasisResult.No).ToString(), FinalTranslateDictionaryCode = nameof(BrainMetastasisResult) }); - } - else - { - item.FinalEvaluationList.Add(new EvaluationInfo() { QuestionId = addtionalQustionInfoList.FirstOrDefault()?.QuestionId, Answer = ((int)BrainMetastasisResult.Unknown).ToString(), FinalTranslateDictionaryCode = nameof(BrainMetastasisResult) }); - } - } - else - { - item.FinalEvaluationList.Add(new EvaluationInfo() { QuestionId = addtionalQustionInfoList.FirstOrDefault()?.QuestionId, Answer = ((int)BrainMetastasisResult.Unknown).ToString(), FinalTranslateDictionaryCode = nameof(BrainMetastasisResult) }); - } - - } - else - { - - } - - break; - default: - break; - } - } - - - - - - - return ResponseOutput.Ok (pageList, addtionalQustionInfoList); - } - - - /// - /// 添加 编辑 是否参与评估 - /// - /// - /// - [UnitOfWork] - public async Task BatchAddOrUpdateSubjectCriteriaEvaluation(List addOrEditSubjectCriteriaEvaluationList) - { - // 在此处拷贝automapper 映射 - - foreach (var addOrEditSubjectCriteriaEvaluation in addOrEditSubjectCriteriaEvaluationList) - { - - - if (addOrEditSubjectCriteriaEvaluation.Id == null) - { - var entity = await _subjectCriteriaEvaluationRepository.InsertFromDTOAsync(addOrEditSubjectCriteriaEvaluation); - - if (addOrEditSubjectCriteriaEvaluation.IsJoinEvaluation) - { - - //找到一致性核查通过的访视 并且没有 自动影像筛选的数据 - var subjectVisitIdList = await _subjectVisitRepository.Where(t => t.SubjectId == addOrEditSubjectCriteriaEvaluation.SubjectId && t.CheckState == CheckStateEnum.CVPassed - && !t.SubjectCriteriaEvaluationVisitFilterList.Any(t => t.TrialReadingCriterionId == addOrEditSubjectCriteriaEvaluation.TrialReadingCriterionId && t.SubjectId == addOrEditSubjectCriteriaEvaluation.SubjectId)).Select(t => t.Id) - .ToListAsync(); - - - foreach (var subjectVisitId in subjectVisitIdList) - { - await AutoSubjectCriteriaEvaluationVisitFilter(addOrEditSubjectCriteriaEvaluation.SubjectId, subjectVisitId, addOrEditSubjectCriteriaEvaluation.TrialReadingCriterionId); - } - - } - - - - - } - //编辑 - else - { - //参与评估 - if (addOrEditSubjectCriteriaEvaluation.IsJoinEvaluation) - { - var dbBeforeEntity = await _subjectCriteriaEvaluationRepository.UpdateFromDTOAsync(addOrEditSubjectCriteriaEvaluation); - - //从不评估 改为评估 - if (addOrEditSubjectCriteriaEvaluation.IsJoinEvaluation != dbBeforeEntity.IsJoinEvaluation) - { - //找到一致性核查通过的访视 并且没有 自动影像筛选的数据 - var subjectVisitIdList = await _subjectVisitRepository.Where(t => t.SubjectId == addOrEditSubjectCriteriaEvaluation.SubjectId && t.CheckState == CheckStateEnum.CVPassed && - !t.SubjectCriteriaEvaluationVisitFilterList.Any(t => t.TrialReadingCriterionId == addOrEditSubjectCriteriaEvaluation.TrialReadingCriterionId && t.SubjectId == addOrEditSubjectCriteriaEvaluation.SubjectId)). - Select(t => t.Id).ToListAsync(); - - - foreach (var subjectVisitId in subjectVisitIdList) - { - await AutoSubjectCriteriaEvaluationVisitFilter(addOrEditSubjectCriteriaEvaluation.SubjectId, subjectVisitId, addOrEditSubjectCriteriaEvaluation.TrialReadingCriterionId); - } - } - //未修改 不做任何操作 - - - } - //不参与评估 - else - { - //删除该Subject 该标准访视的所有 访视筛选记录数据 - await _subjectCriteriaEvaluationVisitFilterRepository.BatchDeleteNoTrackingAsync(t => t.TrialReadingCriterionId == addOrEditSubjectCriteriaEvaluation.TrialReadingCriterionId && t.SubjectId == addOrEditSubjectCriteriaEvaluation.SubjectId); - await _subjectCriteriaEvaluationVisitStudyFilterRepository.BatchDeleteNoTrackingAsync(t => t.TrialReadingCriterionId == addOrEditSubjectCriteriaEvaluation.TrialReadingCriterionId && t.SubjectVisit.SubjectId == addOrEditSubjectCriteriaEvaluation.SubjectId); - } - } - - } - - await _subjectCriteriaEvaluationRepository.SaveChangesAsync(); - return ResponseOutput.Ok(); - - } - - /// - /// 自动访视筛选 (针对单一访视,重新筛选一遍,可能不存在该接口,仅仅留存) - /// - /// - [NonDynamicMethod] - public async Task AutoSubjectCriteriaEvaluationVisitFilter(Guid subjectId, Guid subjectVisitId, Guid trialReadingCriterionId) - { - - if ((await _trialReadingCriterionRepository.FindAsync(trialReadingCriterionId)).CriterionType == CriterionType.RECIST1Pointt1_MB) - { - //如果所有访视 的所有序列部位都是脑部 那么自动筛选通过,同时需要插入序列的筛选记录 - - - //找到该方式的所有序列 - var list = await _repository.Where(t => t.SubjectVisitId == subjectVisitId && t.SubjectId == subjectId).Select(t => new { SeriesId = t.Id, t.StudyId, t.BodyPartForEdit }).ToListAsync(); - - - ////已经自动筛选过 - //if (await _subjectCriteriaEvaluationVisitFilterRepository.AnyAsync(t => t.TrialReadingCriterionId == trialReadingCriterionId && t.SubjectVisitId == subjectVisitId)) - //{ - // await _subjectCriteriaEvaluationVisitFilterRepository.BatchDeleteNoTrackingAsync(t => t.TrialReadingCriterionId == trialReadingCriterionId && t.SubjectVisitId == subjectVisitId); - - // await _subjectCriteriaEvaluationVisitStudyFilterRepository.BatchDeleteNoTrackingAsync(t => t.TrialReadingCriterionId == trialReadingCriterionId && t.SubjectVisitId == subjectVisitId); - //} - - var existEntity = await _subjectCriteriaEvaluationVisitFilterRepository.FirstOrDefaultAsync(t => t.SubjectId == subjectId && t.SubjectVisitId == subjectVisitId && t.TrialReadingCriterionId == trialReadingCriterionId); - - //已经自动筛选过 - - if (existEntity != null) - { - await _subjectCriteriaEvaluationVisitStudyFilterRepository.BatchDeleteNoTrackingAsync(t => t.TrialReadingCriterionId == trialReadingCriterionId && t.SubjectVisitId == subjectVisitId); - } - - //有不是脑部的序列 - if (list.Any(t => t.BodyPartForEdit != "脑部")) - { - - - if (existEntity == null) - { - var addItem = new SubjectCriteriaEvaluationVisitFilter - { - SubjectVisitId = subjectVisitId, - SubjectId = subjectId, - ImageDeterminationResultState = ImageDeterminationResultState.None, - ImageFilterState = ImageFilterState.None, - TrialReadingCriterionId = trialReadingCriterionId - }; - - - var subjectCriteriaEvaluationVisitFilter = await _subjectCriteriaEvaluationVisitFilterRepository.AddAsync(addItem); - } - else - { - existEntity.ImageDeterminationResultState = ImageDeterminationResultState.None; - existEntity.ImageFilterState = ImageFilterState.None; - } - - } - //都是脑部的序列 - else - { - - if (existEntity == null) - { - var addItem = new SubjectCriteriaEvaluationVisitFilter - { - SubjectVisitId = subjectVisitId, - SubjectId = subjectId, - ImageDeterminationResultState = ImageDeterminationResultState.Passed, - ImageFilterState = ImageFilterState.Finished, - TrialReadingCriterionId = trialReadingCriterionId, - IsGeneratedTask = true - }; - - var subjectCriteriaEvaluationVisitFilter = await _subjectCriteriaEvaluationVisitFilterRepository.AddAsync(addItem); - - } - else - { - existEntity.ImageDeterminationResultState = ImageDeterminationResultState.Passed; - existEntity.ImageFilterState = ImageFilterState.Finished; - } - - foreach (var item in list) - { - await _subjectCriteriaEvaluationVisitStudyFilterRepository.AddAsync(new SubjectCriteriaEvaluationVisitStudyFilter { SubjectVisitId = subjectVisitId, SeriesId = item.SeriesId, TrialReadingCriterionId = trialReadingCriterionId, StudyId = item.StudyId, IsConfirmed = true, IsReading = true }); - } - - //自动生成任务 - - var trialId = _subjectVisitRepository.Where(t => t.Id == subjectVisitId).Select(t => t.TrialId).FirstOrDefault(); - - await _IVisitTaskHelpeService.BaseCritrionGenerateVisitTask(trialId, trialReadingCriterionId, true, new List() { subjectVisitId }); - - } - } - - await _subjectCriteriaEvaluationVisitFilterRepository.SaveChangesAsync(); - - - } - - - /// - /// 评估访视筛选列表(一致性核查通过的访视都会出现 根据条件筛选) - /// - /// - /// - [HttpPost] - public async Task> GetSubjectCriteriaEvaluationVisitFilterList(SubjectCriteriaEvaluationVisitFilterQuery inQuery) - { - - - - - var subjectCriteriaEvaluationVisitFilterQueryable = from subjectVisit in _subjectVisitRepository.Where(t => t.SubjectId == inQuery.SubjectId && t.CheckState == CheckStateEnum.CVPassed) - - - join subjectCriteriaEvaluationVisitFilter in _subjectCriteriaEvaluationVisitFilterRepository - .Where(t => t.TrialReadingCriterionId == inQuery.TrialReadingCriterionId) - .WhereIf(inQuery.ImageDeterminationResultState != null, t => t.ImageDeterminationResultState == inQuery.ImageDeterminationResultState) - .WhereIf(inQuery.ImageFilterState != null, t => t.ImageFilterState == inQuery.ImageFilterState) - .WhereIf(inQuery.IsGeneratedTask != null, t => t.IsGeneratedTask == inQuery.IsGeneratedTask) - on subjectVisit.Id equals subjectCriteriaEvaluationVisitFilter.SubjectVisitId - - //into d from subjectCriteriaEvaluationVisitFilter in d.DefaultIfEmpty() - - select new SubjectCriteriaEvaluationVisitFilterView() - { - VisitName = subjectVisit.VisitName, - VisitNum = subjectVisit.VisitNum, - SubjectVisitId = subjectVisit.Id, - TrialId = subjectVisit.TrialId, - SubjectId = subjectVisit.SubjectId, - SubjectCode = subjectVisit.Subject.Code, - SiteId = subjectVisit.SiteId, - TrialReadingCriterionId = inQuery.TrialReadingCriterionId, - LatestScanDate = subjectVisit.LatestScanDate, - EarliestScanDate = subjectVisit.LatestScanDate, - ImageDeterminationResultState = subjectCriteriaEvaluationVisitFilter.ImageDeterminationResultState, - ImageFilterState = subjectCriteriaEvaluationVisitFilter.ImageFilterState, - IsGeneratedTask = subjectCriteriaEvaluationVisitFilter.IsGeneratedTask, - Id = subjectCriteriaEvaluationVisitFilter.Id, - - CreateTime = subjectCriteriaEvaluationVisitFilter.CreateTime, - CreateUserId = subjectCriteriaEvaluationVisitFilter.CreateUserId, - UpdateTime = subjectCriteriaEvaluationVisitFilter.UpdateTime, - UpdateUserId = subjectCriteriaEvaluationVisitFilter.UpdateUserId, - - }; - - - return await subjectCriteriaEvaluationVisitFilterQueryable.OrderBy(t => t.VisitNum).ToListAsync(); - } - - /// - /// 已生成任务列表 - /// - /// - /// - [HttpPost] - public async Task> GetHaveGeneratedTaskList(HaveGeneratedTaskQuery inQuery) - { - var list = await _repository.Where(t => t.TrialReadingCriterionId == inQuery.TrialReadingCriterionId && t.SubjectId == inQuery.SubjectId && t.TaskState == TaskState.Effect).OrderBy(t => t.VisitTaskNum) - .ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); - - return list; - } - - /// - /// 批量勾选 生成该标准的任务 - /// - /// - [UnitOfWork] - public async Task BatchGenerateTask(BatchGenerateTaskCommand batchGenerateTaskCommand) - { - - var trakingList= await _subjectCriteriaEvaluationVisitFilterRepository.Where(t => t.SubjectId == batchGenerateTaskCommand.SubjectId - && t.TrialReadingCriterionId == batchGenerateTaskCommand.TrialReadingCriterionId - && batchGenerateTaskCommand.SubjectVisitIdList.Contains(t.SubjectVisitId),true).ToListAsync(); - - foreach (var item in trakingList) - { - item.IsGeneratedTask = true; - } - - //await _subjectCriteriaEvaluationVisitFilterRepository.BatchUpdateNoTrackingAsync(t => t.SubjectId == batchGenerateTaskCommand.SubjectId - //&& t.TrialReadingCriterionId == batchGenerateTaskCommand.TrialReadingCriterionId - //&& batchGenerateTaskCommand.SubjectVisitIdList.Contains(t.SubjectVisitId), u => new SubjectCriteriaEvaluationVisitFilter { IsGeneratedTask = true }); - - //自动生成任务 - - var idList = batchGenerateTaskCommand.SubjectVisitIdList.Select(t => (Guid?)t).ToList(); - - //存在任务的访视 - var haveGenerateVisitIdList = await _repository.Where(t => idList.Contains(t.SourceSubjectVisitId) && t.TrialReadingCriterionId == batchGenerateTaskCommand.TrialReadingCriterionId && t.TaskState == TaskState.Effect) - .Select(t => t.SourceSubjectVisitId).ToListAsync(); - - var generateVisitIdList = idList.Except(haveGenerateVisitIdList); - - await _IVisitTaskHelpeService.BaseCritrionGenerateVisitTask(batchGenerateTaskCommand.TrialId, batchGenerateTaskCommand.TrialReadingCriterionId, true, generateVisitIdList.Select(t => (Guid)t).ToList()); - - await _subjectCriteriaEvaluationVisitFilterRepository.SaveChangesAsync(); - - return ResponseOutput.Ok(); - } - - - /// - /// 获取dicom 访视检查列表 (序列的 Id CreateTime 是否为空 代表了记录是否创建、IsConfirmed 代表 保存 确认) - /// - /// - [HttpPost] - public async Task GetVisitStudyAndSeriesList(VisitStudyAndSeriesQuery inQuery) - { - var studyList = await _repository.Where(s => s.SubjectVisitId == inQuery.SubjectVisitId).ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); - - var studyIds = studyList.Select(t => t.StudyId).ToList(); - - - var query = from series in _repository.Where(t => studyIds.Contains(t.StudyId)) - join visitStudyFilter in _subjectCriteriaEvaluationVisitStudyFilterRepository.Where(t => t.TrialReadingCriterionId == inQuery.TrialReadingCriterionId && t.SubjectVisitId == inQuery.SubjectVisitId) on series.Id equals visitStudyFilter.SeriesId into d - from visitStudyFilter in d.DefaultIfEmpty() - - select new SelectSeriesView() - { - Description = series.Description, - BodyPartExamined = series.BodyPartExamined, - BodyPartForEdit = series.BodyPartForEdit, - Modality = series.Modality, - SeriesInstanceUid = series.SeriesInstanceUid, - StudyCode = series.DicomStudy.StudyCode, - SeriesNumber = series.SeriesNumber, - SeriesTime = series.SeriesTime, - - InstanceCount = series.InstanceCount, - StudyTime = series.DicomStudy.StudyTime, - StudyId = series.StudyId, - SeriesId = series.Id, - SubjectVisitId = series.SubjectVisitId, - TrialReadingCriterionId = inQuery.TrialReadingCriterionId, - - - IsReading = visitStudyFilter.IsReading, - Id = visitStudyFilter.Id, - CreateTime = visitStudyFilter.CreateTime, - IsConfirmed = visitStudyFilter.IsConfirmed, - }; - - - var seriesList = query.ToList(); - - - - - return new SelctStudySeriesView { StudyList = studyList, SeriesList = seriesList }; - - } - - /// - /// 批量保存或者确认 选择的序列 - /// - /// - public async Task BatchAddSubjectCriteriaEvaluationVisitStudyFilter(List batchList) - { - - var ids = batchList.Where(t => t.Id != null).Select(t => t.Id).ToList(); - #region 稽查修改前 - - //await _subjectCriteriaEvaluationVisitStudyFilterRepository.BatchDeleteNoTrackingAsync(t => ids.Contains(t.Id)); - - //await _subjectCriteriaEvaluationVisitStudyFilterRepository.AddRangeAsync(_mapper.Map>(batchList)); - - #endregion - - - #region 查询再更新 - if (ids.Count > 0) - { - var list = await _subjectCriteriaEvaluationVisitStudyFilterRepository.Where(t => ids.Contains(t.Id), true).ToListAsync(); - - foreach (var item in list) - { - item.IsReading = batchList.FirstOrDefault(t => t.Id == item.Id)?.IsReading ?? item.IsReading; - item.IsConfirmed = batchList.FirstOrDefault(t => t.Id == item.Id)?.IsConfirmed ?? item.IsConfirmed; - } - } - else - { - await _subjectCriteriaEvaluationVisitStudyFilterRepository.AddRangeAsync(_mapper.Map>(batchList)); - } - #endregion - - - - - var first = batchList.First(); - - if (batchList.Count(t => t.IsReading == true) >= 0 && batchList.All(t => t.IsConfirmed == false)) - { - await _subjectCriteriaEvaluationVisitFilterRepository.UpdatePartialFromQueryAsync(t => t.SubjectVisitId == first.SubjectVisitId && t.TrialReadingCriterionId == first.TrialReadingCriterionId, - u => new SubjectCriteriaEvaluationVisitFilter() { ImageFilterState = ImageFilterState.Filtering }); - } - - if (batchList.All(t => t.IsConfirmed == true)) - { - - await _subjectCriteriaEvaluationVisitFilterRepository.UpdatePartialFromQueryAsync(t => t.SubjectVisitId == first.SubjectVisitId && t.TrialReadingCriterionId == first.TrialReadingCriterionId, - u => new SubjectCriteriaEvaluationVisitFilter() { ImageFilterState = ImageFilterState.Finished }); - } - - - - await _subjectCriteriaEvaluationVisitStudyFilterRepository.SaveChangesAsync(); - return ResponseOutput.Ok(); - - } - - - - /// - /// 附加评估标准 PM 退回某一访视 影响任务列表 - /// - /// - /// - [HttpPost] - - public async Task<(List, object)> GetCriteriaVisitBackInfluenceTaskList(CriteriaVisitBackCommand command) - { - - var isIRAppyTaskInfluenced = false; - - var filterExpression = await GetTaskExpressionAsync(command); - - var criterionConfig = (await _trialReadingCriterionRepository.Where(x => x.Id == command.TrialReadingCriterionId).Select(x => new { x.ReadingTool, x.IsReadingTaskViewInOrder }).FirstOrDefaultAsync()).IfNullThrowException(); - - var subjectVisit = await _subjectVisitRepository.FindAsync(command.SubjectVisitId); - - if (await _visitTaskReReadingRepository.AnyAsync(t => t.RequestReReadingType == RequestReReadingType.DocotorApply && t.RequestReReadingResultEnum == RequestReReadingResult.Default && - t.OriginalReReadingTask.VisitTaskNum >= subjectVisit.VisitNum && t.OriginalReReadingTask.SubjectId == subjectVisit.SubjectId && t.OriginalReReadingTask.TrialReadingCriterionId == command.TrialReadingCriterionId)) - { - isIRAppyTaskInfluenced = true; - } - - var list = await _visitTaskRepository.Where(filterExpression) - - .OrderBy(t => t.VisitTaskNum).ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); - foreach (var influenceTask in list) - { - - //重阅重置或者失效 - influenceTask.OptType = influenceTask.ReadingTaskState == ReadingTaskState.HaveSigned ? ReReadingOrBackOptType.Return : ReReadingOrBackOptType.Abandon; - } - - - return (list, new { IsIRAppyTaskInfluenced = isIRAppyTaskInfluenced }); - } - - private async Task>> GetTaskExpressionAsync(CriteriaVisitBackCommand command) - { - var criterionConfig = (await _trialReadingCriterionRepository.Where(x => x.Id == command.TrialReadingCriterionId).Select(x => new { x.ReadingTool, x.IsReadingTaskViewInOrder }).FirstOrDefaultAsync()).IfNullThrowException(); - - var subjectVisit = await _subjectVisitRepository.FirstOrDefaultAsync(t => t.Id == command.SubjectVisitId); - - //仅仅影响该标准自己的任务 - Expression> filterExpression = t => t.TrialId == command.TrialId && t.SubjectId == command.SubjectId && t.TaskState == TaskState.Effect && t.TaskAllocationState == TaskAllocationState.Allocated - && t.TrialReadingCriterionId == command.TrialReadingCriterionId; - - //有序 - if (criterionConfig.IsReadingTaskViewInOrder) - { - filterExpression = filterExpression.And(t => t.VisitTaskNum >= subjectVisit.VisitNum); - } - else - { - filterExpression = filterExpression.And(t => t.VisitTaskNum == subjectVisit.VisitNum); - } - - return filterExpression; - } - - /// - /// 退回任务 - /// - /// - /// - public async Task ConfirmBackCriteriaVisitTask(CriteriaVisitBackCommand command) - { - - var filterExpression = await GetTaskExpressionAsync(command); - - var influenceTaskList = await _visitTaskRepository.Where(filterExpression, true).ToListAsync(); - - var subjectVisit = await _subjectVisitRepository.FindAsync(command.SubjectVisitId); - - foreach (var influenceTask in influenceTaskList) - { - - if (influenceTask.ReadingTaskState == ReadingTaskState.HaveSigned) - { - influenceTask.TaskState = TaskState.HaveReturned; - } - else - { - influenceTask.TaskState = TaskState.Adbandon; - } - } - - var taskIdList = influenceTaskList.Select(t => t.Id).ToList(); - var subjectVisitIdLsit = influenceTaskList.Where(t => t.SourceSubjectVisitId != null).Select(t => t.SourceSubjectVisitId).ToList(); - - if (subjectVisitIdLsit.Count == 0) - { - subjectVisitIdLsit.Add(command.SubjectVisitId); - } - - //医学审核任务失效 - await _taskMedicalReviewRepository.UpdatePartialFromQueryAsync(t => taskIdList.Contains(t.VisitTaskId) && t.AuditState != MedicalReviewAuditState.HaveSigned, u => new TaskMedicalReview() { IsInvalid = true }); - - //将筛选的访视 序列状态重置 - - - //当前申请影像回退的访视 筛选状态重置,任务生成状态重置 - - - var otherVisitIdList = subjectVisitIdLsit.Where(t => t != command.SubjectVisitId).ToList(); - - await _subjectCriteriaEvaluationVisitFilterRepository.UpdatePartialFromQueryAsync(t => t.TrialReadingCriterionId == command.TrialReadingCriterionId && t.SubjectId == command.SubjectId && t.SubjectVisitId == command.SubjectVisitId, - t => new SubjectCriteriaEvaluationVisitFilter() - { - ImageFilterState = ImageFilterState.None, - ImageDeterminationResultState = ImageDeterminationResultState.None, - IsGeneratedTask = false - }); - - //删除序列数据 - await _subjectCriteriaEvaluationVisitStudyFilterRepository.BatchDeleteNoTrackingAsync(t => t.TrialReadingCriterionId == command.TrialReadingCriterionId && t.SubjectVisitId == command.SubjectVisitId); - - //BM后续访视 ,筛选状态不变,任务生成状态重置(实际该访视任务状态 可能是重阅重置了或者失效了,需要后续生成,或者取消分配了,需要后续重新分配) - await _subjectCriteriaEvaluationVisitFilterRepository.BatchUpdateNoTrackingAsync(t => t.TrialReadingCriterionId == command.TrialReadingCriterionId && t.SubjectId == command.SubjectId && otherVisitIdList.Contains(t.SubjectVisitId), - t => new SubjectCriteriaEvaluationVisitFilter() - { - IsGeneratedTask = false - }); - - - - - await _visitTaskRepository.SaveChangesAsync(); - } - } -} diff --git a/IRaCIS.Core.Application/Service/Reading/_MapConfig.cs b/IRaCIS.Core.Application/Service/Reading/_MapConfig.cs index 1f39bf5a9..ebd59056e 100644 --- a/IRaCIS.Core.Application/Service/Reading/_MapConfig.cs +++ b/IRaCIS.Core.Application/Service/Reading/_MapConfig.cs @@ -303,11 +303,7 @@ namespace IRaCIS.Core.Application.Service // .ForMember(d => d.SubjectStatus, u => u.MapFrom(s => s.subject.Status)); - CreateMap().ReverseMap(); - CreateMap().ReverseMap(); - CreateMap().ReverseMap(); - - CreateMap().ReverseMap(); + CreateMap() .ForMember(o => o.UploadedTime, t => t.MapFrom(u => u.CreateTime)) diff --git a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs index bc25e676f..afdf8c648 100644 --- a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs +++ b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs @@ -28,14 +28,12 @@ namespace IRaCIS.Core.Application.Contracts private readonly IRepository _trialSiteUserSurveyRepository; private readonly IRepository _userRepository; private readonly IRepository _trialSiteRepository; - private readonly IRepository _doctorRepository; private readonly IRepository _trialUserRepository; private readonly ITokenService _tokenService; private readonly IMailVerificationService _mailVerificationService; public TrialSiteSurveyService(IRepository trialSiteSurveyRepository, IRepository trialUserRepository, IRepository trialSiteUserSurveyRepository, IRepository userRepository, IRepository trialSiteRepository, - IRepository doctorRepository, ITokenService tokenService, IMailVerificationService mailVerificationService) { @@ -44,7 +42,6 @@ namespace IRaCIS.Core.Application.Contracts _userRepository = userRepository; _trialUserRepository = trialUserRepository; _trialSiteRepository = trialSiteRepository; - this._doctorRepository = doctorRepository; _tokenService = tokenService; _mailVerificationService = mailVerificationService; } @@ -86,11 +83,6 @@ namespace IRaCIS.Core.Application.Contracts var verificationRecord = await _repository.GetQueryable().OrderByDescending(x => x.ExpirationTime).Where(t => (t.EmailOrPhone == inDto.EmailOrPhone) && t.Code == inDto.VerificationCode && t.CodeType == VerifyType.Email).FirstOrDefaultAsync(); VerifyEmialGetDoctorInfoOutDto result = new VerifyEmialGetDoctorInfoOutDto(); - var doctorInfo = await _doctorRepository.Where(x => x.EMail == inDto.EmailOrPhone).FirstOrDefaultAsync(); - - result.DoctorId = doctorInfo == null ? null : doctorInfo.Id; - result.ReviewStatus = doctorInfo == null ? null : doctorInfo.ReviewStatus; - //检查数据库是否存在该验证码 if (verificationRecord == null) { diff --git a/IRaCIS.Core.Application/Service/Stat/IStatisticsService.cs b/IRaCIS.Core.Application/Service/Stat/IStatisticsService.cs index c597a3221..55dee8526 100644 --- a/IRaCIS.Core.Application/Service/Stat/IStatisticsService.cs +++ b/IRaCIS.Core.Application/Service/Stat/IStatisticsService.cs @@ -7,37 +7,12 @@ namespace IRaCIS.Application.Interfaces { public interface IStatisticsService { - Task> GetWorkloadByTrialAndReviewer(StatisticsWorkloadQueryParam param); - - PageOutput GetEnrollStatByTrial(EnrollStatByTrialQueryDTO param); PageOutput GetParticipateTrialStat(ParticipateQueryDto param); List GetParticipateTrialList(Guid userId); - #region Dashboard 数据统计 - /// 按类型统计读片数量 - ReadingDataDTO GetReadingDataByType(); + - /// 按月份统计读片数量 - List GetReadingDataByMonth(int monthCount); - - /// 读片数量排行 - List GetReadingDataRank(int topCount); - - /// 按Position统计 Reviewers 数量 - List GetReviewersByRank(); - - /// 每月入组人次 - List GetEnrollDataByQuarter(int quarterCount, int monthCount); - - /// 参与项目数排行 - List GetTrialCountRank(int topCount); - - /// 最新工作量 (已确定的) - List GetLatestWorkLoadList( int searchCount); - #endregion - - Task> GetEnrollStatByReviewer(EnrollStatByReviewerQueryDTO enrollTrialStatisticsQueryParam); } } diff --git a/IRaCIS.Core.Application/Service/Stat/StatisticsService.cs b/IRaCIS.Core.Application/Service/Stat/StatisticsService.cs index c13ae8372..42ec6fc81 100644 --- a/IRaCIS.Core.Application/Service/Stat/StatisticsService.cs +++ b/IRaCIS.Core.Application/Service/Stat/StatisticsService.cs @@ -14,380 +14,39 @@ namespace IRaCIS.Application.Services [ApiExplorerSettings(GroupName = "Dashboard&Statistics")] public class StatisticsService : BaseService, IStatisticsService { - private readonly IRepository _doctorRepository; private readonly IRepository _trialRepository; - private readonly IRepository _enrollRepository; - private readonly IRepository _workloadRepository; private readonly IRepository _croCompanyRepository; private readonly IRepository _dictionaryRepository; private readonly IRepository _hospitalRepository; - private readonly IRepository _enrollDetailRepository; private readonly IRepository _userRepository; private readonly IRepository _userTrialRepository; - public StatisticsService(IRepository doctorRepository, IRepository trialRepository, - IRepository intoGroupRepository, IRepository workloadRepository, + public StatisticsService( IRepository trialRepository, + IRepository croCompanyRepository, IRepository dictionaryRepository, IRepository hospitalRepository, - IRepository enrollDetailRepository, IRepository userRepository, + IRepository userRepository, IRepository userTrialRepository) { - _doctorRepository = doctorRepository; + _trialRepository = trialRepository; - _enrollRepository = intoGroupRepository; - _workloadRepository = workloadRepository; + + _croCompanyRepository = croCompanyRepository; _dictionaryRepository = dictionaryRepository; _hospitalRepository = hospitalRepository; - _enrollDetailRepository = enrollDetailRepository; + _userRepository = userRepository; _userTrialRepository = userTrialRepository; } - /// 根据项目和医生,分页获取工作量统计[New] - [HttpPost] - public async Task> GetWorkloadByTrialAndReviewer( - StatisticsWorkloadQueryParam param) - { - var bDate = new DateTime(param.BeginDate.Year, param.BeginDate.Month, param.BeginDate.Day); - var eDate = new DateTime(param.EndDate.Year, param.EndDate.Month, param.EndDate.Day); - eDate = eDate.AddDays(1); - Expression> workloadLambda = x => x.DataFrom == (int)WorkLoadFromStatus.FinalConfirm; - workloadLambda = workloadLambda.And(x => x.WorkTime >= bDate && x.WorkTime < eDate); - Expression> trialLambda = x => true; - if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.SuperAdmin) //超级管理员按照条件查询所有 - { - if (param.CroId != null) - { - trialLambda = trialLambda.And(u => u.CROId == param.CroId); - } - } - - else //不管是精鼎的pm还是我们的pm 还是运维人员 只能看到自己参与项目的统计 - { - List trialIdList = _userTrialRepository.Where(u => u.UserId == _userInfo.Id).Select(u => u.TrialId).ToList(); - trialLambda = trialLambda.And(u => trialIdList.Contains(u.Id)); - } - if (!string.IsNullOrWhiteSpace(param.TrialCode)) - { - trialLambda = trialLambda.And(u => u.TrialCode.Contains(param.TrialCode)); - } - - Expression> doctorLambda = x => true; - if (!string.IsNullOrWhiteSpace(param.Reviewer)) - { - - var reviewer = param.Reviewer.Trim(); - doctorLambda = doctorLambda.And(u => u.ChineseName.Contains(reviewer) - || u.FirstName.Contains(reviewer) - || u.LastName.Contains(reviewer) - || u.ReviewerCode.Contains(reviewer) - ); - - } - if (Guid.Empty != param.HospitalId && param.HospitalId != null) - { - doctorLambda = doctorLambda.And(u => u.HospitalId == param.HospitalId); - } - - var workloadQuery = from workLoad in _workloadRepository.Where(workloadLambda) - join trial in _trialRepository.Where(trialLambda) on workLoad.TrialId equals trial.Id - join doctor in _doctorRepository.Where(doctorLambda) on workLoad.DoctorId equals doctor.Id - group workLoad by new { workLoad.DoctorId, workLoad.TrialId } into gWorkLoad - - select new - { - DoctorId = gWorkLoad.Key.DoctorId, - TrialId = gWorkLoad.Key.TrialId, - Downtime = gWorkLoad.Sum(t => t.Downtime), - Training = gWorkLoad.Sum(t => t.Training), - Timepoint = gWorkLoad.Sum(t => t.Timepoint), - TimepointIn24H = gWorkLoad.Sum(t => t.TimepointIn24H), - TimepointIn48H = gWorkLoad.Sum(t => t.TimepointIn48H), - Global = gWorkLoad.Sum(t => t.Global), - Adjudication = gWorkLoad.Sum(t => t.Adjudication), - AdjudicationIn24H = gWorkLoad.Sum(t => t.AdjudicationIn24H), - AdjudicationIn48H = gWorkLoad.Sum(t => t.AdjudicationIn48H), - RefresherTraining = gWorkLoad.Sum(t => t.RefresherTraining), - - }; - var query = from w in workloadQuery - join trial in _trialRepository.Where(trialLambda) on w.TrialId equals trial.Id into t - from trialItem in t.DefaultIfEmpty() - join doctor in _doctorRepository.Where(doctorLambda) on w.DoctorId equals doctor.Id into tt - from doctorItem in tt.DefaultIfEmpty() - join cro in _croCompanyRepository.AsQueryable() on trialItem.CROId equals cro.Id into ttt - from croItem in ttt.DefaultIfEmpty() - select new WorkloadByTrialAndReviewerDTO - { - Id = Guid.NewGuid(), - TrialId = trialItem.Id, - Indication = trialItem.Indication, - TrialCode = trialItem.TrialCode, - CroId = trialItem.CROId, - Cro = croItem.CROName, - ReviewerCode = doctorItem.ReviewerCode, - ChineseName = doctorItem.ChineseName, - FirstName = doctorItem.FirstName, - LastName = doctorItem.LastName, - FullName = doctorItem.FullName, - Training = w.Training, - Timepoint = w.Timepoint, - TimepointIn24H = w.TimepointIn24H, - TimepointIn48H = w.TimepointIn48H, - Adjudication = w.Adjudication, - AdjudicationIn24H = w.AdjudicationIn24H, - AdjudicationIn48H = w.AdjudicationIn48H, - Global = w.Global, - Downtime = w.Downtime, - RefresherTraining = w.RefresherTraining, - - PersonalTotal = w.Timepoint + w.TimepointIn24H + w.TimepointIn48H + w.Adjudication + w.AdjudicationIn24H + - w.AdjudicationIn48H + w.Global - }; - - - return await query.ToPagedListAsync(param.PageIndex, param.PageSize, string.IsNullOrWhiteSpace(param.SortField) ? "ReviewerCode" : param.SortField, param.Asc); - - //var propName = param.SortField == "" ? "ReviewerCode" : param.SortField; - //query = param.Asc - // ? query.OrderBy(propName).ThenBy(t => t.TrialCode).ThenBy(u => u.ReviewerCode) - // : query.OrderByDescending(propName).ThenBy(t => t.TrialCode).ThenBy(u => u.ReviewerCode); - - - //if (propName == "FirstName" || propName == "LastName") - //{ - // query = param.Asc - // ? query.OrderBy(t => t.LastName).ThenBy(t => t.FirstName) - // : query.OrderByDescending(t => t.LastName).ThenBy(t => t.FirstName); - //} - //var count = query.Count(); - - //query = query - // .Skip((param.PageIndex - 1) * param.PageSize) - // .Take(param.PageSize); - //var doctorViewList = query.ToList(); - - //return new PageOutput(param.PageIndex, param.PageSize, count, doctorViewList); - } - - - - /// 项目入组 医生维度统计[New] - [HttpPost] - public async Task> GetEnrollStatByReviewer(EnrollStatByReviewerQueryDTO param) - { - var bDate = new DateTime(param.BeginDate.Year, param.BeginDate.Month, 1); - var eDate = new DateTime(param.EndDate.Year, param.EndDate.Month, 1); - eDate = eDate.AddMonths(1); - - Expression> enrollLambda = x => true; - enrollLambda = enrollLambda.And(x => x.EnrollTime >= bDate && x.EnrollTime < eDate); - - Expression> hospitalLambda = x => true; - if (Guid.Empty != param.HospitalId && param.HospitalId != null) - { - hospitalLambda = hospitalLambda.And(u => u.Id == param.HospitalId); - } - - Expression> doctorLambda = x => true; - if (!string.IsNullOrWhiteSpace(param.Reviewer)) - { - - var reviewer = param.Reviewer.Trim(); - doctorLambda = doctorLambda.And(u => u.ChineseName.Contains(reviewer) - || u.FirstName.Contains(reviewer) - || u.LastName.Contains(reviewer) - || u.ReviewerCode.Contains(reviewer) - ); - } - - var enrollQueryable = - from enroll in _enrollRepository.Where(enrollLambda) - group enroll by new { enroll.DoctorId } - into g - select new - { - DoctorId = g.Key.DoctorId, - Submitted = g.Sum(t => - t.EnrollStatus == EnrollStatus.HasCommittedToCRO ? 1 : 0), - Approved = g.Sum(t => - t.EnrollStatus == EnrollStatus.InviteIntoGroup ? 1 : 0), - Reading = g.Sum(t => - t.EnrollStatus == EnrollStatus.DoctorReading ? 1 : 0), - Finished = g.Sum(t => - t.EnrollStatus >= EnrollStatus.Finished ? 1 : 0), - }; - - - var query = from w in enrollQueryable - - join doctor in _doctorRepository.Where(doctorLambda) on w.DoctorId equals doctor.Id - join hospital in _hospitalRepository.Where(hospitalLambda) on doctor.HospitalId equals hospital.Id - select new EnrollStatByReviewerDTO - { - Id = Guid.NewGuid(), - Hospital = hospital.HospitalName, - ReviewerCode = doctor.ReviewerCode, - ChineseName = doctor.ChineseName, - FirstName = doctor.FirstName, - LastName = doctor.LastName, - FullName = doctor.FullName, - Pending = w.Submitted, - Approved = w.Approved, - Reading = w.Reading, - Finished = w.Finished, - - Total = w.Submitted + w.Approved + w.Reading + w.Finished - }; - - - var pageData = await query.ToPagedListAsync(param.PageIndex, param.PageIndex, param.SortField == "" ? "ReviewerCode" : param.SortField, param.Asc); - - if (param.SortField == "EntryRate") - { - pageData.CurrentPageData.OrderBy(t => t.EntryRate); - } - - return pageData; - - //var count = query.Count(); - //query = query - // .Skip((param.PageIndex - 1) * param.PageSize) - // .Take(param.PageSize); - //var list = query.ToList(); - - //if (param.SortField == "EntryRate") - //{ - // list = param.Asc - // ? list.OrderBy(t => t.EntryRate).ToList() - // : list.OrderByDescending(t => t.EntryRate).ToList(); - //} - - //return new PageOutput(param.PageIndex, param.PageSize, count, list); - } - - [HttpPost] - public PageOutput GetEnrollStatByTrial(EnrollStatByTrialQueryDTO param) - { - - #region 筛选条件 - - Expression> trialLambda = x => true; - - if (param.Expedited != null) - { - trialLambda = trialLambda.And(o => o.Expedited == param.Expedited); - } - - if (!string.IsNullOrEmpty(param.TrialCode)) - { - var code = param.TrialCode.Trim(); - trialLambda = trialLambda.And(o => o.TrialCode.Contains(code)); - } - - if (!string.IsNullOrWhiteSpace(param.Indication)) - { - var indication = param.Indication.Trim(); - trialLambda = trialLambda.And(o => o.Indication.Contains(indication)); - } - - if (param.CROId != null) - { - trialLambda = trialLambda.And(o => o.CROId == param.CROId); - } - - - if (param.BeginDate != null && param.EndDate != null) - { - var bDate = new DateTime(param.BeginDate.Value.Year, param.BeginDate.Value.Month, param.BeginDate.Value.Day); - var eDate = new DateTime(param.EndDate.Value.Year, param.EndDate.Value.Month, param.BeginDate.Value.Day); - eDate = eDate.AddMonths(1); - - trialLambda = trialLambda.And(o => o.CreateTime >= bDate && o.CreateTime < eDate); - - } - - #endregion - - var trialEnrollStatQuery = _enrollRepository.AsQueryable() - .Where(t => t.EnrollStatus >= EnrollStatus.ConfirmIntoGroup).GroupBy(t => t.TrialId).Select(g => new - { - TrialId = g.Key, - EnrollCount = g.Count() - }); - - var trialQuery = from trial in _trialRepository.Where(trialLambda) - join cro in _croCompanyRepository.AsQueryable() on trial.CROId equals cro.Id into t - from cro in t.DefaultIfEmpty() - - join trialEnroll in trialEnrollStatQuery on trial.Id equals trialEnroll.TrialId - select new EnrollStatByTrialDTO - { - TrialId = trial.Id, - Cro = cro != null ? cro.CROName : "", - Expedited = trial.Expedited, - Indication = trial.Indication, - TrialCode = trial.TrialCode, - EnrollCount = trialEnroll.EnrollCount, - CreateTime = trial.CreateTime - }; - - var propName = param.SortField == "" ? "TrialCode" : param.SortField; - trialQuery = param.Asc - ? trialQuery.OrderBy(propName) - : trialQuery.OrderBy(propName + " desc"); - - var count = trialQuery.Count(); - - trialQuery = trialQuery - .Skip((param.PageIndex - 1) * param.PageSize) - .Take(param.PageSize); - - var trialList = trialQuery.ToList(); - - var trialIds = trialList.Select(t => t.TrialId).ToList(); - - var enrollReviewerQuery = from enroll in _enrollRepository.AsQueryable() - .Where(t => t.EnrollStatus >= EnrollStatus.ConfirmIntoGroup && trialIds.Contains(t.TrialId)) - join reviewer in _doctorRepository.AsQueryable() on enroll.DoctorId equals reviewer.Id - - select new - { - TrialId = enroll.TrialId, - NameCN = reviewer.ChineseName, - Name = reviewer.LastName + " / " + reviewer.FirstName - }; - var enrollReviewerByTrialList = enrollReviewerQuery.ToList().GroupBy(t => t.TrialId).Select(g => new - { - TrialId = g.Key, - ReviewerNameCNList = g.Select(t => t.NameCN).ToList(), - ReviewerNameList = g.Select(t => t.Name).ToList() - }).ToList(); - - - trialList.ForEach(t => - { - var trialDoctors = enrollReviewerByTrialList.FirstOrDefault(u => u.TrialId == t.TrialId); - - if (trialDoctors != null) - { - t.ReviewerNameCNList = trialDoctors.ReviewerNameCNList; - t.ReviewerNameList = trialDoctors.ReviewerNameList; - } - }); - - - return new PageOutput(param.PageIndex, param.PageSize, count, trialList); - - } /// 用户参与项目 统计[New] [HttpPost] @@ -497,355 +156,8 @@ namespace IRaCIS.Application.Services #region Dashboard 数据统计 - /// 读片数分类统计[New] - public ReadingDataDTO GetReadingDataByType() - { - int tp = 0; int ad = 0; int g = 0; - var finalConfirmWorkload = _workloadRepository.Where(u => u.DataFrom == (int)WorkLoadFromStatus.FinalConfirm).ToList(); - foreach (var item in finalConfirmWorkload) - { - tp += (item.Timepoint + item.TimepointIn24H + item.TimepointIn48H); - ad += (item.Adjudication + item.AdjudicationIn24H + item.AdjudicationIn48H); - g += item.Global; - } - return new ReadingDataDTO - { - Timepoint = tp, - Adjudication = ad, - Global = g - }; - } - /// 获取最近几个月份的数据[New] - [HttpGet, Route("{monthCount:int}")] - public List GetReadingDataByMonth(int monthCount) - { - DateTime now = DateTime.Now.AddMonths(-1); - DateTime eTime = new DateTime(now.Year, now.Month, 20); - - DateTime now6 = now.AddMonths(-1 * (monthCount - 1)); - DateTime bTime = new DateTime(now.AddMonths(-(monthCount - 1)).Year, - now.AddMonths(-(monthCount - 1)).Month, 1, 0, 0, 0, 0); - - var query = from workload in _workloadRepository - .Where(u => u.DataFrom == (int)WorkLoadFromStatus.FinalConfirm && - u.WorkTime >= bTime && u.WorkTime < eTime) - group workload by workload.YearMonth - into gWorkLoad - select new ReadingDataMonthDTO - { - Month = gWorkLoad.Key, - Timepoint = gWorkLoad.Sum(t => t.Timepoint) + gWorkLoad.Sum(t => t.TimepointIn24H) - + gWorkLoad.Sum(t => t.TimepointIn48H), - Adjudication = gWorkLoad.Sum(t => t.Adjudication) + gWorkLoad.Sum(t => t.AdjudicationIn24H) - + gWorkLoad.Sum(t => t.AdjudicationIn48H), - Global = gWorkLoad.Sum(t => t.Global) - }; - var workloadList = query.OrderByDescending(u => u.Month).ToList(); - List result = new List(); - - for (int i = 0; i < monthCount; i++) - { - var tempTime = now.AddMonths(-1 * i); - var existedItem = workloadList.Find(u => u.Month == - (tempTime.Year + "-" + tempTime.Month.ToString().PadLeft(2, '0'))); - if (existedItem != null) - { - result.Add(new ReadingDataMonthDTO - { - Month = existedItem.Month, - Timepoint = existedItem.Timepoint, - Adjudication = existedItem.Adjudication, - Global = existedItem.Global - }); - } - else - { - result.Add(new ReadingDataMonthDTO - { - Month = tempTime.Year + "-" + tempTime.Month.ToString().PadLeft(2, '0'), - Timepoint = 0, - Adjudication = 0, - Global = 0 - }); - } - } - return result; - } - /// 读片数量排行前几的数据[New] - [HttpGet("{topCount:int}")] - public List GetReadingDataRank(int topCount) - { - var query = from workload in _workloadRepository - .Where(u => u.DataFrom == (int)WorkLoadFromStatus.FinalConfirm) - group workload by workload.DoctorId - into gWorkLoad - - select new ReadingDataRankDTO - { - TotalReadingCount = gWorkLoad.Sum(t => t.Timepoint) + gWorkLoad.Sum(t => t.TimepointIn24H) - + gWorkLoad.Sum(t => t.TimepointIn48H) + gWorkLoad.Sum(t => t.Adjudication) + gWorkLoad.Sum(t => t.AdjudicationIn24H) - + gWorkLoad.Sum(t => t.AdjudicationIn48H) + gWorkLoad.Sum(t => t.Global), - ReviewerId = gWorkLoad.Key, - Timepoint = gWorkLoad.Sum(t => t.Timepoint) + gWorkLoad.Sum(t => t.TimepointIn24H) - + gWorkLoad.Sum(t => t.TimepointIn48H), - Adjudication = gWorkLoad.Sum(t => t.Adjudication) + gWorkLoad.Sum(t => t.AdjudicationIn24H) - + gWorkLoad.Sum(t => t.AdjudicationIn48H), - Global = gWorkLoad.Sum(t => t.Global) - }; - var workloadList = query.OrderByDescending(u => u.TotalReadingCount).Take(topCount).ToList(); - var reviewerList = from w in workloadList - join doctor in _doctorRepository.Where() on w.ReviewerId equals doctor.Id into tt - from doctorItem in tt.DefaultIfEmpty() - select new ReadingDataRankDTO - { - TotalReadingCount = w.TotalReadingCount, - ReviewerId = w.ReviewerId, - Timepoint = w.Timepoint, - Adjudication = w.Adjudication, - Global = w.Global, - ReviewerCode = doctorItem.ReviewerCode, - FirstName = doctorItem.FirstName, - LastName = doctorItem.LastName, - ChineseName = doctorItem.ChineseName - }; - return reviewerList.ToList(); - } - - /// 按Rank统计Reviewer 数量[New] - public List GetReviewersByRank() - { - var query = from q in (from reviewer in _doctorRepository.AsQueryable() - //.Find(u => u.ReviewStatus == 1 && u.CooperateStatus == 1) - group reviewer by reviewer.RankId - into gReviewer - select new - { - RankId = gReviewer.Key, - ReviewerCount = gReviewer.Count() - }) - - join dic in _dictionaryRepository.Where() on q.RankId equals dic.Id into tt - from dicItem in tt.DefaultIfEmpty() - select new RankReviewersDTO - { - RankId = q.RankId, - ReviewerCount = q.ReviewerCount, - RankName = dicItem == null ? "Other" : dicItem.Value - }; - - var rankList = query.ToList(); - var staffList = rankList.Where(u => u.RankName == "Staff" || u.RankName == "Other"); - int staffCount = 0; - foreach (var item in staffList) - { - staffCount += item.ReviewerCount; - } - rankList.RemoveAll(u => u.RankName == "Staff" || u.RankName == "Other"); - - rankList.Add(new RankReviewersDTO { RankId = Guid.NewGuid(), RankName = "Staff", ReviewerCount = staffCount }); - - return rankList; - } - /// 最近几个季度入组人次[New] type==0 按照月份 - [HttpGet("{type:int}/{count:int}")] - public List GetEnrollDataByQuarter(int type, int count) - { - //等于0按照月份 否则按照季度 - if (type != 0) - { - var quarterCount = count; - var year = DateTime.Now.AddMonths(-(quarterCount - 1) * 3 - DateTime.Now.Month % 3 + 1).Year; - var month = DateTime.Now.AddMonths(-(quarterCount - 1) * 3 - DateTime.Now.Month % 3 + 1).Month; - - var beginMonth = new DateTime(year, month, 1); - - var endMonth = DateTime.Now; - var querySql = from enrollDetail in _enrollDetailRepository.Where(t => - t.CreateTime > beginMonth && t.CreateTime < endMonth && - t.EnrollStatus == EnrollStatus.ConfirmIntoGroup) - select new - { - - OptTime = enrollDetail.CreateTime, - Year = enrollDetail.CreateTime.Year, - Month = enrollDetail.CreateTime.Month, - }; - - var result = querySql.GroupBy(t => new { t.Year, t.Month }).Select(s => new EnrollDataDTO - { - Year = s.Key.Year, - Month = s.Key.Month, - EnrollCount = s.Count() - }).ToList(); - - - #region 填充数据 - - List returnList = new List(); - for (int i = 0; i < DateTime.Now.Month % 3 + (quarterCount - 1) * 3; i++) - { - var tempTime = DateTime.Now.AddMonths(-1 * i); - var existedItem = result.FirstOrDefault(u => u.YearMonth == tempTime.ToString("yyyy-MM")); - if (existedItem != null) - { - returnList.Add(new EnrollDataDTO - { - Month = existedItem.Month, - Year = existedItem.Year, - EnrollCount = existedItem.EnrollCount - }); - } - else - { - returnList.Add(new EnrollDataDTO - { - Month = tempTime.Month, - Year = tempTime.Year, - EnrollCount = 0 - }); - } - } - - #endregion - - var returnResult = returnList.GroupBy(t => t.QuarterStr).Select(u => new EnrollQuartDataDTO() - { - ViewStr = u.Key, - EnrollCount = u.Sum(t => t.EnrollCount) - }).ToList(); - - return returnResult; - } - else - { - var year = DateTime.Now.AddMonths(-(count - 1)).Year; - var month = DateTime.Now.AddMonths(-(count - 1)).Month; - - var beginMonth = new DateTime(year, month, 1); - - var endMonth = DateTime.Now; - var querySql = from enrollDetail in _enrollDetailRepository.Where(t => - t.CreateTime > beginMonth && t.CreateTime < endMonth && - t.EnrollStatus == EnrollStatus.ConfirmIntoGroup) - select new - { - - OptTime = enrollDetail.CreateTime, - Year = enrollDetail.CreateTime.Year, - Month = enrollDetail.CreateTime.Month, - }; - - var result = querySql.GroupBy(t => new { t.Year, t.Month }).Select(s => new EnrollDataDTO - { - Year = s.Key.Year, - Month = s.Key.Month, - EnrollCount = s.Count() - }).ToList(); - - #region 填充数据 - - List returnList = new List(); - for (int i = 0; i < count; i++) - { - var tempTime = DateTime.Now.AddMonths(-1 * i); - var existedItem = result.FirstOrDefault(u => u.YearMonth == tempTime.ToString("yyyy-MM")); - if (existedItem != null) - { - returnList.Add(new EnrollDataDTO - { - Month = existedItem.Month, - Year = existedItem.Year, - EnrollCount = existedItem.EnrollCount - }); - } - else - { - returnList.Add(new EnrollDataDTO - { - Month = tempTime.Month, - Year = tempTime.Year, - EnrollCount = 0 - }); - } - } - - #endregion - - var returnResult = returnList.GroupBy(t => t.YearMonth).Select(u => new EnrollQuartDataDTO() - { - ViewStr = u.Key, - EnrollCount = u.Sum(t => t.EnrollCount) - }).ToList(); - - return returnResult; - } - - } - /// 参与项目数排行 [New] - [HttpGet("{topCount:int}")] - public List GetTrialCountRank(int topCount) - { - var queryList = (from enrollDetail in _enrollDetailRepository.Where(t => - t.EnrollStatus == EnrollStatus.ConfirmIntoGroup) - group enrollDetail by enrollDetail.DoctorId - into g - select new - { - ReviewerId = g.Key, - TrialCount = g.Count() - }).OrderByDescending(u => u.TrialCount).Take(topCount).ToList(); - - var trialDataRank = from stat in queryList - join doctor in _doctorRepository.AsQueryable() on stat.ReviewerId equals doctor.Id - select new TrialDataRankDTO() - { - TrialCount = stat.TrialCount, - ChineseName = doctor.ChineseName, - FirstName = doctor.FirstName, - LastName = doctor.LastName, - ReviewerId = doctor.Id, - ReviewerCode = doctor.ReviewerCode - }; - return trialDataRank.ToList(); - - } - /// 最新工作量 (已确定的)[New] - [HttpGet("{searchCount:int}")] - public List GetLatestWorkLoadList(int searchCount) - { - var workloadList = _workloadRepository.AsQueryable() - .Where(t => t.DataFrom == (int)WorkLoadFromStatus.FinalConfirm && - (t.Adjudication + t.AdjudicationIn24H + t.AdjudicationIn48H) > 0 && - (t.Timepoint + t.TimepointIn24H + t.TimepointIn48H) > 0) - .OrderByDescending(t => t.CreateTime).Take(searchCount).ToList(); - - - var reviewerList = from w in workloadList - join doctor in _doctorRepository.Where() on w.DoctorId equals doctor.Id into tt - from doctorItem in tt.DefaultIfEmpty() - join trial in _trialRepository.AsQueryable() on w.TrialId equals trial.Id into cc - from trialItem in cc.DefaultIfEmpty() - select new LatestWorkLoadDTO - { - - ReviewerId = w.DoctorId, - Timepoint = w.Timepoint + w.TimepointIn48H + w.TimepointIn24H, - Adjudication = w.Adjudication + w.AdjudicationIn48H + w.AdjudicationIn24H, - Global = w.Global, - ReviewerCode = doctorItem.ReviewerCode, - FirstName = doctorItem.FirstName, - LastName = doctorItem.LastName, - ChineseName = doctorItem.ChineseName, - - TrialCode = trialItem.TrialCode - }; - return reviewerList.ToList(); - - - } - - - + + #endregion } diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/Interface/ITrialService.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/Interface/ITrialService.cs index ff2193eb0..563ae4f45 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/Interface/ITrialService.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/Interface/ITrialService.cs @@ -10,14 +10,11 @@ namespace IRaCIS.Application.Interfaces Task> AddOrUpdateTrial(TrialCommand trialAddModel); Task DeleteTrial(Guid trialId); - Task> GetReviewerTrialListByEnrollmentStatus(TrialByStatusQueryDTO param); - Task> GetTrialEnrollmentReviewerIds(Guid trialId); + Task GetTrialExpeditedState(Guid trialId); Task GetTrialInfoAndLockState(Guid projectId); Task GetTrialInfoAndMaxTrialState(Guid trialId); Task> GetTrialList(TrialQueryDTO searchParam); - Task> GetTrialListByReviewer(ReviewerTrialQueryDTO searchModel); - Task GetTrialMaxState(Guid trialId); - Task UpdateEnrollStatus(Guid trialId, EnrollStatus status); + } } \ No newline at end of file diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/PersonalWorkstation.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/PersonalWorkstation.cs index 91b06c204..71cd81d3c 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/PersonalWorkstation.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/PersonalWorkstation.cs @@ -262,40 +262,6 @@ namespace IRaCIS.Core.Application } - /// - ///PM 阅片人筛选 -- PM APM 待办 - /// - /// - /// - /// - /// vvv - [HttpPost] - public async Task>> GetPM_ReviewerSelectToBeDoneList(ReviewerSelectToBeDoneQuery inQuery - , [FromServices] IRepository _enrollRepository, - [FromServices] IRepository _trialRepository) - { - var query = _trialRepository - .Where(t => t.TrialUserList.Any(t => t.UserId == _userInfo.Id)) - .Select(t => new ReviewerSelectToBeDoneDto() - { - TrialId = t.Id, - ResearchProgramNo = t.ResearchProgramNo, - ExperimentName = t.ExperimentName, - TrialCode = t.TrialCode, - - IsUrgent = t.IsUrgent || t.IsSubjectExpeditedView, - ToBeApprovalCount = t.EnrollList.Where(u => u.EnrollStatus == EnrollStatus.InviteIntoGroup).Count() - }).Where(x => x.ToBeApprovalCount > 0); - - var result = await query.ToPagedListAsync(inQuery.PageIndex, inQuery.PageSize, string.IsNullOrEmpty(inQuery.SortField) ? nameof(ReviewerSelectToBeDoneDto.TrialId) : inQuery.SortField, inQuery.Asc); - - var toBeApprovalCount = await _enrollRepository.Where(t => t.Trial.TrialUserList.Any(t => t.UserId == _userInfo.Id)) - .Where(u => u.EnrollStatus == EnrollStatus.HasCommittedToCRO).CountAsync(); - - return ResponseOutput.Ok(result, new { ToBeApprovalCount = toBeApprovalCount }); ; - - } - /// /// 获取PM核对临床数据 @@ -339,39 +305,6 @@ namespace IRaCIS.Core.Application #region SPM CPM 待办 - /// - ///SPM 阅片人筛选 - /// - /// - /// - /// - /// vvv - [HttpPost] - public async Task>> GetSPM_ReviewerSelectToBeDoneList(ReviewerSelectToBeDoneQuery inQuery - , [FromServices] IRepository _enrollRepository, - [FromServices] IRepository _trialRepository) - { - var query = _trialRepository - .Where(t => t.TrialUserList.Any(t => t.UserId == _userInfo.Id)) - .Select(t => new ReviewerSelectToBeDoneDto() - { - TrialId = t.Id, - ResearchProgramNo = t.ResearchProgramNo, - ExperimentName = t.ExperimentName, - TrialCode = t.TrialCode, - - IsUrgent = t.IsUrgent || t.IsSubjectExpeditedView, - ToBeApprovalCount = t.EnrollList.Where(u => u.EnrollStatus == EnrollStatus.HasCommittedToCRO).Count() - }).Where(x => x.ToBeApprovalCount > 0) ; - - var result = await query.ToPagedListAsync(inQuery.PageIndex, inQuery.PageSize, string.IsNullOrEmpty(inQuery.SortField) ? nameof(ReviewerSelectToBeDoneDto.TrialId) : inQuery.SortField, inQuery.Asc); - - var toBeApprovalCount = await _enrollRepository.Where(t => t.Trial.TrialUserList.Any(t => t.UserId == _userInfo.Id)) - .Where(u => u.EnrollStatus == EnrollStatus.HasCommittedToCRO).CountAsync(); - - return ResponseOutput.Ok(result, new { TotalToBeApprovalCount = toBeApprovalCount }); ; - - } /// /// SPM 重阅审批 @@ -811,7 +744,7 @@ namespace IRaCIS.Core.Application // 前序 不存在 未一致性核查未通过的 .Where(t => !t.Subject.SubjectVisitList.Any(sv => sv.CheckState != CheckStateEnum.CVPassed && t.VisitTaskNum > sv.VisitNum)) //前序 不存在 未生成任务的访视 - .Where(t => c.IsAutoCreate ? !t.Subject.SubjectCriteriaEvaluationVisitFilterList.Where(d => d.TrialReadingCriterionId == t.TrialReadingCriterionId).Any(f => f.IsGeneratedTask == false && t.VisitTaskNum > f.SubjectVisit.VisitNum) : true) + //.Where(t => c.IsAutoCreate ? !t.Subject.SubjectCriteriaEvaluationVisitFilterList.Where(d => d.TrialReadingCriterionId == t.TrialReadingCriterionId).Any(f => f.IsGeneratedTask == false && t.VisitTaskNum > f.SubjectVisit.VisitNum) : true) .Where(y => y.IsFrontTaskNeedSignButNotSign == false && (y.IsNeedClinicalDataSign == false || y.IsClinicalDataSign == true)) .Count(t => t.IsUrgent), @@ -822,7 +755,7 @@ namespace IRaCIS.Core.Application .Where(t => !t.Subject.SubjectVisitList.Any(sv => sv.CheckState != CheckStateEnum.CVPassed && t.VisitTaskNum > sv.VisitNum)) //前序 不存在 未生成任务的访视 //.WhereIf(g.Key.IsAutoCreate == false, t => !t.Subject.SubjectCriteriaEvaluationVisitFilterList.Where(d => d.TrialReadingCriterionId == t.TrialReadingCriterionId).Any(f => f.IsGeneratedTask == false && t.VisitTaskNum > f.SubjectVisit.VisitNum)) - .Where(t => c.IsAutoCreate ? !t.Subject.SubjectCriteriaEvaluationVisitFilterList.Where(d => d.TrialReadingCriterionId == t.TrialReadingCriterionId).Any(f => f.IsGeneratedTask == false && t.VisitTaskNum > f.SubjectVisit.VisitNum) : true) + //.Where(t => c.IsAutoCreate ? !t.Subject.SubjectCriteriaEvaluationVisitFilterList.Where(d => d.TrialReadingCriterionId == t.TrialReadingCriterionId).Any(f => f.IsGeneratedTask == false && t.VisitTaskNum > f.SubjectVisit.VisitNum) : true) .Where(y => y.IsFrontTaskNeedSignButNotSign == false && (y.IsNeedClinicalDataSign == false || y.IsClinicalDataSign == true)) .Count(), @@ -911,8 +844,6 @@ namespace IRaCIS.Core.Application .Where(t => t.DoctorUserId == _userInfo.Id && t.ReadingTaskState != ReadingTaskState.HaveSigned && t.TaskState == TaskState.Effect) // 前序 不存在 未一致性核查未通过的 .Where(t => !t.Subject.SubjectVisitList.Any(sv => sv.CheckState != CheckStateEnum.CVPassed && t.VisitTaskNum > sv.VisitNum)) - //前序 不存在 未生成任务的访视 - .Where(t => t.TrialReadingCriterion.IsAutoCreate == false ? !t.Subject.SubjectCriteriaEvaluationVisitFilterList.Where(d => d.TrialReadingCriterionId == t.TrialReadingCriterionId).Any(f => f.IsGeneratedTask == false && t.VisitTaskNum > f.SubjectVisit.VisitNum) : true) .Where(y => y.IsFrontTaskNeedSignButNotSign == false && (y.IsNeedClinicalDataSign == false || y.IsClinicalDataSign == true)) .Count(); @@ -1150,15 +1081,7 @@ namespace IRaCIS.Core.Application FullName = t.User.FullName, UserType = t.User.UserTypeEnum, - //SPM 阅片人筛选 - ReviewerSelect_SPM_ToBeApprovalCount = - (t.User.UserTypeEnum == UserTypeEnum.SPM || t.User.UserTypeEnum == UserTypeEnum.CPM) ? - t.Trial.EnrollList.Where(u => u.EnrollStatus == EnrollStatus.HasCommittedToCRO).Count() : 0, - - //PM 阅片人确认 - ReviewerSelect_PM_ToBeConfirmCount = - (t.User.UserTypeEnum == UserTypeEnum.APM || t.User.UserTypeEnum == UserTypeEnum.ProjectManager) ? - t.Trial.EnrollList.Where(u => u.EnrollStatus == EnrollStatus.InviteIntoGroup).Count() : 0, + //CRC 重传 --区分人 ImageUpload_CRC_ToBeReUploadCount = @@ -1227,7 +1150,7 @@ namespace IRaCIS.Core.Application // 前序 不存在 未一致性核查未通过的 .Where(t => !t.Subject.SubjectVisitList.Any(sv => sv.CheckState != CheckStateEnum.CVPassed && t.VisitTaskNum > sv.VisitNum)) //前序 不存在 未生成任务的访视 - .Where(t => t.TrialReadingCriterion.IsAutoCreate == false ? !t.Subject.SubjectCriteriaEvaluationVisitFilterList.Where(d => d.TrialReadingCriterionId == t.TrialReadingCriterionId).Any(f => f.IsGeneratedTask == false && t.VisitTaskNum > f.SubjectVisit.VisitNum) : true) + .Where(y => y.IsFrontTaskNeedSignButNotSign == false && (y.IsNeedClinicalDataSign == false || y.IsClinicalDataSign == true)).Count() : 0, diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialConfigService.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialConfigService.cs index c449c05d5..3b2e23a57 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialConfigService.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialConfigService.cs @@ -37,7 +37,6 @@ namespace IRaCIS.Core.Application private readonly IRepository _readingCriterionPageRepository; private readonly IEasyCachingProvider _provider; private readonly IOrganInfoService _iOrganInfoService; - private readonly IRepository _taskAllocationRuleRepository; private readonly IRepository _readingCriterionDictionaryRepository; private readonly IRepository _readingTrialCriterionDictionaryRepository; private readonly IReadingQuestionService iReadingQuestionService; @@ -60,7 +59,7 @@ namespace IRaCIS.Core.Application IRepository readingQuestionCriterionSystemRepository, IRepository clinicalDataTrialSetRepository, IRepository readingCriterionPageRepository, - IRepository taskAllocationRuleRepository, + IRepository readingCriterionDictionaryRepository, IRepository readingTrialCriterionDictionaryRepository, IReadingQuestionService iReadingQuestionService, @@ -77,7 +76,7 @@ namespace IRaCIS.Core.Application { _trialCriterionAdditionalAssessmentTypeRepository = trialCriterionAdditionalAssessmentTypeRepository; _trialRepository = trialRepository; - _taskAllocationRuleRepository = taskAllocationRuleRepository; + this._readingCriterionDictionaryRepository = readingCriterionDictionaryRepository; this._readingTrialCriterionDictionaryRepository = readingTrialCriterionDictionaryRepository; this.iReadingQuestionService = iReadingQuestionService; @@ -1151,10 +1150,6 @@ namespace IRaCIS.Core.Application //Paused、 添加工总量 算医生读片中 if (trialStatusStr.Contains(StaticData.TrialState.TrialCompleted)) { - await _repository.BatchUpdateAsync(u => u.TrialId == trialId, e => new Enroll - { - EnrollStatus = EnrollStatus.Finished - }); await _trialRepository.BatchUpdateNoTrackingAsync(u => u.Id == trialId, s => new Trial { TrialFinishedTime = DateTime.Now }); diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialService.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialService.cs index 03cd04a9a..493e04861 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialService.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialService.cs @@ -123,11 +123,7 @@ namespace IRaCIS.Application.Services } - [NonDynamicMethod] - public async Task GetTrialMaxState(Guid trialId) - { - return await _repository.Where(t => t.TrialId == trialId).MaxAsync(u => (int?)u.EnrollStatus) ?? 0; - } + [HttpGet("{trialId:guid}")] public async Task GetTrialInfoAndMaxTrialState(Guid trialId) @@ -135,7 +131,7 @@ namespace IRaCIS.Application.Services return new TrialAndTrialStateVieModel() { TrialView = await GetTrialInfoAndLockState(trialId), - TrialMaxState = await GetTrialMaxState(trialId) + }; } @@ -211,8 +207,7 @@ namespace IRaCIS.Application.Services //添加运维人员PM await _repository.AddAsync(new TrialUser() { TrialId = trial.Id, UserId = _userInfo.Id, JoinTime = DateTime.Now }); - // 添加扩展信息表记录 - await _repository.AddAsync(new TrialPaymentPrice() { TrialId = trial.Id }); + //添加访视 await _repository.AddAsync(new VisitStage { TrialId = trial.Id, VisitNum = 0, BlindName = "B" + 0.ToString("D3"), VisitDay = 0, VisitName = "Baseline", IsBaseLine = true }); @@ -260,7 +255,7 @@ namespace IRaCIS.Application.Services if (updateModel.Expedited != trial.Expedited && updateModel.Expedited != null) { TrialExpeditedChange = true; - await TrialExpeditedStatusChange(trial.Id, trial.Expedited, (int)updateModel.Expedited); + } _mapper.Map(updateModel, trial); @@ -274,104 +269,7 @@ namespace IRaCIS.Application.Services } - // TODO: 需要优化,嵌套两层 switch case ? - [NonDynamicMethod] - private async Task TrialExpeditedStatusChange(Guid trialId, int oldState, int newState) - { - switch (oldState) - { - case (int)TrialExpedited.None: - switch (newState) - { - case (int)TrialExpedited.ExpeditedIn24H: - await _repository.BatchUpdateAsync(t => t.IsLock == false && t.TrialId == trialId, u => new Workload() - { - TimepointIn24H = u.Timepoint, - AdjudicationIn24H = u.Adjudication, - Timepoint = 0, - Adjudication = 0 - }); - break; - case (int)TrialExpedited.ExpeditedIn48H: - await _repository.BatchUpdateAsync(t => t.IsLock == false && t.TrialId == trialId, u => new Workload() - { - TimepointIn48H = u.Timepoint, - AdjudicationIn48H = u.Adjudication, - Timepoint = 0, - Adjudication = 0 - }); - break; - } - //_workloadRepository.Update(t => t.IsLock == false && t.TrialId == trialId, u => new Workload() - //{ - // Timepoint = 0, - // Adjudication = 0 - //}); - - break; - case (int)TrialExpedited.ExpeditedIn24H: - - switch (newState) - { - case (int)TrialExpedited.None: - await _repository.BatchUpdateAsync(t => t.IsLock == false && t.TrialId == trialId, u => new Workload() - { - Timepoint = u.TimepointIn24H, - Adjudication = u.AdjudicationIn24H, - TimepointIn24H = 0, - AdjudicationIn24H = 0 - }); - break; - case (int)TrialExpedited.ExpeditedIn48H: - await _repository.BatchUpdateAsync(t => t.IsLock == false && t.TrialId == trialId, u => new Workload() - { - TimepointIn48H = u.TimepointIn24H, - AdjudicationIn48H = u.AdjudicationIn24H, - TimepointIn24H = 0, - AdjudicationIn24H = 0 - }); - - break; - } - - //_workloadRepository.Update(t => t.IsLock == false && t.TrialId == trialId, u => new Workload() - //{ - // TimepointIn24H = 0, - // AdjudicationIn24H = 0 - //}); - - break; - case (int)TrialExpedited.ExpeditedIn48H: - switch (newState) - { - case (int)TrialExpedited.None: - await _repository.BatchUpdateAsync(t => t.IsLock == false && t.TrialId == trialId, u => new Workload() - { - Timepoint = u.TimepointIn48H, - Adjudication = u.AdjudicationIn48H, - TimepointIn48H = 0, - AdjudicationIn48H = 0 - }); - break; - case (int)TrialExpedited.ExpeditedIn24H: - await _repository.BatchUpdateAsync(t => t.IsLock == false && t.TrialId == trialId, u => new Workload() - { - TimepointIn24H = u.TimepointIn48H, - AdjudicationIn24H = u.AdjudicationIn48H, - TimepointIn48H = 0, - AdjudicationIn48H = 0 - }); - break; - } - - //_workloadRepository.Update(t => t.IsLock == false && t.TrialId == trialId, u => new Workload() - //{ - // TimepointIn48H = 0, - // AdjudicationIn48H = 0 - //}); - break; - } - } + @@ -427,8 +325,7 @@ namespace IRaCIS.Application.Services //} #endregion - await _repository.BatchDeleteAsync(o => o.Workload.TrialId == trialId); - await _repository.BatchDeleteAsync(o => o.TrialId == trialId); + await _repository.BatchDeleteAsync(o => o.SubjectVisit.TrialId == trialId); await _repository.BatchDeleteAsync(o => o.TrialId == trialId); @@ -439,16 +336,13 @@ namespace IRaCIS.Application.Services await _repository.BatchDeleteAsync(t => t.TrialId == trialId); await _repository.BatchDeleteAsync(t => t.TrialId == trialId); await _repository.BatchDeleteAsync(t => t.TrialId == trialId); - await _repository.BatchDeleteAsync(t => t.Enroll.TrialId == trialId); - await _repository.BatchDeleteAsync(t => t.TrialId == trialId); - await _repository.BatchDeleteAsync(t => t.TrialId == trialId); + await _repository.BatchDeleteAsync(t => t.NoneDicomStudy.TrialId == trialId); await _repository.BatchDeleteAsync(t => t.TrialId == trialId); await _repository.BatchDeleteAsync(t => t.TrialId == trialId); - await _repository.BatchDeleteAsync(t => t.TrialId == trialId); - await _repository.BatchDeleteAsync(t => t.TrialId == trialId); + @@ -490,20 +384,18 @@ namespace IRaCIS.Application.Services await _repository.BatchDeleteAsync(t => t.TrialId == trialId); await _repository.BatchDeleteAsync(t => t.TrialId == trialId); - await _repository.BatchDeleteAsync(t => t.Subject.TrialId == trialId); - await _repository.BatchDeleteAsync(t => t.TrialId == trialId); + await _repository.BatchDeleteAsync(t => t.TrialId == trialId); await _repository.BatchDeleteAsync(t => t.TrialId == trialId); - await _repository.BatchDeleteAsync(t => t.TrialId == trialId); - await _repository.BatchDeleteAsync(t => t.TrialId == trialId); + await _repository.BatchDeleteAsync(t => t.InfluenceTask.TrialId == trialId); await _repository.BatchDeleteAsync(t => t.TrialId == trialId); await _repository.BatchDeleteAsync(t => t.TrialId == trialId); await _repository.BatchDeleteAsync(t => t.TrialId == trialId); - await _repository.BatchDeleteAsync(t => t.TrialId == trialId); + await _repository.BatchDeleteAsync(o => o.Id == trialId); @@ -524,14 +416,11 @@ namespace IRaCIS.Application.Services await _repository.BatchDeleteAsync(t => t.TrialId == trialId); - await _repository.BatchDeleteAsync(t => t.TrialId == trialId); await _repository.BatchDeleteAsync(t => t.TrialId == trialId); await _repository.BatchDeleteAsync(t => t.TrialId == trialId); - await _repository.BatchDeleteAsync(t => t.TrialId == trialId); - await _repository.BatchDeleteAsync(t => t.TrialId == trialId); @@ -601,83 +490,18 @@ namespace IRaCIS.Application.Services return ResponseOutput.Ok(); } - [HttpPost] - public async Task> GetReviewerTrialListByEnrollmentStatus(TrialByStatusQueryDTO param) - { - - var query = _trialRepository.AsQueryable() - .WhereIf(param.Status == 5, t => t.EnrollList.Any(u => u.EnrollStatus == EnrollStatus.HasCommittedToCRO)) - .WhereIf(param.Status == 8, t => t.EnrollList.Any(u => u.EnrollStatus == EnrollStatus.InviteIntoGroup)) - .WhereIf(param.Status == 10, t => t.EnrollList.Any(u => u.EnrollStatus == EnrollStatus.DoctorReading)) - .WhereIf(param.Status == 14, t => t.EnrollList.Any(u => u.EnrollStatus == EnrollStatus.Finished)) - .ProjectTo(_mapper.ConfigurationProvider, new { userTypeEnumInt = _userInfo.UserTypeEnumInt, userId = _userInfo.Id }); - - return await query.ToPagedListAsync(param.PageIndex, param.PageSize, string.IsNullOrWhiteSpace(param.SortField) ? "CreateTime" : param.SortField, param.Asc); - - } - /// - /// 根据项目Id 获取医生Id,用于触发计算费用 - /// - public async Task> GetTrialEnrollmentReviewerIds(Guid trialId) - { - return await _repository.Where(u => u.TrialId == trialId && - u.EnrollStatus >= EnrollStatus.DoctorReading).Select(u => u.DoctorId).Distinct().ToListAsync(); - } #region 医生用户接口 - /// 分页获取医生参与的临床实验项目列表(查询条件) - /// - [HttpPost] - public async Task> GetTrialListByReviewer(ReviewerTrialQueryDTO searchModel) - { - var query = _trialRepository - .WhereIf(searchModel.EnrollStatus != null, o => (int)searchModel.EnrollStatus! == 10 ? - o.EnrollList.Any(o => o.EnrollStatus >= EnrollStatus.ConfirmIntoGroup && o.EnrollStatus <= EnrollStatus.DoctorReading && o.DoctorId == _userInfo.Id) : - o.EnrollList.Any(o => o.EnrollStatus == searchModel.EnrollStatus && o.DoctorId == _userInfo.Id)) - .WhereIf(searchModel.Expedited != null, o => o.Expedited == searchModel.Expedited) - .WhereIf(!string.IsNullOrEmpty(searchModel.Code), o => o.TrialCode.Contains(searchModel.Code)) - .WhereIf(!string.IsNullOrWhiteSpace(searchModel.Indication), o => o.Indication.Contains(searchModel.Indication)) - .WhereIf(_userInfo.UserTypeEnumInt != (int)UserTypeEnum.SuperAdmin, t => t.TrialUserList.Any(t => t.UserId == _userInfo.Id)) - .ProjectTo(_mapper.ConfigurationProvider, new { userTypeEnumInt = _userInfo.UserTypeEnumInt, userId = _userInfo.Id }); - return await query.ToPagedListAsync(searchModel.PageIndex, searchModel.PageSize, string.IsNullOrWhiteSpace(searchModel.SortField) ? "CreateTime" : searchModel.SortField, searchModel.Asc); - - - - } - - - /// - /// 医生确认入组或拒绝入组 - /// - /// 项目Id - /// 9-拒绝入组,10-确认入组 - /// - [HttpPost("{trialId:guid}/{status:int}")] - - [TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })] - public async Task UpdateEnrollStatus(Guid trialId, EnrollStatus status) - { - await _repository.AddAsync(new EnrollDetail() - { - DoctorId = _userInfo.Id, - TrialId = trialId, - EnrollStatus = status, - OptUserType = (int)SystemUserType.DoctorUser, - }); - return ResponseOutput.Result(await _repository.BatchUpdateAsync(u => u.TrialId == trialId && u.DoctorId == _userInfo.Id, e => new Enroll - { - EnrollStatus = status - })); - } + #endregion diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/_MapConfig.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/_MapConfig.cs index 2cc817948..00a6a8be6 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/_MapConfig.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/_MapConfig.cs @@ -75,7 +75,7 @@ namespace IRaCIS.Core.Application.Service .ForMember(d => d.CRO, u => u.MapFrom(s => s.CRO.CROName)) .ForMember(d => d.ReviewMode, u => u.MapFrom(s => s.ReviewMode.MappedValue)) //.ForMember(d => d.ReviewType, u => u.MapFrom(s => s.ReviewType.Value)) - .ForMember(d => d.IsLocked, u => u.MapFrom(s => s.WorkloadList.Any(u => u.DataFrom == (int)WorkLoadFromStatus.FinalConfirm))) + //.ForMember(d => d.SiteCount, u => u.MapFrom(s => userTypeEnumInt == (int)UserTypeEnum.ClinicalResearchCoordinator ? s.TrialSiteUserList.Count(k => k.UserId == userId) : s.TrialSiteList.Count())) //.ForMember(d => d.StudyCount, u => u.MapFrom(s => userTypeEnumInt == (int)UserTypeEnum.ClinicalResearchCoordinator ? s.StudyList.Count(t => t.TrialSite.CRCUserList.Any(t => t.UserId == userId)) : s.StudyList.Count())) //.ForMember(d => d.SubjectCount, u => u.MapFrom(s => userTypeEnumInt == (int)UserTypeEnum.ClinicalResearchCoordinator ? s.SubjectList.Count(t => t.TrialSite.CRCUserList.Any(t => t.UserId == userId)) : s.SubjectList.Count())) diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/_MapConfig2.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/_MapConfig2.cs index 912f5b093..b38bb11d1 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/_MapConfig2.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/_MapConfig2.cs @@ -37,7 +37,6 @@ namespace IRaCIS.Core.Application.Service - CreateMap(); CreateMap(); diff --git a/IRaCIS.Core.Application/Service/Visit/SubjectVisitService.cs b/IRaCIS.Core.Application/Service/Visit/SubjectVisitService.cs index c3b0254b3..ff91d6e6c 100644 --- a/IRaCIS.Core.Application/Service/Visit/SubjectVisitService.cs +++ b/IRaCIS.Core.Application/Service/Visit/SubjectVisitService.cs @@ -32,7 +32,6 @@ namespace IRaCIS.Core.Application.Services private readonly IRepository _subjectRepository; private readonly IRepository _trialReadingCriterionRepository; - private readonly IRepository _subjectCriteriaEvaluationVisitStudyFilterRepository; public SubjectVisitService(IRepository subjectVisitRepository, IRepository clinicalDataTrialSetRepository, @@ -47,8 +46,7 @@ namespace IRaCIS.Core.Application.Services IRepository noneDicomStudyFileRepository, IRepository readingPeriodPlanRepository, IRepository subjectRepository, - IRepository trialReadingCriterionRepository, - IRepository subjectCriteriaEvaluationVisitStudyFilterRepository + IRepository trialReadingCriterionRepository ) { @@ -66,7 +64,6 @@ namespace IRaCIS.Core.Application.Services this._readingPeriodPlanRepository = readingPeriodPlanRepository; _subjectRepository = subjectRepository; _trialReadingCriterionRepository = trialReadingCriterionRepository; - _subjectCriteriaEvaluationVisitStudyFilterRepository = subjectCriteriaEvaluationVisitStudyFilterRepository; } @@ -427,7 +424,6 @@ namespace IRaCIS.Core.Application.Services var isManualGenerate = await _trialReadingCriterionRepository.AnyAsync(t => t.Id == taskInfo.TrialReadingCriterionId && t.IsAutoCreate == false); var studyList = await _repository.Where(t => t.TrialId == indto.TrialId && t.SubjectVisitId == indto.SujectVisitId) - .WhereIf(isManualGenerate,t=>t.SubjectCriteriaEvaluationVisitStudyFilterList.Any(t=>t.TrialReadingCriterionId==taskInfo.TrialReadingCriterionId && t.IsConfirmed &&t.IsReading )) .Select(k => new VisitStudyDTO() { InstanceCount = k.InstanceCount, @@ -446,7 +442,6 @@ namespace IRaCIS.Core.Application.Services List seriesLists = await _repository.Where(s => studyIds.Contains(s.StudyId) /*&& s.IsReading*/) .WhereIf(isManualGenerate==false, t => t.IsReading) - .WhereIf(isManualGenerate, t => t.SubjectCriteriaEvaluationVisitStudyFilterList.Any(t => t.TrialReadingCriterionId == taskInfo.TrialReadingCriterionId && t.IsConfirmed && t.IsReading)) .OrderBy(s => s.SeriesNumber). ThenBy(s => s.SeriesTime) .ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); diff --git a/IRaCIS.Core.Application/Service/WorkLoad/DoctorWorkloadService.cs b/IRaCIS.Core.Application/Service/WorkLoad/DoctorWorkloadService.cs deleted file mode 100644 index dc0998e93..000000000 --- a/IRaCIS.Core.Application/Service/WorkLoad/DoctorWorkloadService.cs +++ /dev/null @@ -1,855 +0,0 @@ -using AutoMapper; -using IRaCIS.Application.Contracts; -using IRaCIS.Core.Domain.Share; -using System.Linq.Expressions; -using IRaCIS.Core.Application.Filter; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Authorization; -using IRaCIS.Core.Application.Auth; -using System.Linq.Dynamic.Core; - -namespace IRaCIS.Application.Services -{ - [ApiExplorerSettings(GroupName = "Trial")] - public class DoctorWorkloadService : BaseService, IDoctorWorkloadService - { - private readonly IRepository _trialRepository; - private readonly IRepository _enrollRepository; - private readonly IRepository _doctorRepository; - private readonly IRepository _doctorWorkloadRepository; - private readonly IRepository _enrollReadingCategoryRepository; - private readonly IRepository _attachmentRepository; - private readonly IRepository _costStatisticsRepository; - private readonly IRepository _trialRevenuesPriceRepository; - private readonly IRepository _trialRevenuesPriceVerificationRepository; - - private readonly IRepository _taskAllocationRuleRepository; - public DoctorWorkloadService(IRepository clinicalTrialProjectRepository, - IRepository intoGroupRepository, - IRepository doctorInfoRepository, - IRepository doctorWorkloadRepository, - IRepository enrollReadingCategoryRepository, - IRepository attachmentRepository, - IRepository costStatisticsRepository, - IRepository trialRevenuesPriceRepository, - IRepository taskAllocationRuleRepository, - IRepository trialRevenuesPriceVerificationRepository, - IMapper mapper) - { - _taskAllocationRuleRepository = taskAllocationRuleRepository; - _trialRepository = clinicalTrialProjectRepository; - _enrollRepository = intoGroupRepository; - _doctorRepository = doctorInfoRepository; - _doctorWorkloadRepository = doctorWorkloadRepository; - this._enrollReadingCategoryRepository = enrollReadingCategoryRepository; - _attachmentRepository = attachmentRepository; - _costStatisticsRepository = costStatisticsRepository; - _trialRevenuesPriceRepository = trialRevenuesPriceRepository; - _trialRevenuesPriceVerificationRepository = trialRevenuesPriceVerificationRepository; - - } - - #region 入组工作量统计列表 具体详情 增删改查相关 上传\删除协议 - - - #region 协议废弃 - ///// - ///// 保存协议- ack Sow [AUTH] - ///// - //[HttpPost("{trialId}")] - - //[TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })] - ////[Authorize(Policy = IRaCISPolicy.PM_APM)] - //public async Task UploadReviewerAckSOW(Guid trialId, - // ReviewerAckDTO attachmentViewModel) - //{ - - // var intoGroupItem = (await _enrollRepository.Where(t => t.TrialId == trialId && t.DoctorId == attachmentViewModel.DoctorId).FirstOrDefaultAsync()).IfNullThrowException(); - - - // if (attachmentViewModel.Id != Guid.Empty) - // { - // await _attachmentRepository.BatchDeleteNoTrackingAsync(t => t.Id == attachmentViewModel.Id); - // } - - // var attachment = await _attachmentRepository.InsertFromDTOAsync(attachmentViewModel); - - // //intoGroupItem.AttachmentId = attachment.Id; - // await _enrollRepository.UpdatePartialFromQueryAsync(intoGroupItem.Id, u => new Enroll() { AttachmentId = attachment.Id }); - - - // var success = await _enrollRepository.SaveChangesAsync(); - - // return ResponseOutput.Result(success, attachment.Id.ToString()); - //} - - ///// - ///// 删除协议 - ///// - //[HttpDelete, Route("{trialId}/{doctorId}/{attachmentId}")] - - //[TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })] - ////[Authorize(Policy = IRaCISPolicy.PM_APM)] - //public async Task DeleteReviewerAckSOW(Guid trialId, Guid doctorId, Guid attachmentId) - //{ - // var success1 = await _attachmentRepository.BatchDeleteNoTrackingAsync(a => a.Id == attachmentId); - // await _enrollRepository.UpdatePartialFromQueryAsync(t => t.TrialId == trialId && t.DoctorId == doctorId, u => - // new Enroll() - // { - // AttachmentId = Guid.Empty - // }, true); - // return ResponseOutput.Ok(success1); - //} - - - - #endregion - - - - - /// - /// 修改项目医生的阅片类型 - /// - /// - /// - //[Authorize(Policy = IRaCISPolicy.PM_APM)] - [TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })] - public async Task SetEnrollReadingCategory(SetEnrollReadingCategoryInDto inDto) - { - - var enroll = await _enrollRepository.FirstAsync(t => t.Id == inDto.EnrollId); - - - if (_repository.Where(t => t.TrialId == enroll.TrialId && t.DoctorUserId == enroll.DoctorUserId && t.TaskAllocationState == TaskAllocationState.Allocated && t.TrialReadingCriterionId==inDto.TrialReadingCriterionId).Any()) - { - - var readingCategoryList = await _enrollReadingCategoryRepository.Where(t => t.EnrollId == inDto.EnrollId && t.TrialReadingCriterionId == inDto.TrialReadingCriterionId).Select(t => t.ReadingCategory).ToListAsync(); - - if (readingCategoryList.Except(inDto.ReadingCategorys).Count() > 0) - { - //---已分配任务,不允许减少阅片类型 - return ResponseOutput.NotOk(_localizer["DoctorWorkload_AssignType"]); - - } - - } - - //if (inDto.ReadingCategorys.Count > 0) - //{ - // await _enrollReadingCategoryRepository.BatchDeleteNoTrackingAsync(x => x.EnrollId == inDto.EnrollId); - - //} - //else - //{ - // await _enrollReadingCategoryRepository.DeleteFromQueryAsync(x => x.EnrollId == inDto.EnrollId); - //} - - await _enrollReadingCategoryRepository.DeleteFromQueryAsync(x => x.EnrollId == inDto.EnrollId && x.TrialReadingCriterionId == inDto.TrialReadingCriterionId); - - - List enrollReadings = inDto.ReadingCategorys.Select(x => new EnrollReadingCategory() - { - TrialReadingCriterionId= inDto.TrialReadingCriterionId, - EnrollId = inDto.EnrollId, - ReadingCategory = x - }).ToList(); - - await _enrollReadingCategoryRepository.AddRangeAsync(enrollReadings); - var result = await _enrollReadingCategoryRepository.SaveChangesAsync(); - - - return ResponseOutput.Ok(result); - } - - /// - /// 修改项目医生启用禁用状态 - /// - /// - /// - //[Authorize(Policy = IRaCISPolicy.PM_APM)] - [TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })] - public async Task UpdateTrialReviewerState(SetEnrollEnableCommand inCommand) - { - await _taskAllocationRuleRepository.UpdatePartialFromQueryAsync(t => t.TrialId == inCommand.TrialId && t.EnrollId == inCommand.EnrollId, u => new TaskAllocationRule() { IsEnable = inCommand.IsEnable },true); - - return ResponseOutput.Ok(); - } - - - /// - /// 0代表裁判和Tp 都可以 1、代表Tp 2 代表裁判 - /// - /// - [HttpPost("{trialId}/{doctorId}/{type}")] - [TypeFilter(typeof(TrialResourceFilter),Arguments = new object[] { "AfterStopCannNotOpt" })] - //[Authorize(Policy = IRaCISPolicy.PM_APM)] - public async Task UpdateReviewerReadingType(Guid trialId, Guid doctorId, int type) - { - var success2 = await _enrollRepository.BatchUpdateNoTrackingAsync(t => t.TrialId == trialId && t.DoctorId == doctorId, u => - new Enroll() - { - ReviewerReadingType = type - }); - return ResponseOutput.Result(success2); - } - - /// - /// 获取某个项目入组的医生工作量统计列表 - /// - [HttpPost] - public async Task> GetTrialEnrollmentWorkloadStats(WorkLoadDoctorQueryDTO doctorSearchModel) - { - //https://blog.csdn.net/sunshineblog/article/details/78636389 - - var trialId = doctorSearchModel.TrialId; - - var doctorIntoGroupQueryable = - - from intoGroup in _enrollRepository.Where(x => x.TrialId == trialId && x.EnrollStatus >= EnrollStatus.ConfirmIntoGroup) - join allocateRule in _taskAllocationRuleRepository.AsQueryable() on intoGroup.Id equals allocateRule.EnrollId - join doctor in _doctorRepository.AsQueryable() on intoGroup.DoctorId equals doctor.Id - join attachmentItem in _attachmentRepository.AsQueryable() on intoGroup.AttachmentId equals attachmentItem.Id into cc - from attachment in cc.DefaultIfEmpty() - - select new WorkLoadAndAgreementDTO() - { - EnrollId = intoGroup.Id, - IsEnable = allocateRule.IsEnable, - - TrialReadingCriterionList = intoGroup.Trial.ReadingQuestionCriterionTrialList.Where(t=>t.IsConfirm).Select(t=>new TrialReadingCriterionDto() { TrialReadingCriterionId=t.Id,TrialReadingCriterionName=t.CriterionName,CriterionType=t.CriterionType,IsOncologyReading=t.IsOncologyReading,IsArbitrationReading=t.IsArbitrationReading,IsGlobalReading=t.IsGlobalReading,ReadingInfoSignTime=t.ReadingInfoSignTime,ReadingType=t.ReadingType}).ToList(), - - - - CriterionReadingCategoryList =intoGroup.EnrollReadingCategoryList.Select(t=>new TrialCriterionReadingCategory() { EnrollId=t.EnrollId,ReadingCategory=t.ReadingCategory, TrialReadingCriterionId = t.TrialReadingCriterionId }).ToList(), - - CriterionFileList = doctor.CriterionFileList.Where(x => x.IsEnable && (x.TrialId==null ||x.TrialId==trialId)).Select(x => new CriterionFile() - { - CriterionType = x.CriterionType, - DoctorId = x.DoctorId, - FileName = x.FileName, - FilePath = x.FilePath, - FileType = x.FileType, - Remark = x.Remark, - TrialReadingCriterionId=x.TrialReadingCriterionId, - Id = x.Id - }).ToList(), - - ReadingTaskStateList = doctor.User.VisitTaskList.Where(x => x.TaskState == TaskState.Effect && x.TrialId == trialId).Select(x => new DoctorUserTask() - { - ReadingTaskState = x.ReadingTaskState, - TrialReadingCriterionId=x.TrialReadingCriterionId, - CriterionType = x.TrialReadingCriterion.CriterionType, - - }).ToList(), - - DoctorId = doctor.Id, - Code = doctor.ReviewerCode, - FirstName = doctor.FirstName, - LastName = doctor.LastName, - FullName = doctor.FullName, - ChineseName = doctor.ChineseName, - UserName= intoGroup.DoctorUser.UserName, - - OutEnrollTime = intoGroup.OutEnrollTime, - EnrollTime = intoGroup.EnrollTime, - AgreementId = intoGroup.AttachmentId, - ReviewerReadingType = intoGroup.ReviewerReadingType, - AgreementPath = attachment.Path, - - - - }; - - return await doctorIntoGroupQueryable.ToPagedListAsync(doctorSearchModel.PageIndex, doctorSearchModel.PageSize, doctorSearchModel.SortField == "" ? "EnrollTime" : doctorSearchModel.SortField, doctorSearchModel.Asc); - - - } - - /// - /// 获取入组某个项目的医生的最近几个月的工作量详情(带有填充数据) - /// - [HttpPost] - public PageOutput GetEnrollmentWorkloadStatsDetail(WorkLoadStatsQueryDTO workLoadSearch) - { - #region 条件查询 - Expression> workloadLambda = x => true; - if (workLoadSearch.TrialId != Guid.Empty && workLoadSearch.TrialId != null) - { - workloadLambda = workloadLambda.And(x => x.TrialId == workLoadSearch.TrialId); - } - if (workLoadSearch.DoctorId != Guid.Empty && workLoadSearch.DoctorId != null) - { - workloadLambda = workloadLambda.And(t => t.DoctorId == workLoadSearch.DoctorId); - } - if (workLoadSearch.SearchBeginDateTime != null) - { - var bDate = workLoadSearch.SearchBeginDateTime; - - var beginDate = new DateTime(bDate.Value.Year, bDate.Value.Month, 1); - - workloadLambda = workloadLambda.And(t => - t.WorkTime >= beginDate); - } - if (workLoadSearch.SearchEndDateTime != null) - { - var eDate = workLoadSearch.SearchEndDateTime.Value.AddMonths(1); - - DateTime endDate = new DateTime(eDate.Year, eDate.Month, 1); - - workloadLambda = workloadLambda.And(t => - t.WorkTime < endDate); - } - - - #endregion - - IQueryable? workLoadQueryable = default; - - var tempWorkload = new List(); - if (workLoadSearch.WorkLoadFromStatus.Contains(1)) - { - workLoadQueryable = from workLoad in _doctorWorkloadRepository.Where(workloadLambda.And(t => t.DataFrom == (int)WorkLoadFromStatus.CRO)) - join doctor in _doctorRepository.AsQueryable() on workLoad.DoctorId equals doctor.Id - join trial in _trialRepository.AsQueryable() on workLoad.TrialId equals trial.Id - - select new WorkLoadDetailDTO() - { - Id = workLoad.Id, - DoctorId = workLoad.DoctorId, - ChineseName = doctor.ChineseName, - FirstName = doctor.FirstName, - LastName = doctor.LastName, - - YearMonthStr = workLoad.YearMonth, - CreateTime = workLoad.CreateTime, - WorkTime = workLoad.WorkTime, - - DataFrom = workLoad.DataFrom, - TrialId = workLoad.TrialId, - Indication = trial.Indication, - Code = trial.TrialCode, - - Timepoint = workLoad.Timepoint, - TimepointIn24H = workLoad.TimepointIn24H, - TimepointIn48H = workLoad.TimepointIn48H, - Global = workLoad.Global, - RefresherTraining = workLoad.RefresherTraining, - Adjudication = workLoad.Adjudication, - AdjudicationIn24H = workLoad.AdjudicationIn24H, - AdjudicationIn48H = workLoad.AdjudicationIn48H, - - - - Training = workLoad.Training, - Downtime = workLoad.Downtime, - IsLock = workLoad.IsLock - }; - tempWorkload.AddRange(workLoadQueryable.ToList()); - } - - - if (workLoadSearch.WorkLoadFromStatus.Contains(2)) - { - workLoadQueryable = from workLoad in _doctorWorkloadRepository.Where(workloadLambda.And(t => t.DataFrom == (int)WorkLoadFromStatus.FinalConfirm)) - join doctor in _doctorRepository.AsQueryable() on workLoad.DoctorId equals doctor.Id - join trial in _trialRepository.AsQueryable() on workLoad.TrialId equals trial.Id - - select new WorkLoadDetailDTO() - { - Id = workLoad.Id, - DoctorId = workLoad.DoctorId, - ChineseName = doctor.ChineseName, - FirstName = doctor.FirstName, - LastName = doctor.LastName, - - YearMonthStr = workLoad.YearMonth, - CreateTime = workLoad.CreateTime, - WorkTime = workLoad.WorkTime, - - DataFrom = workLoad.DataFrom, - TrialId = workLoad.TrialId, - Indication = trial.Indication, - Code = trial.TrialCode, - - Timepoint = workLoad.Timepoint, - TimepointIn24H = workLoad.TimepointIn24H, - TimepointIn48H = workLoad.TimepointIn48H, - Global = workLoad.Global, - RefresherTraining = workLoad.RefresherTraining, - Adjudication = workLoad.Adjudication, - AdjudicationIn24H = workLoad.AdjudicationIn24H, - AdjudicationIn48H = workLoad.AdjudicationIn48H, - - Training = workLoad.Training, - Downtime = workLoad.Downtime, - IsLock = workLoad.IsLock - }; - tempWorkload.AddRange(workLoadQueryable.ToList()); - } - - if (workLoadSearch.WorkLoadFromStatus.Contains(0)) - { - workLoadQueryable = - from workLoad in (from workLoadItem in _doctorWorkloadRepository.Where(workloadLambda.And(t => t.DataFrom == (int)WorkLoadFromStatus.Doctor)) - group workLoadItem by new { workLoadItem.YearMonth, workLoadItem.DoctorId, workLoadItem.TrialId, workLoadItem.IsLock } into g - select new - { - Id = Guid.NewGuid(), - DoctorId = g.Key.DoctorId, - DataFrom = 0, - TrialId = g.Key.TrialId, - IsLock = g.Key.IsLock, - YearMonthStr = g.Key.YearMonth, - Timepoint = g.Sum(workLoad => workLoad.Timepoint), - TimepointIn24H = g.Sum(workLoad => workLoad.TimepointIn24H), - TimepointIn48H = g.Sum(workLoad => workLoad.TimepointIn48H), - Global = g.Sum(workLoad => workLoad.Global), - RefresherTraining = g.Sum(workLoad => workLoad.RefresherTraining), - Adjudication = g.Sum(workLoad => workLoad.Adjudication), - AdjudicationIn24H = g.Sum(workLoad => workLoad.AdjudicationIn24H), - AdjudicationIn48H = g.Sum(workLoad => workLoad.AdjudicationIn48H), - - Training = g.Sum(workLoad => workLoad.Training), - Downtime = g.Sum(workLoad => workLoad.Downtime) - }) - join doctor in _doctorRepository.AsQueryable() on workLoad.DoctorId equals doctor.Id - join trial in _trialRepository.AsQueryable() on workLoad.TrialId equals trial.Id - select new WorkLoadDetailDTO() - { - Id = workLoad.Id, - DoctorId = workLoad.DoctorId, - ChineseName = doctor.ChineseName, - FirstName = doctor.FirstName, - LastName = doctor.LastName, - YearMonthStr = workLoad.YearMonthStr, - - DataFrom = workLoad.DataFrom, - TrialId = workLoad.TrialId, - Indication = trial.Indication, - Code = trial.TrialCode, - - Timepoint = workLoad.Timepoint, - TimepointIn24H = workLoad.TimepointIn24H, - TimepointIn48H = workLoad.TimepointIn48H, - Global = workLoad.Global, - RefresherTraining = workLoad.RefresherTraining, - Adjudication = workLoad.Adjudication, - AdjudicationIn24H = workLoad.AdjudicationIn24H, - AdjudicationIn48H = workLoad.AdjudicationIn48H, - - Training = workLoad.Training, - Downtime = workLoad.Downtime, - IsLock = workLoad.IsLock - }; - tempWorkload.AddRange(workLoadQueryable.ToList()); - } - - //workLoadQueryable = workLoadQueryable.OrderByDescending(t => t.YearMonthStr).ThenBy(t => t.DataFrom); - - //取选取月份的数据 - var month = (workLoadSearch.SearchEndDateTime?.Year - workLoadSearch.SearchBeginDateTime?.Year) * 12 + (workLoadSearch.SearchEndDateTime?.Month - workLoadSearch.SearchBeginDateTime?.Month) + 1; - var count = (month ?? 1) * workLoadSearch.WorkLoadFromStatus.Count; - //tempWorkload = tempWorkload.Take(count); - tempWorkload.OrderByDescending(t => t.YearMonthStr).ThenBy(t => t.DataFrom).Take(count); - //var workLoadList = workLoadQueryable.ToList(); - return BuildFullData(tempWorkload, workLoadSearch); - } - - /// - /// 获取来自Reviewer自己的数据,某个月添加的多条 - /// - [HttpPost] - public async Task> GetReviewerWorkLoadListDetail( - WorkLoadDetailQueryDTO workLoadSearch) - { - Expression> workloadLambda = t => t.DataFrom == (int)WorkLoadFromStatus.Doctor && t.YearMonth == workLoadSearch.YearMonthStr; - - if (workLoadSearch.TrialId != Guid.Empty) - { - workloadLambda = workloadLambda.And(x => x.TrialId == workLoadSearch.TrialId); - } - - if (workLoadSearch.DoctorId != Guid.Empty) - { - workloadLambda = workloadLambda.And(t => t.DoctorId == workLoadSearch.DoctorId); - } - - var workLoadQueryable = from workLoad in _doctorWorkloadRepository.Where(workloadLambda) - join doctor in _doctorRepository.AsQueryable() on workLoad.DoctorId equals doctor.Id - join trial in _trialRepository.AsQueryable() on workLoad.TrialId equals trial.Id - - select new WorkLoadDetailViewModel() - { - Id = workLoad.Id, - DoctorId = workLoad.DoctorId, - ChineseName = doctor.ChineseName, - FirstName = doctor.FirstName, - LastName = doctor.LastName, - YearMonthStr = workLoad.YearMonth, - CreateTime = workLoad.CreateTime, - WorkTime = workLoad.WorkTime, - - DataFrom = workLoad.DataFrom, - TrialId = workLoad.TrialId, - Indication = trial.Indication, - Code = trial.TrialCode, - - Timepoint = workLoad.Timepoint, - TimepointIn24H = workLoad.TimepointIn24H, - TimepointIn48H = workLoad.TimepointIn48H, - Global = workLoad.Global, - Adjudication = workLoad.Adjudication, - AdjudicationIn24H = workLoad.AdjudicationIn24H, - AdjudicationIn48H = workLoad.AdjudicationIn48H, - RefresherTraining = workLoad.RefresherTraining, - - Training = workLoad.Training, - Downtime = workLoad.Downtime, - IsLock = workLoad.IsLock - }; - - workLoadQueryable = workLoadQueryable.OrderBy("WorkTime"); - - var workLoadList = await workLoadQueryable.ToListAsync(); - - workLoadList.ForEach(t => t.RowGuid = Guid.NewGuid()); - - return workLoadList; - - } - - /// - /// 工作量是否存在,用于判断只能添加一条的工作量记录 - /// - /// - /// 查询某个医生是否在某天有某个项目的工作量数据,处理添加来自医生自己的工作量数据 - /// - [HttpPost] - public async Task> WorkloadExist(WorkloadExistQueryDTO param) - { - var isExist = false; - var exist = await _doctorWorkloadRepository.FirstOrDefaultAsync(u => u.TrialId == param.TrialId && u.DoctorId == param.DoctorId - && u.WorkTime == param.WorkDate && u.DataFrom == 0); - if (exist != null) - { - isExist = true; - } - return ResponseOutput.Ok(new ExistWorkloadViewModel - { - IsExist = isExist, - WorkLoad = _mapper.Map(exist), - }); - } - - /// - /// 添加或更新工作量 - /// - //[Authorize(Policy = IRaCISPolicy.PM_APM)] - public async Task AddOrUpdateWorkload(WorkloadCommand workLoadAddOrUpdateModel, - Guid userId) - { - var yearMonthStr = workLoadAddOrUpdateModel.WorkTime.ToString("yyyy-MM"); - - - if (workLoadAddOrUpdateModel.Id == Guid.Empty || workLoadAddOrUpdateModel.Id == null) - { - //确定是那个医生 那个项目 那个月份做的 - Expression> workloadLambda = x => x.DoctorId == workLoadAddOrUpdateModel.DoctorId && x.TrialId == workLoadAddOrUpdateModel.TrialId && x.YearMonth == yearMonthStr; - - //只要是来自CRO或者最终确认的 只能有一条 - switch (workLoadAddOrUpdateModel.DataFrom) - { - case (int)WorkLoadFromStatus.CRO: //1 来自CRO的 - workloadLambda = workloadLambda.And(t => t.DataFrom == (int)WorkLoadFromStatus.CRO); - break; - - case (int)WorkLoadFromStatus.FinalConfirm: //2 最终确认的 - workloadLambda = workloadLambda.And(t => t.DataFrom == (int)WorkLoadFromStatus.FinalConfirm); - - var isExist = await _costStatisticsRepository.AnyAsync(u => u.YearMonth == yearMonthStr && u.DoctorId == workLoadAddOrUpdateModel.DoctorId); - if (!isExist) - { - await _costStatisticsRepository.AddAsync(new Payment - { - DoctorId = workLoadAddOrUpdateModel.DoctorId, - YearMonth = yearMonthStr, - YearMonthDate = DateTime.Parse(yearMonthStr), - IsLock = false - }); - } - - //处理 验证项目收入价格是否都填写了 - - var revenuesPriceExist = await _trialRevenuesPriceRepository.AsQueryable() - .FirstOrDefaultAsync(t => t.TrialId == workLoadAddOrUpdateModel.TrialId); - - //没填写收入价格 插入记录 所有的都是false - if (revenuesPriceExist == null) - { - await _trialRevenuesPriceVerificationRepository.AddAsync(new TrialRevenuesPriceVerification() - { - TrialId = workLoadAddOrUpdateModel.TrialId, - ReviewerId = workLoadAddOrUpdateModel.DoctorId, - YearMonth = yearMonthStr, - WorkLoadDate = workLoadAddOrUpdateModel.WorkTime - }); - } - else //有价格 校验 看全不全 - { - - var tpNeedSetPrice = workLoadAddOrUpdateModel.Timepoint > 0 && - revenuesPriceExist.Timepoint <= 0; - var tp24HNeedSetPrice = workLoadAddOrUpdateModel.TimepointIn24H > 0 && - revenuesPriceExist.TimepointIn24H <= 0; - var tp48NeedSetPrice = workLoadAddOrUpdateModel.TimepointIn48H > 0 && - revenuesPriceExist.TimepointIn48H <= 0; - var adNeedSetPrice = workLoadAddOrUpdateModel.Adjudication > 0 && - revenuesPriceExist.Adjudication <= 0; - var ad24NeedSetPrice = workLoadAddOrUpdateModel.AdjudicationIn24H > 0 && - revenuesPriceExist.AdjudicationIn24H <= 0; - var ad48NeedSetPrice = workLoadAddOrUpdateModel.AdjudicationIn48H > 0 && - revenuesPriceExist.AdjudicationIn48H <= 0; - var downtimeNeedSetPrice = workLoadAddOrUpdateModel.Downtime > 0 && - revenuesPriceExist.Downtime <= 0; - var globalNeedSetPrice = workLoadAddOrUpdateModel.Global > 0 && - revenuesPriceExist.Global <= 0; - var trainingNeedSetPrice = workLoadAddOrUpdateModel.Training > 0 && - revenuesPriceExist.Training <= 0; - - var refresherTrainingTrainingNeedSetPrice = workLoadAddOrUpdateModel.RefresherTraining > 0 && - revenuesPriceExist.RefresherTraining <= 0; - - - - - var needAdd = tpNeedSetPrice || tp24HNeedSetPrice || tp48NeedSetPrice || adNeedSetPrice || ad24NeedSetPrice || - ad48NeedSetPrice || downtimeNeedSetPrice || globalNeedSetPrice && trainingNeedSetPrice || refresherTrainingTrainingNeedSetPrice; - - //验证不通过 增加 - if (needAdd) - { - await _trialRevenuesPriceVerificationRepository.AddAsync(new TrialRevenuesPriceVerification() - { - TrialId = workLoadAddOrUpdateModel.TrialId, - ReviewerId = workLoadAddOrUpdateModel.DoctorId, - YearMonth = yearMonthStr, - WorkLoadDate = workLoadAddOrUpdateModel.WorkTime, - //需要设置价格和 有价格是相反的 数据库此字段存储的时候对应项是否有价格 - Timepoint = !tpNeedSetPrice, - TimepointIn24H = !tp24HNeedSetPrice, - TimepointIn48H = !tp48NeedSetPrice, - Adjudication = !adNeedSetPrice, - AdjudicationIn24H = !ad24NeedSetPrice, - AdjudicationIn48H = !ad48NeedSetPrice, - Downtime = !downtimeNeedSetPrice, - Global = !globalNeedSetPrice, - Training = !trainingNeedSetPrice, - RefresherTraining = !refresherTrainingTrainingNeedSetPrice - }); - } - - } - - - break; - } - if (workLoadAddOrUpdateModel.DataFrom != (int)WorkLoadFromStatus.Doctor) - { - if (await _doctorWorkloadRepository.AnyAsync(workloadLambda)) - { - - //---This type of data can only have one - return ResponseOutput.NotOk(_localizer["DoctorWorkload_Unique"]); - - } - } - if (workLoadAddOrUpdateModel.DataFrom == (int)WorkLoadFromStatus.Doctor) - { - Expression> doctorworkloadLambda = x => x.DoctorId == workLoadAddOrUpdateModel.DoctorId && x.TrialId == workLoadAddOrUpdateModel.TrialId && x.YearMonth == yearMonthStr && workLoadAddOrUpdateModel.WorkTime == x.WorkTime; - - doctorworkloadLambda = doctorworkloadLambda.And(t => t.DataFrom == (int)WorkLoadFromStatus.Doctor); - if (await _doctorWorkloadRepository.AnyAsync(doctorworkloadLambda)) - { - //---This type of data can only have one - return ResponseOutput.NotOk(_localizer["DoctorWorkload_Unique"]); - } - } - - var workLoad = _mapper.Map(workLoadAddOrUpdateModel); - - workLoad.YearMonth = yearMonthStr; - - await _doctorWorkloadRepository.AddAsync(workLoad); - - await _enrollRepository.BatchUpdateNoTrackingAsync( - t => t.DoctorId == workLoadAddOrUpdateModel.DoctorId && t.TrialId == workLoadAddOrUpdateModel.TrialId, u => new Enroll() - { - EnrollStatus = EnrollStatus.DoctorReading, - }); - - var success = await _doctorWorkloadRepository.SaveChangesAsync(); - - return ResponseOutput.Result(success, workLoad.Id); - - } - else - { - //判断是否已经被锁定 - var isLocked = await _costStatisticsRepository.AnyAsync(u => u.DoctorId == workLoadAddOrUpdateModel.DoctorId && - u.YearMonth == yearMonthStr && u.IsLock); - if (isLocked) - { - - //---Expenses have been settled and workload cannot be modified. - return ResponseOutput.NotOk(_localizer["DoctorWorkload_FeeSettled"]); - - } - - var success = await _doctorWorkloadRepository.BatchUpdateNoTrackingAsync(t => t.Id == workLoadAddOrUpdateModel.Id, - u => new Workload() - { - Timepoint = workLoadAddOrUpdateModel.Timepoint, - TimepointIn24H = workLoadAddOrUpdateModel.TimepointIn24H, - TimepointIn48H = workLoadAddOrUpdateModel.TimepointIn48H, - - Adjudication = workLoadAddOrUpdateModel.Adjudication, - AdjudicationIn24H = workLoadAddOrUpdateModel.AdjudicationIn24H, - AdjudicationIn48H = workLoadAddOrUpdateModel.AdjudicationIn48H, - - RefresherTraining = workLoadAddOrUpdateModel.RefresherTraining, - - Downtime = workLoadAddOrUpdateModel.Downtime, - Training = workLoadAddOrUpdateModel.Training, - Global = workLoadAddOrUpdateModel.Global, - - WorkTime = workLoadAddOrUpdateModel.WorkTime, - YearMonth = yearMonthStr - }); - return ResponseOutput.Result(success); - - } - } - - /// - /// 删除工作量 - /// - public async Task DeleteWorkload(Guid workloadId) - { - return ResponseOutput.Result(await _doctorWorkloadRepository.BatchDeleteNoTrackingAsync(t => t.Id == workloadId)); - } - - /// - /// 获取工作量详情(用于判断工作量锁定时,调用) - /// - public async Task GetWorkloadDetailById(Guid id) - { - var workload = await _doctorWorkloadRepository.FirstOrDefaultAsync(u => u.Id == id); - return _mapper.Map(workload); - } - - #endregion - - private PageOutput BuildFullData( - List workLoadList, WorkLoadStatsQueryDTO workLoadSearch) - { - var doctor = _doctorRepository.Where(t => t.Id == workLoadSearch.DoctorId).ProjectTo(_mapper.ConfigurationProvider).FirstOrDefault().IfNullThrowException(); - //查询 1-3月的 共3个月 - var month = (workLoadSearch.SearchEndDateTime?.Year - workLoadSearch.SearchBeginDateTime?.Year) * 12 + - (workLoadSearch.SearchEndDateTime?.Month - workLoadSearch.SearchBeginDateTime?.Month) + 1; - - var needCount = month * workLoadSearch.WorkLoadFromStatus.Count ?? 1; - - if (workLoadSearch.WorkLoadFromStatus.Contains((int)WorkLoadFromStatus.FinalConfirm)) - { - if (workLoadList.Count != needCount) - { - for (int i = 0; i < month; i++) - { - var yearMonthStr = workLoadSearch.SearchBeginDateTime?.AddMonths(i).ToString("yyyy-MM"); - if (!workLoadList.Any(t => t.YearMonthStr == yearMonthStr && - t.DataFrom == (int)WorkLoadFromStatus.FinalConfirm)) - { - workLoadList.Add(new WorkLoadDetailDTO() - { - Id = Guid.Empty, - DataFrom = (int)WorkLoadFromStatus.FinalConfirm, - YearMonthStr = yearMonthStr, - ChineseName = doctor.ChineseName, - FirstName = doctor.FirstName, - LastName = doctor.LastName, - Code = doctor.ReviewerCode - }); - } - } - } - } - if (workLoadSearch.WorkLoadFromStatus.Contains((int)WorkLoadFromStatus.CRO)) - { - if (workLoadList.Count != needCount) - { - for (int i = 0; i < month; i++) - { - var yearMonthStr = workLoadSearch.SearchBeginDateTime?.AddMonths(i).ToString("yyyy-MM"); - if (!workLoadList.Any(t => t.YearMonthStr == yearMonthStr && - t.DataFrom == (int)WorkLoadFromStatus.CRO)) - { - workLoadList.Add(new WorkLoadDetailDTO() - { - Id = Guid.Empty, - DataFrom = (int)WorkLoadFromStatus.CRO, - YearMonthStr = yearMonthStr, - ChineseName = doctor.ChineseName, - FirstName = doctor.FirstName, - LastName = doctor.LastName, - Code = doctor.ReviewerCode - }); - } - } - } - } - if (workLoadSearch.WorkLoadFromStatus.Contains((int)WorkLoadFromStatus.Doctor)) - { - if (workLoadList.Count != needCount) - { - for (int i = 0; i < month; i++) - { - var yearMonthStr = workLoadSearch.SearchBeginDateTime?.AddMonths(i).ToString("yyyy-MM"); - if (!workLoadList.Any(t => t.YearMonthStr == yearMonthStr && - t.DataFrom == (int)WorkLoadFromStatus.Doctor)) - { - workLoadList.Add(new WorkLoadDetailDTO() - { - Id = Guid.Empty, - DataFrom = (int)WorkLoadFromStatus.Doctor, - YearMonthStr = yearMonthStr, - ChineseName = doctor.ChineseName, - FirstName = doctor.FirstName, - LastName = doctor.LastName, - Code = doctor.ReviewerCode - }); - } - } - } - - } - - workLoadList = workLoadList.OrderByDescending(t => t.YearMonthStr).ThenBy(t => t.DataFrom) - .ToList(); - int tempRowId = 0; - foreach (var workLoad in workLoadList) - { - workLoad.RowGuid = Guid.NewGuid(); - workLoad.RowIntId = tempRowId + 1; - tempRowId++; - } - - return new PageOutput(1, workLoadList.Count, - workLoadList.Count, workLoadList); - - - } - - - } -} diff --git a/IRaCIS.Core.Application/Service/WorkLoad/EnrollService.cs b/IRaCIS.Core.Application/Service/WorkLoad/EnrollService.cs deleted file mode 100644 index 1fc3c3e04..000000000 --- a/IRaCIS.Core.Application/Service/WorkLoad/EnrollService.cs +++ /dev/null @@ -1,517 +0,0 @@ -using IRaCIS.Application.Interfaces; -using IRaCIS.Core.Infra.EFCore; -using IRaCIS.Core.Domain.Share; -using IRaCIS.Core.Application.Filter; -using Microsoft.AspNetCore.Mvc; -using IRaCIS.Core.Application.Service.WorkLoad.DTO; -using Microsoft.AspNetCore.Authorization; -using IRaCIS.Core.Application.Auth; -using System.Text.RegularExpressions; - -namespace IRaCIS.Application.Services -{ - [ApiExplorerSettings(GroupName = "Enroll")] - public class EnrollService : BaseService, IEnrollService - { - private readonly IRepository _trialRepository; - private readonly IRepository _trialDetailRepository; - - private readonly IRepository _TrialPaymentPriceRepository; - private readonly IRepository _enrollRepository; - private readonly IRepository _doctorRepository; - private readonly IRepository _enrollDetailRepository; - private readonly IRepository _workloadRepository; - private readonly IMailVerificationService _mailVerificationService; - - //private readonly IRepository _trialUserRepository; - - - public EnrollService(IRepository clinicalTrialProjectRepository, - IRepository clinicalProjectDetailRepository, - IRepository intoGroupRepository, - IRepository doctorRepository, - IRepository TrialPaymentPriceRepository, - IRepository intoGroupDetailRepository, - IRepository workloadRepository, - IMailVerificationService mailVerificationService) - { - _trialRepository = clinicalTrialProjectRepository; - _TrialPaymentPriceRepository = TrialPaymentPriceRepository; - _doctorRepository = doctorRepository; - - _trialDetailRepository = clinicalProjectDetailRepository; - _enrollRepository = intoGroupRepository; - _enrollDetailRepository = intoGroupDetailRepository; - _workloadRepository = workloadRepository; - - _mailVerificationService = mailVerificationService; - //_trialUserRepository = trialUserRepository; - - } - - - - /// - /// 添加或更新项目医生项目价格 - /// - [HttpPost] - public async Task AddOrUpdateEnroll(EnrollCommand addOrUpdateModel) - { - - var trialDoctoritem = await _enrollRepository.FirstOrDefaultAsync(u => u.Id == addOrUpdateModel.Id); - if (trialDoctoritem == null)//insert - { - await _enrollRepository.InsertFromDTOAsync(addOrUpdateModel); - } - else//update - { - await _enrollRepository.UpdateFromDTOAsync(addOrUpdateModel); - } - var success = await _enrollRepository.SaveChangesAsync(); - return ResponseOutput.Result(success); - } - - - - /// - /// 获取医生项目列表 - /// - /// - /// - [HttpPost] - public async Task> GetTrialDoctorList(EnrollGetQuery challengeQuery) - { - var costStatisticsQueryable = from enroll in _enrollRepository.Where(t => t.TrialId == challengeQuery.TrialId) - join dociorc in _doctorRepository.Where() on enroll.DoctorId equals dociorc.Id - join price in _TrialPaymentPriceRepository.Where() on enroll.TrialId equals price.TrialId - select new EnrollViewModel() - { - ChineseName = dociorc.ChineseName, - AdjustmentMultiple = enroll.AdjustmentMultiple, - FirstName = dociorc.FirstName, - LastName = dociorc.LastName, - DoctorId = dociorc.Id, - TrialId = challengeQuery.TrialId, - Id = enroll.Id, - Training = enroll.Training, - RefresherTraining = enroll.RefresherTraining, - Timepoint = enroll.Timepoint, - Timepoint48H = enroll.Timepoint48H, - Timepoint24H = enroll.Timepoint24H, - Adjudication = enroll.Adjudication, - Adjudication48H = enroll.Adjudication48H, - Adjudication24H = enroll.Adjudication24H, - Global = enroll.Global, - Code = dociorc.Code, - ReviewerCode = dociorc.ReviewerCode, - Downtime = enroll.Downtime, - }; - return await costStatisticsQueryable.ToPagedListAsync(challengeQuery.PageIndex, challengeQuery.PageSize, "ChineseName"); - - - - //var query2 = _repository.Where(x => x.TrialId == challengeQuery.TrialId) - // .WhereIf(challengeQuery.TrialId != null, t => t.TrialId == challengeQuery.TrialId) - // .WhereIf(challengeQuery.DoctorId != null, t => t.DoctorId == challengeQuery.DoctorId) - - // .ProjectTo(_mapper.ConfigurationProvider); - - //var pageList = await query2.ToListAsync(); - - - // return new PageOutput(challengeQuery.pageIndex, challengeQuery.pageSize, - //costStatisticsQueryable); - - - } - - - #region Reviewer 入组审核流程(select-submit-approve-confirm) - - /// 为项目筛选医生 提交 【select】 - /// 项目Id - /// 医生Id数组 - /// - - [HttpPost("{trialId:guid}")] - [TypeFilter(typeof(TrialResourceFilter),Arguments = new object[] { "AfterStopCannNotOpt" })] - //[Authorize(Policy = IRaCISPolicy.PM_APM_SPM_CPM_SMM_CMM)] - public async Task SelectReviewers(Guid trialId, Guid[] doctorIdArray) - { - var trial = await _trialRepository.FirstOrDefaultAsync(t => t.Id == trialId); - - if (trial == null) return Null404NotFound(trial); - - //_trialRepository.Attach(trial); - - //更新项目状态 - trial.TrialEnrollStatus = (int)TrialEnrollStatus.HasApplyDownLoadResume; - - //_trialRepository.Update(trial); - - //添加项目状态变化记录 - var trialDetail = new TrialStatusDetail() - { - TrialId = trial.Id, - TrialStatus = (int)TrialEnrollStatus.HasApplyDownLoadResume, - }; - await _trialDetailRepository.AddAsync(trialDetail); - - // 入组表 入组状态跟踪表 - foreach (var doctorId in doctorIdArray) - { - await _enrollRepository.AddAsync(new Enroll() - { - DoctorId = doctorId, - TrialId = trialId, - EnrollStatus = EnrollStatus.HasApplyDownloadResume, - - DoctorUserId = _repository.Where(t => t.DoctorId == doctorId).Select(t => t.Id).FirstOrDefault() - }); ; - - await _enrollDetailRepository.AddAsync(new EnrollDetail() - { - DoctorId = doctorId, - TrialId = trialId, - EnrollStatus = EnrollStatus.HasApplyDownloadResume, - OptUserType = (int)SystemUserType.AdminUser, - }); - } - - return ResponseOutput.Result(await _enrollRepository.SaveChangesAsync()); - - } - - /// - /// 入组流程-向CRO提交医生[Submit] - /// - - [HttpPost("{trialId:guid}/{commitState:int}")] - [TypeFilter(typeof(TrialResourceFilter),Arguments = new object[] { "AfterStopCannNotOpt" })] - //[Authorize(Policy = IRaCISPolicy.PM_APM_SPM_CPM_SMM_CMM)] - public async Task SubmitReviewer(Guid trialId, Guid[] doctorIdArray, int commitState) - { - - var trial = await _trialRepository.FirstOrDefaultAsync(t => t.Id == trialId); - - - if (trial != null) - { - if (commitState == 1) //确认提交CRO - { - //更新项目状态 - trial.TrialEnrollStatus = (int)TrialEnrollStatus.HasCommitCRO; - - //添加项目详细记录 - var trialDetail = new TrialStatusDetail() - { - TrialId = trial.Id, - TrialStatus = (int)TrialEnrollStatus.HasCommitCRO - }; - await _trialDetailRepository.AddAsync(trialDetail); - - //更新入组表 跟踪了 所以不用下面的_enrollRepository.Update(intoGroupItem); - var intoGroupList = await _enrollRepository.Where(t => t.TrialId == trialId, true).ToListAsync(); - - foreach (var intoGroupItem in intoGroupList) - { - if (doctorIdArray.Contains(intoGroupItem.DoctorId)) - { - intoGroupItem.EnrollStatus = EnrollStatus.HasCommittedToCRO; - //_enrollRepository.Update(intoGroupItem); - - await _enrollDetailRepository.AddAsync(new EnrollDetail() - { - TrialDetailId = trialDetail.Id, - DoctorId = intoGroupItem.DoctorId, - TrialId = trialId, - EnrollStatus = EnrollStatus.HasCommittedToCRO, - OptUserType = (int)SystemUserType.AdminUser, //后台用户 - }); - } - } - - - } - else if (commitState == 0)//回退上一步 - { - //更新入组表 - var intoGroupList = await _enrollRepository.Where(t => t.TrialId == trialId, true).ToListAsync(); - - foreach (var intoGroupItem in intoGroupList) - { - if (doctorIdArray.Contains(intoGroupItem.DoctorId)) - { - intoGroupItem.EnrollStatus = EnrollStatus.HasApplyDownloadResume; - - //_enrollRepository.Update(intoGroupItem); - - - var deleteItem = await _enrollDetailRepository.FirstOrDefaultAsync(t => - t.TrialId == trialId && t.DoctorId == intoGroupItem.DoctorId && - t.EnrollStatus == EnrollStatus.HasCommittedToCRO); - - await _enrollDetailRepository.DeleteAsync(deleteItem); - } - } - - - } - return ResponseOutput.Result(await _enrollRepository.SaveChangesAsync()); - } - //$"Cannot find trial {trialId}" - return ResponseOutput.NotOk(_localizer["Enroll_NotFound", trialId]); - } - - /// - /// 入组流程-CRO确定医生名单 [ Approve] - /// - - [HttpPost("{trialId:guid}/{auditState:int}")] - [TypeFilter(typeof(TrialResourceFilter),Arguments = new object[] { "AfterStopCannNotOpt" })] - //[Authorize(Policy = IRaCISPolicy.PM_APM_SPM_CPM_SMM_CMM)] - public async Task ApproveReviewer(Guid trialId, Guid[] doctorIdArray, int auditState) - { - - var trial = await _trialRepository.FirstOrDefaultAsync(t => t.Id == trialId); - - if (trial == null) return Null404NotFound(trial); - - if (auditState == 1) //确认入组 - { - //var existItem = _trialRepository.FindSingleOrDefault(u => u.Id == trialId && u.TrialStatus >= (int)TrialEnrollStatus.HasConfirmedDoctorNames); - //if (existItem == null) - //{ - // trial.TrialStatus = (int)TrialEnrollStatus.HasConfirmedDoctorNames; - // trial.TrialStatusStr = "Approved"; - //} - //_trialRepository.Update(trial); - - //更新项目状态 - trial.TrialEnrollStatus = (int)TrialEnrollStatus.HasConfirmedDoctorNames; - - //添加项目详细记录 - var trialDetail = new TrialStatusDetail() - { - TrialId = trialId, - TrialStatus = (int)TrialEnrollStatus.HasConfirmedDoctorNames - }; - await _trialDetailRepository.AddAsync(trialDetail); - - //更新入组表 跟踪方式,不用下面的_enrollRepository.Update(intoGroupItem); - var intoGroupList = _enrollRepository.Where(t => t.TrialId == trialId, true).ToList(); - - - foreach (var intoGroupItem in intoGroupList) - { - if (doctorIdArray.Contains(intoGroupItem.DoctorId)) - { - intoGroupItem.EnrollStatus = EnrollStatus.InviteIntoGroup; - //_enrollRepository.Update(intoGroupItem); - - await _enrollDetailRepository.AddAsync(new EnrollDetail() - { - DoctorId = intoGroupItem.DoctorId, - TrialId = trialId, - EnrollStatus = EnrollStatus.InviteIntoGroup, - OptUserType = (int)SystemUserType.AdminUser, //后台用户 - }); - } - } - - } - else if (auditState == 0)//回退上一步 - { - //更新入组表 - var intoGroupList = _enrollRepository.Where(t => t.TrialId == trialId, true).ToList(); - - foreach (var intoGroupItem in intoGroupList) - { - if (doctorIdArray.Contains(intoGroupItem.DoctorId)) - { - intoGroupItem.EnrollStatus = EnrollStatus.HasCommittedToCRO; - - //_enrollRepository.Update(intoGroupItem); - - var deleteItem = await _enrollDetailRepository.FirstOrDefaultAsync(t => - t.TrialId == trialId && t.DoctorId == intoGroupItem.DoctorId && - t.EnrollStatus == EnrollStatus.InviteIntoGroup); - - await _enrollDetailRepository.DeleteAsync(deleteItem); - } - } - - - } - return ResponseOutput.Result(await _enrollRepository.SaveChangesAsync()); - - - - } - - /// - /// 入组流程-后台确认医生入组[Confirm] - /// - - [HttpPost] - [TypeFilter(typeof(TrialResourceFilter),Arguments = new object[] { "AfterStopCannNotOpt" })] - //[Authorize(Policy = IRaCISPolicy.PM_APM_SPM_CPM_SMM_CMM)] - [UnitOfWork] - public async Task ConfirmReviewer(ConfirmReviewerCommand confirmReviewerCommand, - [FromServices] IRepository _trialUserRepository, - [FromServices] IRepository _taskAllocationRuleRepository) - { - //var trial = _trialRepository.FirstOrDefault(t => t.Id == trialId); - //var existItem = _trialRepository.FindSingleOrDefault(u => u.Id == trialId && u.TrialStatus >= (int)TrialEnrollStatus.HasConfirmedDoctorNames); - - //trial.TrialStatusStr = "Reading"; - ////trial.TrialStatus = (int)TrialStatus.HasConfirmedDoctorNames; - //_trialRepository.Update(trial); - - var trialId = confirmReviewerCommand.TrialId; - - var trial = await _trialRepository.FirstOrDefaultAsync(t => t.Id == trialId); - - if (trial == null) return Null404NotFound(trial); - - - //更新入组表 - var intoGroupList = await _enrollRepository.Where(t => t.TrialId == trialId,true).ToListAsync(); - - //验证邮件 - var emaiList = await _doctorRepository.Where(t => intoGroupList.Select(t => t.DoctorId).Contains(t.Id)) - .Select(t => new { t.EMail, t.FirstName, t.LastName }).ToListAsync(); - - - var errorList = emaiList.Where(t => !Regex.IsMatch(t.EMail, @"^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$")) - .ToList(); - - if (errorList.Count() > 0) - { - // errorList.Select(c => c.LastName+" / "+c.FirstName)) +"邮箱格式存在问题" - return ResponseOutput.NotOk(string.Join(',', _localizer["Enroll_EmailFormat"], errorList.Select(c => c.LastName + " / " + c.FirstName))) ; - } - - if (confirmReviewerCommand.ConfirmState == 1) //确认入组 - { - foreach (var intoGroupItem in intoGroupList) - { - if (confirmReviewerCommand.DoctorIdArray.Contains(intoGroupItem.DoctorId)) - { - - //当邮件发送没有问题的时候,才修改状态 如果有问题,就当前不做处理 - try - { - var userId = await _mailVerificationService.DoctorJoinTrialEmail(trialId, intoGroupItem.DoctorId, confirmReviewerCommand.BaseUrl, confirmReviewerCommand.RouteUrl); - - if (!await _trialUserRepository.AnyAsync(t => t.TrialId == trialId && t.UserId == userId, true)) - { - await _trialUserRepository.AddAsync(new TrialUser() { TrialId = trialId, UserId = userId, JoinTime = DateTime.Now }); - } - - await _enrollRepository.BatchUpdateNoTrackingAsync(t => t.Id == intoGroupItem.Id, u => new Enroll() { DoctorUserId = userId }); - - if (!await _taskAllocationRuleRepository.AnyAsync(t => t.TrialId == trialId && t.DoctorUserId == userId && t.EnrollId == intoGroupItem.Id, true)) - { - await _taskAllocationRuleRepository.AddAsync(new TaskAllocationRule() { TrialId = trialId, DoctorUserId = userId, EnrollId = intoGroupItem.Id }); - - } - - await _enrollDetailRepository.AddAsync(new EnrollDetail() - { - DoctorId = intoGroupItem.DoctorId, - TrialId = trialId, - EnrollStatus = EnrollStatus.ConfirmIntoGroup, - OptUserType = (int)SystemUserType.AdminUser, //后台用户 - }); - - intoGroupItem.EnrollStatus = EnrollStatus.ConfirmIntoGroup; - intoGroupItem.EnrollTime = DateTime.Now; - } - catch (Exception ) - { - intoGroupItem.EnrollStatus = EnrollStatus.ConfirmIntoGroupFailed; - - } - - } - } - - } - else if (confirmReviewerCommand.ConfirmState == 0)//回退上一步 - { - foreach (var intoGroupItem in intoGroupList) - { - if (confirmReviewerCommand.DoctorIdArray.Contains(intoGroupItem.DoctorId)) - { - intoGroupItem.EnrollStatus = EnrollStatus.InviteIntoGroup; - intoGroupItem.EnrollTime = null; - - - var deleteItem = await _enrollDetailRepository.FirstOrDefaultAsync(t => - t.TrialId == trialId && t.DoctorId == intoGroupItem.DoctorId && - t.EnrollStatus == EnrollStatus.ConfirmIntoGroup); - - await _enrollDetailRepository.DeleteAsync(deleteItem); - } - } - - - } - - await _enrollRepository.SaveChangesAsync(); - return ResponseOutput.Ok(); - - } - - - - /// - /// optType 0表示入组,列表没这条数据了, 1表示出组,需要填写出组时间 废弃 - /// - /// - /// - /// - /// - /// - [HttpPost("{trialId:guid}/{doctorId:guid}/{optType:int}")] - [TypeFilter(typeof(TrialResourceFilter),Arguments = new object[] { "AfterStopCannNotOpt" })] - //[Authorize(Policy = IRaCISPolicy.PM_APM_SPM_CPM)] - [Obsolete] - public async Task EnrollBackOrOut(Guid trialId, Guid doctorId, int optType, DateTime? outEnrollTime) - { - var intoGroupItem = await _enrollRepository.FirstOrDefaultAsync(t => t.TrialId == trialId && t.DoctorId == doctorId); - if (optType == 0) - { - var sum = _workloadRepository.Where(t => - t.TrialId == trialId && t.DoctorId == doctorId && - t.DataFrom == (int)WorkLoadFromStatus.FinalConfirm) - .Sum(u => u.Adjudication + u.AdjudicationIn24H + u.AdjudicationIn48H + u.Timepoint + - u.TimepointIn24H + u.TimepointIn48H + u.RefresherTraining + u.Training + u.Global + - u.Downtime); - if (sum != 0) - { - //---Reviewers with workload cannot go back - return ResponseOutput.NotOk(_localizer["Enroll_CannotRollback"]); - } - - intoGroupItem.EnrollStatus = EnrollStatus.InviteIntoGroup; - intoGroupItem.EnrollTime = null; - - var deleteItem = await _enrollDetailRepository.FirstOrDefaultAsync(t => - t.TrialId == trialId && t.DoctorId == intoGroupItem.DoctorId && - t.EnrollStatus == EnrollStatus.ConfirmIntoGroup); - - await _enrollDetailRepository.DeleteAsync(deleteItem); - - } - else if (optType == 1) - { - intoGroupItem.OutEnrollTime = outEnrollTime; - } - return ResponseOutput.Result(await _enrollRepository.SaveChangesAsync()); - } - #endregion - - } -} diff --git a/IRaCIS.Core.Application/Service/WorkLoad/Interface/IDoctorWorkloadService.cs b/IRaCIS.Core.Application/Service/WorkLoad/Interface/IDoctorWorkloadService.cs deleted file mode 100644 index b3972e414..000000000 --- a/IRaCIS.Core.Application/Service/WorkLoad/Interface/IDoctorWorkloadService.cs +++ /dev/null @@ -1,18 +0,0 @@ -using IRaCIS.Application.Contracts; - -namespace IRaCIS.Application.Services -{ - public interface IDoctorWorkloadService - { - Task AddOrUpdateWorkload(WorkloadCommand workLoadAddOrUpdateModel, Guid userId); - //Task DeleteReviewerAckSOW(Guid trialId, Guid doctorId, Guid attachmentId); - Task DeleteWorkload(Guid workloadId); - PageOutput GetEnrollmentWorkloadStatsDetail(WorkLoadStatsQueryDTO workLoadSearch); - Task> GetReviewerWorkLoadListDetail(WorkLoadDetailQueryDTO workLoadSearch); - Task> GetTrialEnrollmentWorkloadStats(WorkLoadDoctorQueryDTO doctorSearchModel); - Task GetWorkloadDetailById(Guid id); - Task UpdateReviewerReadingType(Guid trialId, Guid doctorId, int type); - //Task UploadReviewerAckSOW(Guid trialId, ReviewerAckDTO attachmentViewModel); - Task> WorkloadExist(WorkloadExistQueryDTO param); - } -} \ No newline at end of file diff --git a/IRaCIS.Core.Application/Service/WorkLoad/Interface/IEnrollService.cs b/IRaCIS.Core.Application/Service/WorkLoad/Interface/IEnrollService.cs deleted file mode 100644 index bc34d3197..000000000 --- a/IRaCIS.Core.Application/Service/WorkLoad/Interface/IEnrollService.cs +++ /dev/null @@ -1,15 +0,0 @@ -using IRaCIS.Core.Application.Service.WorkLoad.DTO; - -namespace IRaCIS.Application.Services -{ - public interface IEnrollService - { - Task AddOrUpdateEnroll(EnrollCommand addOrUpdateModel); - Task ApproveReviewer(Guid trialId, Guid[] doctorIdArray, int auditState); - //Task ConfirmReviewer(Guid trialId, Guid[] doctorIdArray, int confirmState); - Task EnrollBackOrOut(Guid trialId, Guid doctorId, int optType, DateTime? outEnrollTime); - Task> GetTrialDoctorList(EnrollGetQuery challengeQuery); - Task SelectReviewers(Guid trialId, Guid[] doctorIdArray); - Task SubmitReviewer(Guid trialId, Guid[] doctorIdArray, int commitState); - } -} \ No newline at end of file diff --git a/IRaCIS.Core.Application/Service/WorkLoad/Interface/ITrialEnrollmentService.cs b/IRaCIS.Core.Application/Service/WorkLoad/Interface/ITrialEnrollmentService.cs deleted file mode 100644 index e0e5374ee..000000000 --- a/IRaCIS.Core.Application/Service/WorkLoad/Interface/ITrialEnrollmentService.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System; -using IRaCIS.Core.Application.Service.WorkLoad.DTO; -using IRaCIS.Core.Infrastructure.Extention; - -namespace IRaCIS.Application.Interfaces -{ - public interface ITrialEnrollmentService - { - IResponseOutput AddOrUpdateEnroll(EnrollCommand addOrUpdateModel); - - Task< PageOutput> GetTrialDoctorList(EnrollGetQuery challengeQuery); - - /// 入组流程-筛选医生 [select] - IResponseOutput SelectReviewers( Guid trialId, Guid[] doctorIdArray); - - /// 入组流程-向CRO提交医生[Submit] - IResponseOutput SubmitReviewer( Guid trialId, Guid[] doctorIdArray, int commitState); - - /// 入组流程-CRO确定医生名单 [ Approve] - IResponseOutput ApproveReviewer( Guid trialId, Guid[] doctorIdArray, int auditState); - - /// 入组流程-向CRO提交医生[Submit] - IResponseOutput ConfirmReviewer(Guid trialId, Guid[] doctorIdArray, int confirmState); - - - IResponseOutput EnrollBackOrOut( Guid trialId, Guid doctorId, int optType,DateTime? outEnrollTime); - - } -} diff --git a/IRaCIS.Core.Application/Service/WorkLoad/Interface/IWorkloadDistributionService.cs b/IRaCIS.Core.Application/Service/WorkLoad/Interface/IWorkloadDistributionService.cs deleted file mode 100644 index 7043447d9..000000000 --- a/IRaCIS.Core.Application/Service/WorkLoad/Interface/IWorkloadDistributionService.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; -using System.Collections.Generic; -using IRaCIS.Application.Contracts; -using IRaCIS.Core.Infrastructure.Extention; - -namespace IRaCIS.Core.Application.Contracts -{ - public interface IWorkloadDistributionService - { - PageOutput GetWorkloadTPList(WorkloadDistributionQueryParam param); - IResponseOutput DistributeTP(WorkloadTPCommand workloadTPCommand); - IResponseOutput UpdateDistributeTP(Guid tpId, Guid ReviewerId, Guid studyId); - - PageOutput GetWorkloadGlobalList(WorkloadDistributionQueryParam param); - IResponseOutput DistributeGlobal(WorkloadGlobalCommand workloadGlobalCommand); - IResponseOutput UpdateDistributeGlobal(Guid tpId, Guid ReviewerId,Guid subjectId, decimal visitNum); - - PageOutput GetWorkloadADList(WorkloadDistributionQueryParam param); - IResponseOutput DistributeAD(WorkloadAdCommand workloadTPCommand); - IResponseOutput UpdateDistributeAD(Guid tpId, Guid ReviewerId); - - IResponseOutput> GetWorkloadDetail(Guid WorkloadId); - - IResponseOutput UpdateGlobalStatus(Guid globalId); - - } -} diff --git a/IRaCIS.Core.Application/Service/WorkLoad/WorkloadDistributionService.cs b/IRaCIS.Core.Application/Service/WorkLoad/WorkloadDistributionService.cs deleted file mode 100644 index ddc073534..000000000 --- a/IRaCIS.Core.Application/Service/WorkLoad/WorkloadDistributionService.cs +++ /dev/null @@ -1,573 +0,0 @@ -//using IRaCIS.Application.Contracts; -//using IRaCIS.Core.Application.Contracts; -//using System.Linq.Expressions; -//using IRaCIS.Core.Infrastructure.ExpressionExtend; -//using IRaCIS.Core.Infra.EFCore; -//using IRaCIS.Core.Domain.Models; -//using IRaCIS.Core.Domain.Share; -//using IRaCIS.Core.Infrastructure.Extention; -//using Microsoft.AspNetCore.Mvc; - -//namespace IRaCIS.Core.Application.Services -//{ -// /// -// /// TP、Global、AD 工作量分配查看 -// /// -// [ ApiExplorerSettings(GroupName = "Trial")] -//#pragma warning disable -// public class WorkloadDistributionService : BaseService, IWorkloadDistributionService -// { -// private readonly IWorkloadTPRepository _workloadTpRepository; -// private readonly IWorkloadGlobalRepository _workloadGlobalRepository; -// private readonly IWorkloadADRepository _workloadAdRepository; -// private readonly IRepository _subjectVisitRepository; -// private readonly IRepository _studyRepository; -// private readonly IRepository _doctorRepository; -// private readonly IRepository _subjectRepository; -// private readonly IRepository _siteRepository; -// private readonly IWorkloadDetailRepository _workloadDetailRepository; - - -// public WorkloadDistributionService(IWorkloadTPRepository workloadTpRepository, -// IWorkloadGlobalRepository workloadGlobalRepository, -// IWorkloadADRepository workloadAdRepository, -// IRepository subjectVisitRepository, IRepository studyRepository, -// IRepository doctorRepository, IRepository subjectRepository, -// IRepository siteRepository, -// IWorkloadDetailRepository workloadDetailRepository, -// IUserInfo userInfo) -// { -// _workloadTpRepository = workloadTpRepository; -// _workloadGlobalRepository = workloadGlobalRepository; -// _workloadAdRepository = workloadAdRepository; -// _subjectVisitRepository = subjectVisitRepository; -// _studyRepository = studyRepository; -// _doctorRepository = doctorRepository; -// _subjectRepository = subjectRepository; -// _siteRepository = siteRepository; -// _workloadDetailRepository = workloadDetailRepository; - -// } - -// /// -// /// 批量分配Tp -// /// -// /// -// /// -// [HttpPost] -// public IResponseOutput DistributeTP(WorkloadTPCommand workloadTPCommand) -// { -// //当前采用的是没有提示到具体的TP,如有需要在修改下 -// var studyIdList = workloadTPCommand.TpList.Select(u => u.StudyId); -// var temp = _workloadTpRepository.Where(u => studyIdList.Contains(u.StudyId) && u.ReviewerId == workloadTPCommand.ReviewerId); -// if (temp.Any() ) -// { -// return ResponseOutput.NotOk("The TPs of different Arms of the same subject couldn't be assigned to the same reviewer."); -// } -// var success = false; -// workloadTPCommand.TpList.ForEach(t => -// { -// _workloadDetailRepository.Add(new WorkloadDetail -// { -// WorkloadId = t.Id, -// OptUserName = _userInfo.RealName, -// OptTime = DateTime.Now, -// Status = (int)WorkloadStatus.Distributed, -// ReviewerId = workloadTPCommand.ReviewerId -// }); -// _workloadDetailRepository.SaveChanges(); -// success = _workloadTpRepository.Update(u => u.Id == t.Id, k => new WorkloadTP() -// { -// ReviewerId = workloadTPCommand.ReviewerId, -// Status = (int)WorkloadStatus.Distributed -// }); -// }); -// return ResponseOutput.Result(success); -// } - - -// /// -// /// 批量分配AD -// /// -// /// -// /// -// [HttpPost] -// public IResponseOutput DistributeAD(WorkloadAdCommand workloadTPCommand) -// { -// var success = false; -// workloadTPCommand.IdList.ForEach(t => -// { -// _workloadDetailRepository.Add(new WorkloadDetail -// { -// WorkloadId = t, -// OptUserName = _userInfo.RealName, -// OptTime = DateTime.Now, -// Status = (int)WorkloadStatus.Distributed, -// ReviewerId = workloadTPCommand.ReviewerId -// }); -// _workloadDetailRepository.SaveChanges(); -// success = _workloadAdRepository.Update(u => u.Id == t, k => new WorkloadAD() -// { -// ReviewerId = workloadTPCommand.ReviewerId, -// Status = (int)WorkloadStatus.Distributed -// }); -// }); -// return ResponseOutput.Result(success); -// } - -// /// -// /// 批量分配Global -// /// -// /// -// /// -// [HttpPost] -// public IResponseOutput DistributeGlobal(WorkloadGlobalCommand workloadGCommand) -// { -// var temp = _workloadGlobalRepository.Where(u => workloadGCommand.GlobalList.Select(s => s.SubjectId).Contains(u.SubjectId) -// && workloadGCommand.GlobalList.Select(s => s.VisitNum).Contains(u.VisitNum) && -// u.ReviewerId == workloadGCommand.ReviewerId); -// if (temp.Any()) -// { -// return ResponseOutput.NotOk("The Globals of different Arms of the same subject couldn't be assigned to the same reviewer."); -// } - -// var success = false; -// workloadGCommand.GlobalList.ForEach(t => -// { -// _workloadDetailRepository.Add(new WorkloadDetail -// { -// WorkloadId = t.Id, -// OptUserName = _userInfo.RealName, -// OptTime = DateTime.Now, -// Status = (int)WorkloadStatus.Distributed, -// ReviewerId = workloadGCommand.ReviewerId -// }); -// _workloadDetailRepository.SaveChanges(); -// success = _workloadGlobalRepository.Update(u => u.Id == t.Id, k => new WorkloadGlobal() -// { -// ReviewerId = workloadGCommand.ReviewerId, -// Status = (int)WorkloadStatus.Distributed -// }); -// }); -// return ResponseOutput.Result(success); -// } - -// [HttpPost] -// public PageOutput GetWorkloadGlobalList(WorkloadDistributionQueryParam param) -// { -// IQueryable query = null; -// Expression> workloadTPLambda = x => x.TrialId == param.TrialId; -// if (param.SiteId != null) -// { -// workloadTPLambda = workloadTPLambda.And(t => t.SiteId == param.SiteId); -// } - -// if (param.Status != null) -// { -// workloadTPLambda = workloadTPLambda.And(t => t.Status == param.Status); -// } -// if (!string.IsNullOrEmpty(param.WorkloadCode)) -// { -// var globalCode = param.WorkloadCode.Trim(); -// workloadTPLambda = workloadTPLambda.And(t => t.GlobalCode.Contains(globalCode)); -// } -// if (param.GroupId != null && param.GroupId > 0) -// { -// var groupCode = "G0" + param.GroupId; -// workloadTPLambda = workloadTPLambda.And(t => t.GlobalCode.Contains(groupCode)); -// } - -// Expression> subjectLambda = x => x.TrialId == param.TrialId; -// if (!string.IsNullOrEmpty(param.SubjectCode)) -// { -// var subjectCode = param.SubjectCode.Trim(); -// subjectLambda = subjectLambda.And(t => t.Code.Contains(subjectCode)); -// } -// Expression> doctorLambda = x => true; -// if (!string.IsNullOrEmpty(param.Reviewer)) -// { -// var reviewer = param.Reviewer.Trim(); - -// doctorLambda = doctorLambda.And(t => t.ChineseName.Contains(reviewer) -// || t.FirstName.Contains(reviewer) || t.LastName.Contains(reviewer)); -// query = from workloadG in _workloadGlobalRepository.Where(workloadTPLambda) -// join subject in _subjectRepository.Where(subjectLambda) on workloadG.SubjectId equals subject.Id -// join site in _siteRepository.AsQueryable() on workloadG.SiteId equals site.Id -// join doctor in _doctorRepository.Where(doctorLambda) on workloadG.ReviewerId equals doctor.Id -// select new WorkloadGlobalDTO() -// { -// Id = workloadG.Id, -// ReviewerCode = doctor.ReviewerCode, -// ReviewerChineseName = doctor.ChineseName, -// ReviewerFirstName = doctor.FirstName, -// ReviewerId = doctor.Id, -// ReviewerLastName = doctor.LastName, -// SiteId = workloadG.SiteId, -// SiteName = site.SiteName, -// Status = workloadG.Status, -// GlobalCode = workloadG.GlobalCode, -// SubjectCode = subject.Code, -// VisitId = workloadG.VisitId, -// UpdateTime = workloadG.UpdateTime, -// SubjectId = workloadG.SubjectId, -// VisitNum = workloadG.VisitNum, -// VisitName = workloadG.VisitName -// }; -// } -// else -// { -// query = from workloadG in _workloadGlobalRepository.Where(workloadTPLambda) -// join subject in _subjectRepository.Where(subjectLambda) on workloadG.SubjectId equals subject.Id -// join site in _siteRepository.AsQueryable() on workloadG.SiteId equals site.Id -// join doctor in _doctorRepository.Where(doctorLambda) on workloadG.ReviewerId equals doctor.Id into cc -// from doctor in cc.DefaultIfEmpty() -// select new WorkloadGlobalDTO() -// { -// Id = workloadG.Id, -// ReviewerCode = doctor.ReviewerCode, -// ReviewerChineseName = doctor.ChineseName, -// ReviewerFirstName = doctor.FirstName, -// ReviewerId = doctor.Id, -// ReviewerLastName = doctor.LastName, -// SiteId = workloadG.SiteId, -// SiteName = site.SiteName, -// Status = workloadG.Status, -// GlobalCode = workloadG.GlobalCode, -// SubjectCode = subject.Code, -// VisitId = workloadG.VisitId, -// UpdateTime = workloadG.UpdateTime, -// SubjectId = workloadG.SubjectId, -// VisitNum = workloadG.VisitNum, -// VisitName = workloadG.VisitName -// }; -// } - -// var count = query.Count(); - -// var propName = param.SortField == string.Empty ? "GlobalCode" : param.SortField; - -// query = param.Asc -// ? query.OrderBy(propName).ThenBy(t => t.SiteName).ThenBy(t => t.SubjectCode) -// : query.OrderByDescending(propName).ThenBy(t => t.SiteName).ThenBy(t => t.SubjectCode); - -// query = query.Skip((param.PageIndex - 1) * param.PageSize).Take(param.PageSize); -// var list = query.ToList(); - -// return new PageOutput(param.PageIndex, -// param.PageSize, count, list); -// } - -// [HttpPost] -// public PageOutput GetWorkloadADList(WorkloadDistributionQueryParam param) -// { -// IQueryable query = null; -// Expression> workloadAdLambda = x => x.TrialId == param.TrialId; -// if (param.SiteId != null) -// { -// workloadAdLambda = workloadAdLambda.And(t => t.SiteId == param.SiteId); -// } - -// if (param.Status != null) -// { -// workloadAdLambda = workloadAdLambda.And(t => t.Status == param.Status); -// } -// if (!string.IsNullOrEmpty(param.WorkloadCode)) -// { -// var adCode = param.WorkloadCode.Trim(); -// workloadAdLambda = workloadAdLambda.And(t => t.ADCode.Contains(adCode)); -// } - -// Expression> subjectLambda = x => x.TrialId == param.TrialId; -// if (!string.IsNullOrEmpty(param.SubjectCode)) -// { -// var subjectCode = param.SubjectCode.Trim(); -// subjectLambda = subjectLambda.And(t => t.Code.Contains(subjectCode)); - -// } -// Expression> doctorLambda = x => true; -// if (!string.IsNullOrEmpty(param.Reviewer)) -// { -// var reviewer = param.Reviewer.Trim(); -// doctorLambda = doctorLambda.And(t => t.ChineseName.Contains(reviewer) -// || t.FirstName.Contains(reviewer) || t.LastName.Contains(reviewer)); -// query = from workloadAd in _workloadAdRepository.Where(workloadAdLambda) -// join subject in _subjectRepository.Where(subjectLambda) on workloadAd.SubjectId equals subject.Id -// join site in _siteRepository.AsQueryable() on workloadAd.SiteId equals site.Id -// join doctor in _doctorRepository.Where(doctorLambda) on workloadAd.ReviewerId equals doctor.Id -// select new WorkloadADDTO() -// { -// Id = workloadAd.Id, -// ReviewerCode = doctor.ReviewerCode, -// ReviewerChineseName = doctor.ChineseName, -// ReviewerFirstName = doctor.FirstName, -// ReviewerId = doctor.Id, -// ReviewerLastName = doctor.LastName, -// SiteId = workloadAd.SiteId, -// SiteName = site.SiteName, -// Status = workloadAd.Status, -// ADCode = workloadAd.ADCode, -// SubjectCode = subject.Code, -// SubjectId = workloadAd.SubjectId, -// UpdateTime = workloadAd.UpdateTime -// }; -// } -// else -// { -// query = from workloadAd in _workloadAdRepository.Where(workloadAdLambda) -// join subject in _subjectRepository.Where(subjectLambda) on workloadAd.SubjectId equals subject.Id - -// join site in _siteRepository.AsQueryable() on workloadAd.SiteId equals site.Id -// join doctor in _doctorRepository.Where(doctorLambda) on workloadAd.ReviewerId equals doctor.Id into cc -// from doctor in cc.DefaultIfEmpty() -// select new WorkloadADDTO() -// { -// Id = workloadAd.Id, -// ReviewerCode = doctor.ReviewerCode, -// ReviewerChineseName = doctor.ChineseName, -// ReviewerFirstName = doctor.FirstName, -// ReviewerId = doctor.Id, -// ReviewerLastName = doctor.LastName, -// SiteId = workloadAd.SiteId, -// SiteName = site.SiteName, -// Status = workloadAd.Status, -// ADCode = workloadAd.ADCode, -// SubjectCode = subject.Code, -// SubjectId = workloadAd.SubjectId, -// UpdateTime = workloadAd.UpdateTime -// }; - -// } -// var count = query.Count(); - -// var propName = param.SortField == string.Empty ? "ADCode" : param.SortField; - -// query = param.Asc -// ? query.OrderBy(propName).ThenBy(t => t.SiteName).ThenBy(t => t.SubjectCode) -// : query.OrderByDescending(propName).ThenBy(t => t.SiteName).ThenBy(t => t.SubjectCode); - -// query = query.Skip((param.PageIndex - 1) * param.PageSize).Take(param.PageSize); -// var list = query.ToList(); - -// return new PageOutput(param.PageIndex, -// param.PageSize, count, list); -// } - -// [HttpPost] -// public PageOutput GetWorkloadTPList(WorkloadDistributionQueryParam param) -// { -// IQueryable query = null; -// Expression> workloadTPLambda = x => x.TrialId == param.TrialId; -// if (param.SiteId != null) -// { -// workloadTPLambda = workloadTPLambda.And(t => t.SiteId == param.SiteId); -// } - -// if (param.Status != null) -// { -// workloadTPLambda = workloadTPLambda.And(t => t.Status == param.Status); -// } -// if (!string.IsNullOrEmpty(param.WorkloadCode)) -// { -// var timepoint = param.WorkloadCode.Trim(); - -// workloadTPLambda = workloadTPLambda.And(t => t.TimepointCode.Contains(timepoint)); -// } -// if (param.GroupId != null && param.GroupId > 0) -// { -// var groupCode = "T0" + param.GroupId; -// workloadTPLambda = workloadTPLambda.And(t => t.TimepointCode.Contains(groupCode)); -// } - -// Expression> subjectLambda = x => x.TrialId == param.TrialId; -// if (!string.IsNullOrEmpty(param.SubjectCode)) -// { -// var subjectCode = param.SubjectCode.Trim(); -// subjectLambda = subjectLambda.And(t => t.Code.Contains(subjectCode)); -// } -// Expression> doctorLambda = x => true; -// if (!string.IsNullOrEmpty(param.Reviewer)) -// { -// var reviewer = param.Reviewer.Trim(); -// doctorLambda = doctorLambda.And(t => t.ChineseName.Contains(reviewer) -// || t.FirstName.Contains(reviewer) || t.LastName.Contains(reviewer)); -// query = from workloadTp in _workloadTpRepository.Where(workloadTPLambda) -// join subject in _subjectRepository.Where(subjectLambda) on workloadTp.SubjectId equals subject.Id -// join subjectVisit in _subjectVisitRepository.AsQueryable() on workloadTp.SubjectVisitId equals subjectVisit.Id -// join study in _studyRepository.AsQueryable() on workloadTp.StudyId equals study.Id -// join site in _siteRepository.AsQueryable() on workloadTp.SiteId equals site.Id -// join doctor in _doctorRepository.Where(doctorLambda) on workloadTp.ReviewerId equals doctor.Id - -// select new WorkloadTPDTO() -// { -// Id = workloadTp.Id, -// ReviewerCode = doctor.ReviewerCode, -// ReviewerChineseName = doctor.ChineseName, -// ReviewerFirstName = doctor.FirstName, -// ReviewerId = doctor.Id, -// ReviewerLastName = doctor.LastName, -// SiteId = workloadTp.SiteId, -// SiteName = site.SiteName, -// Status = workloadTp.Status, -// StudyCode = study.StudyCode, -// StudyId = workloadTp.StudyId, -// TimepointCode = workloadTp.TimepointCode, -// SubjectCode = subject.Code, -// SubjectVisitId = workloadTp.SubjectVisitId, -// SubjectId = workloadTp.SubjectId, -// VisitNum = subjectVisit.VisitNum, -// VisitName = subjectVisit.VisitName, -// UpdateTime = workloadTp.UpdateTime -// }; -// } -// else -// { -// query = from workloadTp in _workloadTpRepository.Where(workloadTPLambda) -// join subject in _subjectRepository.Where(subjectLambda) on workloadTp.SubjectId equals subject.Id -// join subjectVisit in _subjectVisitRepository.AsQueryable() on workloadTp.SubjectVisitId equals subjectVisit.Id -// join study in _studyRepository.AsQueryable() on workloadTp.StudyId equals study.Id -// join site in _siteRepository.AsQueryable() on workloadTp.SiteId equals site.Id -// join doctor in _doctorRepository.Where(doctorLambda) on workloadTp.ReviewerId equals doctor.Id into cc -// from doctor in cc.DefaultIfEmpty() -// select new WorkloadTPDTO() -// { -// Id = workloadTp.Id, -// ReviewerCode = doctor.ReviewerCode, -// ReviewerChineseName = doctor.ChineseName, -// ReviewerFirstName = doctor.FirstName, -// ReviewerId = doctor.Id, -// ReviewerLastName = doctor.LastName, -// SiteId = workloadTp.SiteId, -// SiteName = site.SiteName, -// Status = workloadTp.Status, -// StudyCode = study.StudyCode, -// StudyId = workloadTp.StudyId, -// TimepointCode = workloadTp.TimepointCode, -// SubjectCode = subject.Code, -// SubjectVisitId = workloadTp.SubjectVisitId, -// SubjectId = workloadTp.SubjectId, -// VisitNum = subjectVisit.VisitNum, -// VisitName = subjectVisit.VisitName, -// UpdateTime = workloadTp.UpdateTime -// }; - -// } -// var count = query.Count(); - -// var propName = param.SortField == string.Empty ? "TimepointCode" : param.SortField; -// query = param.Asc -// ? query.OrderBy(propName).ThenBy(t => t.SiteName).ThenBy(t => t.SubjectCode) -// : query.OrderByDescending(propName).ThenBy(t => t.SiteName).ThenBy(t => t.SubjectCode); -// query = query.Skip((param.PageIndex - 1) * param.PageSize).Take(param.PageSize); -// var list = query.ToList(); - -// return new PageOutput(param.PageIndex, -// param.PageSize, count, list); -// } - -// //修改单个TP -// [HttpPost("{tpId:guid}/{reviewerId:guid}")] -// public IResponseOutput UpdateDistributeAD(Guid tpId, Guid reviewerId) -// { -// _workloadDetailRepository.Add(new WorkloadDetail -// { -// WorkloadId = tpId, -// OptUserName = _userInfo.RealName, -// OptTime = DateTime.Now, -// Status = (int)WorkloadStatus.Distributed, -// ReviewerId = reviewerId -// }); -// _workloadDetailRepository.SaveChanges(); -// var success= _workloadAdRepository.Update(t => t.Id == tpId, u => new WorkloadAD() -// { -// ReviewerId = reviewerId, -// Status = (int)WorkloadStatus.Distributed -// }); - -// return ResponseOutput.Result(success); -// } - -// //修改单个Global -// [HttpPost("{tpId:guid}/{reviewerId:guid}/{subjectId:guid}/{visitNum}")] -// public IResponseOutput UpdateDistributeGlobal(Guid tpId, Guid reviewerId, Guid subjectId, decimal visitNum) -// { -// var temp = _workloadGlobalRepository.Where(u => u.SubjectId == subjectId && -// u.VisitNum == visitNum && -// u.ReviewerId == reviewerId && u.Id != tpId); -// if (temp.Any()) -// { -// return ResponseOutput.NotOk("The Global of the other arm of this subject has already been assigned to this reviewer, and the assignment couldn't be performed."); -// } - -// _workloadDetailRepository.Add(new WorkloadDetail -// { -// WorkloadId = tpId, -// OptUserName = _userInfo.RealName, -// OptTime = DateTime.Now, -// Status = (int)WorkloadStatus.Distributed, -// ReviewerId = reviewerId -// }); -// _workloadDetailRepository.SaveChanges(); -// return ResponseOutput.Result(_workloadGlobalRepository.Update(t => t.Id == tpId, u => new WorkloadGlobal() -// { -// ReviewerId = reviewerId, -// Status = (int)WorkloadStatus.Distributed -// })); -// } - -// //修改单个TP -// [HttpPost("{tpId:guid}/{reviewerId:guid}/{studyId:guid}")] -// public IResponseOutput UpdateDistributeTP(Guid tpId, Guid reviewerId, Guid studyId) -// { -// var temp = _workloadTpRepository.Where(u => u.StudyId == studyId && u.ReviewerId == reviewerId && u.Id != tpId); -// if (temp.Any()) -// { -// return ResponseOutput.NotOk("The TP of the other arm of this subject has already been assigned to this reviewer, and the assignment couldn't be performed."); -// } - -// _workloadDetailRepository.Add(new WorkloadDetail -// { -// WorkloadId = tpId, -// OptUserName = _userInfo.RealName, -// OptTime = DateTime.Now, -// Status = (int)WorkloadStatus.Distributed, -// ReviewerId = reviewerId -// }); -// _workloadDetailRepository.SaveChanges(); -// return ResponseOutput.Result(_workloadTpRepository.Update(t => t.Id == tpId, u => new WorkloadTP() -// { -// ReviewerId = reviewerId, -// Status = (int)WorkloadStatus.Distributed -// })); -// } - -// [HttpGet("{workloadId:guid}")] -// public IResponseOutput> GetWorkloadDetail(Guid workloadId) -// { -// IQueryable query = null; -// query = from detail in _workloadDetailRepository.Where(u => u.WorkloadId == workloadId) -// join doctor in _doctorRepository.AsQueryable() on detail.ReviewerId equals doctor.Id into cc -// from doctor in cc.DefaultIfEmpty() -// select new WorkloadDetailDTO() -// { -// OptTime = detail.OptTime, -// OptUserName = detail.OptUserName, -// ReviewerChineseName = doctor.ChineseName, -// ReviewerFirstName = doctor.FirstName, -// ReviewerLastName = doctor.LastName, -// Status = detail.Status -// }; -// var list = query.OrderByDescending(u => u.OptTime).ToList(); -// return ResponseOutput.Ok(list); -// } - -// [HttpPost("UpdateGlobalStatus/{globalId:guid}")] -// public IResponseOutput UpdateGlobalStatus(Guid globalId) -// { -// return ResponseOutput.Result(_workloadGlobalRepository.Update(u => u.Id == globalId, t => new WorkloadGlobal() -// { -// Status = 0 -// })); -// } - -// } -//} diff --git a/IRaCIS.Core.Application/Service/WorkLoad/_MapConfig.cs b/IRaCIS.Core.Application/Service/WorkLoad/_MapConfig.cs deleted file mode 100644 index 3e9e55141..000000000 --- a/IRaCIS.Core.Application/Service/WorkLoad/_MapConfig.cs +++ /dev/null @@ -1,21 +0,0 @@ -using AutoMapper; -using IRaCIS.Application.Contracts; -using IRaCIS.Core.Application.Service.WorkLoad.DTO; -using IRaCIS.Core.Domain.Models; - -namespace IRaCIS.Core.Application.Service -{ - public class WorkLoadConfig : Profile - { - public WorkLoadConfig() - { - CreateMap(); - - CreateMap(); - - CreateMap(); - - } - } - -} diff --git a/IRaCIS.Core.Application/Triggers/SubjectVisitCheckPassedTrigger.cs b/IRaCIS.Core.Application/Triggers/SubjectVisitCheckPassedTrigger.cs index 94463c240..cfbe3ad5b 100644 --- a/IRaCIS.Core.Application/Triggers/SubjectVisitCheckPassedTrigger.cs +++ b/IRaCIS.Core.Application/Triggers/SubjectVisitCheckPassedTrigger.cs @@ -23,30 +23,28 @@ namespace IRaCIS.Core.Application.Triggers private readonly IRepository _trialReadingCriterionRepository; - private readonly IRepository _SubjectCriteriaEvaluationVisitFilterRepository; - private readonly ISubjectCriteriaEvaluationService _subjectCriteriaEvaluationService; - private readonly IRepository _subjectCriteriaEvaluationRepository; + public SubjectVisitCheckPassedTrigger(IRepository subjectRepository, IRepository clinicalDataTrialSetRepository, IRepository readingClinicalDataRepository, - IVisitTaskHelpeService visitTaskHelpeService, IRepository trialReadingCriterionRepository, - IRepository subjectCriteriaEvaluationVisitFilterRepository, ISubjectCriteriaEvaluationService subjectCriteriaEvaluationService - , IRepository subjectCriteriaEvaluationRepository) + IVisitTaskHelpeService visitTaskHelpeService, IRepository trialReadingCriterionRepository + + ) { - _subjectCriteriaEvaluationRepository= subjectCriteriaEvaluationRepository; + _subjectRepository = subjectRepository; _clinicalDataTrialSetRepository = clinicalDataTrialSetRepository; _readingClinicalDataRepository = readingClinicalDataRepository; this._clinicalDataTrialSetRepository = clinicalDataTrialSetRepository; _visitTaskHelpeService = visitTaskHelpeService; _trialReadingCriterionRepository = trialReadingCriterionRepository; - _SubjectCriteriaEvaluationVisitFilterRepository = subjectCriteriaEvaluationVisitFilterRepository; - _subjectCriteriaEvaluationService = subjectCriteriaEvaluationService; + + } @@ -80,12 +78,7 @@ namespace IRaCIS.Core.Application.Triggers // await _SubjectCriteriaEvaluationVisitFilterRepository.AddAsync(new SubjectCriteriaEvaluationVisitFilter() { SubjectId = subjectVisit.SubjectId, SubjectVisitId = subjectVisit.Id, TrialReadingCriterionId = criterion.Id }); //} - //如果参与评估,那么久对当前访视进行自动筛选 - if( await _subjectCriteriaEvaluationRepository.AnyAsync(t=>t.SubjectId==subjectVisit.SubjectId && t.TrialReadingCriterionId==criterion.Id && t.IsJoinEvaluation)) - { - await _subjectCriteriaEvaluationService.AutoSubjectCriteriaEvaluationVisitFilter(subjectVisit.SubjectId, subjectVisit.Id, criterion.Id); - } diff --git a/IRaCIS.Core.Domain.Share/Doctor/WorkLoadStatus.cs b/IRaCIS.Core.Domain.Share/Doctor/WorkLoadStatus.cs deleted file mode 100644 index 0edddb8c0..000000000 --- a/IRaCIS.Core.Domain.Share/Doctor/WorkLoadStatus.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace IRaCIS.Core.Domain.Share -{ - public enum WorkloadStatus - { - ToBeAllocated=0,//待分配 - - Distributed = 30,//已分配 - - Reading = 40,//都片中,未提交读片报告之前 - - ReviewFinish = 80,//读片完成 - - //Archived=100,//流程结束,归档锁库 - } -} diff --git a/IRaCIS.Core.Domain/Abandon/WorkloadDistribution.cs b/IRaCIS.Core.Domain/Abandon/WorkloadDistribution.cs index a071d3f6d..d5972cc07 100644 --- a/IRaCIS.Core.Domain/Abandon/WorkloadDistribution.cs +++ b/IRaCIS.Core.Domain/Abandon/WorkloadDistribution.cs @@ -58,10 +58,6 @@ namespace IRaCIS.Core.Domain.Models [Table("WorkloadDetail")] public class WorkloadDetail : Entity { - [JsonIgnore] - - public Workload Workload { get; set; } - public Guid WorkloadId { get; set; } public string OptUserName { get; set; } public DateTime OptTime { get; set; } = DateTime.Now; diff --git a/IRaCIS.Core.Domain/Allocation/SubjectUser.cs b/IRaCIS.Core.Domain/Allocation/SubjectUser.cs deleted file mode 100644 index 3ce77427c..000000000 --- a/IRaCIS.Core.Domain/Allocation/SubjectUser.cs +++ /dev/null @@ -1,90 +0,0 @@ - -//-------------------------------------------------------------------- -// 此代码由T4模板自动生成 byzhouhang 20210918 -// 生成时间 2022-06-10 11:59:27 -// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。 -using System; -using IRaCIS.Core.Domain.Share; -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; -using System.Collections.Generic; - -namespace IRaCIS.Core.Domain.Models -{ - /// - ///SubjectUser - /// - [Table("SubjectUser")] - public class SubjectUser : Entity, IAuditUpdate, IAuditAdd - { - [JsonIgnore] - public Trial Trial { get; set; } - public Guid TrialId { get; set; } - - - public Guid TrialReadingCriterionId { get; set; } - - - /// - /// CreateUserId - /// - [Required] - public Guid CreateUserId { get; set; } - - /// - /// CreateTime - /// - [Required] - public DateTime CreateTime { get; set; } - - /// - /// UpdateTime - /// - [Required] - public DateTime UpdateTime { get; set; } - - /// - /// UpdateUserId - /// - [Required] - public Guid UpdateUserId { get; set; } - - - public DateTime? AssignTime { get; set; } - - /// - /// SubjectId - /// - [Required] - public Guid SubjectId { get; set; } - - public Subject Subject { get; set; } - - - public Guid DoctorUserId { get; set; } - - [JsonIgnore] - public User DoctorUser { get; set; } - - public Arm ArmEnum { get; set; } - - public bool IsConfirmed { get; set; } = true; - - //该属性有值 说明该医生被替换了 分配的时候 要过滤掉 - public Guid? OrignalSubjectUserId { get; set; } - - [JsonIgnore] - //Parent - [ForeignKey("OrignalSubjectUserId")] - public SubjectUser OrignalSubjectUser { get; set; } - - //ChildList - [JsonIgnore] - public List EarlierSubjectUserList { get; set; } - - //public List SubjectArmVisitTaskList { get; set; } - - - } - -} diff --git a/IRaCIS.Core.Domain/Allocation/TaskAllocationRule.cs b/IRaCIS.Core.Domain/Allocation/TaskAllocationRule.cs deleted file mode 100644 index a277c1eae..000000000 --- a/IRaCIS.Core.Domain/Allocation/TaskAllocationRule.cs +++ /dev/null @@ -1,62 +0,0 @@ - -//-------------------------------------------------------------------- -// 此代码由T4模板自动生成 byzhouhang 20210918 -// 生成时间 2022-06-07 13:13:13 -// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。 -using System; -using IRaCIS.Core.Domain.Share; -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; -using System.Collections.Generic; - -namespace IRaCIS.Core.Domain.Models -{ - /// - ///TaskAllocationRule - /// - [Table("TaskAllocationRule")] - public class TaskAllocationRule : Entity, IAuditUpdate, IAuditAdd - { - [JsonIgnore] - public Trial Trial { get; set; } - public Guid TrialId { get; set; } - public Guid CreateUserId { get; set; } - public DateTime CreateTime { get; set; } - public DateTime UpdateTime { get; set; } - public Guid UpdateUserId { get; set; } - public int PlanSubjectCount { get; set; } - - - public bool IsEnable { get; set; } - - public string Note { get; set; } = string.Empty; - - - - public Guid DoctorUserId { get; set; } - - [ForeignKey("DoctorUserId")] - [JsonIgnore] - public User DoctorUser { get; set; } - - - - - - - public Guid EnrollId { get; set; } - [JsonIgnore] - public Enroll Enroll { get; set; } - - //是否是裁判医生 裁判医生单独加入 - public bool IsJudgeDoctor { get; set; } - - public int PlanReadingRatio { get; set; } - - - - - - } - -} diff --git a/IRaCIS.Core.Domain/Allocation/TaskConsistentRule.cs b/IRaCIS.Core.Domain/Allocation/TaskConsistentRule.cs deleted file mode 100644 index 1ce5902dc..000000000 --- a/IRaCIS.Core.Domain/Allocation/TaskConsistentRule.cs +++ /dev/null @@ -1,76 +0,0 @@ - -//-------------------------------------------------------------------- -// 此代码由T4模板自动生成 byzhouhang 20210918 -// 生成时间 2022-07-01 15:32:56 -// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。 -using System; -using System.ComponentModel.DataAnnotations.Schema; -using System.Collections.Generic; -using EntityFrameworkCore.Projectables; -using System.Linq; - -namespace IRaCIS.Core.Domain.Models -{ - /// - ///TaskConsistentRule - /// - [Table("TaskConsistentRule")] - public class TaskConsistentRule : Entity, IAuditUpdate, IAuditAdd - { - - - public Trial Trial { get; set; } - - public Guid CreateUserId { get; set; } - - public DateTime CreateTime { get; set; } - - public DateTime UpdateTime { get; set; } - - public Guid UpdateUserId { get; set; } - - public Guid TrialId { get; set; } - - - public int PlanSubjectCount { get; set; } - - public int PlanVisitCount { get; set; } - - public int IntervalWeeks { get; set; } - - - public bool IsHaveReadingPeriod { get; set; } - - - public bool IsGenerateGlobalTask { get; set; } - - - public int BlindSubjectNumberOfPlaces { get; set; } - - public string BlindTrialSiteCode { get; set; } = string.Empty; - - - public bool IsSelfAnalysis { get; set; } - - //public Guid? CompareDoctorUserId { get; set; } - //public User AnalysisDoctorUser { get; set; } - //public Guid AnalysisDoctorUserId { get; set; } - //public List DoctorVisitTaskList { get; set; } - - public bool IsEnable { get; set; } - - public string Note { get; set; } - - - public Guid TrialReadingCriterionId { get; set; } - - [JsonIgnore] - [ForeignKey("TrialReadingCriterionId")] - public ReadingQuestionCriterionTrial TrialReadingCriterion { get; set; } - - - //[Projectable] - //public List DoctorConsistentTaskList => DoctorVisitTaskList.Where(t => t.IsAnalysisCreate && t.TaskConsistentRuleId == Id).ToList(); - } - -} diff --git a/IRaCIS.Core.Domain/Common/Dictionary.cs b/IRaCIS.Core.Domain/Common/Dictionary.cs index 6b518574a..2117bd7cc 100644 --- a/IRaCIS.Core.Domain/Common/Dictionary.cs +++ b/IRaCIS.Core.Domain/Common/Dictionary.cs @@ -10,9 +10,6 @@ namespace IRaCIS.Core.Domain.Models [Table("Dictionary")] public partial class Dictionary : Entity, IAuditUpdate, IAuditAdd { - [JsonIgnore] - public List DoctorDicRelationList { get; set; } = new List(); - public string ChildGroup { get; set; } public int ChildCodeEnum { get; set; } diff --git a/IRaCIS.Core.Domain/Dcotor/Attachment.cs b/IRaCIS.Core.Domain/Dcotor/Attachment.cs deleted file mode 100644 index bf61dd5ee..000000000 --- a/IRaCIS.Core.Domain/Dcotor/Attachment.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System; -using System.ComponentModel.DataAnnotations.Schema; - -namespace IRaCIS.Core.Domain.Models -{ - //public enum AttachmentType - //{ - // Avatar=1,//ͷ - // Resume=2,// - // GCP=3,//GCP֤ - // MedicalLicence=4,//ҽʦʸ֤ - // PracticeCertificate=5,//ִҵʸ֤ - // LargeEquipmentWorkingCertificate=6,//еϸ֤ - // HighestDegreeCertificate=7//ѧ֤ - //} - [Table("Attachment")] - public partial class Attachment : Entity, IAuditAdd - { - public Guid? DoctorId { get; set; } - public string Type { get; set; } - public bool IsOfficial { get; set; } = false; - public string Path { get; set; } = string.Empty; - public string Code { get; set; } = string.Empty; - public DateTime? ExpiryDate { get; set; } - public string FileName { get; set; } = string.Empty; - public DateTime CreateTime { get; set; } - public Guid CreateUserId { get; set; } = Guid.Empty; - //language=1 ģ 2ΪӢ - public int Language { get; set; } = 0; - - //public Guid CreateUserId { get; set; } = Guid.Empty; - //public DateTime? CreateTime { get; set; } - } -} diff --git a/IRaCIS.Core.Domain/Dcotor/Doctor.cs b/IRaCIS.Core.Domain/Dcotor/Doctor.cs deleted file mode 100644 index fcfdcfff7..000000000 --- a/IRaCIS.Core.Domain/Dcotor/Doctor.cs +++ /dev/null @@ -1,207 +0,0 @@ -using EntityFrameworkCore.Projectables; -using IRaCIS.Core.Domain.Share; -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; - -namespace IRaCIS.Core.Domain.Models -{ - [Table("Doctor")] - public partial class Doctor : Entity, IAuditUpdate, IAuditAdd - { - - // - [JsonIgnore] - public List DoctorDicRelationList { get; set; }=new List(); - [JsonIgnore] - public List TrialExperienceCriteriaList { get; set; } - - - //// UserDoctor һҽ ɱû - //[JsonIgnore] - //public List UserList { get; set; } - - [JsonIgnore] - public List EnrollList { get; set; } - - - - public string ReviewerCode { get; set; } - - public int Code { get; set; } - - - [StringLength(100)] - public string Phone { get; set; } = string.Empty; - - - [StringLength(100)] - public string Password { get; set; } - - - [StringLength(50)] - public string ChineseName { get; set; } = string.Empty; - - - [StringLength(100)] - public string FirstName { get; set; } = string.Empty; - - - [StringLength(100)] - public string LastName { get; set; } = string.Empty; - - [Projectable] - public string FullName => LastName + " / " + FirstName; - - public int Sex { get; set; } - - - [StringLength(100)] - public string EMail { get; set; } = string.Empty; - - - [StringLength(100)] - public string WeChat { get; set; } = string.Empty; - - - [StringLength(1000)] - public string Introduction { get; set; } = string.Empty; - - public Guid? DepartmentId { get; set; } = Guid.Empty; - - - [StringLength(100)] - public string DepartmentOther { get; set; } = string.Empty; - - public Guid? PhysicianId { get; set; } - public string Physician { get; set; } = string.Empty; - public string PhysicianCN { get; set; } = string.Empty; - - public Guid? RankId { get; set; } = Guid.Empty; - - - [StringLength(100)] - public string RankOther { get; set; } = string.Empty; - - - - public Guid? PositionId { get; set; } = Guid.Empty; - - - [StringLength(100)] - public string PositionOther { get; set; } = string.Empty; - - // Ƿɿ ζ һֱ - public Guid? HospitalId { get; set; } = Guid.Empty; - - - [StringLength(200)] - public string HospitalOther { get; set; } = string.Empty; - - - - - - [StringLength(100)] - public string ReadingTypeOther { get; set; } = string.Empty; - - - - - [StringLength(100)] - public string SubspecialityOther { get; set; } = string.Empty; - - public int GCP { get; set; } - - public Guid? GCPId { get; set; } = Guid.Empty; - - public Guid OrganizationId { get; set; } = Guid.Empty; - - public string OtherClinicalExperience { get; set; } = string.Empty; - public string OtherClinicalExperienceCN { get; set; } = string.Empty; - - public ContractorStatusEnum CooperateStatus { get; set; } = ContractorStatusEnum.Noncooperation; - - public ResumeStatusEnum ResumeStatus { get; set; } = ResumeStatusEnum.Failed; - - - - [StringLength(512)] - public string PhotoPath { get; set; } = string.Empty; - - [StringLength(512)] - public string ResumePath { get; set; } = string.Empty; - public Guid? SpecialityId { get; set; } = Guid.Empty; - - public string SpecialityOther { get; set; } = string.Empty; - - public string AdminComment { get; set; } = string.Empty; - - public ReviewerInformationConfirmStatus ReviewStatus { get; set; } = ReviewerInformationConfirmStatus.ConfirmRefuse; - - public bool AcceptingNewTrial { get; set; } = false; - public bool ActivelyReading { get; set; } = false; - - public Guid CreateUserId { get; set; } - public DateTime CreateTime { get; set; } - - public Guid UpdateUserId { get; set; } - public DateTime UpdateTime { get; set; } - - public DateTime? LastLoginTime { get; set; } - - public Guid AuditUserId { get; set; } = Guid.Empty; - - public DateTime? AuditTime { get; set; } - - public int Nation { get; set; } = 0; // ֧ͣ0-йҽCN1-ҽUS - - - public string ReadingTypeOtherCN { get; set; } = string.Empty; - public string HospitalOtherCN { get; set; } = string.Empty; - public string PositionOtherCN { get; set; } = string.Empty; - public string RankOtherCN { get; set; } = string.Empty; - public string DepartmentOtherCN { get; set; } = string.Empty; - public string SubspecialityOtherCN { get; set; } = string.Empty; - public string SpecialityOtherCN { get; set; } = string.Empty; - - [JsonIgnore] - [ForeignKey("HospitalId")] - public Hospital Hospital { get; set; } - [JsonIgnore] - [ForeignKey("SpecialityId")] - public virtual Dictionary Speciality { get; set; } - [JsonIgnore] - [ForeignKey("DepartmentId")] - public virtual Dictionary Department { get; set; } - - [JsonIgnore] - [ForeignKey("RankId")] - public virtual Dictionary Rank { get; set; } - - [JsonIgnore] - [ForeignKey("PositionId")] - public virtual Dictionary Position { get; set; } - [JsonIgnore] - public List AttachmentList { get; set; } - [JsonIgnore] - public List CriterionFileList { get; set; } - - [JsonIgnore] - public User User { get; set; } - - - //[JsonIgnore] - //public List VisitTaskList { get; set; } - - public bool IsVirtual { get; set; } - - public string BlindName { get; set; } = string.Empty; - - public string BlindNameCN { get; set; } = string.Empty; - - - public string BlindPublications { get; set; } = string.Empty; - } -} diff --git a/IRaCIS.Core.Domain/Dcotor/DoctorCriterionFile.cs b/IRaCIS.Core.Domain/Dcotor/DoctorCriterionFile.cs deleted file mode 100644 index 84baafcf4..000000000 --- a/IRaCIS.Core.Domain/Dcotor/DoctorCriterionFile.cs +++ /dev/null @@ -1,76 +0,0 @@ - -//-------------------------------------------------------------------- -// 此代码由T4模板自动生成 byzhouhang 20210918 -// 生成时间 2023-01-09 14:34:17 -// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。 -using System; -using IRaCIS.Core.Domain.Share; -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; -namespace IRaCIS.Core.Domain.Models -{ - /// - ///DoctorCriterionFile - /// - [Table("DoctorCriterionFile")] - public class DoctorCriterionFile : Entity, IAuditAdd - { - - /// - /// 文件名称 - /// - public string FileName { get; set; } - - /// - /// 文件路径 - /// - public string FilePath { get; set; } - - /// - /// 标准类型 - /// - public CriterionType CriterionType { get; set; } - - /// - /// 医生Id - /// - public Guid DoctorId { get; set; } - - /// - /// 备注 - /// - public string Remark { get; set; } - - /// - /// 文件类型 - /// - public CriterionFileType FileType { get; set; } - - /// - /// CreateUserId - /// - public Guid CreateUserId { get; set; } - - /// - /// CreateTime - /// - public DateTime CreateTime { get; set; } - - /// - /// 是否启用 - /// - public bool IsEnable { get; set; } = true; - - [JsonIgnore] - [ForeignKey("DoctorId")] - public Doctor Doctor { get; set; } - - public string CriterionName { get; set; } - public Guid? TrialReadingCriterionId { get; set; } - public Guid? TrialId { get; set; } - - - } - - -} diff --git a/IRaCIS.Core.Domain/Dcotor/DoctorDictionary.cs b/IRaCIS.Core.Domain/Dcotor/DoctorDictionary.cs deleted file mode 100644 index 24394b994..000000000 --- a/IRaCIS.Core.Domain/Dcotor/DoctorDictionary.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; - -namespace IRaCIS.Core.Domain.Models -{ - [Table("DoctorDictionary")] - public partial class DoctorDictionary : Entity - { - [JsonIgnore] - [ForeignKey("DoctorId")] - public Doctor Doctor { get; set; } - - [JsonIgnore] - [ForeignKey("DictionaryId")] - public Dictionary Dictionary { get; set; } - - [StringLength(50)] - public string KeyName { get; set; } = string.Empty; - - public Guid DoctorId { get; set; } - - public Guid DictionaryId { get; set; } - } -} diff --git a/IRaCIS.Core.Domain/Dcotor/DoctorWorkload.cs b/IRaCIS.Core.Domain/Dcotor/DoctorWorkload.cs deleted file mode 100644 index 46186c58b..000000000 --- a/IRaCIS.Core.Domain/Dcotor/DoctorWorkload.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System; -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; - -namespace IRaCIS.Core.Domain.Models -{ - [Table("DoctorWorkload")] - public partial class Workload : Entity, IAuditUpdate, IAuditAdd - { - [Required] - public Guid TrialId { get; set; } - - public Guid DoctorId { get; set; } - - public int DataFrom { get; set; } - - public DateTime WorkTime { get; set; } - - public int Training { get; set; } - - public int Downtime { get; set; } - - public int Timepoint { get; set; } - - public int TimepointIn24H { get; set; } - - public int TimepointIn48H { get; set; } - - public int Adjudication { get; set; } - - public int AdjudicationIn24H { get; set; } - - public int AdjudicationIn48H { get; set; } - - public int Global { get; set; } - public int RefresherTraining { get; set; } - - public int CreateUserType { get; set; } - - [Required] - public string YearMonth { get; set; } - - public bool IsLock { get; set; } = false; - - - public Guid CreateUserId { get; set; } - - public DateTime CreateTime { get; set; } - - public Guid UpdateUserId { get; set; } - - public DateTime UpdateTime { get; set; } - } -} diff --git a/IRaCIS.Core.Domain/Dcotor/Education.cs b/IRaCIS.Core.Domain/Dcotor/Education.cs deleted file mode 100644 index 498478f40..000000000 --- a/IRaCIS.Core.Domain/Dcotor/Education.cs +++ /dev/null @@ -1,69 +0,0 @@ -using System; -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; - -namespace IRaCIS.Core.Domain.Models -{ - [Table("Education")] - public partial class Education : Entity, IAuditUpdate, IAuditAdd - { - public Guid DoctorId { get; set; } - - [Column(TypeName = "date")] - public DateTime? BeginDate { get; set; } - [Column(TypeName = "date")] - public DateTime? EndDate { get; set; } - - [StringLength(50)] - public string Degree { get; set; } = string.Empty; - [StringLength(100)] - public string Major { get; set; } = string.Empty; - - [StringLength(100)] - public string Organization { get; set; } = string.Empty; - - - [StringLength(50)] - public string Country { get; set; } = string.Empty; - - - [StringLength(50)] - public string Province { get; set; } = string.Empty; - - - [StringLength(50)] - public string City { get; set; } = string.Empty; - - - [StringLength(50)] - public string DegreeCN { get; set; } = string.Empty; - [StringLength(100)] - public string MajorCN { get; set; } = string.Empty; - - [StringLength(100)] - public string OrganizationCN { get; set; } = string.Empty; - - - [StringLength(50)] - public string CountryCN { get; set; } = string.Empty; - - - [StringLength(50)] - public string ProvinceCN { get; set; } = string.Empty; - - - [StringLength(50)] - public string CityCN { get; set; } = string.Empty; - - - - public int ShowOrder { get; set; } - - public Guid CreateUserId { get; set; } - public DateTime CreateTime { get; set; } = DateTime.Now; - - - public Guid UpdateUserId { get; set; } - public DateTime UpdateTime { get; set; } - } -} diff --git a/IRaCIS.Core.Domain/Dcotor/Postgraduate.cs b/IRaCIS.Core.Domain/Dcotor/Postgraduate.cs deleted file mode 100644 index 7486316b4..000000000 --- a/IRaCIS.Core.Domain/Dcotor/Postgraduate.cs +++ /dev/null @@ -1,66 +0,0 @@ -using System; -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; - -namespace IRaCIS.Core.Domain.Models -{ - [Table("Postgraduate")] - public partial class Postgraduate : Entity, IAuditUpdate, IAuditAdd - { - // public Guid Id { get; set; } - - public Guid DoctorId { get; set; } - - [Column(TypeName = "date")] - public DateTime? BeginDate { get; set; } - - [Column(TypeName = "date")] - public DateTime? EndDate { get; set; } - - - [StringLength(50)] - public string Training { get; set; } = string.Empty; - - [StringLength(100)] - public string Major { get; set; } = string.Empty; - - [StringLength(100)] - public string Hospital { get; set; } = string.Empty; - - [StringLength(100)] - public string School { get; set; } = string.Empty; - [StringLength(100)] - public string Country { get; set; } = string.Empty; - - [StringLength(100)] - public string Province { get; set; } = string.Empty; - - [StringLength(100)] - public string City { get; set; } = string.Empty; - - public Guid CreateUserId { get; set; } - public DateTime CreateTime { get; set; } = DateTime.Now; - public Guid UpdateUserId { get; set; } - public DateTime UpdateTime { get; set; } - - [StringLength(50)] - public string TrainingCN { get; set; } = string.Empty; - - [StringLength(100)] - public string MajorCN { get; set; } = string.Empty; - - [StringLength(100)] - public string HospitalCN { get; set; } = string.Empty; - - [StringLength(100)] - public string SchoolCN { get; set; } = string.Empty; - [StringLength(100)] - public string CountryCN { get; set; } = string.Empty; - - [StringLength(100)] - public string ProvinceCN { get; set; } = string.Empty; - - [StringLength(100)] - public string CityCN { get; set; } = string.Empty; - } -} diff --git a/IRaCIS.Core.Domain/Dcotor/ResearchPublication.cs b/IRaCIS.Core.Domain/Dcotor/ResearchPublication.cs deleted file mode 100644 index f86f505b2..000000000 --- a/IRaCIS.Core.Domain/Dcotor/ResearchPublication.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using System.ComponentModel.DataAnnotations.Schema; - -namespace IRaCIS.Core.Domain.Models -{ - [Table("ResearchPublication")] - public partial class ResearchPublication : Entity, IAuditUpdate, IAuditAdd - { - public Guid DoctorId { get; set; } - public string Research { get; set; } = string.Empty; - public string Grants { get; set; } = string.Empty; - public string Publications { get; set; } = string.Empty; - public string AwardsHonors { get; set; } = string.Empty; - public Guid UpdateUserId { get; set; } - public DateTime UpdateTime { get; set; } = DateTime.Now; - public Guid CreateUserId { get; set; } - public DateTime CreateTime { get; set; }=DateTime.Now; - - public string ResearchCN { get; set; } = string.Empty; - public string GrantsCN { get; set; } = string.Empty; - public string PublicationsCN { get; set; } = string.Empty; - public string AwardsHonorsCN { get; set; } = string.Empty; - } -} diff --git a/IRaCIS.Core.Domain/Dcotor/TrialExperience.cs b/IRaCIS.Core.Domain/Dcotor/TrialExperience.cs deleted file mode 100644 index c3ecb3979..000000000 --- a/IRaCIS.Core.Domain/Dcotor/TrialExperience.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; - -namespace IRaCIS.Core.Domain.Models -{ - [Table("TrialExperience")] - public partial class TrialExperience : Entity, IAuditUpdate, IAuditAdd - { - - public List ExperienceCriteriaList { get; set; } - - - public Guid DoctorId { get; set; } - - //[StringLength(100)] - //public string Term { get; set; } - //[StringLength(100)] - //public string EvaluationCriteria { get; set; } - - public Guid? PhaseId { get; set; } - - public Dictionary Phase { get; set; } - - [StringLength(512)] - public string EvaluationContent { get; set; } - - public Guid CreateUserId { get; set; } - public DateTime CreateTime { get; set; } = DateTime.Now; - public Guid UpdateUserId { get; set; } - public DateTime UpdateTime { get; set; } - - public int VisitReadingCount { get; set; } - - public DateTime? StartTime { get; set; } - - public DateTime? EndTime { get; set; } - } -} diff --git a/IRaCIS.Core.Domain/Dcotor/TrialExperienceCriteria.cs b/IRaCIS.Core.Domain/Dcotor/TrialExperienceCriteria.cs deleted file mode 100644 index 7328aa357..000000000 --- a/IRaCIS.Core.Domain/Dcotor/TrialExperienceCriteria.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.ComponentModel.DataAnnotations.Schema; - -namespace IRaCIS.Core.Domain.Models -{ - public class TrialExperienceCriteria:Entity - { - public Guid DoctorId { get; set; } - public Guid TrialExperienceId { get; set; } - public Guid EvaluationCriteriaId { get; set; } - - [ForeignKey("EvaluationCriteriaId")] - public Dictionary EvaluationCriteria { get; set; } - - - - } -} \ No newline at end of file diff --git a/IRaCIS.Core.Domain/Dcotor/UserDoctor.cs b/IRaCIS.Core.Domain/Dcotor/UserDoctor.cs deleted file mode 100644 index 0f93551bd..000000000 --- a/IRaCIS.Core.Domain/Dcotor/UserDoctor.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using System.ComponentModel.DataAnnotations.Schema; - -namespace IRaCIS.Core.Domain.Models -{ - /// - /// ûҽϵ - ʵ - /// - [Table("UserDoctor")] - public partial class UserDoctor : Entity - { - [ForeignKey("User")] - public Guid UserId { get; set; } - - [ForeignKey("Doctor")] - public Guid DoctorId { get; set; } - - public Doctor Doctor { get; set; } - - public User User { get; set; } - } -} diff --git a/IRaCIS.Core.Domain/Dcotor/Vacation.cs b/IRaCIS.Core.Domain/Dcotor/Vacation.cs deleted file mode 100644 index ae5670c36..000000000 --- a/IRaCIS.Core.Domain/Dcotor/Vacation.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.ComponentModel.DataAnnotations.Schema; - -namespace IRaCIS.Core.Domain.Models -{ - [Table("Vacation")] - public class Vacation : Entity, IAuditUpdate, IAuditAdd - { - public Guid DoctorId { get; set; } - public DateTime StartDate { get; set; } - public DateTime EndDate { get; set; } - public int Status { get; set; } = 1; - public Guid UpdateUserId { get; set; } - public DateTime UpdateTime { get; set; } - public Guid CreateUserId { get; set; } - public DateTime CreateTime { get; set; } - } -} diff --git a/IRaCIS.Core.Domain/Financial/CalculateTask.cs b/IRaCIS.Core.Domain/Financial/CalculateTask.cs deleted file mode 100644 index d46027c7c..000000000 --- a/IRaCIS.Core.Domain/Financial/CalculateTask.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; - -namespace IRaCIS.Core.Domain.Models -{ - [Table("CalculateTask")] - public class CalculateTask : Entity - { - public Guid ReviewerId { get; set; } - - [Required] - public string YearMonth { get; set; } - public bool IsLock { get; set; } - } -} diff --git a/IRaCIS.Core.Domain/Financial/ExchangeRate.cs b/IRaCIS.Core.Domain/Financial/ExchangeRate.cs deleted file mode 100644 index c77e3ce95..000000000 --- a/IRaCIS.Core.Domain/Financial/ExchangeRate.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.ComponentModel.DataAnnotations.Schema; - -namespace IRaCIS.Core.Domain.Models -{ - [Table("ExchangeRate")] - public class ExchangeRate : Entity, IAuditUpdate, IAuditAdd - { - public string YearMonth { get; set; } - - [Column(TypeName = "decimal(18,2)")] - public decimal Rate { get; set; } - public Guid UpdateUserId { get; set; } - public DateTime UpdateTime { get; set; } - public Guid CreateUserId { get; set; } - public DateTime CreateTime { get; set; } - } -} diff --git a/IRaCIS.Core.Domain/Financial/Payment.cs b/IRaCIS.Core.Domain/Financial/Payment.cs deleted file mode 100644 index 800ce71bd..000000000 --- a/IRaCIS.Core.Domain/Financial/Payment.cs +++ /dev/null @@ -1,49 +0,0 @@ -using System; -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; - -namespace IRaCIS.Core.Domain.Models -{ - - [Table("Payment")] - public partial class Payment : Entity, IAuditUpdate, IAuditAdd - { - public Guid DoctorId { get; set; } - public string YearMonth { get; set; } = string.Empty; - public bool IsLock { get; set; } - public DateTime YearMonthDate { get; set; } - - [Column(TypeName = "decimal(18,2)")] - public decimal PaymentUSD { get; set; } - - [Column(TypeName = "decimal(18,4)")] - public decimal PaymentCNY { get; set; } - - [Column(TypeName = "decimal(18,2)")] - public decimal ExchangeRate { get; set; } - - - [Column(TypeName = "decimal(18,4)")] - public decimal AdjustmentCNY { get; set; } - - [Column(TypeName = "decimal(18,2)")] - public decimal AdjustmentUSD { get; set; } - public DateTime CalculateTime { get; set; } = DateTime.Now; - - [StringLength(100)] - public string CalculateUser { get; set; } = string.Empty; - - [StringLength(500)] - public string Note { get; set; } = string.Empty; - - //public double TaxCNY { get; set; } - //public double ActuallyPaidCNY { get; set; } - //public double BankTransferCNY { get; set; } - - - public Guid UpdateUserId { get; set; } - public DateTime UpdateTime { get; set; } - public Guid CreateUserId { get; set; } - public DateTime CreateTime { get; set; } - } -} diff --git a/IRaCIS.Core.Domain/Financial/PaymentAdjustment.cs b/IRaCIS.Core.Domain/Financial/PaymentAdjustment.cs deleted file mode 100644 index 44d475543..000000000 --- a/IRaCIS.Core.Domain/Financial/PaymentAdjustment.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; -using System.ComponentModel.DataAnnotations.Schema; - -namespace IRaCIS.Core.Domain.Models -{ - [Table("PaymentAdjustment")] - public partial class PaymentAdjustment : Entity, IAuditUpdate, IAuditAdd - { - public Guid ReviewerId { get; set; } - - public DateTime YearMonthDate { get; set; } - public string YearMonth { get; set; } - - [Column(TypeName = "decimal(18,2)")] - public decimal AdjustmentUSD { get; set; } - - [Column(TypeName = "decimal(18,4)")] - public decimal AdjustmentCNY { get; set; } - - - public Guid TrialId { get; set; } = Guid.Empty; - - [Column(TypeName = "decimal(18,2)")] - public decimal ExchangeRate { get; set; } - public bool IsLock { get; set; } = false; - public string Note { get; set; } = string.Empty; - - public Guid CreateUserId { get; set; } = Guid.Empty; - public DateTime CreateTime { get; set; } = DateTime.Now; - public Guid UpdateUserId { get; set; } = Guid.Empty; - public DateTime UpdateTime { get; set; } = DateTime.Now; - } -} diff --git a/IRaCIS.Core.Domain/Financial/PaymentDetail.cs b/IRaCIS.Core.Domain/Financial/PaymentDetail.cs deleted file mode 100644 index feb8e5047..000000000 --- a/IRaCIS.Core.Domain/Financial/PaymentDetail.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System; -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; - -namespace IRaCIS.Core.Domain.Models -{ - [Table("PaymentDetail")] - public partial class PaymentDetail : Entity, IAuditUpdate, IAuditAdd - { - public Guid PaymentId { get; set; } - public Guid DoctorId { get; set; } - public string YearMonth { get; set; } - public Guid TrialId { get; set; } - - [StringLength(50)] - public string TrialCode { get; set; } - - [StringLength(50)] - public string PaymentType { get; set; } - public int Count { get; set; } - - [Column(TypeName = "decimal(18,2)")] - public decimal BasePrice { get; set; } - - [Column(TypeName = "decimal(18,2)")] - public decimal PersonalAdditional { get; set; } - - [Column(TypeName = "decimal(18,2)")] - public decimal TrialAdditional { get; set; } - - [Column(TypeName = "decimal(18,2)")] - public decimal ExchangeRate { get; set; } - - [Column(TypeName = "decimal(18,2)")] - public decimal PaymentUSD { get; set; } - - [Column(TypeName = "decimal(18,4)")] - public decimal PaymentCNY { get; set; } - - public int ShowTypeOrder { get; set; } - public int ShowCodeOrder { get; set; } - - public Guid UpdateUserId { get; set; } - public DateTime UpdateTime { get; set; } - public Guid CreateUserId { get; set; } - public DateTime CreateTime { get; set; } - } -} diff --git a/IRaCIS.Core.Domain/Financial/RankPrice.cs b/IRaCIS.Core.Domain/Financial/RankPrice.cs deleted file mode 100644 index 01daf2b7e..000000000 --- a/IRaCIS.Core.Domain/Financial/RankPrice.cs +++ /dev/null @@ -1,49 +0,0 @@ -using System; -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; - -namespace IRaCIS.Core.Domain.Models -{ - [Table("RankPrice")] - public partial class RankPrice : Entity, IAuditUpdate, IAuditAdd - { - [StringLength(200)] - public string RankName { get; set; } - - [Column(TypeName = "decimal(18,2)")] - public decimal Timepoint { get; set; } - - [Column(TypeName = "decimal(18,2)")] - public decimal TimepointIn24H { get; set; } - - [Column(TypeName = "decimal(18,2)")] - public decimal TimepointIn48H { get; set; } - - [Column(TypeName = "decimal(18,2)")] - public decimal Adjudication { get; set; } - - [Column(TypeName = "decimal(18,2)")] - public decimal AdjudicationIn24H { get; set; } - - [Column(TypeName = "decimal(18,2)")] - public decimal AdjudicationIn48H { get; set; } - - [Column(TypeName = "decimal(18,2)")] - public decimal Global { get; set; } - - [Column(TypeName = "decimal(18,2)")] - public decimal Training { get; set; } - - [Column(TypeName = "decimal(18,2)")] - public decimal Downtime { get; set; } - - [Column(TypeName = "decimal(18,2)")] - public decimal RefresherTraining { get; set; } - public int ShowOrder { get; set; } - - public DateTime CreateTime { get; set; } - public Guid CreateUserId { get; set; } = Guid.Empty; - public DateTime UpdateTime { get; set; } - public Guid UpdateUserId { get; set; } = Guid.Empty; - } -} diff --git a/IRaCIS.Core.Domain/Financial/ReviewerPayInformation.cs b/IRaCIS.Core.Domain/Financial/ReviewerPayInformation.cs deleted file mode 100644 index ebf486ab3..000000000 --- a/IRaCIS.Core.Domain/Financial/ReviewerPayInformation.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System; -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; - -namespace IRaCIS.Core.Domain.Models -{ - [Table("DoctorPayInformation")] - public partial class ReviewerPayInformation : Entity, IAuditAdd, IAuditUpdate - { - public Guid DoctorId { get; set; } - [StringLength(200)] - public string DoctorNameInBank { get; set; } - - [StringLength(100)] - public string IDCard { get; set; } - - [StringLength(100)] - public string BankCardNumber { get; set; } - - [StringLength(200)] - public string BankName { get; set; } - public Guid RankId { get; set; } - - [Column(TypeName = "decimal(18,2)")] - public decimal Additional { get; set; } - - public DateTime CreateTime { get; set; } - public Guid CreateUserId { get; set; } = Guid.Empty; - public DateTime UpdateTime { get; set; } - public Guid UpdateUserId { get; set; } = Guid.Empty; - } -} diff --git a/IRaCIS.Core.Domain/Financial/TrialPaymentPrice.cs b/IRaCIS.Core.Domain/Financial/TrialPaymentPrice.cs deleted file mode 100644 index f883a570e..000000000 --- a/IRaCIS.Core.Domain/Financial/TrialPaymentPrice.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System; -using System.ComponentModel.DataAnnotations.Schema; - -namespace IRaCIS.Core.Domain.Models -{ - [Table("TrialPaymentPrice")] - public partial class TrialPaymentPrice : Entity, IAuditAdd, IAuditUpdate - { - public Guid TrialId { get; set; } - - public Trial Trial { get; set; } - - [Column(TypeName = "decimal(18,2)")] - public decimal TrialAdditional { get; set; } = 0; - - public string SowName { get; set; } = string.Empty; - public string SowPath { get; set; } = string.Empty; - - [Column(TypeName = "decimal(18,2)")] - public decimal AdjustmentMultiple { get; set; } = 1; - - - - /// - /// Ƿ ΪĿ - /// - public bool? IsNewTrial { get; set; } = false; - - public DateTime CreateTime { get; set; } - public Guid CreateUserId { get; set; } - public DateTime UpdateTime { get; set; } - public Guid UpdateUserId { get; set; } - } -} diff --git a/IRaCIS.Core.Domain/Financial/TrialRevenuesPrice.cs b/IRaCIS.Core.Domain/Financial/TrialRevenuesPrice.cs deleted file mode 100644 index 10557226f..000000000 --- a/IRaCIS.Core.Domain/Financial/TrialRevenuesPrice.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System; -using System.ComponentModel.DataAnnotations.Schema; - -namespace IRaCIS.Core.Domain.Models -{ - [Table("TrialRevenuesPrice")] - public class TrialRevenuesPrice : Entity, IAuditUpdate, IAuditAdd - { - public Guid TrialId { get; set; } - - [Column(TypeName = "decimal(18,2)")] - public decimal Timepoint { get; set; } - - [Column(TypeName = "decimal(18,2)")] - public decimal TimepointIn24H { get; set; } - - [Column(TypeName = "decimal(18,2)")] - public decimal TimepointIn48H { get; set; } - - [Column(TypeName = "decimal(18,2)")] - public decimal Adjudication { get; set; } - - [Column(TypeName = "decimal(18,2)")] - public decimal AdjudicationIn24H { get; set; } - - [Column(TypeName = "decimal(18,2)")] - public decimal AdjudicationIn48H { get; set; } - - [Column(TypeName = "decimal(18,2)")] - public decimal Global { get; set; } - - [Column(TypeName = "decimal(18,2)")] - public decimal Training { get; set; } - - [Column(TypeName = "decimal(18,2)")] - public decimal Downtime { get; set; } - - [Column(TypeName = "decimal(18,2)")] - public decimal RefresherTraining { get; set; } - - public Guid UpdateUserId { get; set; } - public DateTime UpdateTime { get; set; } - public Guid CreateUserId { get; set; } - public DateTime CreateTime { get; set; } - } -} diff --git a/IRaCIS.Core.Domain/Financial/TrialRevenuesPriceVerification.cs b/IRaCIS.Core.Domain/Financial/TrialRevenuesPriceVerification.cs deleted file mode 100644 index 822c312d6..000000000 --- a/IRaCIS.Core.Domain/Financial/TrialRevenuesPriceVerification.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; - -namespace IRaCIS.Core.Domain.Models -{ - public class TrialRevenuesPriceVerification : Entity - { - public Guid TrialId { get; set; } - - public Guid ReviewerId { get; set; } - - public string YearMonth { get; set; } - - public bool Training { get; set; } = false; - - public bool Downtime { get; set; } = false; - - public bool Global { get; set; } = false; - - public bool Timepoint { get; set; } = false; - - public bool TimepointIn24H { get; set; } = false; - - public bool TimepointIn48H { get; set; } = false; - - public bool Adjudication { get; set; } = false; - - public bool AdjudicationIn24H { get; set; } = false; - - public bool AdjudicationIn48H { get; set; } = false; - public bool RefresherTraining { get; set; } = false; - public DateTime WorkLoadDate { get; set; } - } -} \ No newline at end of file diff --git a/IRaCIS.Core.Domain/Financial/VolumeReward.cs b/IRaCIS.Core.Domain/Financial/VolumeReward.cs deleted file mode 100644 index 937d56edc..000000000 --- a/IRaCIS.Core.Domain/Financial/VolumeReward.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.ComponentModel.DataAnnotations.Schema; - -namespace IRaCIS.Core.Domain.Models -{ - [Table("VolumeReward")] - public partial class VolumeReward : Entity, IAuditUpdate, IAuditAdd - { - [Column(TypeName = "decimal(18,2)")] - public decimal Price { get; set; } - public int Min { get; set; } - public int Max { get; set; } - public Guid UpdateUserId { get; set; } - public DateTime UpdateTime { get; set; } - public Guid CreateUserId { get; set; } - public DateTime CreateTime { get; set; } - } -} diff --git a/IRaCIS.Core.Domain/Image/DicomSeries.cs b/IRaCIS.Core.Domain/Image/DicomSeries.cs index 46820e012..dda7cab73 100644 --- a/IRaCIS.Core.Domain/Image/DicomSeries.cs +++ b/IRaCIS.Core.Domain/Image/DicomSeries.cs @@ -15,10 +15,6 @@ namespace IRaCIS.Core.Domain.Models [JsonIgnore] public List DicomInstanceList { get; set; } - [JsonIgnore] - public List SubjectCriteriaEvaluationVisitStudyFilterList { get; set; } - - [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public Guid SeqId { get; set; } public Guid StudyId { get; set; } diff --git a/IRaCIS.Core.Domain/Image/DicomStudy.cs b/IRaCIS.Core.Domain/Image/DicomStudy.cs index a42a79b81..b7d5e091f 100644 --- a/IRaCIS.Core.Domain/Image/DicomStudy.cs +++ b/IRaCIS.Core.Domain/Image/DicomStudy.cs @@ -20,9 +20,6 @@ namespace IRaCIS.Core.Domain.Models [JsonIgnore] public Site Site { get; set; } - [JsonIgnore] - public List SubjectCriteriaEvaluationVisitStudyFilterList { get; set; } - [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public Guid SeqId { get; set; } diff --git a/IRaCIS.Core.Domain/Institution/Hospital.cs b/IRaCIS.Core.Domain/Institution/Hospital.cs index 683dc8d5a..7bdef275b 100644 --- a/IRaCIS.Core.Domain/Institution/Hospital.cs +++ b/IRaCIS.Core.Domain/Institution/Hospital.cs @@ -36,8 +36,5 @@ namespace IRaCIS.Core.Domain.Models [ForeignKey("SiteId")] public Site Site { get; set; } - [JsonIgnore] - public List DoctorList { get; set; } - } } diff --git a/IRaCIS.Core.Domain/Management/User.cs b/IRaCIS.Core.Domain/Management/User.cs index ade0229e1..07a572a50 100644 --- a/IRaCIS.Core.Domain/Management/User.cs +++ b/IRaCIS.Core.Domain/Management/User.cs @@ -16,8 +16,6 @@ namespace IRaCIS.Core.Domain.Models [JsonIgnore] public List SystemDocConfirmedList { get; set; } [JsonIgnore] - public List UserDoctors { get; set; } = new List(); - [JsonIgnore] public List UserTrials { get; set; } = new List(); [JsonIgnore] @@ -81,10 +79,6 @@ namespace IRaCIS.Core.Domain.Models //ҽ˺ź󣬻ֵ public Guid? DoctorId { get; set; } - [JsonIgnore] - [ForeignKey("DoctorId")] - public Doctor Doctor { get; set; } - public bool IsTestUser { get; set; } diff --git a/IRaCIS.Core.Domain/Reading/AdditionalEvaluate/SubjectCriteriaEvaluation.cs b/IRaCIS.Core.Domain/Reading/AdditionalEvaluate/SubjectCriteriaEvaluation.cs deleted file mode 100644 index e7432ddcb..000000000 --- a/IRaCIS.Core.Domain/Reading/AdditionalEvaluate/SubjectCriteriaEvaluation.cs +++ /dev/null @@ -1,88 +0,0 @@ - -//-------------------------------------------------------------------- -// 此代码由T4模板自动生成 byzhouhang 20210918 -// 生成时间 2023-03-17 11:46:55 -// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。 -using System; -using IRaCIS.Core.Domain.Share; -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; -using System.Collections.Generic; - -namespace IRaCIS.Core.Domain.Models -{ - /// - ///SubjectCriteriaEvaluation - /// - [Table("SubjectCriteriaEvaluation")] - public class SubjectCriteriaEvaluation : Entity, IAuditUpdate, IAuditAdd - { - [JsonIgnore] - public Subject subject { get; set; } - - [JsonIgnore] - [ForeignKey("TrialReadingCriterionId")] - public ReadingQuestionCriterionTrial TrialReadingCriterion { get; set; } - - [JsonIgnore] - public List SubjectCriteriaEvaluationVisitFilterList { get; set; } - - /// - /// SubjectId - /// - [Required] - public Guid SubjectId { get; set; } - - /// - /// TrialReadingCriterionId - /// - [Required] - public Guid TrialReadingCriterionId { get; set; } - - /// - /// 是否参与评估 - /// - [Required] - public bool IsJoinEvaluation { get; set; } - - /// - /// CreateTime - /// - [Required] - public DateTime CreateTime { get; set; } - - /// - /// CreateUserId - /// - [Required] - public Guid CreateUserId { get; set; } - - /// - /// UpdateUserId - /// - [Required] - public Guid UpdateUserId { get; set; } - - /// - /// UpdateTime - /// - [Required] - public DateTime UpdateTime { get; set; } - - - - - - - - - ///// - // /// 是否影像筛选 - // /// - //[Required] - //public bool IsImageFiltering { get; set; } - - } - - -} diff --git a/IRaCIS.Core.Domain/Reading/AdditionalEvaluate/SubjectCriteriaEvaluationVisitFilter.cs b/IRaCIS.Core.Domain/Reading/AdditionalEvaluate/SubjectCriteriaEvaluationVisitFilter.cs deleted file mode 100644 index 91f03106c..000000000 --- a/IRaCIS.Core.Domain/Reading/AdditionalEvaluate/SubjectCriteriaEvaluationVisitFilter.cs +++ /dev/null @@ -1,101 +0,0 @@ - -//-------------------------------------------------------------------- -// 此代码由T4模板自动生成 byzhouhang 20210918 -// 生成时间 2023-03-17 11:51:12 -// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。 -using System; -using IRaCIS.Core.Domain.Share; -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; -using System.Collections.Generic; - -namespace IRaCIS.Core.Domain.Models -{ - /// - ///SubjectCriteriaEvaluationVisitFilter - /// - [Table("SubjectCriteriaEvaluationVisitFilter")] - public class SubjectCriteriaEvaluationVisitFilter : Entity, IAuditUpdate, IAuditAdd - { - - //[JsonIgnore] - - //public List SubjectCriterionTaskList { get; set; } - [JsonIgnore] - [ForeignKey("TrialReadingCriterionId")] - public ReadingQuestionCriterionTrial TrialReadingCriterion { get; set; } - - - [JsonIgnore] - public SubjectCriteriaEvaluation SubjectCriteriaEvaluation { get; set; } - - [JsonIgnore] - - public SubjectVisit SubjectVisit { get; set; } - public Guid SubjectId { get; set; } - - - public Guid TrialReadingCriterionId { get; set; } - - public DateTime CreateTime { get; set; } - - - public Guid CreateUserId { get; set; } - - - public Guid UpdateUserId { get; set; } - - - public DateTime UpdateTime { get; set; } - - - public Guid SubjectVisitId { get; set; } - - /// - /// 影像筛选状态 - /// - [Required] - public ImageFilterState ImageFilterState { get; set; } - - /// - /// 影像判断结果 - /// - [Required] - public ImageDeterminationResultState ImageDeterminationResultState { get; set; } - - /// - /// 是否已生成任务 - /// - [Required] - public bool IsGeneratedTask { get; set; } - - } - - /// - /// 影像确认结果 - /// - public enum ImageDeterminationResultState - { - //待定 - None = 0, - - - //通过 - Passed = 1, - } - - /// - /// 影像筛选状态 - /// - public enum ImageFilterState - { - //默认值 待筛选 - None = 0, - - Filtering=1, - - //筛选已完成 - Finished = 2 - } - -} diff --git a/IRaCIS.Core.Domain/Reading/AdditionalEvaluate/SubjectCriteriaEvaluationVisitStudyFilter.cs b/IRaCIS.Core.Domain/Reading/AdditionalEvaluate/SubjectCriteriaEvaluationVisitStudyFilter.cs deleted file mode 100644 index 68dd7aefa..000000000 --- a/IRaCIS.Core.Domain/Reading/AdditionalEvaluate/SubjectCriteriaEvaluationVisitStudyFilter.cs +++ /dev/null @@ -1,64 +0,0 @@ - -//-------------------------------------------------------------------- -// 此代码由T4模板自动生成 byzhouhang 20210918 -// 生成时间 2023-03-17 11:51:13 -// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。 -using System; -using IRaCIS.Core.Domain.Share; -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; -namespace IRaCIS.Core.Domain.Models -{ - /// - ///SubjectCriteriaEvaluationVisitStudyFilter - /// - [Table("SubjectCriteriaEvaluationVisitStudyFilter")] - public class SubjectCriteriaEvaluationVisitStudyFilter : Entity, IAuditUpdate, IAuditAdd - { - [JsonIgnore] - [ForeignKey("TrialReadingCriterionId")] - public ReadingQuestionCriterionTrial TrialReadingCriterion { get; set; } - - [JsonIgnore] - public SubjectVisit SubjectVisit { get; set; } - - [ForeignKey("SeriesId")] - [JsonIgnore] - public DicomSeries Series { get; set; } - - - [ForeignKey("StudyId")] - [JsonIgnore] - public DicomStudy Study { get; set; } - - public Guid TrialReadingCriterionId { get; set; } - - public Guid SubjectVisitId { get; set; } - - - public Guid StudyId { get; set; } - - public Guid SeriesId { get; set; } - - - public bool IsConfirmed { get; set; } - - public bool IsReading { get; set; } - - - public DateTime CreateTime { get; set; } - - - public Guid CreateUserId { get; set; } - - - public Guid UpdateUserId { get; set; } - - - public DateTime UpdateTime { get; set; } - - - - } - -} diff --git a/IRaCIS.Core.Domain/Trial/Enroll.cs b/IRaCIS.Core.Domain/Trial/Enroll.cs deleted file mode 100644 index 4146a913e..000000000 --- a/IRaCIS.Core.Domain/Trial/Enroll.cs +++ /dev/null @@ -1,73 +0,0 @@ -using IRaCIS.Core.Domain.Share; -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations.Schema; - -namespace IRaCIS.Core.Domain.Models -{ - [Table("Enroll")] - public partial class Enroll : Entity,IAuditUpdate,IAuditAdd - { - - [JsonIgnore] - [ForeignKey("TrialId")] - public virtual Trial Trial { get; set; } - [JsonIgnore] - public virtual Doctor Doctor { get; set; } - - //public TrialPaymentPrice TrialPaymentPrice { get; set; } - - public Guid DoctorId { get; set; } - public Guid TrialId { get; set; } - public Guid AttachmentId { get; set; } = Guid.Empty; - public EnrollStatus EnrollStatus { get; set; } - - public decimal? AdjustmentMultiple { get; set; } - public DateTime? EnrollTime { get; set; } - public DateTime? OutEnrollTime { get; set; } - - public string Memo { get; set; } = string.Empty; - - public int ReviewerReadingType { get; set; } = 0; - - public Guid UpdateUserId { get; set; } - public DateTime UpdateTime { get; set; } = DateTime.Now; - public Guid CreateUserId { get; set; } - public DateTime CreateTime { get; set; } - - public int? Training { get; set; } - - public int? RefresherTraining { get; set; } - - public int? Timepoint { get; set; } - - public int? Timepoint48H { get; set; } - - public int? Timepoint24H { get; set; } - - public int? Adjudication { get; set; } - - public int? Adjudication48H { get; set; } - - public int? Adjudication24H { get; set; } - - public int? Global { get; set; } - - - public int? Downtime { get; set; } - - - - /// - /// ˺ 뵽Ŀк ֵ - /// - public Guid? DoctorUserId { get; set; } - [JsonIgnore] - public User DoctorUser { get; set; } - - - [JsonIgnore] - public List EnrollReadingCategoryList { get; set; } - - } -} diff --git a/IRaCIS.Core.Domain/Trial/EnrollDetail.cs b/IRaCIS.Core.Domain/Trial/EnrollDetail.cs deleted file mode 100644 index c4f46c29d..000000000 --- a/IRaCIS.Core.Domain/Trial/EnrollDetail.cs +++ /dev/null @@ -1,31 +0,0 @@ -using IRaCIS.Core.Domain.Share; -using System; -using System.ComponentModel.DataAnnotations.Schema; - -namespace IRaCIS.Core.Domain.Models -{ - [Table("EnrollDetail")] - public partial class EnrollDetail : Entity, IAuditAdd - { - [JsonIgnore] - public virtual TrialStatusDetail TrialDetail { get; set; } - - public Guid DoctorId { get; set; } - public Guid TrialId { get; set; } - public EnrollStatus EnrollStatus { get; set; } - public Guid? EnrollId { get; set; } - public string Memo { get; set; } = string.Empty; - public Guid CreateUserId { get; set; } - public int OptUserType { get; set; } - public DateTime CreateTime { get; set; } - - - public Guid TrialDetailId { get; set; } - - [JsonIgnore] - [ForeignKey("CreateUserId")] - public User CreateUser { get; set; } - [JsonIgnore] - public Doctor Doctor { get; set; } - } -} diff --git a/IRaCIS.Core.Domain/Trial/EnrollReadingCategory.cs b/IRaCIS.Core.Domain/Trial/EnrollReadingCategory.cs deleted file mode 100644 index 6cf112e7c..000000000 --- a/IRaCIS.Core.Domain/Trial/EnrollReadingCategory.cs +++ /dev/null @@ -1,46 +0,0 @@ - -//-------------------------------------------------------------------- -// 此代码由T4模板自动生成 byzhouhang 20210918 -// 生成时间 2022-07-08 10:43:53 -// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。 -using System; -using IRaCIS.Core.Domain.Share; -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; -namespace IRaCIS.Core.Domain.Models -{ - /// - ///EnrollReadingCategory - /// - [Table("EnrollReadingCategory")] - public class EnrollReadingCategory : Entity, IAuditAdd - { - /// - /// EnrollId - /// - public Guid EnrollId { get; set; } - - /// - /// ReadingCategory - /// - public ReadingCategory ReadingCategory { get; set; } - - - public Guid TrialReadingCriterionId { get; set; } - - /// - /// CreateUserId - /// - public Guid CreateUserId { get; set; } - - /// - /// CreateTime - /// - public DateTime CreateTime { get; set; } - - [JsonIgnore] - [ForeignKey("EnrollId")] - public Enroll Enroll { get; set; } - } - -} diff --git a/IRaCIS.Core.Domain/Trial/Trial.cs b/IRaCIS.Core.Domain/Trial/Trial.cs index e173f31f1..cdac60b49 100644 --- a/IRaCIS.Core.Domain/Trial/Trial.cs +++ b/IRaCIS.Core.Domain/Trial/Trial.cs @@ -20,11 +20,6 @@ namespace IRaCIS.Core.Domain.Models [JsonIgnore] public List TaskMedicalReviewList { get; set; } - - [JsonIgnore] - public List TaskConsistentRuleList { get; set; } - [JsonIgnore] - public List SubjectDoctorUserList { get; set; } = new List(); [JsonIgnore] public List VisitTaskList { get; set; } = new List() { }; @@ -36,10 +31,6 @@ namespace IRaCIS.Core.Domain.Models [JsonIgnore] public List TrialDocumentList { get; set; } [JsonIgnore] - public List EnrollList { get; set; } = new List(); - [JsonIgnore] - public List WorkloadList { get; set; } = new List(); - [JsonIgnore] public List TrialUserList { get; set; } = new List(); [JsonIgnore] public List ReadingQuestionCriterionTrialList { get; set; } = new List(); diff --git a/IRaCIS.Core.Domain/Trial/TrialStatusDetail.cs b/IRaCIS.Core.Domain/Trial/TrialStatusDetail.cs index d90d797a4..4250ac2d8 100644 --- a/IRaCIS.Core.Domain/Trial/TrialStatusDetail.cs +++ b/IRaCIS.Core.Domain/Trial/TrialStatusDetail.cs @@ -8,10 +8,9 @@ namespace IRaCIS.Core.Domain.Models [Table("TrialStatus")] public partial class TrialStatusDetail : Entity, IAuditAdd { - public virtual ICollection IntoGroupDetails { get; set; } public TrialStatusDetail() { - IntoGroupDetails = new HashSet(); + } [JsonIgnore] public Trial Trial { get; set; } diff --git a/IRaCIS.Core.Domain/Visit/Subject.cs b/IRaCIS.Core.Domain/Visit/Subject.cs index 82adee191..ce75c64dc 100644 --- a/IRaCIS.Core.Domain/Visit/Subject.cs +++ b/IRaCIS.Core.Domain/Visit/Subject.cs @@ -17,24 +17,15 @@ namespace IRaCIS.Core.Domain.Models [JsonIgnore] public List SubjectVisitList { get; set; } = new List(); [JsonIgnore] - public List SubjectDoctorList { get; set; } = new List(); - [JsonIgnore] public List SubjectVisitTaskList { get; set; } = new List(); [JsonIgnore] public List ReadModuleList { get; set; } - [JsonIgnore] - public List SubjectCanceDoctorList { get; set; } [JsonIgnore] public List ClinicalDataList { get; set; } - [JsonIgnore] - public List SubjectCriteriaEvaluationList { get; set; } - [JsonIgnore] - public List SubjectCriteriaEvaluationVisitFilterList { get; set; } - [JsonIgnore] public List SubjectAdditionalEvaluationResult { get; set; } diff --git a/IRaCIS.Core.Domain/Visit/SubjectCanceDoctor.cs b/IRaCIS.Core.Domain/Visit/SubjectCanceDoctor.cs deleted file mode 100644 index 7be50545f..000000000 --- a/IRaCIS.Core.Domain/Visit/SubjectCanceDoctor.cs +++ /dev/null @@ -1,31 +0,0 @@ - -//-------------------------------------------------------------------- -// 此代码由T4模板自动生成 byzhouhang 20210918 -// 生成时间 2022-07-29 10:43:49 -// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。 -using System; -using IRaCIS.Core.Domain.Share; -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; -namespace IRaCIS.Core.Domain.Models -{ - /// - ///SubjectCanceDoctor - /// - [Table("SubjectCanceDoctor")] - public class SubjectCanceDoctor : Entity, IAuditAdd - { - - public Subject Subject { get; set; } - public Guid CreateUserId { get; set; } - - public DateTime CreateTime { get; set; } - - - public Guid SubjectId { get; set; } - - public string Note { get; set; } - - } - -} diff --git a/IRaCIS.Core.Domain/Visit/SubjectVisit.cs b/IRaCIS.Core.Domain/Visit/SubjectVisit.cs index 0711685f5..e00d65c47 100644 --- a/IRaCIS.Core.Domain/Visit/SubjectVisit.cs +++ b/IRaCIS.Core.Domain/Visit/SubjectVisit.cs @@ -228,8 +228,6 @@ namespace IRaCIS.Core.Domain.Models [JsonIgnore] public List VisitTaskList { get; set; } = new List(); - [JsonIgnore] - public List SubjectCriteriaEvaluationVisitFilterList { get; set; } public ReadingStatusEnum ReadingStatus { get; set; } diff --git a/IRaCIS.Core.Domain/_Config/_AppSettings.cs b/IRaCIS.Core.Domain/_Config/_AppSettings.cs index 4bda63fec..d67ca0634 100644 --- a/IRaCIS.Core.Domain/_Config/_AppSettings.cs +++ b/IRaCIS.Core.Domain/_Config/_AppSettings.cs @@ -100,10 +100,6 @@ namespace IRaCIS.Core.Domain.Share { switch (typeStr) { - case nameof(Doctor): - - return DoctorCodePrefix + codeInt.ToString("D4"); - case nameof(User): return UserCodePrefix + codeInt.ToString("D4"); diff --git a/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs b/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs index 4ccdc0025..7901898af 100644 --- a/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs +++ b/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs @@ -993,131 +993,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common #region 附加评估 - // 是否参与附加评估记录表 - foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(SubjectCriteriaEvaluation))) - { - var type = GetEntityAuditOpt(item); - - //var extraIdentification = string.Empty; - - var entity = item.Entity as SubjectCriteriaEvaluation; - - - await InsertInspection(entity, type, x => new InspectionConvertDTO() - { - IsDistinctionInterface = false, - ObjectRelationParentId = x.SubjectId, - ObjectRelationParentId2 = x.TrialReadingCriterionId, - - TrialReadingCriterionId = x.TrialReadingCriterionId, - }); - - - } - - foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(SubjectCriteriaEvaluationVisitFilter))) - { - var type = GetEntityAuditOpt(item); - - var extraIdentification = string.Empty; - - var entity = item.Entity as SubjectCriteriaEvaluationVisitFilter; - - - if (type == AuditOpt.Add) - { - if (entity.IsGeneratedTask) - { - extraIdentification = "/AutoGenerate"; - } - else - { - extraIdentification = "/Add"; - } - } - - if (type == AuditOpt.Update) - { - - //手动生成任务 - - if (entity.IsGeneratedTask) - { - //Update - extraIdentification = "/ManualGenerate"; - } - - - //回退接口 - else if (_userInfo.RequestUrl == "SubjectCriteriaEvaluation/confirmBackCriteriaVisitTask") - { - extraIdentification = "/Back"; - } - else - { - //筛选影像保存接口 - //if (_userInfo.RequestUrl == "SubjectCriteriaEvaluation/batchAddSubjectCriteriaEvaluationVisitStudyFilter") - //{ - extraIdentification = "/Update"; - //} - - } - - - } - - - - - - - await InsertInspection(entity, type, x => new InspectionConvertDTO() - { - IsDistinctionInterface = false, - IsSelfDefine = true, - ExtraIndentification = extraIdentification, - ObjectRelationParentId = x.SubjectVisitId, - ObjectRelationParentId2 = x.TrialReadingCriterionId, - - TrialReadingCriterionId = x.TrialReadingCriterionId, - }); - } - - foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(SubjectCriteriaEvaluationVisitStudyFilter))) - { - var type = GetEntityAuditOpt(item); - - var extraIdentification = string.Empty; - - var entity = item.Entity as SubjectCriteriaEvaluationVisitStudyFilter; - - if (entity.IsConfirmed == true) - { - extraIdentification = "/Confirm"; - } - else - { - extraIdentification = "/Save"; - } - - await InsertInspection(entity, type, x => new InspectionConvertDTO() - { - IsDistinctionInterface = false, - IsSelfDefine = true, - - ExtraIndentification = extraIdentification, - - ObjectRelationParentId = x.StudyId, - ObjectRelationParentId2 = x.SeriesId,//序列有的稽查没有记录,所以StudyId放前面 - - ObjectRelationParentId3 = x.TrialReadingCriterionId, - - TrialReadingCriterionId = x.TrialReadingCriterionId, - }); - } - - - + #endregion #region 医学审核 @@ -1956,71 +1832,6 @@ namespace IRaCIS.Core.Infra.EFCore.Common #region 阅片人入组 - //阅片人入组 父层级未记录稽查(医生) - foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(Enroll))) - { - var type = GetEntityAuditOpt(item); - - var entity = item.Entity as Enroll; - var doctor = await _dbContext.Doctor.FirstOrDefaultAsync(x => x.Id == entity.DoctorId); - var readingCategoryList = await _dbContext.EnrollReadingCategory.Where(x => x.EnrollId == entity.Id).Select(t => t.ReadingCategory).ToListAsync(); - await InsertInspection(item.Entity as Enroll, type, x => new InspectionConvertDTO() - { - ObjectRelationParentId = x.TrialId - }, new - { - //父层级的数据 暂时没有记录稽查 所以这里必须查 - Name = doctor.FullName, - ChineseName = doctor.ChineseName, - Email = doctor.EMail, - IsUploadedACKSOW = entity.AttachmentId != Guid.Empty, - - //子层级的数据 记录到父层级 必须查询 不然找上一条时数据不准 - ReadingCategoryList = readingCategoryList - }); - } - - //独立阅片人 设置阅片类型 这里对于操作人 不区分 添加 编辑 删除 只有设置(相当于更新) - - if (entitys.Any(x => x.Entity.GetType() == typeof(EnrollReadingCategory))) - { - var type = AuditOpt.Update; - - var addList = entitys.Where(x => x.Entity.GetType() == typeof(EnrollReadingCategory) && x.State == EntityState.Added).Select(t => t.Entity as EnrollReadingCategory).ToList(); - var deleteList = entitys.Where(x => x.Entity.GetType() == typeof(EnrollReadingCategory) && x.State == EntityState.Deleted).Select(t => t.Entity as EnrollReadingCategory).ToList(); - - var first = addList.Union(deleteList).FirstOrDefault(); - - var enrollId = first.EnrollId; - - Guid? trialId = Guid.Empty; - - if (first.Enroll != null) - { - trialId = first.Enroll.TrialId; - } - else - { - trialId = await _dbContext.Enroll.Where(x => x.Id == enrollId).Select(t => t.TrialId).FirstOrDefaultAsync(); - } - - - await InsertInspection(first, type, x => new InspectionConvertDTO() - { - //GeneralId 和ObjectRelationParentId 一样 会成环 所以查询的时候 需要排除自身 - GeneralId = enrollId, - - TrialId = trialId, - - ObjectRelationParentId = enrollId, - - IsDistinctionInterface = false - }, new - { - ReadingCategoryList = addList.Select(t => t.ReadingCategory).ToList(), - }); - } - #endregion @@ -2224,43 +2035,6 @@ namespace IRaCIS.Core.Infra.EFCore.Common //分配规则 - foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(TaskAllocationRule))) - { - var type = GetEntityAuditOpt(item); - - var entity = item.Entity as TaskAllocationRule; - - await InsertInspection(entity, type, x => new InspectionConvertDTO() - { - IsDistinctionInterface = false, - - ObjectRelationParentId = entity.EnrollId, - - ObjectRelationParentId2 = entity.DoctorUserId - - }); - } - - // suject 医生绑定关系 - foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(SubjectUser))) - { - var type = GetEntityAuditOpt(item); - - var entity = item.Entity as SubjectUser; - - await InsertInspection(entity, type, x => new InspectionConvertDTO() - { - IsDistinctionInterface = false, - - ObjectRelationParentId = entity.SubjectId, - - ObjectRelationParentId2 = entity.DoctorUserId, - - ObjectRelationParentId3 = entity.TrialReadingCriterionId, - - }, new { ArmToTask = entity.ArmEnum }); - } - //申请重阅记录表 @@ -2321,40 +2095,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common //一致性分析规则 - foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(TaskConsistentRule))) - { - var type = GetEntityAuditOpt(item); - - var entity = item.Entity as TaskConsistentRule; - - - var extraIdentification = string.Empty; - - //自身一致性分析 - if (entity.IsSelfAnalysis == true) - { - extraIdentification = "/" + 1; - - } - //组件一致性分析 - else - { - extraIdentification = "/" + 2; - } - - await InsertInspection(entity, type, x => new InspectionConvertDTO() - { - IsDistinctionInterface = true, - - ObjectRelationParentId = entity.TrialId, - - ObjectRelationParentId2 = entity.TrialReadingCriterionId, - - ExtraIndentification = extraIdentification, - }); - } - - + #endregion diff --git a/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs b/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs index 6e1d84aae..48b04a03b 100644 --- a/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs +++ b/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs @@ -122,7 +122,6 @@ namespace IRaCIS.Core.Infra.EFCore modelBuilder.Entity().HasMany(t => t.ChildList).WithOne(t => t.Parent); - modelBuilder.Entity().HasMany(t => t.EarlierSubjectUserList).WithOne(t => t.OrignalSubjectUser); if (_userInfo.IsEn_Us) { modelBuilder.Entity().Property(t => t.MappedValue).HasColumnName(nameof(Domain.Models.Dictionary.Value)); @@ -177,20 +176,7 @@ namespace IRaCIS.Core.Infra.EFCore #region Doctor public virtual DbSet Dictionary { get; set; } - public virtual DbSet Doctor { get; set; } - public virtual DbSet DoctorCriterionFile { get; set; } - public virtual DbSet DoctorDictionary { get; set; } - public virtual DbSet Postgraduate { get; set; } - public virtual DbSet Education { get; set; } - public virtual DbSet ResearchPublications { get; set; } - public virtual DbSet TrialExperience { get; set; } - - public virtual DbSet UserDoctor { get; set; } - public virtual DbSet Vacation { get; set; } - - public virtual DbSet Attachment { get; set; } - public virtual DbSet TrialExperienceCriteria { get; set; } @@ -199,13 +185,7 @@ namespace IRaCIS.Core.Infra.EFCore #region Enroll - public virtual DbSet DoctorWorkload { get; set; } - public virtual DbSet Enroll { get; set; } - public virtual DbSet EnrollReadingCategory { get; set; } - - - public virtual DbSet EnrollDetails { get; set; } @@ -281,10 +261,9 @@ namespace IRaCIS.Core.Infra.EFCore public virtual DbSet TrialCriterionAdditionalAssessmentType { get; set; } - public virtual DbSet SubjectCriteriaEvaluation { get; set; } + public virtual DbSet SubjectAdditionalEvaluationResult { get; set; } - public virtual DbSet SubjectCriteriaEvaluationVisitFilter { get; set; } - public virtual DbSet SubjectCriteriaEvaluationVisitStudyFilter { get; set; } + @@ -372,16 +351,8 @@ namespace IRaCIS.Core.Infra.EFCore #endregion #region Financial - public virtual DbSet ReviewerPayInformation { get; set; } - public virtual DbSet RankPrice { get; set; } - public virtual DbSet TrialPaymentPrice { get; set; } - public virtual DbSet AwardPrice { get; set; } - public virtual DbSet Payment { get; set; } - public virtual DbSet PaymentDetail { get; set; } - public virtual DbSet ExchangeRate { get; set; } - public virtual DbSet TrialRevenuesPrice { get; set; } - public virtual DbSet PaymentAdjustment { get; set; } - public virtual DbSet TrialRevenuesPriceVerification { get; set; } + + #endregion @@ -756,11 +727,10 @@ namespace IRaCIS.Core.Infra.EFCore - public virtual DbSet TaskAllocationRule { get; set; } public virtual DbSet VisitTask { get; set; } - public virtual DbSet SubjectUser { get; set; } + public virtual DbSet VisitTaskReReading { get; set; } @@ -768,12 +738,11 @@ namespace IRaCIS.Core.Infra.EFCore public virtual DbSet TaskMedicalReviewRule { get; set; } - public virtual DbSet TaskConsistentRule { get; set; } public virtual DbSet TaskInfluence { get; set; } - public virtual DbSet SubjectCanceDoctor { get; set; } + public virtual DbSet TrialEmailNoticeConfig { get; set; } diff --git a/IRaCIS.Core.Infra.EFCore/EntityConfigration/DoctorConfigration.cs b/IRaCIS.Core.Infra.EFCore/EntityConfigration/DoctorConfigration.cs deleted file mode 100644 index bac14118a..000000000 --- a/IRaCIS.Core.Infra.EFCore/EntityConfigration/DoctorConfigration.cs +++ /dev/null @@ -1,57 +0,0 @@ -using IRaCIS.Core.Domain.Models; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Metadata.Builders; - - -namespace IRaCIS.Core.Infra.EFCore.EntityConfigration -{ - public class DoctorConfigration : IEntityTypeConfiguration - { - - - public void Configure(EntityTypeBuilder builder) - { - builder - .HasOne(dd => dd.Doctor) - .WithMany(p => p.DoctorDicRelationList) - .HasForeignKey(dd => dd.DoctorId); - - builder - .HasOne(dd => dd.Dictionary) - .WithMany(d => d.DoctorDicRelationList) - .HasForeignKey(dd => dd.DictionaryId); - } - - - } - - //public class DoctorTaskConfigration : IEntityTypeConfiguration - //{ - - - // public void Configure(EntityTypeBuilder builder) - // { - // builder - // .HasOne(dd => dd.DoctorUser) - // .WithMany(p => p.VisitTaskList) - // .HasForeignKey(dd => dd.DoctorUserId); - - - // } - - - //} - - public class DictionaryConfigration : IEntityTypeConfiguration - { - - - public void Configure(EntityTypeBuilder builder) - { - builder.Property(e => e.MappedValue).Metadata.SetBeforeSaveBehavior(PropertySaveBehavior.Ignore); - builder.Property(e => e.MappedValue).Metadata.SetAfterSaveBehavior(PropertySaveBehavior.Ignore); - - } - } -} diff --git a/IRaCIS.Core.Infra.EFCore/EntityConfigration/TrialSiteConfigration.cs b/IRaCIS.Core.Infra.EFCore/EntityConfigration/TrialSiteConfigration.cs index 1306cbbf3..80fc299e8 100644 --- a/IRaCIS.Core.Infra.EFCore/EntityConfigration/TrialSiteConfigration.cs +++ b/IRaCIS.Core.Infra.EFCore/EntityConfigration/TrialSiteConfigration.cs @@ -21,20 +21,6 @@ namespace IRaCIS.Core.Infra.EFCore.EntityConfigration } } - public class SubjectCriteriaEvaluationConfigration : IEntityTypeConfiguration - { - - - public void Configure(EntityTypeBuilder builder) - { - builder - .HasMany(s => s.SubjectCriteriaEvaluationVisitFilterList) - .WithOne(c => c.SubjectCriteriaEvaluation) - .HasForeignKey(s => new { s.SubjectId, s.TrialReadingCriterionId }) - .HasPrincipalKey(c => new { c.SubjectId, c.TrialReadingCriterionId }); - - } - } //public class SubjectCriteriaEvaluationVisitFilterConfigration : IEntityTypeConfiguration //{