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