示例#1
0
 public HomeController()
 {
     _doctorRepo     = new DoctorRepo();
     _customerRepo   = new CustomerRepo();
     context         = new ApplicationDbContext();
     databaseContext = new DatabaseContext();
 }
示例#2
0
 public DoctorInfoViewModel()
 {
     repo            = new DoctorRepo(new ClinicAppDAL.EF.ClinicAppClinicContext());
     DShowList       = new DelegateCommand(ShowList);
     LeftBorderDate  = DateTime.Now;
     RightBorderDate = DateTime.Now;
 }
 private void GetDoctorID()
 {
     if (UserLoginInfo.Designation.Equals("Doctor"))
     {
         this.Doctorid = DoctorRepo.GetDoctorID(Convert.ToInt32(UserLoginInfo.EmployeeID.ToString()));
     }
 }
        //Konstruktor
        public DoctorTab()
        {
            InitializeComponent();
            List <Doctor> DoctorList = DoctorRepo.GetAllDoctors();

            DoctorListView.ItemsSource = DoctorList;
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                this.CheckIfFieldEmpty();

                PersonRepo p = new PersonRepo();
                p.Name       = this.txtFullName.Text;
                p.Age        = Convert.ToInt32(this.txtAge.Text);
                p.Gender     = this.cmbGender.Text;
                p.BloodGroup = this.cmbBloodGrp.Text;
                p.Phone      = this.txtPhoneNumber.Text;


                EmployeeRepo e1 = new EmployeeRepo();

                e1.Salary      = Convert.ToInt32(this.txtSalary.Text);
                e1.Designation = this.cmbDesignation.Text;
                //e1.PersonIdOfEmp = Convert.ToInt32(this.txtId.Text);

                DoctorRepo dr = new DoctorRepo();
                dr.Specialty     = this.txtSpecialty.Text;
                dr.AvailableDays = this.cmbAvailableDays.Text;
                //dr.EmployeeIdOfDoctor = Convert.ToInt32(this.txtEmpId.Text);

                //person created
                p.CreatePerson(p.Name, p.Age, p.Gender, p.BloodGroup, p.Phone);
                this.PopulatePersonTable();
                //refrsh

                //get last person
                DataTable lastperson = p.GetLastPerson();

                //DataTable lastperson = p.GetLastPerson();
                this.personID = Convert.ToInt32(lastperson.Rows[0]["personid"].ToString());

                //getpersonid
                //this.personID = Convert.ToInt32(lastperson.Rows[0]["personid"].ToString());
                //create emplyee
                e1.CreateEmployee(e1.Designation, e1.Salary, this.personID);
                if (this.cmbDesignation.Text == "Doctor")
                {
                    DataTable lastemp = e1.GetLastEmployee();
                    this.empID = Convert.ToInt32(lastemp.Rows[0]["empid"].ToString());

                    //create doctor
                    dr.CreateDoctor(dr.Specialty, dr.AvailableDays, empID);
                }

                MessageBox.Show("Successfully added!");
                this.PopulatePersonTable();
                this.ClearAll();
            }
            catch (Exception exc)
            {
                MessageBox.Show("error!" + exc);
            }
        }
示例#6
0
 public UnitOfWork(ApplicationDbContext context)
 {
     _context        = context;
     Patients        = new PatientRepo(context);
     Appointments    = new AppointmentRepo(context);
     Attandences     = new AttendanceRepo(context);
     Cities          = new CityRepo(context);
     Doctors         = new DoctorRepo(context);
     Specializations = new SpecializationRepo(context);
     Users           = new ApplicationUserRepo(context);
 }
示例#7
0
 public DoctorListViewModel(IRegionManager regionManager, IDialogService dialogService)
 {
     _regionManager        = regionManager;
     _dialogService        = dialogService;
     docRepo               = new DoctorRepo(new ClinicAppDAL.EF.ClinicAppClinicContext());
     Doctors               = new ObservableCollection <Doctor>(docRepo.GetAll());
     DoctorSelectedCommand = new DelegateCommand <Doctor>(DoctorSelected);
     DoctorDeleteCommand   = new DelegateCommand(DoctorDelete, canDelete).ObservesProperty(() => SelectedDoctor);
     DoctorAddCommand      = new DelegateCommand(DoctorAdd);
     SearchCommand         = new DelegateCommand(Search);
     ChangeCommand         = new DelegateCommand(Change, canDelete).ObservesProperty(() => SelectedDoctor);
 }
