Пример #1
0
        public JsonResult AutoCompleteLaborat(string formMedicalID, string prefix)
        {
            List <LabItem> labList = _unitOfWork.LabItemRepository.Get(x => x.LabItemCategory.LabType == "Laboratorium" && x.RowStatus == 0).ToList();

            var filteredList = labList.Where(t => t.Name.ToLower().Contains(prefix.ToLower()));

            List <TempClass> resultList = new List <TempClass>();

            foreach (var item in filteredList)
            {
                TempClass temp = new TempClass
                {
                    id    = item.ID,
                    label = item.Name,
                    code  = item.Code,
                    stock = "911" // hardcoded for now
                };

                FormExamineLab lab = _unitOfWork.FormExamineLabRepository.GetFirstOrDefault(x => x.LabItemID == item.ID && x.FormMedicalID.ToString() == formMedicalID);
                temp.value = lab == null ? string.Empty : lab.Result;

                resultList.Add(temp);
            }

            return(Json(resultList, JsonRequestBehavior.AllowGet));
        }
Пример #2
0
        public JsonResult AutoCompleteService(string poliID, string prefix)
        {
            int                _poliID         = int.Parse(poliID);
            List <Service>     serviceList     = _unitOfWork.ServicesRepository.Get().ToList();
            List <PoliService> poliServiceList = _unitOfWork.PoliServicesRepository.Get(x => x.PoliID == _poliID && x.RowStatus == 0).ToList();

            var filteredList = serviceList.Where(x => !poliServiceList.Any(p => p.ServicesID == x.ID) && x.Name.ToLower().Contains(prefix.ToLower())).ToList();

            List <TempClass> resultList = new List <TempClass>();

            foreach (var item in filteredList)
            {
                TempClass temp = new TempClass
                {
                    id    = item.ID,
                    label = item.Name,
                    code  = item.Code,
                    stock = item.Price.ToString()
                };

                resultList.Add(temp);
            }

            return(Json(resultList, JsonRequestBehavior.AllowGet));
        }
Пример #3
0
        public JsonResult AutoCompleteMedicineAdvance(string prefix)
        {
            List <ProductModel> lists = new List <ProductModel>();
            dynamic             qry   = null;
            var searchPredicate       = PredicateBuilder.New <Product>(true);

            // add default filter to show the active data only
            searchPredicate = searchPredicate.And(x => x.RowStatus == 0 && x.Name.ToLower().Contains(prefix.ToLower()));

            qry = _unitOfWork.ProductRepository.Get(searchPredicate, null);

            long clinicId = 0;

            if (Session["UserLogon"] != null)
            {
                var tempData = (AccountModel)Session["UserLogon"];
                clinicId = tempData.ClinicID;
            }


            var temp            = (IEnumerable <Product>)qry;
            var productIdS      = temp.Select(x => x.ID).Distinct().ToList();
            var gudangs         = _unitOfWork.GudangRepository.Get(x => x.ClinicId == clinicId).Select(x => x.id).ToList();
            var stockCollection = _unitOfWork.ProductInGudangRepository.Get(x => productIdS.Contains(x.ProductId ?? 0) && gudangs.Contains(x.GudangId ?? 0)).Select(x => new {
                x.ProductId,
                x.stock
            });
            List <TempClass> resultList = new List <TempClass>();

            foreach (var item in qry)
            {
                var prData = new ProductModel();
                prData = Mapper.Map <Product, ProductModel>(item);
                //prData.stock = Convert.ToDecimal(stockCollection.SingleOrDefault(x => x.ProductId == prData.Id) == null ? 0 : stockCollection.SingleOrDefault(x => x.ProductId == prData.Id).stock);
                //lists.Add(prData);
                TempClass tmp = new TempClass
                {
                    id       = (Int32)prData.Id,
                    label    = prData.Name,
                    code     = prData.Code,
                    stock    = stockCollection.SingleOrDefault(x => x.ProductId == prData.Id) == null ? "0" : stockCollection.SingleOrDefault(x => x.ProductId == prData.Id).stock.ToString(),
                    category = prData.ProductCategoryName,
                    unit     = prData.ProductUnitName,
                    price    = prData.RetailPrice.ToString()
                };

                resultList.Add(tmp);
            }

            return(Json(resultList, JsonRequestBehavior.AllowGet));
        }
Пример #4
0
        public JsonResult AutoCompleteEmployee(string prefix)
        {
            long            _employeeId  = 0;
            List <Employee> employeeList = new List <Employee>();

            if (Session["UserLogon"] != null)
            {
                var _account = (AccountModel)Session["UserLogon"];
                if (_account != null)
                {
                    if (_account.EmployeeID > 0)
                    {
                        _employeeId = _account.EmployeeID;
                    }
                }
            }
            List <string> exceptionStatus = new List <string>();

            exceptionStatus.Add("Na");
            exceptionStatus.Add("R");

            var except = _unitOfWork.EmployeeStatusRepository.Get(x => exceptionStatus.Contains(x.Code)).Select(x => x.ID).ToList();

            if (_employeeId == 0)
            {
                employeeList = _unitOfWork.EmployeeRepository.Get(x => x.RowStatus == 0 && !except.Contains(x.Status ?? 0)).ToList();
            }
            else
            {
                employeeList = _unitOfWork.EmployeeRepository.Get(x => x.RowStatus == 0 && x.ID == _employeeId && !except.Contains(x.Status ?? 0)).ToList();
            }

            var filteredList = employeeList.Where(t => t.EmpName.ToLower().Contains(prefix.ToLower()));

            List <TempClass> resultList = new List <TempClass>();

            foreach (var item in filteredList)
            {
                TempClass temp = new TempClass
                {
                    id    = item.ID,
                    nik   = item.EmpID,
                    label = item.EmpName,
                };

                resultList.Add(temp);
            }

            return(Json(resultList, JsonRequestBehavior.AllowGet));
        }
Пример #5
0
        public JsonResult AutoCompleteMedicine(string prefix)
        {
            List <Product> productList = _unitOfWork.ProductRepository.Get(x => x.ProductCategoryID == 1 && x.RowStatus == 0).ToList();

            var filteredList = productList.Where(t => t.Name.ToLower().Contains(prefix.ToLower()));

            List <TempClass> resultList = new List <TempClass>();

            foreach (var item in filteredList)
            {
                TempClass temp = new TempClass
                {
                    id    = item.ID,
                    label = item.Name,
                    code  = item.Code,
                    stock = "911" // hardcoded for now
                };

                resultList.Add(temp);
            }

            return(Json(resultList, JsonRequestBehavior.AllowGet));
        }