//Check all DateTime values in the list and find the earliest value. private DateTime ResolveTargetEventDateTime(Timing Timing, bool TargetLowest, int searchParameterId) { DateTime TargetEventDateTime; if (TargetLowest) { TargetEventDateTime = DateTime.MaxValue.ToUniversalTime(); } else { TargetEventDateTime = DateTime.MinValue.ToUniversalTime(); } foreach (var EventDateTime in Timing.EventElement) { if (!string.IsNullOrWhiteSpace(EventDateTime.Value)) { if (FhirDateTime.IsValidValue(EventDateTime.Value)) { PartialDateTime?PartialDateTimeType = EventDateTime.ToPartialDateTime(); if (PartialDateTimeType.HasValue) { IndexDateTime?DateTimeIndexOffSetValue = ParsePartialDateTime(PartialDateTimeType.Value, searchParameterId); if (DateTimeIndexOffSetValue is object) { if (TargetLowest) { if (DateTimeIndexOffSetValue.Low.HasValue) { if (TargetEventDateTime > DateTimeIndexOffSetValue.Low.Value) { TargetEventDateTime = DateTimeIndexOffSetValue.Low.Value; } } } else { if (DateTimeIndexOffSetValue.High.HasValue) { if (TargetEventDateTime < DateTimeIndexOffSetValue.High.Value) { TargetEventDateTime = DateTimeIndexOffSetValue.High.Value; } } } } } } } } return(TargetEventDateTime); }
//Check all DateTime values in the list and find the earliest value. private static DateTimeOffset ResolveTargetEventDateTime(Timing Timing, bool TargetLowest) { DateTimeOffset TargetEventDateTime; if (TargetLowest) { TargetEventDateTime = DateTimeOffset.MaxValue.ToUniversalTime(); } else { TargetEventDateTime = DateTimeOffset.MinValue.ToUniversalTime(); } foreach (var EventDateTime in Timing.EventElement) { if (!string.IsNullOrWhiteSpace(EventDateTime.Value)) { if (FhirDateTime.IsValidValue(EventDateTime.Value)) { PartialDateTime?PartialDateTimeType = EventDateTime.ToPartialDateTime(); if (PartialDateTimeType.HasValue) { DateTimeIndex DateTimeIndexOffSetValue = ParsePartialDateTime(PartialDateTimeType.Value); DateTimeOffset DateTimeOffSetValue = PartialDateTimeType.Value.ToUniversalTime().ToLocalTime(); if (TargetLowest) { if (TargetEventDateTime > DateTimeIndexOffSetValue.Low.Value) { TargetEventDateTime = DateTimeIndexOffSetValue.Low.Value; } } else { if (TargetEventDateTime < DateTimeIndexOffSetValue.High.Value) { TargetEventDateTime = DateTimeIndexOffSetValue.High.Value; } } } } } } return(TargetEventDateTime); }