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

            Validator.ThrowInvalidIfNull(itemNav, Resources.LabTestResultsUnexpectedNode);

            // when
            _when =
                XPathHelper.GetOptNavValue <ApproximateDateTime>(itemNav, "when");

            // lab-group
            XPathNodeIterator labGroupIterator =
                itemNav.Select("lab-group");

            _labGroup = new Collection <LabTestResultGroup>();
            foreach (XPathNavigator labGroupNav in labGroupIterator)
            {
                LabTestResultGroup labTestResultGroup = new LabTestResultGroup();
                labTestResultGroup.ParseXml(labGroupNav);
                _labGroup.Add(labTestResultGroup);
            }

            // ordered-by
            _orderedBy =
                XPathHelper.GetOptNavValue <Organization>(itemNav, "ordered-by");
        }
Example #2
0
        /// <summary>
        /// Populates this <see cref="LabTestResultGroup"/> instance from the data in the XML.
        /// </summary>
        ///
        /// <param name="navigator">
        /// The XML to get the lab test results group type data from.
        /// </param>
        ///
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="navigator"/> is <b>null</b>.
        /// </exception>
        ///
        public override void ParseXml(XPathNavigator navigator)
        {
            Validator.ThrowIfNavigatorNull(navigator);

            // group-name
            _groupName = new CodableValue();
            _groupName.ParseXml(navigator.SelectSingleNode("group-name"));

            // laboratory-name
            _laboratoryName =
                XPathHelper.GetOptNavValue <Organization>(navigator, "laboratory-name");

            // status
            _status =
                XPathHelper.GetOptNavValue <CodableValue>(navigator, "status");

            // sub-groups
            XPathNodeIterator subGroupsIterator = navigator.Select("sub-groups");

            _subGroups = new Collection <LabTestResultGroup>();
            foreach (XPathNavigator subGroupNav in subGroupsIterator)
            {
                LabTestResultGroup subGroup = new LabTestResultGroup();
                subGroup.ParseXml(subGroupNav);
                _subGroups.Add(subGroup);
            }

            // results
            XPathNodeIterator resultsIterator = navigator.Select("results");

            _results = new Collection <LabTestResultDetails>();
            foreach (XPathNavigator resultNav in resultsIterator)
            {
                LabTestResultDetails result = new LabTestResultDetails();
                result.ParseXml(resultNav);
                _results.Add(result);
            }
        }