Beispiel #1
0
        private void removeDoctorToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int    rowindex = doctorGridView1.CurrentCell.RowIndex;
            int    doctorid = (int)doctorGridView1.Rows[rowindex].Cells[0].Value;
            Person doctor   = _student.Doctors.Find(x => x.PersonId == doctorid);

            if (doctor != null)
            {
                if (MessageBox.Show("Are you sure you want to remove doctor '" + doctor.FullName + "' from this student?", "Remove Doctor", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    DataBase db = new DoctorData();
                    db.Remove(doctor, _student.PersonId);
                    _student.Doctors = db.GetList(_student.PersonId);
                    PopulateDoctors();
                }
            }
        }
        /// <summary>
        /// Calls the doctor microservice API to get the name using the doctor Id
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task <DoctorData> GetByIdAsync(int id)
        {
            var doctorServiceName            = new Uri($"{_serviceContext.CodePackageActivationContext.ApplicationName}/MedicalBookingSystem.Doctor");
            var doctorServiceReverseProxyUrl = new Uri($"{APIGatewayConfiguration.ReverseProxyUri}{doctorServiceName.AbsolutePath}");

            var response = await _apiClient.GetAsync(doctorServiceReverseProxyUrl + UrlsConfig.DoctorOperations.GetDoctorById(id.ToString()));

            DoctorData doctor = null;

            if (response.StatusCode == HttpStatusCode.OK)
            {
                var content = await response.Content.ReadAsStringAsync();

                doctor = JsonConvert.DeserializeObject <DoctorData>(content);
            }

            return(doctor);
        }
Beispiel #3
0
        public async Task <IActionResult> PutDoctor(int id, DoctorData item)
        {
            if (!ModelState.IsValid || id != item.Doctor.ID)
            {
                return(BadRequest());
            }
            var doctor = await _context.Doctors.FindAsync(id);

            var hasedPassword = Encrypt.EncryptString(item.Doctor.Password);
            var user          = await _context.Doctors
                                .Where(u => u.Password == hasedPassword || u.Email == item.Doctor.Email)
                                .FirstOrDefaultAsync();

            if (doctor == null || (user != null && user.ID != doctor.ID))
            {
                return(BadRequest());
            }
            doctor.Name        = item.Doctor.Name;
            doctor.Email       = item.Doctor.Email;
            doctor.Password    = hasedPassword;
            doctor.City        = item.Doctor.City;
            doctor.Address     = item.Doctor.Address;
            doctor.Information = item.Doctor.Information;
            var specialtyDoctors = await _context.SpecialtyDoctors
                                   .Where(d => d.DoctorID == doctor.ID)
                                   .Include(s => s.Specialty)
                                   .ToListAsync();

            _context.SpecialtyDoctors.RemoveRange(specialtyDoctors);
            foreach (var ids in item.Specialty)
            {
                var specialtyDoctor = new SpecialtyDoctor
                {
                    DoctorID    = doctor.ID,
                    SpecialtyID = ids
                };
                await _context.SpecialtyDoctors.AddAsync(specialtyDoctor);
            }
            _context.Doctors.Update(doctor);
            await _context.SaveChangesAsync();

            return(Ok(doctor));
        }
        public void LoadFullList()
        {
            ep.SetError(dgDoctor, "");
            try
            {
                //DataBase db;
                //if(rbAllStudents.Checked)
                //    db = new StudenData();
                //else
                DataBase db = new DoctorData();

                _allDoctors         = db.GetList();
                _filteredDoctorList = _allDoctors;
            }
            catch (Exception ex)
            {
                ep.SetError(dgDoctor, ex.Message);
            }
        }
        public Doctor Put(DoctorRequests request)
        {
            Doctor c = new Doctor()
            {
                Id                     = request.Id,
                Name                   = request.Name,
                Description            = request.Description,
                Email                  = request.Email,
                JoinDate               = request.JoinDate,
                Title                  = request.Title,
                Website                = request.Website,
                PhoneNumber            = request.PhoneNumber,
                Reviews                = request.Reviews,
                Language               = request.Language,
                RewardsAndCertificates = request.RewardsAndCertificates
            };
            DoctorData cd = new DoctorData(Db);

            return(cd.UpdateDoctor(c));
        }
        public void Delete(DoctorIdRequest request)
        {
            DoctorData cd = new DoctorData(Db);

            cd.DeleteDoctorById(request.DoctorID);
        }
