public async Task <ActionResult> Create(PatientMedicalHistory_Allergy allergy) { if (HelperExtensions.isAllowedforEditingorAdd(allergy.PatientId, CategoryCycleStatusHelper.GetPatientNewOrOldCycleByCategory(allergy.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(allergy.PatientId); if (patient != null && ModelState.IsValid) { if (patient.AllergyId != null) { _db.Entry(allergy).State = EntityState.Modified; } else { _db.PatientMedicalHistory_Allergies.Add(allergy); await _db.SaveChangesAsync(); patient.AllergyId = allergy.Id; } patient.UpdatedBy = User.Identity.GetUserId(); patient.UpdatedOn = DateTime.Now; _db.Entry(patient).State = EntityState.Modified; await _db.SaveChangesAsync(); return(RedirectToAction("Patient", "CurrentMedication", new { patientId = patient.Id })); } ViewBag.PatientName = patient?.FirstName + " " + patient?.LastName; ViewBag.PatientId = patient?.Id; ViewBag.CcmStatus = patient?.CcmStatus; return(View(allergy)); }
public async Task <string> _Create(PatientMedicalHistory_Allergy allergy) { if (HelperExtensions.isAllowedforEditingorAdd(allergy.PatientId, CategoryCycleStatusHelper.GetPatientNewOrOldCycleByCategory(allergy.PatientId, BillingCodeHelper.cmmBillingCatagoryid), User.Identity.GetUserId()) == false) { return("Cycle is locked."); } var patient = _db.Patients.Find(allergy.PatientId); if (patient != null && ModelState.IsValid) { if (patient.AllergyId != null) { _db.Entry(allergy).State = EntityState.Modified; } else { _db.PatientMedicalHistory_Allergies.Add(allergy); await _db.SaveChangesAsync(); patient.AllergyId = allergy.Id; } patient.UpdatedBy = User.Identity.GetUserId(); patient.UpdatedOn = DateTime.Now; _db.Entry(patient).State = EntityState.Modified; await _db.SaveChangesAsync(); return("True"); } ViewBag.PatientName = patient?.FirstName + " " + patient?.LastName; ViewBag.PatientId = patient?.Id; ViewBag.CcmStatus = patient?.CcmStatus; return("False"); }