Exemple #1
0
        public void Save(DrugModel drugModel)
        {
            if (drugModel.DrugId == 0)
            {
                var drugEntity = new Drug
                {
                    DrugCategoryId = drugModel.CategoryId,
                    DrugName       = drugModel.DrugName,
                    MeasureUnit    = drugModel.MeasureUnit,
                    ModifiedDate   = DateTime.Now.ToLocalTime()
                };

                _patientsContext.Drug.Add(drugEntity);
            }
            else
            {
                var drugEntity = _patientsContext.Drug.FirstOrDefault(c => c.DrugId == drugModel.DrugId);
                if (drugEntity != null)
                {
                    drugEntity.DrugCategoryId = drugModel.CategoryId;
                    drugEntity.DrugName       = drugModel.DrugName;
                    drugEntity.MeasureUnit    = drugModel.MeasureUnit;
                    drugEntity.ModifiedDate   = DateTime.Now.ToLocalTime();
                }
            }

            Save();
        }
        public ActionResult JS_Drugs()
        {
            int memid = Convert.ToInt32(Session["Memberid"]);

            using (KIITEntities db = new KIITEntities())
            {
                var data             = db.Drugs;
                List <DrugModel> lst = new List <DrugModel>();
                foreach (var item in data)
                {
                    lst.Add(new DrugModel
                    {
                        DrugId      = item.DrugId,
                        DrugName    = item.DrugName,
                        Man_Date    = item.ManufactureDate,
                        Exp_Date    = item.ExpiredDate,
                        UsedFor     = item.UsedFor,
                        SideEffects = item.SideEffects,
                        Quantity    = item.TotalQuantityAvailable,
                    });
                }
                DrugModel model = new DrugModel();
                model.lstDrugs = lst;
                return(View(model));
            }
        }
    public static string confirmDrug(int pid, string pspnum, string Hospitalid)
    {
        DrugModel dm = new DrugModel();

        DataTable dt = dm.findDrugByPid(pid + "");

        if (dt.Rows.Count > 0)
        {
            RecipeModel rm    = new RecipeModel();
            int         count = rm.confirmDrug(pid);
            if (count > 0)
            {
                DrugMatchingModel dmm = new DrugMatchingModel();

                dmm.findNotCheckAndMatchRecipeDrugInfoToMatch();
                return("操作成功");
            }
            else
            {
                return("操作失败");
            }
        }
        else
        {
            return("操作失败:该处方还没有录入药品");
        }
    }
Exemple #4
0
        public IActionResult Create(DrugModel drugModel)
        {
            try
            {
                int? userId = HttpContext.Session.GetInt32("userId");
                User user   = _context.Users.Where(u => u.Id == userId)
                              .Include(u => u.Applicant)
                              .Include(u => u.Manufacturer)
                              .FirstOrDefault();

                if (user != null && user.Applicant != null)
                {
                    if (ModelState.IsValid !)
                    {
                        Drug drug = new Drug
                        {
                            TradeName         = drugModel.TradeName,
                            InternationalName = drugModel.InternationalName,
                            Form      = drugModel.Form,
                            Formula   = drugModel.Formula,
                            Applicant = user.Applicant
                        };
                        _context.Drugs.Add(drug);
                        _context.SaveChanges();
                        return(RedirectToAction("Personal", "Drug"));
                    }
                    return(View());
                }
            }
            catch { }
            return(RedirectToAction("Login", "User"));
        }
        public DrugModel DetailsMethod(int?id)
        {
            //var dr=new DrugModel();
            DrugModel dr = new DrugModel();

            using (var drugr = new DrugRespo())
            {
                if (id.HasValue && id != 0)
                {
                    Drug _drug = drugr.GetById(id.Value);

                    dr.DrugId = _drug.DrugId;

                    dr.DrugCode        = _drug.DrugCode;
                    dr.DrugName        = _drug.DrugName;
                    dr.DrugCategory    = _drug.DrugCategory;
                    dr.DrugDescription = _drug.DrugDescription;
                    dr.DrugQuantity    = _drug.DrugQuantity;
                    dr.Status          = _drug.Status;
                    dr.DrugType        = _drug.DrugType;
                    dr.DrugPrice       = _drug.DrugPrice;
                }
                return(dr);
            }
        }
        public ActionResult Create(DrugModel model, string DrugType)
        {
            try
            {
                var dbo = new DrugBusiness();

                if (dbo.nameexists(model.DrugCode, DrugType))
                {
                    ModelState.AddModelError("", "Drug already exists, you can only increase quantity & change price for drug");
                    return(View(model));
                }

                dbo.CreateMethod(model, DrugType);
                foreach (DrugModel dg in dbo.GetAll())
                {
                    ViewBag.DrugName = dg.DrugName;
                }
                //TempData["msg"] = "Data has been successfully saved";
                return(RedirectToAction("Index"));
            }
            catch (DataException)
            {
                return(View(model));
            }
        }
