Exemple #1
0
 public void Add(Patient patient)
 {
     try
     {
         var memento = patient.GetMemento();
         _context.Add(new Backend.Model.Users.Patient()
         {
             Jmbg    = memento.Jmbg,
             Name    = memento.Name,
             Surname = memento.Surname,
             IsGuest = true
         });
         _context.SaveChanges();
         _context.Add(new Backend.Model.Users.PatientCard()
         {
             PatientJmbg    = memento.Jmbg,
             BloodType      = memento.BloodType.ToBackendBloodType(),
             RhFactor       = memento.RhFactor.ToBackendRhFactor(),
             Alergies       = memento.Allergies,
             MedicalHistory = memento.MedicalHistory,
             HasInsurance   = !String.IsNullOrWhiteSpace(memento.InsuranceNumber),
             Lbo            = memento.InsuranceNumber
         });
         _context.SaveChanges();
     }
     catch (PatientServiceException)
     {
         throw;
     }
     catch (DbUpdateException e)
     {
         throw new ValidationException(e.Message);
     }
     catch (Exception e)
     {
         throw new DataStorageException(e.Message);
     }
 }
Exemple #2
0
        private void SeedExaminations(MyDbContext context)
        {
            Doctor      doctor      = context.Doctors.Find("8520147896320");
            PatientCard patientCard = context.PatientCards.Find(2);
            Room        room        = context.Rooms.Where(r => r.Usage.Equals(TypeOfUsage.CONSULTING_ROOM)).First();

            DateTime start = DateTime.Now.Date.AddDays(10).AddHours(7);
            DateTime end   = DateTime.Now.Date.AddDays(13).AddHours(17);

            for (DateTime current = start; current < end; current = current.AddMinutes(30))
            {
                if (CheckIfTimeValid(current))
                {
                    int examinationId = context.Examinations.Count();
                    context.Add(new Examination
                    {
                        Type              = TypeOfExamination.GENERAL,
                        DoctorJmbg        = doctor.Jmbg,
                        IdPatientCard     = patientCard.Id,
                        IdRoom            = room.Id,
                        DateAndTime       = current,
                        IsSurveyCompleted = false,
                        ExaminationStatus = ExaminationStatus.CREATED
                    });

                    AddEquipmentInExamination(context, room.Id, examinationId);

                    continue;
                }
                current = new DateTime(current.Year, current.Month, current.Day, 6, 30, 0);
                current = current.AddDays(1);
            }
            context.Add(new Examination
            {
                Type              = TypeOfExamination.GENERAL,
                DoctorJmbg        = doctor.Jmbg,
                IdPatientCard     = patientCard.Id,
                IdRoom            = room.Id,
                DateAndTime       = DateTime.Now.Date.AddDays(-10).AddHours(8).AddMinutes(30),
                IsSurveyCompleted = false,
                ExaminationStatus = ExaminationStatus.CANCELED
            });
            context.Add(new Examination
            {
                Type              = TypeOfExamination.GENERAL,
                DoctorJmbg        = doctor.Jmbg,
                IdPatientCard     = patientCard.Id,
                IdRoom            = room.Id,
                DateAndTime       = DateTime.Now.Date.AddDays(-12).AddHours(10),
                IsSurveyCompleted = false,
                ExaminationStatus = ExaminationStatus.CANCELED
            });
            context.Add(new Examination
            {
                Type              = TypeOfExamination.GENERAL,
                DoctorJmbg        = doctor.Jmbg,
                IdPatientCard     = patientCard.Id,
                IdRoom            = room.Id,
                DateAndTime       = DateTime.Now.Date.AddDays(-15).AddHours(12).AddMinutes(30),
                IsSurveyCompleted = false,
                ExaminationStatus = ExaminationStatus.CANCELED
            });

            patientCard = context.PatientCards.Find(1);
            Doctor doctor1 = context.Doctors.Find("0606988520123");
            Doctor doctor2 = context.Doctors.Find("0323970501235");

            context.Add(new Examination
            {
                Type              = TypeOfExamination.GENERAL,
                DoctorJmbg        = doctor.Jmbg,
                IdPatientCard     = patientCard.Id,
                IdRoom            = room.Id,
                DateAndTime       = DateTime.Now.Date.AddDays(-15).AddHours(14),
                IsSurveyCompleted = true,
                ExaminationStatus = ExaminationStatus.FINISHED,
                Anamnesis         = "Sinuzitis"
            });
            context.Add(new Examination
            {
                Type              = TypeOfExamination.GENERAL,
                DoctorJmbg        = doctor1.Jmbg,
                IdPatientCard     = patientCard.Id,
                IdRoom            = room.Id,
                DateAndTime       = DateTime.Now.Date.AddDays(-10).AddHours(9).AddMinutes(30),
                IsSurveyCompleted = false,
                ExaminationStatus = ExaminationStatus.FINISHED,
                Anamnesis         = "Upala uha"
            });
            context.Add(new Examination
            {
                Type              = TypeOfExamination.GENERAL,
                DoctorJmbg        = doctor2.Jmbg,
                IdPatientCard     = patientCard.Id,
                IdRoom            = room.Id,
                DateAndTime       = DateTime.Now.Date.AddDays(-5).AddHours(11).AddMinutes(30),
                IsSurveyCompleted = false,
                ExaminationStatus = ExaminationStatus.FINISHED,
                Anamnesis         = "Upala pluća"
            });

            context.Add(new Examination
            {
                Type              = TypeOfExamination.GENERAL,
                DoctorJmbg        = doctor1.Jmbg,
                IdPatientCard     = patientCard.Id,
                IdRoom            = room.Id,
                DateAndTime       = DateTime.Now.Date.AddDays(1).AddHours(10).AddMinutes(30),
                IsSurveyCompleted = false,
                ExaminationStatus = ExaminationStatus.CREATED
            });
            context.Add(new Examination
            {
                Type              = TypeOfExamination.GENERAL,
                DoctorJmbg        = doctor.Jmbg,
                IdPatientCard     = patientCard.Id,
                IdRoom            = room.Id,
                DateAndTime       = DateTime.Now.Date.AddDays(13).AddHours(7),
                IsSurveyCompleted = false,
                ExaminationStatus = ExaminationStatus.CREATED
            });

            context.Add(new Examination
            {
                Type              = TypeOfExamination.GENERAL,
                DoctorJmbg        = doctor1.Jmbg,
                IdPatientCard     = patientCard.Id,
                IdRoom            = room.Id,
                DateAndTime       = DateTime.Now.Date.AddDays(-2).AddHours(10),
                IsSurveyCompleted = false,
                ExaminationStatus = ExaminationStatus.CANCELED
            });

            context.SaveChanges();
        }
