public bool ShouldBeClosed() { var mostRecentTreatmentEvent = TreatmentEvents.GetMostRecentTreatmentEvent(); return(NotificationStatus == NotificationStatus.Notified && (EventIsEndingAndOlderThanOneYear(mostRecentTreatmentEvent) || IsPostMortemAndOlderThanOneYear())); bool EventIsEndingAndOlderThanOneYear(TreatmentEvent treatmentEvent) { if (mostRecentTreatmentEvent?.TreatmentOutcomeId == null || !mostRecentTreatmentEvent.TreatmentEventTypeIsOutcome) { return(false); } var treatmentOutcome = treatmentEvent.TreatmentOutcome ?? SeedData.TreatmentOutcomes.GetTreatmentOutcomes() .Single(oc => oc.TreatmentOutcomeId == treatmentEvent.TreatmentOutcomeId); return(treatmentOutcome.TreatmentOutcomeSubType != TreatmentOutcomeSubType.StillOnTreatment && treatmentEvent.EventDate < DateTime.Today.AddYears(-1)); } bool IsPostMortemAndOlderThanOneYear() { return(IsPostMortemAndHasCorrectEvents && TreatmentEvents.Single(te => te.TreatmentEventIsDeathEvent).EventDate < DateTime.Today.AddYears(-1)); } }
public ICollection <TreatmentEvent> GetTreatmentEventsWithStartingEvent() { var treatmentEvents = TreatmentEvents.ToList(); if (NotificationStatus == NotificationStatus.Draft && ClinicalDetails.StartingDate != null) { treatmentEvents.Add(NotificationHelper.CreateTreatmentStartEvent(this)); } return(treatmentEvents); }
public void AddTreatmentEvent(TreatmentEvent treatmentEvent) { TreatmentEvents.Add(treatmentEvent); PeriodEndDate = treatmentEvent.EventDate; }