public JsonResult GetAllPatient(string date) { List <AppointmentView> pt = new List <AppointmentView>(); int doc = Convert.ToInt32(Session["DoctorId"]); using (var ctx = new MedicalContext()) { var data = from a in ctx.Appointment join p in ctx.Registers on a.PatientId equals p.Id where a.DoctorId == doc && a.Date == date select new { pappointmentId = a.Id, patientName = p.Name, patientAge = p.Age, }; foreach (var dc in data) { AppointmentView p = new AppointmentView(); p.AppointmentId = dc.pappointmentId; p.PatientName = privacy.Decrypt(dc.patientName); p.Age = dc.patientAge; pt.Add(p); } } return(Json(pt)); }
public JsonResult GetAllAdmitPatientByWard(int id) { List <Prescription> prescriptions = new List <Prescription>(); using (var db = new MedicalContext()) { var info = from a in db.Appointment join p in db.Registers on a.PatientId equals p.Id join d in db.Doctors on a.DoctorId equals d.Id where a.WardId == id select new { appointmentId = a.Id, PatientName = p.Name, PatientAge = p.Age, patientAddress = p.Address, DoctorName = d.Name, }; foreach (var k in info) { Prescription pres = new Prescription(); pres.Id = k.appointmentId; pres.PatientName = privacy.Decrypt(k.PatientName); pres.PatientAge = k.PatientAge; pres.PatientAddress = privacy.Decrypt(k.patientAddress); pres.DoctorName = privacy.Decrypt(k.DoctorName); prescriptions.Add(pres); } } return(Json(prescriptions)); }
//[HttpPost] public ViewResult ProductsPost(int id) { Order OrderForUser = null; int userID = 0; MedicalContext db = new MedicalContext(); foreach (var item in db.Users) { if (item.Login == User.Identity.Name) { userID = item.Id; } } foreach (var item in db.Orders) { if (item.UserId == userID) { OrderForUser = item; } } if (User.Identity.IsAuthenticated && OrderForUser == null) { var firstOrder = new Order { UserId = userID }; db.Orders.Add(firstOrder); Session["Order"] = firstOrder; db.SaveChanges(); } Session["Order"] = OrderForUser; HomeServices.PostProduct(id, OrderForUser); return(View("~/Views/Home/Products.cshtml")); }
public ActionResult Log_in(LoginModel model) { //bool check = false; //HomeServices hs = new HomeServices(); //model = hs.Login(model, check); //if (check) RedirectToAction("Contacts", "Home"); if (ModelState.IsValid) { User user = null; using (MedicalContext db = new MedicalContext()) { user = db.Users.FirstOrDefault(u => u.Login == model.Name && u.Password == model.Password); } if (user != null) { Order order = null; int userID = 0; MedicalContext db = new MedicalContext(); foreach (var item in db.Users) { if (item.Login == model.Name) { userID = item.Id; } } foreach (var item in db.Orders) { if (item.UserId == userID) { order = item; } } if (order == null) { order = new Order { Id = db.Orders.Max(p => p.Id) + 1, UserId = userID }; Session["Order"] = order; db.Orders.Add(order); } else { Session["Order"] = order; } db.SaveChanges(); FormsAuthentication.SetAuthCookie(model.Name, true); return(RedirectToAction("Main", "Home")); } else { ModelState.AddModelError("", "Пользователя с таким логином и паролем нет"); } } return(View(model)); }
static public InvoiceTemplate ReadCurrentTemplate(int sourceId) { using (var context = new MedicalContext()) return(context.InvoiceMemberships .Where(m => m.SourceId == sourceId) .Where(m => m.EndDate == null) .Select(m => m.InvoiceTemplate) .FirstOrDefault()); }
public JsonResult AssignIntoWard(int nurseId, int wardId) { using (var db = new MedicalContext()) { Nurse nurse = db.Nurses.Find(nurseId); nurse.Wardassign = wardId; db.SaveChanges(); } return(Json(1)); }
public JsonResult ReleasePatientFromWards(int id, int wardId) { using (var db = new MedicalContext()) { PatientAppointmentModel appoint = db.Appointment.Find(id); appoint.WardId = 0; db.SaveChanges(); } return(Json(1)); }
public JsonResult ReleaseNurseFromWard(int id) { using (var db = new MedicalContext()) { Nurse n = db.Nurses.Find(id); n.Wardassign = 0; db.SaveChanges(); } return(Json(1)); }
// // GET: /Medical/ public ActionResult Index() { ViewBag.Index = "active"; List <Services> services; using (var ctx = new MedicalContext()) { services = ctx.AllServices.ToList(); } return(View(services)); }
private static void BindSessionToken(string token, MedicalContext dbContextNet) { // dbContextNet.Database.ExecuteSqlCommand($"EXEC sp_bindsession '{token}'"); var command = dbContextNet.Database.Connection.CreateCommand(); command.CommandText = $"EXEC sp_bindsession '{token}'"; dbContextNet.Database.Connection.Open(); var result = command.ExecuteNonQuery(); dbContextNet.Database.Connection.Close(); }
public ActionResult Prescription(Prescription prescription, int AppointmentId) { prescription.DocId = Convert.ToInt32(Session["DoctorId"]); ViewBag.Prescription = "active"; string searchdate = DateTime.Now.ToString("MM/dd/yyyy"); string pdfname; pdfname = DateTime.Now.ToString("dd-MM-yyyy") + "_" + Guid.NewGuid() + ".pdf"; using (var db = new MedicalContext()) { if (prescription.WardId > 0) { PatientAppointmentModel appointment = db.Appointment.Find(AppointmentId); appointment.WardId = prescription.WardId; db.SaveChanges(); } var presdoc = from ap in db.Appointment join p in db.Registers on ap.PatientId equals p.Id join d in db.Doctors on ap.DoctorId equals d.Id where ap.Id == AppointmentId select new { PatientName = p.Name, PatientAge = p.Age }; foreach (var v in presdoc) { prescription.PatientName = privacy.Decrypt(v.PatientName); prescription.PatientAge = v.PatientAge; } PatientAppointmentModel app = db.Appointment.Single(c => c.Id == AppointmentId && c.DoctorId == prescription.DocId && c.Date == searchdate); app.Prescription = "Prescriptions/" + pdfname; db.SaveChanges(); } var printpdf = new ActionAsPdf("MakePdf", prescription) { FileName = pdfname }; string path = Server.MapPath("~/Prescriptions"); string a = Path.Combine(path, pdfname); var byteArray = printpdf.BuildPdf(ControllerContext); var fileStream = new FileStream(a, FileMode.Create, FileAccess.Write); fileStream.Write(byteArray, 0, byteArray.Length); fileStream.Close(); return(printpdf); }
public ActionResult TestForm(TestForm testForm) { ViewBag.TestForm = "active"; testForm.PatientId = Convert.ToInt32(Session["PatientId"]); using (var db = new MedicalContext()) { db.TestForms.Add(testForm); db.SaveChanges(); } ViewBag.Yes = '1'; return(View()); }
public void Sync() { MedicalContext clientRepo = new MedicalContext(); Medical2Context serverRepo = new Medical2Context(); List <Medicine> clientsMedicines = clientRepo.Medicines.OrderBy(x => x.Id).ToList(); List <Medicine> serverMedicines = serverRepo.Medicines.OrderBy(x => x.Id).ToList(); foreach (Medicine org in clientsMedicines) { bool isExist = false; foreach (Medicine target in serverMedicines) { if (org.Id != target.Id) { continue; } isExist = true; update(org, target); Console.WriteLine("Update: " + org.Id); } if (isExist) { continue; } clientRepo.Medicines.Remove(org); Console.WriteLine("Delete: " + org.Id); } foreach (Medicine target in serverMedicines) { bool isExist = false; foreach (Medicine org in clientsMedicines) { if (org.Id != target.Id) { continue; } isExist = true; } if (isExist) { continue; } Medicine news = clone(target); clientRepo.Medicines.Add(news); Console.WriteLine("Add: " + target.Id); } clientRepo.SaveChanges(); }
public ActionResult Prescription() { ViewBag.Prescription = "active"; List <Ward> wards = new List <Ward>(); using (var db = new MedicalContext()) { wards = db.Wards.ToList(); } ViewBag.Wards = wards; return(View()); }
public ActionResult PatientRealeseFromWard() { ViewBag.PatientRealeseFromWard = "active"; List <Ward> wards = new List <Ward>(); using (var db = new MedicalContext()) { wards = db.Wards.ToList(); } ViewBag.Wards = wards; return(View()); }
public ActionResult DoctorAppointment() { List <SpecialistModel> specialists; using (var db = new MedicalContext()) { specialists = db.Specialist.ToList(); } ViewBag.Category = specialists; return(View()); }
public void Setup() { /*var optionsInDb = new DbContextOptionsBuilder<MedicalContext>() * .UseSqlServer("Server=DESKTOP-N95GP02\\SQLEXPRESS;Database=MedicalServices;Trusted_Connection=True;MultipleActiveResultSets=true") * .Options; * * _context = new MedicalContext(optionsInDb);*/ var optionsInMemory = new DbContextOptionsBuilder <MedicalContext>().UseInMemoryDatabase("MedicalServices") .Options; _context = new MedicalContext(optionsInMemory); _context.Database.EnsureDeleted(); }
public JsonResult GetAllNurseByWard(int id) { List <Nurse> nurses = new List <Nurse>(); using (var db = new MedicalContext()) { nurses = db.Nurses.Where(c => c.Wardassign == id).ToList(); } foreach (Nurse a in nurses) { a.Name = privacy.Decrypt(a.Name); a.Designation = privacy.Decrypt(a.Designation); } return(Json(nurses)); }
public ActionResult DoctorInfo() { ViewBag.Doctor = "active"; List <SpecialistModel> doctorCategories; using (var ctx = new MedicalContext()) { doctorCategories = ctx.Specialist.ToList(); } ViewBag.Category = doctorCategories; return(View()); }
public ActionResult BloodDonorRegistration(BloodDonorModel bloodDonor) { ViewBag.Donor = "active"; List <BloodModel> bloodCategories; using (var ctx = new MedicalContext()) { ctx.BloodDonor.Add(bloodDonor); ctx.SaveChanges(); bloodCategories = ctx.Blood.ToList(); } ViewBag.Category = bloodCategories; return(View()); }
public ActionResult BloodDonorList() { ViewBag.Donor = "active"; List <BloodModel> bloodCategories; using (var ctx = new MedicalContext()) { bloodCategories = ctx.Blood.ToList(); } ViewBag.Category = bloodCategories; return(View()); }
public ActionResult Information() { ViewBag.Information = "active"; int id = Convert.ToInt32(Session["PatientId"]); List <DoctorAppointmentView> appointmentList = new List <DoctorAppointmentView>(); using (var db = new MedicalContext()) { List <PatientAppointmentModel> lappoint = (from a in db.Appointment where a.PatientId == id && a.Accepted == 3 select a).ToList(); foreach (PatientAppointmentModel p in lappoint) { p.Accepted = 1; } db.SaveChanges(); Session["PatientNotification"] = 0; var q = (from ab in db.Doctors join p in db.Specialist on ab.SpecialistId equals p.Id join a in db.Appointment on ab.Id equals a.DoctorId where a.DoctorId == ab.Id && a.PatientId == id select new { appointmentDate = a.Date, appointmentName = ab.Name, appointmentSpecialist = p.Specialist, appointmentPrescription = a.Prescription }); foreach (var d in q) { DoctorAppointmentView ap = new DoctorAppointmentView(); ap.DoctorName = privacy.Decrypt(d.appointmentName); ap.Date = d.appointmentDate; ap.Specialist = d.appointmentSpecialist; ap.Prescription = d.appointmentPrescription; appointmentList.Add(ap); } } return(View(appointmentList)); }
public ActionResult BloodDonorRegistration() { ViewBag.Donor = "active"; if (Session["PatientId"] == null) { return(RedirectToAction("LogIn", "Security")); } List <BloodModel> bloodCategories; using (var ctx = new MedicalContext()) { bloodCategories = ctx.Blood.ToList(); } ViewBag.Category = bloodCategories; return(View()); }
public ActionResult PatientHistory(int id) { List <PatientAppointmentModel> appointmentlist = new List <PatientAppointmentModel>(); using (var db = new MedicalContext()) { int s = db.Appointment.Where(c => c.Id == id).Select(c => c.PatientId).FirstOrDefault(); var data = db.Appointment.Where(c => c.PatientId == s).Select(c => new { c.Prescription, c.Date }); foreach (var d in data) { PatientAppointmentModel appoint = new PatientAppointmentModel(); appoint.Prescription = d.Prescription; appoint.Date = d.Date; appointmentlist.Add(appoint); } } return(View(appointmentlist)); }
public ActionResult Appointment() { if (Session["PatientId"] == null) { return(RedirectToAction("LogIn", "Security")); } ViewBag.Appoint = "active"; List <SpecialistModel> specialists; using (var ctx = new MedicalContext()) { specialists = ctx.Specialist.ToList(); } ViewBag.Category = specialists; return(View()); }
public ActionResult MakePdf(Prescription prescription) { DoctorView doctor = new DoctorView(); //string email = privacy.Encrypt(prescription.PatientEmail); using (var db = new MedicalContext()) { var q = (from a in db.Doctors join p in db.Specialist on a.SpecialistId equals p.Id where a.Id == prescription.DocId select new { dId = a.Id, dName = a.Name, dQualification = a.Degree, dspecialist = p.Specialist }); foreach (var j in q) { doctor.DocName = privacy.Decrypt(j.dName); doctor.DocSpecialist = j.dspecialist; doctor.DocDegree = privacy.Decrypt(j.dQualification); } //var kl = from b in db.Registers // where b.Email == email // select new // { // PatientName = b.Name, // PatientAge = b.Age // }; //foreach (var k in kl) //{ // prescription.PatientName = privacy.Decrypt(k.PatientName); // prescription.PatientAge = k.PatientAge; //} ViewBag.Doctor = doctor; return(View(prescription)); } }
public ActionResult ReceptionistProfileUpdate() { ViewBag.ReceptionistProfileUpdate = "active"; Receptionist receptionist = new Receptionist(); int receptionistid = Convert.ToInt32(Session["ReceptionistId"]); using (var db = new MedicalContext()) { var q = db.Receptionist.Where(k => k.Id == receptionistid).Select(c => new { c.Name, c.Address, c.PhoneNo }); foreach (var j in q) { receptionist.Name = privacy.Decrypt(j.Name); receptionist.Address = privacy.Decrypt(j.Address); receptionist.PhoneNo = privacy.Decrypt(j.PhoneNo); } ViewBag.Receptionist = receptionist; return(View()); } }
public JsonResult GetAllDoctorInfoById(int id) { List <DoctorDetailsModel> doctor = new List <DoctorDetailsModel>(); using (var ctx = new MedicalContext()) { var a = ctx.Doctors.Where(s => s.SpecialistId == id).Select(c => new { c.Name, c.Degree, c.Fees, c.Schedule });; foreach (var k in a) { DoctorDetailsModel doc = new DoctorDetailsModel(); doc.Name = privacy.Decrypt(k.Name); doc.Degree = privacy.Decrypt(k.Degree); doc.Fees = k.Fees; doc.Schedule = privacy.Decrypt(k.Schedule); doctor.Add(doc); } } return(Json(doctor)); }
public ActionResult DoctorProfileUpdate() { ViewBag.DoctorProfileUpdate = "active"; DoctorDetailsModel doctor = new DoctorDetailsModel(); int doctorid = Convert.ToInt32(Session["DoctorId"]); using (var db = new MedicalContext()) { var q = db.Doctors.Where(k => k.Id == doctorid).Select(c => new { c.Name, c.Degree, c.Fees }); foreach (var j in q) { doctor.Name = privacy.Decrypt(j.Name); doctor.Degree = privacy.Decrypt(j.Degree); doctor.Fees = j.Fees; } ViewBag.Doctor = doctor; return(View()); } }
public JsonResult GetAllDonorInfoById(int id) { List <BloodDonorModel> donor = new List <BloodDonorModel>(); using (var ctx = new MedicalContext()) { var a = ctx.BloodDonor.Where(s => s.Bloodid == id); foreach (var k in a) { BloodDonorModel doc = new BloodDonorModel(); doc.DonorName = k.DonorName; doc.Number = k.Number; doc.Address = k.Address; donor.Add(doc); } } return(Json(donor)); }