/// <summary>
        /// Populates this <see cref="DailyMedicationUsage"/> instance from the
        /// data in the XML.
        /// </summary>
        ///
        /// <param name="typeSpecificXml">
        /// The XML to get the medication usage data from.
        /// </param>
        ///
        /// <exception cref="InvalidOperationException">
        /// The first node in <paramref name="typeSpecificXml"/> is not
        /// a <see cref="DailyMedicationUsage"/> node.
        /// </exception>
        ///
        protected override void ParseXml(IXPathNavigable typeSpecificXml)
        {
            XPathNavigator itemNav =
                typeSpecificXml.CreateNavigator().SelectSingleNode(
                    "daily-medication-usage");

            Validator.ThrowInvalidIfNull(itemNav, Resources.DailyMedicationUsageUnexpectedNode);

            _when = new HealthServiceDate();
            _when.ParseXml(itemNav.SelectSingleNode("when"));

            _drugName = new CodableValue();
            _drugName.ParseXml(itemNav.SelectSingleNode("drug-name"));

            _dosesConsumed =
                itemNav.SelectSingleNode("number-doses-consumed-in-day").ValueAsInt;

            _purposeOfUse =
                XPathHelper.GetOptNavValue <CodableValue>(itemNav, "purpose-of-use");

            _intendedDoses =
                XPathHelper.GetOptNavValueAsInt(itemNav, "number-doses-intended-in-day");

            _usageSchedule =
                XPathHelper.GetOptNavValue <CodableValue>(itemNav, "medication-usage-schedule");

            _drugForm =
                XPathHelper.GetOptNavValue <CodableValue>(itemNav, "drug-form");

            _prescriptionType =
                XPathHelper.GetOptNavValue <CodableValue>(itemNav, "prescription-type");

            _singleDoseDescription =
                XPathHelper.GetOptNavValue <CodableValue>(itemNav, "single-dose-description");
        }
        /// <summary>
        /// Populates the data for the date and time from the XML.
        /// </summary>
        ///
        /// <param name="navigator">
        /// The XML node representing the date and time.
        /// </param>
        ///
        public override void ParseXml(XPathNavigator navigator)
        {
            Validator.ThrowIfNavigatorNull(navigator);

            _date = new HealthServiceDate();
            _date.ParseXml(navigator.SelectSingleNode("date"));

            XPathNavigator timeNav = navigator.SelectSingleNode("time");

            if (timeNav != null)
            {
                _time = new ApproximateTime();
                _time.ParseXml(timeNav);
            }
            else
            {
                _time = null;
            }

            XPathNavigator tzNav =
                navigator.SelectSingleNode("tz");

            if (tzNav != null)
            {
                _timeZone = new CodableValue();
                _timeZone.ParseXml(tzNav);
            }
        }
 /// <summary>
 /// Creates a new instance of the <see cref="HealthServiceDateTime"/>
 /// class with the specified date, time, and time zone.
 /// </summary>
 ///
 /// <param name="date">
 /// The date.
 /// </param>
 ///
 /// <param name="time">
 /// The approximate time.
 /// </param>
 ///
 /// <param name="timeZone">
 /// The optional time zone for the <paramref name="time"/>.
 /// </param>
 ///
 /// <exception cref="ArgumentNullException">
 /// The <paramref name="date"/> parameter is <b>null</b>.
 /// </exception>
 ///
 public HealthServiceDateTime(
     HealthServiceDate date,
     ApproximateTime time,
     CodableValue timeZone)
 {
     Date     = date;
     Time     = time;
     TimeZone = timeZone;
 }
        /// <summary>
        /// Creates a new instance of the <see cref="HealthServiceDateTime"/> class
        /// with the date set to the current date and the time not set.
        /// </summary>
        ///
        public HealthServiceDateTime()
        {
            DateTime now = DateTime.Now;

            _date =
                new HealthServiceDate(
                    now.Year,
                    now.Month,
                    now.Day);
        }
 /// <summary>
 /// Creates a new instance of the <see cref="DailyMedicationUsage"/> class
 /// specifying the mandatory values.
 /// </summary>
 ///
 /// <param name="when">
 /// The date when the medication/supplement was consumed.
 /// </param>
 ///
 /// <param name="drugName">
 /// The name of the drug.
 /// </param>
 ///
 /// <param name="dosesConsumed">
 /// The number of doses consumed by the person.
 /// </param>
 ///
 /// <exception cref="ArgumentNullException">
 /// The <paramref name="when"/> or <paramref name="drugName"/> parameter is <b>null</b>.
 /// </exception>
 ///
 public DailyMedicationUsage(
     HealthServiceDate when,
     CodableValue drugName,
     int dosesConsumed)
     : base(TypeId)
 {
     When          = when;
     DrugName      = drugName;
     DosesConsumed = dosesConsumed;
 }
        /// <summary>
        /// Creates a new instance of the <see cref="HealthServiceDateTime"/>
        /// class from the specified <see cref="LocalDateTime" /> instance.
        /// </summary>
        /// <param name="dateTime">
        /// The date and time used to construct the HealthVault date and time.
        /// </param>
        public HealthServiceDateTime(LocalDateTime dateTime)
        {
            _date =
                new HealthServiceDate(
                    dateTime.Year,
                    dateTime.Month,
                    dateTime.Day);

            _time =
                new ApproximateTime(
                    dateTime.Hour,
                    dateTime.Minute,
                    dateTime.Second,
                    dateTime.Millisecond);
        }
