Esempio n. 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 ((BasedOn != null) && (BasedOn.Count != 0))
            {
                writer.WritePropertyName("basedOn");
                writer.WriteStartArray();

                foreach (Reference valBasedOn in BasedOn)
                {
                    valBasedOn.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 ((Category != null) && (Category.Count != 0))
            {
                writer.WritePropertyName("category");
                writer.WriteStartArray();

                foreach (CodeableConcept valCategory in Category)
                {
                    valCategory.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            if (Code != null)
            {
                writer.WritePropertyName("code");
                Code.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(EffectiveDateTime))
            {
                writer.WriteString("effectiveDateTime", (string)EffectiveDateTime !);
            }

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

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

            if (!string.IsNullOrEmpty(Issued))
            {
                writer.WriteString("issued", (string)Issued !);
            }

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

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

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

                writer.WriteEndArray();
            }

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

                foreach (Reference valResultsInterpreter in ResultsInterpreter)
                {
                    valResultsInterpreter.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

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

                foreach (Reference valSpecimen in Specimen)
                {
                    valSpecimen.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

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

                foreach (Reference valResult in Result)
                {
                    valResult.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

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

                foreach (Reference valImagingStudy in ImagingStudy)
                {
                    valImagingStudy.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

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

                foreach (DiagnosticReportMedia valMedia in Media)
                {
                    valMedia.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            if (!string.IsNullOrEmpty(Conclusion))
            {
                writer.WriteString("conclusion", (string)Conclusion !);
            }

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

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

                foreach (CodeableConcept valConclusionCode in ConclusionCode)
                {
                    valConclusionCode.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

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

                foreach (Attachment valPresentedForm in PresentedForm)
                {
                    valPresentedForm.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            if (includeStartObject)
            {
                writer.WriteEndObject();
            }
        }
        /// <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 ((Instantiates != null) && (Instantiates.Count != 0))
            {
                writer.WritePropertyName("instantiates");
                writer.WriteStartArray();

                foreach (string valInstantiates in Instantiates)
                {
                    writer.WriteStringValue(valInstantiates);
                }

                writer.WriteEndArray();
            }

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

                foreach (Element val_Instantiates in _Instantiates)
                {
                    val_Instantiates.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 ((StatusReason != null) && (StatusReason.Count != 0))
            {
                writer.WritePropertyName("statusReason");
                writer.WriteStartArray();

                foreach (CodeableConcept valStatusReason in StatusReason)
                {
                    valStatusReason.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

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

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

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

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

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

                writer.WriteEndArray();
            }

            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 (Request != null)
            {
                writer.WritePropertyName("request");
                Request.SerializeJson(writer, options);
            }

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

                foreach (Reference valDevice in Device)
                {
                    valDevice.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 (Dosage != null)
            {
                writer.WritePropertyName("dosage");
                Dosage.SerializeJson(writer, options);
            }

            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();
            }
        }
Esempio n. 3
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 (!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 (!string.IsNullOrEmpty(ShortTitle))
            {
                writer.WriteString("shortTitle", (string)ShortTitle !);
            }

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

            if (!string.IsNullOrEmpty(Subtitle))
            {
                writer.WriteString("subtitle", (string)Subtitle !);
            }

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

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

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

            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 ((Note != null) && (Note.Count != 0))
            {
                writer.WritePropertyName("note");
                writer.WriteStartArray();

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

                writer.WriteEndArray();
            }

            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(Copyright))
            {
                writer.WriteString("copyright", (string)Copyright !);
            }

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

            if (!string.IsNullOrEmpty(ApprovalDate))
            {
                writer.WriteString("approvalDate", (string)ApprovalDate !);
            }

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

            if (!string.IsNullOrEmpty(LastReviewDate))
            {
                writer.WriteString("lastReviewDate", (string)LastReviewDate !);
            }

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

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

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

                foreach (CodeableConcept valTopic in Topic)
                {
                    valTopic.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

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

                foreach (ContactDetail valAuthor in Author)
                {
                    valAuthor.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

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

                foreach (ContactDetail valEditor in Editor)
                {
                    valEditor.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

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

                foreach (ContactDetail valReviewer in Reviewer)
                {
                    valReviewer.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

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

                foreach (ContactDetail valEndorser in Endorser)
                {
                    valEndorser.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

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

                foreach (RelatedArtifact valRelatedArtifact in RelatedArtifact)
                {
                    valRelatedArtifact.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

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

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

                foreach (Reference valExposureVariant in ExposureVariant)
                {
                    valExposureVariant.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

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

                foreach (Reference valOutcome in Outcome)
                {
                    valOutcome.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            if (includeStartObject)
            {
                writer.WriteEndObject();
            }
        }
Esempio n. 4
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 ((BasedOn != null) && (BasedOn.Count != 0))
            {
                writer.WritePropertyName("basedOn");
                writer.WriteStartArray();

                foreach (Reference valBasedOn in BasedOn)
                {
                    valBasedOn.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 ((StatusReason != null) && (StatusReason.Count != 0))
            {
                writer.WritePropertyName("statusReason");
                writer.WriteStartArray();

                foreach (CodeableConcept valStatusReason in StatusReason)
                {
                    valStatusReason.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

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

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

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

            if (!string.IsNullOrEmpty(DateAsserted))
            {
                writer.WriteString("dateAsserted", (string)DateAsserted !);
            }

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

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

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

                foreach (Reference valDerivedFrom in DerivedFrom)
                {
                    valDerivedFrom.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            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 ((Dosage != null) && (Dosage.Count != 0))
            {
                writer.WritePropertyName("dosage");
                writer.WriteStartArray();

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

                writer.WriteEndArray();
            }

            if (includeStartObject)
            {
                writer.WriteEndObject();
            }
        }
Esempio n. 5
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 (!string.IsNullOrEmpty(ShortTitle))
            {
                writer.WriteString("shortTitle", (string)ShortTitle !);
            }

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

            if (!string.IsNullOrEmpty(Subtitle))
            {
                writer.WriteString("subtitle", (string)Subtitle !);
            }

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

            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 (SubjectCodeableConcept != null)
            {
                writer.WritePropertyName("subjectCodeableConcept");
                SubjectCodeableConcept.SerializeJson(writer, options);
            }

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

            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 ((Comment != null) && (Comment.Count != 0))
            {
                writer.WritePropertyName("comment");
                writer.WriteStartArray();

                foreach (string valComment in Comment)
                {
                    writer.WriteStringValue(valComment);
                }

                writer.WriteEndArray();
            }

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

                foreach (Element val_Comment in _Comment)
                {
                    val_Comment.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            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(Usage))
            {
                writer.WriteString("usage", (string)Usage !);
            }

            if (_Usage != null)
            {
                writer.WritePropertyName("_usage");
                _Usage.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(ApprovalDate))
            {
                writer.WriteString("approvalDate", (string)ApprovalDate !);
            }

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

            if (!string.IsNullOrEmpty(LastReviewDate))
            {
                writer.WriteString("lastReviewDate", (string)LastReviewDate !);
            }

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

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

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

                foreach (CodeableConcept valTopic in Topic)
                {
                    valTopic.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

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

                foreach (ContactDetail valAuthor in Author)
                {
                    valAuthor.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

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

                foreach (ContactDetail valEditor in Editor)
                {
                    valEditor.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

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

                foreach (ContactDetail valReviewer in Reviewer)
                {
                    valReviewer.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

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

                foreach (ContactDetail valEndorser in Endorser)
                {
                    valEndorser.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

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

                foreach (RelatedArtifact valRelatedArtifact in RelatedArtifact)
                {
                    valRelatedArtifact.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

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

                foreach (string valLibrary in Library)
                {
                    writer.WriteStringValue(valLibrary);
                }

                writer.WriteEndArray();
            }

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

                foreach (Element val_Library in _Library)
                {
                    val_Library.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

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

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

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

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

            if (includeStartObject)
            {
                writer.WriteEndObject();
            }
        }
Esempio n. 6
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 ((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(Status))
            {
                writer.WriteString("status", (string)Status !);
            }

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

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

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

            if (!string.IsNullOrEmpty(Description))
            {
                writer.WriteString("description", (string)Description !);
            }

            if (_Description != null)
            {
                writer.WritePropertyName("_description");
                _Description.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(EffectiveDateTime))
            {
                writer.WriteString("effectiveDateTime", (string)EffectiveDateTime !);
            }

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

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

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

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

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

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

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

                foreach (Reference valProblem in Problem)
                {
                    valProblem.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

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

                foreach (ClinicalImpressionInvestigation valInvestigation in Investigation)
                {
                    valInvestigation.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

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

                foreach (string valProtocol in Protocol)
                {
                    writer.WriteStringValue(valProtocol);
                }

                writer.WriteEndArray();
            }

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

                foreach (Element val_Protocol in _Protocol)
                {
                    val_Protocol.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            if (!string.IsNullOrEmpty(Summary))
            {
                writer.WriteString("summary", (string)Summary !);
            }

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

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

                foreach (ClinicalImpressionFinding valFinding in Finding)
                {
                    valFinding.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

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

                foreach (CodeableConcept valPrognosisCodeableConcept in PrognosisCodeableConcept)
                {
                    valPrognosisCodeableConcept.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

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

                foreach (Reference valPrognosisReference in PrognosisReference)
                {
                    valPrognosisReference.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

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

                foreach (Reference valSupportingInfo in SupportingInfo)
                {
                    valSupportingInfo.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 (includeStartObject)
            {
                writer.WriteEndObject();
            }
        }