示例#8
0
        public VisitAddViewModel()
        {
            ButtonClick = new DelegateCommand(Add);
            patRepo     = new BaseRepo <Patient>(new ClinicAppDAL.EF.ClinicAppClinicContext());
            diagRepo    = new BaseRepo <Diagnosis>(new ClinicAppDAL.EF.ClinicAppClinicContext());
            docRepo     = new DoctorRepo(new ClinicAppDAL.EF.ClinicAppClinicContext());
            visRepo     = new DoctorVisitRepo(new ClinicAppDAL.EF.ClinicAppClinicContext());
            VisitDate   = DateTime.Now;

            Doctors   = new ObservableCollection <Doctor>(docRepo.GetAll());
            Patients  = new ObservableCollection <Patient>(patRepo.GetAll());
            Diagnoses = new ObservableCollection <Diagnosis>(diagRepo.GetAll());
        }
示例#9
0
        private void btnUpdateDays_Click(object sender, EventArgs e)
        {
            DoctorRepo dr = new DoctorRepo();

            dr.DoctorID      = Convert.ToInt32(this.txtDoctorID.Text);
            dr.Specialty     = this.txtSpecialty.Text;
            dr.AvailableDays = this.cmbAvailableDays.Text.ToString();
            int check = dr.UpdateDoctor(dr.DoctorID, dr.Specialty, dr.AvailableDays);

            if (check == 1)
            {
                MessageBox.Show("Data Updated");
            }
        }
