Example #1
0
        public void Write(String parameterName, FhirDateTime fhirDateTime)
        {
            BsonDocument value = new BsonDocument();

            value.Add(new BsonElement("start", BsonDateTime.Create(fhirDateTime.LowerBound())));
            value.Add(new BsonElement("end", BsonDateTime.Create(fhirDateTime.UpperBound())));
            document.Write(parameterName, value);
        }
Example #2
0
        /// <summary>
        /// { start : lowerbound-of-fhirdatetime, end : upperbound-of-fhirdatetime }
        /// <seealso cref="ToExpressions(Period)"/>, with lower and upper bounds of FhirDateTime as bounds of the Period.
        /// </summary>
        /// <param name="element"></param>
        /// <returns></returns>
        private List <Expression> ToExpressions(FhirDateTime element)
        {
            if (element == null)
            {
                return(null);
            }

            var bounds = new List <IndexValue>();

            bounds.Add(new IndexValue("start", new DateTimeValue(element.LowerBound())));
            bounds.Add(new IndexValue("end", new DateTimeValue(element.UpperBound())));

            return(ListOf(new CompositeValue(bounds)));
        }
Example #3
0
        public static DateTimeOffset UpperBound(this FhirDateTime fdt)
        {
            var dtoStart = fdt.LowerBound();
            var dtoEnd   = fdt.Precision() switch
            {
                FhirDateTimePrecision.Year => dtoStart.AddYears(1),
                FhirDateTimePrecision.Month => dtoStart.AddMonths(1),
                FhirDateTimePrecision.Day => dtoStart.AddDays(1),
                FhirDateTimePrecision.Minute => dtoStart.AddMinutes(1),
                FhirDateTimePrecision.Second => dtoStart.AddSeconds(1),
                _ => dtoStart
            };

            return(dtoEnd);
        }
    }
        public static DateTimeOffset UpperBound(this FhirDateTime fdt)
        {
            var dtoStart = fdt.LowerBound();
            var dtoEnd   = dtoStart;

            switch (fdt.Precision())
            {
            case FhirDateTimePrecision.Year: dtoEnd = dtoStart.AddYears(1); break;

            case FhirDateTimePrecision.Month: dtoEnd = dtoStart.AddMonths(1); break;

            case FhirDateTimePrecision.Day: dtoEnd = dtoStart.AddDays(1); break;

            case FhirDateTimePrecision.Minute: dtoEnd = dtoStart.AddMinutes(1); break;

            case FhirDateTimePrecision.Second: dtoEnd = dtoStart.AddSeconds(1); break;

            default: dtoEnd = dtoStart; break;
            }

            return(dtoEnd);
        }