Example #1
0
 public List <Medicament> Medicaments(bool?isActive = true)
 {
     using (MsSqlHealthContext ctx = new MsSqlHealthContext())
     {
         return(ctx.Medicaments.Where(c => isActive == null || c.IsActive == isActive).ToList());
     }
 }
Example #2
0
 public Department Select(string name)
 {
     using (MsSqlHealthContext ctx = new MsSqlHealthContext())
     {
         return(ctx.Departments.FirstOrDefault(d => d.Name == name));
     }
 }
Example #3
0
        public Extensions.DataBaseResult Delete(int id)
        {
            using (MsSqlHealthContext ctx = new MsSqlHealthContext())
            {
                if (!ctx.ServerIsEnable)
                {
                    return(Extensions.DataBaseResult.ServerDisable);
                }

                Department department = ctx.Departments.FirstOrDefault(d => d.Id == id);

                if (department == null)
                {
                    return(Extensions.DataBaseResult.NotFound);
                }

                bool b = ctx.Doctors.Any(d => d.DepartmentId == id) || ctx.Diagnoses.Any(d => d.DepartmentId == id);

                if (b)
                {
                    return(Extensions.DataBaseResult.Referanced);
                }

                ctx.Departments.Remove(department);

                return(ctx.SaveChanges() > -1 ? Extensions.DataBaseResult.Success : Extensions.DataBaseResult.Error);
            }
        }
Example #4
0
 public Diagnosis Select(int id)
 {
     using (MsSqlHealthContext ctx = new MsSqlHealthContext())
     {
         return(ctx.Diagnoses.Include("Department").FirstOrDefault(d => d.Id == id));
     }
 }
Example #5
0
        public Extensions.DataBaseResult Update(Diagnosis newInfoDiagnosis)
        {
            using (MsSqlHealthContext ctx = new MsSqlHealthContext())
            {
                if (!ctx.ServerIsEnable)
                {
                    return(Extensions.DataBaseResult.ServerDisable);
                }

                if (ctx.Diagnoses.Any(d => d.Name == newInfoDiagnosis.Name && d.Id != newInfoDiagnosis.Id))
                {
                    return(Extensions.DataBaseResult.AlreadyFound);
                }

                Diagnosis diagnosis = ctx.Diagnoses.FirstOrDefault(d => d.Id == newInfoDiagnosis.Id);
                if (diagnosis == null)
                {
                    return(Extensions.DataBaseResult.NotFound);
                }

                diagnosis.Name     = newInfoDiagnosis.Name;
                diagnosis.IsActive = newInfoDiagnosis.IsActive;

                return(ctx.SaveChanges() > -1 ? Extensions.DataBaseResult.Success : Extensions.DataBaseResult.Error);
            }
        }
Example #6
0
 public DoctorMail Select(int id)
 {
     using (MsSqlHealthContext ctx = new MsSqlHealthContext())
     {
         return(ctx.DoctorMails.Include("Doctor").FirstOrDefault(d => d.Id == id));
     }
 }
 public LaboratoryItemUnit Select(int id)
 {
     using (MsSqlHealthContext ctx = new MsSqlHealthContext())
     {
         return(ctx.LaboratoryItemUnits.FirstOrDefault(d => d.Id == id));
     }
 }
Example #8
0
 public List <DoctorPhone> DoctorPhones(bool?isActive = true)
 {
     using (MsSqlHealthContext ctx = new MsSqlHealthContext())
     {
         return(ctx.DoctorPhones.Include("Doctor").ToList());
     }
 }
Example #9
0
 public BloodGroup Select(int id)
 {
     using (MsSqlHealthContext ctx = new MsSqlHealthContext())
     {
         return(ctx.BloodGroups.Include("Patients").FirstOrDefault(d => d.Id == id));
     }
 }
Example #10
0
 public List <Holiday> Holidays()
 {
     using (MsSqlHealthContext ctx = new MsSqlHealthContext())
     {
         return(ctx.Holidays.ToList());
     }
 }
Example #11
0
        public Extensions.DataBaseResult Update(Holiday newInfoHoliday)
        {
            using (MsSqlHealthContext ctx = new MsSqlHealthContext())
            {
                if (!ctx.ServerIsEnable)
                {
                    return(Extensions.DataBaseResult.ServerDisable);
                }

                if (ctx.Holidays.Any(d => d.Name == newInfoHoliday.Name))
                {
                    return(Extensions.DataBaseResult.AlreadyFound);
                }

                Holiday holiday = ctx.Holidays.FirstOrDefault(b => b.Id == newInfoHoliday.Id);

                if (holiday == null)
                {
                    return(Extensions.DataBaseResult.NotFound);
                }

                holiday.Name  = newInfoHoliday.Name;
                holiday.Year  = newInfoHoliday.Year;
                holiday.Month = newInfoHoliday.Month;
                holiday.Day   = newInfoHoliday.Day;
                return(ctx.SaveChanges() > -1 ? Extensions.DataBaseResult.Success : Extensions.DataBaseResult.Error);
            }
        }
