Esempio n. 1
0
        /// <summary>
        /// Serialize a FHIR MedicinalProductPharmaceutical#WithdrawalPeriod into JSON
        /// </summary>
        public static void SerializeJson(this MedicinalProductPharmaceutical.WithdrawalPeriodComponent current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true)
        {
            if (includeStartObject)
            {
                writer.WriteStartObject();
            }
            // Component: MedicinalProductPharmaceutical#WithdrawalPeriod, Export: WithdrawalPeriodComponent, Base: BackboneElement (BackboneElement)
            ((Hl7.Fhir.Model.BackboneElement)current).SerializeJson(writer, options, false);

            writer.WritePropertyName("tissue");
            current.Tissue.SerializeJson(writer, options);

            writer.WritePropertyName("value");
            current.Value.SerializeJson(writer, options);

            if (current.SupportingInformationElement != null)
            {
                if (!string.IsNullOrEmpty(current.SupportingInformationElement.Value))
                {
                    writer.WriteString("supportingInformation", current.SupportingInformationElement.Value);
                }
                if (current.SupportingInformationElement.HasExtensions() || (!string.IsNullOrEmpty(current.SupportingInformationElement.ElementId)))
                {
                    JsonStreamUtilities.SerializeExtensionList(writer, options, "_supportingInformation", false, current.SupportingInformationElement.Extension, current.SupportingInformationElement.ElementId);
                }
            }

            if (includeStartObject)
            {
                writer.WriteEndObject();
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Serialize a FHIR Location#Position into JSON
        /// </summary>
        public static void SerializeJson(this Location.PositionComponent current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true)
        {
            if (includeStartObject)
            {
                writer.WriteStartObject();
            }
            // Component: Location#Position, Export: PositionComponent, Base: BackboneElement (BackboneElement)
            ((Hl7.Fhir.Model.BackboneElement)current).SerializeJson(writer, options, false);

            writer.WriteNumber("longitude", (decimal)current.LongitudeElement.Value);

            writer.WriteNumber("latitude", (decimal)current.LatitudeElement.Value);

            if (current.AltitudeElement != null)
            {
                if (current.AltitudeElement.Value != null)
                {
                    writer.WriteNumber("altitude", (decimal)current.AltitudeElement.Value);
                }
                if (current.AltitudeElement.HasExtensions() || (!string.IsNullOrEmpty(current.AltitudeElement.ElementId)))
                {
                    JsonStreamUtilities.SerializeExtensionList(writer, options, "_altitude", false, current.AltitudeElement.Extension, current.AltitudeElement.ElementId);
                }
            }

            if (includeStartObject)
            {
                writer.WriteEndObject();
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Serialize a FHIR Account#Coverage into JSON
        /// </summary>
        public static void SerializeJson(this Account.CoverageComponent current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true)
        {
            if (includeStartObject)
            {
                writer.WriteStartObject();
            }
            // Component: Account#Coverage, Export: CoverageComponent, Base: BackboneElement (BackboneElement)
            ((Hl7.Fhir.Model.BackboneElement)current).SerializeJson(writer, options, false);

            writer.WritePropertyName("coverage");
            current.Coverage.SerializeJson(writer, options);

            if (current.PriorityElement != null)
            {
                if (current.PriorityElement.Value != null)
                {
                    writer.WriteNumber("priority", (int)current.PriorityElement.Value);
                }
                if (current.PriorityElement.HasExtensions() || (!string.IsNullOrEmpty(current.PriorityElement.ElementId)))
                {
                    JsonStreamUtilities.SerializeExtensionList(writer, options, "_priority", false, current.PriorityElement.Extension, current.PriorityElement.ElementId);
                }
            }

            if (includeStartObject)
            {
                writer.WriteEndObject();
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Serialize a FHIR Composition#Attester into JSON
        /// </summary>
        public static void SerializeJson(this Composition.AttesterComponent current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true)
        {
            if (includeStartObject)
            {
                writer.WriteStartObject();
            }
            // Component: Composition#Attester, Export: AttesterComponent, Base: BackboneElement (BackboneElement)
            ((Hl7.Fhir.Model.BackboneElement)current).SerializeJson(writer, options, false);

            writer.WriteString("mode", Hl7.Fhir.Utility.EnumUtility.GetLiteral(current.ModeElement.Value));

            if (current.TimeElement != null)
            {
                if (!string.IsNullOrEmpty(current.TimeElement.Value))
                {
                    writer.WriteString("time", current.TimeElement.Value);
                }
                if (current.TimeElement.HasExtensions() || (!string.IsNullOrEmpty(current.TimeElement.ElementId)))
                {
                    JsonStreamUtilities.SerializeExtensionList(writer, options, "_time", false, current.TimeElement.Extension, current.TimeElement.ElementId);
                }
            }

            if (current.Party != null)
            {
                writer.WritePropertyName("party");
                current.Party.SerializeJson(writer, options);
            }

            if (includeStartObject)
            {
                writer.WriteEndObject();
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Serialize a FHIR EpisodeOfCare#Diagnosis into JSON
        /// </summary>
        public static void SerializeJson(this EpisodeOfCare.DiagnosisComponent current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true)
        {
            if (includeStartObject)
            {
                writer.WriteStartObject();
            }
            // Component: EpisodeOfCare#Diagnosis, Export: DiagnosisComponent, Base: BackboneElement (BackboneElement)
            ((Hl7.Fhir.Model.BackboneElement)current).SerializeJson(writer, options, false);

            writer.WritePropertyName("condition");
            current.Condition.SerializeJson(writer, options);

            if (current.Role != null)
            {
                writer.WritePropertyName("role");
                current.Role.SerializeJson(writer, options);
            }

            if (current.RankElement != null)
            {
                if (current.RankElement.Value != null)
                {
                    writer.WriteNumber("rank", (int)current.RankElement.Value);
                }
                if (current.RankElement.HasExtensions() || (!string.IsNullOrEmpty(current.RankElement.ElementId)))
                {
                    JsonStreamUtilities.SerializeExtensionList(writer, options, "_rank", false, current.RankElement.Extension, current.RankElement.ElementId);
                }
            }

            if (includeStartObject)
            {
                writer.WriteEndObject();
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Serialize a FHIR RelatedPerson#Communication into JSON
        /// </summary>
        public static void SerializeJson(this RelatedPerson.CommunicationComponent current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true)
        {
            if (includeStartObject)
            {
                writer.WriteStartObject();
            }
            // Component: RelatedPerson#Communication, Export: CommunicationComponent, Base: BackboneElement (BackboneElement)
            ((Hl7.Fhir.Model.BackboneElement)current).SerializeJson(writer, options, false);

            writer.WritePropertyName("language");
            current.Language.SerializeJson(writer, options);

            if (current.PreferredElement != null)
            {
                if (current.PreferredElement.Value != null)
                {
                    writer.WriteBoolean("preferred", (bool)current.PreferredElement.Value);
                }
                if (current.PreferredElement.HasExtensions() || (!string.IsNullOrEmpty(current.PreferredElement.ElementId)))
                {
                    JsonStreamUtilities.SerializeExtensionList(writer, options, "_preferred", false, current.PreferredElement.Extension, current.PreferredElement.ElementId);
                }
            }

            if (includeStartObject)
            {
                writer.WriteEndObject();
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Serialize a FHIR Binary into JSON
        /// </summary>
        public static void SerializeJson(this Binary current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true)
        {
            if (includeStartObject)
            {
                writer.WriteStartObject();
            }
            writer.WriteString("resourceType", "Binary");
            // Complex: Binary, Export: Binary, Base: Resource (Resource)
            ((Hl7.Fhir.Model.Resource)current).SerializeJson(writer, options, false);

            writer.WriteString("contentType", current.ContentTypeElement.Value.Trim());

            if (current.SecurityContext != null)
            {
                writer.WritePropertyName("securityContext");
                current.SecurityContext.SerializeJson(writer, options);
            }

            if (current.DataElement != null)
            {
                if (current.DataElement.Value != null)
                {
                    writer.WriteString("data", System.Convert.ToBase64String(current.DataElement.Value));
                }
                if (current.DataElement.HasExtensions() || (!string.IsNullOrEmpty(current.DataElement.ElementId)))
                {
                    JsonStreamUtilities.SerializeExtensionList(writer, options, "_data", false, current.DataElement.Extension, current.DataElement.ElementId);
                }
            }

            if (includeStartObject)
            {
                writer.WriteEndObject();
            }
        }
Esempio n. 8
0
        /// <summary>
        /// Serialize a FHIR Person#Link into JSON
        /// </summary>
        public static void SerializeJson(this Person.LinkComponent current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true)
        {
            if (includeStartObject)
            {
                writer.WriteStartObject();
            }
            // Component: Person#Link, Export: LinkComponent, Base: BackboneElement (BackboneElement)
            ((Hl7.Fhir.Model.BackboneElement)current).SerializeJson(writer, options, false);

            writer.WritePropertyName("target");
            current.Target.SerializeJson(writer, options);

            if (current.AssuranceElement != null)
            {
                if (current.AssuranceElement.Value != null)
                {
                    writer.WriteString("assurance", Hl7.Fhir.Utility.EnumUtility.GetLiteral(current.AssuranceElement.Value));
                }
                if (current.AssuranceElement.HasExtensions() || (!string.IsNullOrEmpty(current.AssuranceElement.ElementId)))
                {
                    JsonStreamUtilities.SerializeExtensionList(writer, options, "_assurance", false, current.AssuranceElement.Extension, current.AssuranceElement.ElementId);
                }
            }

            if (includeStartObject)
            {
                writer.WriteEndObject();
            }
        }
Esempio n. 9
0
        /// <summary>
        /// Serialize a FHIR ResearchStudy#Arm into JSON
        /// </summary>
        public static void SerializeJson(this ResearchStudy.ArmComponent current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true)
        {
            if (includeStartObject)
            {
                writer.WriteStartObject();
            }
            // Component: ResearchStudy#Arm, Export: ArmComponent, Base: BackboneElement (BackboneElement)
            ((Hl7.Fhir.Model.BackboneElement)current).SerializeJson(writer, options, false);

            writer.WriteString("name", current.NameElement.Value);

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

            if (current.DescriptionElement != null)
            {
                if (!string.IsNullOrEmpty(current.DescriptionElement.Value))
                {
                    writer.WriteString("description", current.DescriptionElement.Value);
                }
                if (current.DescriptionElement.HasExtensions() || (!string.IsNullOrEmpty(current.DescriptionElement.ElementId)))
                {
                    JsonStreamUtilities.SerializeExtensionList(writer, options, "_description", false, current.DescriptionElement.Extension, current.DescriptionElement.ElementId);
                }
            }

            if (includeStartObject)
            {
                writer.WriteEndObject();
            }
        }
Esempio n. 10
0
        /// <summary>
        /// Serialize a FHIR Group#Member into JSON
        /// </summary>
        public static void SerializeJson(this Group.MemberComponent current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true)
        {
            if (includeStartObject)
            {
                writer.WriteStartObject();
            }
            // Component: Group#Member, Export: MemberComponent, Base: BackboneElement (BackboneElement)
            ((Hl7.Fhir.Model.BackboneElement)current).SerializeJson(writer, options, false);

            writer.WritePropertyName("entity");
            current.Entity.SerializeJson(writer, options);

            if (current.Period != null)
            {
                writer.WritePropertyName("period");
                current.Period.SerializeJson(writer, options);
            }

            if (current.InactiveElement != null)
            {
                if (current.InactiveElement.Value != null)
                {
                    writer.WriteBoolean("inactive", (bool)current.InactiveElement.Value);
                }
                if (current.InactiveElement.HasExtensions() || (!string.IsNullOrEmpty(current.InactiveElement.ElementId)))
                {
                    JsonStreamUtilities.SerializeExtensionList(writer, options, "_inactive", false, current.InactiveElement.Extension, current.InactiveElement.ElementId);
                }
            }

            if (includeStartObject)
            {
                writer.WriteEndObject();
            }
        }
Esempio n. 11
0
        /// <summary>
        /// Serialize a FHIR DiagnosticReport#Media into JSON
        /// </summary>
        public static void SerializeJson(this DiagnosticReport.MediaComponent current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true)
        {
            if (includeStartObject)
            {
                writer.WriteStartObject();
            }
            // Component: DiagnosticReport#Media, Export: MediaComponent, Base: BackboneElement (BackboneElement)
            ((Hl7.Fhir.Model.BackboneElement)current).SerializeJson(writer, options, false);

            if (current.CommentElement != null)
            {
                if (!string.IsNullOrEmpty(current.CommentElement.Value))
                {
                    writer.WriteString("comment", current.CommentElement.Value);
                }
                if (current.CommentElement.HasExtensions() || (!string.IsNullOrEmpty(current.CommentElement.ElementId)))
                {
                    JsonStreamUtilities.SerializeExtensionList(writer, options, "_comment", false, current.CommentElement.Extension, current.CommentElement.ElementId);
                }
            }

            writer.WritePropertyName("link");
            current.Link.SerializeJson(writer, options);

            if (includeStartObject)
            {
                writer.WriteEndObject();
            }
        }
Esempio n. 12
0
        /// <summary>
        /// Serialize a FHIR DetectedIssue#Mitigation into JSON
        /// </summary>
        public static void SerializeJson(this DetectedIssue.MitigationComponent current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true)
        {
            if (includeStartObject)
            {
                writer.WriteStartObject();
            }
            // Component: DetectedIssue#Mitigation, Export: MitigationComponent, Base: BackboneElement (BackboneElement)
            ((Hl7.Fhir.Model.BackboneElement)current).SerializeJson(writer, options, false);

            writer.WritePropertyName("action");
            current.Action.SerializeJson(writer, options);

            if (current.DateElement != null)
            {
                if (!string.IsNullOrEmpty(current.DateElement.Value))
                {
                    writer.WriteString("date", current.DateElement.Value);
                }
                if (current.DateElement.HasExtensions() || (!string.IsNullOrEmpty(current.DateElement.ElementId)))
                {
                    JsonStreamUtilities.SerializeExtensionList(writer, options, "_date", false, current.DateElement.Extension, current.DateElement.ElementId);
                }
            }

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

            if (includeStartObject)
            {
                writer.WriteEndObject();
            }
        }
Esempio n. 13
0
        /// <summary>
        /// Serialize a FHIR MessageHeader#MessageSource into JSON
        /// </summary>
        public static void SerializeJson(this MessageHeader.MessageSourceComponent current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true)
        {
            if (includeStartObject)
            {
                writer.WriteStartObject();
            }
            // Component: MessageHeader#MessageSource, Export: MessageSourceComponent, Base: BackboneElement (BackboneElement)
            ((Hl7.Fhir.Model.BackboneElement)current).SerializeJson(writer, options, false);

            if (current.NameElement != null)
            {
                if (!string.IsNullOrEmpty(current.NameElement.Value))
                {
                    writer.WriteString("name", current.NameElement.Value);
                }
                if (current.NameElement.HasExtensions() || (!string.IsNullOrEmpty(current.NameElement.ElementId)))
                {
                    JsonStreamUtilities.SerializeExtensionList(writer, options, "_name", false, current.NameElement.Extension, current.NameElement.ElementId);
                }
            }

            if (current.SoftwareElement != null)
            {
                if (!string.IsNullOrEmpty(current.SoftwareElement.Value))
                {
                    writer.WriteString("software", current.SoftwareElement.Value);
                }
                if (current.SoftwareElement.HasExtensions() || (!string.IsNullOrEmpty(current.SoftwareElement.ElementId)))
                {
                    JsonStreamUtilities.SerializeExtensionList(writer, options, "_software", false, current.SoftwareElement.Extension, current.SoftwareElement.ElementId);
                }
            }

            if (current.VersionElement != null)
            {
                if (!string.IsNullOrEmpty(current.VersionElement.Value))
                {
                    writer.WriteString("version", current.VersionElement.Value);
                }
                if (current.VersionElement.HasExtensions() || (!string.IsNullOrEmpty(current.VersionElement.ElementId)))
                {
                    JsonStreamUtilities.SerializeExtensionList(writer, options, "_version", false, current.VersionElement.Extension, current.VersionElement.ElementId);
                }
            }

            if (current.Contact != null)
            {
                writer.WritePropertyName("contact");
                current.Contact.SerializeJson(writer, options);
            }

            writer.WriteString("endpoint", current.EndpointElement.Value);

            if (includeStartObject)
            {
                writer.WriteEndObject();
            }
        }
Esempio n. 14
0
        /// <summary>
        /// Serialize a FHIR Bundle#Response into JSON
        /// </summary>
        public static void SerializeJson(this Bundle.ResponseComponent current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true)
        {
            if (includeStartObject)
            {
                writer.WriteStartObject();
            }
            // Component: Bundle#Response, Export: ResponseComponent, Base: BackboneElement (BackboneElement)
            ((Hl7.Fhir.Model.BackboneElement)current).SerializeJson(writer, options, false);

            writer.WriteString("status", current.StatusElement.Value);

            if (current.LocationElement != null)
            {
                if (!string.IsNullOrEmpty(current.LocationElement.Value))
                {
                    writer.WriteString("location", current.LocationElement.Value);
                }
                if (current.LocationElement.HasExtensions() || (!string.IsNullOrEmpty(current.LocationElement.ElementId)))
                {
                    JsonStreamUtilities.SerializeExtensionList(writer, options, "_location", false, current.LocationElement.Extension, current.LocationElement.ElementId);
                }
            }

            if (current.EtagElement != null)
            {
                if (!string.IsNullOrEmpty(current.EtagElement.Value))
                {
                    writer.WriteString("etag", current.EtagElement.Value);
                }
                if (current.EtagElement.HasExtensions() || (!string.IsNullOrEmpty(current.EtagElement.ElementId)))
                {
                    JsonStreamUtilities.SerializeExtensionList(writer, options, "_etag", false, current.EtagElement.Extension, current.EtagElement.ElementId);
                }
            }

            if (current.LastModifiedElement != null)
            {
                if (current.LastModifiedElement.Value != null)
                {
                    writer.WriteString("lastModified", ((DateTimeOffset)current.LastModifiedElement.Value).ToString("yyyy-MM-dd'T'HH:mm:ss.FFFFFFFK", System.Globalization.CultureInfo.InvariantCulture));
                }
                if (current.LastModifiedElement.HasExtensions() || (!string.IsNullOrEmpty(current.LastModifiedElement.ElementId)))
                {
                    JsonStreamUtilities.SerializeExtensionList(writer, options, "_lastModified", false, current.LastModifiedElement.Extension, current.LastModifiedElement.ElementId);
                }
            }

            if (current.Outcome != null)
            {
                writer.WritePropertyName("outcome");
                JsonSerializer.Serialize <object>(writer, (Hl7.Fhir.Model.Resource)current.Outcome, options);
            }

            if (includeStartObject)
            {
                writer.WriteEndObject();
            }
        }
        /// <summary>
        /// Serialize a FHIR MedicinalProductAuthorization#Procedure into JSON
        /// </summary>
        public static void SerializeJson(this MedicinalProductAuthorization.ProcedureComponent current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true)
        {
            if (includeStartObject)
            {
                writer.WriteStartObject();
            }
            // Component: MedicinalProductAuthorization#Procedure, Export: ProcedureComponent, Base: BackboneElement (BackboneElement)
            ((Hl7.Fhir.Model.BackboneElement)current).SerializeJson(writer, options, false);

            if (current.Identifier != null)
            {
                writer.WritePropertyName("identifier");
                current.Identifier.SerializeJson(writer, options);
            }

            writer.WritePropertyName("type");
            current.Type.SerializeJson(writer, options);

            if (current.Date != null)
            {
                switch (current.Date)
                {
                case Period v_Period:
                    writer.WritePropertyName("datePeriod");
                    v_Period.SerializeJson(writer, options);
                    break;

                case FhirDateTime v_FhirDateTime:
                    if (v_FhirDateTime != null)
                    {
                        if (!string.IsNullOrEmpty(v_FhirDateTime.Value))
                        {
                            writer.WriteString("dateDateTime", v_FhirDateTime.Value);
                        }
                        if (v_FhirDateTime.HasExtensions() || (!string.IsNullOrEmpty(v_FhirDateTime.ElementId)))
                        {
                            JsonStreamUtilities.SerializeExtensionList(writer, options, "_dateDateTime", false, v_FhirDateTime.Extension, v_FhirDateTime.ElementId);
                        }
                    }
                    break;
                }
            }
            if ((current.Application != null) && (current.Application.Count != 0))
            {
                writer.WritePropertyName("application");
                writer.WriteStartArray();
                foreach (MedicinalProductAuthorization.ProcedureComponent val in current.Application)
                {
                    val.SerializeJson(writer, options, true);
                }
                writer.WriteEndArray();
            }

            if (includeStartObject)
            {
                writer.WriteEndObject();
            }
        }
        /// <summary>
        /// Serialize a FHIR BiologicallyDerivedProduct#Storage into JSON
        /// </summary>
        public static void SerializeJson(this BiologicallyDerivedProduct.StorageComponent current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true)
        {
            if (includeStartObject)
            {
                writer.WriteStartObject();
            }
            // Component: BiologicallyDerivedProduct#Storage, Export: StorageComponent, Base: BackboneElement (BackboneElement)
            ((Hl7.Fhir.Model.BackboneElement)current).SerializeJson(writer, options, false);

            if (current.DescriptionElement != null)
            {
                if (!string.IsNullOrEmpty(current.DescriptionElement.Value))
                {
                    writer.WriteString("description", current.DescriptionElement.Value);
                }
                if (current.DescriptionElement.HasExtensions() || (!string.IsNullOrEmpty(current.DescriptionElement.ElementId)))
                {
                    JsonStreamUtilities.SerializeExtensionList(writer, options, "_description", false, current.DescriptionElement.Extension, current.DescriptionElement.ElementId);
                }
            }

            if (current.TemperatureElement != null)
            {
                if (current.TemperatureElement.Value != null)
                {
                    writer.WriteNumber("temperature", (decimal)current.TemperatureElement.Value);
                }
                if (current.TemperatureElement.HasExtensions() || (!string.IsNullOrEmpty(current.TemperatureElement.ElementId)))
                {
                    JsonStreamUtilities.SerializeExtensionList(writer, options, "_temperature", false, current.TemperatureElement.Extension, current.TemperatureElement.ElementId);
                }
            }

            if (current.ScaleElement != null)
            {
                if (current.ScaleElement.Value != null)
                {
                    writer.WriteString("scale", Hl7.Fhir.Utility.EnumUtility.GetLiteral(current.ScaleElement.Value));
                }
                if (current.ScaleElement.HasExtensions() || (!string.IsNullOrEmpty(current.ScaleElement.ElementId)))
                {
                    JsonStreamUtilities.SerializeExtensionList(writer, options, "_scale", false, current.ScaleElement.Extension, current.ScaleElement.ElementId);
                }
            }

            if (current.Duration != null)
            {
                writer.WritePropertyName("duration");
                current.Duration.SerializeJson(writer, options);
            }

            if (includeStartObject)
            {
                writer.WriteEndObject();
            }
        }
Esempio n. 17
0
        /// <summary>
        /// Serialize a FHIR Reference into JSON
        /// </summary>
        public static void SerializeJson(this ResourceReference current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true)
        {
            if (includeStartObject)
            {
                writer.WriteStartObject();
            }
            // Complex: Reference, Export: ResourceReference, Base: Element (Element)
            ((Hl7.Fhir.Model.Element)current).SerializeJson(writer, options, false);

            if (current.ReferenceElement != null)
            {
                if (!string.IsNullOrEmpty(current.ReferenceElement.Value))
                {
                    writer.WriteString("reference", current.ReferenceElement.Value);
                }
                if (current.ReferenceElement.HasExtensions() || (!string.IsNullOrEmpty(current.ReferenceElement.ElementId)))
                {
                    JsonStreamUtilities.SerializeExtensionList(writer, options, "_reference", false, current.ReferenceElement.Extension, current.ReferenceElement.ElementId);
                }
            }

            if (current.TypeElement != null)
            {
                if (!string.IsNullOrEmpty(current.TypeElement.Value))
                {
                    writer.WriteString("type", current.TypeElement.Value);
                }
                if (current.TypeElement.HasExtensions() || (!string.IsNullOrEmpty(current.TypeElement.ElementId)))
                {
                    JsonStreamUtilities.SerializeExtensionList(writer, options, "_type", false, current.TypeElement.Extension, current.TypeElement.ElementId);
                }
            }

            if (current.Identifier != null)
            {
                writer.WritePropertyName("identifier");
                current.Identifier.SerializeJson(writer, options);
            }

            if (current.DisplayElement != null)
            {
                if (!string.IsNullOrEmpty(current.DisplayElement.Value))
                {
                    writer.WriteString("display", current.DisplayElement.Value);
                }
                if (current.DisplayElement.HasExtensions() || (!string.IsNullOrEmpty(current.DisplayElement.ElementId)))
                {
                    JsonStreamUtilities.SerializeExtensionList(writer, options, "_display", false, current.DisplayElement.Extension, current.DisplayElement.ElementId);
                }
            }

            if (includeStartObject)
            {
                writer.WriteEndObject();
            }
        }
Esempio n. 18
0
        /// <summary>
        /// Serialize a FHIR DeviceRequest#Parameter into JSON
        /// </summary>
        public static void SerializeJson(this DeviceRequest.ParameterComponent current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true)
        {
            if (includeStartObject)
            {
                writer.WriteStartObject();
            }
            // Component: DeviceRequest#Parameter, Export: ParameterComponent, Base: BackboneElement (BackboneElement)
            ((Hl7.Fhir.Model.BackboneElement)current).SerializeJson(writer, options, false);

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

            if (current.Value != null)
            {
                switch (current.Value)
                {
                case CodeableConcept v_CodeableConcept:
                    writer.WritePropertyName("valueCodeableConcept");
                    v_CodeableConcept.SerializeJson(writer, options);
                    break;

                case Quantity v_Quantity:
                    writer.WritePropertyName("valueQuantity");
                    v_Quantity.SerializeJson(writer, options);
                    break;

                case Range v_Range:
                    writer.WritePropertyName("valueRange");
                    v_Range.SerializeJson(writer, options);
                    break;

                case FhirBoolean v_FhirBoolean:
                    if (v_FhirBoolean != null)
                    {
                        if (v_FhirBoolean.Value != null)
                        {
                            writer.WriteBoolean("valueBoolean", (bool)v_FhirBoolean.Value);
                        }
                        if (v_FhirBoolean.HasExtensions() || (!string.IsNullOrEmpty(v_FhirBoolean.ElementId)))
                        {
                            JsonStreamUtilities.SerializeExtensionList(writer, options, "_valueBoolean", false, v_FhirBoolean.Extension, v_FhirBoolean.ElementId);
                        }
                    }
                    break;
                }
            }
            if (includeStartObject)
            {
                writer.WriteEndObject();
            }
        }
Esempio n. 19
0
        /// <summary>
        /// Serialize a FHIR Resource into JSON
        /// </summary>
        public static void SerializeJson(this Resource current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true)
        {
            if (includeStartObject)
            {
                writer.WriteStartObject();
            }
            if (current.IdElement != null)
            {
                if (!string.IsNullOrEmpty(current.IdElement.Value))
                {
                    writer.WriteString("id", current.IdElement.Value);
                }
                if (current.IdElement.HasExtensions() || (!string.IsNullOrEmpty(current.IdElement.ElementId)))
                {
                    JsonStreamUtilities.SerializeExtensionList(writer, options, "_id", false, current.IdElement.Extension, current.IdElement.ElementId);
                }
            }

            if (current.Meta != null)
            {
                writer.WritePropertyName("meta");
                current.Meta.SerializeJson(writer, options);
            }

            if (current.ImplicitRulesElement != null)
            {
                if (!string.IsNullOrEmpty(current.ImplicitRulesElement.Value))
                {
                    writer.WriteString("implicitRules", current.ImplicitRulesElement.Value);
                }
                if (current.ImplicitRulesElement.HasExtensions() || (!string.IsNullOrEmpty(current.ImplicitRulesElement.ElementId)))
                {
                    JsonStreamUtilities.SerializeExtensionList(writer, options, "_implicitRules", false, current.ImplicitRulesElement.Extension, current.ImplicitRulesElement.ElementId);
                }
            }

            if (current.LanguageElement != null)
            {
                if (!string.IsNullOrEmpty(current.LanguageElement.Value))
                {
                    writer.WriteString("language", current.LanguageElement.Value.Trim());
                }
                if (current.LanguageElement.HasExtensions() || (!string.IsNullOrEmpty(current.LanguageElement.ElementId)))
                {
                    JsonStreamUtilities.SerializeExtensionList(writer, options, "_language", false, current.LanguageElement.Extension, current.LanguageElement.ElementId);
                }
            }

            if (includeStartObject)
            {
                writer.WriteEndObject();
            }
        }
Esempio n. 20
0
        /// <summary>
        /// Serialize a FHIR Basic into JSON
        /// </summary>
        public static void SerializeJson(this Basic current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true)
        {
            if (includeStartObject)
            {
                writer.WriteStartObject();
            }
            writer.WriteString("resourceType", "Basic");
            // Complex: Basic, Export: Basic, Base: DomainResource (DomainResource)
            ((Hl7.Fhir.Model.DomainResource)current).SerializeJson(writer, options, false);

            if ((current.Identifier != null) && (current.Identifier.Count != 0))
            {
                writer.WritePropertyName("identifier");
                writer.WriteStartArray();
                foreach (Identifier val in current.Identifier)
                {
                    val.SerializeJson(writer, options, true);
                }
                writer.WriteEndArray();
            }

            writer.WritePropertyName("code");
            current.Code.SerializeJson(writer, options);

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

            if (current.CreatedElement != null)
            {
                if (!string.IsNullOrEmpty(current.CreatedElement.Value))
                {
                    writer.WriteString("created", current.CreatedElement.Value);
                }
                if (current.CreatedElement.HasExtensions() || (!string.IsNullOrEmpty(current.CreatedElement.ElementId)))
                {
                    JsonStreamUtilities.SerializeExtensionList(writer, options, "_created", false, current.CreatedElement.Extension, current.CreatedElement.ElementId);
                }
            }

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

            if (includeStartObject)
            {
                writer.WriteEndObject();
            }
        }
Esempio n. 21
0
        /// <summary>
        /// Serialize a FHIR Invoice#LineItem into JSON
        /// </summary>
        public static void SerializeJson(this Invoice.LineItemComponent current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true)
        {
            if (includeStartObject)
            {
                writer.WriteStartObject();
            }
            // Component: Invoice#LineItem, Export: LineItemComponent, Base: BackboneElement (BackboneElement)
            ((Hl7.Fhir.Model.BackboneElement)current).SerializeJson(writer, options, false);

            if (current.SequenceElement != null)
            {
                if (current.SequenceElement.Value != null)
                {
                    writer.WriteNumber("sequence", (int)current.SequenceElement.Value);
                }
                if (current.SequenceElement.HasExtensions() || (!string.IsNullOrEmpty(current.SequenceElement.ElementId)))
                {
                    JsonStreamUtilities.SerializeExtensionList(writer, options, "_sequence", false, current.SequenceElement.Extension, current.SequenceElement.ElementId);
                }
            }

            if (current.ChargeItem != null)
            {
                switch (current.ChargeItem)
                {
                case ResourceReference v_ResourceReference:
                    writer.WritePropertyName("chargeItemReference");
                    v_ResourceReference.SerializeJson(writer, options);
                    break;

                case CodeableConcept v_CodeableConcept:
                    writer.WritePropertyName("chargeItemCodeableConcept");
                    v_CodeableConcept.SerializeJson(writer, options);
                    break;
                }
            }
            if ((current.PriceComponent != null) && (current.PriceComponent.Count != 0))
            {
                writer.WritePropertyName("priceComponent");
                writer.WriteStartArray();
                foreach (Invoice.PriceComponentComponent val in current.PriceComponent)
                {
                    val.SerializeJson(writer, options, true);
                }
                writer.WriteEndArray();
            }

            if (includeStartObject)
            {
                writer.WriteEndObject();
            }
        }
Esempio n. 22
0
        /// <summary>
        /// Serialize a FHIR MedicinalProductIngredient#ReferenceStrength into JSON
        /// </summary>
        public static void SerializeJson(this MedicinalProductIngredient.ReferenceStrengthComponent current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true)
        {
            if (includeStartObject)
            {
                writer.WriteStartObject();
            }
            // Component: MedicinalProductIngredient#ReferenceStrength, Export: ReferenceStrengthComponent, Base: BackboneElement (BackboneElement)
            ((Hl7.Fhir.Model.BackboneElement)current).SerializeJson(writer, options, false);

            if (current.Substance != null)
            {
                writer.WritePropertyName("substance");
                current.Substance.SerializeJson(writer, options);
            }

            writer.WritePropertyName("strength");
            current.Strength.SerializeJson(writer, options);

            if (current.StrengthLowLimit != null)
            {
                writer.WritePropertyName("strengthLowLimit");
                current.StrengthLowLimit.SerializeJson(writer, options);
            }

            if (current.MeasurementPointElement != null)
            {
                if (!string.IsNullOrEmpty(current.MeasurementPointElement.Value))
                {
                    writer.WriteString("measurementPoint", current.MeasurementPointElement.Value);
                }
                if (current.MeasurementPointElement.HasExtensions() || (!string.IsNullOrEmpty(current.MeasurementPointElement.ElementId)))
                {
                    JsonStreamUtilities.SerializeExtensionList(writer, options, "_measurementPoint", false, current.MeasurementPointElement.Extension, current.MeasurementPointElement.ElementId);
                }
            }

            if ((current.Country != null) && (current.Country.Count != 0))
            {
                writer.WritePropertyName("country");
                writer.WriteStartArray();
                foreach (CodeableConcept val in current.Country)
                {
                    val.SerializeJson(writer, options, true);
                }
                writer.WriteEndArray();
            }

            if (includeStartObject)
            {
                writer.WriteEndObject();
            }
        }
Esempio n. 23
0
        /// <summary>
        /// Serialize a FHIR Annotation into JSON
        /// </summary>
        public static void SerializeJson(this Annotation current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true)
        {
            if (includeStartObject)
            {
                writer.WriteStartObject();
            }
            // Complex: Annotation, Export: Annotation, Base: Element (Element)
            ((Hl7.Fhir.Model.Element)current).SerializeJson(writer, options, false);

            if (current.Author != null)
            {
                switch (current.Author)
                {
                case ResourceReference v_ResourceReference:
                    writer.WritePropertyName("authorReference");
                    v_ResourceReference.SerializeJson(writer, options);
                    break;

                case FhirString v_FhirString:
                    if (v_FhirString != null)
                    {
                        if (!string.IsNullOrEmpty(v_FhirString.Value))
                        {
                            writer.WriteString("authorString", v_FhirString.Value);
                        }
                        if (v_FhirString.HasExtensions() || (!string.IsNullOrEmpty(v_FhirString.ElementId)))
                        {
                            JsonStreamUtilities.SerializeExtensionList(writer, options, "_authorString", false, v_FhirString.Extension, v_FhirString.ElementId);
                        }
                    }
                    break;
                }
            }
            if (current.TimeElement != null)
            {
                if (!string.IsNullOrEmpty(current.TimeElement.Value))
                {
                    writer.WriteString("time", current.TimeElement.Value);
                }
                if (current.TimeElement.HasExtensions() || (!string.IsNullOrEmpty(current.TimeElement.ElementId)))
                {
                    JsonStreamUtilities.SerializeExtensionList(writer, options, "_time", false, current.TimeElement.Extension, current.TimeElement.ElementId);
                }
            }

            writer.WriteString("text", current.Text.Value);

            if (includeStartObject)
            {
                writer.WriteEndObject();
            }
        }
Esempio n. 24
0
        /// <summary>
        /// Serialize a FHIR Appointment#Participant into JSON
        /// </summary>
        public static void SerializeJson(this Appointment.ParticipantComponent current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true)
        {
            if (includeStartObject)
            {
                writer.WriteStartObject();
            }
            // Component: Appointment#Participant, Export: ParticipantComponent, Base: BackboneElement (BackboneElement)
            ((Hl7.Fhir.Model.BackboneElement)current).SerializeJson(writer, options, false);

            if ((current.Type != null) && (current.Type.Count != 0))
            {
                writer.WritePropertyName("type");
                writer.WriteStartArray();
                foreach (CodeableConcept val in current.Type)
                {
                    val.SerializeJson(writer, options, true);
                }
                writer.WriteEndArray();
            }

            if (current.Actor != null)
            {
                writer.WritePropertyName("actor");
                current.Actor.SerializeJson(writer, options);
            }

            if (current.RequiredElement != null)
            {
                if (current.RequiredElement.Value != null)
                {
                    writer.WriteString("required", Hl7.Fhir.Utility.EnumUtility.GetLiteral(current.RequiredElement.Value));
                }
                if (current.RequiredElement.HasExtensions() || (!string.IsNullOrEmpty(current.RequiredElement.ElementId)))
                {
                    JsonStreamUtilities.SerializeExtensionList(writer, options, "_required", false, current.RequiredElement.Extension, current.RequiredElement.ElementId);
                }
            }

            writer.WriteString("status", Hl7.Fhir.Utility.EnumUtility.GetLiteral(current.StatusElement.Value));

            if (current.Period != null)
            {
                writer.WritePropertyName("period");
                current.Period.SerializeJson(writer, options);
            }

            if (includeStartObject)
            {
                writer.WriteEndObject();
            }
        }
Esempio n. 25
0
        /// <summary>
        /// Serialize a FHIR DeviceMetric#Calibration into JSON
        /// </summary>
        public static void SerializeJson(this DeviceMetric.CalibrationComponent current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true)
        {
            if (includeStartObject)
            {
                writer.WriteStartObject();
            }
            // Component: DeviceMetric#Calibration, Export: CalibrationComponent, Base: BackboneElement (BackboneElement)
            ((Hl7.Fhir.Model.BackboneElement)current).SerializeJson(writer, options, false);

            if (current.TypeElement != null)
            {
                if (current.TypeElement.Value != null)
                {
                    writer.WriteString("type", Hl7.Fhir.Utility.EnumUtility.GetLiteral(current.TypeElement.Value));
                }
                if (current.TypeElement.HasExtensions() || (!string.IsNullOrEmpty(current.TypeElement.ElementId)))
                {
                    JsonStreamUtilities.SerializeExtensionList(writer, options, "_type", false, current.TypeElement.Extension, current.TypeElement.ElementId);
                }
            }

            if (current.StateElement != null)
            {
                if (current.StateElement.Value != null)
                {
                    writer.WriteString("state", Hl7.Fhir.Utility.EnumUtility.GetLiteral(current.StateElement.Value));
                }
                if (current.StateElement.HasExtensions() || (!string.IsNullOrEmpty(current.StateElement.ElementId)))
                {
                    JsonStreamUtilities.SerializeExtensionList(writer, options, "_state", false, current.StateElement.Extension, current.StateElement.ElementId);
                }
            }

            if (current.TimeElement != null)
            {
                if (current.TimeElement.Value != null)
                {
                    writer.WriteString("time", ((DateTimeOffset)current.TimeElement.Value).ToString("yyyy-MM-dd'T'HH:mm:ss.FFFFFFFK", System.Globalization.CultureInfo.InvariantCulture));
                }
                if (current.TimeElement.HasExtensions() || (!string.IsNullOrEmpty(current.TimeElement.ElementId)))
                {
                    JsonStreamUtilities.SerializeExtensionList(writer, options, "_time", false, current.TimeElement.Extension, current.TimeElement.ElementId);
                }
            }

            if (includeStartObject)
            {
                writer.WriteEndObject();
            }
        }
        /// <summary>
        /// Serialize a FHIR BiologicallyDerivedProduct#Manipulation into JSON
        /// </summary>
        public static void SerializeJson(this BiologicallyDerivedProduct.ManipulationComponent current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true)
        {
            if (includeStartObject)
            {
                writer.WriteStartObject();
            }
            // Component: BiologicallyDerivedProduct#Manipulation, Export: ManipulationComponent, Base: BackboneElement (BackboneElement)
            ((Hl7.Fhir.Model.BackboneElement)current).SerializeJson(writer, options, false);

            if (current.DescriptionElement != null)
            {
                if (!string.IsNullOrEmpty(current.DescriptionElement.Value))
                {
                    writer.WriteString("description", current.DescriptionElement.Value);
                }
                if (current.DescriptionElement.HasExtensions() || (!string.IsNullOrEmpty(current.DescriptionElement.ElementId)))
                {
                    JsonStreamUtilities.SerializeExtensionList(writer, options, "_description", false, current.DescriptionElement.Extension, current.DescriptionElement.ElementId);
                }
            }

            if (current.Time != null)
            {
                switch (current.Time)
                {
                case FhirDateTime v_FhirDateTime:
                    if (v_FhirDateTime != null)
                    {
                        if (!string.IsNullOrEmpty(v_FhirDateTime.Value))
                        {
                            writer.WriteString("timeDateTime", v_FhirDateTime.Value);
                        }
                        if (v_FhirDateTime.HasExtensions() || (!string.IsNullOrEmpty(v_FhirDateTime.ElementId)))
                        {
                            JsonStreamUtilities.SerializeExtensionList(writer, options, "_timeDateTime", false, v_FhirDateTime.Extension, v_FhirDateTime.ElementId);
                        }
                    }
                    break;

                case Period v_Period:
                    writer.WritePropertyName("timePeriod");
                    v_Period.SerializeJson(writer, options);
                    break;
                }
            }
            if (includeStartObject)
            {
                writer.WriteEndObject();
            }
        }
        /// <summary>
        /// Serialize a FHIR ObservationDefinition#QuantitativeDetails into JSON
        /// </summary>
        public static void SerializeJson(this ObservationDefinition.QuantitativeDetailsComponent current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true)
        {
            if (includeStartObject)
            {
                writer.WriteStartObject();
            }
            // Component: ObservationDefinition#QuantitativeDetails, Export: QuantitativeDetailsComponent, Base: BackboneElement (BackboneElement)
            ((Hl7.Fhir.Model.BackboneElement)current).SerializeJson(writer, options, false);

            if (current.CustomaryUnit != null)
            {
                writer.WritePropertyName("customaryUnit");
                current.CustomaryUnit.SerializeJson(writer, options);
            }

            if (current.Unit != null)
            {
                writer.WritePropertyName("unit");
                current.Unit.SerializeJson(writer, options);
            }

            if (current.ConversionFactorElement != null)
            {
                if (current.ConversionFactorElement.Value != null)
                {
                    writer.WriteNumber("conversionFactor", (decimal)current.ConversionFactorElement.Value);
                }
                if (current.ConversionFactorElement.HasExtensions() || (!string.IsNullOrEmpty(current.ConversionFactorElement.ElementId)))
                {
                    JsonStreamUtilities.SerializeExtensionList(writer, options, "_conversionFactor", false, current.ConversionFactorElement.Extension, current.ConversionFactorElement.ElementId);
                }
            }

            if (current.DecimalPrecisionElement != null)
            {
                if (current.DecimalPrecisionElement.Value != null)
                {
                    writer.WriteNumber("decimalPrecision", (int)current.DecimalPrecisionElement.Value);
                }
                if (current.DecimalPrecisionElement.HasExtensions() || (!string.IsNullOrEmpty(current.DecimalPrecisionElement.ElementId)))
                {
                    JsonStreamUtilities.SerializeExtensionList(writer, options, "_decimalPrecision", false, current.DecimalPrecisionElement.Extension, current.DecimalPrecisionElement.ElementId);
                }
            }

            if (includeStartObject)
            {
                writer.WriteEndObject();
            }
        }
Esempio n. 28
0
        /// <summary>
        /// Serialize a FHIR NamingSystem#UniqueId into JSON
        /// </summary>
        public static void SerializeJson(this NamingSystem.UniqueIdComponent current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true)
        {
            if (includeStartObject)
            {
                writer.WriteStartObject();
            }
            // Component: NamingSystem#UniqueId, Export: UniqueIdComponent, Base: BackboneElement (BackboneElement)
            ((Hl7.Fhir.Model.BackboneElement)current).SerializeJson(writer, options, false);

            writer.WriteString("type", Hl7.Fhir.Utility.EnumUtility.GetLiteral(current.TypeElement.Value));

            writer.WriteString("value", current.ValueElement.Value);

            if (current.PreferredElement != null)
            {
                if (current.PreferredElement.Value != null)
                {
                    writer.WriteBoolean("preferred", (bool)current.PreferredElement.Value);
                }
                if (current.PreferredElement.HasExtensions() || (!string.IsNullOrEmpty(current.PreferredElement.ElementId)))
                {
                    JsonStreamUtilities.SerializeExtensionList(writer, options, "_preferred", false, current.PreferredElement.Extension, current.PreferredElement.ElementId);
                }
            }

            if (current.CommentElement != null)
            {
                if (!string.IsNullOrEmpty(current.CommentElement.Value))
                {
                    writer.WriteString("comment", current.CommentElement.Value);
                }
                if (current.CommentElement.HasExtensions() || (!string.IsNullOrEmpty(current.CommentElement.ElementId)))
                {
                    JsonStreamUtilities.SerializeExtensionList(writer, options, "_comment", false, current.CommentElement.Extension, current.CommentElement.ElementId);
                }
            }

            if (current.Period != null)
            {
                writer.WritePropertyName("period");
                current.Period.SerializeJson(writer, options);
            }

            if (includeStartObject)
            {
                writer.WriteEndObject();
            }
        }
Esempio n. 29
0
        /// <summary>
        /// Serialize a FHIR Medication#Ingredient into JSON
        /// </summary>
        public static void SerializeJson(this Medication.IngredientComponent current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true)
        {
            if (includeStartObject)
            {
                writer.WriteStartObject();
            }
            // Component: Medication#Ingredient, Export: IngredientComponent, Base: BackboneElement (BackboneElement)
            ((Hl7.Fhir.Model.BackboneElement)current).SerializeJson(writer, options, false);

            if (current.Item != null)
            {
                switch (current.Item)
                {
                case CodeableConcept v_CodeableConcept:
                    writer.WritePropertyName("itemCodeableConcept");
                    v_CodeableConcept.SerializeJson(writer, options);
                    break;

                case ResourceReference v_ResourceReference:
                    writer.WritePropertyName("itemReference");
                    v_ResourceReference.SerializeJson(writer, options);
                    break;
                }
            }
            if (current.IsActiveElement != null)
            {
                if (current.IsActiveElement.Value != null)
                {
                    writer.WriteBoolean("isActive", (bool)current.IsActiveElement.Value);
                }
                if (current.IsActiveElement.HasExtensions() || (!string.IsNullOrEmpty(current.IsActiveElement.ElementId)))
                {
                    JsonStreamUtilities.SerializeExtensionList(writer, options, "_isActive", false, current.IsActiveElement.Extension, current.IsActiveElement.ElementId);
                }
            }

            if (current.Strength != null)
            {
                writer.WritePropertyName("strength");
                current.Strength.SerializeJson(writer, options);
            }

            if (includeStartObject)
            {
                writer.WriteEndObject();
            }
        }
Esempio n. 30
0
        /// <summary>
        /// Serialize a FHIR List#Entry into JSON
        /// </summary>
        public static void SerializeJson(this List.EntryComponent current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true)
        {
            if (includeStartObject)
            {
                writer.WriteStartObject();
            }
            // Component: List#Entry, Export: EntryComponent, Base: BackboneElement (BackboneElement)
            ((Hl7.Fhir.Model.BackboneElement)current).SerializeJson(writer, options, false);

            if (current.Flag != null)
            {
                writer.WritePropertyName("flag");
                current.Flag.SerializeJson(writer, options);
            }

            if (current.DeletedElement != null)
            {
                if (current.DeletedElement.Value != null)
                {
                    writer.WriteBoolean("deleted", (bool)current.DeletedElement.Value);
                }
                if (current.DeletedElement.HasExtensions() || (!string.IsNullOrEmpty(current.DeletedElement.ElementId)))
                {
                    JsonStreamUtilities.SerializeExtensionList(writer, options, "_deleted", false, current.DeletedElement.Extension, current.DeletedElement.ElementId);
                }
            }

            if (current.DateElement != null)
            {
                if (!string.IsNullOrEmpty(current.DateElement.Value))
                {
                    writer.WriteString("date", current.DateElement.Value);
                }
                if (current.DateElement.HasExtensions() || (!string.IsNullOrEmpty(current.DateElement.ElementId)))
                {
                    JsonStreamUtilities.SerializeExtensionList(writer, options, "_date", false, current.DateElement.Extension, current.DateElement.ElementId);
                }
            }

            writer.WritePropertyName("item");
            current.Item.SerializeJson(writer, options);

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