/// <summary> /// Creates a new instance of the <see cref="TargetGlucoseZone"/> class /// with the specified absolute glucose value boundaries and name. /// </summary> /// /// <param name="name"> /// The name of the zone. /// </param> /// /// <param name="lowerBoundaryAbsoluteGlucose"> /// The glucose value in millimoles per liter (mmol/L) for the lower /// boundary of the zone. /// </param> /// /// <param name="upperBoundaryAbsoluteGlucose"> /// The glucose value in millimoles per liter (mmol/L) for the upper /// boundary of the zone. /// </param> /// public TargetGlucoseZone( string name, BloodGlucoseMeasurement lowerBoundaryAbsoluteGlucose, BloodGlucoseMeasurement upperBoundaryAbsoluteGlucose) { _name = name; _lowAbsolute = lowerBoundaryAbsoluteGlucose; _upperAbsolute = upperBoundaryAbsoluteGlucose; }
/// <summary> /// Populates the data from the specified XML. /// </summary> /// /// <param name="navigator"> /// The XML containing the glucose zone information. /// </param> /// /// <exception cref="ArgumentNullException"> /// The <paramref name="navigator"/> parameter is null. /// </exception> /// public override void ParseXml(XPathNavigator navigator) { Validator.ThrowIfNavigatorNull(navigator); string name = navigator.GetAttribute("name", string.Empty); if (name.Length != 0) { _name = name; } XPathNavigator lowNav = navigator.SelectSingleNode("lower-bound"); if (lowNav != null) { XPathNavigator absoluteNav = lowNav.SelectSingleNode("absolute-glucose"); if (absoluteNav != null) { _lowAbsolute = new BloodGlucoseMeasurement(); _lowAbsolute.ParseXml(absoluteNav); } else { XPathNavigator relativeNav = lowNav.SelectSingleNode("percent-max-glucose"); if (relativeNav != null) { _lowRelative = relativeNav.ValueAsDouble; } } } XPathNavigator upperNav = navigator.SelectSingleNode("upper-bound"); if (upperNav != null) { XPathNavigator absoluteNav = upperNav.SelectSingleNode("absolute-glucose"); if (absoluteNav != null) { _upperAbsolute = new BloodGlucoseMeasurement(); _upperAbsolute.ParseXml(absoluteNav); } else { XPathNavigator relativeNav = upperNav.SelectSingleNode("percent-max-glucose"); if (relativeNav != null) { _upperRelative = relativeNav.ValueAsDouble; } } } }
/// <summary> /// Constructs the new blood glucose thing instance /// specifying the mandatory values. /// </summary> /// /// <param name="when"> /// The date/time when the blood glucose reading was take. /// </param> /// /// <param name="value"> /// The blood glucose value of the reading. /// </param> /// /// <param name="glucoseMeasurementType"> /// How the glucose was measured; whole blood, plasma, etc. /// </param> /// /// <exception cref="ArgumentNullException"> /// The <paramref name="when"/> parameter is <b>null</b>. /// </exception> /// public BloodGlucose( HealthServiceDateTime when, BloodGlucoseMeasurement value, CodableValue glucoseMeasurementType) : base(TypeId) { When = when; Value = value; GlucoseMeasurementType = glucoseMeasurementType; }
/// <summary> /// Populates this BloodGlucose instance from the data in the XML. /// </summary> /// /// <param name="typeSpecificXml"> /// The XML to get the blood glucose data from. /// </param> /// /// <exception cref="InvalidOperationException"> /// The first node in <paramref name="typeSpecificXml"/> is not /// a blood-glucose node. /// </exception> /// protected override void ParseXml(IXPathNavigable typeSpecificXml) { XPathNavigator bgNav = typeSpecificXml.CreateNavigator().SelectSingleNode( "blood-glucose"); Validator.ThrowInvalidIfNull(bgNav, Resources.BGUnexpectedNode); _when = new HealthServiceDateTime(); _when.ParseXml(bgNav.SelectSingleNode("when")); _value = new BloodGlucoseMeasurement(); _value.ParseXml(bgNav.SelectSingleNode("value")); _glucoseMeasurementType = new CodableValue(); _glucoseMeasurementType.ParseXml( bgNav.SelectSingleNode("glucose-measurement-type")); _outsideOperatingTemp = XPathHelper.GetOptNavValueAsBool( bgNav, "outside-operating-temp"); _isControlTest = XPathHelper.GetOptNavValueAsBool( bgNav, "is-control-test"); XPathNavigator normalcyNav = bgNav.SelectSingleNode("normalcy"); if (normalcyNav != null) { _normalcyValue = normalcyNav.ValueAsInt; if (_normalcyValue < (int)Normalcy.WellBelowNormal || _normalcyValue > (int)Normalcy.WellAboveNormal) { _normalcy = Normalcy.Unknown; } else { _normalcy = (Normalcy)_normalcyValue; } } _measurementContext = XPathHelper.GetOptNavValue <CodableValue>( bgNav, "measurement-context"); }