using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using DocuMed.Domain.Dtos.LargDtos;
using DocuMed.Domain.Dtos.SmallDtos;
using DocuMed.Domain.Entities.City;
using DocuMed.Domain.Entities.MedicalHistory;
using DocuMed.Domain.Entities.User;
using Mapster.Models;

namespace DocuMed.Domain.Mappers
{
    public static partial class MedicalHistoryMapper
    {
        public static MedicalHistory AdaptToMedicalHistory(this MedicalHistorySDto p1)
        {
            return p1 == null ? null : new MedicalHistory()
            {
                ChiefComplaint = p1.ChiefComplaint,
                SectionId = p1.SectionId,
                Section = new Section()
                {
                    Name = p1.SectionName,
                    Id = p1.SectionId
                },
                FirstName = p1.FirstName,
                LastName = p1.LastName,
                FatherName = p1.FatherName,
                NationalId = p1.NationalId,
                Age = p1.Age,
                BirthDate = p1.BirthDate,
                PresentIllnessDetail = p1.PresentIllnessDetail,
                PastDiseasesHistoryDetail = p1.PastDiseasesHistoryDetail,
                PastSurgeryHistoryDetail = p1.PastSurgeryHistoryDetail,
                FamilyHistoryDetail = p1.FamilyHistoryDetail,
                AllergyDetail = p1.AllergyDetail,
                DrugHistoryDetail = p1.DrugHistoryDetail,
                AddictionHistoryDetail = p1.AddictionHistoryDetail,
                SystemReviewDetail = p1.SystemReviewDetail,
                VitalSignDetail = p1.VitalSignDetail,
                GeneralAppearanceDetail = p1.GeneralAppearanceDetail,
                SystolicBloodPressure = p1.SystolicBloodPressure,
                DiastolicBloodPressure = p1.DiastolicBloodPressure,
                PulseRate = p1.PulseRate,
                SPO2 = p1.SPO2,
                Temperature = p1.Temperature,
                MedicalHistoryTemplateId = p1.MedicalHistoryTemplateId,
                ApplicationUserId = p1.ApplicationUserId,
                ApplicationUser = new ApplicationUser() {Id = p1.ApplicationUserId},
                Id = p1.Id
            };
        }
        public static MedicalHistory AdaptTo(this MedicalHistorySDto p2, MedicalHistory p3)
        {
            if (p2 == null)
            {
                return null;
            }
            MedicalHistory result = p3 ?? new MedicalHistory();
            
            result.ChiefComplaint = p2.ChiefComplaint;
            result.SectionId = p2.SectionId;
            result.Section = funcMain1(new Never(), result.Section, p2);
            result.FirstName = p2.FirstName;
            result.LastName = p2.LastName;
            result.FatherName = p2.FatherName;
            result.NationalId = p2.NationalId;
            result.Age = p2.Age;
            result.BirthDate = p2.BirthDate;
            result.PresentIllnessDetail = p2.PresentIllnessDetail;
            result.PastDiseasesHistoryDetail = p2.PastDiseasesHistoryDetail;
            result.PastSurgeryHistoryDetail = p2.PastSurgeryHistoryDetail;
            result.FamilyHistoryDetail = p2.FamilyHistoryDetail;
            result.AllergyDetail = p2.AllergyDetail;
            result.DrugHistoryDetail = p2.DrugHistoryDetail;
            result.AddictionHistoryDetail = p2.AddictionHistoryDetail;
            result.SystemReviewDetail = p2.SystemReviewDetail;
            result.VitalSignDetail = p2.VitalSignDetail;
            result.GeneralAppearanceDetail = p2.GeneralAppearanceDetail;
            result.SystolicBloodPressure = p2.SystolicBloodPressure;
            result.DiastolicBloodPressure = p2.DiastolicBloodPressure;
            result.PulseRate = p2.PulseRate;
            result.SPO2 = p2.SPO2;
            result.Temperature = p2.Temperature;
            result.MedicalHistoryTemplateId = p2.MedicalHistoryTemplateId;
            result.ApplicationUserId = p2.ApplicationUserId;
            result.ApplicationUser = funcMain2(new Never(), result.ApplicationUser, p2);
            result.Id = p2.Id;
            return result;
            
        }
        public static Expression<Func<MedicalHistorySDto, MedicalHistory>> ProjectToMedicalHistory => p8 => new MedicalHistory()
        {
            ChiefComplaint = p8.ChiefComplaint,
            SectionId = p8.SectionId,
            Section = new Section()
            {
                Name = p8.SectionName,
                Id = p8.SectionId
            },
            FirstName = p8.FirstName,
            LastName = p8.LastName,
            FatherName = p8.FatherName,
            NationalId = p8.NationalId,
            Age = p8.Age,
            BirthDate = p8.BirthDate,
            PresentIllnessDetail = p8.PresentIllnessDetail,
            PastDiseasesHistoryDetail = p8.PastDiseasesHistoryDetail,
            PastSurgeryHistoryDetail = p8.PastSurgeryHistoryDetail,
            FamilyHistoryDetail = p8.FamilyHistoryDetail,
            AllergyDetail = p8.AllergyDetail,
            DrugHistoryDetail = p8.DrugHistoryDetail,
            AddictionHistoryDetail = p8.AddictionHistoryDetail,
            SystemReviewDetail = p8.SystemReviewDetail,
            VitalSignDetail = p8.VitalSignDetail,
            GeneralAppearanceDetail = p8.GeneralAppearanceDetail,
            SystolicBloodPressure = p8.SystolicBloodPressure,
            DiastolicBloodPressure = p8.DiastolicBloodPressure,
            PulseRate = p8.PulseRate,
            SPO2 = p8.SPO2,
            Temperature = p8.Temperature,
            MedicalHistoryTemplateId = p8.MedicalHistoryTemplateId,
            ApplicationUserId = p8.ApplicationUserId,
            ApplicationUser = new ApplicationUser() {Id = p8.ApplicationUserId},
            Id = p8.Id
        };
        public static MedicalHistorySDto AdaptToSDto(this MedicalHistory p9)
        {
            return p9 == null ? null : new MedicalHistorySDto()
            {
                ChiefComplaint = p9.ChiefComplaint,
                SectionId = p9.SectionId,
                SectionName = p9.Section != null ? p9.Section.Name : string.Empty,
                FirstName = p9.FirstName,
                LastName = p9.LastName,
                FatherName = p9.FatherName,
                NationalId = p9.NationalId,
                MedicalHistoryTemplateId = p9.MedicalHistoryTemplateId,
                Age = p9.Age,
                BirthDate = p9.BirthDate,
                PresentIllnessDetail = p9.PresentIllnessDetail,
                PastDiseasesHistoryDetail = p9.PastDiseasesHistoryDetail,
                PastSurgeryHistoryDetail = p9.PastSurgeryHistoryDetail,
                FamilyHistoryDetail = p9.FamilyHistoryDetail,
                AllergyDetail = p9.AllergyDetail,
                DrugHistoryDetail = p9.DrugHistoryDetail,
                AddictionHistoryDetail = p9.AddictionHistoryDetail,
                SystemReviewDetail = p9.SystemReviewDetail,
                VitalSignDetail = p9.VitalSignDetail,
                GeneralAppearanceDetail = p9.GeneralAppearanceDetail,
                SystolicBloodPressure = p9.SystolicBloodPressure,
                DiastolicBloodPressure = p9.DiastolicBloodPressure,
                PulseRate = p9.PulseRate,
                SPO2 = p9.SPO2,
                Temperature = p9.Temperature,
                ApplicationUserId = p9.ApplicationUserId,
                Id = p9.Id
            };
        }
        public static MedicalHistorySDto AdaptTo(this MedicalHistory p10, MedicalHistorySDto p11)
        {
            if (p10 == null)
            {
                return null;
            }
            MedicalHistorySDto result = p11 ?? new MedicalHistorySDto();
            
            result.ChiefComplaint = p10.ChiefComplaint;
            result.SectionId = p10.SectionId;
            result.SectionName = p10.Section != null ? p10.Section.Name : string.Empty;
            result.FirstName = p10.FirstName;
            result.LastName = p10.LastName;
            result.FatherName = p10.FatherName;
            result.NationalId = p10.NationalId;
            result.MedicalHistoryTemplateId = p10.MedicalHistoryTemplateId;
            result.Age = p10.Age;
            result.BirthDate = p10.BirthDate;
            result.PresentIllnessDetail = p10.PresentIllnessDetail;
            result.PastDiseasesHistoryDetail = p10.PastDiseasesHistoryDetail;
            result.PastSurgeryHistoryDetail = p10.PastSurgeryHistoryDetail;
            result.FamilyHistoryDetail = p10.FamilyHistoryDetail;
            result.AllergyDetail = p10.AllergyDetail;
            result.DrugHistoryDetail = p10.DrugHistoryDetail;
            result.AddictionHistoryDetail = p10.AddictionHistoryDetail;
            result.SystemReviewDetail = p10.SystemReviewDetail;
            result.VitalSignDetail = p10.VitalSignDetail;
            result.GeneralAppearanceDetail = p10.GeneralAppearanceDetail;
            result.SystolicBloodPressure = p10.SystolicBloodPressure;
            result.DiastolicBloodPressure = p10.DiastolicBloodPressure;
            result.PulseRate = p10.PulseRate;
            result.SPO2 = p10.SPO2;
            result.Temperature = p10.Temperature;
            result.ApplicationUserId = p10.ApplicationUserId;
            result.Id = p10.Id;
            return result;
            
        }
        public static Expression<Func<MedicalHistory, MedicalHistorySDto>> ProjectToSDto => p12 => new MedicalHistorySDto()
        {
            ChiefComplaint = p12.ChiefComplaint,
            SectionId = p12.SectionId,
            SectionName = p12.Section != null ? p12.Section.Name : string.Empty,
            FirstName = p12.FirstName,
            LastName = p12.LastName,
            FatherName = p12.FatherName,
            NationalId = p12.NationalId,
            MedicalHistoryTemplateId = p12.MedicalHistoryTemplateId,
            Age = p12.Age,
            BirthDate = p12.BirthDate,
            PresentIllnessDetail = p12.PresentIllnessDetail,
            PastDiseasesHistoryDetail = p12.PastDiseasesHistoryDetail,
            PastSurgeryHistoryDetail = p12.PastSurgeryHistoryDetail,
            FamilyHistoryDetail = p12.FamilyHistoryDetail,
            AllergyDetail = p12.AllergyDetail,
            DrugHistoryDetail = p12.DrugHistoryDetail,
            AddictionHistoryDetail = p12.AddictionHistoryDetail,
            SystemReviewDetail = p12.SystemReviewDetail,
            VitalSignDetail = p12.VitalSignDetail,
            GeneralAppearanceDetail = p12.GeneralAppearanceDetail,
            SystolicBloodPressure = p12.SystolicBloodPressure,
            DiastolicBloodPressure = p12.DiastolicBloodPressure,
            PulseRate = p12.PulseRate,
            SPO2 = p12.SPO2,
            Temperature = p12.Temperature,
            ApplicationUserId = p12.ApplicationUserId,
            Id = p12.Id
        };
        public static MedicalHistory AdaptToMedicalHistory(this MedicalHistoryLDto p13)
        {
            return p13 == null ? null : new MedicalHistory()
            {
                ChiefComplaint = p13.ChiefComplaint,
                SectionId = p13.SectionId,
                Section = p13.Section == null ? null : new Section()
                {
                    Name = p13.Section.Name,
                    Detail = p13.Section.Detail,
                    UniversityId = p13.Section.UniversityId,
                    Id = p13.Section.Id
                },
                FirstName = p13.FirstName,
                LastName = p13.LastName,
                FatherName = p13.FatherName,
                NationalId = p13.NationalId,
                Age = p13.Age,
                BirthDate = p13.BirthDate,
                PresentIllnessDetail = p13.PresentIllnessDetail,
                PastDiseasesHistoryDetail = p13.PastDiseasesHistoryDetail,
                PastSurgeryHistoryDetail = p13.PastSurgeryHistoryDetail,
                FamilyHistoryDetail = p13.FamilyHistoryDetail,
                AllergyDetail = p13.AllergyDetail,
                DrugHistoryDetail = p13.DrugHistoryDetail,
                AddictionHistoryDetail = p13.AddictionHistoryDetail,
                SystemReviewDetail = p13.SystemReviewDetail,
                VitalSignDetail = p13.VitalSignDetail,
                GeneralAppearanceDetail = p13.GeneralAppearanceDetail,
                SystolicBloodPressure = p13.SystolicBloodPressure,
                DiastolicBloodPressure = p13.DiastolicBloodPressure,
                PulseRate = p13.PulseRate,
                SPO2 = p13.SPO2,
                Temperature = p13.Temperature,
                MedicalHistoryTemplateId = p13.MedicalHistoryTemplateId,
                ApplicationUserId = p13.ApplicationUserId,
                Answers = funcMain3(p13.Answers),
                Id = p13.Id
            };
        }
        public static MedicalHistory AdaptTo(this MedicalHistoryLDto p15, MedicalHistory p16)
        {
            if (p15 == null)
            {
                return null;
            }
            MedicalHistory result = p16 ?? new MedicalHistory();
            
            result.ChiefComplaint = p15.ChiefComplaint;
            result.SectionId = p15.SectionId;
            result.Section = funcMain4(p15.Section, result.Section);
            result.FirstName = p15.FirstName;
            result.LastName = p15.LastName;
            result.FatherName = p15.FatherName;
            result.NationalId = p15.NationalId;
            result.Age = p15.Age;
            result.BirthDate = p15.BirthDate;
            result.PresentIllnessDetail = p15.PresentIllnessDetail;
            result.PastDiseasesHistoryDetail = p15.PastDiseasesHistoryDetail;
            result.PastSurgeryHistoryDetail = p15.PastSurgeryHistoryDetail;
            result.FamilyHistoryDetail = p15.FamilyHistoryDetail;
            result.AllergyDetail = p15.AllergyDetail;
            result.DrugHistoryDetail = p15.DrugHistoryDetail;
            result.AddictionHistoryDetail = p15.AddictionHistoryDetail;
            result.SystemReviewDetail = p15.SystemReviewDetail;
            result.VitalSignDetail = p15.VitalSignDetail;
            result.GeneralAppearanceDetail = p15.GeneralAppearanceDetail;
            result.SystolicBloodPressure = p15.SystolicBloodPressure;
            result.DiastolicBloodPressure = p15.DiastolicBloodPressure;
            result.PulseRate = p15.PulseRate;
            result.SPO2 = p15.SPO2;
            result.Temperature = p15.Temperature;
            result.MedicalHistoryTemplateId = p15.MedicalHistoryTemplateId;
            result.ApplicationUserId = p15.ApplicationUserId;
            result.Answers = funcMain5(p15.Answers, result.Answers);
            result.Id = p15.Id;
            return result;
            
        }
        public static Expression<Func<MedicalHistoryLDto, MedicalHistory>> ProjectLDtoToMedicalHistory => p21 => new MedicalHistory()
        {
            ChiefComplaint = p21.ChiefComplaint,
            SectionId = p21.SectionId,
            Section = p21.Section == null ? null : new Section()
            {
                Name = p21.Section.Name,
                Detail = p21.Section.Detail,
                UniversityId = p21.Section.UniversityId,
                Id = p21.Section.Id
            },
            FirstName = p21.FirstName,
            LastName = p21.LastName,
            FatherName = p21.FatherName,
            NationalId = p21.NationalId,
            Age = p21.Age,
            BirthDate = p21.BirthDate,
            PresentIllnessDetail = p21.PresentIllnessDetail,
            PastDiseasesHistoryDetail = p21.PastDiseasesHistoryDetail,
            PastSurgeryHistoryDetail = p21.PastSurgeryHistoryDetail,
            FamilyHistoryDetail = p21.FamilyHistoryDetail,
            AllergyDetail = p21.AllergyDetail,
            DrugHistoryDetail = p21.DrugHistoryDetail,
            AddictionHistoryDetail = p21.AddictionHistoryDetail,
            SystemReviewDetail = p21.SystemReviewDetail,
            VitalSignDetail = p21.VitalSignDetail,
            GeneralAppearanceDetail = p21.GeneralAppearanceDetail,
            SystolicBloodPressure = p21.SystolicBloodPressure,
            DiastolicBloodPressure = p21.DiastolicBloodPressure,
            PulseRate = p21.PulseRate,
            SPO2 = p21.SPO2,
            Temperature = p21.Temperature,
            MedicalHistoryTemplateId = p21.MedicalHistoryTemplateId,
            ApplicationUserId = p21.ApplicationUserId,
            Answers = p21.Answers.Select<MedicalHistoryAnswerSDto, MedicalHistoryAnswer>(p22 => new MedicalHistoryAnswer()
            {
                Answer = p22.Answer,
                Question = p22.Question,
                Part = p22.Part,
                QuestionType = p22.QuestionType,
                MedicalHistoryId = p22.MedicalHistoryId,
                Id = p22.Id
            }).ToList<MedicalHistoryAnswer>(),
            Id = p21.Id
        };
        public static MedicalHistoryLDto AdaptToLDto(this MedicalHistory p23)
        {
            return p23 == null ? null : new MedicalHistoryLDto()
            {
                ChiefComplaint = p23.ChiefComplaint,
                SectionId = p23.SectionId,
                FirstName = p23.FirstName,
                LastName = p23.LastName,
                FatherName = p23.FatherName,
                NationalId = p23.NationalId,
                Age = p23.Age,
                BirthDate = p23.BirthDate,
                Section = p23.Section == null ? null : new SectionSDto()
                {
                    Name = p23.Section.Name,
                    Detail = p23.Section.Detail,
                    UniversityId = p23.Section.UniversityId,
                    Id = p23.Section.Id
                },
                PresentIllnessDetail = p23.PresentIllnessDetail,
                PastDiseasesHistoryDetail = p23.PastDiseasesHistoryDetail,
                PastSurgeryHistoryDetail = p23.PastSurgeryHistoryDetail,
                FamilyHistoryDetail = p23.FamilyHistoryDetail,
                AllergyDetail = p23.AllergyDetail,
                DrugHistoryDetail = p23.DrugHistoryDetail,
                AddictionHistoryDetail = p23.AddictionHistoryDetail,
                SystemReviewDetail = p23.SystemReviewDetail,
                VitalSignDetail = p23.VitalSignDetail,
                GeneralAppearanceDetail = p23.GeneralAppearanceDetail,
                MedicalHistoryTemplateId = p23.MedicalHistoryTemplateId,
                SystolicBloodPressure = p23.SystolicBloodPressure,
                DiastolicBloodPressure = p23.DiastolicBloodPressure,
                PulseRate = p23.PulseRate,
                SPO2 = p23.SPO2,
                Temperature = p23.Temperature,
                ApplicationUserId = p23.ApplicationUserId,
                Answers = funcMain6(p23.Answers),
                Id = p23.Id
            };
        }
        public static MedicalHistoryLDto AdaptTo(this MedicalHistory p25, MedicalHistoryLDto p26)
        {
            if (p25 == null)
            {
                return null;
            }
            MedicalHistoryLDto result = p26 ?? new MedicalHistoryLDto();
            
            result.ChiefComplaint = p25.ChiefComplaint;
            result.SectionId = p25.SectionId;
            result.FirstName = p25.FirstName;
            result.LastName = p25.LastName;
            result.FatherName = p25.FatherName;
            result.NationalId = p25.NationalId;
            result.Age = p25.Age;
            result.BirthDate = p25.BirthDate;
            result.Section = funcMain7(p25.Section, result.Section);
            result.PresentIllnessDetail = p25.PresentIllnessDetail;
            result.PastDiseasesHistoryDetail = p25.PastDiseasesHistoryDetail;
            result.PastSurgeryHistoryDetail = p25.PastSurgeryHistoryDetail;
            result.FamilyHistoryDetail = p25.FamilyHistoryDetail;
            result.AllergyDetail = p25.AllergyDetail;
            result.DrugHistoryDetail = p25.DrugHistoryDetail;
            result.AddictionHistoryDetail = p25.AddictionHistoryDetail;
            result.SystemReviewDetail = p25.SystemReviewDetail;
            result.VitalSignDetail = p25.VitalSignDetail;
            result.GeneralAppearanceDetail = p25.GeneralAppearanceDetail;
            result.MedicalHistoryTemplateId = p25.MedicalHistoryTemplateId;
            result.SystolicBloodPressure = p25.SystolicBloodPressure;
            result.DiastolicBloodPressure = p25.DiastolicBloodPressure;
            result.PulseRate = p25.PulseRate;
            result.SPO2 = p25.SPO2;
            result.Temperature = p25.Temperature;
            result.ApplicationUserId = p25.ApplicationUserId;
            result.Answers = funcMain8(p25.Answers, result.Answers);
            result.Id = p25.Id;
            return result;
            
        }
        public static Expression<Func<MedicalHistory, MedicalHistoryLDto>> ProjectToLDto => p31 => new MedicalHistoryLDto()
        {
            ChiefComplaint = p31.ChiefComplaint,
            SectionId = p31.SectionId,
            FirstName = p31.FirstName,
            LastName = p31.LastName,
            FatherName = p31.FatherName,
            NationalId = p31.NationalId,
            Age = p31.Age,
            BirthDate = p31.BirthDate,
            Section = p31.Section == null ? null : new SectionSDto()
            {
                Name = p31.Section.Name,
                Detail = p31.Section.Detail,
                UniversityId = p31.Section.UniversityId,
                Id = p31.Section.Id
            },
            PresentIllnessDetail = p31.PresentIllnessDetail,
            PastDiseasesHistoryDetail = p31.PastDiseasesHistoryDetail,
            PastSurgeryHistoryDetail = p31.PastSurgeryHistoryDetail,
            FamilyHistoryDetail = p31.FamilyHistoryDetail,
            AllergyDetail = p31.AllergyDetail,
            DrugHistoryDetail = p31.DrugHistoryDetail,
            AddictionHistoryDetail = p31.AddictionHistoryDetail,
            SystemReviewDetail = p31.SystemReviewDetail,
            VitalSignDetail = p31.VitalSignDetail,
            GeneralAppearanceDetail = p31.GeneralAppearanceDetail,
            MedicalHistoryTemplateId = p31.MedicalHistoryTemplateId,
            SystolicBloodPressure = p31.SystolicBloodPressure,
            DiastolicBloodPressure = p31.DiastolicBloodPressure,
            PulseRate = p31.PulseRate,
            SPO2 = p31.SPO2,
            Temperature = p31.Temperature,
            ApplicationUserId = p31.ApplicationUserId,
            Answers = p31.Answers.Select<MedicalHistoryAnswer, MedicalHistoryAnswerSDto>(p32 => new MedicalHistoryAnswerSDto()
            {
                Answer = p32.Answer,
                Question = p32.Question,
                Part = p32.Part,
                QuestionType = p32.QuestionType,
                MedicalHistoryId = p32.MedicalHistoryId,
                Id = p32.Id
            }).ToList<MedicalHistoryAnswerSDto>(),
            Id = p31.Id
        };
        