Example #12
0
 public Holiday Select(int id)
 {
     using (MsSqlHealthContext ctx = new MsSqlHealthContext())
     {
         return(ctx.Holidays.FirstOrDefault(d => d.Id == id));
     }
 }
Example #13
0
        public Extensions.DataBaseResult Delete(int id)
        {
            using (MsSqlHealthContext ctx = new MsSqlHealthContext())
            {
                if (!ctx.ServerIsEnable)
                {
                    return(Extensions.DataBaseResult.ServerDisable);
                }

                Medicament medicament = ctx.Medicaments.FirstOrDefault(d => d.Id == id);
                if (medicament == null)
                {
                    return(Extensions.DataBaseResult.NotFound);
                }
                bool b = ctx.PrescriptionItems.Any(d => d.MedicamentId == id);

                if (b)
                {
                    return(Extensions.DataBaseResult.Referanced);
                }

                ctx.Medicaments.Remove(medicament);
                return(ctx.SaveChanges() > -1 ? Extensions.DataBaseResult.Success : Extensions.DataBaseResult.Error);
            }
        }
Example #14
0
        public Extensions.DataBaseResult Update(Medicament newInfoMedicament)
        {
            using (MsSqlHealthContext ctx = new MsSqlHealthContext())
            {
                if (!ctx.ServerIsEnable)
                {
                    return(Extensions.DataBaseResult.ServerDisable);
                }

                if (ctx.Departments.Any(d => d.Name == newInfoMedicament.Name && d.Id != newInfoMedicament.Id))
                {
                    return(Extensions.DataBaseResult.AlreadyFound);
                }

                Medicament medicament = ctx.Medicaments.FirstOrDefault(d => d.Id == newInfoMedicament.Id);

                if (medicament == null)
                {
                    return(Extensions.DataBaseResult.NotFound);
                }

                medicament.Name      = newInfoMedicament.Name;
                medicament.UsePerDay = newInfoMedicament.UsePerDay;
                medicament.Note      = newInfoMedicament.Note;
                medicament.IsActive  = newInfoMedicament.IsActive;

                return(ctx.SaveChanges() > -1 ? Extensions.DataBaseResult.Success : Extensions.DataBaseResult.Error);
            }
        }
Example #15
0
 public Patient Select(string tc)
 {
     using (MsSqlHealthContext ctx = new MsSqlHealthContext())
     {
         return(ctx.Patients.FirstOrDefault(p => p.TcNo == tc));
     }
 }
Example #16
0
 public List <BloodGroup> BloodGroups(bool?isActive = true)
 {
     using (MsSqlHealthContext ctx = new MsSqlHealthContext())
     {
         return(ctx.BloodGroups.Where(b => isActive == null || b.IsActive == isActive).ToList());
     }
 }
Example #17
0
        public Extensions.DataBaseResult Update(Patient newInfoPatient)
        {
            using (MsSqlHealthContext ctx = new MsSqlHealthContext())
            {
                if (!ctx.ServerIsEnable)
                {
                    return(Extensions.DataBaseResult.ServerDisable);
                }

                Patient patient = ctx.Patients.FirstOrDefault(d => d.Id == newInfoPatient.Id);
                if (patient == null)
                {
                    return(Extensions.DataBaseResult.NotFound);
                }

                patient.TcNo         = newInfoPatient.TcNo;
                patient.Name         = newInfoPatient.Name;
                patient.Surname      = newInfoPatient.Surname;
                patient.MotherName   = newInfoPatient.MotherName;
                patient.FatherName   = newInfoPatient.FatherName;
                patient.Address      = newInfoPatient.Address;
                patient.CityId       = newInfoPatient.CityId;
                patient.CountryId    = newInfoPatient.CountryId;
                patient.Phone        = newInfoPatient.Phone;
                patient.Mail         = newInfoPatient.Mail;
                patient.BirthDay     = newInfoPatient.BirthDay;
                patient.Gender       = newInfoPatient.Gender;
                patient.BloodGroupId = newInfoPatient.BloodGroupId;
                patient.IsActive     = newInfoPatient.IsActive;
                patient.Password     = newInfoPatient.Password;
                bool b = ctx.SaveChanges() > -1;
                return(b ? Extensions.DataBaseResult.Success : Extensions.DataBaseResult.Error);
            }
        }
 public List <Examination> Examinations(DateTime?time, int doctorId, int?patientId, bool?isActive = true,
                                        bool includeDiagnosis = false)
 {
     using (MsSqlHealthContext ctx = new MsSqlHealthContext())
     {
         return(includeDiagnosis
             ? ctx.Examinations.Include("Patient")
                .Include("Diagnosis")
                .Where(
                    c =>
                    (time == null ||
                     (c.Time.Year == time.Value.Year && c.Time.Month == time.Value.Month &&
                      c.Time.Day == time.Value.Day)) && (isActive == null || c.IsActive == isActive) &&
                    (c.DoctorId == doctorId) && (patientId == null || c.PatientId == patientId))
                .OrderBy(e => e.RendezvousId)
                .ToList()
             : ctx.Examinations.Include("Patient")
                .Where(
                    c =>
                    (time == null ||
                     (c.Time.Year == time.Value.Year && c.Time.Month == time.Value.Month &&
                      c.Time.Day == time.Value.Day)) && (isActive == null || c.IsActive == isActive) &&
                    (c.DoctorId == doctorId) && (patientId == null || c.PatientId == patientId))
                .OrderBy(e => e.RendezvousId)
                .ToList());
     }
 }
