Example #1
0
        public static void SerializeImmunizationExplanationComponent(Hl7.Fhir.Model.Immunization.ImmunizationExplanationComponent 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 reason
            if (value.Reason != null && value.Reason.Count > 0)
            {
                writer.WriteStartArrayElement("reason");
                foreach (var item in value.Reason)
                {
                    writer.WriteStartArrayMember("reason");
                    CodeableConceptSerializer.SerializeCodeableConcept(item, writer, summary);
                    writer.WriteEndArrayMember();
                }
                writer.WriteEndArrayElement();
            }

            // Serialize element refusalReason
            if (value.RefusalReason != null && value.RefusalReason.Count > 0)
            {
                writer.WriteStartArrayElement("refusalReason");
                foreach (var item in value.RefusalReason)
                {
                    writer.WriteStartArrayMember("refusalReason");
                    CodeableConceptSerializer.SerializeCodeableConcept(item, writer, summary);
                    writer.WriteEndArrayMember();
                }
                writer.WriteEndArrayElement();
            }


            writer.WriteEndComplexContent();
        }
Example #2
0
        /// <summary>
        /// Parse ImmunizationExplanationComponent
        /// </summary>
        public static Hl7.Fhir.Model.Immunization.ImmunizationExplanationComponent ParseImmunizationExplanationComponent(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Immunization.ImmunizationExplanationComponent existingInstance = null)
        {
            Hl7.Fhir.Model.Immunization.ImmunizationExplanationComponent result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Immunization.ImmunizationExplanationComponent();
            string currentElementName = reader.CurrentElementName;

            reader.EnterElement();

            while (reader.HasMoreElements())
            {
                var atName = reader.CurrentElementName;
                // Parse element extension
                if (atName == "extension")
                {
                    result.Extension = new List <Hl7.Fhir.Model.Extension>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "extension"))
                    {
                        result.Extension.Add(ExtensionParser.ParseExtension(reader, errors));
                    }

                    reader.LeaveArray();
                }

                // Parse element _id
                else if (atName == "_id")
                {
                    result.LocalIdElement = Id.Parse(reader.ReadPrimitiveContents(typeof(Id)));
                }

                // Parse element reason
                else if (atName == "reason")
                {
                    result.Reason = new List <Hl7.Fhir.Model.CodeableConcept>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "reason"))
                    {
                        result.Reason.Add(CodeableConceptParser.ParseCodeableConcept(reader, errors));
                    }

                    reader.LeaveArray();
                }

                // Parse element refusalReason
                else if (atName == "refusalReason")
                {
                    result.RefusalReason = new List <Hl7.Fhir.Model.CodeableConcept>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "refusalReason"))
                    {
                        result.RefusalReason.Add(CodeableConceptParser.ParseCodeableConcept(reader, errors));
                    }

                    reader.LeaveArray();
                }

                else
                {
                    errors.Add(String.Format("Encountered unknown element {0} while parsing {1}", reader.CurrentElementName, currentElementName), reader);
                    reader.SkipSubElementsFor(currentElementName);
                    result = null;
                }
            }

            reader.LeaveElement();
            return(result);
        }