public override IDeepCopyable CopyTo(IDeepCopyable other) { var dest = other as MedicationOrder; if (dest != null) { base.CopyTo(dest); if (Identifier != null) { dest.Identifier = new List <Hl7.Fhir.Model.Identifier>(Identifier.DeepCopy()); } if (DateWrittenElement != null) { dest.DateWrittenElement = (Hl7.Fhir.Model.FhirDateTime)DateWrittenElement.DeepCopy(); } if (StatusElement != null) { dest.StatusElement = (Code <Hl7.Fhir.Model.MedicationOrder.MedicationOrderStatus>)StatusElement.DeepCopy(); } if (DateEndedElement != null) { dest.DateEndedElement = (Hl7.Fhir.Model.FhirDateTime)DateEndedElement.DeepCopy(); } if (ReasonEnded != null) { dest.ReasonEnded = (Hl7.Fhir.Model.CodeableConcept)ReasonEnded.DeepCopy(); } if (Patient != null) { dest.Patient = (Hl7.Fhir.Model.ResourceReference)Patient.DeepCopy(); } if (Prescriber != null) { dest.Prescriber = (Hl7.Fhir.Model.ResourceReference)Prescriber.DeepCopy(); } if (Encounter != null) { dest.Encounter = (Hl7.Fhir.Model.ResourceReference)Encounter.DeepCopy(); } if (Reason != null) { dest.Reason = (Hl7.Fhir.Model.Element)Reason.DeepCopy(); } if (NoteElement != null) { dest.NoteElement = (Hl7.Fhir.Model.FhirString)NoteElement.DeepCopy(); } if (Medication != null) { dest.Medication = (Hl7.Fhir.Model.Element)Medication.DeepCopy(); } if (DosageInstruction != null) { dest.DosageInstruction = new List <Hl7.Fhir.Model.MedicationOrder.MedicationOrderDosageInstructionComponent>(DosageInstruction.DeepCopy()); } if (DispenseRequest != null) { dest.DispenseRequest = (Hl7.Fhir.Model.MedicationOrder.MedicationOrderDispenseRequestComponent)DispenseRequest.DeepCopy(); } if (Substitution != null) { dest.Substitution = (Hl7.Fhir.Model.MedicationOrder.MedicationOrderSubstitutionComponent)Substitution.DeepCopy(); } if (PriorPrescription != null) { dest.PriorPrescription = (Hl7.Fhir.Model.ResourceReference)PriorPrescription.DeepCopy(); } return(dest); } else { throw new ArgumentException("Can only copy to an object of the same type", "other"); } }