public static void SerializeProvenance(Hl7.Fhir.Model.Provenance value, IFhirWriter writer, bool summary) { writer.WriteStartRootObject("Provenance"); 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 language if (value.LanguageElement != null && !summary) { writer.WriteStartElement("language"); CodeSerializer.SerializeCode(value.LanguageElement, writer, summary); writer.WriteEndElement(); } // Serialize element text if (value.Text != null && !summary) { writer.WriteStartElement("text"); NarrativeSerializer.SerializeNarrative(value.Text, writer, summary); writer.WriteEndElement(); } // Serialize element contained if (value.Contained != null && !summary && value.Contained.Count > 0) { writer.WriteStartArrayElement("contained"); foreach (var item in value.Contained) { writer.WriteStartArrayMember("contained"); FhirSerializer.SerializeResource(item, writer, summary); writer.WriteEndArrayMember(); } writer.WriteEndArrayElement(); } // Serialize element target if (value.Target != null && !summary && value.Target.Count > 0) { writer.WriteStartArrayElement("target"); foreach (var item in value.Target) { writer.WriteStartArrayMember("target"); ResourceReferenceSerializer.SerializeResourceReference(item, writer, summary); writer.WriteEndArrayMember(); } writer.WriteEndArrayElement(); } // Serialize element period if (value.Period != null && !summary) { writer.WriteStartElement("period"); PeriodSerializer.SerializePeriod(value.Period, writer, summary); writer.WriteEndElement(); } // Serialize element recorded if (value.RecordedElement != null && !summary) { writer.WriteStartElement("recorded"); InstantSerializer.SerializeInstant(value.RecordedElement, writer, summary); writer.WriteEndElement(); } // Serialize element reason if (value.Reason != null && !summary) { writer.WriteStartElement("reason"); CodeableConceptSerializer.SerializeCodeableConcept(value.Reason, writer, summary); writer.WriteEndElement(); } // Serialize element location if (value.Location != null && !summary) { writer.WriteStartElement("location"); ResourceReferenceSerializer.SerializeResourceReference(value.Location, writer, summary); writer.WriteEndElement(); } // Serialize element policy if (value.PolicyElement != null && !summary && value.PolicyElement.Count > 0) { writer.WriteStartArrayElement("policy"); foreach (var item in value.PolicyElement) { writer.WriteStartArrayMember("policy"); FhirUriSerializer.SerializeFhirUri(item, writer, summary); writer.WriteEndArrayMember(); } writer.WriteEndArrayElement(); } // Serialize element agent if (value.Agent != null && !summary && value.Agent.Count > 0) { writer.WriteStartArrayElement("agent"); foreach (var item in value.Agent) { writer.WriteStartArrayMember("agent"); ProvenanceSerializer.SerializeProvenanceAgentComponent(item, writer, summary); writer.WriteEndArrayMember(); } writer.WriteEndArrayElement(); } // Serialize element entity if (value.Entity != null && !summary && value.Entity.Count > 0) { writer.WriteStartArrayElement("entity"); foreach (var item in value.Entity) { writer.WriteStartArrayMember("entity"); ProvenanceSerializer.SerializeProvenanceEntityComponent(item, writer, summary); writer.WriteEndArrayMember(); } writer.WriteEndArrayElement(); } // Serialize element signature if (value.SignatureElement != null && !summary) { writer.WriteStartElement("signature"); FhirStringSerializer.SerializeFhirString(value.SignatureElement, writer, summary); writer.WriteEndElement(); } writer.WriteEndComplexContent(); writer.WriteEndRootObject(); }
public static void SerializeProvenanceEntityComponent(Hl7.Fhir.Model.Provenance.ProvenanceEntityComponent 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 role if (value.RoleElement != null) { writer.WriteStartElement("role"); CodeSerializer.SerializeCode <Hl7.Fhir.Model.Provenance.ProvenanceEntityRole>(value.RoleElement, writer, summary); writer.WriteEndElement(); } // Serialize element type if (value.Type != null) { writer.WriteStartElement("type"); CodingSerializer.SerializeCoding(value.Type, writer, summary); writer.WriteEndElement(); } // Serialize element reference if (value.ReferenceElement != null) { writer.WriteStartElement("reference"); FhirUriSerializer.SerializeFhirUri(value.ReferenceElement, writer, summary); writer.WriteEndElement(); } // Serialize element display if (value.DisplayElement != null) { writer.WriteStartElement("display"); FhirStringSerializer.SerializeFhirString(value.DisplayElement, writer, summary); writer.WriteEndElement(); } // Serialize element agent if (value.Agent != null) { writer.WriteStartElement("agent"); ProvenanceSerializer.SerializeProvenanceAgentComponent(value.Agent, writer, summary); writer.WriteEndElement(); } writer.WriteEndComplexContent(); }