예제 #7
0
        /// <summary>
        /// Populates this <see cref="CholesterolProfile"/> instance from the data in the XML.
        /// </summary>
        ///
        /// <param name="typeSpecificXml">
        /// The XML to get the cholesterol profile data from.
        /// </param>
        ///
        /// <exception cref="InvalidOperationException">
        /// The first node in <paramref name="typeSpecificXml"/> is not
        /// a cholesterol-profile node.
        /// </exception>
        ///
        protected override void ParseXml(IXPathNavigable typeSpecificXml)
        {
            XPathNavigator itemNav =
                typeSpecificXml.CreateNavigator().SelectSingleNode(
                    "cholesterol-profile");

            Validator.ThrowInvalidIfNull(itemNav, Resources.CholesterolProfileUnexpectedNode);

            _when = new HealthServiceDate();
            _when.ParseXml(itemNav.SelectSingleNode("when"));

            _ldl = XPathHelper.GetOptNavValueAsInt(itemNav, "ldl");

            _hdl = XPathHelper.GetOptNavValueAsInt(itemNav, "hdl");

            _totalCholesterol = XPathHelper.GetOptNavValueAsInt(itemNav, "total-cholesterol");

            _triglyceride = XPathHelper.GetOptNavValueAsInt(itemNav, "triglyceride");
        }
 /// <summary>
 /// Creates a new instance of the <see cref="HealthServiceDateTime"/>
 /// class with the specified date and time.
 /// </summary>
 ///
 /// <param name="date">
 /// The date.
 /// </param>
 ///
 /// <param name="time">
 /// The approximate time.
 /// </param>
 ///
 /// <exception cref="ArgumentNullException">
 /// The <paramref name="date"/> parameter is <b>null</b>.
 /// </exception>
 ///
 public HealthServiceDateTime(HealthServiceDate date, ApproximateTime time)
 {
     Date = date;
     Time = time;
 }
 /// <summary>
 /// Creates a new instance of the <see cref="HealthServiceDateTime"/> class
 /// with the specified date.
 /// </summary>
 ///
 /// <param name="date">
 /// The date.
 /// </param>
 ///
 /// <exception cref="ArgumentNullException">
 /// The <paramref name="date"/> parameter is <b>null</b>.
 /// </exception>
 ///
 public HealthServiceDateTime(HealthServiceDate date)
 {
     Date = date;
     Time = null;
 }
