public static void SerializeMedicationProductIngredientComponent(Hl7.Fhir.Model.Medication.MedicationProductIngredientComponent value, IFhirWriter writer, bool summary)
        {
            writer.WriteStartComplexContent();

            // Serialize element _id
            if (value.LocalIdElement != null)
            {
                writer.WritePrimitiveContents("_id", value.LocalIdElement, XmlSerializationHint.Attribute);
            }

            // Serialize element extension
            if (value.Extension != null && !summary && value.Extension.Count > 0)
            {
                writer.WriteStartArrayElement("extension");
                foreach (var item in value.Extension)
                {
                    writer.WriteStartArrayMember("extension");
                    ExtensionSerializer.SerializeExtension(item, writer, summary);
                    writer.WriteEndArrayMember();
                }
                writer.WriteEndArrayElement();
            }

            // Serialize element item
            if (value.Item != null)
            {
                writer.WriteStartElement("item");
                ResourceReferenceSerializer.SerializeResourceReference(value.Item, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element amount
            if (value.Amount != null)
            {
                writer.WriteStartElement("amount");
                RatioSerializer.SerializeRatio(value.Amount, writer, summary);
                writer.WriteEndElement();
            }


            writer.WriteEndComplexContent();
        }
        public static void SerializeMedicationAdministrationDosageComponent(Hl7.Fhir.Model.MedicationAdministration.MedicationAdministrationDosageComponent value, IFhirWriter writer, bool summary)
        {
            writer.WriteStartComplexContent();

            // Serialize element _id
            if (value.LocalIdElement != null)
            {
                writer.WritePrimitiveContents("_id", value.LocalIdElement, XmlSerializationHint.Attribute);
            }

            // Serialize element extension
            if (value.Extension != null && !summary && value.Extension.Count > 0)
            {
                writer.WriteStartArrayElement("extension");
                foreach (var item in value.Extension)
                {
                    writer.WriteStartArrayMember("extension");
                    ExtensionSerializer.SerializeExtension(item, writer, summary);
                    writer.WriteEndArrayMember();
                }
                writer.WriteEndArrayElement();
            }

            // Serialize element timing
            if (value.Timing != null)
            {
                writer.WriteStartElement("timing");
                ScheduleSerializer.SerializeSchedule(value.Timing, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element site
            if (value.Site != null)
            {
                writer.WriteStartElement("site");
                CodeableConceptSerializer.SerializeCodeableConcept(value.Site, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element route
            if (value.Route != null)
            {
                writer.WriteStartElement("route");
                CodeableConceptSerializer.SerializeCodeableConcept(value.Route, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element method
            if (value.Method != null)
            {
                writer.WriteStartElement("method");
                CodeableConceptSerializer.SerializeCodeableConcept(value.Method, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element quantity
            if (value.Quantity != null)
            {
                writer.WriteStartElement("quantity");
                QuantitySerializer.SerializeQuantity(value.Quantity, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element rate
            if (value.Rate != null)
            {
                writer.WriteStartElement("rate");
                RatioSerializer.SerializeRatio(value.Rate, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element maxDosePerPeriod
            if (value.MaxDosePerPeriod != null)
            {
                writer.WriteStartElement("maxDosePerPeriod");
                RatioSerializer.SerializeRatio(value.MaxDosePerPeriod, writer, summary);
                writer.WriteEndElement();
            }


            writer.WriteEndComplexContent();
        }
        public static void SerializeMedicationDispenseDispenseDosageComponent(Hl7.Fhir.Model.MedicationDispense.MedicationDispenseDispenseDosageComponent value, IFhirWriter writer, bool summary)
        {
            writer.WriteStartComplexContent();

            // Serialize element _id
            if (value.LocalIdElement != null)
            {
                writer.WritePrimitiveContents("_id", value.LocalIdElement, XmlSerializationHint.Attribute);
            }

            // Serialize element extension
            if (value.Extension != null && !summary && value.Extension.Count > 0)
            {
                writer.WriteStartArrayElement("extension");
                foreach (var item in value.Extension)
                {
                    writer.WriteStartArrayMember("extension");
                    ExtensionSerializer.SerializeExtension(item, writer, summary);
                    writer.WriteEndArrayMember();
                }
                writer.WriteEndArrayElement();
            }

            // Serialize element additionalInstructions
            if (value.AdditionalInstructions != null)
            {
                writer.WriteStartElement(SerializationUtil.BuildPolymorphicName("additionalInstructions", value.AdditionalInstructions.GetType()));
                FhirSerializer.SerializeElement(value.AdditionalInstructions, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element timing
            if (value.Timing != null)
            {
                writer.WriteStartElement(SerializationUtil.BuildPolymorphicName("timing", value.Timing.GetType()));
                FhirSerializer.SerializeElement(value.Timing, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element site
            if (value.Site != null)
            {
                writer.WriteStartElement("site");
                CodeableConceptSerializer.SerializeCodeableConcept(value.Site, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element route
            if (value.Route != null)
            {
                writer.WriteStartElement("route");
                CodeableConceptSerializer.SerializeCodeableConcept(value.Route, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element method
            if (value.Method != null)
            {
                writer.WriteStartElement("method");
                CodeableConceptSerializer.SerializeCodeableConcept(value.Method, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element quantity
            if (value.Quantity != null)
            {
                writer.WriteStartElement("quantity");
                QuantitySerializer.SerializeQuantity(value.Quantity, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element rate
            if (value.Rate != null)
            {
                writer.WriteStartElement("rate");
                RatioSerializer.SerializeRatio(value.Rate, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element maxDosePerPeriod
            if (value.MaxDosePerPeriod != null)
            {
                writer.WriteStartElement("maxDosePerPeriod");
                RatioSerializer.SerializeRatio(value.MaxDosePerPeriod, writer, summary);
                writer.WriteEndElement();
            }


            writer.WriteEndComplexContent();
        }
Beispiel #4
0
        public static void SerializePrescriptionAdministrationRequestComponent(Prescription.PrescriptionAdministrationRequestComponent value, IFhirWriter writer)
        {
            writer.WriteStartComplexContent();

            // Serialize element's localId attribute
            if (value.InternalId != null && !String.IsNullOrEmpty(value.InternalId.Contents))
            {
                writer.WriteRefIdContents(value.InternalId.Contents);
            }

            // Serialize element extension
            if (value.Extension != null && value.Extension.Count > 0)
            {
                writer.WriteStartArrayElement("extension");
                foreach (var item in value.Extension)
                {
                    writer.WriteStartArrayMember("extension");
                    ExtensionSerializer.SerializeExtension(item, writer);
                    writer.WriteEndArrayMember();
                }
                writer.WriteEndArrayElement();
            }

            // Serialize element description
            if (value.Description != null)
            {
                writer.WriteStartElement("description");
                FhirStringSerializer.SerializeFhirString(value.Description, writer);
                writer.WriteEndElement();
            }

            // Serialize element totalPeriodicDose
            if (value.TotalPeriodicDose != null)
            {
                writer.WriteStartElement("totalPeriodicDose");
                RatioSerializer.SerializeRatio(value.TotalPeriodicDose, writer);
                writer.WriteEndElement();
            }

            // Serialize element start
            if (value.Start != null)
            {
                writer.WriteStartElement("start");
                FhirDateTimeSerializer.SerializeFhirDateTime(value.Start, writer);
                writer.WriteEndElement();
            }

            // Serialize element end
            if (value.End != null)
            {
                writer.WriteStartElement("end");
                FhirDateTimeSerializer.SerializeFhirDateTime(value.End, writer);
                writer.WriteEndElement();
            }

            // Serialize element duration
            if (value.Duration != null)
            {
                writer.WriteStartElement("duration");
                QuantitySerializer.SerializeQuantity(value.Duration, writer);
                writer.WriteEndElement();
            }

            // Serialize element numberOfAdministrations
            if (value.NumberOfAdministrations != null)
            {
                writer.WriteStartElement("numberOfAdministrations");
                IntegerSerializer.SerializeInteger(value.NumberOfAdministrations, writer);
                writer.WriteEndElement();
            }

            // Serialize element dosageInstruction
            if (value.DosageInstruction != null && value.DosageInstruction.Count > 0)
            {
                writer.WriteStartArrayElement("dosageInstruction");
                foreach (var item in value.DosageInstruction)
                {
                    writer.WriteStartArrayMember("dosageInstruction");
                    PrescriptionSerializer.SerializePrescriptionAdministrationRequestDosageInstructionComponent(item, writer);
                    writer.WriteEndArrayMember();
                }
                writer.WriteEndArrayElement();
            }


            writer.WriteEndComplexContent();
        }
 internal static void SerializeElement(Element value, IFhirWriter writer, bool summary)
 {
     if (value.GetType() == typeof(Hl7.Fhir.Model.Address))
     {
         AddressSerializer.SerializeAddress((Hl7.Fhir.Model.Address)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.Attachment))
     {
         AttachmentSerializer.SerializeAttachment((Hl7.Fhir.Model.Attachment)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.Choice))
     {
         ChoiceSerializer.SerializeChoice((Hl7.Fhir.Model.Choice)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.CodeableConcept))
     {
         CodeableConceptSerializer.SerializeCodeableConcept((Hl7.Fhir.Model.CodeableConcept)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.Coding))
     {
         CodingSerializer.SerializeCoding((Hl7.Fhir.Model.Coding)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.Contact))
     {
         ContactSerializer.SerializeContact((Hl7.Fhir.Model.Contact)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.Extension))
     {
         ExtensionSerializer.SerializeExtension((Hl7.Fhir.Model.Extension)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.HumanName))
     {
         HumanNameSerializer.SerializeHumanName((Hl7.Fhir.Model.HumanName)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.Identifier))
     {
         IdentifierSerializer.SerializeIdentifier((Hl7.Fhir.Model.Identifier)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.Narrative))
     {
         NarrativeSerializer.SerializeNarrative((Hl7.Fhir.Model.Narrative)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.Period))
     {
         PeriodSerializer.SerializePeriod((Hl7.Fhir.Model.Period)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.Quantity))
     {
         QuantitySerializer.SerializeQuantity((Hl7.Fhir.Model.Quantity)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.Range))
     {
         RangeSerializer.SerializeRange((Hl7.Fhir.Model.Range)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.Ratio))
     {
         RatioSerializer.SerializeRatio((Hl7.Fhir.Model.Ratio)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.ResourceReference))
     {
         ResourceReferenceSerializer.SerializeResourceReference((Hl7.Fhir.Model.ResourceReference)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.SampledData))
     {
         SampledDataSerializer.SerializeSampledData((Hl7.Fhir.Model.SampledData)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.Schedule))
     {
         ScheduleSerializer.SerializeSchedule((Hl7.Fhir.Model.Schedule)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.Base64Binary))
     {
         Base64BinarySerializer.SerializeBase64Binary((Hl7.Fhir.Model.Base64Binary)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.FhirBoolean))
     {
         FhirBooleanSerializer.SerializeFhirBoolean((Hl7.Fhir.Model.FhirBoolean)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.Code))
     {
         CodeSerializer.SerializeCode((Hl7.Fhir.Model.Code)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.Date))
     {
         DateSerializer.SerializeDate((Hl7.Fhir.Model.Date)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.FhirDateTime))
     {
         FhirDateTimeSerializer.SerializeFhirDateTime((Hl7.Fhir.Model.FhirDateTime)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.FhirDecimal))
     {
         FhirDecimalSerializer.SerializeFhirDecimal((Hl7.Fhir.Model.FhirDecimal)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.Id))
     {
         IdSerializer.SerializeId((Hl7.Fhir.Model.Id)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.IdRef))
     {
         IdRefSerializer.SerializeIdRef((Hl7.Fhir.Model.IdRef)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.Instant))
     {
         InstantSerializer.SerializeInstant((Hl7.Fhir.Model.Instant)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.Integer))
     {
         IntegerSerializer.SerializeInteger((Hl7.Fhir.Model.Integer)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.Oid))
     {
         OidSerializer.SerializeOid((Hl7.Fhir.Model.Oid)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.FhirString))
     {
         FhirStringSerializer.SerializeFhirString((Hl7.Fhir.Model.FhirString)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.FhirUri))
     {
         FhirUriSerializer.SerializeFhirUri((Hl7.Fhir.Model.FhirUri)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.Uuid))
     {
         UuidSerializer.SerializeUuid((Hl7.Fhir.Model.Uuid)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.XHtml))
     {
         XHtmlSerializer.SerializeXHtml((Hl7.Fhir.Model.XHtml)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.Age))
     {
         QuantitySerializer.SerializeQuantity((Hl7.Fhir.Model.Age)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.Count))
     {
         QuantitySerializer.SerializeQuantity((Hl7.Fhir.Model.Count)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.Distance))
     {
         QuantitySerializer.SerializeQuantity((Hl7.Fhir.Model.Distance)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.Duration))
     {
         QuantitySerializer.SerializeQuantity((Hl7.Fhir.Model.Duration)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.Money))
     {
         QuantitySerializer.SerializeQuantity((Hl7.Fhir.Model.Money)value, writer, summary);
     }
     else
     {
         throw new Exception("Encountered unknown type " + value.GetType().Name);
     }
 }