private static int?GetDaysFromDuration(Hl7.Fhir.Model.Duration duration)
        {
            if (duration == null)
            {
                return(null);
            }

            if (duration.Value.HasValue)
            {
                switch (duration.Code)
                {
                case "day":
                    return(decimal.ToInt32(duration.Value.Value));

                case "week":
                case "month":
                case "year":
                    double value            = decimal.ToDouble(duration.Value.Value);
                    var    fromUnit         = UnitsNet.Duration.ParseUnit(duration.Code);
                    var    unitsNetDuration = UnitsNet.Duration.From(value, fromUnit);
                    return(Convert.ToInt32(unitsNetDuration.Days));
                }
            }
            return(null);
        }
 /// <summary>
 /// Parse Duration
 /// </summary>
 public static Hl7.Fhir.Model.Duration ParseDuration(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Duration existingInstance = null)
 {
     Hl7.Fhir.Model.Duration result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Duration();
     QuantityParser.ParseQuantity(reader, errors, result);
     return(result);
 }