public override IDeepCopyable CopyTo(IDeepCopyable other) { var dest = other as Dosage; if (dest == null) { throw new ArgumentException("Can only copy to an object of the same type", "other"); } base.CopyTo(dest); if (SequenceElement != null) { dest.SequenceElement = (Hl7.Fhir.Model.Integer)SequenceElement.DeepCopy(); } if (TextElement != null) { dest.TextElement = (Hl7.Fhir.Model.FhirString)TextElement.DeepCopy(); } if (AdditionalInstruction != null) { dest.AdditionalInstruction = new List <Hl7.Fhir.Model.CodeableConcept>(AdditionalInstruction.DeepCopy()); } if (PatientInstructionElement != null) { dest.PatientInstructionElement = (Hl7.Fhir.Model.FhirString)PatientInstructionElement.DeepCopy(); } if (Timing != null) { dest.Timing = (Hl7.Fhir.Model.Timing)Timing.DeepCopy(); } if (AsNeeded != null) { dest.AsNeeded = (Hl7.Fhir.Model.DataType)AsNeeded.DeepCopy(); } if (Site != null) { dest.Site = (Hl7.Fhir.Model.CodeableConcept)Site.DeepCopy(); } if (Route != null) { dest.Route = (Hl7.Fhir.Model.CodeableConcept)Route.DeepCopy(); } if (Method != null) { dest.Method = (Hl7.Fhir.Model.CodeableConcept)Method.DeepCopy(); } if (DoseAndRate != null) { dest.DoseAndRate = new List <Hl7.Fhir.Model.Dosage.DoseAndRateComponent>(DoseAndRate.DeepCopy()); } if (MaxDosePerPeriod != null) { dest.MaxDosePerPeriod = (Hl7.Fhir.Model.Ratio)MaxDosePerPeriod.DeepCopy(); } if (MaxDosePerAdministration != null) { dest.MaxDosePerAdministration = (Hl7.Fhir.Model.Quantity)MaxDosePerAdministration.DeepCopy(); } if (MaxDosePerLifetime != null) { dest.MaxDosePerLifetime = (Hl7.Fhir.Model.Quantity)MaxDosePerLifetime.DeepCopy(); } return(dest); }
/// <summary> /// Serialize to a JSON object /// </summary> public new void SerializeJson(Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true) { if (includeStartObject) { writer.WriteStartObject(); } ((fhirCsR4.Models.BackboneElement) this).SerializeJson(writer, options, false); if (Sequence != null) { writer.WriteNumber("sequence", (int)Sequence !); } if (!string.IsNullOrEmpty(Text)) { writer.WriteString("text", (string)Text !); } if (_Text != null) { writer.WritePropertyName("_text"); _Text.SerializeJson(writer, options); } if ((AdditionalInstruction != null) && (AdditionalInstruction.Count != 0)) { writer.WritePropertyName("additionalInstruction"); writer.WriteStartArray(); foreach (CodeableConcept valAdditionalInstruction in AdditionalInstruction) { valAdditionalInstruction.SerializeJson(writer, options, true); } writer.WriteEndArray(); } if (!string.IsNullOrEmpty(PatientInstruction)) { writer.WriteString("patientInstruction", (string)PatientInstruction !); } if (_PatientInstruction != null) { writer.WritePropertyName("_patientInstruction"); _PatientInstruction.SerializeJson(writer, options); } if (Timing != null) { writer.WritePropertyName("timing"); Timing.SerializeJson(writer, options); } if (AsNeededBoolean != null) { writer.WriteBoolean("asNeededBoolean", (bool)AsNeededBoolean !); } if (AsNeededCodeableConcept != null) { writer.WritePropertyName("asNeededCodeableConcept"); AsNeededCodeableConcept.SerializeJson(writer, options); } if (Site != null) { writer.WritePropertyName("site"); Site.SerializeJson(writer, options); } if (Route != null) { writer.WritePropertyName("route"); Route.SerializeJson(writer, options); } if (Method != null) { writer.WritePropertyName("method"); Method.SerializeJson(writer, options); } if ((DoseAndRate != null) && (DoseAndRate.Count != 0)) { writer.WritePropertyName("doseAndRate"); writer.WriteStartArray(); foreach (DosageDoseAndRate valDoseAndRate in DoseAndRate) { valDoseAndRate.SerializeJson(writer, options, true); } writer.WriteEndArray(); } if (MaxDosePerPeriod != null) { writer.WritePropertyName("maxDosePerPeriod"); MaxDosePerPeriod.SerializeJson(writer, options); } if (MaxDosePerAdministration != null) { writer.WritePropertyName("maxDosePerAdministration"); MaxDosePerAdministration.SerializeJson(writer, options); } if (MaxDosePerLifetime != null) { writer.WritePropertyName("maxDosePerLifetime"); MaxDosePerLifetime.SerializeJson(writer, options); } if (includeStartObject) { writer.WriteEndObject(); } }