/// <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 (!string.IsNullOrEmpty(ProductCategory))
            {
                writer.WriteString("productCategory", (string)ProductCategory !);
            }

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

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

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

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

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

                foreach (Reference valRequest in Request)
                {
                    valRequest.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            if (Quantity != null)
            {
                writer.WriteNumber("quantity", (int)Quantity !);
            }

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

                foreach (Reference valParent in Parent)
                {
                    valParent.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

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

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

                foreach (BiologicallyDerivedProductProcessing valProcessing in Processing)
                {
                    valProcessing.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

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

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

                foreach (BiologicallyDerivedProductStorage valStorage in Storage)
                {
                    valStorage.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

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