Beispiel #1
0
        /// <summary>
        /// Writes the health problem data to the specified XmlWriter.
        /// </summary>
        ///
        /// <param name="writer">
        /// The XmlWriter to write the health problem data to.
        /// </param>
        ///
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="writer"/> is <b>null</b>.
        /// </exception>
        ///
        /// <exception cref="ThingSerializationException">
        /// The <see cref="When"/> property has not been set.
        /// </exception>
        ///
        public override void WriteXml(XmlWriter writer)
        {
            Validator.ThrowIfWriterNull(writer);
            Validator.ThrowSerializationIfNull(_when, Resources.ProblemWhenNotSet);

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

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

            // <diagnosis>
            foreach (CodableValue value in _diagnosis)
            {
                value.WriteXml("diagnosis", writer);
            }

            // <duration>
            foreach (DurationValue value in _duration)
            {
                value.WriteXml("duration", writer);
            }

            // <importance>
            XmlWriterHelper.WriteOptInt(
                writer,
                "importance",
                _importance);

            // </problem>
            writer.WriteEndElement();
        }
Beispiel #2
0
        /// <summary>
        /// Writes the XML representation of the GoalRecurrence 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 GoalRecurrence 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="Interval"/> 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 (_interval == null)
            {
                throw new ThingSerializationException(
                          Resources.GoalRecurrenceIntervalNullValue);
            }

            writer.WriteStartElement(nodeName);

            _interval.WriteXml("interval", writer);
            XmlWriterHelper.WriteOptInt(writer, "times-in-interval", _timesInInterval);
            writer.WriteEndElement();
        }
Beispiel #3
0
        /// <summary>
        /// Writes the cholesterol profile data to the specified XmlWriter.
        /// </summary>
        ///
        /// <param name="writer">
        /// The XmlWriter to write the cholesterol 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);

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

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

            XmlWriterHelper.WriteOptInt(
                writer,
                "ldl",
                _ldl);

            XmlWriterHelper.WriteOptInt(
                writer,
                "hdl",
                _hdl);

            XmlWriterHelper.WriteOptInt(
                writer,
                "total-cholesterol",
                _totalCholesterol);

            XmlWriterHelper.WriteOptInt(
                writer,
                "triglyceride",
                _triglyceride);

            // </cholesterol-profile>
            writer.WriteEndElement();
        }
Beispiel #4
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();
        }
        /// <summary>
        /// Writes the daily medication usage data to the specified XmlWriter.
        /// </summary>
        ///
        /// <param name="writer">
        /// The XmlWriter to write the daily medication usage data to.
        /// </param>
        ///
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="writer"/> is <b> null </b>.
        /// </exception>
        ///
        /// <exception cref="ThingSerializationException">
        /// If <see cref="DrugName"/> is <b> null </b>.
        /// </exception>
        ///
        public override void WriteXml(XmlWriter writer)
        {
            Validator.ThrowIfWriterNull(writer);
            Validator.ThrowSerializationIfNull(_drugName, Resources.DailyMedicationUsageDrugNameNotSet);

            // <daily-medication-usage>
            writer.WriteStartElement("daily-medication-usage");

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

            _drugName.WriteXml("drug-name", writer);

            writer.WriteElementString(
                "number-doses-consumed-in-day",
                _dosesConsumed.ToString(CultureInfo.InvariantCulture));

            XmlWriterHelper.WriteOpt(
                writer,
                "purpose-of-use",
                _purposeOfUse);

            XmlWriterHelper.WriteOptInt(
                writer,
                "number-doses-intended-in-day",
                _intendedDoses);

            XmlWriterHelper.WriteOpt(
                writer,
                "medication-usage-schedule",
                _usageSchedule);

            XmlWriterHelper.WriteOpt(
                writer,
                "drug-form",
                _drugForm);

            XmlWriterHelper.WriteOpt(
                writer,
                "prescription-type",
                _prescriptionType);

            XmlWriterHelper.WriteOpt(
                writer,
                "single-dose-description",
                _singleDoseDescription);

            // </daily-medication-usage>
            writer.WriteEndElement();
        }
