Пример #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 !);
            }


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

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

            if (!string.IsNullOrEmpty(EventUri))
            {
                writer.WriteString("eventUri", (string)EventUri !);
            }

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

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

                foreach (MessageHeaderDestination valDestination in Destination)
                {
                    valDestination.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

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

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

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

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

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

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

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

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

                foreach (Reference valFocus in Focus)
                {
                    valFocus.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            if (!string.IsNullOrEmpty(Definition))
            {
                writer.WriteString("definition", (string)Definition !);
            }

            if (_Definition != null)
            {
                writer.WritePropertyName("_definition");
                _Definition.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 !);
            }


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

            if (!string.IsNullOrEmpty(Url))
            {
                writer.WriteString("url", (string)Url !);
            }

            if (_Url != null)
            {
                writer.WritePropertyName("_url");
                _Url.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(Version))
            {
                writer.WriteString("version", (string)Version !);
            }

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

            if (!string.IsNullOrEmpty(Name))
            {
                writer.WriteString("name", (string)Name !);
            }

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

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

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

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

                foreach (string valReplaces in Replaces)
                {
                    writer.WriteStringValue(valReplaces);
                }

                writer.WriteEndArray();
            }

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

                foreach (Element val_Replaces in _Replaces)
                {
                    val_Replaces.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 (Experimental != null)
            {
                writer.WriteBoolean("experimental", (bool)Experimental !);
            }

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

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

            if (!string.IsNullOrEmpty(Publisher))
            {
                writer.WriteString("publisher", (string)Publisher !);
            }

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

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

                foreach (ContactDetail valContact in Contact)
                {
                    valContact.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 ((UseContext != null) && (UseContext.Count != 0))
            {
                writer.WritePropertyName("useContext");
                writer.WriteStartArray();

                foreach (UsageContext valUseContext in UseContext)
                {
                    valUseContext.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

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

                foreach (CodeableConcept valJurisdiction in Jurisdiction)
                {
                    valJurisdiction.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            if (!string.IsNullOrEmpty(Purpose))
            {
                writer.WriteString("purpose", (string)Purpose !);
            }

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

            if (!string.IsNullOrEmpty(Copyright))
            {
                writer.WriteString("copyright", (string)Copyright !);
            }

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

            if (!string.IsNullOrEmpty(Base))
            {
                writer.WriteString("base", (string)Base !);
            }

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

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

                foreach (string valParent in Parent)
                {
                    writer.WriteStringValue(valParent);
                }

                writer.WriteEndArray();
            }

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

                foreach (Element val_Parent in _Parent)
                {
                    val_Parent.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

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

            if (!string.IsNullOrEmpty(EventUri))
            {
                writer.WriteString("eventUri", (string)EventUri !);
            }

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

            if (!string.IsNullOrEmpty(Category))
            {
                writer.WriteString("category", (string)Category !);
            }

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

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

                foreach (MessageDefinitionFocus valFocus in Focus)
                {
                    valFocus.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            if (!string.IsNullOrEmpty(ResponseRequired))
            {
                writer.WriteString("responseRequired", (string)ResponseRequired !);
            }

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

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

                foreach (MessageDefinitionAllowedResponse valAllowedResponse in AllowedResponse)
                {
                    valAllowedResponse.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

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

                foreach (string valGraph in Graph)
                {
                    writer.WriteStringValue(valGraph);
                }

                writer.WriteEndArray();
            }

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

                foreach (Element val_Graph in _Graph)
                {
                    val_Graph.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

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