Пример #1
0
 public Dictionary <string, int> drugStatistics(DateTime start, DateTime finish, string drugID = null)
 {
     try
     {
         Dictionary <string, int> result = new Dictionary <string, int>();
         if (drugID != null)
         {
             var prescriptionsOnTheAppropriateDate = (from item in IDalService.GetAllRecipes()
                                                      where (drugID == item.MedicineId && start <= item.Date && finish >= item.Date)
                                                      group item by item.Date.ToString("MM")).ToList();
             var prescriptions = prescriptionsOnTheAppropriateDate.OrderBy(g => g.Key);
             foreach (var g in prescriptions)
             {
                 result.Add(g.Key, g.Count());
             }
         }
         if (drugID == null)
         {
             var prescriptionsOnTheAppropriateDate = (from item in IDalService.GetAllRecipes()
                                                      where (start <= item.Date && finish >= item.Date)
                                                      group item by item.Date.ToString("MM")).ToList();
             var prescriptions = prescriptionsOnTheAppropriateDate.OrderBy(g => g.Key);
             foreach (var g in prescriptions)
             {
                 result.Add(g.Key, g.Count());
             }
         }
         return(result);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Пример #2
0
 public List <Recipe> GetAllRecipes(Func <Recipe, bool> predicate = null)
 {
     try
     {
         List <Recipe> res = IDalService.GetAllRecipes();
         return(res);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Пример #3
0
 public List <Recipe> getPatientHistoryByDrug(DateTime first, DateTime second, string patientId = null, string drugID = null)
 {
     try
     {
         List <Recipe> result = new List <Recipe>();
         if (patientId != null && drugID != null)
         {
             result = (from item in getPatientHistory(patientId)
                       where drugID == item.MedicineId && item.Date <= second.AddDays(1) && item.Date.AddDays(item.PeriodOfUse) > first
                       select item).ToList();
         }
         if (patientId != null && drugID == null)
         {
             result = (from item in getPatientHistory(patientId)
                       where item.Date <= second.AddDays(1) && item.Date.AddDays(item.PeriodOfUse) > first
                       select item).ToList();
         }
         if (patientId == null && drugID != null)
         {
             result = (from item in IDalService.GetAllRecipes()
                       where drugID == item.MedicineId && item.Date <= second.AddDays(1) && item.Date.AddDays(item.PeriodOfUse) > first
                       select item).ToList();
         }
         if (patientId == null && drugID == null)
         {
             result = (from item in IDalService.GetAllRecipes()
                       where item.Date <= second.AddDays(1) && item.Date.AddDays(item.PeriodOfUse) > first
                       select item).ToList();
         }
         return(result);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }