/// <summary>
        /// Writes the XML representation of the CarePlan into
        /// the specified XML writer.
        /// </summary>
        ///
        /// <param name="writer">
        /// The XML writer into which the CarePlan should be
        /// written.
        /// </param>
        ///
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="writer"/> parameter is <b>null</b>.
        /// </exception>
        ///
        /// <exception cref="ThingSerializationException">
        /// If <see cref="Name"/> is <b>null</b> or empty or contains only whitespace.
        /// </exception>
        ///
        public override void WriteXml(XmlWriter writer)
        {
            Validator.ThrowIfArgumentNull(writer, nameof(writer), Resources.WriteXmlNullWriter);

            if (string.IsNullOrEmpty(_name) || string.IsNullOrEmpty(_name.Trim()))
            {
                throw new ThingSerializationException(Resources.CarePlanNameNullOrEmpty);
            }

            writer.WriteStartElement("care-plan");
            {
                writer.WriteElementString("name", _name);
                XmlWriterHelper.WriteOpt(writer, "start-date", _startDate);
                XmlWriterHelper.WriteOpt(writer, "end-date", _endDate);
                XmlWriterHelper.WriteOpt(writer, "status", _status);

                XmlWriterHelper.WriteXmlCollection(writer, "care-team", _careTeam, "person");

                XmlWriterHelper.WriteOpt(writer, "care-plan-manager", _carePlanManager);
                XmlWriterHelper.WriteXmlCollection(writer, "tasks", _tasks, "task");
                XmlWriterHelper.WriteXmlCollection(writer, "goal-groups", _goalGroups, "goal-group");
            }

            writer.WriteEndElement();
        }
Esempio n. 2
0
        /// <summary>
        /// Writes the XML representation of the medical image study into
        /// the specified XML writer.
        /// </summary>
        ///
        /// <param name="writer">
        /// The XML writer into which the medical image study series should be
        /// written.
        /// </param>
        ///
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="writer"/> parameter is <b>null</b>.
        /// </exception>
        ///
        /// <exception cref="ThingSerializationException">
        /// If <see cref="When"/> is <b>null</b>.
        /// If <see cref="Series"/> collection is <b>null</b> or empty.
        /// </exception>
        ///
        public override void WriteXml(XmlWriter writer)
        {
            Validator.ThrowIfWriterNull(writer);
            Validator.ThrowSerializationIfNull(_when, Resources.WhenNullValue);

            if (_series == null || _series.Count == 0)
            {
                throw new ThingSerializationException(Resources.MedicalImageStudySeriesMandatory);
            }

            writer.WriteStartElement("medical-image-study");

            _when.WriteXml("when", writer);
            XmlWriterHelper.WriteOptString(writer, "patient-name", _patientName);
            XmlWriterHelper.WriteOptString(writer, "description", _description);

            foreach (MedicalImageStudySeries imageStudySeries in _series)
            {
                imageStudySeries.WriteXml("series", writer);
            }

            XmlWriterHelper.WriteOpt(writer, "reason", _reason);
            XmlWriterHelper.WriteOptString(writer, "preview-blob-name", _previewBlobName);

            foreach (MedicalImageStudySeriesImage image in _keyImages)
            {
                image.WriteXml("key-images", writer);
            }

            XmlWriterHelper.WriteOptString(writer, "study-instance-uid", _studyInstanceUID);

            writer.WriteEndElement();
        }
Esempio n. 3
0
        /// <summary>
        /// Writes the procedure data to the specified XmlWriter.
        /// </summary>
        ///
        /// <param name="writer">
        /// The XmlWriter to write the procedure data to.
        /// </param>
        ///
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="writer"/> is <b>null</b>.
        /// </exception>
        ///
        /// <exception cref="ThingSerializationException">
        /// The <see cref="Name"/> property has not been set.
        /// </exception>
        ///
        public override void WriteXml(XmlWriter writer)
        {
            Validator.ThrowIfWriterNull(writer);
            Validator.ThrowSerializationIfNull(_name, Resources.ProcedureNameNotSet);

            writer.WriteStartElement("procedure");

            XmlWriterHelper.WriteOpt(
                writer,
                "when",
                _when);

            XmlWriterHelper.WriteOpt(
                writer,
                "name",
                _name);

            XmlWriterHelper.WriteOpt(
                writer,
                "anatomic-location",
                _anatomicLocation);

            XmlWriterHelper.WriteOpt(
                writer,
                "primary-provider",
                _primaryProvider);

            XmlWriterHelper.WriteOpt(
                writer,
                "secondary-provider",
                _secondaryProvider);

            writer.WriteEndElement();
        }
        /// <summary>
        /// Writes the family history person data to the specified XmlWriter.
        /// </summary>
        ///
        /// <param name="writer">
        /// The XmlWriter to write the family history person data to.
        /// </param>
        ///
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="writer"/> parameter is <b>null</b>.
        /// </exception>
        ///
        /// <exception cref="ThingSerializationException">
        /// If <see cref="RelativeName"/> parameter is <b>null</b>.
        /// </exception>
        ///
        public override void WriteXml(XmlWriter writer)
        {
            Validator.ThrowIfWriterNull(writer);
            Validator.ThrowSerializationIfNull(_relativeName, Resources.FamilyHistoryPersonRelativeNameNotSet);

            // <family-history-person>
            writer.WriteStartElement("family-history-person");

            // relative-name
            _relativeName.WriteXml("relative-name", writer);

            // relationship
            XmlWriterHelper.WriteOpt(
                writer,
                "relationship",
                _relationship);

            // date-of-birth
            XmlWriterHelper.WriteOpt(
                writer,
                "date-of-birth",
                _dateOfBirth);

            // date-of-death
            XmlWriterHelper.WriteOpt(
                writer,
                "date-of-death",
                _dateOfDeath);

            // </family-history-person>
            writer.WriteEndElement();
        }
        /// <summary>
        /// Writes the lab test results data to the specified XmlWriter.
        /// </summary>
        ///
        /// <param name="writer">
        /// The XmlWriter to write the lab test results data to.
        /// </param>
        ///
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="writer"/> parameter is <b>null</b>.
        /// </exception>
        ///
        /// <exception cref="ThingSerializationException">
        /// If <see cref="Groups"/> is <b>null</b> or empty.
        /// </exception>
        ///
        public override void WriteXml(XmlWriter writer)
        {
            Validator.ThrowIfWriterNull(writer);

            if (_labGroup == null || _labGroup.Count == 0)
            {
                throw new ThingSerializationException(Resources.LabTestResultsLabGroupNotSet);
            }

            // <lab-test-results>
            writer.WriteStartElement("lab-test-results");

            // when
            XmlWriterHelper.WriteOpt(
                writer,
                "when",
                _when);

            // lab-group
            for (int index = 0; index < _labGroup.Count; ++index)
            {
                _labGroup[index].WriteXml("lab-group", writer);
            }

            // ordered-by
            XmlWriterHelper.WriteOpt(
                writer,
                "ordered-by",
                _orderedBy);

            // </lab-test-results>
            writer.WriteEndElement();
        }
        /// <summary>
        /// Writes the XML representation of the NutritionFact into
        /// the specified XML writer.
        /// </summary>
        ///
        /// <param name="nodeName">
        /// The name of the outer node for the medical image study series.
        /// </param>
        ///
        /// <param name="writer">
        /// The XML writer into which the NutritionFact should be
        /// written.
        /// </param>
        ///
        /// <exception cref="ArgumentException">
        /// If <paramref name="nodeName"/> parameter is <b>null</b> or empty.
        /// </exception>
        ///
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="writer"/> parameter is <b>null</b>.
        /// </exception>
        ///
        /// <exception cref="ThingSerializationException">
        /// If <see cref="Name"/> is <b>null</b>.
        /// </exception>
        ///
        public override void WriteXml(string nodeName, XmlWriter writer)
        {
            if (string.IsNullOrEmpty(nodeName))
            {
                throw new ArgumentException(
                          Resources.WriteXmlEmptyNodeName,
                          "nodeName");
            }

            if (writer == null)
            {
                throw new ArgumentNullException(
                          "writer",
                          Resources.WriteXmlNullWriter);
            }

            if (_name == null)
            {
                throw new ThingSerializationException(
                          Resources.NutrientNameNullValue);
            }

            writer.WriteStartElement(nodeName);

            _name.WriteXml("name", writer);
            XmlWriterHelper.WriteOpt(writer, "fact", _fact);
            writer.WriteEndElement();
        }
