Examination GetExamination(ZAP billCase, int examinationStage) { var examination = new Examination(); if (examinationStage == 1) { examination.BeginDate = billCase.Z_SL.SL.USL.First(x => x.CODE_USL == 24101).DATE_IN; } else { examination.BeginDate = billCase.Z_SL.SL.DATE_1; } examination.EndDate = billCase.Z_SL.SL.DATE_2; examination.HealthGroup = GetHealthGroup(billCase.Z_SL.RSLT_D); var naz_r = billCase.Z_SL.SL.NAZ.FirstOrDefault()?.NAZ_R ?? 0; examination.Referral = GetRefferal(examination.HealthGroup, naz_r); return(examination); }