public override IDeepCopyable CopyTo(IDeepCopyable other)
        {
            var dest = other as DocumentReference;

            if (dest != null)
            {
                base.CopyTo(dest);
                if (MasterIdentifier != null)
                {
                    dest.MasterIdentifier = (Hl7.Fhir.Model.Identifier)MasterIdentifier.DeepCopy();
                }
                if (Identifier != null)
                {
                    dest.Identifier = new List <Hl7.Fhir.Model.Identifier>(Identifier.DeepCopy());
                }
                if (Subject != null)
                {
                    dest.Subject = (Hl7.Fhir.Model.ResourceReference)Subject.DeepCopy();
                }
                if (Type != null)
                {
                    dest.Type = (Hl7.Fhir.Model.CodeableConcept)Type.DeepCopy();
                }
                if (Class != null)
                {
                    dest.Class = (Hl7.Fhir.Model.CodeableConcept)Class.DeepCopy();
                }
                if (Author != null)
                {
                    dest.Author = new List <Hl7.Fhir.Model.ResourceReference>(Author.DeepCopy());
                }
                if (Custodian != null)
                {
                    dest.Custodian = (Hl7.Fhir.Model.ResourceReference)Custodian.DeepCopy();
                }
                if (Authenticator != null)
                {
                    dest.Authenticator = (Hl7.Fhir.Model.ResourceReference)Authenticator.DeepCopy();
                }
                if (CreatedElement != null)
                {
                    dest.CreatedElement = (Hl7.Fhir.Model.FhirDateTime)CreatedElement.DeepCopy();
                }
                if (IndexedElement != null)
                {
                    dest.IndexedElement = (Hl7.Fhir.Model.Instant)IndexedElement.DeepCopy();
                }
                if (StatusElement != null)
                {
                    dest.StatusElement = (Code <Hl7.Fhir.Model.DocumentReferenceStatus>)StatusElement.DeepCopy();
                }
                if (DocStatus != null)
                {
                    dest.DocStatus = (Hl7.Fhir.Model.CodeableConcept)DocStatus.DeepCopy();
                }
                if (RelatesTo != null)
                {
                    dest.RelatesTo = new List <Hl7.Fhir.Model.DocumentReference.RelatesToComponent>(RelatesTo.DeepCopy());
                }
                if (DescriptionElement != null)
                {
                    dest.DescriptionElement = (Hl7.Fhir.Model.FhirString)DescriptionElement.DeepCopy();
                }
                if (SecurityLabel != null)
                {
                    dest.SecurityLabel = new List <Hl7.Fhir.Model.CodeableConcept>(SecurityLabel.DeepCopy());
                }
                if (Content != null)
                {
                    dest.Content = new List <Hl7.Fhir.Model.DocumentReference.ContentComponent>(Content.DeepCopy());
                }
                if (Context != null)
                {
                    dest.Context = (Hl7.Fhir.Model.DocumentReference.ContextComponent)Context.DeepCopy();
                }
                return(dest);
            }
            else
            {
                throw new ArgumentException("Can only copy to an object of the same type", "other");
            }
        }
        public override IDeepCopyable CopyTo(IDeepCopyable other)
        {
            var dest = other as DocumentReference;

            if (dest != null)
            {
                base.CopyTo(dest);
                if (MasterIdentifier != null)
                {
                    dest.MasterIdentifier = (Hl7.Fhir.Model.Identifier)MasterIdentifier.DeepCopy();
                }
                if (Identifier != null)
                {
                    dest.Identifier = new List <Hl7.Fhir.Model.Identifier>(Identifier.DeepCopy());
                }
                if (Subject != null)
                {
                    dest.Subject = (Hl7.Fhir.Model.ResourceReference)Subject.DeepCopy();
                }
                if (Type != null)
                {
                    dest.Type = (Hl7.Fhir.Model.CodeableConcept)Type.DeepCopy();
                }
                if (Class != null)
                {
                    dest.Class = (Hl7.Fhir.Model.CodeableConcept)Class.DeepCopy();
                }
                if (Author != null)
                {
                    dest.Author = new List <Hl7.Fhir.Model.ResourceReference>(Author.DeepCopy());
                }
                if (Custodian != null)
                {
                    dest.Custodian = (Hl7.Fhir.Model.ResourceReference)Custodian.DeepCopy();
                }
                if (PolicyManagerElement != null)
                {
                    dest.PolicyManagerElement = (Hl7.Fhir.Model.FhirUri)PolicyManagerElement.DeepCopy();
                }
                if (Authenticator != null)
                {
                    dest.Authenticator = (Hl7.Fhir.Model.ResourceReference)Authenticator.DeepCopy();
                }
                if (CreatedElement != null)
                {
                    dest.CreatedElement = (Hl7.Fhir.Model.FhirDateTime)CreatedElement.DeepCopy();
                }
                if (IndexedElement != null)
                {
                    dest.IndexedElement = (Hl7.Fhir.Model.Instant)IndexedElement.DeepCopy();
                }
                if (StatusElement != null)
                {
                    dest.StatusElement = (Code <Hl7.Fhir.Model.DocumentReference.DocumentReferenceStatus>)StatusElement.DeepCopy();
                }
                if (DocStatus != null)
                {
                    dest.DocStatus = (Hl7.Fhir.Model.CodeableConcept)DocStatus.DeepCopy();
                }
                if (RelatesTo != null)
                {
                    dest.RelatesTo = new List <Hl7.Fhir.Model.DocumentReference.DocumentReferenceRelatesToComponent>(RelatesTo.DeepCopy());
                }
                if (DescriptionElement != null)
                {
                    dest.DescriptionElement = (Hl7.Fhir.Model.FhirString)DescriptionElement.DeepCopy();
                }
                if (Confidentiality != null)
                {
                    dest.Confidentiality = new List <Hl7.Fhir.Model.CodeableConcept>(Confidentiality.DeepCopy());
                }
                if (PrimaryLanguageElement != null)
                {
                    dest.PrimaryLanguageElement = (Hl7.Fhir.Model.Code)PrimaryLanguageElement.DeepCopy();
                }
                if (MimeTypeElement != null)
                {
                    dest.MimeTypeElement = (Hl7.Fhir.Model.Code)MimeTypeElement.DeepCopy();
                }
                if (FormatElement != null)
                {
                    dest.FormatElement = new List <Hl7.Fhir.Model.FhirUri>(FormatElement.DeepCopy());
                }
                if (SizeElement != null)
                {
                    dest.SizeElement = (Hl7.Fhir.Model.Integer)SizeElement.DeepCopy();
                }
                if (HashElement != null)
                {
                    dest.HashElement = (Hl7.Fhir.Model.FhirString)HashElement.DeepCopy();
                }
                if (LocationElement != null)
                {
                    dest.LocationElement = (Hl7.Fhir.Model.FhirUri)LocationElement.DeepCopy();
                }
                if (Service != null)
                {
                    dest.Service = (Hl7.Fhir.Model.DocumentReference.DocumentReferenceServiceComponent)Service.DeepCopy();
                }
                if (Context != null)
                {
                    dest.Context = (Hl7.Fhir.Model.DocumentReference.DocumentReferenceContextComponent)Context.DeepCopy();
                }
                return(dest);
            }
            else
            {
                throw new ArgumentException("Can only copy to an object of the same type", "other");
            }
        }