public IHttpActionResult GetCustomerStatisticsByIdCard(string idCard) { var cust = _customerLogic.GetLatestCustomerByIdCard(idCard); string name = cust.CustomerName; var exams = _examLogic.GetAllPhysicalExamByIdCard(idCard); string freq = ""; var alldates = exams.OrderByDescending(p => p.CheckedDate).Select(p => p.CheckedDate); if (alldates.Count() == 1) { freq = "n/a"; } else { var timeSpan = alldates.First() - alldates.Last(); freq = $"{(int)(alldates.Count() / timeSpan.Value.TotalDays) * 365}/year"; } var highFreq = _conclusionLogic.GetConclusionsByIdCard(idCard) .Where(p => !string.IsNullOrEmpty(p.ConclusionTypeName)) .Select(p => p.ConclusionTypeName) .GroupBy(p => p) .OrderByDescending(g => g.Count()) .First().Key; var result = new { Name = name, ExamFrequency = freq, CustomerId = cust.ID_ArcCustomer, LastExamTime = alldates.FirstOrDefault(), FreqSymptom = highFreq }; return(Json(result)); }
public IHttpActionResult GetExamLogicByIDCard(string idCard) { var allHistory = _examLogic.GetAllPhysicalExamByIdCard(idCard); return(Json(allHistory)); }