/// <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> /// 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 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> /// 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); } }