Exemplo n.º 1
0
        public ActionResult GetResultData(string search, string airline, string nomorPenerbangan, string startDate, string endDate, string suspect, string rujukRS, string hasilLab, string kondisi)
        {
            var dc = new PinereDataContext(PinereConstant.PinereConnectionString);
            List <SearchResult> ResultList = new List <SearchResult>();

            try
            {
                if (search == "True")
                {
                    var Result = (from a in dc.GetPasienListReport() select a);
                    if (!airline.IsNullOrEmpty())
                    {
                        Result = Result.Where(o => o.AirlineId.Value.ToString() == airline);
                    }
                    if (!nomorPenerbangan.IsNullOrEmpty())
                    {
                        Result = Result.Where(o => o.NomorPenerbangan.Contains(nomorPenerbangan));
                    }
                    if (!startDate.IsNullOrEmpty() && !endDate.IsNullOrEmpty())
                    {
                        Result = Result.Where(o => (o.TanggalDatang >= DateTime.Parse(startDate) && o.TanggalDatang <= DateTime.Parse(endDate)));
                    }
                    if (!suspect.IsNullOrEmpty())
                    {
                        Result = Result.Where(o => o.Hasil_Diagnosa == suspect);
                    }
                    if (!rujukRS.IsNullOrEmpty())
                    {
                        Result = Result.Where(o => o.Rujuk_RS == rujukRS);
                    }
                    if (!hasilLab.IsNullOrEmpty())
                    {
                        Result = Result.Where(o => o.Hasil_Lab == hasilLab);
                    }
                    if (!kondisi.IsNullOrEmpty())
                    {
                        Result = Result.Where(o => o.Kondisi == kondisi);
                    }

                    Result     = Result.OrderByDescending(o => o.TanggalDatang);
                    ResultList = (from a in Result
                                  select new SearchResult
                    {
                        NamaPasien = a.NamaPasien,
                        TanggalLahir = DataRepository.GetDateStringFromDate(a.TanggalLahir),
                        NamaAirline = a.NamaAirline,
                        NomorPenerbangan = a.NomorPenerbangan,
                        WaktuBerangkat = DataRepository.GetDateStringFromDate(a.TanggalDatang),
                        Suspect = a.DiagnosaDis,
                        RujukRS = a.Rujuk_RS_Dis,
                        Resiko = a.tingkat_risiko_dis,
                        HasilLab = a.Hasil_Lab_Dis,
                        Kondisi = a.Kondisi_Dis,
                        ActionEdit = Url.Action("View", new { @KKPId = a.KKPId })
                    }).ToList();
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
            return(Json(new
            {
                iTotalRecords = ResultList.Count(),
                iTotalDisplayRecords = ResultList.Count(),
                aaData = ResultList
            }, JsonRequestBehavior.AllowGet));
        }