Ejemplo n.º 1
0
        /// <summary>
        /// Populates this <see cref="Emotion"/> instance from the data in the XML.
        /// </summary>
        ///
        /// <param name="typeSpecificXml">
        /// The XML to get the emotion data from.
        /// </param>
        ///
        /// <exception cref="InvalidOperationException">
        /// The first node in <paramref name="typeSpecificXml"/> is not
        /// a emotion node.
        /// </exception>
        ///
        protected override void ParseXml(IXPathNavigable typeSpecificXml)
        {
            XPathNavigator emotionNav =
                typeSpecificXml.CreateNavigator().SelectSingleNode("emotion");

            Validator.ThrowInvalidIfNull(emotionNav, Resources.EmotionUnexpectedNode);

            _when = new HealthServiceDateTime();
            _when.ParseXml(emotionNav.SelectSingleNode("when"));

            XPathNavigator moodNav =
                emotionNav.SelectSingleNode("mood");

            if (moodNav != null)
            {
                _mood = (Mood)moodNav.ValueAsInt;
            }

            XPathNavigator stressNav =
                emotionNav.SelectSingleNode("stress");

            if (stressNav != null)
            {
                _stress = (RelativeRating)stressNav.ValueAsInt;
            }

            XPathNavigator wellbeingNav =
                emotionNav.SelectSingleNode("wellbeing");

            if (wellbeingNav != null)
            {
                _wellbeing = (Wellbeing)wellbeingNav.ValueAsInt;
            }
        }
        /// <summary>
        /// Populates this health assessment instance from the data in the XML.
        /// </summary>
        ///
        /// <param name="typeSpecificXml">
        /// The XML to get the health assessment data from.
        /// </param>
        ///
        /// <exception cref="InvalidOperationException">
        /// If the first node in <paramref name="typeSpecificXml"/> is not
        /// a health-assessment node.
        /// </exception>
        ///
        protected override void ParseXml(IXPathNavigable typeSpecificXml)
        {
            XPathNavigator itemNav =
                typeSpecificXml.CreateNavigator().SelectSingleNode("health-assessment");

            Validator.ThrowInvalidIfNull(itemNav, Resources.HealthAssessmentUnexpectedNode);

            // <when>
            _when = new HealthServiceDateTime();
            _when.ParseXml(itemNav.SelectSingleNode("when"));

            // <name>
            _name = itemNav.SelectSingleNode("name").Value;

            // <category>
            _category = new CodableValue();
            _category.ParseXml(itemNav.SelectSingleNode("category"));

            // <result>
            _result.Clear();
            XPathNodeIterator resultIterator = itemNav.Select("result");

            foreach (XPathNavigator resultNav in resultIterator)
            {
                Assessment result = new Assessment();
                result.ParseXml(resultNav);
                _result.Add(result);
            }
        }
        /// <summary>
        /// Populates this <see cref="HeartRate"/> instance from the data in the XML.
        /// </summary>
        ///
        /// <param name="typeSpecificXml">
        /// The XML to get the heart rate data from.
        /// </param>
        ///
        /// <exception cref="InvalidOperationException">
        /// If the first node in <paramref name="typeSpecificXml"/> is not
        /// a "heart-rate" node.
        /// </exception>
        ///
        protected override void ParseXml(IXPathNavigable typeSpecificXml)
        {
            XPathNavigator itemNav =
                typeSpecificXml.CreateNavigator().SelectSingleNode("heart-rate");

            Validator.ThrowInvalidIfNull(itemNav, Resources.HeartRateUnexpectedNode);

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

            // value
            _value = itemNav.SelectSingleNode("value").ValueAsInt;

            // measurement-method
            _measurementMethod =
                XPathHelper.GetOptNavValue <CodableValue>(itemNav, "measurement-method");

            // measurement-condition
            _measurementConditions =
                XPathHelper.GetOptNavValue <CodableValue>(itemNav, "measurement-conditions");

            // measurement-flags
            _measurementFlags =
                XPathHelper.GetOptNavValue <CodableValue>(itemNav, "measurement-flags");
        }
        /// <summary>
        /// Populates this <see cref="InsulinInjectionUse"/> instance from the
        /// data in the XML.
        /// </summary>
        ///
        /// <param name="typeSpecificXml">
        /// The XML to get the insulin injection use data from.
        /// </param>
        ///
        /// <exception cref="InvalidOperationException">
        /// The first node in <paramref name="typeSpecificXml"/> is not
        /// an insulin-injection-use node.
        /// </exception>
        ///
        protected override void ParseXml(IXPathNavigable typeSpecificXml)
        {
            XPathNavigator itemNav =
                typeSpecificXml.CreateNavigator().SelectSingleNode(
                    "diabetes-insulin-injection-use");

            Validator.ThrowInvalidIfNull(itemNav, Resources.InsulinInjectionUseUnexpectedNode);

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

            _insulinType = new CodableValue();
            _insulinType.ParseXml(itemNav.SelectSingleNode("type"));

            _amount = new InsulinInjectionMeasurement();
            _amount.ParseXml(itemNav.SelectSingleNode("amount"));

            XPathNavigator deviceIdNav =
                itemNav.SelectSingleNode("device-id");

            if (deviceIdNav != null)
            {
                _deviceId = deviceIdNav.Value;
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Populates this <see cref="RespiratoryProfile"/> instance from the data in the XML.
        /// </summary>
        ///
        /// <param name="typeSpecificXml">
        /// The XML to get the respiratory profile data from.
        /// </param>
        ///
        /// <exception cref="InvalidOperationException">
        /// The first node in <paramref name="typeSpecificXml"/> is not
        /// a respiratory-profile node.
        /// </exception>
        ///
        protected override void ParseXml(IXPathNavigable typeSpecificXml)
        {
            XPathNavigator itemNav =
                typeSpecificXml.CreateNavigator().SelectSingleNode(
                    "respiratory-profile");

            Validator.ThrowInvalidIfNull(itemNav, Resources.RespiratoryProfileUnexpectedNode);

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

            _expiratoryFlowRedZoneUpperBoundary =
                XPathHelper.GetOptNavValue <FlowMeasurement>(
                    itemNav,
                    "expiratory-flow-red-zone-upper-boundary");

            _expiratoryFlowOrangeZoneUpperBoundary =
                XPathHelper.GetOptNavValue <FlowMeasurement>(
                    itemNav,
                    "expiratory-flow-orange-zone-upper-boundary");

            _expiratoryFlowYellowZoneUpperBoundary =
                XPathHelper.GetOptNavValue <FlowMeasurement>(
                    itemNav,
                    "expiratory-flow-yellow-zone-upper-boundary");
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Populates this medical device instance from the data in the XML.
        /// </summary>
        ///
        /// <param name="typeSpecificXml">
        /// The XML to get the medical device data from.
        /// </param>
        ///
        /// <exception cref="InvalidOperationException">
        /// The first node in <paramref name="typeSpecificXml"/> is not
        /// a medical device node.
        /// </exception>
        ///
        protected override void ParseXml(IXPathNavigable typeSpecificXml)
        {
            XPathNavigator itemNav =
                typeSpecificXml.CreateNavigator().SelectSingleNode("device");

            Validator.ThrowInvalidIfNull(itemNav, Resources.DeviceUnexpectedNode);

            // <when>
            _when = new HealthServiceDateTime();
            _when.ParseXml(itemNav.SelectSingleNode("when"));

            // <device-name>
            _deviceName = XPathHelper.GetOptNavValue(itemNav, "device-name");

            // <vendor>
            _vendor = XPathHelper.GetOptNavValue <PersonItem>(itemNav, "vendor");

            // <model>
            _model = XPathHelper.GetOptNavValue(itemNav, "model");

            // <serial-number>
            _serialNumber =
                XPathHelper.GetOptNavValue(itemNav, "serial-number");

            // <anatomic-site>
            _anatomicSite =
                XPathHelper.GetOptNavValue(itemNav, "anatomic-site");

            // <description>
            _description =
                XPathHelper.GetOptNavValue(itemNav, "description");
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Populates this <see cref="PapSession"/> instance from the data in the specified XML.
        /// </summary>
        ///
        /// <param name="typeSpecificXml">
        /// The XML to get the PAP session data from.
        /// </param>
        ///
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="typeSpecificXml"/> parameter is <b>null</b>.
        /// </exception>
        ///
        /// <exception cref="InvalidOperationException">
        /// If the first node in <paramref name="typeSpecificXml"/> is not
        /// a PAP session node.
        /// </exception>
        ///
        protected override void ParseXml(IXPathNavigable typeSpecificXml)
        {
            Validator.ThrowIfArgumentNull(typeSpecificXml, nameof(typeSpecificXml), Resources.ParseXmlNavNull);

            XPathNavigator itemNav =
                typeSpecificXml.CreateNavigator().SelectSingleNode("pap-session");

            Validator.ThrowInvalidIfNull(itemNav, Resources.PapSessionUnexpectedNode);

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

            _durationMinutes    = itemNav.SelectSingleNode("duration-minutes").ValueAsDouble;
            _apneaHypopneaIndex = itemNav.SelectSingleNode("apnea-hypopnea-index").ValueAsDouble;

            _apneaIndex              = XPathHelper.GetOptNavValueAsDouble(itemNav, "apnea-index");
            _hypopneaIndex           = XPathHelper.GetOptNavValueAsDouble(itemNav, "hypopnea-index");
            _oxygenDesaturationIndex = XPathHelper.GetOptNavValueAsDouble(itemNav, "oxygen-desaturation-index");

            _pressure          = XPathHelper.GetOptNavValue <PapSessionMeasurements <PressureMeasurement> >(itemNav, "pressure");
            _leakRate          = XPathHelper.GetOptNavValue <PapSessionMeasurements <FlowMeasurement> >(itemNav, "leak-rate");
            _tidalVolume       = XPathHelper.GetOptNavValue <PapSessionMeasurements <VolumeMeasurement> >(itemNav, "tidal-volume");
            _minuteVentilation = XPathHelper.GetOptNavValue <PapSessionMeasurements <VolumeMeasurement> >(itemNav, "minute-ventilation");
            _respiratoryRate   = XPathHelper.GetOptNavValue <PapSessionMeasurements <RespiratoryRateMeasurement> >(itemNav, "respiratory-rate");
        }
        /// <summary>
        /// Populates this <see cref="Annotation"/> instance from the data in the XML.
        /// </summary>
        ///
        /// <param name="typeSpecificXml">
        /// The XML to get the annotation data from.
        /// </param>
        ///
        /// <exception cref="InvalidOperationException">
        /// The first node in <paramref name="typeSpecificXml"/> is not
        /// an annotation node.
        /// </exception>
        ///
        protected override void ParseXml(IXPathNavigable typeSpecificXml)
        {
            XPathNavigator itemNav =
                typeSpecificXml.CreateNavigator().SelectSingleNode("annotation");

            Validator.ThrowInvalidIfNull(itemNav, Resources.AnnotationUnexpectedNode);

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

            _content =
                XPathHelper.GetOptNavValue(itemNav, "content");

            _author =
                XPathHelper.GetOptNavValue <PersonItem>(itemNav, "author");

            _classification =
                XPathHelper.GetOptNavValue(itemNav, "classification");

            _index =
                XPathHelper.GetOptNavValue(itemNav, "index");

            _version =
                XPathHelper.GetOptNavValue(itemNav, "version");
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Populates this <see cref="AllergicEpisode"/> instance from the data in the XML.
        /// </summary>
        ///
        /// <param name="typeSpecificXml">
        /// The XML to get the allergic episode data from.
        /// </param>
        ///
        /// <exception cref="InvalidOperationException">
        /// The first node in <paramref name="typeSpecificXml"/> is not
        /// an allergic-episode node.
        /// </exception>
        ///
        protected override void ParseXml(IXPathNavigable typeSpecificXml)
        {
            _name.Clear();
            XPathNavigator allergyNav =
                typeSpecificXml.CreateNavigator().SelectSingleNode("allergic-episode");

            Validator.ThrowInvalidIfNull(allergyNav, Resources.AllergicEpisodeUnexpectedNode);

            _when = new HealthServiceDateTime();
            _when.ParseXml(allergyNav.SelectSingleNode("when"));
            _name.ParseXml(allergyNav.SelectSingleNode("name"));

            XPathNavigator reactionNav =
                allergyNav.SelectSingleNode("reaction");

            if (reactionNav != null)
            {
                _reaction = new CodableValue();
                _reaction.ParseXml(reactionNav);
            }

            XPathNavigator treatmentNav =
                allergyNav.SelectSingleNode("treatment");

            if (treatmentNav != null)
            {
                _treatment = new CodableValue();
                _treatment.ParseXml(treatmentNav);
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Populates this <see cref="CardiacProfile"/> instance from the data in the XML.
        /// </summary>
        ///
        /// <param name="typeSpecificXml">
        /// The XML to get the cardiac profile data from.
        /// </param>
        ///
        /// <exception cref="InvalidOperationException">
        /// The first node in <paramref name="typeSpecificXml"/> is not
        /// a cardiac-profile node.
        /// </exception>
        ///
        protected override void ParseXml(IXPathNavigable typeSpecificXml)
        {
            XPathNavigator itemNav =
                typeSpecificXml.CreateNavigator().SelectSingleNode(
                    "cardiac-profile");

            Validator.ThrowInvalidIfNull(itemNav, Resources.CardiacProfileUnexpectedNode);

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

            _onHypertensionDiet =
                XPathHelper.GetOptNavValueAsBool(itemNav, "on-hypertension-diet");

            _onHypertensionMedication =
                XPathHelper.GetOptNavValueAsBool(itemNav, "on-hypertension-medication");

            _renalFailureDiagnosed =
                XPathHelper.GetOptNavValueAsBool(itemNav, "renal-failure-diagnosed");

            _diabetesDiagnosed =
                XPathHelper.GetOptNavValueAsBool(itemNav, "diabetes-diagnosed");

            _hasFamilyHeartDiseaseHistory =
                XPathHelper.GetOptNavValueAsBool(itemNav, "has-family-heart-disease-history");

            _hasFamilyStrokeHistory =
                XPathHelper.GetOptNavValueAsBool(itemNav, "has-family-stroke-history");

            _hasPersonalHeartDiseaseHistory =
                XPathHelper.GetOptNavValueAsBool(itemNav, "has-personal-heart-disease-history");

            _hasPersonalStrokeHistory =
                XPathHelper.GetOptNavValueAsBool(itemNav, "has-person-stroke-history");
        }
        /// <summary>
        /// Populates this <see cref="DiabeticProfile"/> instance from the data in the XML.
        /// </summary>
        ///
        /// <param name="typeSpecificXml">
        /// The XML to get the diabetic profile data from.
        /// </param>
        ///
        /// <exception cref="InvalidOperationException">
        /// The first node in <paramref name="typeSpecificXml"/> is not
        /// a diabetic-profile node.
        /// </exception>
        ///
        protected override void ParseXml(IXPathNavigable typeSpecificXml)
        {
            XPathNavigator itemNav =
                typeSpecificXml.CreateNavigator().SelectSingleNode(
                    "diabetic-profile");

            Validator.ThrowInvalidIfNull(itemNav, Resources.DiabeticProfileUnexpectedNode);

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

            XPathNavigator maxHbA1CNav =
                itemNav.SelectSingleNode("max-HbA1C");

            if (maxHbA1CNav != null)
            {
                _maxHbA1C = maxHbA1CNav.ValueAsDouble;
            }

            XPathNodeIterator zoneGroupIterator =
                itemNav.Select("target-glucose-zone-group");

            foreach (XPathNavigator groupNav in zoneGroupIterator)
            {
                TargetGlucoseZoneGroup zoneGroup = new TargetGlucoseZoneGroup();
                zoneGroup.ParseXml(groupNav);
                _zoneGroups.Add(zoneGroup);
            }
        }
        /// <summary>
        /// Populates this <see cref="BloodPressure"/> instance from the data in the XML.
        /// </summary>
        ///
        /// <param name="typeSpecificXml">
        /// The XML to get the blood pressure data from.
        /// </param>
        ///
        /// <exception cref="InvalidOperationException">
        /// The first node in <paramref name="typeSpecificXml"/> is not
        /// a bp node.
        /// </exception>
        ///
        protected override void ParseXml(IXPathNavigable typeSpecificXml)
        {
            XPathNavigator bpNav =
                typeSpecificXml.CreateNavigator().SelectSingleNode(
                    "blood-pressure");

            Validator.ThrowInvalidIfNull(bpNav, Resources.BPUnexpectedNode);

            _when = new HealthServiceDateTime();
            _when.ParseXml(bpNav.SelectSingleNode("when"));

            _systolic  = bpNav.SelectSingleNode("systolic").ValueAsInt;
            _diastolic = bpNav.SelectSingleNode("diastolic").ValueAsInt;

            XPathNavigator pulseNav = bpNav.SelectSingleNode("pulse");

            if (pulseNav != null)
            {
                _pulse = pulseNav.ValueAsInt;
            }

            XPathNavigator irregularHeartbeatNav =
                bpNav.SelectSingleNode("irregular-heartbeat");

            if (irregularHeartbeatNav != null)
            {
                _irregularHeartbeatDetected =
                    irregularHeartbeatNav.ValueAsBoolean;
            }
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Populates this vital signs instance from the data in the XML.
        /// </summary>
        ///
        /// <param name="typeSpecificXml">
        /// The XML to get the vital signs data from.
        /// </param>
        ///
        /// <exception cref="InvalidOperationException">
        /// The first node in <paramref name="typeSpecificXml"/> is not
        /// a vital signs node.
        /// </exception>
        ///
        protected override void ParseXml(IXPathNavigable typeSpecificXml)
        {
            XPathNavigator itemNav =
                typeSpecificXml.CreateNavigator().SelectSingleNode("vital-signs");

            Validator.ThrowInvalidIfNull(itemNav, Resources.VitalSignsUnexpectedNode);

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

            XPathNodeIterator vitalSignsResultsIterator =
                itemNav.Select("vital-signs-results");

            foreach (XPathNavigator vitalSignsResultsNav in vitalSignsResultsIterator)
            {
                VitalSignsResultType vitalSignResult = new VitalSignsResultType();
                vitalSignResult.ParseXml(vitalSignsResultsNav);
                _vitalSignsResults.Add(vitalSignResult);
            }

            // <site>
            _site =
                XPathHelper.GetOptNavValue(itemNav, "site");

            // <position>
            _position =
                XPathHelper.GetOptNavValue(itemNav, "position");
        }
        /// <summary>
        /// Populates the data for the lab test type from the XML.
        /// </summary>
        ///
        /// <param name="navigator">
        /// The XML node representing the lab test type.
        /// </param>
        ///
        /// <exception cref="ArgumentNullException">
        /// The <paramref name="navigator"/> parameter is <b>null</b>.
        /// </exception>
        ///
        public override void ParseXml(XPathNavigator navigator)
        {
            Validator.ThrowIfNavigatorNull(navigator);

            _when = new HealthServiceDateTime();
            _when.ParseXml(navigator.SelectSingleNode("when"));

            _name      = XPathHelper.GetOptNavValue(navigator, "name");
            _substance = XPathHelper.GetOptNavValue <CodableValue>(navigator, "substance");

            _collectionMethod =
                XPathHelper.GetOptNavValue <CodableValue>(
                    navigator,
                    "collection-method");

            _abbreviation = XPathHelper.GetOptNavValue(navigator, "abbreviation");
            _description  = XPathHelper.GetOptNavValue(navigator, "description");

            _code.Clear();
            XPathNodeIterator codeIterator = navigator.Select("code");

            foreach (XPathNavigator codeNav in codeIterator)
            {
                CodableValue codeValue = new CodableValue();
                codeValue.ParseXml(codeNav);
                _code.Add(codeValue);
            }

            _result = XPathHelper.GetOptNavValue <LabResultType>(navigator, "result");
            _status = XPathHelper.GetOptNavValue <CodableValue>(navigator, "status");
        }
        /// <summary>
        /// Populates this <see cref="Weight"/> instance from the data in the XML.
        /// </summary>
        ///
        /// <param name="typeSpecificXml">
        /// The XML to get the weight data from.
        /// </param>
        ///
        /// <exception cref="InvalidOperationException">
        /// The first node in <paramref name="typeSpecificXml"/> is not
        /// a weight node.
        /// </exception>
        ///
        protected override void ParseXml(IXPathNavigable typeSpecificXml)
        {
            XPathNavigator weightNav =
                typeSpecificXml.CreateNavigator().SelectSingleNode("weight");

            Validator.ThrowInvalidIfNull(weightNav, Resources.WeightUnexpectedNode);

            _when = new HealthServiceDateTime();
            _when.ParseXml(weightNav.SelectSingleNode("when"));

            _value = new WeightValue();
            _value.ParseXml(weightNav.SelectSingleNode("value"));
        }
        /// <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");
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Populates this <see cref="SleepJournalPM"/> instance from the data in the XML.
        /// </summary>
        ///
        /// <param name="typeSpecificXml">
        /// The XML to get the evening sleep journal data from.
        /// </param>
        ///
        /// <exception cref="InvalidOperationException">
        /// The first node in <paramref name="typeSpecificXml"/> is not
        /// a sleep-pm node.
        /// </exception>
        ///
        protected override void ParseXml(IXPathNavigable typeSpecificXml)
        {
            XPathNavigator sleepNav =
                typeSpecificXml.CreateNavigator().SelectSingleNode("sleep-pm");

            Validator.ThrowInvalidIfNull(sleepNav, Resources.SleepJournalPMUnexpectedNode);

            _when = new HealthServiceDateTime();
            _when.ParseXml(sleepNav.SelectSingleNode("when"));

            XPathNodeIterator caffeineNodes = sleepNav.Select("caffeine");

            foreach (XPathNavigator caffeineNav in caffeineNodes)
            {
                ApproximateTime caffeineTaken = new ApproximateTime();
                caffeineTaken.ParseXml(caffeineNav);
                _caffeine.Add(caffeineTaken);
            }

            XPathNodeIterator alcoholNodes = sleepNav.Select("alcohol");

            foreach (XPathNavigator alcoholNav in alcoholNodes)
            {
                ApproximateTime alcoholTaken = new ApproximateTime();
                alcoholTaken.ParseXml(alcoholNav);
                _alcohol.Add(alcoholTaken);
            }

            XPathNodeIterator napNodes = sleepNav.Select("nap");

            foreach (XPathNavigator napNav in napNodes)
            {
                Occurrence napTaken = new Occurrence();
                napTaken.ParseXml(napNav);
                _naps.Add(napTaken);
            }

            XPathNodeIterator exerciseNodes = sleepNav.Select("exercise");

            foreach (XPathNavigator exerciseNav in exerciseNodes)
            {
                Occurrence exerciseTaken = new Occurrence();
                exerciseTaken.ParseXml(exerciseNav);
                _exercise.Add(exerciseTaken);
            }

            _sleepiness =
                (Sleepiness)sleepNav.SelectSingleNode("sleepiness").ValueAsInt;
        }
        /// <summary>
        /// Populates this <see cref="GroupMembershipActivity"/> instance from the data in the XML.
        /// </summary>
        ///
        /// <param name="typeSpecificXml">
        /// The XML to get the group membership activity data from.
        /// </param>
        ///
        /// <exception cref="InvalidOperationException">
        /// If the first node in <paramref name="typeSpecificXml"/> is not
        /// a group-membership-activity node.
        /// </exception>
        ///
        protected override void ParseXml(IXPathNavigable typeSpecificXml)
        {
            XPathNavigator itemNav =
                typeSpecificXml.CreateNavigator().SelectSingleNode("group-membership-activity");

            Validator.ThrowInvalidIfNull(itemNav, Resources.GroupMembershipActivityUnexpectedNode);

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

            _activity = new CodedValue();
            _activity.ParseXml(itemNav.SelectSingleNode("activity"));

            _activityInfo = XPathHelper.GetOptNavValue(itemNav, "activity-info");
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Populates this <see cref="DefibrillatorEpisode"/> instance from the data in the specified XML.
        /// </summary>
        ///
        /// <param name="typeSpecificXml">
        /// The XML to get the DefibrillatorEpisode data from.
        /// </param>
        ///
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="typeSpecificXml"/> parameter is <b>null</b>.
        /// </exception>
        ///
        /// <exception cref="InvalidOperationException">
        /// If the first node in <paramref name="typeSpecificXml"/> is not
        /// a DefibrillatorEpisode node.
        /// </exception>
        ///
        protected override void ParseXml(IXPathNavigable typeSpecificXml)
        {
            XPathNavigator itemNav =
                typeSpecificXml.CreateNavigator().SelectSingleNode(
                    "defibrillator-episode");

            Validator.ThrowInvalidIfNull(itemNav, Resources.DefibrillatorEpisodeFieldUnexpectedNode);

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

            _episodeTypeGroup  = XPathHelper.GetOptNavValue <CodableValue>(itemNav, "episode-type-group");
            _episodeType       = XPathHelper.GetOptNavValue <CodableValue>(itemNav, "episode-type");
            _dataSource        = XPathHelper.GetOptNavValue <CodableValue>(itemNav, "data-source");
            _durationInSeconds = XPathHelper.GetOptNavValueAsUInt(itemNav, "duration-in-seconds");
            _episodeFields     = XPathHelper.ParseXmlCollection <DefibrillatorEpisodeField>(itemNav, "episode-fields/episode-field");
        }
        /// <summary>
        /// Populates this <see cref="Menstruation"/> instance from the data in the XML.
        /// </summary>
        ///
        /// <param name="typeSpecificXml">
        /// The XML to get the menstrual flow data from.
        /// </param>
        ///
        /// <exception cref="InvalidOperationException">
        /// If the first node in <paramref name="typeSpecificXml"/> is not
        /// an "menstrual-flow" node.
        /// </exception>
        ///
        protected override void ParseXml(IXPathNavigable typeSpecificXml)
        {
            XPathNavigator itemNav =
                typeSpecificXml.CreateNavigator().SelectSingleNode("menstruation");

            Validator.ThrowInvalidIfNull(itemNav, Resources.MenstruationUnexpectedNode);

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

            // isNewCycle
            _isNewCycle = XPathHelper.GetOptNavValueAsBool(itemNav, "is-new-cycle");

            // amount
            _amount = XPathHelper.GetOptNavValue <CodableValue>(itemNav, "amount");
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Populates this <see cref="Insight"/> instance from the data in the XML.
        /// </summary>
        ///
        /// <param name="typeSpecificXml">
        /// The XML to get the insight data from.
        /// </param>
        ///
        /// <exception cref="InvalidOperationException">
        /// The first node in <paramref name="typeSpecificXml"/> is not
        /// an insight node.
        /// </exception>
        ///
        protected override void ParseXml(IXPathNavigable typeSpecificXml)
        {
            XPathNavigator itemNav =
                typeSpecificXml.CreateNavigator().SelectSingleNode(
                    "insight");

            Validator.ThrowInvalidIfNull(itemNav, Resources.InsightUnexpectedNode);

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

            _raisedInsightId = itemNav.SelectSingleNode("raised-insight-id").Value;
            _catalogId       = itemNav.SelectSingleNode("catalog-id").Value;

            _expirationDate = new HealthServiceDateTime();
            _expirationDate.ParseXml(itemNav.SelectSingleNode("expiration-date"));

            _channel         = XPathHelper.GetOptNavValue(itemNav, "channel");
            _algoClass       = XPathHelper.GetOptNavValue(itemNav, "algo-class");
            _directionality  = XPathHelper.GetOptNavValue(itemNav, "directionality");
            _timespanPivot   = XPathHelper.GetOptNavValue(itemNav, "time-span-pivot");
            _comparisonPivot = XPathHelper.GetOptNavValue(itemNav, "comparison-pivot");
            _tonePivot       = XPathHelper.GetOptNavValue(itemNav, "tone-pivot");
            _scopePivot      = XPathHelper.GetOptNavValue(itemNav, "scope-pivot");

            XPathNavigator dataUsedNav = itemNav.SelectSingleNode("data-used-pivot");

            _dataUsedPivot = GetStringList(dataUsedNav, "data-used");

            _annotation = XPathHelper.GetOptNavValue(itemNav, "annotation");
            _strength   = XPathHelper.GetOptNavValueAsDouble(itemNav, "strength");
            _confidence = XPathHelper.GetOptNavValueAsDouble(itemNav, "confidence");
            _origin     = XPathHelper.GetOptNavValue(itemNav, "origin");

            XPathNavigator tagsNav = itemNav.SelectSingleNode("tags");

            _insightTags = GetStringList(tagsNav, "tag");

            XPathNavigator valueNav = itemNav.SelectSingleNode("values");

            _values = GetDictionary(valueNav, "value");

            XPathNavigator callToActionNav = itemNav.SelectSingleNode("links");

            _links = GetDictionary(callToActionNav, "value");
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Populates this SleepJournalAM instance from the data in the XML.
        /// </summary>
        ///
        /// <param name="typeSpecificXml">
        /// The XML to get the morning sleep journal data from.
        /// </param>
        ///
        /// <exception cref="InvalidOperationException">
        /// The first node in the <paramref name="typeSpecificXml"/> parameter
        /// is not a sleep-am node.
        /// </exception>
        ///
        protected override void ParseXml(IXPathNavigable typeSpecificXml)
        {
            XPathNavigator sleepNav =
                typeSpecificXml.CreateNavigator().SelectSingleNode("sleep-am");

            Validator.ThrowInvalidIfNull(sleepNav, Resources.SleepJournalAMUnexpectedNode);

            _when = new HealthServiceDateTime();
            _when.ParseXml(sleepNav.SelectSingleNode("when"));

            _bedtime = new ApproximateTime();
            _bedtime.ParseXml(sleepNav.SelectSingleNode("bed-time"));

            _wakeTime = new ApproximateTime();
            _wakeTime.ParseXml(sleepNav.SelectSingleNode("wake-time"));

            _sleepMinutes =
                sleepNav.SelectSingleNode("sleep-minutes").ValueAsInt;

            _settlingMinutes =
                sleepNav.SelectSingleNode("settling-minutes").ValueAsInt;

            XPathNodeIterator awakeningsIterator =
                sleepNav.Select("awakening");

            foreach (XPathNavigator awakeningNav in awakeningsIterator)
            {
                Occurrence awakening = new Occurrence();
                awakening.ParseXml(awakeningNav);
                _awakenings.Add(awakening);
            }

            XPathNavigator medNav = sleepNav.SelectSingleNode("medications");

            if (medNav != null)
            {
                _medications = new CodableValue();
                _medications.ParseXml(medNav);
            }

            _wakeState =
                (WakeState)sleepNav.SelectSingleNode("wake-state").ValueAsInt;
        }
        /// <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.CholesterolProfileV2UnexpectedNode);

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

            _ldl = XPathHelper.GetOptNavValue <ConcentrationMeasurement>(itemNav, "ldl");

            _hdl = XPathHelper.GetOptNavValue <ConcentrationMeasurement>(itemNav, "hdl");

            _totalCholesterol = XPathHelper.GetOptNavValue <ConcentrationMeasurement>(itemNav, "total-cholesterol");

            _triglyceride = XPathHelper.GetOptNavValue <ConcentrationMeasurement>(itemNav, "triglyceride");
        }
        /// <summary>
        /// Populates this <see cref="HbA1CV2"/> instance from the data in the XML.
        /// </summary>
        ///
        /// <param name="typeSpecificXml">
        /// The XML to get the HbA1C data from.
        /// </param>
        ///
        /// <exception cref="InvalidOperationException">
        /// The first node in <paramref name="typeSpecificXml"/> is not
        /// an HbA1C node.
        /// </exception>
        ///
        protected override void ParseXml(IXPathNavigable typeSpecificXml)
        {
            XPathNavigator itemNav =
                typeSpecificXml.CreateNavigator().SelectSingleNode(
                    "HbA1C");

            Validator.ThrowInvalidIfNull(itemNav, Resources.HbA1CV2UnexpectedNode);

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

            _value = XPathHelper.GetOptNavValue <HbA1CMeasurement>(itemNav, "value");

            _assayMethod =
                XPathHelper.GetOptNavValue <CodableValue>(
                    itemNav,
                    "HbA1C-assay-method");

            _deviceId =
                XPathHelper.GetOptNavValue(itemNav, "device-id");
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Populates this health problem instance from the data in the XML.
        /// </summary>
        ///
        /// <param name="typeSpecificXml">
        /// The XML to get the health problem data from.
        /// </param>
        ///
        /// <exception cref="InvalidOperationException">
        /// The first node in <paramref name="typeSpecificXml"/> is not
        /// a health problem node.
        /// </exception>
        ///
        protected override void ParseXml(IXPathNavigable typeSpecificXml)
        {
            XPathNavigator itemNav =
                typeSpecificXml.CreateNavigator().SelectSingleNode("problem");

            Validator.ThrowInvalidIfNull(itemNav, Resources.ProblemUnexpectedNode);

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

            // <diagnosis>
            XPathNodeIterator diagnosisIterator =
                itemNav.Select("diagnosis");

            _diagnosis.Clear();
            foreach (XPathNavigator diagnosisNav in diagnosisIterator)
            {
                CodableValue value = new CodableValue();
                value.ParseXml(diagnosisNav);
                _diagnosis.Add(value);
            }

            // <duration>
            XPathNodeIterator durationIterator =
                itemNav.Select("duration");

            _duration.Clear();
            foreach (XPathNavigator durationNav in durationIterator)
            {
                DurationValue value = new DurationValue();
                value.ParseXml(durationNav);
                _duration.Add(value);
            }

            // <importance>
            _importance =
                XPathHelper.GetOptNavValueAsInt(
                    itemNav,
                    "importance");
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Populates this <see cref="AsthmaInhalerUse"/> instance from the data in the XML.
        /// </summary>
        ///
        /// <param name="typeSpecificXml">
        /// The XML to get the asthma inhaler use data from.
        /// </param>
        ///
        /// <exception cref="InvalidOperationException">
        /// The first node in <paramref name="typeSpecificXml"/> is not
        /// an asthma-inhaler-use node.
        /// </exception>
        ///
        protected override void ParseXml(IXPathNavigable typeSpecificXml)
        {
            XPathNavigator inhalerUseNav =
                typeSpecificXml.CreateNavigator().SelectSingleNode("asthma-inhaler-use");

            Validator.ThrowInvalidIfNull(inhalerUseNav, Resources.AsthmaInhalerUseUnexpectedNode);

            _when = new HealthServiceDateTime();
            _when.ParseXml(inhalerUseNav.SelectSingleNode("when"));

            _drug = new CodableValue();
            _drug.ParseXml(inhalerUseNav.SelectSingleNode("drug"));

            XPathNavigator strengthNav =
                inhalerUseNav.SelectSingleNode("strength");

            if (strengthNav != null)
            {
                _strength = new CodableValue();
                _strength.ParseXml(strengthNav);
            }

            _doseCount = inhalerUseNav.SelectSingleNode("dose-count").ValueAsInt;

            XPathNavigator deviceIdNav = inhalerUseNav.SelectSingleNode("device-id");

            if (deviceIdNav != null)
            {
                _deviceId = deviceIdNav.Value;
            }

            XPathNavigator purposeNav = inhalerUseNav.SelectSingleNode("dose-purpose");

            if (purposeNav != null)
            {
                _dosePurpose = new CodableValue();
                _dosePurpose.ParseXml(purposeNav);
            }
        }
        /// <summary>
        /// Populates the <see cref="Message"/> instance from the data in the specified XML.
        /// </summary>
        ///
        /// <param name="typeSpecificXml">
        /// The XML to get the Message data from.
        /// </param>
        ///
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="typeSpecificXml"/> parameter is <b>null</b>.
        /// </exception>
        ///
        /// <exception cref="InvalidOperationException">
        /// If the first node in <paramref name="typeSpecificXml"/> is not
        /// a Message node.
        /// </exception>
        ///
        protected override void ParseXml(IXPathNavigable typeSpecificXml)
        {
            Validator.ThrowIfArgumentNull(typeSpecificXml, nameof(typeSpecificXml), Resources.ParseXmlNavNull);

            XPathNavigator itemNav =
                typeSpecificXml.CreateNavigator().SelectSingleNode("message");

            Validator.ThrowInvalidIfNull(itemNav, Resources.MessageUnexpectedNode);

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

            _headers.Clear();
            foreach (XPathNavigator nav in itemNav.Select("headers"))
            {
                string name  = nav.SelectSingleNode("name").Value;
                string value = nav.SelectSingleNode("value").Value;

                if (!_headers.ContainsKey(name))
                {
                    _headers.Add(name, new Collection <string>());
                }

                _headers[name].Add(value);
            }

            _size         = itemNav.SelectSingleNode("size").ValueAsLong;
            _summary      = XPathHelper.GetOptNavValue(itemNav, "summary");
            _htmlBlobName = XPathHelper.GetOptNavValue(itemNav, "html-blob-name");
            _textBlobName = XPathHelper.GetOptNavValue(itemNav, "text-blob-name");

            _attachments.Clear();
            foreach (XPathNavigator nav in itemNav.Select("attachments"))
            {
                MessageAttachment messageAttachment = new MessageAttachment();
                messageAttachment.ParseXml(nav);
                _attachments.Add(messageAttachment);
            }
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Populates this <see cref="BloodOxygenSaturation"/> instance from the data in the XML.
        /// </summary>
        ///
        /// <param name="typeSpecificXml">
        /// The XML to get the blood oxygen saturation data from.
        /// </param>
        ///
        /// <exception cref="InvalidOperationException">
        /// If the first node in <paramref name="typeSpecificXml"/> is not
        /// a "blood-oxygen-saturation" node.
        /// </exception>
        ///
        protected override void ParseXml(IXPathNavigable typeSpecificXml)
        {
            XPathNavigator itemNav =
                typeSpecificXml.CreateNavigator().SelectSingleNode("blood-oxygen-saturation");

            Validator.ThrowInvalidIfNull(itemNav, Resources.BloodOxygenSaturationUnexpectedNode);

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

            // value
            _value = itemNav.SelectSingleNode("value").ValueAsDouble;

            // measurement-method
            _measurementMethod =
                XPathHelper.GetOptNavValue <CodableValue>(itemNav, "measurement-method");

            // measurement-flags
            _measurementFlags =
                XPathHelper.GetOptNavValue <CodableValue>(itemNav, "measurement-flags");
        }
        /// <summary>
        /// Populates this question/answer instance from the data in the XML.
        /// </summary>
        ///
        /// <param name="typeSpecificXml">
        /// The XML to get the question/answer data from.
        /// </param>
        ///
        /// <exception cref="InvalidOperationException">
        /// If the first node in <paramref name="typeSpecificXml"/> is not
        /// a question-answer node.
        /// </exception>
        ///
        protected override void ParseXml(IXPathNavigable typeSpecificXml)
        {
            XPathNavigator itemNav =
                typeSpecificXml.CreateNavigator().SelectSingleNode("question-answer");

            Validator.ThrowInvalidIfNull(itemNav, Resources.QuestionAnswerUnexpectedNode);

            // <when>
            _when = new HealthServiceDateTime();
            _when.ParseXml(itemNav.SelectSingleNode("when"));

            // <question>
            _question = new CodableValue();
            _question.ParseXml(itemNav.SelectSingleNode("question"));

            // <answer-choice>
            _answerChoice.Clear();

            XPathNodeIterator choiceIterator = itemNav.Select("answer-choice");

            foreach (XPathNavigator choiceNav in choiceIterator)
            {
                CodableValue choice = new CodableValue();
                choice.ParseXml(choiceNav);
                _answerChoice.Add(choice);
            }

            // <answer>
            _answer.Clear();

            XPathNodeIterator answerIterator = itemNav.Select("answer");

            foreach (XPathNavigator answerNav in answerIterator)
            {
                CodableValue answer = new CodableValue();
                answer.ParseXml(answerNav);
                _answer.Add(answer);
            }
        }
        /// <summary>
        /// Populates this radiology laboratory results instance from the data in the XML.
        /// </summary>
        ///
        /// <param name="typeSpecificXml">
        /// The XML to get the radiology laboratory results data from.
        /// </param>
        ///
        /// <exception cref="InvalidOperationException">
        /// The first node in <paramref name="typeSpecificXml"/> is not
        /// a radiology laboratory results node.
        /// </exception>
        ///
        protected override void ParseXml(IXPathNavigable typeSpecificXml)
        {
            XPathNavigator itemNav =
                typeSpecificXml.CreateNavigator().SelectSingleNode("radiology-lab-results");

            Validator.ThrowInvalidIfNull(itemNav, Resources.RadiologyLabResultsUnexpectedNode);

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

            // <title>
            _title =
                XPathHelper.GetOptNavValue(itemNav, "title");

            // <anatomic-site>
            _anatomicSite =
                XPathHelper.GetOptNavValue(itemNav, "anatomic-site");

            // <result-text>
            _resultText =
                XPathHelper.GetOptNavValue(itemNav, "result-text");
        }