Beispiel #1
0
            public void SinglePatientVisit()
            {
                //Arrange
                Patient patient = new Patient()
                {
                    Id = 5
                };
                Visit visit1 = new Visit()
                {
                    Patient = patient
                };

                Mock <IDataStorage> dataStorage = new Mock <IDataStorage>();

                dataStorage.Setup(ds => ds.GetData <Visit>()).Returns(new List <Visit> {
                    visit1
                });
                VisitRepository repository = new VisitRepository(dataStorage.Object);
                //Act
                IList <Visit> result = repository.GetVisitsForPatient(patient.Id);

                //Assert
                Assert.That(result, Is.Not.Null);
                Assert.That(result.Count, Is.EqualTo(1));
                Assert.That(result[0], Is.EqualTo(visit1));
            }
Beispiel #2
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);
        }
            public void SinglePatientVisit()
            {
                //Arrange
                Patient patient = new Patient() {Id = 5};
                Visit visit1 = new Visit() {Patient = patient};

                Mock<IDataStorage> dataStorage = new Mock<IDataStorage>();
                dataStorage.Setup(ds => ds.GetData<Visit>()).Returns(new List<Visit> {visit1});
                VisitRepository repository = new VisitRepository(dataStorage.Object);
                //Act
                IList<Visit> result = repository.GetVisitsForPatient(patient.Id);

                //Assert
                Assert.That(result, Is.Not.Null);
                Assert.That(result.Count, Is.EqualTo(1));
                Assert.That(result[0], Is.EqualTo(visit1));
            }