示例#1
0
        private async Task <List <KeyValuePair <string, string> > > PrepareAdverseEventForActiveReportAsync(PatientClinicalEvent patientClinicalEvent, ReportInstance reportInstance, bool isSerious)
        {
            var extendable = (IExtendable)patientClinicalEvent;
            List <KeyValuePair <string, string> > rows = new();

            rows.Add(new KeyValuePair <string, string>("Source Description", patientClinicalEvent.SourceDescription));
            rows.Add(new KeyValuePair <string, string>("MedDRA Term", reportInstance.TerminologyMedDra?.MedDraTerm));
            rows.Add(new KeyValuePair <string, string>("Onset Date (yyyy-mm-dd)", patientClinicalEvent.OnsetDate.HasValue ? patientClinicalEvent.OnsetDate.Value.ToString("yyyy-MM-dd") : ""));
            rows.Add(new KeyValuePair <string, string>("Resolution Date (yyyy-mm-dd)", patientClinicalEvent.ResolutionDate.HasValue ? patientClinicalEvent.ResolutionDate.Value.ToString("yyyy-MM-dd") : ""));

            if (patientClinicalEvent.OnsetDate.HasValue && patientClinicalEvent.ResolutionDate.HasValue)
            {
                rows.Add(new KeyValuePair <string, string>("Duration", $"${(patientClinicalEvent.ResolutionDate.Value - patientClinicalEvent.OnsetDate.Value).Days} days"));
            }
            else
            {
                rows.Add(new KeyValuePair <string, string>("Duration", string.Empty));
            }

            rows.Add(new KeyValuePair <string, string>("Outcome", await _attributeService.GetCustomAttributeValueAsync("PatientClinicalEvent", "Outcome", extendable)));

            if (isSerious)
            {
                rows.Add(new KeyValuePair <string, string>("Seriousness", await _attributeService.GetCustomAttributeValueAsync("PatientClinicalEvent", "Seriousness", extendable)));
                rows.Add(new KeyValuePair <string, string>("Classification", ReportClassification.From(reportInstance.ReportClassificationId).Name));
                rows.Add(new KeyValuePair <string, string>("Severity Grade", await _attributeService.GetCustomAttributeValueAsync("PatientClinicalEvent", "Severity Grade", extendable)));
                rows.Add(new KeyValuePair <string, string>("SAE Number", await _attributeService.GetCustomAttributeValueAsync("PatientClinicalEvent", "FDA SAE Number", extendable)));
            }

            return(rows);
        }
        private async Task CustomMapAsync(PatientClinicalEvent patientClinicalEventFromRepo, PatientClinicalEventExpandedDto dto)
        {
            IExtendable patientClinicalEventExtended = patientClinicalEventFromRepo;

            // Map all custom attributes
            dto.ClinicalEventAttributes = _modelExtensionBuilder.BuildModelExtension(patientClinicalEventExtended)
                                          .Select(h => new AttributeValueDto()
            {
                Id             = h.Id,
                Key            = h.AttributeKey,
                Value          = h.TransformValueToString(),
                Category       = h.Category,
                SelectionValue = GetSelectionValue(h.Type, h.AttributeKey, h.Value.ToString())
            }).Where(s => (s.Value != "0" && !String.IsNullOrWhiteSpace(s.Value)) || !String.IsNullOrWhiteSpace(s.SelectionValue)).ToList();

            dto.ReportDate = await _customAttributeService.GetCustomAttributeValueAsync("PatientClinicalEvent", "Date of Report", patientClinicalEventExtended);

            dto.IsSerious = await _customAttributeService.GetCustomAttributeValueAsync("PatientClinicalEvent", "Is the adverse event serious?", patientClinicalEventExtended);

            var activity = await _reportInstanceQueries.GetExecutionStatusEventsForEventViewAsync(patientClinicalEventFromRepo.Id);

            dto.Activity = activity.ToList();

            var reportInstanceFromRepo = await _reportInstanceRepository.GetAsync(ri => ri.ContextGuid == patientClinicalEventFromRepo.PatientClinicalEventGuid, new string[] { "TerminologyMedDra", "Medications", "Tasks.Comments" });

            if (reportInstanceFromRepo == null)
            {
                return;
            }

            dto.SetMedDraTerm     = reportInstanceFromRepo.TerminologyMedDra?.DisplayName;
            dto.SetClassification = ReportClassification.From(reportInstanceFromRepo.ReportClassificationId).Name;
            dto.Medications       = _mapper.Map <ICollection <ReportInstanceMedicationDetailDto> >(reportInstanceFromRepo.Medications.Where(m => !String.IsNullOrWhiteSpace(m.WhoCausality) || (!String.IsNullOrWhiteSpace(m.NaranjoCausality))));
            dto.Tasks             = _mapper.Map <ICollection <TaskDto> >(reportInstanceFromRepo.Tasks.Where(t => t.TaskStatusId != Core.Aggregates.ReportInstanceAggregate.TaskStatus.Cancelled.Id));
        }