Esempio n. 7
0
        /// <summary>
        /// Writes the blood oxygen saturation data to the specified XmlWriter.
        /// </summary>
        ///
        /// <param name="writer">
        /// The XmlWriter to write the blood oxygen saturation data to.
        /// </param>
        ///
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="writer"/> is <b>null</b>.
        /// </exception>
        ///
        /// <exception cref="ThingSerializationException">
        /// If <see cref="When"/> is <b>null</b>.
        /// </exception>
        ///
        public override void WriteXml(XmlWriter writer)
        {
            Validator.ThrowIfWriterNull(writer);
            Validator.ThrowSerializationIfNull(_when, Resources.WhenNullValue);

            // <blood-oxygen-saturation>
            writer.WriteStartElement("blood-oxygen-saturation");

            // <when>
            _when.WriteXml("when", writer);

            // <value>
            writer.WriteElementString(
                "value",
                XmlConvert.ToString(_value));

            // <measurement-method>
            XmlWriterHelper.WriteOpt(
                writer,
                "measurement-method",
                _measurementMethod);

            // <measurement-flags>
            XmlWriterHelper.WriteOpt(
                writer,
                "measurement-flags",
                _measurementFlags);

            // </blood-oxygen-saturation>
            writer.WriteEndElement();
        }
Esempio n. 8
0
        /// <summary>
        /// Writes the peak flow data to the specified XmlWriter.
        /// </summary>
        ///
        /// <param name="writer">
        /// The XmlWriter to write the peak flow data to.
        /// </param>
        ///
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="writer"/> is <b>null</b>.
        /// </exception>
        ///
        /// <exception cref="ThingSerializationException">
        /// If <see cref="When"/> is <b>null</b>.
        /// </exception>
        ///
        public override void WriteXml(XmlWriter writer)
        {
            Validator.ThrowIfWriterNull(writer);
            Validator.ThrowSerializationIfNull(_when, Resources.PeakFlowWhenNotSet);

            // <peak-flow>
            writer.WriteStartElement("peak-flow");

            // <when>
            _when.WriteXml("when", writer);

            XmlWriterHelper.WriteOpt(
                writer,
                "pef",
                _peakExpiratoryFlow);

            XmlWriterHelper.WriteOpt(
                writer,
                "fev1",
                _fev1);

            XmlWriterHelper.WriteOpt(
                writer,
                "fev6",
                _fev6);

            foreach (CodableValue flag in _measurementFlags)
            {
                flag.WriteXml("measurement-flags", writer);
            }

            // </peak-flow>
            writer.WriteEndElement();
        }
