Exemplo n.º 1
0
        //public void Post([FromBody] string value)
        //{
        //}
        public IActionResult Post([FromBody] Registration obj)
        {
            // create the object of context

            var context = new ValidationContext(obj, null, null);

            //if there are errors then it will fill in ValidationResult collection

            var result = new List <ValidationResult>();

            //class says that validate the obj and if there is error then fill in result

            var isValid = Validator.TryValidateObject(obj, context, result, true);

            if (result.Count == 0)
            {
                PatientDAL dal = new PatientDAL();
                dal.Database.EnsureCreated(); // ensure table is created or not
                dal.Add(obj);                 // here obj is UI comming object //it adds in memory not in database
                dal.SaveChanges();            // pysical commit save to database


                // return Json(recs);

                return(StatusCode(200, result)); // 200 for success
            }
            else
            {
                return(StatusCode(500, result)); // 500 for internal server error
            }
        }
        public IActionResult Get()
        {
            PatientDAL          dal  = new PatientDAL(ConStr);
            List <DiseaseModel> recs = dal.Diseas.ToList();

            return(StatusCode(200, recs));
        }
Exemplo n.º 3
0
        public IActionResult Post([FromBody] LoginModel obj)
        {
            PatientDAL dal = new PatientDAL();

            if (ModelState.IsValid)
            {
                using (var Dbcontext = new PatientDAL())
                {
                    List <Registration> search = (from u in dal.Registrations
                                                  .Where(u => u.userName == obj.userName &&
                                                         u.password == obj.password)
                                                  select u)
                                                 .ToList <Registration>();



                    if (obj != null)
                    {
                        obj.token    = GenerateKey(obj.userName);
                        obj.password = "";
                        return(Ok(obj));
                    }

                    else
                    {
                        ModelState.AddModelError("", "Invalid User Name or Password");
                        return(View(obj));
                    }
                }
            }
            else
            {
                return(View(obj));
            }
        }
Exemplo n.º 4
0
        public ActionResult AddPatientMedicine(int?patient_id, int?PatientMedID)
        {
            List <tblPatientAppointment> lstAppointment = new PatientDAL().getPatientAppointments(Convert.ToInt32(patient_id)).ToList();

            if (lstAppointment.Count > 0)
            {
                ViewBag.lstAppointment = lstAppointment;
            }
            Session["lstAppointment"] = lstAppointment;
            List <tblMedicine> lstMed = new MedicineDAL().GetAllMedicine().ToList();

            ViewBag.lstMed    = lstMed;
            Session["lstMed"] = lstMed;
            List <tblMedicineTiming> lstTiming = new MedicineDAL().GetMedicineTiming().ToList();

            Session["lstTiming"] = lstTiming;
            ViewBag.lstTiming    = lstTiming;

            List <tblMedicineOccurance> lstOccurance = new MedicineDAL().GetMedicineOccurance().ToList();

            Session["lstOccurance"] = lstOccurance;
            ViewBag.lstOccurance    = lstOccurance;
            if (Session["Medicine"] != null)
            {
                ViewBag.med = Session["Medicine"];
            }
            return(View());
        }
Exemplo n.º 5
0
        public ActionResult AddPatient(tblPatient obj, int?patient_id)
        {
            obj.is_active = true;
            if (obj.Gender == "1")
            {
                //obj.Gender = "Male";
            }
            if (obj.Gender == "2")
            {
                //obj.Gender = "Female";
            }
            try
            {
                // TODO: Add insert logic here
                if (obj.Patient_id == 0)
                {
                    patient_id = new PatientDAL().InsertRecord(obj);

                    TempData["AlertTask"] = "Patient added successfully";
                }
                else
                {
                    new PatientDAL().UpdateRecord(obj);
                    patient_id            = obj.Patient_id;
                    TempData["AlertTask"] = "Patient updated successfully";
                }

                return(Redirect("/patients"));
            }
            catch (Exception ex)
            {
                return(View());
            }
        }