Exemple #7
0
        public IActionResult Update(DrugModel drugModel)
        {
            try
            {
                int? userId = HttpContext.Session.GetInt32("userId");
                User user   = _context.Users.Where(u => u.Id == userId)
                              .Include(u => u.Applicant)
                              .Include(u => u.Manufacturer)
                              .FirstOrDefault();

                if (user != null && user.Applicant != null)
                {
                    if (ModelState.IsValid !)
                    {
                        Drug drug = _context.Drugs.Where(d => d.Id == drugModel.Id).Include(d => d.Applicant).FirstOrDefault();
                        if (drug != null || drug.Applicant.Id == user.Applicant.Id)
                        {
                            drug.TradeName         = drugModel.TradeName;
                            drug.InternationalName = drugModel.InternationalName;
                            drug.Form    = drugModel.Form;
                            drug.Formula = drugModel.Formula;
                            _context.SaveChanges();
                        }
                        return(RedirectToAction("Personal", "Drug"));
                    }
                }
            }
            catch { }
            return(RedirectToAction("Login", "User"));
        }
    public dotNetFlexGrid.DataHandlerResult FlexGridDrugDataHandler(dotNetFlexGrid.DataHandlerParams p)
    {
        dotNetFlexGrid.DataHandlerResult result = new dotNetFlexGrid.DataHandlerResult();
        result.page  = p.page; //设定当前返回的页号
        result.total = 100;    //总计的数据条数,此处用100进行模拟,查询和筛选时需要根据实际

        DrugModel dm         = new DrugModel();
        string    pspnum     = "0";
        string    hospitalId = "";

        if (p.extParam.ContainsKey("drugpspnum"))
        {
            pspnum = p.extParam["drugpspnum"];
        }
        if (p.extParam.ContainsKey("hospitalId"))
        {
            hospitalId = p.extParam["hospitalId"];
        }

        string pid = "";

        if (p.extParam.ContainsKey("pid"))
        {
            pid = p.extParam["pid"];
        }


        //result.table = dm.findNotMatchDrugByPspnum(pspnum, hospitalId);
        result.table = dm.findNotMatchDrugByPspnum(pid);

        return(result);
    }
Exemple #9
0
        public ActionResult OrderDrug()
        {
            Clinic_automation_systemEntities db = new Clinic_automation_systemEntities();
            var                   getdata       = db.Drugs.Where(m => m.IsDeleted == false).ToList();
            DrugModel             dm            = new DrugModel();
            List <SelectListItem> lst           = new List <SelectListItem>();

            if (getdata != null)
            {
                foreach (var item in getdata)
                {
                    lst.Add(new SelectListItem
                    {
                        Text  = item.DrugName,
                        Value = item.DrugId.ToString()
                    });
                }
                dm.DrugNameList = lst;
            }
            else
            {
                ViewBag.text = "No Drugs Available";
            }
            return(View(dm));
        }
        public ActionResult ViewEditDrugs()
        {
            DrugModel dm = new DrugModel();
            Clinic_automation_systemEntities db = new Clinic_automation_systemEntities();
            List <DrugModel> dmlist             = new List <DrugModel>();
            var getdata = db.Drugs.ToList();

            if (getdata != null)
            {
                foreach (var item in getdata)
                {
                    dmlist.Add(new DrugModel
                    {
                        DrugId          = item.DrugId,
                        DrugName        = item.DrugName,
                        ManufactureDate = item.ManufactureDate,
                        ExpiryDate      = item.ExpiryDate,
                        TotalQuantity   = item.TotalQuantityAvailable,
                        UsedFor         = item.UsedFor,
                        SideEffects     = item.SideEffects,
                        IsDeleted       = item.IsDeleted
                    });

                    dm.DrugList = dmlist;
                }
            }
            else
            {
                ViewBag.text = "No drug available";
            }

            return(View(dm));
        }
        public JsonResult DeleteDrug(DrugModel drug)
        {
            using (KIITEntities entities = new KIITEntities())
            {
                entities.RemoveDrug(drug.DrugId);
            }

            return(Json(drug));
        }
        public JsonResult InsertDrug(DrugModel drug)
        {
            using (KIITEntities entities = new KIITEntities())
            {
                entities.InsertDrug(drug.DrugName, drug.Man_Date, drug.Exp_Date, drug.UsedFor, drug.SideEffects, drug.Quantity);
            }

            return(Json(drug));
        }
        public ActionResult UpdateDrug(DrugModel drug)
        {
            using (KIITEntities entities = new KIITEntities())
            {
                entities.UpdateDrug(drug.DrugId, drug.DrugName, drug.Man_Date, drug.Exp_Date, drug.UsedFor, drug.SideEffects, drug.Quantity);
            }

            return(new EmptyResult());
        }
        public static void DeleteDrugFromDB(DrugModel selectedDrug)
        {
            using (SQLite.SQLiteConnection connection = new SQLite.SQLiteConnection(drugDatabasePath))
            {
                // Create table/ check for table so program does not crash
                connection.CreateTable <DrugModel>();

                // Delete the currently selected patient
                connection.Delete(selectedDrug);
            }
        }
        public static void UpdateDrug(DrugModel selectedDrugModel, string drugName, GeneralUseModel generalUse)
        {
            selectedDrugModel.DrugName   = drugName;
            selectedDrugModel.GeneralUse = generalUse.GeneralUse;

            using (SQLite.SQLiteConnection connection = new SQLite.SQLiteConnection(drugDatabasePath))
            {
                connection.CreateTable <DrugModel>();
                connection.Update(selectedDrugModel);
            }
        }
