예제 #1
0
        public ActionResult DeallocateTeamMember(Guid patientId, Guid userId)
        {
            _patientService.DeallocateTeamMember(patientId, userId);

            return(RedirectToAction("Edit", "Patient", new
            {
                patientId = patientId
            }));
        }
예제 #2
0
        public void DeallocateTeamMember_GivenNoDischargeTypeId_WhereDischaringLastTeamMember()
        {
            // Arrange
            var               connection        = GetConnection();
            ListRepository    listRepository    = new ListRepository(connection);
            PatientRepository patientRepository = new PatientRepository(connection);

            PatientService patientService = new PatientService(connection);

            Patient patient = new Patient()
            {
                Firstname   = _nameDataSet.FirstName(),
                Lastname    = _nameDataSet.LastName(),
                DateOfBirth = _dateDataSet.Past()
            };

            Guid patientId  = patientService.Create(patient);
            Guid facilityId = listRepository.GetFacilities().First(x => x.Name == "Tijger Mental Health Clinic Loevenstein").Id;

            Guid[] userIds         = listRepository.GetFacilityUsers(facilityId).Select(x => x.Id).ToArray();
            Guid   admissionTypeId = listRepository.GetAdmissionTypes().First().Id;

            TeamMember teamMember = new TeamMember()
            {
                FacilityId                  = facilityId,
                PatientId                   = patientId,
                ReasonForAdmissionName      = "G46.4 - Cerebellar stroke syndrome (I60-I67+)",
                ReasonForAdmissionTimestamp = _dateDataSet.Past(),
                AdmissionTypeId             = admissionTypeId,
                UserIds = userIds
            };

            patientService.AllocateTeamMember(teamMember);

            try
            {
                foreach (var item in userIds.Skip(1))
                {
                    patientService.DeallocateTeamMember(patientId, item);
                }
            }catch (Exception ex)
            {
                throw;
            }

            // Act
            patientService.DeallocateTeamMember(patientId, userIds.First());


            // Assert
        }
예제 #3
0
        public void FindCompletedEpisodesOfCare()
        {
            // Arrange
            var               connection        = GetConnection();
            ListRepository    listRepository    = new ListRepository(connection);
            PatientRepository patientRepository = new PatientRepository(connection);

            PatientService patientService = new PatientService(connection);

            Patient patient = new Patient()
            {
                Firstname   = _nameDataSet.FirstName(),
                Lastname    = _nameDataSet.LastName(),
                DateOfBirth = _dateDataSet.Past()
            };

            Guid patientId  = patientService.Create(patient);
            Guid facilityId = listRepository.GetFacilities().First(x => x.Name == "Tijger Mental Health Clinic Loevenstein").Id;

            Guid[] userIds         = listRepository.GetFacilityUsers(facilityId).Select(x => x.Id).ToArray();
            Guid   admissionTypeId = listRepository.GetAdmissionTypes().First().Id;
            Guid   dischargeTypeId = listRepository.GetDischargeTypes().First().Id;

            userIds = Shuffle <Guid>(userIds, _random).ToArray();

            TeamMember teamMember1 = new TeamMember()
            {
                FacilityId                  = facilityId,
                PatientId                   = patientId,
                ReasonForAdmissionName      = "G46.4 - Cerebellar stroke syndrome (I60-I67+)",
                ReasonForAdmissionTimestamp = _dateDataSet.Past(),
                AdmissionTypeId             = admissionTypeId,
                UserIds = userIds.Take(1).ToArray()
            };

            patientService.AllocateTeamMember(teamMember1);

            TeamMember teamMember2 = new TeamMember()
            {
                FacilityId = facilityId,
                PatientId  = patientId,
                UserIds    = userIds.Skip(1).ToArray()
            };

            patientService.AllocateTeamMember(teamMember2);


            userIds = Shuffle <Guid>(userIds, _random).ToArray();

            try
            {
                foreach (var item in userIds.Skip(1))
                {
                    patientService.DeallocateTeamMember(patientId, item, null, null, null);
                }
            }
            catch (Exception ex)
            {
                throw;
            }

            patientService.DeallocateTeamMember(patientId, userIds.First(), dischargeTypeId, null, null);


            ////
            Thread.Sleep(5000);

            userIds = Shuffle <Guid>(userIds, _random).ToArray();

            TeamMember teamMember3 = new TeamMember()
            {
                FacilityId                  = facilityId,
                PatientId                   = patientId,
                ReasonForAdmissionName      = "G46.4 - Cerebellar stroke syndrome (I60-I67+)",
                ReasonForAdmissionTimestamp = _dateDataSet.Past(),
                AdmissionTypeId             = admissionTypeId,
                UserIds = userIds.Take(1).ToArray()
            };

            patientService.AllocateTeamMember(teamMember1);

            TeamMember teamMember4 = new TeamMember()
            {
                FacilityId = facilityId,
                PatientId  = patientId,
                UserIds    = userIds.Skip(1).ToArray()
            };

            patientService.AllocateTeamMember(teamMember2);


            userIds = Shuffle <Guid>(userIds, _random).ToArray();

            try
            {
                foreach (var item in userIds.Skip(1))
                {
                    patientService.DeallocateTeamMember(patientId, item);
                }
            }
            catch (Exception ex)
            {
                throw;
            }

            patientService.DeallocateTeamMember(patientId, userIds.First(), dischargeTypeId, null, null);

            //////

            // Act
            var result = patientRepository.FindCompletedEpisodesOfCare(patientId, facilityId);


            // Assert
            Assert.Equals(2, result.Count);
        }