public static void SerializeProblemEvidenceComponent(Hl7.Fhir.Model.Problem.ProblemEvidenceComponent value, IFhirWriter writer)
        {
            writer.WriteStartComplexContent();

            // 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 _id
            if (value.LocalId != null)
            {
                writer.WriteStartElement("_id");
                IdSerializer.SerializeId(value.LocalId, writer);
                writer.WriteEndElement();
            }

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

            // Serialize element details
            if (value.Details != null && value.Details.Count > 0)
            {
                writer.WriteStartArrayElement("details");
                foreach (var item in value.Details)
                {
                    writer.WriteStartArrayMember("details");
                    ResourceReferenceSerializer.SerializeResourceReference(item, writer);
                    writer.WriteEndArrayMember();
                }
                writer.WriteEndArrayElement();
            }


            writer.WriteEndComplexContent();
        }
        /// <summary>
        /// Parse ProblemEvidenceComponent
        /// </summary>
        public static Hl7.Fhir.Model.Problem.ProblemEvidenceComponent ParseProblemEvidenceComponent(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Problem.ProblemEvidenceComponent existingInstance = null)
        {
            Hl7.Fhir.Model.Problem.ProblemEvidenceComponent result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Problem.ProblemEvidenceComponent();
            try
            {
                string currentElementName = reader.CurrentElementName;
                reader.EnterElement();

                while (reader.HasMoreElements())
                {
                    // Parse element extension
                    if (ParserUtils.IsAtFhirElement(reader, "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 (ParserUtils.IsAtFhirElement(reader, "_id"))
                    {
                        result.LocalId = Id.Parse(reader.ReadPrimitiveContents("id"));
                    }

                    // Parse element code
                    else if (ParserUtils.IsAtFhirElement(reader, "code"))
                    {
                        result.Code = CodeableConceptParser.ParseCodeableConcept(reader, errors);
                    }

                    // Parse element details
                    else if (ParserUtils.IsAtFhirElement(reader, "details"))
                    {
                        result.Details = new List <Hl7.Fhir.Model.ResourceReference>();
                        reader.EnterArray();

                        while (ParserUtils.IsAtArrayElement(reader, "details"))
                        {
                            result.Details.Add(ResourceReferenceParser.ParseResourceReference(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();
            }
            catch (Exception ex)
            {
                errors.Add(ex.Message, reader);
            }
            return(result);
        }