public async Task <ActionResult> EditMedication(PatientMedicalHistory_MedicationRx medicationRx)
        {
            if (HelperExtensions.isAllowedforEditingorAdd(medicationRx.PatientId, CategoryCycleStatusHelper.GetPatientNewOrOldCycleByCategory(medicationRx.PatientId, BillingCodeHelper.cmmBillingCatagoryid), User.Identity.GetUserId()) == false)
            {
                return(RedirectToAction("Index", "CcmStatus", new { status = HelperExtensions.GetStatusRedirectionbyUser(User.Identity.GetUserId()), Message = "Cycle is locked." }));
            }
            var patient = _db.Patients.Find(medicationRx.PatientId);

            if (patient != null && ModelState.IsValid)
            {
                patient.UpdatedBy = User.Identity.GetUserId();
                patient.UpdatedOn = DateTime.Now;

                _db.Entry(medicationRx).State = EntityState.Modified;

                await _db.SaveChangesAsync();
            }

            ViewBag.PatientName = patient?.FirstName + " " + patient?.LastName;
            ViewBag.PatientId   = patient?.Id;
            ViewBag.CcmStatus   = patient?.CcmStatus;
            ViewBag.CurrentPage = "Medical History";

            return(RedirectToAction("Patient", "CurrentMedication", new { patientId = medicationRx.PatientId }));
        }
        public async Task <string> _EditMedication(PatientMedicalHistory_MedicationRx medicationRx)
        {
            if (HelperExtensions.isAllowedforEditingorAdd(medicationRx.PatientId, CategoryCycleStatusHelper.GetPatientNewOrOldCycleByCategory(medicationRx.PatientId, BillingCodeHelper.cmmBillingCatagoryid), User.Identity.GetUserId()) == false)
            {
                //return RedirectToAction("Index", "CcmStatus", new { status = HelperExtensions.GetStatusRedirectionbyUser(User.Identity.GetUserId()), Message = "Cycle is locked." });
                return("Cycle is locked.");
            }
            var patient = _db.Patients.Find(medicationRx.PatientId);

            if (patient != null && ModelState.IsValid)
            {
                patient.UpdatedBy = User.Identity.GetUserId();
                patient.UpdatedOn = DateTime.Now;

                _db.Entry(medicationRx).State = EntityState.Modified;

                await _db.SaveChangesAsync();

                return("True");
            }
            else
            {
                var errorList = ModelState.Values.SelectMany(m => m.Errors)
                                .Select(e => e.ErrorMessage)
                                .ToList();
                var errorstr = string.Join(",", errorList);
                return(errorstr);
            }
            ViewBag.PatientName = patient?.FirstName + " " + patient?.LastName;
            ViewBag.PatientId   = patient?.Id;
            ViewBag.CcmStatus   = patient?.CcmStatus;
            ViewBag.CurrentPage = "Medical History";

            //return RedirectToAction("Patient", "CurrentMedication", new { patientId = medicationRx.PatientId });
        }
        public PartialViewResult _EditMedicationPartial(int medicationId)
        {
            var physicians = _db.Physicians.Select(p => new SelectListItem {
                Value = p.Id.ToString(), Text = p.FirstName + " " + p.LastName
            });

            ViewBag.Physicians          = new SelectList(physicians.OrderBy(p => p.Text).ToList(), "Text", "Text");//, patient.PhysicianId
            ViewBag.MedicineRepitinDose = new SelectList(_db.MedicationDoseRepetitionTimes.ToList(), "Id", "DoseRepetitionTime");
            ViewBag.MedicationRoute     = new SelectList(_db.MedicationRoutes.ToList(), "RouteItme", "RouteItme");

            PatientMedicalHistory_MedicationRx model = _db.PatientMedicalHistory_MedicationRxes.Where(m => m.Id == medicationId).First();


            //PatientMedicalHistory_MedicationRx model = new PatientMedicalHistory_MedicationRx();
            //model.DrugName = model1.DrugName;
            //model.DailyDose = model1.DailyDose;
            //model.RxCuis = model1.RxCuis;
            //model.RateQuantity = model1.RateQuantity;
            //model.Route = model1.Route;
            //model.UseReason = model1.UseReason;
            //model.StartDate = model1.StartDate;
            //model.DoseRepetitionTime = model1.DoseRepetitionTime;
            //model.IssuesIdentified = model1.IssuesIdentified;
            //model.PrescribeBy = model1.PrescribeBy;
            //model.Comments = model1.Comments;
            //model.ForHowLong = model1.ForHowLong;
            //model.IsTakenMedicineProperly = model1.IsTakenMedicineProperly;
            //model.TakenMedicineProperly = model1.TakenMedicineProperly;
            return(PartialView(model));
        }