/// <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) && (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 (Period != null)
            {
                writer.WritePropertyName("period");
                Period.SerializeJson(writer, options);
            }

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

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

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

                foreach (Reference valNetwork in Network)
                {
                    valNetwork.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

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

                foreach (CodeableConcept valCode in Code)
                {
                    valCode.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

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

                foreach (CodeableConcept valSpecialty in Specialty)
                {
                    valSpecialty.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

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

                foreach (Reference valLocation in Location)
                {
                    valLocation.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

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

                foreach (Reference valHealthcareService in HealthcareService)
                {
                    valHealthcareService.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 ((Endpoint != null) && (Endpoint.Count != 0))
            {
                writer.WritePropertyName("endpoint");
                writer.WriteStartArray();

                foreach (Reference valEndpoint in Endpoint)
                {
                    valEndpoint.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

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