Esempio n. 9
0
        /// <summary>
        /// Writes the XML representation of the medical image study series into
        /// the specified XML writer.
        /// </summary>
        ///
        /// <param name="nodeName">
        /// The name of the outer node for the medical image study series.
        /// </param>
        ///
        /// <param name="writer">
        /// The XML writer into which the medical image study series should be
        /// written.
        /// </param>
        ///
        /// <exception cref="ArgumentException">
        /// If <paramref name="nodeName"/> parameter is <b>null</b> or empty.
        /// </exception>
        ///
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="writer"/> parameter is <b>null</b>.
        /// </exception>
        ///
        /// <exception cref="ThingSerializationException">
        /// If <see cref="AcquisitionDateTime"/> is <b>null</b>.
        /// If <see cref="Images"/> is <b>null</b> or doesn't contain any image.
        /// </exception>
        ///
        public override void WriteXml(string nodeName, XmlWriter writer)
        {
            Validator.ThrowIfStringNullOrEmpty(nodeName, "nodeName");
            Validator.ThrowIfWriterNull(writer);

            if (_images == null || _images.Count == 0)
            {
                throw new ThingSerializationException(Resources.ImagesMandatory);
            }

            writer.WriteStartElement(nodeName);

            XmlWriterHelper.WriteOpt(writer, "acquisition-datetime", _acquisitionDateTime);
            XmlWriterHelper.WriteOptString(writer, "description", _description);

            foreach (MedicalImageStudySeriesImage image in _images)
            {
                XmlWriterHelper.WriteOpt(writer, "images", image);
            }

            XmlWriterHelper.WriteOpt(writer, "institution-name", _institutionName);
            XmlWriterHelper.WriteOpt(writer, "modality", _modality);
            XmlWriterHelper.WriteOpt(writer, "body-part", _bodyPart);
            XmlWriterHelper.WriteOptString(writer, "preview-blob-name", _previewBlobName);
            XmlWriterHelper.WriteOptString(writer, "series-instance-uid", _seriesInstanceUID);

            writer.WriteEndElement();
        }
        /// <summary>
        /// Writes the body composition data to the specified XmlWriter.
        /// </summary>
        ///
        /// <param name="writer">
        /// The XmlWriter to write the body composition data to.
        /// </param>
        ///
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="writer"/> is <b>null</b>.
        /// </exception>
        ///
        /// <exception cref="ThingSerializationException">
        /// If <see cref="When"/>, <see cref="MeasurementName"/> or <see cref="Value"/> is <b>null</b>.
        /// </exception>
        ///
        public override void WriteXml(XmlWriter writer)
        {
            Validator.ThrowIfWriterNull(writer);
            Validator.ThrowSerializationIfNull(_when, Resources.WhenNullValue);
            Validator.ThrowSerializationIfNull(_measurementName, Resources.BodyCompositionMeasurementNameNotSet);
            Validator.ThrowSerializationIfNull(_value, Resources.BodyCompositionValueNotSet);

            // <body-composition>
            writer.WriteStartElement("body-composition");

            // <when>
            _when.WriteXml("when", writer);

            // <measurement-name>
            _measurementName.WriteXml("measurement-name", writer);

            // <value>
            _value.WriteXml("value", writer);

            // <measurement-method>
            XmlWriterHelper.WriteOpt(
                writer,
                "measurement-method",
                _measurementMethod);

            // <site>
            XmlWriterHelper.WriteOpt(
                writer,
                "site",
                _site);

            // </body-composition>
            writer.WriteEndElement();
        }
Esempio n. 11
0
        /// <summary>
        /// Writes the lab test result value type data to the specified XmlWriter.
        /// </summary>
        ///
        /// <param name="nodeName">
        /// The name of the node to write the XML.</param>
        ///
        /// <param name="writer">
        /// The XmlWriter to write the lab test result value type data to.
        /// </param>
        ///
        /// <exception cref="ArgumentException">
        /// If <paramref name="nodeName"/> is <b> null </b> or empty.
        /// </exception>
        ///
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="writer"/> is <b> null </b>.
        /// </exception>
        ///
        /// <exception cref="ThingSerializationException">
        /// If <see cref="Measurement"/> is <b> null </b>.
        /// </exception>
        ///
        public override void WriteXml(string nodeName, XmlWriter writer)
        {
            Validator.ThrowIfStringNullOrEmpty(nodeName, "nodeName");
            Validator.ThrowIfWriterNull(writer);
            Validator.ThrowSerializationIfNull(_measurement, Resources.LabTestResultValueTypeMeasurementNotSet);

            // <lab-test-result-value-type>
            writer.WriteStartElement(nodeName);

            // measurement
            _measurement.WriteXml("measurement", writer);

            // ranges
            for (int index = 0; index < _ranges.Count; ++index)
            {
                XmlWriterHelper.WriteOpt(
                    writer,
                    "ranges",
                    _ranges[index]);
            }

            // flag
            for (int index = 0; index < _flag.Count; ++index)
            {
                XmlWriterHelper.WriteOpt(
                    writer,
                    "flag",
                    _flag[index]);
            }

            // </lab-test-result-value-type>
            writer.WriteEndElement();
        }
Esempio n. 12
0
        /// <summary>
        /// Writes the XML representation of the Service into
        /// the specified XML writer.
        /// </summary>
        ///
        /// <param name="nodeName">
        /// The name of the outer node for the Service.
        /// </param>
        ///
        /// <param name="writer">
        /// The XML writer into which the Service should be
        /// written.
        /// </param>
        ///
        /// <exception cref="ArgumentException">
        /// If <paramref name="nodeName"/> parameter is <b>null</b> or empty.
        /// </exception>
        ///
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="writer"/> parameter is <b>null</b>.
        /// </exception>
        ///
        /// <exception cref="ThingSerializationException">
        /// If <see cref="ServiceType"/> is <b>null</b>.
        /// If <see cref="ServiceDates"/> is <b>null</b>.
        /// If <see cref="ClaimAmounts"/> is <b>null</b>.
        /// </exception>
        ///
        public override void WriteXml(string nodeName, XmlWriter writer)
        {
            Validator.ThrowIfStringNullOrEmpty(nodeName, "nodeName");
            Validator.ThrowIfWriterNull(writer);
            Validator.ThrowSerializationIfNull(_serviceType, Resources.ServiceTypeNullValue);
            Validator.ThrowSerializationIfNull(_serviceDates, Resources.ServiceDatesNullValue);
            Validator.ThrowSerializationIfNull(_claimAmounts, Resources.ClaimAmountsNullValue);

            writer.WriteStartElement(nodeName);

            _serviceType.WriteXml("service-type", writer);

            XmlWriterHelper.WriteOpt(writer, "diagnosis", _diagnosis);
            XmlWriterHelper.WriteOpt(writer, "billing-code", _billingCode);

            _serviceDates.WriteXml("service-dates", writer);
            _claimAmounts.WriteXml("claim-amounts", writer);

            foreach (string note in _notes)
            {
                writer.WriteElementString("notes", note);
            }

            writer.WriteEndElement();
        }
Esempio n. 13
0
        /// <summary>
        /// Writes the contraindication data to the specified XmlWriter.
        /// </summary>
        ///
        /// <param name="writer">
        /// The XmlWriter to write the contraindication data to.
        /// </param>
        ///
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="writer"/> is <b>null</b>.
        /// </exception>
        ///
        /// <exception cref="ThingSerializationException">
        /// The <see cref="Substance"/> or <see cref="Status"/> property has not been set.
        /// </exception>
        ///
        public override void WriteXml(XmlWriter writer)
        {
            Validator.ThrowIfWriterNull(writer);
            Validator.ThrowSerializationIfNull(_substance, Resources.ContraindicationSubstanceNotSet);
            Validator.ThrowSerializationIfNull(_status, Resources.ContraindicationStatusNotSet);

            // <contraindication>
            writer.WriteStartElement("contraindication");

            // <substance>
            _substance.WriteXml("substance", writer);

            // <status>
            _status.WriteXml("status", writer);

            // <source>
            XmlWriterHelper.WriteOpt(writer, "source", _source);

            // <documenter>
            XmlWriterHelper.WriteOpt(writer, "documenter", _documenter);

            // <documented-date>
            XmlWriterHelper.WriteOpt(writer, "documented-date", _documentedDate);

            // </contraindication>
            writer.WriteEndElement();
        }