示例#3
0
        public async Task UpdateUserRating(Guid userId, Guid reportId, int rating)
        {
            var user = await _userRepo.GetById(userId);

            if (user == null)
            {
                this.Notify("Usuário não encontrado.");
                return;
            }

            //mesma validacao de user para o report

            var classf = await _repository.FindUserClassification(userId, reportId);

            if (classf == null)
            {
                classf = new ReportClassification()
                {
                    UserId   = userId,
                    ReportId = reportId,
                    Rating   = rating
                };

                await _repository.Add(classf);
            }
            else
            {
                classf.Rating = rating;
                await _repository.Update(classf);
            }
        }
示例#4
0
        public ReportInstanceProfile()
        {
            CreateMap <ReportInstance, ReportInstanceIdentifierDto>();
            CreateMap <ReportInstance, ReportInstanceDetailDto>()
            .ForMember(dest => dest.CreatedDetail, opt => opt.MapFrom(src => src.Created))
            .ForMember(dest => dest.UpdatedDetail, opt => opt.MapFrom(src => src.LastUpdated))
            .ForMember(dest => dest.CurrentStatus, opt => opt.MapFrom(src => src.CurrentActivity.CurrentStatus.Description))
            .ForMember(dest => dest.QualifiedName, opt => opt.MapFrom(src => src.CurrentActivity.QualifiedName))
            .ForMember(dest => dest.ReportClassification, opt => opt.MapFrom(src => ReportClassification.From(src.ReportClassificationId).Name))
            .ForMember(dest => dest.TaskCount, opt => opt.MapFrom(src => src.Tasks.Count()))
            .ForMember(dest => dest.ActiveTaskCount, opt => opt.MapFrom(src => src.Tasks.Where(t => t.TaskStatusId != TaskStatus.Cancelled.Id && t.TaskStatusId != TaskStatus.Done.Id && t.TaskStatusId != TaskStatus.Completed.Id).Count()));
            CreateMap <ReportInstance, ReportInstanceExpandedDto>()
            .ForMember(dest => dest.CreatedDetail, opt => opt.MapFrom(src => src.Created))
            .ForMember(dest => dest.UpdatedDetail, opt => opt.MapFrom(src => src.LastUpdated))
            .ForMember(dest => dest.CurrentStatus, opt => opt.MapFrom(src => src.CurrentActivity.CurrentStatus.Description))
            .ForMember(dest => dest.QualifiedName, opt => opt.MapFrom(src => src.CurrentActivity.QualifiedName))
            .ForMember(dest => dest.ReportClassification, opt => opt.MapFrom(src => ReportClassification.From(src.ReportClassificationId).Name))
            .ForMember(dest => dest.TaskCount, opt => opt.MapFrom(src => src.Tasks.Count()))
            .ForMember(dest => dest.ActiveTaskCount, opt => opt.MapFrom(src => src.Tasks.Where(t => t.TaskStatusId != TaskStatus.Cancelled.Id && t.TaskStatusId != TaskStatus.Done.Id && t.TaskStatusId != TaskStatus.Completed.Id).Count()));

            CreateMap <TerminologyMedDra, TerminologyMedDraDto>();

            CreateMap <ReportInstanceMedication, ReportInstanceMedicationIdentifierDto>()
            .ForMember(dest => dest.ReportInstanceId, opt => opt.MapFrom(src => src.ReportInstance.Id));
            CreateMap <ReportInstanceMedication, ReportInstanceMedicationDetailDto>()
            .ForMember(dest => dest.ReportInstanceId, opt => opt.MapFrom(src => src.ReportInstance.Id));

            CreateMap <ReportInstanceTask, TaskDto>()
            .ForMember(dest => dest.Source, opt => opt.MapFrom(src => src.TaskDetail.Source))
            .ForMember(dest => dest.Description, opt => opt.MapFrom(src => src.TaskDetail.Description))
            .ForMember(dest => dest.TaskType, opt => opt.MapFrom(src => TaskType.From(src.TaskTypeId).Name))
            .ForMember(dest => dest.TaskStatus, opt => opt.MapFrom(src => TaskStatus.From(src.TaskStatusId).Name))
            .ForMember(dest => dest.TaskAge, opt => opt.MapFrom(src => (DateTime.UtcNow.Date - src.Created.Date).TotalDays))
            .ForMember(dest => dest.CreatedDetail, opt => opt.MapFrom(src => src.Created))
            .ForMember(dest => dest.UpdatedDetail, opt => opt.MapFrom(src => src.LastUpdated))
            .ForMember(dest => dest.Comments, opt => opt.MapFrom(src => src.Comments.OrderByDescending(c => c.Created)));

            CreateMap <ReportInstanceTaskComment, TaskCommentDto>()
            .ForMember(dest => dest.CreatedDetail, opt => opt.MapFrom(src => src.Created))
            .ForMember(dest => dest.CreatedInitials, opt => opt.MapFrom(src => $"{src.CreatedBy.FirstName.Substring(0, 1)}{src.CreatedBy.LastName.Substring(0, 1)}"))
            .ForMember(dest => dest.UpdatedDetail, opt => opt.MapFrom(src => src.LastUpdated));

            CreateMap <ActivityExecutionStatusEvent, ActivityExecutionStatusEventDto>()
            .ForMember(dest => dest.Activity, opt => opt.MapFrom(src => src.ExecutionStatus.Activity.QualifiedName))
            .ForMember(dest => dest.ExecutionEvent, opt => opt.MapFrom(src => src.ExecutionStatus.Description))
            .ForMember(dest => dest.ExecutedBy, opt => opt.MapFrom(src => src.EventCreatedBy != null ? src.EventCreatedBy.FullName : string.Empty))
            .ForMember(dest => dest.ExecutedDate, opt => opt.MapFrom(src => src.EventDateTime.ToString("yyyy-MM-dd HH:mm tt")))
            .ForMember(dest => dest.ReceiptDate, opt => opt.MapFrom(src => src.ContextDateTime != null ? Convert.ToDateTime(src.ContextDateTime).ToString("yyyy-MM-dd") : ""))
            .ForMember(dest => dest.ReceiptCode, opt => opt.MapFrom(src => src.ContextCode));
        }
        public async Task <ReportClassification> FindRatingByUserAndReport(Guid userId, Guid reportId)
        {
            var rating = await _repository.FindUserClassification(userId, reportId);

            if (rating == null)
            {
                rating = new ReportClassification()
                {
                    Rating   = 0,
                    UserId   = userId,
                    ReportId = reportId
                };

                await _repository.Add(rating);
            }

            return(rating);
        }