示例#10
0
        public override Expression <Func <Appointment, bool> > GenerateFilter()
        {
            DoctorRepo repo = new DoctorRepo();
            Doctor     doc  = repo.GetById(AuthenticationManager.LoggedUser.Id);

            if (doc != null)
            {
                return(u => (u.DoctorId == AuthenticationManager.LoggedUser.Id || u.User.Id == AuthenticationManager.LoggedUser.Id) &&
                       (String.IsNullOrEmpty(Name) || u.User.Firstname.Contains(Name)) &&
                       (String.IsNullOrEmpty(Status) || u.IsApproved.ToLower().Equals(Status.ToLower())) &&
                       (String.IsNullOrEmpty(Name) || u.User.Lastname.Contains(Name)));
            }
            else
            {
                return(u => (u.DoctorId == AuthenticationManager.LoggedUser.Id || u.User.Id == AuthenticationManager.LoggedUser.Id) &&
                       (String.IsNullOrEmpty(Status) || u.IsApproved.ToLower().Equals(Status.ToLower())) &&
                       (String.IsNullOrEmpty(Name) || u.Doctor.User.Lastname.Contains(Name)));
            }
        }
        private void btnDelete_Click(object sender, EventArgs e)
        {
            PersonRepo p1 = new PersonRepo();

            p1.PersonID = Convert.ToInt32(this.txtPID.Text);

            DoctorRepo dr = new DoctorRepo();

            if (this.txtDoctorId.Text != "" && this.txtDoctorId.Text != null)
            {
                dr.DoctorID = Convert.ToInt32(this.txtDoctorId.Text);
            }

            EmployeeRepo er = new EmployeeRepo();

            er.EmpID = Convert.ToInt32(this.txtEmpId.Text);

            try
            {
                if (this.cmbDesignation.Text == "Doctor")
                {
                    // IF DOCTOR -> Delete from all table that contains doctor's reference first
                    CancelledAppointmentsRepo.RemoveParticularDoctorsAppointments(dr.DoctorID);
                    AppointmentRepo.RemoveParticularDoctorsAppointments(dr.DoctorID);
                    PatientDiseaseRepo.DeleteInfoBasedOnDoctor(dr.DoctorID);
                    LoginVerification.DeleteLoginInfo(er.EmpID);
                    // Afterwards delete from doctor table
                    dr.DeleteDoctor(dr.DoctorID);
                }

                int empdelete     = er.DeleteEmployee(er.EmpID);
                int persondeleted = p1.DeletePerson(p1.PersonID);

                this.PopulatePersonTable();
                MessageBox.Show("Successfully deleted!");
                this.ClearAll();
            }
            catch (Exception exc)
            {
                MessageBox.Show("error!" + exc);
            }
        }
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                CheckIfFieldEmpty();

                PersonRepo p1 = new PersonRepo();
                p1.PersonID = Convert.ToInt32(this.txtPID.Text);

                p1.Name       = this.txtName.Text;
                p1.Age        = Convert.ToInt32(this.txtAge.Text);
                p1.Phone      = this.txtNumber.Text;
                p1.Gender     = this.cmbGender.Text;
                p1.BloodGroup = this.cmbBloodGrp.Text;

                DoctorRepo dr = new DoctorRepo();
                dr.DoctorID      = Convert.ToInt32(this.txtDoctorId.Text);
                dr.Specialty     = this.txtSpecialty.Text;
                dr.AvailableDays = this.cmbAvailableDays.Text;


                EmployeeRepo er = new EmployeeRepo();
                er.EmpID       = Convert.ToInt32(this.txtEmpId.Text);
                er.Salary      = Convert.ToInt32(this.txtSalary.Text);
                er.Designation = this.cmbDesignation.Text;

                int personupdate = p1.UpdatePerson(p1.PersonID, p1.Name, p1.Age, p1.Gender, p1.BloodGroup, p1.Phone);
                int empupdate    = er.UpdateEmployee(er.EmpID, er.Designation, er.Salary);
                int doctorupdate = dr.UpdateDoctor(dr.DoctorID, dr.Specialty, dr.AvailableDays);
                PopulatePersonTable();
                MessageBox.Show("Successfully updated!");
                this.ClearAll();
            }

            catch (Exception exc)
            {
                MessageBox.Show("error" + exc);
            }
        }
        private void btnConfirmAppointment_Click(object sender, EventArgs e)
        {
            try
            {
                // Check if text field contains value
                this.CheckTextField();

                if (this.dtpAppointmentDate.Value.Date < DateTime.Today)
                {
                    throw new Exception("Selected date must be of today or future");
                }

                DoctorRepo doctorRepo = new DoctorRepo();
                DataTable  doctorData = doctorRepo.GetIndividualDoctorsInfo(Convert.ToInt32(this.txtDoctorID.Text));
                doctorRepo.DoctorID           = Convert.ToInt32(doctorData.Rows[0]["doctorid"].ToString());
                doctorRepo.Specialty          = doctorData.Rows[0]["specialty"].ToString();
                doctorRepo.AvailableDays      = doctorData.Rows[0]["availabledays"].ToString();
                doctorRepo.EmployeeIdOfDoctor = Convert.ToInt32(doctorData.Rows[0]["empid"].ToString());

                // Check if available day of doctor matches with appointment day
                string[] daysAvailabe  = doctorRepo.AvailableDays.Split(' ');
                bool     checkValidDay = false;
                //string selectedDay = dtpAppointmentDate.Value.DayOfWeek.ToString().Substring(0, 3).ToLower();
                string selectedDay = dtpAppointmentDate.Value.DayOfWeek.ToString().Substring(0, 3);

                foreach (string days in daysAvailabe)
                {
                    if (days.Equals(selectedDay))
                    {
                        checkValidDay = true;
                        break;
                    }
                    else
                    {
                        checkValidDay = false;
                    }
                }
                // If its a invalid day
                if (!checkValidDay)
                {
                    throw new Exception("Doctor not available on this day. Check Available days");
                }

                // Get the person id of the doctor

                string sql = @"select employee.personid from employee 
                        where employee.empid = '" + doctorRepo.EmployeeIdOfDoctor + "' ";

                DataTable  data = DataAccess.GetDataTable(sql);
                int        id   = Convert.ToInt32(data.Rows[0]["personid"].ToString());
                PersonRepo p    = new PersonRepo();
                DataTable  ds   = p.GetIndividualPerson(id);
                string     a    = ds.Rows[0]["personid"].ToString();

                // should not be able to confirm appointment if doctor and patient are same person
                if (a.Equals(this.txtPersonID.Text))
                {
                    //MessageBox.Show("Doctor and Patient cannot be the same person");
                    throw (new Exception("Doctor and patient cannot be the same person"));
                }

                AppointmentRepo ap         = new AppointmentRepo();
                string          apTime     = this.cmbAppointmentTime.Text.ToString();
                string          apDate     = this.dtpAppointmentDate.Value.ToString("MM/dd/yyyy");
                int             apDoctorid = Convert.ToInt32(this.txtDoctorID.Text);

                if (ap.RowExits(apTime, apDate, apDoctorid))
                {
                    //this.txtPersonID.Text = this.PatientID.ToString();
                    throw new Exception("Clash Appointment");
                }

                var result = MessageBox.Show("Confirm appointment?", "Confirm", MessageBoxButtons.YesNoCancel);
                if (result == DialogResult.Yes)
                {
                    if (this.txtPersonID.Text == string.Empty)
                    {
                        // Person p = new Person();
                        p.Name       = this.txtName.Text;
                        p.Age        = Int32.Parse(this.txtAge.Text);
                        p.Gender     = this.cmbGender.Text;
                        p.BloodGroup = this.cmbBloodGroup.Text;
                        p.Phone      = this.txtPhone.Text;

                        // Create a new person
                        int personCreated = p.CreatePerson(p.Name, p.Age, p.Gender, p.BloodGroup, p.Phone);
                        // Refresh the person table
                        this.PopulatePersonTable();
                        // If person created successfully get his/her id to insert into appointment table
                        if (personCreated == 1)
                        {
                            DataTable lastPersonInsertedDT = p.GetLastPerson();
                            this.PatientID = Convert.ToInt32(lastPersonInsertedDT.Rows[0]["personid"].ToString());
                            int appointmentCreated = ap.CreateAppointment(this.cmbAppointmentTime.Text.ToString(), this.dtpAppointmentDate.Value.ToString("MM/dd/yyyy"), this.PatientID, Convert.ToInt32(this.txtDoctorID.Text));
                            if (appointmentCreated == 1)
                            {
                                MessageBox.Show("Appointment Confirmed");
                                this.CLearAll();
                            }
                        }
                    }
                    else
                    {
                        // Person already exists in database, so no need to create newly
                        this.PatientID = Convert.ToInt32(txtPersonID.Text);
                        int appointmentCreated = ap.CreateAppointment(apTime, apDate, this.PatientID, apDoctorid);
                        if (appointmentCreated == 1)
                        {
                            MessageBox.Show("Appointment Confirmed");
                            this.CLearAll();
                        }
                    }
                }
            }
            catch (Exception msg)
            {
                MessageBox.Show(msg.Message, "ERROR");
            }
        }