Esempio n. 14
0
        /// <summary>
        /// Writes the XML representation of the GoalRange into
        /// the specified XML writer.
        /// </summary>
        ///
        /// <param name="nodeName">
        /// The name of the outer node for the medical image study series.
        /// </param>
        ///
        /// <param name="writer">
        /// The XML writer into which the GoalRange should be
        /// written.
        /// </param>
        ///
        /// <exception cref="ArgumentException">
        /// If <paramref name="nodeName"/> parameter is <b>null</b> or empty.
        /// </exception>
        ///
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="writer"/> parameter is <b>null</b>.
        /// </exception>
        ///
        /// <exception cref="ThingSerializationException">
        /// If <see cref="Name"/> is <b>null</b>.
        /// </exception>
        ///
        public override void WriteXml(string nodeName, XmlWriter writer)
        {
            if (string.IsNullOrEmpty(nodeName))
            {
                throw new ArgumentException(
                          Resources.WriteXmlEmptyNodeName,
                          nameof(nodeName));
            }

            if (writer == null)
            {
                throw new ArgumentNullException(
                          nameof(writer),
                          Resources.WriteXmlNullWriter);
            }

            if (_name == null)
            {
                throw new ThingSerializationException(
                          Resources.GoalRangeNameNullValue);
            }

            writer.WriteStartElement(nodeName);

            _name.WriteXml("name", writer);
            XmlWriterHelper.WriteOptString(writer, "description", _description);
            XmlWriterHelper.WriteOpt(writer, "minimum", _minimum);
            XmlWriterHelper.WriteOpt(writer, "maximum", _maximum);
            writer.WriteEndElement();
        }
Esempio n. 15
0
        /// <summary>
        /// Writes the appointment data to the specified XmlWriter.
        /// </summary>
        ///
        /// <param name="writer">
        /// The XmlWriter to write the appointment data to.
        /// </param>
        ///
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="writer"/> is <b>null</b>.
        /// </exception>
        ///
        public override void WriteXml(XmlWriter writer)
        {
            Validator.ThrowIfArgumentNull(writer, nameof(writer), Resources.WriteXmlNullWriter);
            Validator.ThrowSerializationIfNull(_when, Resources.AppointmentWhenNotSet);

            // <appointment>
            writer.WriteStartElement("appointment");

            // <when>
            _when.WriteXml("when", writer);

            // <duration>
            XmlWriterHelper.WriteOpt(
                writer,
                "duration",
                _duration);

            // <service>
            Service?.WriteXml("service", writer);

            // <clinic>
            Clinic?.WriteXml("clinic", writer);

            // <specialty>
            Specialty?.WriteXml("specialty", writer);

            // <status>
            Status?.WriteXml("status", writer);

            // <care-class>
            CareClass?.WriteXml("care-class", writer);

            // </appointment>
            writer.WriteEndElement();
        }