Exemple #3
0
        public void SeedAll(MyDbContext context)
        {
            if (Verbose)
            {
                Console.WriteLine("Seeding countries.");
            }
            SeedCountries(context);
            if (Verbose)
            {
                Console.WriteLine("Seeding cities.");
            }
            SeedCities(context);
            if (Verbose)
            {
                Console.WriteLine("Seeding patients.");
            }
            SeedPatientsAndPatientsCard(context);
            if (Verbose)
            {
                Console.WriteLine("Seeding specialties.");
            }
            SeedSpecialties(context);
            if (Verbose)
            {
                Console.WriteLine("Seeding equipment.");
            }
            SeedEquipmentTypes(context);
            if (Verbose)
            {
                Console.WriteLine("Seeding rooms.");
            }
            SeedRooms(context);
            if (Verbose)
            {
                Console.WriteLine("Seeding doctors.");
            }
            SeedDoctors(context);
            if (Verbose)
            {
                Console.WriteLine("Seeding drugs.");
            }
            SeedDrugTypes(context);
            SeedDrugs(context);
            SeedDrugsInRooms(context);
            if (Verbose)
            {
                Console.WriteLine("Seeding examinations.");
            }
            SeedExaminations(context);
            if (Verbose)
            {
                Console.WriteLine("Seeding therapies.");
            }
            SeedTherapies(context);
            if (Verbose)
            {
                Console.WriteLine("Seeding pharmacies.");
            }
            SeedPharmacies(context);
            if (Verbose)
            {
                Console.WriteLine("Seeding drug consumptions.");
            }
            SeedDrugConsumptions(context);
            if (Verbose)
            {
                Console.WriteLine("Seeding feedback.");
            }
            SeedFeedback(context);
            if (Verbose)
            {
                Console.WriteLine("Seeding admins.");
            }
            SeedAdmins(context);
            if (Verbose)
            {
                Console.WriteLine("Seeding actions.");
            }
            SeedActionBenefits(context);
            if (Verbose)
            {
                Console.WriteLine("Seeding renovations.");
            }
            SeedRenovations(context);

            context.SaveChanges();
        }
