private void AddPatient(string login, string pass, string name, string surname, int specialityId, string sex, DateTime?date, string email, string phone)
        {
            using (MedicalClinicContext context = new MedicalClinicContext())
            {
                Doctor doctor = new Doctor();
                doctor.SpecialityId = specialityId;

                PersonalData patientPersonalData = new PersonalData();
                patientPersonalData.Name        = name;
                patientPersonalData.Surname     = surname;
                patientPersonalData.Sex         = sex;
                patientPersonalData.DateOfBirth = (DateTime)date;
                patientPersonalData.Email       = email;
                patientPersonalData.PhoneNumber = phone;

                context.PersonalData.Add(patientPersonalData);
                context.SaveChanges();

                User patientUser = new User();
                patientUser.Login    = login;
                patientUser.Password = pass;

                context.User.Add(patientUser);
                context.SaveChanges();

                doctor.User         = patientUser;
                doctor.PersonalData = patientPersonalData;

                doctor.UserId          = patientUser.Id;
                doctor.PersonalData.Id = patientPersonalData.Id;

                context.Doctor.Add(doctor);
                context.SaveChanges();
            }
        }
示例#2
0
        private void DeleteButtonClick(object sender, RoutedEventArgs e)
        {
            List <int> idOfAppointments = (Appointments.ItemsSource as List <ElemOfGrid>).Where(app => app.IsSelected == true)
                                          .Select(app => app.IdOfAppointment)
                                          .ToList();

            if (idOfAppointments.Count != 0)
            {
                List <Appointment> rangeToRemove = new List <Appointment>();
                using (var context = new MedicalClinicContext())
                {
                    foreach (var id in idOfAppointments)
                    {
                        rangeToRemove.Add(context.Appointment.FirstOrDefault(app => app.Id == id));
                    }

                    context.Appointment.RemoveRange(rangeToRemove);
                    context.SaveChanges();
                }
                SetDataGridItemSource();

                MessageBox.Show("Зустріч(і) були іспішно відхилені");
            }
            else
            {
                MessageBox.Show("Ви не обрали записи, які треба відмінити");
            }
        }
示例#3
0
 private void SetDateOfAbsent(DateTime date)
 {
     using (var context = new MedicalClinicContext())
     {
         context.Doctor.FirstOrDefault(doc => doc.Id == DoctorsId).AbsentDate = date;
         context.SaveChanges();
     }
 }
示例#4
0
        public void DeleteDateClick(object sender, RoutedEventArgs e)
        {
            using (var context = new MedicalClinicContext())
            {
                context.Doctor.FirstOrDefault(doc => doc.Id == DoctorsId).AbsentDate = null;
                context.SaveChanges();
            }

            MessageBox.Show("Дата була успішно видалена");
        }
示例#5
0
        private void AddPatient(string login, string pass, string name, string surname, string sex, DateTime?date, string email, string phone)
        {
            using (MedicalClinicContext context = new MedicalClinicContext())
            {
                Patient patient = new Patient();

                PersonalData patientPersonalData = new PersonalData();
                patientPersonalData.Name        = name;
                patientPersonalData.Surname     = surname;
                patientPersonalData.Sex         = sex;
                patientPersonalData.DateOfBirth = (DateTime)date;
                patientPersonalData.Email       = email;
                patientPersonalData.PhoneNumber = phone;

                context.PersonalData.Add(patientPersonalData);
                context.SaveChanges();

                User patientUser = new User();
                patientUser.Login    = login;
                patientUser.Password = pass;

                context.User.Add(patientUser);
                context.SaveChanges();

                Medcard patientMedcard = new Medcard();

                context.Medcard.Add(patientMedcard);
                context.SaveChanges();

                patient.Medcard      = patientMedcard;
                patient.User         = patientUser;
                patient.PersonalData = patientPersonalData;

                patient.MedcardId       = patientMedcard.Id;
                patient.UserId          = patientUser.Id;
                patient.PersonalData.Id = patientPersonalData.Id;

                context.Patient.Add(patient);
                context.SaveChanges();
            }
        }
示例#6
0
        public ResponseModel CreatePatient(Patient patient)
        {
            try
            {
                db.Patients.Add(patient);
                db.SaveChanges();

                return(new ResponseModel
                {
                    Result = OperationResult.Sucessful,
                    Message = "Patient Created"
                });
            }
            catch (Exception ex)
            {
                return(new ResponseModel
                {
                    Result = OperationResult.Failed,
                    Message = ex.Message
                });
            }
        }
示例#7
0
        public IHttpActionResult DeletePatient(int id)
        {
            Patient patient = db.Patients.Find(id);

            if (patient == null)
            {
                return(NotFound());
            }

            db.Patients.Remove(patient);
            db.SaveChanges();

            return(Ok(patient));
        }
示例#8
0
        private void AddAppointment(int doctorsId, int patientId, string description, DateTime dateOfMeeting, string timeOfMeeting)
        {
            using (MedicalClinicContext context = new MedicalClinicContext())
            {
                Appointment appointment = new Appointment();

                appointment.DoctorsId          = doctorsId;
                appointment.PatientId          = patientId;
                appointment.Description        = description;
                appointment.DateOfRegistration = DateTime.Now;
                appointment.DateTimeOfMeeting  = dateOfMeeting.AddHours(ParseTimeStringToInt(timeOfMeeting));

                context.Appointment.Add(appointment);
                context.SaveChanges();
            }
        }
示例#9
0
        private void DeleteAppointments(DateTime dateEnd)
        {
            using (var context = new MedicalClinicContext())
            {
                DateTime dateStart = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
                dateStart = dateStart.AddDays(1);

                List <Appointment> appointmnetsToDelete = context.Appointment
                                                          .Where(app => app.DateTimeOfMeeting > dateStart &&
                                                                 app.DateTimeOfMeeting < dateEnd).ToList();

                List <int> appointmentsId = appointmnetsToDelete.Select(app => app.Id).ToList();

                ShowPatients(appointmentsId);

                context.Appointment.RemoveRange(appointmnetsToDelete);
                context.SaveChanges();
            }
        }
        private void AddConclusion(string complaits,
                                   bool allergy, bool chd, bool convulsion, bool diabetes, bool onco,
                                   double bodyTemperature, string bloodPressure, int pulse, int respiratoryRate,
                                   string additionalInfo,
                                   string conclusionResult)
        {
            using (var context = new MedicalClinicContext())
            {
                Anamnesis anamnesis = new Anamnesis();
                anamnesis.Allergy     = allergy;
                anamnesis.CHD         = chd;
                anamnesis.Convulsions = convulsion;
                anamnesis.Diabetes    = diabetes;
                anamnesis.Onco        = onco;

                Examination examination = new Examination();
                examination.BodyTemperature = bodyTemperature;
                examination.BloodPressure   = bloodPressure;
                examination.Pulse           = pulse;
                examination.RespiratoryRate = respiratoryRate;

                Conclusion conclusion = new Conclusion();
                int        medcardId  = context.Appointment.FirstOrDefault(app => app.Id == appointmentId).Patient.Medcard.Id;
                conclusion.MedcardId        = medcardId;
                conclusion.AppointmentId    = appointmentId;
                conclusion.Сomplaints       = complaits;
                conclusion.AnamnesisId      = anamnesis.Id;
                conclusion.ExaminationId    = examination.Id;
                conclusion.AdditionalInfo   = additionalInfo;
                conclusion.ConclusionResult = conclusionResult;

                conclusion.Anamnesis   = anamnesis;
                conclusion.Examination = examination;

                context.Conclusion.Add(conclusion);
                context.SaveChanges();
            }
        }