Example #19
0
 public List <DoctorMail> DoctorMails(bool?isActive = true)
 {
     using (MsSqlHealthContext ctx = new MsSqlHealthContext())
     {
         return(ctx.DoctorMails.Include("Doctor").Where(c => isActive == null || c.IsActive == isActive).ToList());
     }
 }
Example #20
0
 public RendezvousTime Select(int id)
 {
     using (MsSqlHealthContext ctx = new MsSqlHealthContext())
     {
         return(ctx.RendezvousTimes.FirstOrDefault(d => d.Id == id));
     }
 }
 public List <LaboratoryItemUnit> LaboratoryItemUnits(bool?isActive = true)
 {
     using (MsSqlHealthContext ctx = new MsSqlHealthContext())
     {
         return(ctx.LaboratoryItemUnits.Where(c => isActive == null || c.IsActive == isActive).ToList());
     }
 }
Example #22
0
 public List <RendezvousTime> RendezvousTimes(bool?isActive = true)
 {
     using (MsSqlHealthContext ctx = new MsSqlHealthContext())
     {
         return(ctx.RendezvousTimes.Where(c => isActive == null || c.IsActive == isActive).ToList());
     }
 }
Example #23
0
 public Diagnosis Select(string name)
 {
     using (MsSqlHealthContext ctx = new MsSqlHealthContext())
     {
         return(ctx.Diagnoses.Include("Department").FirstOrDefault(d => d.Name == name));
     }
 }
        public Extensions.DataBaseResult Delete(int id)
        {
            using (MsSqlHealthContext ctx = new MsSqlHealthContext())
            {
                if (!ctx.ServerIsEnable)
                {
                    return(Extensions.DataBaseResult.ServerDisable);
                }

                Doctor doctor = ctx.Doctors.FirstOrDefault(d => d.Id == id && d.IsActive);
                if (doctor == null)
                {
                    return(Extensions.DataBaseResult.NotFound);
                }

                bool b = ctx.Rendezvouses.Any(r => r.DoctorId == id && r.IsActive) ||
                         ctx.Examinations.Any(e => e.DoctorId == id && e.IsActive);
                if (b)
                {
                    return(Extensions.DataBaseResult.Referanced);
                }


                doctor.IsActive = false;
                return(ctx.SaveChanges() > -1 ? Extensions.DataBaseResult.Success : Extensions.DataBaseResult.Error);
            }
        }
Example #25
0
 public Department Select(int id)
 {
     using (MsSqlHealthContext ctx = new MsSqlHealthContext())
     {
         return(ctx.Departments.FirstOrDefault(d => d.Id == id));
     }
 }
        public Extensions.DataBaseResult Update(Doctor newInfoDoctor)
        {
            using (MsSqlHealthContext ctx = new MsSqlHealthContext())
            {
                if (!ctx.ServerIsEnable)
                {
                    return(Extensions.DataBaseResult.ServerDisable);
                }

                if (ctx.Doctors.Any(d => d.TcNo == newInfoDoctor.TcNo && d.Id != newInfoDoctor.Id))
                {
                    return(Extensions.DataBaseResult.AlreadyFound);
                }
                Doctor doctor = ctx.Doctors.FirstOrDefault(d => d.Id == newInfoDoctor.Id);
                if (doctor == null)
                {
                    return(Extensions.DataBaseResult.NotFound);
                }

                doctor.Name               = newInfoDoctor.Name;
                doctor.Surname            = newInfoDoctor.Surname;
                doctor.BirthDay           = newInfoDoctor.BirthDay;
                doctor.TcNo               = newInfoDoctor.TcNo;
                doctor.RegistrationNumber = newInfoDoctor.RegistrationNumber;
                doctor.DepartmentId       = newInfoDoctor.DepartmentId;
                doctor.DegreeId           = newInfoDoctor.DegreeId;
                doctor.MotherName         = newInfoDoctor.MotherName;
                doctor.FatherName         = newInfoDoctor.FatherName;
                doctor.IsActive           = newInfoDoctor.IsActive;
                doctor.Password           = newInfoDoctor.Password;
                return(ctx.SaveChanges() > -1 ? Extensions.DataBaseResult.Success : Extensions.DataBaseResult.Error);
            }
        }
