Exemplo 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 !);
            }


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

                foreach (string valDefinitionUri in DefinitionUri)
                {
                    writer.WriteStringValue(valDefinitionUri);
                }

                writer.WriteEndArray();
            }

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

                foreach (Element val_DefinitionUri in _DefinitionUri)
                {
                    val_DefinitionUri.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

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

                foreach (string valDefinitionCanonical in DefinitionCanonical)
                {
                    writer.WriteStringValue(valDefinitionCanonical);
                }

                writer.WriteEndArray();
            }

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

                foreach (Element val_DefinitionCanonical in _DefinitionCanonical)
                {
                    val_DefinitionCanonical.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 ((PartOf != null) && (PartOf.Count != 0))
            {
                writer.WritePropertyName("partOf");
                writer.WriteStartArray();

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

            if (!string.IsNullOrEmpty(OccurrenceDateTime))
            {
                writer.WriteString("occurrenceDateTime", (string)OccurrenceDateTime !);
            }

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

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

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

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

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

                writer.WriteEndArray();
            }

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

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

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

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

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

                foreach (CodeableConcept valBodysite in Bodysite)
                {
                    valBodysite.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            if (FactorOverride != null)
            {
                writer.WriteNumber("factorOverride", (decimal)FactorOverride !);
            }

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

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

            if (!string.IsNullOrEmpty(OverrideReason))
            {
                writer.WriteString("overrideReason", (string)OverrideReason !);
            }

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

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

            if (!string.IsNullOrEmpty(EnteredDate))
            {
                writer.WriteString("enteredDate", (string)EnteredDate !);
            }

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

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

                foreach (CodeableConcept valReason in Reason)
                {
                    valReason.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

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

                foreach (Reference valService in Service)
                {
                    valService.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

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

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

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

                foreach (Reference valAccount in Account)
                {
                    valAccount.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 ((SupportingInformation != null) && (SupportingInformation.Count != 0))
            {
                writer.WritePropertyName("supportingInformation");
                writer.WriteStartArray();

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

                writer.WriteEndArray();
            }

            if (includeStartObject)
            {
                writer.WriteEndObject();
            }
        }
Exemplo n.º 2
0
        public override IDeepCopyable CopyTo(IDeepCopyable other)
        {
            var dest = other as ChargeItem;

            if (dest == null)
            {
                throw new ArgumentException("Can only copy to an object of the same type", "other");
            }

            base.CopyTo(dest);
            if (Identifier != null)
            {
                dest.Identifier = (Hl7.Fhir.Model.Identifier)Identifier.DeepCopy();
            }
            if (DefinitionElement != null)
            {
                dest.DefinitionElement = new List <Hl7.Fhir.Model.FhirUri>(DefinitionElement.DeepCopy());
            }
            if (StatusElement != null)
            {
                dest.StatusElement = (Code <Hl7.Fhir.Model.ChargeItem.ChargeItemStatus>)StatusElement.DeepCopy();
            }
            if (PartOf != null)
            {
                dest.PartOf = new List <Hl7.Fhir.Model.ResourceReference>(PartOf.DeepCopy());
            }
            if (Code != null)
            {
                dest.Code = (Hl7.Fhir.Model.CodeableConcept)Code.DeepCopy();
            }
            if (Subject != null)
            {
                dest.Subject = (Hl7.Fhir.Model.ResourceReference)Subject.DeepCopy();
            }
            if (Context != null)
            {
                dest.Context = (Hl7.Fhir.Model.ResourceReference)Context.DeepCopy();
            }
            if (Occurrence != null)
            {
                dest.Occurrence = (Hl7.Fhir.Model.DataType)Occurrence.DeepCopy();
            }
            if (Participant != null)
            {
                dest.Participant = new List <Hl7.Fhir.Model.ChargeItem.ParticipantComponent>(Participant.DeepCopy());
            }
            if (PerformingOrganization != null)
            {
                dest.PerformingOrganization = (Hl7.Fhir.Model.ResourceReference)PerformingOrganization.DeepCopy();
            }
            if (RequestingOrganization != null)
            {
                dest.RequestingOrganization = (Hl7.Fhir.Model.ResourceReference)RequestingOrganization.DeepCopy();
            }
            if (Quantity != null)
            {
                dest.Quantity = (Hl7.Fhir.Model.Quantity)Quantity.DeepCopy();
            }
            if (Bodysite != null)
            {
                dest.Bodysite = new List <Hl7.Fhir.Model.CodeableConcept>(Bodysite.DeepCopy());
            }
            if (FactorOverrideElement != null)
            {
                dest.FactorOverrideElement = (Hl7.Fhir.Model.FhirDecimal)FactorOverrideElement.DeepCopy();
            }
            if (PriceOverride != null)
            {
                dest.PriceOverride = (Hl7.Fhir.Model.Money)PriceOverride.DeepCopy();
            }
            if (OverrideReasonElement != null)
            {
                dest.OverrideReasonElement = (Hl7.Fhir.Model.FhirString)OverrideReasonElement.DeepCopy();
            }
            if (Enterer != null)
            {
                dest.Enterer = (Hl7.Fhir.Model.ResourceReference)Enterer.DeepCopy();
            }
            if (EnteredDateElement != null)
            {
                dest.EnteredDateElement = (Hl7.Fhir.Model.FhirDateTime)EnteredDateElement.DeepCopy();
            }
            if (Reason != null)
            {
                dest.Reason = new List <Hl7.Fhir.Model.CodeableConcept>(Reason.DeepCopy());
            }
            if (Service != null)
            {
                dest.Service = new List <Hl7.Fhir.Model.ResourceReference>(Service.DeepCopy());
            }
            if (Account != null)
            {
                dest.Account = new List <Hl7.Fhir.Model.ResourceReference>(Account.DeepCopy());
            }
            if (Note != null)
            {
                dest.Note = new List <Hl7.Fhir.Model.Annotation>(Note.DeepCopy());
            }
            if (SupportingInformation != null)
            {
                dest.SupportingInformation = new List <Hl7.Fhir.Model.ResourceReference>(SupportingInformation.DeepCopy());
            }
            return(dest);
        }