Beispiel #6
0
        /// <summary>
        /// Writes the basic data to the specified XmlWriter.
        /// </summary>
        ///
        /// <param name="writer">
        /// The XmlWriter to write the basic data to.
        /// </param>
        ///
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="writer"/> is <b>null</b>.
        /// </exception>
        ///
        public override void WriteXml(XmlWriter writer)
        {
            Validator.ThrowIfWriterNull(writer);

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

            if (_gender != null)
            {
                if (_gender == ItemTypes.Gender.Male)
                {
                    writer.WriteElementString("gender", "m");
                }
                else if (_gender == ItemTypes.Gender.Female)
                {
                    writer.WriteElementString("gender", "f");
                }
            }

            XmlWriterHelper.WriteOptInt(writer, "birthyear", _birthYear);
            XmlWriterHelper.WriteOpt(writer, "country", _country);
            XmlWriterHelper.WriteOptString(writer, "postcode", _postalCode);
            XmlWriterHelper.WriteOptString(writer, "city", _city);
            XmlWriterHelper.WriteOpt(writer, "state", _stateOrProvince);

            if (_firstDayOfWeek != null)
            {
                // The DayOfWeek enum starts at 0 whereas the XSD starts at
                // 1.

                writer.WriteElementString(
                    "firstdow",
                    ((int)_firstDayOfWeek + 1).ToString(CultureInfo.InvariantCulture));
            }

            foreach (Language language in _languages)
            {
                language.WriteXml("language", writer);
            }

            // </basic>
            writer.WriteEndElement();
        }
Beispiel #7
0
        /// <summary>
        /// Writes the medication fill data to the specified XmlWriter.
        /// </summary>
        ///
        /// <param name="writer">
        /// The XmlWriter to write the medication fill data to.
        /// </param>
        ///
        /// <exception cref="ArgumentNullException">
        /// The <paramref name="writer"/> parameter 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.MedicationFillNameNotSet);

            writer.WriteStartElement("medication-fill");

            _name.WriteXml("name", writer);

            XmlWriterHelper.WriteOpt(writer, "date-filled", _dateFilled);
            XmlWriterHelper.WriteOptInt(writer, "days-supply", _daysSupply);
            XmlWriterHelper.WriteOpt(writer, "next-refill-date", _nextRefillDate);
            XmlWriterHelper.WriteOptInt(writer, "refills-left", _refillsLeft);
            XmlWriterHelper.WriteOpt(writer, "pharmacy", _pharmacy);
            XmlWriterHelper.WriteOptString(writer, "prescription-number", _prescriptionNumber);
            XmlWriterHelper.WriteOptString(writer, "lot-number", _lotNumber);

            writer.WriteEndElement();
        }