Esempio n. 16
0
        /// <summary>
        /// Writes the XML representation of the CarePlanGoal into
        /// the specified XML writer.
        /// </summary>
        ///
        /// <param name="nodeName">
        /// The name of the outer node for the medical image study series.
        /// </param>
        ///
        /// <param name="writer">
        /// The XML writer into which the CarePlanGoal should be
        /// written.
        /// </param>
        ///
        /// <exception cref="ArgumentException">
        /// If <paramref name="nodeName"/> parameter is <b>null</b> or empty.
        /// </exception>
        ///
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="writer"/> parameter is <b>null</b>.
        /// </exception>
        ///
        /// <exception cref="ThingSerializationException">
        /// If <see cref="Name"/> is <b>null</b>.
        /// </exception>
        ///
        public override void WriteXml(string nodeName, XmlWriter writer)
        {
            Validator.ThrowIfStringNullOrEmpty(nodeName, "nodeName");
            Validator.ThrowIfArgumentNull(writer, nameof(writer), Resources.WriteXmlNullWriter);

            Validator.ThrowSerializationIfNull(_name, Resources.CarePlanGoalNameNull);

            writer.WriteStartElement("goal");
            {
                _name.WriteXml("name", writer);
                XmlWriterHelper.WriteOptString(writer, "description", _description);
                XmlWriterHelper.WriteOpt(writer, "start-date", _startDate);
                XmlWriterHelper.WriteOpt(writer, "end-date", _endDate);
                XmlWriterHelper.WriteOpt(writer, "target-completion-date", _targetCompletionDate);
                XmlWriterHelper.WriteOpt(writer, "associated-type-info", _goalAssociatedTypeInfo);
                XmlWriterHelper.WriteOpt(writer, "target-range", _targetRange);

                if (_goalAdditionalRanges != null && _goalAdditionalRanges.Count != 0)
                {
                    foreach (GoalRange goalRange in _goalAdditionalRanges)
                    {
                        goalRange.WriteXml("goal-additional-ranges", writer);
                    }
                }

                XmlWriterHelper.WriteOpt(writer, "recurrence", _recurrence);
                XmlWriterHelper.WriteOptString(writer, "reference-id", _referenceId);
            }

            writer.WriteEndElement();
        }
        /// <summary>
        /// Writes the lab test type data to the specified XML writer.
        /// </summary>
        ///
        /// <param name="nodeName">
        /// The name of the outer element for the lab test type.
        /// </param>
        ///
        /// <param name="writer">
        /// The XmlWriter to write the lab test type to.
        /// </param>
        ///
        /// <exception cref="ArgumentException">
        /// The <paramref name="nodeName"/> parameter is <b>null</b> or empty.
        /// </exception>
        ///
        /// <exception cref="ArgumentNullException">
        /// The <paramref name="writer"/> parameter is <b>null</b>.
        /// </exception>
        ///
        public override void WriteXml(string nodeName, XmlWriter writer)
        {
            Validator.ThrowIfStringNullOrEmpty(nodeName, "nodeName");
            Validator.ThrowIfWriterNull(writer);

            writer.WriteStartElement(nodeName);

            _when = new HealthServiceDateTime();
            _when.WriteXml("when", writer);

            XmlWriterHelper.WriteOptString(writer, "name", _name);
            XmlWriterHelper.WriteOpt(writer, "substance", _substance);
            XmlWriterHelper.WriteOpt(writer, "collection-method", _collectionMethod);
            XmlWriterHelper.WriteOptString(writer, "abbreviation", _abbreviation);
            XmlWriterHelper.WriteOptString(writer, "description", _description);

            foreach (CodableValue codeValue in _code)
            {
                codeValue.WriteXml("code", writer);
            }

            XmlWriterHelper.WriteOpt(writer, "result", _result);
            XmlWriterHelper.WriteOpt(writer, "status", _status);

            writer.WriteEndElement();
        }
        /// <summary>
        /// Writes the XML representation of the HealthGoal into
        /// the specified XML writer.
        /// </summary>
        ///
        /// <param name="writer">
        /// The XML writer into which the HealthGoal should be
        /// written.
        /// </param>
        ///
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="writer"/> parameter is <b>null</b>.
        /// </exception>
        ///
        /// <exception cref="ThingSerializationException">
        /// If <see cref="Name"/> is <b>null</b>.
        /// </exception>
        ///
        public override void WriteXml(XmlWriter writer)
        {
            if (writer == null)
            {
                throw new ArgumentNullException(
                          nameof(writer),
                          Resources.WriteXmlNullWriter);
            }

            if (_name == null)
            {
                throw new ThingSerializationException(
                          Resources.GoalNameNullValue);
            }

            writer.WriteStartElement("health-goal");

            _name.WriteXml("name", writer);
            XmlWriterHelper.WriteOptString(writer, "description", _description);
            XmlWriterHelper.WriteOpt(writer, "start-date", _startDate);
            XmlWriterHelper.WriteOpt(writer, "end-date", _endDate);
            XmlWriterHelper.WriteOpt(writer, "associated-type-info", _associatedTypeInfo);
            XmlWriterHelper.WriteOpt(writer, "target-range", _targetRange);

            if (_goalAdditionalRanges != null && _goalAdditionalRanges.Count != 0)
            {
                foreach (GoalRange goalRange in _goalAdditionalRanges)
                {
                    goalRange.WriteXml("goal-additional-ranges", writer);
                }
            }

            XmlWriterHelper.WriteOpt(writer, "recurrence", _recurrence);
            writer.WriteEndElement();
        }
        /// <summary>
        /// Writes the XML representation of the delivery into
        /// the specified XML writer.
        /// </summary>
        ///
        /// <param name="nodeName">
        /// The name of the outer node for the delivery.
        /// </param>
        ///
        /// <param name="writer">
        /// The XML writer into which the delivery should be
        /// written.
        /// </param>
        ///
        /// <exception cref="ArgumentException">
        /// The <paramref name="nodeName"/> parameter is <b>null</b> or empty.
        /// </exception>
        ///
        /// <exception cref="ArgumentNullException">
        /// The <paramref name="writer"/> parameter is <b>null</b>.
        /// </exception>
        ///
        public override void WriteXml(string nodeName, XmlWriter writer)
        {
            Validator.ThrowIfStringNullOrEmpty(nodeName, "nodeName");
            Validator.ThrowIfWriterNull(writer);

            writer.WriteStartElement(nodeName);

            XmlWriterHelper.WriteOpt(writer, "location", _location);
            XmlWriterHelper.WriteOpt(writer, "time-of-delivery", _timeOfDelivery);
            XmlWriterHelper.WriteOptDouble(writer, "labor-duration", _laborDuration);

            foreach (CodableValue complication in _complications)
            {
                complication.WriteXml("complications", writer);
            }

            foreach (CodableValue anesthesia in _anesthesia)
            {
                anesthesia.WriteXml("anesthesia", writer);
            }

            XmlWriterHelper.WriteOpt(writer, "delivery-method", _deliveryMethod);
            XmlWriterHelper.WriteOpt(writer, "outcome", _outcome);
            XmlWriterHelper.WriteOpt(writer, "baby", _baby);
            XmlWriterHelper.WriteOptString(writer, "note", _note);

            writer.WriteEndElement();
        }
        /// <summary>
        /// Writes the family history relative data to the specified XmlWriter.
        /// </summary>
        ///
        /// <param name="nodeName">
        /// The name of the outer node for the family history relative item.
        /// </param>
        ///
        /// <param name="writer">
        /// The XmlWriter to write the family history relative data to.
        /// </param>
        ///
        /// <exception cref="ArgumentException">
        /// If <paramref name="nodeName"/> is <b> null </b> or empty.
        /// </exception>
        ///
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="writer"/> is <b> null </b>.
        /// </exception>
        ///
        /// <exception cref="ThingSerializationException">
        /// If <see cref="Name"/> is <b> null </b>.
        /// </exception>
        ///
        public override void WriteXml(string nodeName, XmlWriter writer)
        {
            Validator.ThrowIfStringNullOrEmpty(nodeName, "nodeName");
            Validator.ThrowIfWriterNull(writer);

            // <family-history-relative>
            writer.WriteStartElement(nodeName);

            // relative-name
            XmlWriterHelper.WriteOpt(
                writer,
                "relative-name",
                _relativeName);

            // relationship
            XmlWriterHelper.WriteOpt(
                writer,
                "relationship",
                _relationship);

            // date-of-birth
            XmlWriterHelper.WriteOpt(
                writer,
                "date-of-birth",
                _dateOfBirth);

            // date-of-death
            XmlWriterHelper.WriteOpt(
                writer,
                "date-of-death",
                _dateOfDeath);

            // </family-history-relative>
            writer.WriteEndElement();
        }
