public async Task <IEnumerable <PhysicalExamAntiAgingViewModel> > GetExamAntiAgingByEpiRowIdAsync(long epiRowId) { var physicalExam = await _questionnaireRepository.GetPhysicalExamAntiAgingAsync(epiRowId); var results = new List <PhysicalExamAntiAgingViewModel>(); foreach (var item in physicalExam) { var history = new History() { QCC = item.QCC, QCCText = item.QCCText, QCCOtherText = item.QCCOtherText, QUnderlying = item.QUnderlying, QCurrentMed = item.QCurrentMed, QSupplementation = item.QSupplementation, QHistoryInvestigation = item.QHistoryInvestigation, QGI = item.QGI, QGOText = item.QGOText, QSleep = item.QSleep, QSleepHours = item.QSleepHours, QSleepText = item.QSleepText, QSkin = item.QSkin, QSkinText = item.QSkinText, QMemory = item.QMemory, QMemoryText = item.QMemoryText, QImmune = item.QImmune, QImmuneText = item.QImmuneText, QSexual = item.QSexual, QSexualText = item.QSexualText, QExercise = item.QExercise, }; var isHistory = history.GetType().GetProperties() .Where(h => h.GetValue(history) is string) .Select(h => (string)h.GetValue(history)) .Any(value => !String.IsNullOrEmpty(value)); var genetic = new Genetic() { QGenetic = item.QGenetic }; var isGenetic = genetic.GetType().GetProperties() .Where(g => g.GetValue(genetic) is string) .Select(g => (string)g.GetValue(genetic)) .Any(value => !String.IsNullOrEmpty(value)); var familyHistory = new FamilyHistory() { QFamilyFather = item.QFamilyFather, QFamilyMother = item.QFamilyMother }; var isFamilyHistory = familyHistory.GetType().GetProperties() .Where(f => f.GetValue(familyHistory) is string) .Select(f => (string)f.GetValue(familyHistory)) .Any(value => !String.IsNullOrEmpty(value)); var physicalExamination = new PhysicalExamination() { QENTPE = item.QENTPE, QAbdomenPE = item.QAbdomenPE, QAbdomenPEText = item.QAbdomenPEText, QCardiovascularPE = item.QCardiovascularPE, QCardiovascularPEText = item.QCardiovascularPEText, QENTNeckNode = item.QENTNeckNode, QENTPEText = item.QENTPEText, QENTPharynx = item.QENTPharynx, QENTTonsils = item.QENTTonsils, QGeneralPE = item.QGeneralPE, QGeneralPEText = item.QGeneralPEText, QPEText = item.QPEText, QRespiratoryPE = item.QRespiratoryPE, QRespiratoryPEText = item.QRespiratoryPEText }; var isPhysicalExamination = physicalExamination.GetType().GetProperties() .Where(p => p.GetValue(physicalExamination) is string) .Select(p => (string)p.GetValue(physicalExamination)) .Any(value => !String.IsNullOrEmpty(value)); var specialNote = new SpecialNote() { QSpecialNote = item.QSpecialNote }; var model = new PhysicalExamAntiAgingViewModel() { ID = item.ID, QUESPAAdmDR = item.QUESPAAdmDR, QUESPAPatMasDR = item.QUESPAPatMasDR, QUESDate = item.QUESDate, QUESTime = item.QUESTime, History = history, IsHistory = isHistory, Genetic = genetic, IsGenetic = isGenetic, FamilyHistory = familyHistory, IsFamilyHistory = isFamilyHistory, PhysicalExamination = physicalExamination, IsPhysicalExamination = isFamilyHistory, SpecialNote = specialNote, QDoctor = item.QDoctor, QUESUserDR = item.QUESUserDR }; results.Add(model); } return(results); }