public PrescriptionViewModel(Prescription p) { IBL bl = new BLImplement(); this.Id = p.Id; this.medicine = bl.getMedicine(p.medicine).Name; this.StartDate = p.StartDate; this.EndDate = p.EndDate; this.Doctor = bl.getDoctor(p.Doctor).Name; this.Patient = bl.getPatient(p.Patient).Name; this.Cause = p.Cause; }
public ActionResult DeleteConfirmed(string id) { try { IBL bl = new BLImplement(); Patient patient = bl.getPatient(id); bl.deletePatient(patient); ViewBag.Message = String.Format("The patient {0} is successfully delete.", patient.Name); return(RedirectToAction("Index")); } catch (Exception ex) { ViewBag.Message = String.Format(ex.Message); return(RedirectToAction("Index")); } }
// GET: Patient/Details/5 public ActionResult Details(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } IBL bl = new BLImplement(); Patient patient = bl.getPatient(id); PatientViewModel patientViewModel = new PatientViewModel(patient); if (patient == null) { return(HttpNotFound()); } return(View(patientViewModel)); }
// GET: Prescription public ActionResult Index(string id)//IEnumerable<Prescription> prescriptions) { IBL bl = new BLImplement(); var patient = bl.getPatient(id); if (patient == null) { patient = bl.getAllPatients().FirstOrDefault(X => X.Name == id);//when return to list } var prescriptions = bl.allPrescriptionFromPatient(patient); if (prescriptions == null) { ViewBag.Message = String.Format("There are no prescription for {0} yet", patient.Name); return(RedirectToAction("DoctorOptions")); } var lst = new List <PrescriptionViewModel>(); foreach (var item in prescriptions) { lst.Add(new PrescriptionViewModel(item)); } return(View(lst)); }
public ActionResult prescriptionIssuance(FormCollection collection)///*string medicine*/, DateTime StartDate, DateTime EndDate, string Doctor, string Patient, string Cause) { try { IBL bl = new BLImplement(); Prescription prescription = new Prescription() { medicine = bl.getAllMedicines().FirstOrDefault(x => x.Name == collection["medicine"]).Id,//change the name to the id StartDate = Convert.ToDateTime(collection["StartDate"]), EndDate = Convert.ToDateTime(collection["EndDate"]), Doctor = collection["Doctor"], Patient = collection["Patient"], Cause = collection["prescription.Cause"] }; bl.addPrescription(prescription); ViewBag.Message = String.Format("The prescription for {0} is successfully added. You can watch {1}'s medical history for full details. ", collection["medicine"].ToString(), bl.getPatient(prescription.Patient).Name.ToString()); return(RedirectToAction("DoctorOptions" /*, prescription.Doctor*/)); } catch (Exception ex) { ViewBag.Message = String.Format(ex.Message); return(RedirectToAction("prescriptionIssuance")); } }