Beispiel #1
0
        public static void SerializeAdverseReactionExposureComponent(Hl7.Fhir.Model.AdverseReaction.AdverseReactionExposureComponent 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 exposureDate
            if (value.ExposureDateElement != null)
            {
                writer.WriteStartElement("exposureDate");
                FhirDateTimeSerializer.SerializeFhirDateTime(value.ExposureDateElement, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element exposureType
            if (value.ExposureTypeElement != null)
            {
                writer.WriteStartElement("exposureType");
                CodeSerializer.SerializeCode <Hl7.Fhir.Model.AdverseReaction.ExposureType>(value.ExposureTypeElement, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element causalityExpectation
            if (value.CausalityExpectationElement != null)
            {
                writer.WriteStartElement("causalityExpectation");
                CodeSerializer.SerializeCode <Hl7.Fhir.Model.AdverseReaction.CausalityExpectation>(value.CausalityExpectationElement, writer, summary);
                writer.WriteEndElement();
            }

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


            writer.WriteEndComplexContent();
        }
Beispiel #2
0
        /// <summary>
        /// Parse AdverseReactionExposureComponent
        /// </summary>
        public static Hl7.Fhir.Model.AdverseReaction.AdverseReactionExposureComponent ParseAdverseReactionExposureComponent(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.AdverseReaction.AdverseReactionExposureComponent existingInstance = null)
        {
            Hl7.Fhir.Model.AdverseReaction.AdverseReactionExposureComponent result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.AdverseReaction.AdverseReactionExposureComponent();
            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 exposureDate
                else if (atName == "exposureDate")
                {
                    result.ExposureDateElement = FhirDateTimeParser.ParseFhirDateTime(reader, errors);
                }

                // Parse element exposureType
                else if (atName == "exposureType")
                {
                    result.ExposureTypeElement = CodeParser.ParseCode <Hl7.Fhir.Model.AdverseReaction.ExposureType>(reader, errors);
                }

                // Parse element causalityExpectation
                else if (atName == "causalityExpectation")
                {
                    result.CausalityExpectationElement = CodeParser.ParseCode <Hl7.Fhir.Model.AdverseReaction.CausalityExpectation>(reader, errors);
                }

                // Parse element substance
                else if (atName == "substance")
                {
                    result.Substance = ResourceReferenceParser.ParseResourceReference(reader, errors);
                }

                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);
        }