Esempio n. 1
0
        public ActionResult UpdateTreatmentRoom(TreatmentRoomModel roomModel)
        {
            TreatmentRoom_Api roomApi = new TreatmentRoom_Api();
            var model = roomApi.UpdateTreatmentRoom(roomModel);

            return(View("~Views/TreatmentRoom/ViewTreatmentRooms.cshtml", model));
        }
        public IEnumerable <TreatmentRoomModel> UpdateTreatmentRoom(TreatmentRoomModel roomModel)
        {
            IEnumerable <TreatmentRoomModel> result = null;

            try
            {
                using (var client = new HttpClient())
                {
                    client.BaseAddress = new Uri(Utils.Url());
                    client.DefaultRequestHeaders.Clear();
                    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                    var jsonData    = JsonConvert.SerializeObject(roomModel);
                    var buffer      = System.Text.Encoding.UTF8.GetBytes(jsonData);
                    var byteContent = new ByteArrayContent(buffer);
                    byteContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
                    HttpResponseMessage Res = client.PostAsync(Utils.Url() + "TreatmentRoom/UpdateTreatmentRoom", byteContent).Result;

                    if (Res.IsSuccessStatusCode)
                    {
                        var res = (Res.Content.ReadAsAsync <IEnumerable <TreatmentRoomModel> >().Result);

                        result = res;
                    }
                }
                return(result);
            }
            catch (Exception ex)
            {
                Utils.Logging(ex, 2);
                return(result);
            }
        }
Esempio n. 3
0
        public ActionResult BookRoomToPaitent(TreatmentRoomModel roomModel)
        {
            TreatmentRoom_Api roomApi = new TreatmentRoom_Api();
            var model = roomApi.BookTreatmentRoom(roomModel);

            return(View("~Views/TreatmentRoom/ViewTreatmentRooms.cshtml", model));
        }
        public ActionResult viewNewBooking()
        {
            if (Convert.ToString(Session["key"]) != "admin")
            {
                return(RedirectToAction("Login", "Home"));
            }

            Admin_Api adminApi = new Admin_Api();
            var       patients = adminApi.GetAllPatients();

            TreatmentRoomModel trModel = new TreatmentRoomModel();

            foreach (var p in patients)
            {
                trModel.patientDropDown.Add(new SelectListItem {
                    Text  = p.firstName,
                    Value = Convert.ToString(p.pid)
                });
            }

            TreatmentRoom_Api roomApi  = new TreatmentRoom_Api();
            var bookedRooms            = roomApi.GetAllTreatmentRooms().Where(t => t.isBooked == true).Select(t => t.patient_ID);
            AppointmentTimings timings = new AppointmentTimings();

            trModel.appointmentTimings = timings.timingsDropDown;

            return(View("~/Views/Administrator/AdminBookRoom.cshtml", trModel));
        }
