Exemplo n.º 1
0
        public static void SerializeDiagnosticReport(Hl7.Fhir.Model.DiagnosticReport value, IFhirWriter writer, bool summary)
        {
            writer.WriteStartRootObject("DiagnosticReport");
            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 status
            if (value.StatusElement != null)
            {
                writer.WriteStartElement("status");
                CodeSerializer.SerializeCode <Hl7.Fhir.Model.ObservationStatus>(value.StatusElement, writer, summary);
                writer.WriteEndElement();
            }

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

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

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

            // Serialize element reportId
            if (value.ReportId != null)
            {
                writer.WriteStartElement("reportId");
                IdentifierSerializer.SerializeIdentifier(value.ReportId, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element requestDetail
            if (value.RequestDetail != null && !summary && value.RequestDetail.Count > 0)
            {
                writer.WriteStartArrayElement("requestDetail");
                foreach (var item in value.RequestDetail)
                {
                    writer.WriteStartArrayMember("requestDetail");
                    DiagnosticReportSerializer.SerializeDiagnosticReportRequestDetailComponent(item, writer, summary);
                    writer.WriteEndArrayMember();
                }
                writer.WriteEndArrayElement();
            }

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

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

            // Serialize element results
            if (value.Results != null && !summary)
            {
                writer.WriteStartElement("results");
                DiagnosticReportSerializer.SerializeResultGroupComponent(value.Results, writer, summary);
                writer.WriteEndElement();
            }

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

            // Serialize element conclusion
            if (value.ConclusionElement != null && !summary)
            {
                writer.WriteStartElement("conclusion");
                FhirStringSerializer.SerializeFhirString(value.ConclusionElement, writer, summary);
                writer.WriteEndElement();
            }

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

            // Serialize element representation
            if (value.Representation != null && !summary && value.Representation.Count > 0)
            {
                writer.WriteStartArrayElement("representation");
                foreach (var item in value.Representation)
                {
                    writer.WriteStartArrayMember("representation");
                    AttachmentSerializer.SerializeAttachment(item, writer, summary);
                    writer.WriteEndArrayMember();
                }
                writer.WriteEndArrayElement();
            }


            writer.WriteEndComplexContent();
            writer.WriteEndRootObject();
        }
Exemplo n.º 2
0
        public static void SerializeResultGroupComponent(Hl7.Fhir.Model.DiagnosticReport.ResultGroupComponent 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 name
            if (value.Name != null)
            {
                writer.WriteStartElement("name");
                CodeableConceptSerializer.SerializeCodeableConcept(value.Name, writer, summary);
                writer.WriteEndElement();
            }

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

            // Serialize element group
            if (value.Group != null && value.Group.Count > 0)
            {
                writer.WriteStartArrayElement("group");
                foreach (var item in value.Group)
                {
                    writer.WriteStartArrayMember("group");
                    DiagnosticReportSerializer.SerializeResultGroupComponent(item, writer, summary);
                    writer.WriteEndArrayMember();
                }
                writer.WriteEndArrayElement();
            }

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


            writer.WriteEndComplexContent();
        }