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

                foreach (Reference valPartOf in PartOf)
                {
                    valPartOf.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 (StatusReasonCodeableConcept != null)
            {
                writer.WritePropertyName("statusReasonCodeableConcept");
                StatusReasonCodeableConcept.SerializeJson(writer, options);
            }

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

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

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

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

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

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

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

                foreach (Reference valSupportingInformation in SupportingInformation)
                {
                    valSupportingInformation.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

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

                foreach (MedicationDispensePerformer valPerformer in Performer)
                {
                    valPerformer.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

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

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

                foreach (Reference valAuthorizingPrescription in AuthorizingPrescription)
                {
                    valAuthorizingPrescription.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

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

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

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

            if (!string.IsNullOrEmpty(WhenPrepared))
            {
                writer.WriteString("whenPrepared", (string)WhenPrepared !);
            }

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

            if (!string.IsNullOrEmpty(WhenHandedOver))
            {
                writer.WriteString("whenHandedOver", (string)WhenHandedOver !);
            }

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

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

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

                foreach (Reference valReceiver in Receiver)
                {
                    valReceiver.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 ((DosageInstruction != null) && (DosageInstruction.Count != 0))
            {
                writer.WritePropertyName("dosageInstruction");
                writer.WriteStartArray();

                foreach (Dosage valDosageInstruction in DosageInstruction)
                {
                    valDosageInstruction.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

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

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

                foreach (Reference valDetectedIssue in DetectedIssue)
                {
                    valDetectedIssue.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

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

                foreach (Reference valEventHistory in EventHistory)
                {
                    valEventHistory.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

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