示例#14
0
 public VisitInfoViewModel()
 {
     patRepo  = new BaseRepo <Patient>(new ClinicAppDAL.EF.ClinicAppClinicContext());
     diagRepo = new BaseRepo <Diagnosis>(new ClinicAppDAL.EF.ClinicAppClinicContext());
     docRepo  = new DoctorRepo(new ClinicAppDAL.EF.ClinicAppClinicContext());
 }
示例#15
0
 public DoctorService(DoctorRepo doctorRepo)
 {
     DoctorRepo = doctorRepo;
 }
示例#16
0
 public DoctorAddViewModel()
 {
     ButtonClick    = new DelegateCommand(Add).ObservesProperty(() => SelectedDoctor);
     repo           = new DoctorRepo(new ClinicAppDAL.EF.ClinicAppClinicContext());
     SelectedDoctor = new Doctor();
 }
示例#17
0
 public AdminController()
 {
     _databaseContext = new DatabaseContext();
     _doctorRepo      = new DoctorRepo();
 }
示例#18
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                if (this.dtpAppointmentDate.Value.Date < DateTime.Today)
                {
                    throw new Exception("Selected date must be of today or future");
                }

                DoctorRepo doctorRepo = new DoctorRepo();
                DataTable  doctorData = doctorRepo.GetIndividualDoctorsInfo(Convert.ToInt32(this.txtDoctorID.Text));
                doctorRepo.DoctorID           = Convert.ToInt32(doctorData.Rows[0]["doctorid"].ToString());
                doctorRepo.Specialty          = doctorData.Rows[0]["specialty"].ToString();
                doctorRepo.AvailableDays      = doctorData.Rows[0]["availabledays"].ToString();
                doctorRepo.EmployeeIdOfDoctor = Convert.ToInt32(doctorData.Rows[0]["empid"].ToString());

                // Check if available day of doctor matches with appointment day
                string[] daysAvailabe  = doctorRepo.AvailableDays.Split(' ');
                bool     checkValidDay = false;
                string   selectedDay   = dtpAppointmentDate.Value.DayOfWeek.ToString().Substring(0, 3);
                foreach (string days in daysAvailabe)
                {
                    if (days.Equals(selectedDay))
                    {
                        checkValidDay = true;
                        break;
                    }
                    else
                    {
                        checkValidDay = false;
                    }
                }
                // If its a invalid day
                if (!checkValidDay)
                {
                    throw new Exception("Doctor not available on this day. Check Available days");
                }

                AppointmentRepo ap = new AppointmentRepo();
                ap.AppointmentID = Convert.ToInt32(this.txtAppointmentID.Text);
                ap.Time          = this.cmbAppointmentTime.Text.ToString();
                ap.Date          = this.dtpAppointmentDate.Value.ToString("MM/dd/yyyy");
                ap.DoctorID      = Convert.ToInt32(this.txtDoctorID.Text);
                ap.PatientID     = Convert.ToInt32(this.txtPatientID.Text);
                // Check if clash appointment
                if (ap.RowExits(ap.Time, ap.Date, ap.DoctorID))
                {
                    throw new Exception("Clash Appointment");
                }
                // If no clash appointment then proceed
                int appointmentCreated = ap.CreateAppointment(ap.Time, ap.Date, ap.PatientID, ap.DoctorID);
                if (appointmentCreated == 1)
                {
                    // Must remove it from cancelled appointment now since reassigned
                    CancelledAppointmentsRepo.RemoveCancelledAppointment(ap.AppointmentID);
                    MessageBox.Show("Appointment  reassigned");
                    // refresh the table
                    this.PopulateCancelledTable();
                    this.ClearAll();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                if (this.dtpAppointmentDate.Value.Date < DateTime.Today)
                {
                    throw new Exception("Selected date must be of today or future");
                }

                DoctorRepo doctorRepo = new DoctorRepo();
                DataTable  doctorData = doctorRepo.GetIndividualDoctorsInfo(Convert.ToInt32(this.txtDoctorID.Text));
                doctorRepo.DoctorID           = Convert.ToInt32(doctorData.Rows[0]["doctorid"].ToString());
                doctorRepo.Specialty          = doctorData.Rows[0]["specialty"].ToString();
                doctorRepo.AvailableDays      = doctorData.Rows[0]["availabledays"].ToString();
                doctorRepo.EmployeeIdOfDoctor = Convert.ToInt32(doctorData.Rows[0]["empid"].ToString());

                // Check if available day of doctor matches with appointment day
                string[] daysAvailabe  = doctorRepo.AvailableDays.Split(' ');
                bool     checkValidDay = false;
                //string selectedDay = dtpAppointmentDate.Value.DayOfWeek.ToString().Substring(0, 3).ToLower();
                string selectedDay = dtpAppointmentDate.Value.DayOfWeek.ToString().Substring(0, 3);
                foreach (string days in daysAvailabe)
                {
                    if (days.Equals(selectedDay))
                    {
                        checkValidDay = true;
                        break;
                    }
                    else
                    {
                        checkValidDay = false;
                    }
                }
                // If its a invalid day
                if (!checkValidDay)
                {
                    throw new Exception("Doctor not available on this day. Check Available days");
                }

                AppointmentRepo ap = new AppointmentRepo();
                ap.AppointmentID = Convert.ToInt32(this.txtAppointmentID.Text);
                ap.Time          = this.cmbAppointmentTime.Text.ToString();
                ap.Date          = this.dtpAppointmentDate.Value.ToString("MM/dd/yyyy");
                ap.DoctorID      = Convert.ToInt32(this.txtDoctorID.Text);
                ap.PatientID     = Convert.ToInt32(this.txtPatientID.Text);
                // Check if clash appointment
                if (ap.RowExits(ap.Time, ap.Date, ap.DoctorID))
                {
                    throw new Exception("Clash Appointment");
                }
                // If no clash appointment then proceed
                var ask = MessageBox.Show("Confirm appointment update?", "Question", MessageBoxButtons.YesNo);
                if (ask == DialogResult.Yes)
                {
                    int appointmentUpdated = ap.UpdateAppointment(ap.AppointmentID, ap.Time, ap.Date, ap.PatientID, ap.DoctorID);
                    if (appointmentUpdated == 1)
                    {
                        MessageBox.Show("Appointment Updated");
                        this.PopulateAppointmentTable();
                        this.ClearAll();
                    }
                    else
                    {
                        MessageBox.Show("Error");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
示例#20
0
 public DoctorController()
 {
     databaseContext = new DatabaseContext();
     context         = new ApplicationDbContext();
     _doctorRepo     = new DoctorRepo();
 }