예제 #10
0
 /// <summary>
 /// Creates a new instance of the <see cref="CholesterolProfile"/> class
 /// with the specified date.
 /// </summary>
 ///
 /// <param name="when">
 /// The date when the cholesterol profile was take.
 /// </param>
 ///
 /// <exception cref="ArgumentNullException">
 /// The <paramref name="when"/> parameter is <b>null</b>.
 /// </exception>
 ///
 public CholesterolProfile(HealthServiceDate when)
     : base(TypeId)
 {
     When = when;
 }
        /// <summary>
        /// Populates this <see cref="DietaryDailyIntake"/> instance from the
        /// data in the XML.
        /// </summary>
        ///
        /// <param name="typeSpecificXml">
        /// The XML to get the dietary intake data from.
        /// </param>
        ///
        /// <exception cref="InvalidOperationException">
        /// The first node in <paramref name="typeSpecificXml"/> is not
        /// a <see cref="DietaryDailyIntake"/> node.
        /// </exception>
        ///
        protected override void ParseXml(IXPathNavigable typeSpecificXml)
        {
            XPathNavigator intakeNav =
                typeSpecificXml.CreateNavigator().SelectSingleNode(
                    "dietary-intake-daily");

            Validator.ThrowInvalidIfNull(intakeNav, Resources.DietaryDailyIntakeUnexpectedNode);

            _when = new HealthServiceDate();
            _when.ParseXml(intakeNav.SelectSingleNode("when"));

            XPathNavigator caloriesNav =
                intakeNav.SelectSingleNode("calories");

            if (caloriesNav != null)
            {
                _calories = caloriesNav.ValueAsInt;
            }

            XPathNavigator totalFatNav =
                intakeNav.SelectSingleNode("total-fat");

            if (totalFatNav != null)
            {
                _totalFat = new WeightValue();
                _totalFat.ParseXml(totalFatNav);
            }

            XPathNavigator satFatNav =
                intakeNav.SelectSingleNode("saturated-fat");

            if (satFatNav != null)
            {
                _saturatedFat = new WeightValue();
                _saturatedFat.ParseXml(satFatNav);
            }

            XPathNavigator transFatNav =
                intakeNav.SelectSingleNode("trans-fat");

            if (transFatNav != null)
            {
                _transFat = new WeightValue();
                _transFat.ParseXml(transFatNav);
            }

            XPathNavigator proteinNav =
                intakeNav.SelectSingleNode("protein");

            if (proteinNav != null)
            {
                _protein = new WeightValue();
                _protein.ParseXml(proteinNav);
            }

            XPathNavigator totalCarbsNav =
                intakeNav.SelectSingleNode("total-carbohydrates");

            if (totalCarbsNav != null)
            {
                _totalCarbs = new WeightValue();
                _totalCarbs.ParseXml(totalCarbsNav);
            }

            XPathNavigator fiberNav =
                intakeNav.SelectSingleNode("dietary-fiber");

            if (fiberNav != null)
            {
                _fiber = new WeightValue();
                _fiber.ParseXml(fiberNav);
            }

            XPathNavigator sugarsNav =
                intakeNav.SelectSingleNode("sugars");

            if (sugarsNav != null)
            {
                _sugars = new WeightValue();
                _sugars.ParseXml(sugarsNav);
            }

            XPathNavigator sodiumNav =
                intakeNav.SelectSingleNode("sodium");

            if (sodiumNav != null)
            {
                _sodium = new WeightValue();
                _sodium.ParseXml(sodiumNav);
            }

            XPathNavigator cholesterolNav =
                intakeNav.SelectSingleNode("cholesterol");

            if (cholesterolNav != null)
            {
                _cholesterol = new WeightValue();
                _cholesterol.ParseXml(cholesterolNav);
            }
        }
 /// <summary>
 /// Creates a new instance of the <see cref="DietaryDailyIntake"/> class
 /// specifying the mandatory values.
 /// </summary>
 ///
 /// <param name="when">
 /// The date when the food was consumed.
 /// </param>
 ///
 /// <exception cref="ArgumentNullException">
 /// The <paramref name="when"/> parameter is <b>null</b>.
 /// </exception>
 ///
 public DietaryDailyIntake(HealthServiceDate when)
     : base(TypeId)
 {
     When = when;
 }