예제 #1
0
        /// <summary>
        /// Serialize to a JSON object
        /// </summary>
        public new void SerializeJson(Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true)
        {
            if (includeStartObject)
            {
                writer.WriteStartObject();
            }
            if (!string.IsNullOrEmpty(ResourceType))
            {
                writer.WriteString("resourceType", (string)ResourceType !);
            }


            ((fhirCsR4.Models.DomainResource) this).SerializeJson(writer, options, false);

            if (MasterIdentifier != null)
            {
                writer.WritePropertyName("masterIdentifier");
                MasterIdentifier.SerializeJson(writer, options);
            }

            if ((Identifier != null) && (Identifier.Count != 0))
            {
                writer.WritePropertyName("identifier");
                writer.WriteStartArray();

                foreach (Identifier valIdentifier in Identifier)
                {
                    valIdentifier.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            if (!string.IsNullOrEmpty(Status))
            {
                writer.WriteString("status", (string)Status !);
            }

            if (_Status != null)
            {
                writer.WritePropertyName("_status");
                _Status.SerializeJson(writer, options);
            }

            if (!string.IsNullOrEmpty(DocStatus))
            {
                writer.WriteString("docStatus", (string)DocStatus !);
            }

            if (_DocStatus != null)
            {
                writer.WritePropertyName("_docStatus");
                _DocStatus.SerializeJson(writer, options);
            }

            if (Type != null)
            {
                writer.WritePropertyName("type");
                Type.SerializeJson(writer, options);
            }

            if ((Category != null) && (Category.Count != 0))
            {
                writer.WritePropertyName("category");
                writer.WriteStartArray();

                foreach (CodeableConcept valCategory in Category)
                {
                    valCategory.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            if (Subject != null)
            {
                writer.WritePropertyName("subject");
                Subject.SerializeJson(writer, options);
            }

            if (!string.IsNullOrEmpty(Date))
            {
                writer.WriteString("date", (string)Date !);
            }

            if (_Date != null)
            {
                writer.WritePropertyName("_date");
                _Date.SerializeJson(writer, options);
            }

            if ((Author != null) && (Author.Count != 0))
            {
                writer.WritePropertyName("author");
                writer.WriteStartArray();

                foreach (Reference valAuthor in Author)
                {
                    valAuthor.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            if (Authenticator != null)
            {
                writer.WritePropertyName("authenticator");
                Authenticator.SerializeJson(writer, options);
            }

            if (Custodian != null)
            {
                writer.WritePropertyName("custodian");
                Custodian.SerializeJson(writer, options);
            }

            if ((RelatesTo != null) && (RelatesTo.Count != 0))
            {
                writer.WritePropertyName("relatesTo");
                writer.WriteStartArray();

                foreach (DocumentReferenceRelatesTo valRelatesTo in RelatesTo)
                {
                    valRelatesTo.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            if (!string.IsNullOrEmpty(Description))
            {
                writer.WriteString("description", (string)Description !);
            }

            if (_Description != null)
            {
                writer.WritePropertyName("_description");
                _Description.SerializeJson(writer, options);
            }

            if ((SecurityLabel != null) && (SecurityLabel.Count != 0))
            {
                writer.WritePropertyName("securityLabel");
                writer.WriteStartArray();

                foreach (CodeableConcept valSecurityLabel in SecurityLabel)
                {
                    valSecurityLabel.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            if ((Content != null) && (Content.Count != 0))
            {
                writer.WritePropertyName("content");
                writer.WriteStartArray();

                foreach (DocumentReferenceContent valContent in Content)
                {
                    valContent.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            if (Context != null)
            {
                writer.WritePropertyName("context");
                Context.SerializeJson(writer, options);
            }

            if (includeStartObject)
            {
                writer.WriteEndObject();
            }
        }
예제 #2
0
        /// <summary>
        /// Serialize to a JSON object
        /// </summary>
        public new void SerializeJson(Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true)
        {
            if (includeStartObject)
            {
                writer.WriteStartObject();
            }

            if (!string.IsNullOrEmpty(ResourceType))
            {
                writer.WriteString("resourceType", (string)ResourceType !);
            }


            ((Fhir.R4.Models.DomainResource) this).SerializeJson(writer, options, false);

            if (Identifier != null)
            {
                writer.WritePropertyName("identifier");
                Identifier.SerializeJson(writer, options);
            }

            if (!string.IsNullOrEmpty(Status))
            {
                writer.WriteString("status", (string)Status !);
            }

            if (_Status != null)
            {
                writer.WritePropertyName("_status");
                _Status.SerializeJson(writer, options);
            }

            if (Type != null)
            {
                writer.WritePropertyName("type");
                Type.SerializeJson(writer, options);
            }

            if ((Category != null) && (Category.Count != 0))
            {
                writer.WritePropertyName("category");
                writer.WriteStartArray();

                foreach (CodeableConcept valCategory in Category)
                {
                    valCategory.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            if (Subject != null)
            {
                writer.WritePropertyName("subject");
                Subject.SerializeJson(writer, options);
            }

            if (Encounter != null)
            {
                writer.WritePropertyName("encounter");
                Encounter.SerializeJson(writer, options);
            }

            if (!string.IsNullOrEmpty(Date))
            {
                writer.WriteString("date", (string)Date !);
            }

            if (_Date != null)
            {
                writer.WritePropertyName("_date");
                _Date.SerializeJson(writer, options);
            }

            if ((Author != null) && (Author.Count != 0))
            {
                writer.WritePropertyName("author");
                writer.WriteStartArray();

                foreach (Reference valAuthor in Author)
                {
                    valAuthor.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            if (!string.IsNullOrEmpty(Title))
            {
                writer.WriteString("title", (string)Title !);
            }

            if (_Title != null)
            {
                writer.WritePropertyName("_title");
                _Title.SerializeJson(writer, options);
            }

            if (!string.IsNullOrEmpty(Confidentiality))
            {
                writer.WriteString("confidentiality", (string)Confidentiality !);
            }

            if (_Confidentiality != null)
            {
                writer.WritePropertyName("_confidentiality");
                _Confidentiality.SerializeJson(writer, options);
            }

            if ((Attester != null) && (Attester.Count != 0))
            {
                writer.WritePropertyName("attester");
                writer.WriteStartArray();

                foreach (CompositionAttester valAttester in Attester)
                {
                    valAttester.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            if (Custodian != null)
            {
                writer.WritePropertyName("custodian");
                Custodian.SerializeJson(writer, options);
            }

            if ((RelatesTo != null) && (RelatesTo.Count != 0))
            {
                writer.WritePropertyName("relatesTo");
                writer.WriteStartArray();

                foreach (CompositionRelatesTo valRelatesTo in RelatesTo)
                {
                    valRelatesTo.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            if ((Event != null) && (Event.Count != 0))
            {
                writer.WritePropertyName("event");
                writer.WriteStartArray();

                foreach (CompositionEvent valEvent in Event)
                {
                    valEvent.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            if ((Section != null) && (Section.Count != 0))
            {
                writer.WritePropertyName("section");
                writer.WriteStartArray();

                foreach (CompositionSection valSection in Section)
                {
                    valSection.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            if (includeStartObject)
            {
                writer.WriteEndObject();
            }
        }