public void ApplyTo(CompletedEvent completedEvent)
        {
            if (!completedEvent.Cancer)
            {
                return;
            }

            var referralReceivedEvent = completedEvent.Period.CompletedEvents.FirstOrDefault(@event => @event.Name.Code == EventCode.ReferralReceived);

            if (completedEvent.Name.Code == EventCode.DiagnosticsTestResultAvailable)
            {
                if (referralReceivedEvent != null)
                {
                    completedEvent.TargetDate =
                        referralReceivedEvent.EventDate.AddDays(
                            Constants.DignosticTestResultAvailableTargetNumberOfDaysForCancer);
                }
            }

            if (completedEvent.Name.Code == EventCode.AttendedOutpatientFirstAppointment)
            {
                if (referralReceivedEvent != null)
                {
                    completedEvent.TargetDate =
                        referralReceivedEvent.EventDate.AddDays(
                            Constants.OutpatientFirstAppointmentAttendedTargetNumberOfDaysForCancer);
                }
            }
        }
Esempio n. 2
0
        public void MapEventMilestoneToCompletedEvent(CompletedEvent completedEvent, EventMilestone eventMilestone, EventName targetEventName)
        {
            if (!(CompletedEvents.Any(@event => @event.Name.Code == targetEventName.Code)))
            {
                OnValidationFailed(new RuleViolation
                {
                    Message = string.Format("Event Milestone {0} on {1}, on pathway {2}, does not have target reference completed event {3}.", eventMilestone.Name.Description, completedEvent.Period.Name, completedEvent.Period.Pathway.PPINumber, targetEventName.Description),
                    Period  = completedEvent.Period
                });
            }

            eventMilestone.CompletedEvent = completedEvent;
        }
Esempio n. 3
0
        public void Add(CompletedEvent completedEvent)
        {
            if (CompletedEvents.Any(@event => @event.EventDate > completedEvent.EventDate))
            {
                OnValidationFailed(new RuleViolation
                {
                    Message = string.Format("Completed event {0} on {1}, on pathway {2}, should not have the date {3} in the past.", completedEvent.Name.Description, Name, Pathway.PPINumber, completedEvent.EventDate),
                    Period  = this
                });
            }

            CompletedEvents.Add(completedEvent);
        }