示例#6
0
 public ChangeReportClassificationCommand(Guid workFlowGuid, int reportInstanceId, ReportClassification reportClassification) : this()
 {
     WorkFlowGuid         = workFlowGuid;
     ReportInstanceId     = reportInstanceId;
     ReportClassification = reportClassification;
 }
        public async Task Handle(CausalityConfirmedDomainEvent domainEvent, CancellationToken cancellationToken)
        {
            var subject = $"Report: {domainEvent.ReportInstance.PatientIdentifier}";

            var sb = new StringBuilder();

            sb.Append($"Causality and terminology has been set for this report. Please note the following details pertaining to the report: ");
            sb.Append("<p><b><u>Adverse Event Details</u></b></p>");
            sb.Append("<table>");
            sb.Append($"<tr><td style='padding: 10px; border: 1px solid black;'><b>Identifier</b></td><td style='padding: 10px; border: 1px solid black;'>{domainEvent.ReportInstance.Identifier}</td></tr>");
            sb.Append($"<tr><td style='padding: 10px; border: 1px solid black;'><b>Patient</b></td><td style='padding: 10px; border: 1px solid black;'>{domainEvent.ReportInstance.PatientIdentifier}</td></tr>");
            sb.Append($"<tr><td style='padding: 10px; border: 1px solid black;'><b>Created</b></td><td style='padding: 10px; border: 1px solid black;'>{domainEvent.ReportInstance.Created}</td></tr>");
            sb.Append($"<tr><td style='padding: 10px; border: 1px solid black;'><b>Description</b></td><td style='padding: 10px; border: 1px solid black;'>{domainEvent.ReportInstance.SourceIdentifier}</td></tr>");
            sb.Append("</table>");
            sb.Append("<p><b><u>Causality and Terminology Details</u></b></p>");
            sb.Append("<table>");
            sb.Append($"<tr><td style='padding: 10px; border: 1px solid black;'><b>Terminology</b></td><td style='padding: 10px; border: 1px solid black;'>{domainEvent.ReportInstance.TerminologyMedDra.DisplayName}</td></tr>");
            sb.Append($"<tr><td style='padding: 10px; border: 1px solid black;'><b>Classification</b></td><td style='padding: 10px; border: 1px solid black;'>{ReportClassification.From(domainEvent.ReportInstance.ReportClassificationId)}</td></tr>");
            sb.Append($"<tr><td style='padding: 10px; border: 1px solid black;'><b>Causality</b></td><td style='padding: 10px; border: 1px solid black;'>Please browse PV feedback for more details</td></tr>");
            sb.Append("</table>");
            sb.Append("<p><b>*** This is system generated. Please do not reply to this message ***</b></p>");

            await _smtpMailService.SendEmailAsync(subject, sb.ToString(), await PrepareDestinationMailBoxesAsync(domainEvent));
        }