Beispiel #8
0
        /// <summary>
        /// Writes the XML representation of the CarePlanTaskRecurrence 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 CarePlanTaskRecurrence 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>
        ///
        public override void WriteXml(string nodeName, XmlWriter writer)
        {
            Validator.ThrowIfStringNullOrEmpty(nodeName, "WriteXmlEmptyNodeName");
            Validator.ThrowIfWriterNull(writer);

            if ((_interval != null && _timesInInterval == null) ||
                (_interval == null && _timesInInterval != null))
            {
                throw new InvalidOperationException(Resources.CarePlanTaskRecurrenceIntervalAndTimesBothSet);
            }

            writer.WriteStartElement("recurrence");
            {
                XmlWriterHelper.WriteOptString(writer, "ical-recurrence", _icalRecurrence);
                XmlWriterHelper.WriteOpt(writer, "interval", _interval);
                XmlWriterHelper.WriteOptInt(writer, "times-in-interval", _timesInInterval);
            }

            writer.WriteEndElement();
        }
        /// <summary>
        /// Writes the pregnancy data to the specified XmlWriter.
        /// </summary>
        ///
        /// <param name="writer">
        /// The XmlWriter to write the pregnancy data to.
        /// </param>
        ///
        /// <exception cref="ArgumentNullException">
        /// The <paramref name="writer"/> parameter is <b>null</b>.
        /// </exception>
        ///
        public override void WriteXml(XmlWriter writer)
        {
            Validator.ThrowIfWriterNull(writer);

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

            XmlWriterHelper.WriteOpt(writer, "due-date", _dueDate);
            XmlWriterHelper.WriteOpt(writer, "last-menstrual-period", _lastMenstrualPeriod);
            XmlWriterHelper.WriteOpt(writer, "conception-method", _conceptionMethod);
            XmlWriterHelper.WriteOptInt(writer, "fetus-count", _fetusCount);
            XmlWriterHelper.WriteOptInt(writer, "gestational-age", _gestationalAge);

            for (int index = 0; index < _delivery.Count; ++index)
            {
                _delivery[index].WriteXml("delivery", writer);
            }

            // </pregnancy>
            writer.WriteEndElement();
        }
        /// <summary>
        /// Writes the XML representation of the CarePlanTask 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 CarePlanTask 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, "WriteXmlEmptyNodeName");
            Validator.ThrowIfWriterNull(writer);

            Validator.ThrowSerializationIfNull(_name, Resources.CarePlanTaskNameNull);

            writer.WriteStartElement("task");
            {
                _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.WriteOptInt(writer, "sequence-number", _sequenceNumber);
                XmlWriterHelper.WriteOpt(writer, "associated-type-info", _taskAssociatedTypeInfo);
                XmlWriterHelper.WriteOpt(writer, "recurrence", _recurrence);
                XmlWriterHelper.WriteOptString(writer, "reference-id", _referenceId);
            }

            writer.WriteEndElement();
        }
        /// <summary>
        /// Writes the aerobic data to the specified XML writer.
        /// </summary>
        ///
        /// <param name="nodeName">
        /// The name of the outer element for the aerobic data.
        /// </param>
        ///
        /// <param name="writer">
        /// The XmlWriter to write the aerobic 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>
        ///
        public override void WriteXml(string nodeName, XmlWriter writer)
        {
            Validator.ThrowIfStringNullOrEmpty(nodeName, "nodeName");

            Validator.ThrowIfArgumentNull(writer, nameof(writer), Resources.WriteXmlNullWriter);

            writer.WriteStartElement(nodeName);

            if (_mode.Text != null)
            {
                // <mode>
                _mode.WriteXml("mode", writer);
            }

            // <distance>
            _distance?.WriteXml("distance", writer);

            if (_minutes != null)
            {
                // <minutes>
                writer.WriteElementString(
                    "minutes",
                    XmlConvert.ToString(_minutes.Value));
            }

            if (_intensity != RelativeRating.None)
            {
                // <intensity>
                writer.WriteElementString(
                    "intensity",
                    ((int)_intensity).ToString(CultureInfo.InvariantCulture));
            }

            if (_peakHr != null)
            {
                // <peak-heartrate>
                writer.WriteElementString(
                    "peak-heartrate",
                    _peakHr.Value.ToString(CultureInfo.InvariantCulture));
            }

            if (_averageHr != null)
            {
                // <avg-heartrate>
                writer.WriteElementString(
                    "avg-heartrate",
                    _averageHr.Value.ToString(CultureInfo.InvariantCulture));
            }

            if (_minHr != null)
            {
                // <min-heartrate>
                writer.WriteElementString(
                    "min-heartrate",
                    _minHr.Value.ToString(CultureInfo.InvariantCulture));
            }

            XmlWriterHelper.WriteOptDouble(
                writer,
                "energy",
                _energy);

            XmlWriterHelper.WriteOptDouble(
                writer,
                "energy-from-fat",
                _energyFromFat);

            _peakSpeed?.WriteXml("peak-speed", writer);

            _averageSpeed?.WriteXml("avg-speed", writer);

            _minSpeed?.WriteXml("min-speed", writer);

            _peakPace?.WriteXml("peak-pace", writer);

            _averagePace?.WriteXml("avg-pace", writer);

            _minPace?.WriteXml("min-pace", writer);

            _peakPower?.WriteXml("peak-power", writer);

            _averagePower?.WriteXml("avg-power", writer);

            _minPower?.WriteXml("min-power", writer);

            _peakTorque?.WriteXml("peak-torque", writer);

            _averageTorque?.WriteXml("avg-torque", writer);

            _minTorque?.WriteXml("min-torque", writer);

            XmlWriterHelper.WriteOptDouble(
                writer,
                "left-right-balance",
                _leftRightBalance);

            XmlWriterHelper.WriteOptDouble(
                writer,
                "peak-cadence",
                _peakCadence);

            XmlWriterHelper.WriteOptDouble(
                writer,
                "avg-cadence",
                _averageCadence);

            XmlWriterHelper.WriteOptDouble(
                writer,
                "min-cadence",
                _minCadence);

            _peakTemperature?.WriteXml("peak-temperature", writer);

            _averageTemperature?.WriteXml("avg-temperature", writer);

            _minTemperature?.WriteXml("min-temperature", writer);

            _peakAltitude?.WriteXml("peak-altitude", writer);

            _averageAltitude?.WriteXml("avg-altitude", writer);

            _minAltitude?.WriteXml("min-altitude", writer);

            XmlWriterHelper.WriteOpt(writer, "elevation-gain", _elevationGain);
            XmlWriterHelper.WriteOpt(writer, "elevation-loss", _elevationLoss);
            XmlWriterHelper.WriteOptInt(writer, "number-of-steps", _numberOfSteps);
            XmlWriterHelper.WriteOptInt(writer, "number-of-aerobic-steps", _numberOfAerobicSteps);
            XmlWriterHelper.WriteOptDouble(writer, "aerobic-step-minutes", _aerobicStepMinutes);

            writer.WriteEndElement();
        }