Esempio n. 5
0
        public TreatmentRoomModel ViewBookedRoom(PatientModel patient)
        {
            TreatmentRoomModel result = null;

            try
            {
                using (var client = new HttpClient())
                {
                    client.BaseAddress = new Uri(Utils.Url());

                    client.DefaultRequestHeaders.Clear();

                    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                    HttpResponseMessage Res = client.GetAsync(Utils.Url() + "Patient/ViewBookedRoom").Result;

                    if (Res.IsSuccessStatusCode)
                    {
                        var res = (Res.Content.ReadAsAsync <TreatmentRoomModel>().Result);

                        result = res;
                    }
                }
                return(result);
            }
            catch (Exception ex)
            {
                Utils.Logging(ex, 2);
                return(result);
            }
        }
        public JsonResult CheckAvailabilityTreatmentRoom(TreatmentRoomModel roomModel)
        {
            TreatmentRoom_Api roomApi = new TreatmentRoom_Api();
            var roomDetail            = roomApi.CheckAvailabilityTreatmentRoom(roomModel);

            if (roomDetail != null)
            {
                return(Json(roomDetail.timings, JsonRequestBehavior.AllowGet));
            }
            return(Json(roomDetail, JsonRequestBehavior.AllowGet));
        }
        public JsonResult fillPatientList(string text)
        {
            Appointment_Api   app     = new Appointment_Api();
            TreatmentRoom_Api roomApi = new TreatmentRoom_Api();
            var model     = roomApi.GetAllTreatmentRoomRecs().Where(t => (t.date == DateTime.Parse(text) && t.isBooked == true)).GroupBy(g => g.patient_ID).Select(s => s.First()).ToList();
            var allAptmts = app.GetAllAppointments();

            var apps = allAptmts.Where(a => a.appointment_Date > DateTime.Now).GroupBy(g => g.paitent_ID).Select(s => s.First()).ToList();

            TreatmentRoomModel trModelPats = new TreatmentRoomModel();

            TreatmentRoomModel trModel = new TreatmentRoomModel();

            //var allApts = app.GetAllAppointments();

            foreach (var p in model)
            {
                trModelPats.patientDropDown.Add(new SelectListItem
                {
                    Text  = p.patientFirstName,
                    Value = Convert.ToString(p.patient_ID)
                });
            }

            foreach (var p in apps)
            {
                trModel.patientDropDown.Add(new SelectListItem
                {
                    Text  = p.patientName,
                    Value = Convert.ToString(p.paitent_ID)
                });
            }

            trModel.patientDropDown = (from t in trModel.patientDropDown
                                       where trModelPats.patientDropDown.All(o => o.Text != t.Text) select t).ToList();
            List <SelectListItem> patientList = new List <SelectListItem>();

            foreach (var p in trModel.patientDropDown)
            {
                patientList.Add(p);
            }

            foreach (var t in trModel.patientDropDown)
            {
                if ((GetApptsForRooms(Convert.ToInt32(t.Value))).Count() == 0)
                {
                    patientList.Remove(t);
                }
            }

            return(Json(patientList, JsonRequestBehavior.AllowGet));
        }
        //  public ActionResult UpdateRooms(TreatmentRoomModel roomModel)
        public ActionResult UpdateRooms(TreatmentRoomModel roomModel)
        {
            if (Convert.ToString(Session["key"]) != "admin")
            {
                return(RedirectToAction("Login", "Home"));
            }

            //IEnumerable<TreatmentRoomModel> model = null;
            TreatmentRoom_Api roomApi = new TreatmentRoom_Api();

            TreatmentRoomModel trModel = new TreatmentRoomModel();

            trModel.room_ID  = roomModel.room_ID;
            trModel.isBooked = false;
            roomApi.UpdateTreatmentRoom(roomModel);
            return(RedirectToAction("ViewRooms"));
            //model =
            //return View("~/Views/Administrator/AdminViewRooms.cshtml", model);
        }
        public JsonResult GetAvailableRooms(string text)
        {
            TreatmentRoom_Api roomApi = new TreatmentRoom_Api();

            TreatmentRoomModel room = new TreatmentRoomModel();

            room.date = DateTime.Parse(text);
            IEnumerable <string> availableRooms = roomApi.GetAvailableRooms(room).Select(r => r.room_ID);

            var ra = room.roomList;

            var displayRooms = new List <RoomValues>();

            try
            {
                displayRooms = ra.Where(r => availableRooms.Contains(r.Value)).ToList();
            }
            catch (Exception ex)
            {
            }
            return(Json(displayRooms, JsonRequestBehavior.AllowGet));
        }
        public ActionResult BookRooms(TreatmentRoomModel roomModel)
        {
            if (Convert.ToString(Session["key"]) != "admin")
            {
                return(RedirectToAction("Login", "Home"));
            }

            TreatmentRoom_Api tr_Api = new TreatmentRoom_Api();

            roomModel.isBooked = true;
            roomModel.timings  = "09:00";
            tr_Api.InsertTreatmentRoomRec(roomModel);

            TreatmentRoom_Api roomApi = new TreatmentRoom_Api();
            PatientModel      pat     = new PatientModel();

            pat.pid = roomModel.patient_ID;
            var model = roomApi.GetRoomsRecordsByPatID(pat);

            Patient_Api patientApi = new Patient_Api();
            var         p          = patientApi.GetPaitentsList();

            foreach (var r in model)
            {
                if (r.date > DateTime.Now)
                {
                    r.canEdit = true;
                }
            }

            foreach (var m in model)
            {
                m.patientList = p;
            }
            return(View("~/Views/Administrator/ViewRoomBooking.cshtml", model));
        }