Exemple #16
0
        public IActionResult Update([FromBody] DrugModel drugModel)
        {
            var validationResult = this._drugValidator.Validate(drugModel);

            if (!validationResult.IsValid)
            {
                return(BadRequest(validationResult.GetFieldLevelErrors()));
            }

            _drugLogic.Save(drugModel);

            return(Ok());
        }
Exemple #17
0
        public ActionResult Add(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add update logic here

                int ElementsToDiscount = int.Parse(collection["add"]);

                if (ElementsToDiscount <= Storage.Instance.drugList.ElementAt(id - 1).Stock)
                {
                    int updateStock = Storage.Instance.drugList.ElementAt(id - 1).Stock - ElementsToDiscount;
                    Storage.Instance.drugList.ElementAt(id - 1).Stock = updateStock;

                    var drugExpended = new DrugOrderModel
                    {
                        Name    = collection["name"],
                        Address = collection["address"],
                        Nit     = collection["nit"],

                        Id          = Storage.Instance.drugList.ElementAt(id - 1).Id,
                        DrugName    = Storage.Instance.drugList.ElementAt(id - 1).DrugName,
                        Description = Storage.Instance.drugList.ElementAt(id - 1).Description,
                        Producer    = Storage.Instance.drugList.ElementAt(id - 1).Producer,
                        Price       = Storage.Instance.drugList.ElementAt(id - 1).Price,
                        Stock       = ElementsToDiscount,
                        Total       = Storage.Instance.drugList.ElementAt(id - 1).Price *ElementsToDiscount,
                    };

                    if (updateStock == 0)
                    {
                        DrugModel.Delete(Storage.Instance.drugList.ElementAt(id - 1).DrugName);
                    }

                    Storage.Instance.drugCartList.Add(drugExpended);



                    return(RedirectToAction("Cart"));
                }
                else
                {
                    return(View("ErrorMessage"));
                }

                //CALL HERE FUNCTION TO DELETE FROM TREE IF NO STOCK LEFT.
            }
            catch
            {
                return(View("ErrorMessage"));
            }
        }
        public DrugModel Create(DrugModel model)
        {
            var drug = new Drug
            {
                Name = model.Name,
                MedicinalSubstanceId = model.MedicinalSubstanceId,
                FormId = model.FormId
            };

            _drugsRepository.Create(drug);
            model.Id = drug.Id;

            return(model);
        }
 public ActionResult Delete(int id, DrugModel model)
 {
     try
     {
         var dbo = new DrugBusiness();
         dbo.PostDeleteMethod(id);
         TempData["msg"] = "Data has been Deleted";
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
        public ActionResult Update(int id, DrugModel model)
        {
            try
            {
                var dbo = new DrugBusiness();

                dbo.PostReviewMethod(model);
                TempData["msg"] = "Data has been successfully Updated";
                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
        public static void AddDrug(string drugName, GeneralUseModel generalPurpose)
        {
            DrugModel newDrug = new DrugModel();

            newDrug.DrugName    = drugName;
            newDrug.GeneralUse  = generalPurpose.GeneralUse;
            newDrug.DateAdded   = DateTime.Now;
            newDrug.LastUpdated = DateTime.Now;

            using (SQLite.SQLiteConnection connection = new SQLite.SQLiteConnection(drugDatabasePath))
            {
                connection.CreateTable <DrugModel>();
                connection.Insert(newDrug);
            }
        }
        public DrugModel GetDrugId(int?id)
        {
            //var dr=new DrugModel();
            DrugModel dr = new DrugModel();

            using (var drugr = new DrugRespo())
            {
                if (id != null)
                {
                    var _drug = drugr.GetById(id.Value);
                    // Drug _drug = drugr.GetById(id.Value);
                    dr.DrugId = _drug.DrugId;
                }

                return(dr);
            }
        }
        public ActionResult EditDrug(string id)
        {
            DrugModel dm = new DrugModel();
            Clinic_automation_systemEntities db = new Clinic_automation_systemEntities();
            int did     = Convert.ToInt32(id);
            var getdata = db.Drugs.Where(m => m.DrugId == did).FirstOrDefault();

            dm.DrugName        = getdata.DrugName;
            dm.ManufactureDate = getdata.ManufactureDate;
            dm.ExpiryDate      = getdata.ExpiryDate;
            dm.SideEffects     = getdata.SideEffects;
            dm.UsedFor         = getdata.UsedFor;
            dm.TotalQuantity   = getdata.TotalQuantityAvailable;
            dm.IsDeleted       = getdata.IsDeleted;
            dm.DrugId          = getdata.DrugId;
            return(View(dm));
        }
        private bool ReadFile(HttpPostedFileBase csvFile)
        {
            bool succeed = false;

            string path = string.Empty;

            if (csvFile != null)
            {
                if (".csv".Equals(Path.GetExtension(csvFile.FileName), StringComparison.OrdinalIgnoreCase))
                {
                    string fileName = Path.GetFileName(csvFile.FileName);
                    path = Path.Combine(Server.MapPath("~/App_Data/Files"), fileName);
                    csvFile.SaveAs(path);

                    string file = System.IO.File.ReadAllText(path);
                    foreach (string line in file.Split('\n'))
                    {
                        if (!string.IsNullOrEmpty(line))
                        {
                            string[] items = Regex.Split(line, ",(?=(?:[^\"]*\"[^\"]*\")*(?![^\"]*\"))");

                            try
                            {
                                DrugModel Drug = new DrugModel()
                                {
                                    Uid         = int.Parse(items[0]),
                                    Name        = items[1],
                                    Description = items[2],
                                    Producer    = items[3],
                                    Price       = float.Parse(items[4].Trim('$')),
                                    Stock       = int.Parse(items[5])
                                };
                                MyTree.Insert(Drug.Name, Drug);
                                succeed = true;
                            }
                            catch (Exception)
                            {
                                MyTree.WipeOut();
                                return(false);
                            }
                        }
                    }
                }
            }
            return(succeed);
        }
Exemple #25
0
        public ActionResult Index(FormCollection collection)
        {
            try
            {
                var drugName = collection["search"];

                Storage.Instance.drugOrderList.Clear();

                int            drugPosition = DrugModel.Search(drugName) - 1;
                DrugOrderModel drugFound    = Storage.Instance.drugList.ElementAt(drugPosition);
                Storage.Instance.drugOrderList.Add(drugFound);
                return(View(Storage.Instance.drugOrderList));
            }
            catch
            {
                return(View("ErrorMessage"));
            }
        }
Exemple #26
0
    public dotNetFlexGrid.DataHandlerResult FlexGridFlexGridDrugDataHandler(dotNetFlexGrid.DataHandlerParams p)
    {
        dotNetFlexGrid.DataHandlerResult result = new dotNetFlexGrid.DataHandlerResult();
        result.page  = p.page; //设定当前返回的页号
        result.total = 100;    //总计的数据条数,此处用100进行模拟,查询和筛选时需要根据实际
        DrugModel dm = new DrugModel();

        string pid = "";

        if (p.extParam.ContainsKey("pid"))
        {
            pid = p.extParam["pid"];
        }

        result.table = dm.findDrugByPspnum(pid);

        return(result);
    }
        public ActionResult ViewPatientOrders()
        {
            DrugModel dm = new DrugModel();
            Clinic_automation_systemEntities db = new Clinic_automation_systemEntities();
            var getdata = from d in db.Drugs
                          join o in db.PatientOrderDetails
                          on d.DrugId equals o.DrugId
                          join p in db.Patients
                          on o.PatientId equals p.PatientId
                          select new
            {
                d.DrugName,
                o.Quantity,
                p.FirstName,
                o.OrderDate,
                o.OrderStatus,
                o.OrderNumber,
                o.OrderId
            };
            List <DrugModel> dmlst = new List <DrugModel>();

            if (getdata != null)
            {
                foreach (var item in getdata)
                {
                    dmlst.Add(new DrugModel
                    {
                        DrugName      = item.DrugName,
                        OrderId       = item.OrderId,
                        Name          = item.FirstName,
                        OrderDate     = item.OrderDate,
                        OrderStatus   = item.OrderStatus,
                        OrderQuantity = item.Quantity,
                        OrderNumber   = item.OrderNumber
                    });
                }
                dm.DrugList = dmlst;
            }
            else
            {
                ViewBag.text = "No Orders Yet";
            }
            return(View(dm));
        }
Exemple #28
0
        public ActionResult OrderDrug(DrugModel dm)
        {
            Clinic_automation_systemEntities db = new Clinic_automation_systemEntities();
            var getqty             = db.Drugs.Where(m => m.DrugId == dm.DrugId).FirstOrDefault();
            int id                 = Convert.ToInt32(Session["MemberId"]);
            var getpid             = db.Patients.Where(m => m.MemberId == id).FirstOrDefault();
            int month              = DateTime.Now.Month;
            PatientOrderDetail obj = new PatientOrderDetail();

            if (dm.OrderQuantity < getqty.TotalQuantityAvailable)
            {
                obj.PatientId   = getpid.PatientId;
                obj.DrugId      = dm.DrugId;
                obj.OrderDate   = DateTime.Now;
                obj.Quantity    = dm.OrderQuantity;
                obj.OrderStatus = "Requested";
                db.PatientOrderDetails.Add(obj);
                getqty.TotalQuantityAvailable = getqty.TotalQuantityAvailable - dm.OrderQuantity;
                db.SaveChanges();
                ViewBag.text = "Order placed successfully";
            }
            else
            {
                ViewBag.text = "Order Quantity cannot exceed Total Quantity";
            }

            var getdata = db.Drugs.Where(m => m.IsDeleted == false).ToList();

            List <SelectListItem> lst = new List <SelectListItem>();

            if (getdata != null)
            {
                foreach (var item in getdata)
                {
                    lst.Add(new SelectListItem
                    {
                        Text  = item.DrugName,
                        Value = item.DrugId.ToString()
                    });
                }
                dm.DrugNameList = lst;
            }
            return(View(dm));
        }
        public static void AddPatientDrugModel(PatientModel patientModel, DrugModel drugModel, string desiredStrength)
        {
            // Explicitly setting the informationt that will be sent to the server
            PatientDrugModel patientDrugModel = new PatientDrugModel();

            patientDrugModel.DrugName           = drugModel.DrugName;
            patientDrugModel.GeneralPurpose     = drugModel.GeneralUse;
            patientDrugModel.DateAddedToProfile = DateTime.Now.ToString("MMMM dd, yyyy");
            patientDrugModel.LastUpdate         = DateTime.Now.ToString("MMMM dd, yyyyy");
            patientDrugModel.PatientId          = patientModel.Id;
            patientDrugModel.DrugStrength       = desiredStrength;


            using (SQLite.SQLiteConnection connection = new SQLite.SQLiteConnection(patientDrugModelDatabasePath))
            {
                connection.CreateTable <PatientDrugModel>();
                connection.Insert(patientDrugModel);
            }
        }
        public ActionResult Pre()
        {
            Storage.Instance.drugStatusList.Clear();
            string result = DrugModel.GetPreorder();
            //Add logic to write in txt here.
            string FilePath;
            string Path = Server.MapPath("~/Traversals/");

            if (!Directory.Exists(Path))
            {
                Directory.CreateDirectory(Path);
            }
            FilePath = Path + "Preorder.txt";
            System.IO.File.Create(FilePath).Close();
            using (var streamWriter = new StreamWriter(FilePath, false))
            {
                streamWriter.Write(result);
            }

            return(RedirectToAction("TreeStatus"));
        }