/// <summary> /// Populates this <see cref="BodyComposition"/> instance from the data in the XML. /// </summary> /// /// <param name="typeSpecificXml"> /// The XML to get the body composition data from. /// </param> /// /// <exception cref="InvalidOperationException"> /// If the first node in <paramref name="typeSpecificXml"/> is not /// a "body-composition" node. /// </exception> /// protected override void ParseXml(IXPathNavigable typeSpecificXml) { XPathNavigator itemNav = typeSpecificXml.CreateNavigator().SelectSingleNode("body-composition"); Validator.ThrowInvalidIfNull(itemNav, Resources.BodyCompositionUnexpectedNode); // when (approxi-date-time, mandatory) _when = new ApproximateDateTime(); _when.ParseXml(itemNav.SelectSingleNode("when")); // measurement-name (codable-value, mandatory) _measurementName = new CodableValue(); _measurementName.ParseXml(itemNav.SelectSingleNode("measurement-name")); // value (BodyCompositionValue, mandatory) _value = new BodyCompositionValue(); _value.ParseXml(itemNav.SelectSingleNode("value")); // measurement-method (codable value ) _measurementMethod = XPathHelper.GetOptNavValue <CodableValue>(itemNav, "measurement-method"); // site _site = XPathHelper.GetOptNavValue <CodableValue>(itemNav, "site"); }
/// <summary> /// Populates this <see cref="GeneticSnpResults"/> instance from the data /// in the XML. /// </summary> /// /// <param name="typeSpecificXml"> /// The XML to get the genetic snp result data from. /// </param> /// /// <exception cref="InvalidOperationException"> /// If the first node in <paramref name="typeSpecificXml"/> is not /// an "genetic-snp-results" node. /// </exception> /// protected override void ParseXml(IXPathNavigable typeSpecificXml) { XPathNavigator itemNav = typeSpecificXml.CreateNavigator().SelectSingleNode("genetic-snp-results"); Validator.ThrowInvalidIfNull(itemNav, Resources.GeneticSnpResultsUnexpectedNode); // <when> mandatory _when = new ApproximateDateTime(); _when.ParseXml(itemNav.SelectSingleNode("when")); // <genome-build> mandatory _genomeBuild = itemNav.SelectSingleNode("genome-build").Value; // <chromosome> mandatory _chromosome = itemNav.SelectSingleNode("chromosome").Value; // <numbering-scheme> mandatory int numberingScheme = itemNav.SelectSingleNode("numbering-scheme").ValueAsInt; if ((numberingScheme == 0) || (numberingScheme == 1)) { _numberingScheme = (GenomeNumberingScheme)numberingScheme; } else { _numberingScheme = GenomeNumberingScheme.Unknown; } // ordered-by _orderedBy = XPathHelper.GetOptNavValue <Organization>(itemNav, "ordered-by"); // test-provider _testProvider = XPathHelper.GetOptNavValue <Organization>(itemNav, "test-provider"); // laboratory-name _laboratoryName = XPathHelper.GetOptNavValue <Organization>(itemNav, "laboratory-name"); // annotation-version _annotationVersion = XPathHelper.GetOptNavValue(itemNav, "annotation-version"); // dbSNP-build _dbSnpBuild = XPathHelper.GetOptNavValue(itemNav, "dbSNP-build"); // platform _platform = XPathHelper.GetOptNavValue(itemNav, "platform"); }
/// <summary> /// Populates this <see cref="HealthJournalEntry"/> instance from the data in the specified XML. /// </summary> /// /// <param name="typeSpecificXml"> /// The XML to get the HealthJournalEntry 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 HealthJournalEntry node. /// </exception> /// protected override void ParseXml(IXPathNavigable typeSpecificXml) { Validator.ThrowIfArgumentNull(typeSpecificXml, nameof(typeSpecificXml), Resources.ParseXmlNavNull); XPathNavigator itemNav = typeSpecificXml.CreateNavigator().SelectSingleNode("health-journal-entry"); Validator.ThrowInvalidIfNull(itemNav, Resources.HealthJournalEntryUnexpectedNode); _when = new ApproximateDateTime(); _when.ParseXml(itemNav.SelectSingleNode("when")); _content = itemNav.SelectSingleNode("content").Value; _category = XPathHelper.GetOptNavValue <CodableValue>(itemNav, "category"); }
/// <summary> /// Populates this Person instance from the data in the XML. /// </summary> /// /// <param name="navigator"> /// The XML containing the duration information. /// </param> /// /// <exception cref="InvalidOperationException"> /// The first node in <paramref name="navigator"/> is not /// a person node. /// </exception> /// public override void ParseXml(XPathNavigator navigator) { Validator.ThrowIfNavigatorNull(navigator); // <start-date> _startDate = new ApproximateDateTime(); _startDate.ParseXml(navigator.SelectSingleNode("start-date")); // <end-date> _endDate = XPathHelper.GetOptNavValue <ApproximateDateTime>( navigator, "end-date"); }
/// <summary> /// Populates this <see cref="Exercise"/> instance from the data in the XML. /// </summary> /// /// <param name="typeSpecificXml"> /// The XML to get the exercise data from. /// </param> /// /// <exception cref="InvalidOperationException"> /// If the first node in <paramref name="typeSpecificXml"/> is not /// an "exercise" node. /// </exception> /// protected override void ParseXml(IXPathNavigable typeSpecificXml) { XPathNavigator itemNav = typeSpecificXml.CreateNavigator().SelectSingleNode("exercise"); Validator.ThrowInvalidIfNull(itemNav, Resources.ExerciseUnexpectedNode); // when _when = new ApproximateDateTime(); _when.ParseXml(itemNav.SelectSingleNode("when")); // activity _activity = XPathHelper.GetOptNavValue <CodableValue>(itemNav, "activity"); // title _title = XPathHelper.GetOptNavValue(itemNav, "title"); _distance = XPathHelper.GetOptNavValue <Length>(itemNav, "distance"); // duration _duration = XPathHelper.GetOptNavValueAsDouble(itemNav, "duration"); // detail XPathNodeIterator detailsIterator = itemNav.Select("detail"); _details.Clear(); foreach (XPathNavigator detailsNavigator in detailsIterator) { ExerciseDetail exerciseDetail = new ExerciseDetail(); exerciseDetail.ParseXml(detailsNavigator); _details[exerciseDetail.Name.Value] = exerciseDetail; } // segment XPathNodeIterator segmentsIterator = itemNav.Select("segment"); _segments.Clear(); foreach (XPathNavigator segmentsNavigator in segmentsIterator) { ExerciseSegment exerciseSegment = new ExerciseSegment(); exerciseSegment.ParseXml(segmentsNavigator); _segments.Add(exerciseSegment); } }
/// <summary> /// Populates this <see cref="Condition"/> instance from the data in the XML. /// </summary> /// /// <param name="typeSpecificXml"> /// The XML to get the condition data from. /// </param> /// /// <exception cref="InvalidOperationException"> /// The first node in <paramref name="typeSpecificXml"/> is not /// a condition node. /// </exception> /// protected override void ParseXml(IXPathNavigable typeSpecificXml) { _name.Clear(); XPathNavigator conditionNav = typeSpecificXml.CreateNavigator().SelectSingleNode("condition"); Validator.ThrowInvalidIfNull(conditionNav, Resources.ConditionUnexpectedNode); _name.ParseXml(conditionNav.SelectSingleNode("name")); XPathNavigator onsetNav = conditionNav.SelectSingleNode("onset-date"); if (onsetNav != null) { _onsetDate = new ApproximateDateTime(); _onsetDate.ParseXml(onsetNav); } XPathNavigator statusNav = conditionNav.SelectSingleNode("status"); if (statusNav != null) { _status = new CodableValue(); _status.ParseXml(statusNav); } XPathNavigator stopDateNav = conditionNav.SelectSingleNode("stop-date"); if (stopDateNav != null) { _stopDate = new ApproximateDateTime(); _stopDate.ParseXml(stopDateNav); } XPathNavigator stopReasonNav = conditionNav.SelectSingleNode("stop-reason"); if (stopReasonNav != null) { _stopReason = stopReasonNav.Value; } }
/// <summary> /// Populates this <see cref="CalorieGuideline"/> instance from the data in the XML. /// </summary> /// /// <param name="typeSpecificXml"> /// The XML to get the calorie guideline data from. /// </param> /// /// <exception cref="InvalidOperationException"> /// If the first node in <paramref name="typeSpecificXml"/> is not /// a "calorie-guideline" node. /// </exception> /// protected override void ParseXml(IXPathNavigable typeSpecificXml) { XPathNavigator itemNav = typeSpecificXml.CreateNavigator().SelectSingleNode("calorie-guideline"); Validator.ThrowInvalidIfNull(itemNav, Resources.CalorieGuidelineUnexpectedNode); // when (approxi-date-time, mandatory) _when = new ApproximateDateTime(); _when.ParseXml(itemNav.SelectSingleNode("when")); // measurement-name (codable-value, mandatory) _name = new CodableValue(); _name.ParseXml(itemNav.SelectSingleNode("name")); // calories (general-measurement, mandatory) _calories = new GeneralMeasurement(); _calories.ParseXml(itemNav.SelectSingleNode("calories")); }
/// <summary> /// Populates this <see cref="BodyDimension"/> instance from the data in the XML. /// </summary> /// /// <param name="typeSpecificXml"> /// The XML to get the body dimension data from. /// </param> /// /// <exception cref="InvalidOperationException"> /// If the first node in <paramref name="typeSpecificXml"/> is not /// a "body-dimension" node. /// </exception> /// protected override void ParseXml(IXPathNavigable typeSpecificXml) { XPathNavigator itemNav = typeSpecificXml.CreateNavigator().SelectSingleNode("body-dimension"); Validator.ThrowInvalidIfNull(itemNav, Resources.BodyDimensionUnexpectedNode); // when (approxi-date-time, mandatory) _when = new ApproximateDateTime(); _when.ParseXml(itemNav.SelectSingleNode("when")); // measurement-name (codable-value, mandatory) _measurementName = new CodableValue(); _measurementName.ParseXml(itemNav.SelectSingleNode("measurement-name")); // value (Length, mandatory) _value = new Length(); _value.ParseXml(itemNav.SelectSingleNode("value")); }
/// <summary> /// Populates this <see cref="ExerciseSamples"/> instance from the data in the XML. /// </summary> /// /// <param name="typeSpecificXml"> /// The XML to get the exercise samples data from. /// </param> /// /// <exception cref="InvalidOperationException"> /// If the first node in <paramref name="typeSpecificXml"/> is not /// an "exercise-samples" node. /// </exception> /// protected override void ParseXml(IXPathNavigable typeSpecificXml) { XPathNavigator itemNav = typeSpecificXml.CreateNavigator().SelectSingleNode("exercise-samples"); Validator.ThrowInvalidIfNull(itemNav, Resources.ExerciseSamplesUnexpectedNode); // when _when = new ApproximateDateTime(); _when.ParseXml(itemNav.SelectSingleNode("when")); // name _name = XPathHelper.GetOptNavValue <CodableValue>(itemNav, "name"); // unit _unit = XPathHelper.GetOptNavValue <CodableValue>(itemNav, "unit"); // sampling interval _samplingInterval = itemNav.SelectSingleNode("sampling-interval").ValueAsDouble; }
/// <summary> /// Populates the data from the specified XML. /// </summary> /// /// <param name="navigator"> /// The XML containing the goal information. /// </param> /// /// <exception cref="ArgumentNullException"> /// The <paramref name="navigator"/> parameter is <b>null</b>. /// </exception> /// public override void ParseXml(XPathNavigator navigator) { Validator.ThrowIfNavigatorNull(navigator); XPathNavigator targetNav = navigator.SelectSingleNode("target-date"); if (targetNav != null) { _targetDate = new ApproximateDateTime(); _targetDate.ParseXml(targetNav); } XPathNavigator completionNav = navigator.SelectSingleNode("completion-date"); if (completionNav != null) { _completionDate = new ApproximateDateTime(); _completionDate.ParseXml(completionNav); } XPathNavigator statusNav = navigator.SelectSingleNode("status"); if (statusNav != null) { try { _status = (GoalStatus)Enum.Parse(typeof(GoalStatus), statusNav.Value, true); } catch (ArgumentException) { _status = GoalStatus.Unknown; _statusString = statusNav.Value; } } }
/// <summary> /// Populates this <see cref="PeakFlow"/> instance from the data in the XML. /// </summary> /// /// <param name="typeSpecificXml"> /// The XML to get the peack flow data from. /// </param> /// /// <exception cref="InvalidOperationException"> /// The first node in the <paramref name="typeSpecificXml"/> parameter /// is not a peak-flow node. /// </exception> /// protected override void ParseXml(IXPathNavigable typeSpecificXml) { XPathNavigator itemNav = typeSpecificXml.CreateNavigator().SelectSingleNode( "peak-flow"); Validator.ThrowInvalidIfNull(itemNav, Resources.PeakFlowUnexpectedNode); _when = new ApproximateDateTime(); _when.ParseXml(itemNav.SelectSingleNode("when")); _peakExpiratoryFlow = XPathHelper.GetOptNavValue <FlowMeasurement>( itemNav, "pef"); _fev1 = XPathHelper.GetOptNavValue <VolumeMeasurement>( itemNav, "fev1"); _fev6 = XPathHelper.GetOptNavValue <VolumeMeasurement>( itemNav, "fev6"); _measurementFlags.Clear(); XPathNodeIterator measurementFlagsIterator = itemNav.Select("measurement-flags"); foreach (XPathNavigator flagNav in measurementFlagsIterator) { CodableValue flag = new CodableValue(); flag.ParseXml(flagNav); _measurementFlags.Add(flag); } }
/// <summary> /// Populates this <see cref="Directive"/> instance from the data in the XML. /// </summary> /// /// <param name="typeSpecificXml"> /// The XML to get the directive data from. /// </param> /// /// <exception cref="InvalidOperationException"> /// The first node of the <paramref name="typeSpecificXml"/> /// parameter is not a directive node. /// </exception> /// protected override void ParseXml(IXPathNavigable typeSpecificXml) { XPathNavigator itemNav = typeSpecificXml.CreateNavigator().SelectSingleNode("directive"); Validator.ThrowInvalidIfNull(itemNav, Resources.DirectiveUnexpectedNode); // <start-date> _startDate = new ApproximateDateTime(); _startDate.ParseXml(itemNav.SelectSingleNode("start-date")); // <stop-date> _stopDate = new ApproximateDateTime(); _stopDate.ParseXml(itemNav.SelectSingleNode("stop-date")); // <description> _description = XPathHelper.GetOptNavValue(itemNav, "description"); // <full-resuscitation> _fullResuscitation = XPathHelper.GetOptNavValueAsBool(itemNav, "full-resuscitation"); // <prohibited-interventions> _prohibitedInterventions = XPathHelper.GetOptNavValue <CodableValue>( itemNav, "prohibited-interventions"); // <additional-instructions> _additionalInstructions = XPathHelper.GetOptNavValue(itemNav, "additional-instructions"); // <attending-physician> _attendingPhysician = XPathHelper.GetOptNavValue <PersonItem>( itemNav, "attending-physician"); // <attending-physician-endorsement> _attendingPhysicianEndorsement = XPathHelper.GetOptNavValue <HealthServiceDateTime>( itemNav, "attending-physician-endorsement"); // <attending-nurse> _attendingNurse = XPathHelper.GetOptNavValue <PersonItem>( itemNav, "attending-nurse"); // <attending-nurse-endorsement" type="d:date-time"> _attendingNurseEndorsement = XPathHelper.GetOptNavValue <HealthServiceDateTime>( itemNav, "attending-nurse-endorsement"); // <expiration-date> _expirationDate = XPathHelper.GetOptNavValue <HealthServiceDateTime>( itemNav, "expiration-date"); // <discontinuation-date> _discontinuationDate = XPathHelper.GetOptNavValue <ApproximateDateTime>( itemNav, "discontinuation-date"); // <discontinuation-physician> _discontinuationPhysician = XPathHelper.GetOptNavValue <PersonItem>( itemNav, "discontinuation-physician"); // <discontinuation-physician-endorsement> _discontinuationPhysicianEndorsement = XPathHelper.GetOptNavValue <HealthServiceDateTime>( itemNav, "discontinuation-physician-endorsement"); // <discontinuation-nurse> _discontinuationNurse = XPathHelper.GetOptNavValue <PersonItem>( itemNav, "discontinuation-nurse"); // <discontinuation-nurse-endorsement> _discontinuationNurseEndorsement = XPathHelper.GetOptNavValue <HealthServiceDateTime>( itemNav, "discontinuation-nurse-endorsement"); }
/// <summary> /// Populates this <see cref="AsthmaInhaler"/> instance from the data in the XML. /// </summary> /// /// <param name="typeSpecificXml"> /// The XML to get the asthma inhaler data from. /// </param> /// /// <exception cref="InvalidOperationException"> /// The first node in the <paramref name="typeSpecificXml"/> /// parameter is not an asthma-inhaler node. /// </exception> /// protected override void ParseXml(IXPathNavigable typeSpecificXml) { XPathNavigator inhalerNav = typeSpecificXml.CreateNavigator().SelectSingleNode( "asthma-inhaler"); Validator.ThrowInvalidIfNull(inhalerNav, Resources.AsthmaInhalerUnexpectedNode); _drug = new CodableValue(); _drug.ParseXml(inhalerNav.SelectSingleNode("drug")); XPathNavigator strengthNav = inhalerNav.SelectSingleNode("strength"); if (strengthNav != null) { _strength = new CodableValue(); _strength.ParseXml(strengthNav); } XPathNavigator purposeNav = inhalerNav.SelectSingleNode("purpose"); if (purposeNav != null) { try { _purpose = (InhalerPurpose)Enum.Parse( typeof(InhalerPurpose), purposeNav.Value, true); } catch (ArgumentException) { _purpose = InhalerPurpose.None; _purposeString = purposeNav.Value; } } _startDate = new ApproximateDateTime(); _startDate.ParseXml(inhalerNav.SelectSingleNode("start-date")); XPathNavigator stopDateNav = inhalerNav.SelectSingleNode("stop-date"); if (stopDateNav != null) { _stopDate = new ApproximateDateTime(); _stopDate.ParseXml(stopDateNav); } XPathNavigator expirationDateNav = inhalerNav.SelectSingleNode("expiration-date"); if (expirationDateNav != null) { _expirationDate = new ApproximateDateTime(); _expirationDate.ParseXml(expirationDateNav); } XPathNavigator deviceIdNav = inhalerNav.SelectSingleNode("device-id"); if (deviceIdNav != null) { _deviceId = deviceIdNav.Value; } XPathNavigator initialDosesNav = inhalerNav.SelectSingleNode("initial-doses"); if (initialDosesNav != null) { _initialDoses = initialDosesNav.ValueAsInt; } XPathNavigator minDosesNav = inhalerNav.SelectSingleNode("min-daily-doses"); if (minDosesNav != null) { _minDailyDoses = minDosesNav.ValueAsInt; } XPathNavigator maxDosesNav = inhalerNav.SelectSingleNode("max-daily-doses"); if (maxDosesNav != null) { _maxDailyDoses = maxDosesNav.ValueAsInt; } XPathNavigator canAlertNav = inhalerNav.SelectSingleNode("can-alert"); if (canAlertNav != null) { _canAlert = canAlertNav.ValueAsBoolean; } XPathNodeIterator alertIterator = inhalerNav.Select("alert"); foreach (XPathNavigator alertNav in alertIterator) { Alert alert = new Alert(); alert.ParseXml(alertNav); _alerts.Add(alert); } }