Esempio n. 21
0
        /// <summary>
        /// Writes the respiratory profile data to the specified XmlWriter.
        /// </summary>
        ///
        /// <param name="writer">
        /// The XmlWriter to write the respiratory profile data to.
        /// </param>
        ///
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="writer"/> is <b>null</b>.
        /// </exception>
        ///
        public override void WriteXml(XmlWriter writer)
        {
            Validator.ThrowIfWriterNull(writer);

            // <respiratory-profile>
            writer.WriteStartElement("respiratory-profile");

            // <when>
            _when.WriteXml("when", writer);

            XmlWriterHelper.WriteOpt(
                writer,
                "expiratory-flow-red-zone-upper-boundary",
                _expiratoryFlowRedZoneUpperBoundary);

            XmlWriterHelper.WriteOpt(
                writer,
                "expiratory-flow-orange-zone-upper-boundary",
                _expiratoryFlowOrangeZoneUpperBoundary);

            XmlWriterHelper.WriteOpt(
                writer,
                "expiratory-flow-yellow-zone-upper-boundary",
                _expiratoryFlowYellowZoneUpperBoundary);

            // </respiratory-profile>
            writer.WriteEndElement();
        }
Esempio n. 22
0
        /// <summary>
        /// Writes the application specific data to the specified XmlWriter.
        /// </summary>
        ///
        /// <param name="writer">
        /// The XmlWriter to write the application specific data to.
        /// </param>
        ///
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="writer"/> is <b>null</b>.
        /// </exception>
        ///
        /// <exception cref="ThingSerializationException">
        /// If <see cref="ApplicationId"/>, <see cref="SubtypeTag"/>, or <see cref="Description"/> is <b>null</b> or empty.
        /// </exception>
        ///
        public override void WriteXml(XmlWriter writer)
        {
            Validator.ThrowIfArgumentNull(writer, nameof(writer), Resources.WriteXmlNullWriter);

            Validator.ThrowSerializationIfNull(ApplicationId, Resources.AppSpecificAppIdMandatory);

            Validator.ThrowSerializationIfNull(SubtypeTag, Resources.AppSpecificTagMandatory);

            Validator.ThrowSerializationIfNull(Description, Resources.AppSpecificDescriptionMandatory);

            // <app-specific>
            writer.WriteStartElement("app-specific");

            // <format-appid>
            writer.WriteElementString("format-appid", ApplicationId);

            // <format-tag>
            writer.WriteElementString("format-tag", SubtypeTag);

            // <when>
            XmlWriterHelper.WriteOpt(
                writer,
                "when",
                _when);

            // <summary>
            writer.WriteElementString("summary", Description);

            // the any node
            WriteApplicationSpecificXml(writer);

            // </app-specific>
            writer.WriteEndElement();
        }
        /// <summary>
        /// Writes the lab test result type data to the specified XmlWriter.
        /// </summary>
        ///
        /// <param name="nodeName">
        /// The name of the node to write XML output.
        /// </param>
        ///
        /// <param name="writer">
        /// The XmlWriter to write the lab test result type data to.
        /// </param>
        ///
        /// <exception cref="ArgumentException">
        /// If <paramref name="nodeName"/> is <b> null </b> or empty.
        /// </exception>
        ///
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="writer"/> is <b> null </b>.
        /// </exception>
        ///
        public override void WriteXml(string nodeName, XmlWriter writer)
        {
            Validator.ThrowIfStringNullOrEmpty(nodeName, "nodeName");
            Validator.ThrowIfWriterNull(writer);

            // <lab-test-result-type>
            writer.WriteStartElement(nodeName);

            // when
            XmlWriterHelper.WriteOpt(
                writer,
                "when",
                _when);

            // name
            XmlWriterHelper.WriteOptString(
                writer,
                "name",
                _name);

            // substance
            XmlWriterHelper.WriteOpt(
                writer,
                "substance",
                _substance);

            // collection-method
            XmlWriterHelper.WriteOpt(
                writer,
                "collection-method",
                _collectionMethod);

            // clinical-code
            XmlWriterHelper.WriteOpt(
                writer,
                "clinical-code",
                _clinicalCode);

            // value
            XmlWriterHelper.WriteOpt(
                writer,
                "value",
                _value);

            // status
            XmlWriterHelper.WriteOpt(
                writer,
                "status",
                _status);

            // note
            XmlWriterHelper.WriteOptString(
                writer,
                "note",
                _note);

            // </lab-test-result-type>
            writer.WriteEndElement();
        }
        /// <summary>
        /// Writes the XML representation of the DietaryIntake into
        /// the specified XML writer.
        /// </summary>
        ///
        /// <param name="nodeName">
        /// The name of the outer node for the dietary intake item.
        /// </param>
        ///
        /// <param name="writer">
        /// The XML writer into which the DietaryIntake should be
        /// written.
        /// </param>
        ///
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="writer"/> parameter is <b>null</b>.
        /// </exception>
        ///
        /// <exception cref="ThingSerializationException">
        /// If <see cref="FoodItem"/> is <b>null</b>.
        /// </exception>
        ///
        public override void WriteXml(string nodeName, XmlWriter writer)
        {
            Validator.ThrowIfStringNullOrEmpty(nodeName, "WriteXmlEmptyNodeName");
            Validator.ThrowIfWriterNull(writer);
            Validator.ThrowSerializationIfNull(_foodItem, Resources.FoodItemNullValue);

            writer.WriteStartElement(nodeName);

            _foodItem.WriteXml("food-item", writer);
            XmlWriterHelper.WriteOpt(writer, "serving-size", _servingSize);
            XmlWriterHelper.WriteOptDouble(writer, "servings-consumed", _servingsConsumed);
            XmlWriterHelper.WriteOpt(writer, "meal", _meal);
            XmlWriterHelper.WriteOpt(writer, "when", _when);
            XmlWriterHelper.WriteOpt(writer, "energy", _energy);
            XmlWriterHelper.WriteOpt(writer, "energy-from-fat", _energyFromFat);
            XmlWriterHelper.WriteOpt(writer, "total-fat", _totalFat);
            XmlWriterHelper.WriteOpt(writer, "saturated-fat", _saturatedFat);
            XmlWriterHelper.WriteOpt(writer, "trans-fat", _transFat);
            XmlWriterHelper.WriteOpt(writer, "monounsaturated-fat", _monounsaturatedFat);
            XmlWriterHelper.WriteOpt(writer, "polyunsaturated-fat", _polyunsaturatedFat);
            XmlWriterHelper.WriteOpt(writer, "protein", _protein);
            XmlWriterHelper.WriteOpt(writer, "carbohydrates", _carbohydrates);
            XmlWriterHelper.WriteOpt(writer, "dietary-fiber", _dietaryFiber);
            XmlWriterHelper.WriteOpt(writer, "sugars", _sugars);
            XmlWriterHelper.WriteOpt(writer, "sodium", _sodium);
            XmlWriterHelper.WriteOpt(writer, "cholesterol", _cholesterol);
            XmlWriterHelper.WriteOpt(writer, "calcium", _calcium);
            XmlWriterHelper.WriteOpt(writer, "iron", _iron);
            XmlWriterHelper.WriteOpt(writer, "magnesium", _magnesium);
            XmlWriterHelper.WriteOpt(writer, "phosphorus", _phosphorus);
            XmlWriterHelper.WriteOpt(writer, "potassium", _potassium);
            XmlWriterHelper.WriteOpt(writer, "zinc", _zinc);
            XmlWriterHelper.WriteOpt(writer, "vitamin-A-RAE", _vitaminARAE);
            XmlWriterHelper.WriteOpt(writer, "vitamin-E", _vitaminE);
            XmlWriterHelper.WriteOpt(writer, "vitamin-D", _vitaminD);
            XmlWriterHelper.WriteOpt(writer, "vitamin-C", _vitaminC);
            XmlWriterHelper.WriteOpt(writer, "thiamin", _thiamin);
            XmlWriterHelper.WriteOpt(writer, "riboflavin", _riboflavin);
            XmlWriterHelper.WriteOpt(writer, "niacin", _niacin);
            XmlWriterHelper.WriteOpt(writer, "vitamin-B-6", _vitaminB6);
            XmlWriterHelper.WriteOpt(writer, "folate-DFE", _folateDFE);
            XmlWriterHelper.WriteOpt(writer, "vitamin-B-12", _vitaminB12);
            XmlWriterHelper.WriteOpt(writer, "vitamin-K", _vitaminK);

            if (_additionalNutritionFacts.Count != 0)
            {
                writer.WriteStartElement("additional-nutrition-facts");

                foreach (NutritionFact nutritionFact in _additionalNutritionFacts)
                {
                    nutritionFact.WriteXml("nutrition-fact", writer);
                }

                writer.WriteEndElement();
            }

            writer.WriteEndElement();
        }
