/// <summary>
        /// Edits the specified identifier.
        /// </summary>
        /// <param name="id">The identifier.</param>
        /// <returns>ActionResult.</returns>
        public ActionResult Edit(int id)
        {
            var model = new PatientViewModel();
            model.Countries = HealthHelper.GetAllCountries();
            if (id != -1)
            {
                var svc = new PatientAppService();
                var o = svc.GetPatient(id);

                model.PatientId = o.PatientId;
                model.FirstName = o.FirstName;
                model.FirstLastName = o.FirstLastName;
                model.Gender = o.Gender;
                model.BirthDate = o.BirthDate;
                model.Identification = o.Identification;
                model.IdentificationType = o.IdentificationType;
                model.Address = o.Address;
                model.Phone = o.Phone;
                model.Mobile = o.Mobile;
                model.SecondName = o.SecondName;
                model.SecondLastName = o.SecondLastName;
                model.EMail = o.EMail;
                model.GeoCityId = o.GeoCityId;
                model.BirthDateText= o.BirthDate.ToString("dd/MM/yyyy");
                model.GeoStateId = o.GeoCity.GeoStateId;
                model.GeoCountryId = o.GeoCity.GeoState.GeoCountryId;


            }
            else
            {
                model.Action = "-1";
                model.PatientId = -1;
                model.FirstName = string.Empty;
                model.FirstLastName = string.Empty;
                model.Gender = "M";
                model.BirthDate = DateTime.Now;
                model.Identification = string.Empty;
                model.IdentificationType = "-1";
                model.Address = string.Empty;
                model.Phone = string.Empty;
                model.Mobile = string.Empty;
                model.SecondName = string.Empty;
                model.SecondLastName = string.Empty;
                model.EMail = string.Empty;
                model.GeoCityId = "-1";
                model.BirthDateText = DateTime.Now.Date.ToString("dd/MM/yyyy");
                model.GeoStateId = "-1";
                model.GeoCountryId = "-1";


            }



            return View(model);
        }
        public ActionResult Index(long id)
        {
            var patient = new PatientAppService().GetPatient(id);
            if (patient != null)
            {
                Session["CurrentPatient"] = patient;
            }
            else
            {
                return RedirectToAction("Index", "Patient");
            }

            return View(patient);
        }
        public JsonResult AutoCompletePatient(string term) {
            var svc = new PatientAppService();
            var patients = svc.GetPatientByTerm(term);
            var result = new List<SearchPatientViewModel>();
            foreach (var p in patients){
                var s = new SearchPatientViewModel();
                s.PatientId = p.PatientId;
                var fullname = string.Format("{0} {1}-{2}", p.FirstLastName, p.FirstName, p.Identification);
                s.FullName = fullname;

                result.Add(s);
            }

            var res = this.Json(result, JsonRequestBehavior.AllowGet);
            return res;
        }
Example #4
0
       public Patient GetPatientById(long id)
       {
           var patient= new PatientAppService().GetPatient(id);
           return patient;

       }
Example #5
0
       public List<Patient> GetAllPatient()
       {
           var patients = new PatientAppService().GetAllPatient();
           return patients;

       }
        public DataTablesResult<PatientViewModel> GetAllRecords(DataTablesParam dataTableParam)
        {

            var svc = new PatientAppService();
            var lst = svc.GetAllPatient();
            var lstVm = new List<PatientViewModel>();
            foreach (var itm in lst)
            {

                var itmVm = new PatientViewModel
                {

                    PatientId = itm.PatientId,
                    FirstName = itm.FirstName,
                    FullName = itm.FirstLastName.ToUpper() + ", " + System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(itm.FirstName.ToLower()),
                    FirstLastName = itm.FirstLastName,
                    IdentificationText = itm.Identification + " (" + itm.IdentificationType + ")",
                    Gender = itm.Gender,
                    BirthDate = itm.BirthDate,
                    Age = DateTimeExtension.ToAgeString(itm.BirthDate),
                    Identification = itm.Identification,
                    IdentificationType = itm.IdentificationType,
                    Address = itm.Address,
                    Phone = itm.Phone,
                    Mobile = itm.Mobile,
                    SecondName = itm.SecondName,
                    SecondLastName = itm.SecondLastName,
                    EMail = itm.EMail,
                    GeoCityId = itm.GeoCityId,


                };






                var sb = new StringBuilder();

                string editUrl = Url.Action("Edit", "Patient");
                string subscriptionUrl = Url.Action("Index", "Subscription");
                sb.AppendLine("<div class=\"btn-group\">");
                sb.AppendLine(
                    "<button type=\"button\" class=\"btn btn-default dropdown-toggle\" data-toggle=\"dropdown\" aria-expanded=\"false\">");
                sb.AppendLine("Acciones <span class=\"caret\"></span>");
                sb.AppendLine("</button>");
                sb.AppendLine("<ul class=\"dropdown-menu\" role=\"menu\">");
                sb.AppendLine("<li><a href=\"" + editUrl + "?id=-1\"><i class=\"fa fa-plus\"></i>&nbsp;Nuevo Registro</a></li>");
                sb.AppendLine("<li><a href=\"" + editUrl + "?id=" + itmVm.PatientId + "\"><i class=\"fa fa-edit\"></i>&nbsp;Editar " + itmVm.FullName + "</a></li>");
                sb.AppendLine("<li><a href=\"" + subscriptionUrl + "?id=" + itmVm.PatientId + "\"><i class=\"fa fa-edit\"></i>&nbsp;SubscripciĆ³n " + itmVm.FullName + "</a></li>");
                sb.AppendLine("</ul>");
                sb.AppendLine("</div>");






                var actionButton = sb.ToString();

                itmVm.ActionButton = actionButton;
                lstVm.Add(itmVm);

            }

            var lstVmQueryable = lstVm.AsQueryable();


            return DataTablesResult.Create(lstVmQueryable, dataTableParam);

        }
        public ActionResult Edit(PatientViewModel model)
        {

            model.Countries = HealthHelper.GetAllCountries();

            try
            {
                var svc = new PatientAppService();

                var o = new Patient
                {
                    PatientId = model.PatientId,
                    FirstName = model.FirstName,
                    FirstLastName = model.FirstLastName,
                    Gender = model.Gender,
                    BirthDate  = DateTime.ParseExact(model.BirthDateText, "dd/MM/yyyy", CultureInfo.InvariantCulture),
                    Identification = model.Identification,
                    IdentificationType = model.IdentificationType,
                    Address = model.Address,
                    Phone = model.Phone,
                    Mobile = model.Mobile,
                    SecondName = model.SecondName,
                    SecondLastName = model.SecondLastName,
                    EMail = model.EMail,
                    GeoCityId = model.GeoCityId

                };

                if (model.Action == "-1")
                {
                    var exist = svc.GetPatient(model.PatientId) != null;
                    if (!exist)
                    {
                        svc.AddPatient(o);
                        ViewBag.Feed = 0;
                    }
                    else
                    {
                        model.Action = "-1";
                        ViewBag.Feed = 3;
                        return View(model);
                    }
                }
                else
                {
                    o.PatientId = model.PatientId;
                    if (model.IsDeleteAction == 0)
                    {

                        svc.SavePatient(o);
                    }
                    else
                    {
                        svc.RemovePatient(model.PatientId);
                    }
                    ViewBag.Feed = 0;
                }
            }
            catch (Exception)
            {
                ViewBag.Feed = 1;

            }

            return View(model);
        }