Example #27
0
        public Extensions.DataBaseResult Update(Department newInfoDepartment)
        {
            using (MsSqlHealthContext ctx = new MsSqlHealthContext())
            {
                if (!ctx.ServerIsEnable)
                {
                    return(Extensions.DataBaseResult.ServerDisable);
                }

                if (ctx.Departments.Any(d => d.Name == newInfoDepartment.Name && d.Id != newInfoDepartment.Id))
                {
                    return(Extensions.DataBaseResult.AlreadyFound);
                }

                Department department = ctx.Departments.FirstOrDefault(d => d.Id == newInfoDepartment.Id);
                if (department == null)
                {
                    return(Extensions.DataBaseResult.NotFound);
                }

                department.Name     = newInfoDepartment.Name;
                department.IsActive = newInfoDepartment.IsActive;
                department.MinAge   = newInfoDepartment.MinAge;
                department.MaxAge   = newInfoDepartment.MaxAge;
                department.Gender   = newInfoDepartment.Gender;

                return(ctx.SaveChanges() > -1 ? Extensions.DataBaseResult.Success : Extensions.DataBaseResult.Error);
            }
        }
Example #28
0
        public Extensions.DataBaseResult Delete(int id)
        {
            using (MsSqlHealthContext ctx = new MsSqlHealthContext())
            {
                if (!ctx.ServerIsEnable)
                {
                    return(Extensions.DataBaseResult.ServerDisable);
                }

                Patient patient = ctx.Patients.FirstOrDefault(d => d.Id == id);
                if (patient == null)
                {
                    return(Extensions.DataBaseResult.NotFound);
                }

                bool b = ctx.Consultations.Any(d => d.PatientId == id) || ctx.Examinations.Any(d => d.PatientId == id) ||
                         ctx.Messages.Any(d => d.PatientId == id) || ctx.Rendezvouses.Any(d => d.PatientId == id);

                if (b)
                {
                    return(Extensions.DataBaseResult.Referanced);
                }

                ctx.Patients.Remove(patient);
                return(ctx.SaveChanges() > -1 ? Extensions.DataBaseResult.Success : Extensions.DataBaseResult.Error);
            }
        }
        public bool Update(Personnel newInfoPersonnel)
        {
            using (MsSqlHealthContext ctx = new MsSqlHealthContext())
            {
                Personnel personnel = ctx.Personnels.FirstOrDefault(d => d.Id == newInfoPersonnel.Id);
                if (personnel == null)
                {
                    return(false);
                }

                personnel.TcNo      = newInfoPersonnel.TcNo;
                personnel.Name      = newInfoPersonnel.Name;
                personnel.Surname   = newInfoPersonnel.Surname;
                personnel.Address   = newInfoPersonnel.Address;
                personnel.CityId    = newInfoPersonnel.CityId;
                personnel.CountryId = newInfoPersonnel.CountryId;
                personnel.Phone     = newInfoPersonnel.Phone;
                personnel.Mail      = newInfoPersonnel.Mail;
                personnel.BirthDay  = newInfoPersonnel.BirthDay;
                personnel.Gender    = newInfoPersonnel.Gender;
                personnel.City      = newInfoPersonnel.City;
                personnel.Country   = newInfoPersonnel.Country;
                personnel.IsActive  = newInfoPersonnel.IsActive;
                personnel.DegreeId  = newInfoPersonnel.DegreeId;
                return(ctx.SaveChanges() > -1);
            }
        }
        public Extensions.DataBaseResult Update(City newInfoCity)
        {
            using (MsSqlHealthContext ctx = new MsSqlHealthContext())
            {
                if (!ctx.ServerIsEnable)
                {
                    return(Extensions.DataBaseResult.ServerDisable);
                }

                if (ctx.Cities.Any(d => d.Name == newInfoCity.Name))
                {
                    return(Extensions.DataBaseResult.AlreadyFound);
                }
                City city = ctx.Cities.FirstOrDefault(b => b.Id == newInfoCity.Id);

                if (city == null)
                {
                    return(Extensions.DataBaseResult.NotFound);
                }

                city.Name     = newInfoCity.Name;
                city.IsActive = newInfoCity.IsActive;
                return(ctx.SaveChanges() > -1 ? Extensions.DataBaseResult.Success : Extensions.DataBaseResult.Error);
            }
        }