/// <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 (RequestIdentifier != null)
            {
                writer.WritePropertyName("requestIdentifier");
                RequestIdentifier.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(ModuleUri))
            {
                writer.WriteString("moduleUri", (string)ModuleUri !);
            }

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

            if (!string.IsNullOrEmpty(ModuleCanonical))
            {
                writer.WriteString("moduleCanonical", (string)ModuleCanonical !);
            }

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

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

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

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

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

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

            if (!string.IsNullOrEmpty(OccurrenceDateTime))
            {
                writer.WriteString("occurrenceDateTime", (string)OccurrenceDateTime !);
            }

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

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

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

                foreach (CodeableConcept valReasonCode in ReasonCode)
                {
                    valReasonCode.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

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

                foreach (Reference valReasonReference in ReasonReference)
                {
                    valReasonReference.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

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

                foreach (Annotation valNote in Note)
                {
                    valNote.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

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

                foreach (Reference valEvaluationMessage in EvaluationMessage)
                {
                    valEvaluationMessage.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

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

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

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

                foreach (DataRequirement valDataRequirement in DataRequirement)
                {
                    valDataRequirement.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

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