        private static Section funcMain1(Never p4, Section p5, MedicalHistorySDto p2)
        {
            Section result = p5 ?? new Section();
            
            result.Name = p2.SectionName;
            result.Id = p2.SectionId;
            return result;
            
        }
        
        private static ApplicationUser funcMain2(Never p6, ApplicationUser p7, MedicalHistorySDto p2)
        {
            ApplicationUser result = p7 ?? new ApplicationUser();
            
            result.Id = p2.ApplicationUserId;
            return result;
            
        }
        
        private static List<MedicalHistoryAnswer> funcMain3(List<MedicalHistoryAnswerSDto> p14)
        {
            if (p14 == null)
            {
                return null;
            }
            List<MedicalHistoryAnswer> result = new List<MedicalHistoryAnswer>(p14.Count);
            
            int i = 0;
            int len = p14.Count;
            
            while (i < len)
            {
                MedicalHistoryAnswerSDto item = p14[i];
                result.Add(item == null ? null : new MedicalHistoryAnswer()
                {
                    Answer = item.Answer,
                    Question = item.Question,
                    Part = item.Part,
                    QuestionType = item.QuestionType,
                    MedicalHistoryId = item.MedicalHistoryId,
                    Id = item.Id
                });
                i++;
            }
            return result;
            
        }
        