Esempio n. 25
0
        /// <summary>
        /// Writes the prescription data to the specified XmlWriter.
        /// </summary>
        ///
        /// <param name="nodeName">
        /// The name of the outer element for the prescription data.
        /// </param>
        ///
        /// <param name="writer">
        /// The XmlWriter to write the prescription data to.
        /// </param>
        ///
        /// <exception cref="ArgumentException">
        /// The <paramref name="nodeName"/> parameter is <b>null</b> or empty.
        /// </exception>
        ///
        /// <exception cref="ArgumentNullException">
        /// The <paramref name="writer"/> parameter is <b>null</b>.
        /// </exception>
        ///
        /// <exception cref="ThingSerializationException">
        /// The <see cref="PrescribedBy"/> property has not been set.
        /// </exception>
        ///
        public override void WriteXml(string nodeName, XmlWriter writer)
        {
            Validator.ThrowIfStringNullOrEmpty(nodeName, "nodeName");
            Validator.ThrowIfWriterNull(writer);
            Validator.ThrowSerializationIfNull(_prescribedBy, Resources.PrescriptionPrescribedByNotSet);

            // <prescription>
            writer.WriteStartElement(nodeName);

            _prescribedBy.WriteXml("prescribed-by", writer);

            // <date-prescribed>
            XmlWriterHelper.WriteOpt(
                writer,
                "date-prescribed",
                _datePrescribed);

            // <amount-prescribed>
            XmlWriterHelper.WriteOpt(
                writer,
                "amount-prescribed",
                _amountPrescribed);

            // <substitution>
            XmlWriterHelper.WriteOpt(
                writer,
                "substitution",
                _substitution);

            // <refills>
            XmlWriterHelper.WriteOptInt(
                writer,
                "refills",
                _refills);

            // <days-supply>
            XmlWriterHelper.WriteOptInt(
                writer,
                "days-supply",
                _daysSupply);

            // <prescription-expiration>
            XmlWriterHelper.WriteOpt(
                writer,
                "prescription-expiration",
                _expiration);

            // <instructions>
            XmlWriterHelper.WriteOpt(
                writer,
                "instructions",
                _instructions);

            // </prescription>
            writer.WriteEndElement();
        }
        public override void WriteXml(XmlWriter writer)
        {
            Validator.ThrowIfWriterNull(writer);
            Validator.ThrowSerializationIfNull(_when, Resources.WhenNullValue);
            Validator.ThrowSerializationIfNull(_name, Resources.ExerciseSampleNameNotSet);
            Validator.ThrowSerializationIfNull(_unit, Resources.ExerciseSampleUnitNotSet);

            if (double.IsNaN(_samplingInterval))
            {
                throw new ThingSerializationException(Resources.ExerciseSampleSamplingIntervalNotSet);
            }

            if (_sampleData != null && _sampleData.SingleValuedSamples.Count > 0)
            {
                // This ensures that the data gets written to a string in _sampleData.Data
                using (MemoryStream stream = new MemoryStream(1024))
                {
                    using (XmlWriter unusedWriter = XmlWriter.Create(stream))
                    {
                        _sampleData.WriteXml(unusedWriter);
                    }
                }

                Blob blob =
                    GetBlobStore(default(HealthRecordAccessor)).NewBlob(
                        string.Empty,
                        _sampleData.ContentType);
                blob.WriteInline(_sampleData.Data);
            }

            // <exercise-samples>
            writer.WriteStartElement("exercise-samples");

            // <when>
            _when.WriteXml("when", writer);

            // <name>
            XmlWriterHelper.WriteOpt(
                writer,
                "name",
                _name);

            // <unit>
            XmlWriterHelper.WriteOpt(
                writer,
                "unit",
                _unit);

            // <sampling-interval>
            writer.WriteElementString(
                "sampling-interval",
                XmlConvert.ToString(_samplingInterval));

            // </exercise-samples>
            writer.WriteEndElement();
        }
        /// <summary>
        /// Writes the allergy data to the specified XmlWriter.
        /// </summary>
        ///
        /// <param name="writer">
        /// The XmlWriter to write the allergy data to.
        /// </param>
        ///
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="writer"/> is <b>null</b>.
        /// </exception>
        ///
        /// <exception cref="ThingSerializationException">
        /// If <see cref="Name"/> has an <b>null</b> Text property.
        /// </exception>
        ///
        public override void WriteXml(XmlWriter writer)
        {
            Validator.ThrowIfArgumentNull(writer, nameof(writer), Resources.WriteXmlNullWriter);
            Validator.ThrowSerializationIfNull(_name.Text, Resources.AllergyNameMandatory);

            // <allergy>
            writer.WriteStartElement("allergy");

            // <name>
            _name.WriteXml("name", writer);

            // <reaction>
            XmlWriterHelper.WriteOpt(
                writer,
                "reaction",
                Reaction);

            // <first-observed>
            XmlWriterHelper.WriteOpt(
                writer,
                "first-observed",
                FirstObserved);

            // <allergen-type>
            XmlWriterHelper.WriteOpt(
                writer,
                "allergen-type",
                AllergenType);

            // <allergen-code>
            XmlWriterHelper.WriteOpt(
                writer,
                "allergen-code",
                AllergenCode);

            // <treatment-provider>
            XmlWriterHelper.WriteOpt(
                writer,
                "treatment-provider",
                TreatmentProvider);

            // <treatment>
            XmlWriterHelper.WriteOpt(
                writer,
                "treatment",
                Treatment);

            // <is-negated>
            XmlWriterHelper.WriteOptBool(
                writer,
                "is-negated",
                _isNegated);

            // </allergy>
            writer.WriteEndElement();
        }
