예제 #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 ((Identifier != null) && (Identifier.Count != 0))
            {
                writer.WritePropertyName("identifier");
                writer.WriteStartArray();

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

                writer.WriteEndArray();
            }

            if (Active != null)
            {
                writer.WriteBoolean("active", (bool)Active !);
            }

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

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

                foreach (CodeableConcept valRelationship in Relationship)
                {
                    valRelationship.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

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

                foreach (HumanName valName in Name)
                {
                    valName.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

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

                foreach (ContactPoint valTelecom in Telecom)
                {
                    valTelecom.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            if (!string.IsNullOrEmpty(Gender))
            {
                writer.WriteString("gender", (string)Gender !);
            }

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

            if (!string.IsNullOrEmpty(BirthDate))
            {
                writer.WriteString("birthDate", (string)BirthDate !);
            }

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

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

                foreach (Address valAddress in Address)
                {
                    valAddress.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

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

                foreach (Attachment valPhoto in Photo)
                {
                    valPhoto.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

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

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

                foreach (RelatedPersonCommunication valCommunication in Communication)
                {
                    valCommunication.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

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