        private static Section funcMain4(SectionSDto p17, Section p18)
        {
            if (p17 == null)
            {
                return null;
            }
            Section result = p18 ?? new Section();
            
            result.Name = p17.Name;
            result.Detail = p17.Detail;
            result.UniversityId = p17.UniversityId;
            result.Id = p17.Id;
            return result;
            
        }
        
        private static List<MedicalHistoryAnswer> funcMain5(List<MedicalHistoryAnswerSDto> p19, List<MedicalHistoryAnswer> p20)
        {
            if (p19 == null)
            {
                return null;
            }
            List<MedicalHistoryAnswer> result = new List<MedicalHistoryAnswer>(p19.Count);
            
            int i = 0;
            int len = p19.Count;
            
            while (i < len)
            {
                MedicalHistoryAnswerSDto item = p19[i];
                result.Add(item == null ? null : new MedicalHistoryAnswer()
                {
                    Answer = item.Answer,
                    Question = item.Question,
                    Part = item.Part,
                    QuestionType = item.QuestionType,
                    MedicalHistoryId = item.MedicalHistoryId,
                    Id = item.Id
                });
                i++;
            }
            return result;
            
        }
        
        private static List<MedicalHistoryAnswerSDto> funcMain6(List<MedicalHistoryAnswer> p24)
        {
            if (p24 == null)
            {
                return null;
            }
            List<MedicalHistoryAnswerSDto> result = new List<MedicalHistoryAnswerSDto>(p24.Count);
            
            int i = 0;
            int len = p24.Count;
            
            while (i < len)
            {
                MedicalHistoryAnswer item = p24[i];
                result.Add(item == null ? null : new MedicalHistoryAnswerSDto()
                {
                    Answer = item.Answer,
                    Question = item.Question,
                    Part = item.Part,
                    QuestionType = item.QuestionType,
                    MedicalHistoryId = item.MedicalHistoryId,
                    Id = item.Id
                });
                i++;
            }
            return result;
            
        }
        
        private static SectionSDto funcMain7(Section p27, SectionSDto p28)
        {
            if (p27 == null)
            {
                return null;
            }
            SectionSDto result = p28 ?? new SectionSDto();
            
            result.Name = p27.Name;
            result.Detail = p27.Detail;
            result.UniversityId = p27.UniversityId;
            result.Id = p27.Id;
            return result;
            
        }
        
        private static List<MedicalHistoryAnswerSDto> funcMain8(List<MedicalHistoryAnswer> p29, List<MedicalHistoryAnswerSDto> p30)
        {
            if (p29 == null)
            {
                return null;
            }
            List<MedicalHistoryAnswerSDto> result = new List<MedicalHistoryAnswerSDto>(p29.Count);
            
            int i = 0;
            int len = p29.Count;
            
            while (i < len)
            {
                MedicalHistoryAnswer item = p29[i];
                result.Add(item == null ? null : new MedicalHistoryAnswerSDto()
                {
                    Answer = item.Answer,
                    Question = item.Question,
                    Part = item.Part,
                    QuestionType = item.QuestionType,
                    MedicalHistoryId = item.MedicalHistoryId,
                    Id = item.Id
                });
                i++;
            }
            return result;
            
        }
    }
}