Beispiel #7
0
        public override void Save()
        {
            DBCommand dbc = new DBCommand(DBCommand.TransactionType.WithTransaction);

            try
            {
                DataBase db = new StudentData(dbc);
                if (Student.PersonId == 0)
                {
                    int studentId = db.Add(Student);
                    if (Student.Doctors.Count > 0)
                    {
                        db = new DoctorData(dbc);
                        foreach (Doctor doctor in Student.Doctors)
                        {
                            db.Allocate(doctor, studentId);
                        }
                    }

                    if (Student.NextOfKin.Count > 0)
                    {
                        db = new NextOfKinData(dbc);
                        foreach (NextOfKin nok in Student.NextOfKin)
                        {
                            if (nok.PersonId == 0)
                            {
                                nok.PersonId = db.Add(nok, studentId);
                            }
                            else
                            {
                                db.Allocate(nok, studentId);
                            }
                        }
                    }

                    if (Student.EmergencyContacts.Count > 0)
                    {
                        db = new EmergencyContactData(dbc);
                        foreach (EmergencyContact ec in Student.EmergencyContacts)
                        {
                            //if (ec.PersonId == 0)
                            //{
                            ec.PersonId = db.Add(ec, studentId);
                            //}
                            //db.Allocate(ec, studentId);
                        }
                    }

                    if (Student.MedicalConditions.Count > 0)
                    {
                        MedicalConditionData mdc = new MedicalConditionData(dbc);
                        foreach (MedicalCondition mc in Student.MedicalConditions)
                        {
                            mdc.Add(mc, studentId);
                        }
                    }
                }
                else
                {
                    db.Update(Student);
                }
                dbc.CommitTransactions();
                dbc.CloseConnection();
                Student.RemovedObjects.Clear();
            }
            catch (Exception ex)
            {
                dbc.rollbackTransactions();
                dbc.CloseConnection();
                throw new Exception(ex.Message);
            }
        }
        public Doctor GetById(int id)
        {
            var db = new DoctorData();

            return(db.GetById(id));
        }
Beispiel #9
0
 public static string GetDoctorFilePath(DoctorData clientData)
 {
     return($"{ServerData.DoctorDir}\\docUser_{clientData.Id}");
 }
Beispiel #10
0
        public IEnumerable <Doctor> List()
        {
            var db = new DoctorData();

            return(db.List());
        }
Beispiel #11
0
        public void OnAuthorizeConnection(Datagram received)
        {
            TcpTask currentTask = null;

            if (received.DataType == DataType.Login)
            {
                var loginRequest = TcpHelper.ToConcreteType <JsonLogin>(received.Data);
                if (loginRequest.IsDoctorProgram)
                {
                    DoctorData currentUser = FindDoctorWithPassword(loginRequest.Id, loginRequest.Password);
                    if (currentUser != null)
                    {
                        DoctorTask doctorTask = new DoctorTask(client, serverData, currentUser, currentTasks);
                        currentTask = doctorTask;
                        lock (OnlineListSyncRoot)
                        {
                            currentTasks.Add(doctorTask);
                        }
                    }
                }
                else
                {
                    //moet voor client lists in server data want we voegen data toe maar lezen ook.
                    serverData.ClientListLock.EnterReadLock();
                    PatientData currentUser = FindClientWithPassword(loginRequest.Id, loginRequest.Password);
                    serverData.ClientListLock.ExitReadLock();
                    if (currentUser != null)
                    {
                        // ZORGT VOOR DEADLOCK!!!
                        PatientTask clientTask = new PatientTask(client, serverData, currentUser, currentTasks);
                        currentTask = clientTask;
                        lock (OnlineListSyncRoot)
                        {
                            currentTasks.Add(clientTask);
                        }
                    }
                }
            }

            //TcpHelper writerHelper = new TcpHelper(client);
            //dynamic response = new ExpandoObject();
            //response.DataType = DataType.Login;
            //response.Data = new ExpandoObject();

            TcpHelper writerHelper = new TcpHelper(client);
            var       response     = new Datagram();

            response.DataType = DataType.Login;
            if (currentTask != null)
            {
                response.Data = new JsonResponse
                {
                    Error   = "200",
                    Message = "LoginOK"
                };
                writerHelper.WriteJsonData(response);
                currentTask.Run();
            }
            else
            {
                response.Data = new JsonResponse
                {
                    Error   = "500",
                    Message = "LoginWrong"
                };
                writerHelper.WriteJsonData(response);
                //lets try that again
                TcpHelper helper = new TcpHelper(client);
                helper.ReadJsonData(OnAuthorizeConnection);
            }
        }
