Example #1
0
        public void Add_should_be_able_to_visit()
        {
            var visit = CreateVisit("a");

            Database.Add(visit.Alias.ShortUrl);
            Database.Add(visit.Alias);

            repository.Add(visit);

            Assert.True(visit.Id >= 0);
        }
Example #2
0
        public Patient CreatePatient(User doctor)
        {
            var patient = new Patient();

            PatientRepository.Add(patient);

            //verify that patient number is unique
            //if it is not, then assign unique number
            var maxNumber = PatientRepository.GetMaxPatientNumber();

            patient.PatientNumber = maxNumber + 1;
            patient.Caption       = string.Format("Subj {0}{1:D3}", "A", patient.PatientNumber);
            patient.Doctor        = doctor;
            doctor.Patients.Add(patient);

            patient.Visits = new List <Visit>();
            patient.Visits.Add(CreateBaselineVisit(patient));
            patient.Visits.Add(Create1stDayVisit(patient));
            patient.Visits.Add(Create10thDayVisit(patient));
            foreach (var visit in patient.Visits)
            {
                VisitRepository.Add(visit);
                foreach (var form in visit.Forms)
                {
                    FormRepository.Add(form);
                }
            }

            return(patient);
        }
Example #3
0
        public void IsMatching_should_return_correct_value(string alias, string expression, int expectedCount, bool useCaseSensitive)
        {
            var queryFactory = new QueryFactory(useCaseSensitive);

            Visit visit = CreateVisit(alias);

            Database.Add(visit.Alias.ShortUrl);
            Database.Add(visit.Alias);

            var repo = new VisitRepository(DatabaseFactory, queryFactory);

            repo.Add(visit);

            int count = repo.Count(expression);

            Assert.Equal(expectedCount, count);
        }
Example #4
0
        public Visit AddAdverseEventVisit(int patientId)
        {
            var patient = PatientRepository.GetByKey(patientId);

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

            var existingVisits     = VisitRepository.GetVisitsForPatient(patientId);
            var maxVisitOrderNo    = existingVisits.Max(v => v.OrderNo);
            var adverseEventsCount = existingVisits.Count(v => v.VisitType == VisitType.AdverseEventVisit);
            var caption            = "Adverse Event";

            if (adverseEventsCount > 0)
            {
                caption = string.Format("{0} {1}", caption, adverseEventsCount + 1);
            }


            var aeVisit = new Visit {
                Caption           = caption,
                ExpectedVisitDate = null,
                VisitDate         = DateTime.Today.Date,
                OrderNo           = maxVisitOrderNo + 1,
                VisitType         = VisitType.AdverseEventVisit,
                Patient           = patient
            };

            VisitRepository.Add(aeVisit);
            patient.Visits.Add(aeVisit);

            AddAdverseEventForm(aeVisit);

            VisitRepository.Save();
            return(aeVisit);
        }
Example #5
0
        private void buttonAddVisit_Click(object sender, EventArgs e)
        {
            if (comboBoxVets.SelectedItem == null ||
                comboBoxOwnersFromVisit.SelectedItem == null ||
                comboBoxAnimals.SelectedItem == null)
            {
                return;
            }


            int ownerId  = ((Owner)comboBoxOwnersFromVisit.SelectedItem).Id;
            int vetId    = ((Vet)comboBoxVets.SelectedItem).Id;
            int animalId = ((Animal)comboBoxAnimals.SelectedItem).Id;

            int cost = 0;

            try
            {
                cost = Int32.Parse(textBoxVisitCost.Text);
            }
            catch (Exception)
            {
                MessageBox.Show("Zły format ceny");
            }


            Visit newVisit = new Visit
            {
                Description = textBoxVisitDescription.Text,
                Cost        = cost,
                Date        = dateTimePickerAnimalDate.Value,
                OwnerId     = ownerId,
                VetId       = vetId,
                AnimalId    = animalId
            };

            textBoxVisitDescription.Text = "";
            textBoxVisitCost.Text        = "";
            dateTimePickerVisitData.Text = "";

            using (RepositoryContext db = new RepositoryContext("RepositoryContext"))
            {
                AnimalRepository animalRepo = new AnimalRepository(db);
                OwnerRepository  ownerRepo  = new OwnerRepository(db);
                VetRepository    vetRepo    = new VetRepository(db);
                VisitRepository  visitRepo  = new VisitRepository(db);

                var owner  = ownerRepo.GetById(ownerId);
                var vet    = vetRepo.GetById(vetId);
                var animal = animalRepo.GetById(animalId);

                newVisit.Owner  = owner;
                newVisit.Vet    = vet;
                newVisit.Animal = animal;

                var visit = visitRepo.Add(newVisit);
                visitRepo.SaveChanges();
            }


            GetData();
        }