public ActionResult PatientRegistration(Patient model, string command, HttpPostedFileBase Files)
        {
            ArogyaParivarEntities context = new ArogyaParivarEntities();
            try
            {
                try
                {



                    ObjectParameter outParm = new ObjectParameter("callid", typeof(string));

                    context.SP_TokenGenration(outParm);

                    int tokennumber = Convert.ToInt32(outParm.Value);

                    ObjectParameter outParm1 = new ObjectParameter("callid", typeof(string));

                    context.SP_GenarateArogyaID(outParm1);

                    int intarogyaID = Convert.ToInt32(outParm1.Value);
                    string arogyaID = "A" + intarogyaID;
                    var webCamePath = ConfigurationSettings.AppSettings["WebCampath"];
                
                    if (command.Equals("Reset"))
                    {
                        return RedirectToAction("PatientRegistration");
                    }
                    else
                    {
                        var fileName = "";
                        if (Request.Files.Count > 0 && Request.Files[0].ContentLength > 0)
                        {
                            var file = Request.Files[0];

                            if (file != null && file.ContentLength > 0)
                            {
                                fileName = Path.GetFileName(file.FileName);
                                var path = Path.Combine(Server.MapPath(ConfigurationSettings.AppSettings["DocumentUploadPath"]), fileName);
                                file.SaveAs(path);
                            }

                            T_RegUpload upload = new T_RegUpload()
                            {
                                Active = true,
                                ArogyaID = arogyaID,
                                CreateDate = DateTime.Now,
                                FileName = fileName,
                                UserID = Convert.ToInt32(Session["UserID"])
                            };
                            context.T_RegUpload.Add(upload);
                            context.SaveChanges();
                        }
                      

                        PatientModel book = new PatientModel()
                        {

                            PatientName = model.PatientName,
                            ArogyaID = arogyaID,
                            Surname = model.Surname,
                            Age = model.Age,
                            AgeType = model.Cal,
                            Gender = model.Gender,
                            AadharID = model.AadharID,
                            Address = model.Address,
                            ContactNo = model.ContactNo,
                            Village = Convert.ToInt64(Request.Form["Village"]),
                            Town = Request.Form["Mandal"].ToString(),
                            RefBy = Convert.ToInt32(Request.Form["RefBy"]),
                            RefName = model.RefName,
                            Consent = true,
                            District = Convert.ToInt32(Request.Form["city"].ToString()),
                            Sate = model.Sate,

                        };

                        T_Token tokn = new T_Token()
                        {
                            ArogyaID = arogyaID,
                            Token_Number = tokennumber,
                            Tokem_Date = DateTime.Now
                        };

                        context.T_Token.Add(tokn);
                        context.SaveChanges();
                        patientBll.Save(book);
                        return RedirectToAction("PrintCard", new { ArogyaID = arogyaID });
                 
                    }
                }
                catch
                {
                    return View(model);
                }


            }
            catch
            {
                return View(model);
            }
        }