Exemplo n.º 1
0
        public void Save_Outstanding_Case_Items_When_Scrutiny_Is_Confirmed_Returns_ExaminationID()
        {
            // Arrange
            var examinationId = Guid.NewGuid().ToString();
            var examination   = new MedicalExaminer.Models.Examination
            {
                ExaminationId = examinationId,
                MedicalTeam   = new MedicalExaminer.Models.MedicalTeam()
                {
                    MedicalExaminerOfficerUserId = "MedicalExaminerOfficerUserId",
                    MedicalExaminerUserId        = "MedicalExaminerUserId"
                },
                ScrutinyConfirmed = true
            };
            var connectionSettings = new Mock <IExaminationConnectionSettings>();
            var caseOutcome        = new MedicalExaminer.Models.CaseOutcome
            {
                MccdIssued          = true,
                CremationFormStatus = CremationFormStatus.Yes,
                GpNotifiedStatus    = GPNotified.GPNotified
            };
            var query    = new SaveOutstandingCaseItemsQuery(examinationId, caseOutcome, new MeUser());
            var dbAccess = new Mock <IDatabaseAccess>();

            dbAccess.Setup(db => db.GetItemByIdAsync <MedicalExaminer.Models.Examination>(
                               connectionSettings.Object,
                               It.IsAny <string>()))
            .Returns(Task.FromResult(examination)).Verifiable();

            dbAccess.Setup(db => db.UpdateItemAsync(
                               connectionSettings.Object,
                               It.IsAny <MedicalExaminer.Models.Examination>())).Returns(Task.FromResult(examination)).Verifiable();

            var sut = new SaveOutstandingCaseItemsService(dbAccess.Object, connectionSettings.Object, _urgencySettingsMock.Object);

            // Act
            var result = sut.Handle(query);

            // Assert
            Assert.NotNull(result.Result);
            Assert.True(examination.OutstandingCaseItemsCompleted);
            Assert.Equal(examinationId, result.Result);
        }
Exemplo n.º 2
0
        public void Confirmation_Of_Scrutiny_Marks_ScrutinyConfirmed_To_True_And_Returns_ScrutinyConfirmedOn_DateTime()
        {
            // Arrange
            var examinationId = Guid.NewGuid().ToString();
            var caseOutcome   = new MedicalExaminer.Models.CaseOutcome
            {
                ScrutinyConfirmedOn = null
            };
            var examination = new MedicalExaminer.Models.Examination
            {
                ExaminationId     = examinationId,
                ScrutinyConfirmed = false,
                CaseOutcome       = caseOutcome
            };
            var connectionSettings = new Mock <IExaminationConnectionSettings>();
            var query    = new ConfirmationOfScrutinyQuery(examinationId, new MeUser());
            var dbAccess = new Mock <IDatabaseAccess>();

            dbAccess.Setup(db => db.GetItemByIdAsync <MedicalExaminer.Models.Examination>(
                               connectionSettings.Object,
                               It.IsAny <string>()))
            .Returns(Task.FromResult(examination)).Verifiable();

            dbAccess.Setup(db => db.UpdateItemAsync(
                               connectionSettings.Object,
                               It.IsAny <MedicalExaminer.Models.Examination>())).Returns(Task.FromResult(examination)).Verifiable();

            var sut = new ConfirmationOfScrutinyService(dbAccess.Object, connectionSettings.Object, _urgencySettingsMock.Object);

            // Act
            var result = sut.Handle(query);

            // Assert
            Assert.NotNull(result.Result);
            Assert.True(examination.ScrutinyConfirmed);
            Assert.NotNull(examination.CaseOutcome.ScrutinyConfirmedOn);
        }
Exemplo n.º 3
0
        public void Close_Case_When_Outstanding_Case_Items_Completed_Marks_Examination_Completed_And_Returns_ExaminationID()
        {
            // Arrange
            var examinationId = Guid.NewGuid().ToString();
            var caseOutcome   = new MedicalExaminer.Models.CaseOutcome
            {
                CaseMedicalExaminerFullName       = "ME Full Name",
                ScrutinyConfirmedOn               = new DateTime(2019, 6, 20),
                OutcomeQapDiscussion              = QapDiscussionOutcome.MccdCauseOfDeathProvidedByQAP,
                OutcomeOfPrescrutiny              = OverallOutcomeOfPreScrutiny.IssueAnMccd,
                OutcomeOfRepresentativeDiscussion = BereavedDiscussionOutcome.CauseOfDeathAccepted,
                CaseCompleted       = false,
                CaseOutcomeSummary  = CaseOutcomeSummary.IssueMCCD,
                MccdIssued          = true,
                CremationFormStatus = CremationFormStatus.Yes,
                GpNotifiedStatus    = GPNotified.GPNotified,
                CoronerReferralSent = false
            };
            var examination = new MedicalExaminer.Models.Examination
            {
                ExaminationId                 = examinationId,
                ScrutinyConfirmed             = false,
                OutstandingCaseItemsCompleted = true,
                CaseOutcome = caseOutcome
            };
            var user = new MeUser
            {
                UserId    = "UserId",
                FirstName = "FirstName",
                LastName  = "LastName",
                GmcNumber = "GmcNumber"
            };
            var connectionSettings = new Mock <IExaminationConnectionSettings>();
            var query    = new CloseCaseQuery(examinationId, user);
            var dbAccess = new Mock <IDatabaseAccess>();

            dbAccess.Setup(db => db.GetItemByIdAsync <MedicalExaminer.Models.Examination>(
                               connectionSettings.Object,
                               It.IsAny <string>()))
            .Returns(Task.FromResult(examination)).Verifiable();

            dbAccess.Setup(db => db.UpdateItemAsync(
                               connectionSettings.Object,
                               It.IsAny <MedicalExaminer.Models.Examination>())).Returns(Task.FromResult(examination)).Verifiable();

            var sut = new CloseCaseService(dbAccess.Object, connectionSettings.Object, _urgencySettingsMock.Object);

            // Act
            var result = sut.Handle(query);

            // Assert
            Assert.NotNull(result.Result);
            Assert.True(examination.CaseCompleted);
            Assert.Equal(examinationId, result.Result);
            Assert.NotNull(examination.DateCaseClosed);
            Assert.Equal(DateTime.Now.Date, examination.DateCaseClosed.Value.Date);
            Assert.NotNull(examination.CaseBreakdown.CaseClosedEvent);
            Assert.Equal(user.FullName(), examination.CaseBreakdown.CaseClosedEvent.UserFullName);
            Assert.Equal(user.UserId, examination.CaseBreakdown.CaseClosedEvent.UserId);
            Assert.Equal(user.GmcNumber, examination.CaseBreakdown.CaseClosedEvent.GmcNumber);
        }