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

            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 = new List <Hl7.Fhir.Model.Identifier>(Identifier.DeepCopy());
            }
            if (BasedOn != null)
            {
                dest.BasedOn = new List <Hl7.Fhir.Model.ResourceReference>(BasedOn.DeepCopy());
            }
            if (StatusElement != null)
            {
                dest.StatusElement = (Code <Hl7.Fhir.Model.DeviceUseStatement.DeviceUseStatementStatus>)StatusElement.DeepCopy();
            }
            if (Subject != null)
            {
                dest.Subject = (Hl7.Fhir.Model.ResourceReference)Subject.DeepCopy();
            }
            if (DerivedFrom != null)
            {
                dest.DerivedFrom = new List <Hl7.Fhir.Model.ResourceReference>(DerivedFrom.DeepCopy());
            }
            if (Timing != null)
            {
                dest.Timing = (Hl7.Fhir.Model.Element)Timing.DeepCopy();
            }
            if (RecordedOnElement != null)
            {
                dest.RecordedOnElement = (Hl7.Fhir.Model.FhirDateTime)RecordedOnElement.DeepCopy();
            }
            if (Source != null)
            {
                dest.Source = (Hl7.Fhir.Model.ResourceReference)Source.DeepCopy();
            }
            if (Device != null)
            {
                dest.Device = (Hl7.Fhir.Model.ResourceReference)Device.DeepCopy();
            }
            if (ReasonCode != null)
            {
                dest.ReasonCode = new List <Hl7.Fhir.Model.CodeableConcept>(ReasonCode.DeepCopy());
            }
            if (ReasonReference != null)
            {
                dest.ReasonReference = new List <Hl7.Fhir.Model.ResourceReference>(ReasonReference.DeepCopy());
            }
            if (BodySite != null)
            {
                dest.BodySite = (Hl7.Fhir.Model.CodeableConcept)BodySite.DeepCopy();
            }
            if (Note != null)
            {
                dest.Note = new List <Hl7.Fhir.Model.Annotation>(Note.DeepCopy());
            }
            return(dest);
        }
        public string GenerateCode(CodeGenStyle style = null)
        {
            if (style == null)
            {
                style = new CodeGenStyle();
            }

            var builder = new StringBuilder();

            if (Comment != null)
            {
                builder.AppendLine(Comment.GenerateCode(style));
            }

            foreach (var attribute in Attributes)
            {
                builder.AppendLine(attribute.GenerateCode(style));
            }

            builder.Append(style.Indent);
            builder.Append(Scope.ToString().ToLower());
            builder.Append(" ");

            if (ClassType != ClassType.Normal)
            {
                builder.Append(ClassType.ToString().ToLower());
                builder.Append(" ");
            }

            var genericList = GenericTypes.Any() ? $"<{string.Join(", ", GenericTypes.Select(gt => gt.Name))}>" : string.Empty;

            builder.Append($"class {Name}{genericList}");

            if (DerivedFrom.Any())
            {
                var derivedFromList = string.Join(", ", DerivedFrom);
                builder.Append($" : {derivedFromList}");
            }

            builder.AppendLine();

            foreach (var constrainedGeneric in GenericTypes.Where(gt => gt.Constraint != null))
            {
                style.IndentCount++;
                builder.AppendLine($"{style.Indent}where {constrainedGeneric.Name} : {constrainedGeneric.Constraint}");
                style.IndentCount--;
            }

            builder.AppendLine($"{style.Indent}{{");

            style.IndentCount++;

            foreach (var constructor in Constructors)
            {
                builder.AppendLine(constructor.GenerateCode(style));
                builder.AppendLine();
            }

            foreach (var variable in Variables)
            {
                builder.AppendLine(variable.GenerateCode(style));
                builder.AppendLine();
            }

            foreach (var property in Properties)
            {
                builder.AppendLine(property.GenerateCode(style));
                builder.AppendLine();
            }

            foreach (var method in Methods)
            {
                builder.AppendLine(method.GenerateCode(style));
                builder.AppendLine();
            }

            style.IndentCount--;

            builder.Append($"{style.Indent}}}");

            return(builder.ToString());
        }
        public override IDeepCopyable CopyTo(IDeepCopyable other)
        {
            var dest = other as MedicationStatement;

            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 = new List <Hl7.Fhir.Model.Identifier>(Identifier.DeepCopy());
            }
            if (BasedOn != null)
            {
                dest.BasedOn = new List <Hl7.Fhir.Model.ResourceReference>(BasedOn.DeepCopy());
            }
            if (PartOf != null)
            {
                dest.PartOf = new List <Hl7.Fhir.Model.ResourceReference>(PartOf.DeepCopy());
            }
            if (StatusElement != null)
            {
                dest.StatusElement = (Code <Hl7.Fhir.Model.MedicationStatement.MedicationStatusCodes>)StatusElement.DeepCopy();
            }
            if (StatusReason != null)
            {
                dest.StatusReason = new List <Hl7.Fhir.Model.CodeableConcept>(StatusReason.DeepCopy());
            }
            if (Category != null)
            {
                dest.Category = (Hl7.Fhir.Model.CodeableConcept)Category.DeepCopy();
            }
            if (Medication != null)
            {
                dest.Medication = (Hl7.Fhir.Model.Element)Medication.DeepCopy();
            }
            if (Subject != null)
            {
                dest.Subject = (Hl7.Fhir.Model.ResourceReference)Subject.DeepCopy();
            }
            if (Context != null)
            {
                dest.Context = (Hl7.Fhir.Model.ResourceReference)Context.DeepCopy();
            }
            if (Effective != null)
            {
                dest.Effective = (Hl7.Fhir.Model.Element)Effective.DeepCopy();
            }
            if (DateAssertedElement != null)
            {
                dest.DateAssertedElement = (Hl7.Fhir.Model.FhirDateTime)DateAssertedElement.DeepCopy();
            }
            if (InformationSource != null)
            {
                dest.InformationSource = (Hl7.Fhir.Model.ResourceReference)InformationSource.DeepCopy();
            }
            if (DerivedFrom != null)
            {
                dest.DerivedFrom = new List <Hl7.Fhir.Model.ResourceReference>(DerivedFrom.DeepCopy());
            }
            if (ReasonCode != null)
            {
                dest.ReasonCode = new List <Hl7.Fhir.Model.CodeableConcept>(ReasonCode.DeepCopy());
            }
            if (ReasonReference != null)
            {
                dest.ReasonReference = new List <Hl7.Fhir.Model.ResourceReference>(ReasonReference.DeepCopy());
            }
            if (Note != null)
            {
                dest.Note = new List <Hl7.Fhir.Model.Annotation>(Note.DeepCopy());
            }
            if (Dosage != null)
            {
                dest.Dosage = new List <Hl7.Fhir.Model.Dosage>(Dosage.DeepCopy());
            }
            return(dest);
        }
        public override IDeepCopyable CopyTo(IDeepCopyable other)
        {
            var dest = other as DeviceUseStatement;

            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 = new List <Hl7.Fhir.Model.Identifier>(Identifier.DeepCopy());
            }
            if (BasedOn != null)
            {
                dest.BasedOn = new List <Hl7.Fhir.Model.ResourceReference>(BasedOn.DeepCopy());
            }
            if (StatusElement != null)
            {
                dest.StatusElement = (Code <Hl7.Fhir.Model.DeviceUseStatement.DeviceUseStatementStatus>)StatusElement.DeepCopy();
            }
            if (Category != null)
            {
                dest.Category = new List <Hl7.Fhir.Model.CodeableConcept>(Category.DeepCopy());
            }
            if (Subject != null)
            {
                dest.Subject = (Hl7.Fhir.Model.ResourceReference)Subject.DeepCopy();
            }
            if (DerivedFrom != null)
            {
                dest.DerivedFrom = new List <Hl7.Fhir.Model.ResourceReference>(DerivedFrom.DeepCopy());
            }
            if (Context != null)
            {
                dest.Context = (Hl7.Fhir.Model.ResourceReference)Context.DeepCopy();
            }
            if (Timing != null)
            {
                dest.Timing = (Hl7.Fhir.Model.DataType)Timing.DeepCopy();
            }
            if (DateAssertedElement != null)
            {
                dest.DateAssertedElement = (Hl7.Fhir.Model.FhirDateTime)DateAssertedElement.DeepCopy();
            }
            if (UsageStatus != null)
            {
                dest.UsageStatus = (Hl7.Fhir.Model.CodeableConcept)UsageStatus.DeepCopy();
            }
            if (UsageReason != null)
            {
                dest.UsageReason = new List <Hl7.Fhir.Model.CodeableConcept>(UsageReason.DeepCopy());
            }
            if (InformationSource != null)
            {
                dest.InformationSource = (Hl7.Fhir.Model.ResourceReference)InformationSource.DeepCopy();
            }
            if (Device != null)
            {
                dest.Device = (Hl7.Fhir.Model.CodeableReference)Device.DeepCopy();
            }
            if (Reason != null)
            {
                dest.Reason = new List <Hl7.Fhir.Model.CodeableReference>(Reason.DeepCopy());
            }
            if (BodySite != null)
            {
                dest.BodySite = (Hl7.Fhir.Model.CodeableReference)BodySite.DeepCopy();
            }
            if (Note != null)
            {
                dest.Note = new List <Hl7.Fhir.Model.Annotation>(Note.DeepCopy());
            }
            return(dest);
        }