Ejemplo n.º 1
0
        public async Task <IActionResult> Index(string sortOrder     = null,
                                                string currentFilter = null,
                                                string searchString  = null,
                                                int?page             = null)
        {
            ViewData["CurrentSort"]         = sortOrder;
            ViewData["SortName"]            = string.IsNullOrEmpty(sortOrder) ? "name_desc" : "";
            ViewData["SortAtcCode"]         = sortOrder == "atc_code" ? "atc_code_desc" : "atc_code";
            ViewData["SortFormOfInjection"] = sortOrder == "form_of_injection" ? "form_of_injection_desc" : "form_of_injection";
            ViewData["SortStrength"]        = sortOrder == "strength" ? "strength_desc" : "strength";
            ViewData["SortManufacturer"]    = sortOrder == "manufacturer" ? "manufacturer_desc" : "manufacturer";
            ViewData["SortLegalStatus"]     = sortOrder == "legal_status" ? "legal_status_desc" : "legal_status";
            ViewData["SortReimbursement"]   = sortOrder == "reimbursement" ? "reimbursement_desc" : "reimbursement";
            ViewData["SortValidFrom"]       = sortOrder == "validFrom" ? "validFrom_desc" : "validFrom";
            ViewData["SortValidTo"]         = sortOrder == "validTo" ? "validTo_desc" : "validTo";

            repository.SortOrder = sortOrder != null && sortOrder.EndsWith("_desc")
                ? SortOrder.Descending
                : SortOrder.Ascending;
            repository.SortFunction = getSortFunction(sortOrder);
            if (searchString != null)
            {
                page = 1;
            }
            else
            {
                searchString = currentFilter;
            }
            ViewData["CurrentFilter"] = searchString;
            repository.SearchString   = searchString;
            repository.PageIndex      = page ?? 1;
            var l = await repository.GetObjectsList();

            return(View(new MedicineViewModelsList(l)));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Index()
        {
            var user = await GetCurrentUser();

            var l = await portfolios.GetMedicines(user.Id);

            var catObjs = await categories.GetCategories(user.Id);

            List <CategoryViewModel> categoryViews = new List <CategoryViewModel>();
            List <MedicineObject>    usedMeds      = new List <MedicineObject>();

            foreach (var c in catObjs)
            {
                await categoryMedicines.LoadMedicines(c);

                foreach (var med in c.MedicinesWithCategory)
                {
                    usedMeds.Add(med);
                    await medicineEffects.LoadEffects(med);
                }
                categoryViews.Add(CategoryViewModelFactory.Create(c));
            }

            var allMeds = await medicines.GetObjectsList();

            List <string> duplicateIds = new List <string>();

            for (int i = 0; i < allMeds.Count; i++)
            {
                bool contains = usedMeds.Any(x => x.DbRecord.ID == allMeds[i].DbRecord.ID);
                if (contains)
                {
                    duplicateIds.Add(allMeds[i].DbRecord.ID);
                }
            }

            foreach (var id in duplicateIds)
            {
                var medicine = allMeds.Where(x => x.DbRecord.ID == id).ToList();
                allMeds.Remove(medicine[0]);
            }
            //foreach (var med in allMeds)
            //{
            //    int index = usedMeds.FindIndex(x => x.DbRecord.ID == med.DbRecord.ID);
            //    if (index>=0)
            //    {
            //        allMeds.Remove(med);
            //    }
            //}

            ViewBag.Medicines = allMeds.Select(x => new SelectListItem
            {
                Value = x.DbRecord.ID,
                Text  = x.DbRecord.Name + ", " + x.DbRecord.FormOfInjection + ", " + x.DbRecord.Strength
            }).ToList();

            ViewBag.Categories = categoryViews;
            return(View(PortfolioViewModelFactory.Create(user.Id, l)));
        }
        public async Task <IActionResult> Index(string sortOrder     = null,
                                                string currentFilter = null,
                                                string searchString  = null,
                                                int?page             = null)
        {
            ViewData["CurrentSort"]         = sortOrder;
            ViewData["SortName"]            = string.IsNullOrEmpty(sortOrder) ? "name_desc" : "";
            ViewData["SortAtcCode"]         = sortOrder == "atc_code" ? "atc_code_desc" : "atc_code";
            ViewData["SortFormOfInjection"] = sortOrder == "form_of_injection" ? "form_of_injection_desc" : "form_of_injection";
            ViewData["SortStrength"]        = sortOrder == "strength" ? "strength_desc" : "strength";
            ViewData["SortManufacturer"]    = sortOrder == "manufacturer" ? "manufacturer_desc" : "manufacturer";
            ViewData["SortLegalStatus"]     = sortOrder == "legal_status" ? "legal_status_desc" : "legal_status";
            ViewData["SortReimbursement"]   = sortOrder == "reimbursement" ? "reimbursement_desc" : "reimbursement";
            ViewData["SortValidFrom"]       = sortOrder == "validFrom" ? "validFrom_desc" : "validFrom";
            ViewData["SortValidTo"]         = sortOrder == "validTo" ? "validTo_desc" : "validTo";

            repository.SortOrder = sortOrder != null && sortOrder.EndsWith("_desc")
                ? SortOrder.Descending
                : SortOrder.Ascending;
            repository.SortFunction = getSortFunction(sortOrder);
            if (searchString != null)
            {
                page = 1;
            }
            else
            {
                searchString = currentFilter;
            }
            ViewData["CurrentFilter"] = searchString;
            repository.SearchString   = searchString;
            repository.PageIndex      = page ?? 1;
            var l = await repository.GetObjectsList();

            var user = await GetCurrentUser();

            categories.PageSize = 1000000;
            var cats = await categories.GetCategories(user.Id);

            ViewBag.Categories = cats.Select(x => new SelectListItem
            {
                Value = x.DbRecord.ID,
                Text  = x.DbRecord.CategoryName
            }).ToList();

            var medicinesInPortfolio = await portfolios.GetMedicines(user.Id);

            Dictionary <string, string> medicineCategoryIds = new Dictionary <string, string>();

            foreach (var med in medicinesInPortfolio)
            {
                var medicineCategory = await categoryMedicines.GetCategory(med);

                medicineCategoryIds[med.DbRecord.ID] = medicineCategory.DbRecord.ID;
            }

            ViewBag.MedicineCategories = medicineCategoryIds;
            return(View(new MedicineViewModelsList(l)));
        }
        public async Task SetPropertiesMedicine(string personIdCode)
        {
            medicines.PageSize = 1000000;
            var l = await medicines.GetObjectsList();

            ViewBag.Medicines = l.Select(x => new SelectListItem
            {
                Value = x.DbRecord.ID,
                Text  = x.DbRecord.Name + ", " + x.DbRecord.FormOfInjection + ", " + x.DbRecord.Strength
            }).ToList();
            var perObj = await persons.GetPersonByIDCode(personIdCode);

            ViewBag.PatientName = perObj.DbRecord.FirstName + " " + perObj.DbRecord.LastName;
        }