Esempio n. 1
0
        public ActionResult AddDisease(HttpPostedFileBase filename, DiseaseViewModel model)
        {
            if (ModelState.IsValid)
            {
                //var result = db.TBL_DISEASE.Create(model)
                TBL_DISEASE mdl = new TBL_DISEASE();
                mdl.DISEASE_ID   = db.TBL_DISEASE.Add(mdl).DISEASE_ID;
                mdl.DISEASE_NAME = model.DISEASE_NAME;
                mdl.SYMPTOMS     = model.SYMPTOMS;
                mdl.CATEGORY     = model.CATEGORY;
                mdl.TREATMENT    = model.TREATMENT;
                //db.TBL_DISEASE.Add(mdl);

                //db.SaveChanges();
                if (db.SaveChanges() > 0)
                {
                    TBL_DISEASE_DETAILS dtl = new TBL_DISEASE_DETAILS();
                    dtl.DETAIL_ID           = db.TBL_DISEASE_DETAILS.Add(dtl).DISEASE_ID;
                    dtl.DISEASE_ID          = mdl.DISEASE_ID;
                    dtl.DISEASE_DESCRIPTION = model.DISEASE_Description;
                    dtl.TREATMENT           = model.TREATMENT_DETAILS;
                    dtl.SUGGESTION          = model.SUGGESTION;
                    if (filename != null)
                    {
                        string pic  = System.IO.Path.GetExtension(filename.FileName);
                        string name = Guid.NewGuid().ToString() + pic;
                        string path = System.IO.Path.Combine(
                            Server.MapPath("~/Contents/upload/Disease"), name);
                        // file is uploaded
                        filename.SaveAs(path);
                        dtl.IMAGE = name;
                    }
                    //db.TBL_DISEASE_DETAILS.Add(dtl);
                    //dtl.TREATMENT = model.TREATMENT;
                    db.SaveChanges();
                }


                if (mdl.DISEASE_ID > 0)
                {
                    return(Json(new { successMessage = "Successfully Registered!" }));
                }
                else
                {
                    Response.StatusCode = (int)HttpStatusCode.SeeOther;
                    return(Json(new { errorMessage = "Something went wrong!" }));
                }
            }
            else
            {
                return(PartialView(model));
            }
        }
Esempio n. 2
0
        public ActionResult DiseasePredict(string symp)
        {
            List <string> termsList = new List <string>();
            List <string> templist  = symp.Split(',').ToList();

            foreach (var v in templist)
            {
                termsList.Add(v);
            }
            List <TBL_DISEASE> result = new List <TBL_DISEASE>();

            foreach (var item in termsList)
            {
                List <TBL_DISEASE> tbl = db.TBL_DISEASE.Where(c => c.SYMPTOMS.Contains(item)).ToList();

                foreach (TBL_DISEASE pak in tbl)
                {
                    result.Add(pak);
                }
            }
            var groups = result;

            List <DiseaseCount> final = new List <DiseaseCount>();
            List <TBL_DISEASE>  temp  = new List <TBL_DISEASE>();

            foreach (var item in result)
            {
                DiseaseCount mdl = new DiseaseCount();
                mdl.disease = item;
                var itemm = final.Where(x => x.disease.Equals(item)).ToList();
                if (itemm.Count > 0)
                {
                    foreach (var num in itemm)
                    {
                        mdl.count = num.count;
                    }
                    mdl.count = mdl.count + 1;
                    final.Add(mdl);
                }

                else
                {
                    final.Add(mdl);
                }
            }

            var data = final.OrderByDescending(x => x.count).Distinct().ToList();
            List <DiseaseCount> temptext  = new List <DiseaseCount>();
            List <DiseaseCount> finaltext = new List <DiseaseCount>();

            foreach (var text in data)
            {
                temptext.Add(text);
                var check = temptext.Where(x => x.disease == text.disease).ToList();
                if (check.Count > 1)
                {
                }
                else
                {
                    finaltext.Add(text);
                }
            }

            List <TBL_DISEASE> list = new List <TBL_DISEASE>();

            foreach (var item in finaltext)
            {
                TBL_DISEASE doc = new TBL_DISEASE();

                doc.DISEASE_ID = item.disease.DISEASE_ID;

                doc.DISEASE_NAME = item.disease.DISEASE_NAME;
                if (item.count >= 4)
                {
                    item.match = "Strong Match";
                }
                else if (item.count == 3)
                {
                    item.match = "Moderate Match";
                }
                else if (item.count <= 2)
                {
                    item.match = "Fair Match";
                }
                else
                {
                    item.match = "Low Match";
                }
                doc.CATEGORY = item.match;


                list.Add(doc);
            }
            ViewBag.data = list;
            return(PartialView());
        }