Exemplo n.º 6
0
        private void buttonDeletePatient_Click(object sender, EventArgs e)
        {
            var isPatientSelected = (this.listViewPatients.SelectedItems.Count > 0) ? true : false;

            if (isPatientSelected)
            {
                // Get patient id
                var patientId = int.Parse(this.listViewPatients.SelectedItems[0].SubItems[3].Text);

                DialogResult okToProceed = MessageBox.Show("You are about to delete a patient", "Please confirm you would like to continue", MessageBoxButtons.YesNo);
                if (okToProceed == DialogResult.Yes)
                {
                    if (!AppointmentDAL.PatientHasAppointment(patientId))
                    {
                        PatientDAL.DeletePatient(patientId);
                        this.search();
                    }
                    else
                    {
                        MessageBox.Show("Patient has appointments and cannot be deleted");
                    }
                }
            }
            else
            {
                MessageBox.Show("Please select a patient if you wish to delete.");
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Creates a new appointment
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public Message AddAppointment([FromBody] JToken value)
        {
            int doctorid = 0, patientid = 0;

            int.TryParse((string)value.SelectToken("doctorid"), out doctorid);
            int.TryParse((string)value.SelectToken("patientid"), out patientid);
            if (!DoctorDAL.DoctorExists(doctorid))
            {
                return(MessageHandler.Error("Incorrect doctorid. Not authorized to update patients"));
            }
            if (!PatientDAL.PatientExist(patientid))
            {
                return(MessageHandler.Error("Incorrect patientid. Patient not found!"));
            }
            string date = (string)value.SelectToken("date");
            string time = (string)value.SelectToken("time");

            if (date == null)
            {
                return(MessageHandler.Error("Please specify a date for this appointment."));
            }
            if (time == null)
            {
                return(MessageHandler.Error("Please specify a time for this appointment."));
            }

            AppointmentDAL.InsertAppointment(doctorid, patientid, (int)StatusEnum.Success, date, time,
                                             (string)value.SelectToken("notes"));

            UserActivity.AddDoctorActivity((int)ActivityEnum.CreateAppointment, doctorid, (int)StatusEnum.Success, "Success", value.ToString());
            return(MessageHandler.Success("Appointment added!"));
        }
Exemplo n.º 8
0
        private void SaveData()
        {
            string sUserName = Session["User"].ToString();

            oDAL   = new PatientDAL();
            oClass = new PatientModel();

            //sID = lblID.Text;

            // oClass.PatientNo = PatientNo.Value;
            oClass.DateRegister = DateTime.Now;
            oClass.LastName     = LastName.Value;
            oClass.FirstName    = FirstName.Value;
            oClass.MiddleName   = MiddleName.Value;
            oClass.DOB          = Convert.ToDateTime(DOB.Value);
            oClass.Gender       = Gender.Value;
            oClass.Address      = txtAddress.InnerText;
            oClass.ContactNo    = Contact.Value;
            oClass.Email        = PatientEmail.Value;
            oClass.Nationality  = "";

            string id = PatientID.Value;

            if (id == "")
            {
                oDAL.InsertPatient(sUserName, oClass);
                //lblMsg.Text = "New Record has been saved";
            }
            else
            {
                oClass.ID = Convert.ToInt16(id);
                oDAL.UpdatePatient(sUserName, oClass);
                // lblMsg.Text = "Record has been updated";
            }
        }
Exemplo n.º 9
0
        public List <PatientData> SearchPatientData([FromBody] JToken value)
        {
            int docId = 0;

            int.TryParse((string)value.SelectToken("doctorid"), out docId);

            if (DoctorDAL.DoctorExists(docId))
            {
                List <PatientData> patients = PatientDAL.GetPatients((string)value.SelectToken("firstname"),
                                                                     (string)value.SelectToken("lastname"),
                                                                     (string)value.SelectToken("nationalid"),
                                                                     (string)value.SelectToken("mobilenumber")
                                                                     );
                if (patients == null)
                {
                    UserActivity.AddDoctorActivity((int)ActivityEnum.PatientSearch, docId, (int)StatusEnum.Failure, "No patients found", value.ToString());
                }
                else
                {
                    UserActivity.AddDoctorActivity((int)ActivityEnum.PatientSearch, docId, (int)StatusEnum.Success, "Success", value.ToString());
                    return(patients);
                }
            }
            return(null);
        }
Exemplo n.º 10
0
        private static void TestPatientSearch()
        {
            // Testing person search
            List <PatientData> pData = PatientDAL.GetPatients("Cara", null, null, null);

            Console.WriteLine(toJSON(pData));
        }
Exemplo n.º 11
0
        public ActionResult PatientAdmissionList(int patient_id)
        {
            var model = new PatientDAL().GetPatientAdmits(Convert.ToInt32(patient_id));


            return(View(model));
        }
Exemplo n.º 12
0
 /// <see cref="PatientDAL.GetActivePatientsByFirstAndLastName(string, string)"/>
 public List <Person> GetActivePatientsByFirstAndLastName(string firstName, string lastName)
 {
     if (string.IsNullOrWhiteSpace(firstName) || string.IsNullOrWhiteSpace(lastName))
     {
         throw new ArgumentException("first name and last name cannot be null, empty, or consist only of white space");
     }
     return(PatientDAL.GetActivePatientsByFirstAndLastName(firstName, lastName));
 }
Exemplo n.º 13
0
 /// <see cref="PatientDAL.GetActivePatientsByDoB(DateTime)"/>
 public List <Person> GetActivePatientsByDoB(DateTime dateOfBirth)
 {
     if (dateOfBirth == null)
     {
         throw new ArgumentNullException("date of birth cannot be null");
     }
     return(PatientDAL.GetActivePatientsByDoB(dateOfBirth));
 }
Exemplo n.º 14
0
        public ActionResult PatientList()
        {
            var model      = new PatientDAL().ListOfRecords().Where(x => x.is_active == true).ToList();
            var lstDoctors = new DoctorsDAL().ListOfRecords().Where(x => x.EmployeeTypeID == 1).ToList();

            ViewBag.doctors            = lstDoctors;
            ViewData["GetPatientList"] = model;
            return(View());
        }
Exemplo n.º 15
0
        public ActionResult PatientTestList(int?patient_id)
        {
            var patientTestDetails = new PatientDAL().GetPatientTestDetail(Convert.ToInt32(patient_id)).ToList();

            if (patientTestDetails != null)
            {
                ViewBag.patientTestDetails = patientTestDetails;
            }
            return(View());
        }
Exemplo n.º 16
0
        // GET: Patient/Create
        public ActionResult AddPatient(int?patient_id)
        {
            var model = new tblPatient();

            if (patient_id != null)
            {
                model = new PatientDAL().SingleRecord(Convert.ToInt32(patient_id));
            }
            return(View(model));
        }
        public IActionResult Get(string patientName)
        {
            PatientDAL          dal    = new PatientDAL(ConStr);
            List <PatientModel> search = (from temp in dal.PatientModels
                                          where temp.name == patientName
                                          select temp)
                                         .ToList <PatientModel>();

            return(Ok(search));
        }
Exemplo n.º 18
0
        public ActionResult PatientappointmentList(int?patient_id)
        {
            var model = new PatientDAL().GetPatientAllAppointments().ToList();

            if (patient_id != null && patient_id != 0)
            {
                model = model.Where(x => x.patient_id == patient_id).ToList();
            }
            return(View(model));
        }
Exemplo n.º 19
0
        public List <Appointment> GetPatientAppointments([FromBody] JToken value)
        {
            int patientid = 0;

            int.TryParse((string)value.SelectToken("patientid"), out patientid);
            if (PatientDAL.PatientExist(patientid))
            {
                return(AppointmentDAL.GetPatientAppointments(patientid));
            }
            return(null);
        }
Exemplo n.º 20
0
 /// <summary>
 /// Updates a Patient's various records in the db
 /// </summary>
 /// <param name="person">Person of the patient to update</param>
 /// <param name="address">Address of the patient to update</param>
 /// <param name="patient">Patient to update</param>
 /// <returns></returns>
 public bool UpdatePatient(Person person, Address address, Patient patient)
 {
     using (TransactionScope scope = new TransactionScope())
     {
         AddressDAL.UpdateAddress(address);
         PersonDAL.UpdatePerson(person);
         PatientDAL.UpdatePatient(patient);
         scope.Complete();
     }
     return(true);
 }
Exemplo n.º 21
0
        /// <summary>
        /// Deletes the given Patient and their Person from the db
        /// </summary>
        /// <param name="patient">Patient to delete</param>
        /// <returns>Whether or not the Patient was deleted</returns>
        public bool DeletePatient(Patient patient)
        {
            Person person = PersonDAL.GetPersonByPatientID(patient);

            using (TransactionScope scope = new TransactionScope())
            {
                PatientDAL.DeletePatient(patient);
                PersonDAL.DeletePerson(person);
                scope.Complete();
            }
            return(true);
        }
Exemplo n.º 22
0
 /// <see cref="PatientDAL.GetActivePatientsByDoBAndLastName(string, DateTime)"/>
 public List <Person> GetActivePatientsByDoBAndLastName(string lastName, DateTime dateOfBirth)
 {
     if (string.IsNullOrWhiteSpace(lastName))
     {
         throw new ArgumentException("last name cannot be null, empty, or consist only of white space");
     }
     if (dateOfBirth == null)
     {
         throw new ArgumentNullException("date of birth cannot be null");
     }
     return(PatientDAL.GetActivePatientsByDoBAndLastName(lastName, dateOfBirth));
 }
Exemplo n.º 23
0
        public ActionResult PatientAppointment(int?patient_id, int?appointment_id)
        {
            ViewBag.ListDoctor = new DoctorsDAL().ListOfRecords().Where(x => x.EmployeeTypeID == 1).ToList();
            var model = new tblPatientAppointment();

            model.patient_id = Convert.ToInt32(patient_id);
            if (patient_id != null && appointment_id != null)
            {
                model = new PatientDAL().GetPatientAppointment(Convert.ToInt32(patient_id), Convert.ToInt32(appointment_id));
            }
            return(View(model));
        }
Exemplo n.º 24
0
 /// <summary>
 /// Initalizes DAL objects
 /// </summary>
 public HealthcareController()
 {
     visitDAL       = new VisitDAL();
     appointmentDAL = new AppointmentDAL();
     doctorDAL      = new DoctorDAL();
     personDAL      = new PersonDAL();
     loginDAL       = new LoginDAL();
     patientDAL     = new PatientDAL();
     nurseDAL       = new NurseDAL();
     testDAL        = new TestDAL();
     specialtyDAL   = new SpecialityDAL();
 }
Exemplo n.º 25
0
        private void PopulatePatient(string patientNo)
        {
            PatientDAL   oDAL   = new PatientDAL();
            PatientModel oClass = new PatientModel();
            DataSet      oDs    = new DataSet();

            oClass.PatientNo = patientNo;

            oDs = oDAL.SelectByPatientNo(oClass);

            lblPatientName.Text = oDs.Tables[0].Rows[0][5].ToString() + " " + oDs.Tables[0].Rows[0][4].ToString();
        }
Exemplo n.º 26
0
        public void UpdatePatient(Patient patient)
        {
            var validationContext = new ValidationContext(patient);
            var validationResults = new List <ValidationResult>();

            if (!Validator.TryValidateObject(patient, validationContext, validationResults, true))
            {
                var ex = new ValidationException("Objektet klarade inte valideringen.");
                ex.Data.Add("ValidationResults", validationResults);
                throw ex;
            }
            PatientDAL.EditPatient(patient);
        }
Exemplo n.º 27
0
        public PatientData GetPatientData([FromBody] JToken value)
        {
            //int docId = 0;
            //int.TryParse((string)value.SelectToken("doctorid"), out docId);
            //if (DoctorDAL.DoctorExists(docId))
            //{
            int patid = 0;

            int.TryParse((string)value.SelectToken("patientid"), out patid);
            return(PatientDAL.GetPatientData(patid));
            //}
            //return null;
        }
Exemplo n.º 28
0
 public ActionResult Login(string username, string password)
 {
     if (PatientDAL.ValidateUser(username, password))
     {
         TempData["username"] = username;
         return(RedirectToAction("Index"));
     }
     else
     {
         ModelState.AddModelError("", "Invalid Username OR Password");
         return(View());
     }
 }
Exemplo n.º 29
0
 public ActionResult Details(string firstName, string lastName, string timeslot, string date)
 {
     if (ModelState.IsValid)
     {
         List <Patient> patientList = new List <Patient>();
         patientList = PatientDAL.PatientDetail(firstName, lastName);
         return(View(patientList));
     }
     else
     {
         ModelState.AddModelError("", "Enter valid Patient Name..!!");
         return(View());
     }
 }
        private async void finishEdit(object sender, RoutedEventArgs e)
        {
            try
            {
                this.ring.IsActive = true;
                var patientDal = new PatientDAL();
                var nurseDal   = new NurseDAL();
                var appointDal = new AppointmentDAL();
                var vm         = new RoutineCheckupViewModel();
                var appnt      = await appointDal.GetAppointmentById(this.AppointmentID);

                var patient = await patientDal.GetPatientById(this.PatientId);

                var nurse = await nurseDal.GetNurseByNurseId(this.NurseId);

                var date = this.CheckupDate.Date.AddHours(this.CheckupTime.Hours).AddMinutes(this.CheckupTime.Minutes);
                var sys  = !string.IsNullOrWhiteSpace(this.SystolicReading.ToString())
                    ? this.SystolicReading
                    : throw new ArgumentException("The Systolic Reading cannot be empty.");
                var dbp = !string.IsNullOrWhiteSpace(this.DiastolicBloodPressure.ToString())
                    ? this.DiastolicBloodPressure
                    : throw new ArgumentException("The blood pressure cannot be empty.");
                var weght = !string.IsNullOrWhiteSpace(this.Weight.ToString())
                    ? this.Weight
                    : throw new ArgumentException("The weight cannot be empty");
                var tep = !string.IsNullOrWhiteSpace(this.Temperature.ToString())
                    ? this.Temperature
                    : throw new ArgumentException("The tmeperature cannot be empty");
                var diag = !string.IsNullOrWhiteSpace(this.InitialDiagnosis)
                    ? this.InitialDiagnosis
                    : throw new ArgumentException("The initial diaggnosis cannot be empty");
                var checkup = new RoutineCheck(appnt, nurse, patient, date, sys, dbp, weght, tep, diag);
                await vm.EditCheckup(checkup);

                this.Editing(false);
                this.ChangesMade = true;
            }
            catch (Exception ex)
            {
                this.ring.IsActive = false;
                this.error.Text    = ex.Message;
                await Task.Delay(4000);

                this.error.Text = "";
            }

            this.ring.IsActive = false;
        }