public override IDeepCopyable CopyTo(IDeepCopyable other) { var dest = other as Encounter; if (dest != null) { base.CopyTo(dest); if (Identifier != null) { dest.Identifier = new List <Hl7.Fhir.Model.Identifier>(Identifier.DeepCopy()); } if (StatusElement != null) { dest.StatusElement = (Code <Hl7.Fhir.Model.Encounter.EncounterState>)StatusElement.DeepCopy(); } if (ClassElement != null) { dest.ClassElement = (Code <Hl7.Fhir.Model.Encounter.EncounterClass>)ClassElement.DeepCopy(); } if (Type != null) { dest.Type = new List <Hl7.Fhir.Model.CodeableConcept>(Type.DeepCopy()); } if (Subject != null) { dest.Subject = (Hl7.Fhir.Model.ResourceReference)Subject.DeepCopy(); } if (Participant != null) { dest.Participant = new List <Hl7.Fhir.Model.Encounter.EncounterParticipantComponent>(Participant.DeepCopy()); } if (Period != null) { dest.Period = (Hl7.Fhir.Model.Period)Period.DeepCopy(); } if (Length != null) { dest.Length = (Hl7.Fhir.Model.Duration)Length.DeepCopy(); } if (Reason != null) { dest.Reason = (Hl7.Fhir.Model.CodeableConcept)Reason.DeepCopy(); } if (Indication != null) { dest.Indication = (Hl7.Fhir.Model.ResourceReference)Indication.DeepCopy(); } if (Priority != null) { dest.Priority = (Hl7.Fhir.Model.CodeableConcept)Priority.DeepCopy(); } if (Hospitalization != null) { dest.Hospitalization = (Hl7.Fhir.Model.Encounter.EncounterHospitalizationComponent)Hospitalization.DeepCopy(); } if (Location != null) { dest.Location = new List <Hl7.Fhir.Model.Encounter.EncounterLocationComponent>(Location.DeepCopy()); } if (ServiceProvider != null) { dest.ServiceProvider = (Hl7.Fhir.Model.ResourceReference)ServiceProvider.DeepCopy(); } if (PartOf != null) { dest.PartOf = (Hl7.Fhir.Model.ResourceReference)PartOf.DeepCopy(); } return(dest); } else { throw new ArgumentException("Can only copy to an object of the same type", "other"); } }