Esempio n. 28
0
        /// <summary>
        /// Writes the XML representation of the MealDefinition into
        /// the specified XML writer.
        /// </summary>
        ///
        /// <param name="writer">
        /// The XML writer into which the MealDefinition should be
        /// written.
        /// </param>
        ///
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="writer"/> parameter is <b>null</b>.
        /// </exception>
        ///
        /// <exception cref="ThingSerializationException">
        /// If <see cref="Name"/> is <b>null</b>.
        /// </exception>
        ///
        public override void WriteXml(XmlWriter writer)
        {
            Validator.ThrowIfWriterNull(writer);
            Validator.ThrowSerializationIfNull(_name, Resources.MealDefinitionNameNullValue);

            writer.WriteStartElement("meal-definition");
            _name.WriteXml("name", writer);
            XmlWriterHelper.WriteOpt(writer, "meal-type", _mealType);
            XmlWriterHelper.WriteOptString(writer, "description", _description);
            XmlWriterHelper.WriteXmlCollection(writer, "dietary-items", _dietaryIntakeItems, "dietary-item");
            writer.WriteEndElement();
        }
        /// <summary>
        /// Writes the XML representation of the vital sign result into
        /// the specified XML writer.
        /// </summary>
        ///
        /// <param name="nodeName">
        /// The name of the outer node for the vital sign result.
        /// </param>
        ///
        /// <param name="writer">
        /// The XML writer into which the vital sign result should be
        /// written.
        /// </param>
        ///
        /// <exception cref="ArgumentException">
        /// The <paramref name="nodeName"/> parameter is <b>null</b> or empty.
        /// </exception>
        ///
        /// <exception cref="ArgumentNullException">
        /// The <paramref name="writer"/> parameter is <b>null</b>.
        /// </exception>
        ///
        /// <exception cref="ThingSerializationException">
        /// If <see cref="Title"/> is <b>null</b>.
        /// </exception>
        ///
        public override void WriteXml(string nodeName, XmlWriter writer)
        {
            Validator.ThrowIfStringNullOrEmpty(nodeName, "nodeName");
            Validator.ThrowIfWriterNull(writer);
            Validator.ThrowSerializationIfNull(_title, Resources.VitalSignResultTitleNotSet);
            Validator.ThrowSerializationIfNull(_title.Text, Resources.CodableValueNullText);

            writer.WriteStartElement(nodeName);

            // <title>
            _title.WriteXml("title", writer);

            // <value>
            XmlWriterHelper.WriteOptDouble(
                writer,
                "value",
                _value);

            // <unit>
            XmlWriterHelper.WriteOpt(
                writer,
                "unit",
                _unit);

            // <reference-minimum>
            XmlWriterHelper.WriteOptDouble(
                writer,
                "reference-minimum",
                _referenceMinimum);

            // <reference-maximum>
            XmlWriterHelper.WriteOptDouble(
                writer,
                "reference-maximum",
                _referenceMaximum);

            // <text-value>
            XmlWriterHelper.WriteOptString(
                writer,
                "text-value",
                _textValue);

            // <flag>
            XmlWriterHelper.WriteOpt(
                writer,
                "flag",
                _flag);

            writer.WriteEndElement();
        }
Esempio n. 30
0
        /// <summary>
        /// Writes the medical device data to the specified XmlWriter.
        /// </summary>
        ///
        /// <param name="writer">
        /// The XmlWriter to write the medical device data to.
        /// </param>
        ///
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="writer"/> is <b>null</b>.
        /// </exception>
        ///
        /// <exception cref="ThingSerializationException">
        /// If <see cref="When"/> has not been set.
        /// </exception>
        ///
        public override void WriteXml(XmlWriter writer)
        {
            Validator.ThrowIfWriterNull(writer);
            Validator.ThrowSerializationIfNull(_when, Resources.DeviceWhenNotSet);

            // <device>
            writer.WriteStartElement("device");

            // <when>
            _when.WriteXml("when", writer);

            // <device-name>
            XmlWriterHelper.WriteOptString(
                writer,
                "device-name",
                _deviceName);

            // <vendor>
            XmlWriterHelper.WriteOpt(
                writer,
                "vendor",
                _vendor);

            // <model>
            XmlWriterHelper.WriteOptString(
                writer,
                "model",
                _model);

            // <serial-number>
            XmlWriterHelper.WriteOptString(
                writer,
                "serial-number",
                _serialNumber);

            // <anatomic-site>
            XmlWriterHelper.WriteOptString(
                writer,
                "anatomic-site",
                _anatomicSite);

            // <description>
            XmlWriterHelper.WriteOptString(
                writer,
                "description",
                _description);

            // </device>
            writer.WriteEndElement();
        }