DateTimeErrorString ValidateDeathOrLastContactDateTime(DateTime?now = null) { switch (OutcomeAt28Days) { case OutcomeAt28DaysOption.Missing: case OutcomeAt28DaysOption.InpatientAt28Days: case OutcomeAt28DaysOption.DischargedBefore28Days: case OutcomeAt28DaysOption.DischargedAndKnownToHaveSurvived: return(new DateTimeErrorString()); } DateTimeErrorString error = _deathOrLastContactDateTime.ValidateNotEmpty(); ValidateIsBetweenRegistrationAndNowOr28(ref error, _deathOrLastContactDateTime, now); switch (OutcomeAt28Days) { case OutcomeAt28DaysOption.DischargedAndKnownToHaveDied: case OutcomeAt28DaysOption.DischargedAndLikelyToHaveDied: case OutcomeAt28DaysOption.DischargedAndLikelyToHaveSurvived: var dischargeAt = _dischargeDateTime.DateAndTime; if (dischargeAt.HasValue) { _deathOrLastContactDateTime.ValidateIsAfter(Strings.ParticipantModel_Describe_DateTimeDischarge, dischargeAt.Value, ref error); } break; } return(error); }
DateTimeErrorString ValidateDischargeDateTime(DateTime?now = null) { DateTimeErrorString error; if (OutcomeAt28Days >= OutcomeAt28DaysOption.DischargedBefore28Days) { error = _dischargeDateTime.ValidateNotEmpty(); ValidateIsBetweenRegistrationAndNowOr28(ref error, _dischargeDateTime, now); } else { error = new DateTimeErrorString(); } return(error); }
void ValidateIsBetweenRegistrationAndNowOr28(ref DateTimeErrorString error, DateTimeSplitter splitter, DateTime?now = null) { splitter.ValidateIsAfter(Strings.ParticipantModel_Error_RegistrationDateTime, RegisteredAt, ref error); DateTime nowVal = now ?? DateTime.Now; if (nowVal >= Becomes28On) { splitter.ValidateIsBefore( string.Format(Strings.TimeInterval_28days, Becomes28On), Becomes28On, ref error); } else { splitter.ValidateIsBefore( Strings.DateTime_Now, nowVal, ref error); } }