Exemple #4
0
        private void SeedDoctors(MyDbContext context)
        {
            context.Add(new Doctor()
            {
                Jmbg             = "1234567891234",
                Name             = "Mira",
                Surname          = "Mirić",
                DateOfBirth      = new DateTime(1950, 11, 27),
                Phone            = "021457852",
                Email            = "*****@*****.**",
                HomeAddress      = "Maršala Tita 102",
                Username         = "******",
                DateOfEmployment = new DateTime(2018, 05, 06),
                CityZipCode      = 1,
                Gender           = GenderType.F,
                NumberOfLicence  = "11111111",
                Password         = "******",
                DoctorsOfficeId  = 9
            });
            context.Add(new Doctor()
            {
                Jmbg             = "8520147896320",
                Name             = "Dara",
                Surname          = "Darić",
                DateOfBirth      = new DateTime(1950, 11, 27),
                Phone            = "021457852",
                Email            = "*****@*****.**",
                HomeAddress      = "Maršala Tita 102",
                Username         = "******",
                DateOfEmployment = new DateTime(2010, 11, 15),
                CityZipCode      = 1,
                Gender           = GenderType.F,
                NumberOfLicence  = "22222222",
                Password         = "******",
                DoctorsOfficeId  = 12
            });
            context.Add(new Doctor()
            {
                Jmbg             = "0110983520145",
                Name             = "Miloš",
                Surname          = "Milošević",
                DateOfBirth      = new DateTime(1983, 01, 10),
                Phone            = "021852145",
                Email            = "*****@*****.**",
                HomeAddress      = "Balzakova 18",
                Username         = "******",
                DateOfEmployment = new DateTime(2019, 04, 30),
                CityZipCode      = 2,
                Gender           = GenderType.M,
                NumberOfLicence  = "11111111",
                Password         = "******",
                DoctorsOfficeId  = 20
            });
            context.Add(new Doctor()
            {
                Jmbg             = "0323970501235",
                Name             = "Žika",
                Surname          = "Žikić",
                DateOfBirth      = new DateTime(1970, 03, 23),
                Phone            = "021752032",
                Email            = "*****@*****.**",
                HomeAddress      = "Narodnog Fronta 7",
                Username         = "******",
                DateOfEmployment = new DateTime(2008, 10, 01),
                CityZipCode      = 2,
                Gender           = GenderType.M,
                NumberOfLicence  = "11111111",
                Password         = "******",
                DoctorsOfficeId  = 25
            });
            context.Add(new Doctor()
            {
                Jmbg             = "0606988520123",
                Name             = "Marija",
                Surname          = "Marić",
                DateOfBirth      = new DateTime(1988, 06, 06),
                Phone            = "021954201",
                Email            = "*****@*****.**",
                HomeAddress      = "Narodnog Fronta 45",
                Username         = "******",
                DateOfEmployment = new DateTime(2020, 02, 05),
                CityZipCode      = 1,
                Gender           = GenderType.F,
                NumberOfLicence  = "11111111",
                Password         = "******",
                DoctorsOfficeId  = 49
            });
            context.Add(new Doctor()
            {
                Jmbg             = "2007975521021",
                Name             = "Sara",
                Surname          = "Sarić",
                DateOfBirth      = new DateTime(1975, 07, 20),
                Phone            = "021954201",
                Email            = "*****@*****.**",
                HomeAddress      = "Futoška 5",
                Username         = "******",
                DateOfEmployment = new DateTime(2018, 05, 11),
                CityZipCode      = 2,
                Gender           = GenderType.F,
                NumberOfLicence  = "11111111",
                Password         = "******",
                DoctorsOfficeId  = 51
            });


            context.SaveChanges();

            context.Add(new DoctorSpecialty()
            {
                DoctorJmbg = "8520147896320", SpecialtyId = 1
            });
            context.Add(new DoctorSpecialty()
            {
                DoctorJmbg = "0110983520145", SpecialtyId = 1
            });
            context.Add(new DoctorSpecialty()
            {
                DoctorJmbg = "1234567891234", SpecialtyId = 2
            });
            context.Add(new DoctorSpecialty()
            {
                DoctorJmbg = "0323970501235", SpecialtyId = 2
            });
            context.Add(new DoctorSpecialty()
            {
                DoctorJmbg = "0606988520123", SpecialtyId = 3
            });
            context.Add(new DoctorSpecialty()
            {
                DoctorJmbg = "2007975521021", SpecialtyId = 4
            });
            context.SaveChanges();
        }