Beispiel #12
0
        //private void CmbFullName_SelectedIndexChanged(object sender, EventArgs e)
        //{
        //    throw new NotImplementedException();
        //}

        private void btnAdd_Click(object sender, EventArgs e)
        {
            ep.Clear();
            if (cmbDoctorName.Text == string.Empty && rbAllocateFromList.Checked)
            {
                ep.SetError(cmbDoctorName, "Select a doctor or type new doctor name");
            }
            if (txtDoctorName.Text == string.Empty && rbAddNewDoctor.Checked)
            {
                ep.SetError(cmbDoctorName, "Type new doctor name");
            }
            if (txtAddr1.Text == string.Empty)
            {
                ep.SetError(txtAddr1, "Type Addr1");
            }
            if (txtAddr2.Text == string.Empty)
            {
                ep.SetError(txtAddr2, "Type Addr2");
            }
            if (txtAddr3.Text == string.Empty)
            {
                ep.SetError(txtAddr3, "Type Addr3");
            }
            if (txtPostcode.Text == string.Empty)
            {
                ep.SetError(txtPostcode, "Type Postcode");
            }
            if (txtPhone.Text == string.Empty)
            {
                ep.SetError(txtPhone, "Type Phone");
            }

            bool failed = false;

            foreach (Control c in this.Controls)
            {
                if (ep.GetError(c).Length > 0)
                {
                    failed = true;
                }
            }

            if (failed)
            {
                return;
            }
            else
            {
                try
                {
                    DataBase db = new DoctorData();
                    if (_selectedDoctor == null) // add doctor and assign to student
                    {
                        Person doctor = new Doctor
                        {
                            FullName = txtDoctorName.Text,
                            Addr1    = txtAddr1.Text,
                            Addr2    = txtAddr2.Text,
                            Addr3    = txtAddr3.Text,
                            Addr4    = txtAddr4.Text,
                            Postcode = txtPostcode.Text,
                            Phone    = txtPhone.Text,
                            Email    = txtEmail.Text
                        };

                        int doctorId = db.Add(doctor, _student.PersonId);
                        doctor.PersonId = doctorId;
                    }
                    else // add doctor to student
                    {
                        db.Allocate(_selectedDoctor, _student.PersonId);
                    }
                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            //if(ep.GetError())
        }
Beispiel #13
0
        /// <summary>
        /// Retrives the list of fee of all the doctors
        /// </summary>
        /// <returns>List of Doctor Fee</returns>
        public List <DoctorFee> GetAllDoctorsList()
        {
            DoctorData doctorData = new DoctorData();

            return(doctorData.GetAllDoctorsList());
        }
Beispiel #14
0
        /// <summary>
        /// Retrives List of Doctor Specialization from database
        /// </summary>
        /// <returns>List of Doctor Specialization</returns>
        public List <DoctorSpecialization> GetDoctorSpecilizationList()
        {
            DoctorData doctorData = new DoctorData();

            return(doctorData.GetDoctorSpecilizationsList());
        }
Beispiel #15
0
        public void Update(Doctor doc)
        {
            var db = new DoctorData();

            db.Update(doc);
        }
Beispiel #16
0
        public override void AllocateDoctor(Doctor doctor)
        {
            DataBase db = new DoctorData();

            db.Allocate(doctor, Student.PersonId);
        }
Beispiel #17
0
        public List <DoctorModel> GetById(string id)
        {
            DoctorData data = new DoctorData();

            return(data.GetDoctorById(id));
        }
Beispiel #18
0
        public void UseAddPatientToDoctor(string idD, string idP)
        {
            DoctorData doctorData = new DoctorData();

            doctorData.AddPatientToDoctor(idD, idP);
        }
Beispiel #19
0
        public void Insert(Doctor doc)
        {
            var db = new DoctorData();

            db.Insert(doc);
        }
        public override void Commit()
        {
            DataBase db = new DoctorData();

            db.Update(_doctorAddEdit.Doctor);
        }
Beispiel #21
0
        public List <Doctor> Get(GetDoctorRequest request)
        {
            DoctorData cd = new DoctorData(Db);

            return(cd.getDoctorList());
        }
Beispiel #22
0
        public List <DoctorModel> GetAllVaccines()
        {
            DoctorData data = new DoctorData();

            return(data.GetAllDoctors());
        }
Beispiel #23
0
        public Doctor Get(DoctorIdRequest request)
        {
            DoctorData cd = new DoctorData(Db);

            return(cd.getDoctorById(request.DoctorID));
        }
Beispiel #24
0
        public override void Commit()
        {
            DataBase db = new DoctorData();

            _doctorAddEdit.Doctor.PersonId = db.Add(_doctorAddEdit.Doctor);
        }
Beispiel #25
0
        public void Delete(int id)
        {
            var db = new DoctorData();

            db.Delete(id);
        }