public void MODCRStudyTeamOnlyCreationThroughNonCommitteeReviewWithModificationsRequiredToApproved()
        {
            string targetStudy = "AutoTest-" + DataGen.String(5);
            EntityClonerUtil.CloneEntity("STUDY00000024", targetStudy, true);

            var CRSmartForm = new InitialModCrSmartForm();
            var StudySF = new InitialStudySmartForm();
            var workspace = new IRBWorkspace();
            var irbSubmissionsPage = new IRBSubmissions();
            var actionsNav = new ActionsNav();

            // Log in as the PI and go to the IRB/Active tab and select an Approved study, Create Modification/CR ,
            // select “Modification and Continuing” and “Other parts of the study”.  Make changes to one or more views of the study.
            Store.LoginAsUser(Users.Pi);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(targetStudy);
            actionsNav.ImgCreateModCr.Click();

            // Fill in just required info
            CRSmartForm.ChooseModCRPurpose(SubmissionPurpose.ModAndCR);
            CRSmartForm.ChooseModificationScope(Scope.StudyTeamMemberInformation);
            CRSmartForm.BtnContinue.Click();
            CRSmartForm.SpecifyEnrollmentTotals("2", "2", "1");
            CRSmartForm.ChooseResearchMilestone(InitialModCrSmartForm.MileStones.StudyPermanentlyClosedToEnrollment, InitialModCrSmartForm.MileStones.AllSubjectCompletedStudyRelatedInterventions,
                InitialModCrSmartForm.MileStones.CollectionOfPrivateInfoComplete, InitialModCrSmartForm.MileStones.AnalysisOfPrivateInfoComplete);
            CRSmartForm.RdoFinancialInterestNo.Click();
            CRSmartForm.BtnContinue.Click();

            // Modification Page
            CRSmartForm.TxtSummarizeModifications.Value = "These are the new modifications!  :/ :) :P";
            CRSmartForm.BtnContinue.Click();

            // Add a study team member, save, exit
            StudySF.StudyTeamMembersPage.AddStudyTeamMember(false, false, "", AddStudyTeamMemberPopup.Roles.CoInvestigator);
            StudySF.LnkSave.Click();
            StudySF.LnkExit.Click();

            //As the PI, Submit the Mod.
            workspace.Submit(Users.Pi.UserName, Users.Pi.Password);
            Assert.IsTrue(new Link(By.LinkText("Submitted")).Exists, "'Submitted' activity not found for:  " + targetStudy);
            Assert.IsTrue(workspace.GetStudyState() == "Pre-Review", "State expected not in 'Pre-Review'.  State currently: " + workspace.GetStudyState());
            var CRName = Web.PortalDriver.Title;

            //Log in as the assigned coordinator and Submit Pre-Review
            Store.LoginAsUser(Users.Irbc);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(CRName);
            workspace.SubmitPreReviewForCR();

            // As the assigned IRBC, Assign Designated Reviewer.
            Store.LoginAsUser(Users.Irbc);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(CRName);
            workspace.AssignDesignatedReviewer("Harry Smith (comm4)");
            Assert.IsTrue(workspace.GetStudyState() == "Non-Committee Review", "State expected not in 'Non-Committee Review'.  State currently:  " + workspace.GetStudyState());

            // Log in as the Designated Reviewer and Submit Designated Review approved.
            Store.LoginAsUser(Users.Comm4);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(CRName);
            workspace.SubmitDesignatedReviewForStudy(SubmitDesignatedReview.StudyDeterminations.ModificationsRequiredToSecureApproved, "These are modifications required:  :/", true);
            Assert.IsTrue(workspace.GetStudyState() == "Post-Review", "State expected not in 'Post-Review'.  State currently:  " + workspace.GetStudyState());

            // As the assigned IRB Coordinator, Finalize Documents.
            Store.LoginAsUser(Users.Irbc);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(CRName);
            workspace.FinalizeDocuments();
            Assert.IsTrue(workspace.GetStudyState() == "Post-Review", "State expected not in 'Post-Review'.  State currently:  " + workspace.GetStudyState());

            //As the assigned coordinator, Prepare Letter.
            workspace.PrepareLetter();
            Assert.IsTrue(workspace.GetStudyState() == "Post-Review", "State expected not in 'Post-Review'.  State currently:  " + workspace.GetStudyState());

            // As the assigned coordinator, Send Letter.
            workspace.SendLetter();
            Assert.IsTrue(workspace.GetStudyState() == "Modifications Required", "State expected not in 'Modifications Required'.  State currently:  " + workspace.GetStudyState());

            // Log in as the PI and Submit Response.
            Store.LoginAsUser(Users.Pi);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(CRName);
            workspace.SubmitResponse(Users.Pi.UserName, Users.Pi.Password, "This is my response!  :P");
            Assert.IsTrue(workspace.GetStudyState() == "Modifications Submitted", "State expected not in 'Modifications Submitted'.  State currently:  " + workspace.GetStudyState());

            // Log in as the assigned IRB Coordinator, Review Required Modifications (Yes to the question “Were the modifications completed as required?” “yes” response)
            Store.LoginAsUser(Users.Irbc);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(CRName);
            workspace.ReviewRequiredModifications();
            Assert.IsTrue(workspace.GetStudyState() == "Post-Review", "State expected not in 'Post-Review'.  State currently:  " + workspace.GetStudyState());

            //As the assigned coordinator, Prepare Letter.
            workspace.PrepareLetter();
            Assert.IsTrue(workspace.GetStudyState() == "Post-Review", "State expected not in 'Post-Review'.  State currently:  " + workspace.GetStudyState());

            // As the assigned coordinator, Send Letter.
            workspace.SendLetter();
            Assert.IsTrue(workspace.GetStudyState() == "Approved", "State expected not in 'Approved'.  State currently:  " + workspace.GetStudyState());
        }
        public void ModificationOtherPartsOfStudyCreationThroughCommitteeReviewDeferred()
        {
            string targetStudy = "AutoTest-" + DataGen.String(5);
            EntityClonerUtil.CloneEntity("STUDY00000024", targetStudy, true);

            var CRSmartForm = new InitialModCrSmartForm();
            var StudySF = new InitialStudySmartForm();
            var workspace = new IRBWorkspace();
            var irbSubmissionsPage = new IRBSubmissions();
            var actionsNav = new ActionsNav();

            // Log in as the PI and go to the IRB/Active tab and select an Approved study, Create Modification/CR ,
            // select “Modification and Continuing” and “Other parts of the study”.  Make changes to one or more views of the study.
            Store.LoginAsUser(Users.Pi);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(targetStudy);
            actionsNav.ImgCreateModCr.Click();

            // Fill in just required info
            CRSmartForm.ChooseModCRPurpose(SubmissionPurpose.Modification);
            CRSmartForm.ChooseModificationScope(Scope.OtherPartsOfTheStudy);
            CRSmartForm.BtnContinue.Click();

            // Modification Page
            CRSmartForm.TxtSummarizeModifications.Value = "These are the new modifications!  :/ :) :P";
            CRSmartForm.BtnContinue.Click();

            StudySF.NewSubmissionSmartformPage.TxtDescription.Value = "This is a modified description for this test.";
            StudySF.LnkSave.Click();
            StudySF.LnkExit.Click();

            //As the PI, Submit.
            workspace.Submit(Users.Pi.UserName, Users.Pi.Password);
            Assert.IsTrue(new Link(By.LinkText("Submitted")).Exists, "'Submitted' activity not found for:  " + targetStudy);
            Assert.IsTrue(workspace.GetStudyState() == "Pre-Review", "State expected not in 'Pre-Review'.  State currently: " + workspace.GetStudyState());
            var CRName = Web.PortalDriver.Title;

            //Log in as the assigned coordinator and Submit Pre-Review
            Store.LoginAsUser(Users.Irbc);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(CRName);
            workspace.SubmitPreReviewForCR();
            Assert.IsTrue(workspace.GetStudyState() == "Pre-Review Completed", "State expected not in 'Pre-Review Completed'.  State currently:  " + workspace.GetStudyState());

            //As the assigned coordinator, Assign Meeting.
            workspace.AssignMeetingByFirstMeeting();
            Assert.IsTrue(workspace.GetStudyState() == "Committee Review", "State expected not in 'Committee Review'.  State currently:  " + workspace.GetStudyState());

            //As the assigned coordinator, Submit Committee Review (approved determination).
            // need determination, risk level
            workspace.SubmitCommitteeReview(SubmitCommitteeReviewPopup.Determinations.Deferred, "modification comments", "2", "0", "0", "0", "0", "", true);
            Assert.IsTrue(workspace.GetStudyState() == "Post-Review", "State expected not in 'Post-Review'.  State currently:  " + workspace.GetStudyState());

            // As the assigned IRB Coordinator, Finalize Documents.
            workspace.FinalizeDocuments();
            Assert.IsTrue(workspace.GetStudyState() == "Post-Review", "State expected not in 'Post-Review'.  State currently:  " + workspace.GetStudyState());

            //As the assigned coordinator, Prepare Letter.
            workspace.PrepareLetter();
            Assert.IsTrue(workspace.GetStudyState() == "Post-Review", "State expected not in 'Post-Review'.  State currently:  " + workspace.GetStudyState());

            // As the assigned coordinator, Send Letter.
            workspace.SendLetter();
            Assert.IsTrue(workspace.GetStudyState() == "Deferred", "State expected not in 'Deferred'.  State currently:  " + workspace.GetStudyState());
        }
        public void MODCRStudyTeamOnlyCreationThroughCommitteeReviewToDeferred()
        {
            string targetStudy = "AutoTest-" + DataGen.String(5);
            EntityClonerUtil.CloneEntity("STUDY00000024", targetStudy, true);

            var CRSmartForm = new InitialModCrSmartForm();
            var StudySF = new InitialStudySmartForm();
            var workspace = new IRBWorkspace();
            var irbSubmissionsPage = new IRBSubmissions();
            var actionsNav = new ActionsNav();

            // Log in as the PI and go to the IRB/Active tab and select an Approved study, Create Modification/CR ,
            // select “Modification and Continuing” and “Other parts of the study”.  Make changes to one or more views of the study.
            Store.LoginAsUser(Users.Pi);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(targetStudy);
            actionsNav.ImgCreateModCr.Click();

            // Fill in just required info
            CRSmartForm.ChooseModCRPurpose(SubmissionPurpose.ModAndCR);
            CRSmartForm.ChooseModificationScope(Scope.StudyTeamMemberInformation);
            CRSmartForm.BtnContinue.Click();
            CRSmartForm.SpecifyEnrollmentTotals("2", "2", "1");
            CRSmartForm.ChooseResearchMilestone(InitialModCrSmartForm.MileStones.StudyPermanentlyClosedToEnrollment, InitialModCrSmartForm.MileStones.AllSubjectCompletedStudyRelatedInterventions,
                InitialModCrSmartForm.MileStones.CollectionOfPrivateInfoComplete, InitialModCrSmartForm.MileStones.AnalysisOfPrivateInfoComplete);
            CRSmartForm.RdoFinancialInterestNo.Click();
            CRSmartForm.BtnContinue.Click();

            // Modification Page
            CRSmartForm.TxtSummarizeModifications.Value = "These are the new modifications!  :/ :) :P";
            CRSmartForm.BtnContinue.Click();

            // Add a study team member, save, exit
            //StudySF.StudyTeamMembersPage.AddStudyTeamMember("Czerch (comm2)", false, false, AddStudyTeamMemberPopup.Roles.CoInvestigator);
            // test to see if "" selects first value...
            StudySF.StudyTeamMembersPage.AddStudyTeamMember(false, false, "", AddStudyTeamMemberPopup.Roles.CoInvestigator);
            StudySF.LnkSave.Click();
            StudySF.LnkExit.Click();

            //As the PI, Submit.
            workspace.Submit(Users.Pi.UserName, Users.Pi.Password);
            Assert.IsTrue(new Link(By.LinkText("Submitted")).Exists, "'Submitted' activity not found for:  " + targetStudy);
            Assert.IsTrue(workspace.GetStudyState() == "Pre-Review", "State expected not in 'Pre-Review'.  State currently: " + workspace.GetStudyState());
            var CRName = Web.PortalDriver.Title;

            //Log in as the assigned coordinator and Submit Pre-Review
            Store.LoginAsUser(Users.Irbc);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(CRName);
            workspace.SubmitPreReviewForCR();
            Assert.IsTrue(workspace.GetStudyState() == "Pre-Review Completed", "State expected not in 'Pre-Review Completed'.  State currently:  " + workspace.GetStudyState());

            // Log in as an IRB coordinator and Assign Coordinator
            Store.LoginAsUser(Users.Irbc);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(CRName);
            workspace.AssignCoordinator("Orlando Max (irbc)");

            //As the assigned coordinator, Assign Meeting.
            workspace.AssignMeetingByFirstMeeting();
            Assert.IsTrue(workspace.GetStudyState() == "Committee Review");

            //As the assigned coordinator, Submit Committee Review (approved determination).
            // need determination, risk level
            workspace.SubmitCommitteeReview(SubmitCommitteeReviewPopup.Determinations.Deferred, "2", "0", "0", "0", "0", "", true);
            Assert.IsTrue(workspace.GetStudyState() == "Post-Review", "State expected not in 'Post-Review'.  State currently:  " + workspace.GetStudyState());

            // As the assigned IRB Coordinator, Finalize Documents.
            workspace.FinalizeDocuments();
            Assert.IsTrue(workspace.GetStudyState() == "Post-Review", "State expected not in 'Post-Review'.  State currently:  " + workspace.GetStudyState());

            //As the assigned coordinator, Prepare Letter.
            workspace.PrepareLetter();
            Assert.IsTrue(workspace.GetStudyState() == "Post-Review", "State expected not in 'Post-Review'.  State currently:  " + workspace.GetStudyState());

            // As the assigned coordinator, Send Letter.
            workspace.SendLetter();
            Assert.IsTrue(workspace.GetStudyState() == "Deferred", "State expected not in 'Deferred'.  State currently:  " + workspace.GetStudyState());
        }
        public void ModificationStudyTeamOnlyCreationThroughCR_Disapproved()
        {
            string targetStudy = "AutoTest-" + DataGen.String(5);
            EntityClonerUtil.CloneEntity("STUDY00000024", targetStudy, true);

            var CRSmartForm = new InitialModCrSmartForm();
            var StudySF = new InitialStudySmartForm();
            var workspace = new IRBWorkspace();
            var irbSubmissionsPage = new IRBSubmissions();
            var actionsNav = new ActionsNav();

            // Log in as the PI and go to the IRB/Active tab and select an Approved study, Create Modification/CR , select “Modification” and “Study team member information”.
            // Change some aspect of the Study Team member form.
            Store.LoginAsUser(Users.Pi);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(targetStudy);
            actionsNav.ImgCreateModCr.Click();

            // Fill in just required info
            CRSmartForm.ChooseModCRPurpose(SubmissionPurpose.Modification);
            CRSmartForm.ChooseModificationScope(Scope.StudyTeamMemberInformation);
            CRSmartForm.BtnContinue.Click();
            // Modification Page
            CRSmartForm.TxtSummarizeModifications.Value = "These are the new modifications!  :/ :) :P";
            CRSmartForm.BtnContinue.Click();
            // Add a study team member, save, exit
            StudySF.StudyTeamMembersPage.AddStudyTeamMember(false, false, "", AddStudyTeamMemberPopup.Roles.CoInvestigator);
            StudySF.LnkSave.Click();
            StudySF.LnkExit.Click();

            //As the PI, Submit.
            workspace.Submit(Users.Pi.UserName, Users.Pi.Password);
            Assert.IsTrue(new Link(By.LinkText("Submitted")).Exists, "'Submitted' activity not found for:  " + targetStudy);
            Assert.IsTrue(workspace.GetStudyState() == "Pre-Review", "State expected not in 'Pre-Review'.  State currently: " + workspace.GetStudyState());
            var modName = Web.PortalDriver.Title;

            // Log in as IRBD and assign Coordinator (skip this this step if the copy option is enabled).
            Store.LoginAsUser(Users.Irbd);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(modName);
            workspace.AssignCoordinator("Orlando Max (irbc)");

            //Log in as the assigned coordinator and Submit Pre-Review
            Store.LoginAsUser(Users.Irbc);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(modName);
            workspace.SubmitPreReviewForCR();
            Assert.IsTrue(workspace.GetStudyState() == "Pre-Review Completed", "State expected not in 'Pre-Review Completed'.  State currently:  " + workspace.GetStudyState());

            //As the assigned coordinator, Assign Meeting.
            workspace.AssignMeetingByFirstMeeting();
            Assert.IsTrue(workspace.GetStudyState() == "Committee Review", "State expected not in 'Committee Review'.  State currently:  " + workspace.GetStudyState());

            //As the assigned coordinator, Submit Committee Review (approved determination).
            workspace.SubmitCommitteeReview(SubmitCommitteeReviewPopup.Determinations.Disapproved, "modification comments", "2", "0", "0", "0", "0", "", true);
            Assert.IsTrue(workspace.GetStudyState() == "Post-Review", "State expected not in 'Post-Review'.  State currently:  " + workspace.GetStudyState());

            // As the assigned IRB Coordinator, Finalize Documents.
            workspace.FinalizeDocuments();
            Assert.IsTrue(workspace.GetStudyState() == "Post-Review", "State expected not in 'Post-Review'.  State currently:  " + workspace.GetStudyState());

            //As the assigned coordinator, Prepare Letter.
            workspace.PrepareLetter();
            Assert.IsTrue(workspace.GetStudyState() == "Post-Review", "State expected not in 'Post-Review'.  State currently:  " + workspace.GetStudyState());

            // As the assigned coordinator, Send Letter.
            workspace.SendLetter();
            Assert.IsTrue(workspace.GetStudyState() == "Disapproved", "State expected not in 'Disapproved'.  State currently:  " + workspace.GetStudyState());
        }
        public void ModificationStudyTeamOnlyCreation_NCR_ModsRequired_Approved()
        {
            string targetStudy = "AutoTest-" + DataGen.String(5);
            EntityClonerUtil.CloneEntity("STUDY00000024", targetStudy, true);

            var CRSmartForm = new InitialModCrSmartForm();
            var StudySF = new InitialStudySmartForm();
            var workspace = new IRBWorkspace();
            var irbSubmissionsPage = new IRBSubmissions();
            var actionsNav = new ActionsNav();

            // Log in as the PI and go to the IRB/Active tab and select an Approved study, Create Modification/CR , select “Modification” and “Study team member information”.
            // Change some aspect of the Study Team member form.
            Store.LoginAsUser(Users.Pi);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(targetStudy);
            actionsNav.ImgCreateModCr.Click();

            // Fill in just required info
            CRSmartForm.ChooseModCRPurpose(SubmissionPurpose.Modification);
            CRSmartForm.ChooseModificationScope(Scope.StudyTeamMemberInformation);
            CRSmartForm.BtnContinue.Click();
            // Modification Page
            CRSmartForm.TxtSummarizeModifications.Value = "These are the new modifications!  :/ :) :P";
            CRSmartForm.BtnContinue.Click();
            // Add a study team member, save, exit
            StudySF.StudyTeamMembersPage.AddStudyTeamMember(false, false, "", AddStudyTeamMemberPopup.Roles.CoInvestigator);
            StudySF.LnkSave.Click();
            StudySF.LnkExit.Click();

            //As the PI, Submit.
            workspace.Submit(Users.Pi.UserName, Users.Pi.Password);
            Assert.IsTrue(workspace.GetStudyState() == "Pre-Review", "State expected not in 'Pre-Review'.  State currently: " + workspace.GetStudyState());
            var ModName = Web.PortalDriver.Title;

            // Log in as IRBD and assign Coordinator (skip this this step if the copy option is enabled).
            Store.LoginAsUser(Users.Irbd);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(ModName);
            workspace.AssignCoordinator("Orlando Max (irbc)");

            //Log in as the assigned coordinator and Submit Pre-Review
            Store.LoginAsUser(Users.Irbc);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(ModName);
            workspace.SubmitPreReviewForCR();
            Assert.IsTrue(workspace.GetStudyState() == "Pre-Review Completed", "State expected not in 'Pre-Review Completed'.  State currently:  " + workspace.GetStudyState());

            // As the assigned IRBC, Assign Designated Reviewer.
            workspace.AssignDesignatedReviewer("Harry Smith (comm4)");
            Assert.IsTrue(workspace.GetStudyState() == "Non-Committee Review", "State expected not in 'Non-Committee Review'.  State currently:  " + workspace.GetStudyState());

            // Log in as the Designated Reviewer and Submit Designated Review (modifications required to secure “approved” determination).
            Store.LoginAsUser(Users.Comm4);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(ModName);
            workspace.SubmitDesignatedReviewForStudy(SubmitDesignatedReview.StudyDeterminations.ModificationsRequiredToSecureApproved, "These are modification notes: ", true);
            Assert.IsTrue(workspace.GetStudyState() == "Post-Review", "State expected not in 'Post-Review'.  State currently:  " + workspace.GetStudyState());

            // As the assigned IRB Coordinator, Finalize Documents.
            Store.LoginAsUser(Users.Irbc);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(ModName);
            workspace.FinalizeDocuments();
            Assert.IsTrue(workspace.GetStudyState() == "Post-Review", "State expected not in 'Post-Review'.  State currently:  " + workspace.GetStudyState());

            // As the assigned coordinator, Prepare Letter.
            workspace.PrepareLetter();
            Assert.IsTrue(workspace.GetStudyState() == "Post-Review", "State expected not in 'Post-Review'.  State currently:  " + workspace.GetStudyState());

            // As the assigned coordinator, Send Letter.
            workspace.SendLetter();
            Assert.IsTrue(workspace.GetStudyState() == "Modifications Required", "State expected not in 'Modifications Required'.  State currently:  " + workspace.GetStudyState());

            // Log in as the PI and Submit Response.
            Store.LoginAsUser(Users.Pi);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(ModName);
            workspace.SubmitResponse(Users.Pi.UserName, Users.Pi.Password);
            Assert.IsTrue(workspace.GetStudyState() == "Modifications Submitted", "State expected not in 'Modifications Submitted'.  State currently:  " + workspace.GetStudyState());

            // Log in as IRBC, Review Required Modifications.
            Store.LoginAsUser(Users.Irbc);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(ModName);
            workspace.ReviewRequiredModifications();
            Assert.IsTrue(workspace.GetStudyState() == "Post-Review", "State expected not in 'Post-Review'.  State currently:  " + workspace.GetStudyState());

            //As the assigned coordinator, Prepare Letter.
            Store.LoginAsUser(Users.Irbc);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(ModName);
            workspace.PrepareLetter();
            Assert.IsTrue(workspace.GetStudyState() == "Post-Review", "State expected not in 'Post-Review'.  State currently:  " + workspace.GetStudyState());

            // As the assigned coordinator, Send Letter.
            workspace.SendLetter();
            Assert.IsTrue(workspace.GetStudyState() == "Approved", "State expected not in 'Approved'.  State currently:  " + workspace.GetStudyState());
        }
        public void InitialStudyCreationWithNonCommitteeReview_HumanResearchNotEngaged()
        {
            string targetStudy = "AutoTestStudy-" + DataGen.String(5);
            var InitialStudySF = new InitialStudySmartForm();
            var irbSubmissionsPage = new IRBSubmissions();
            var actionsNav = new ActionsNav();
            var workspace = new IRBWorkspace();

            //Log in as PI and Create New Study.
            Store.LoginAsUser(Users.Pi);
            actionsNav.ImgCreateNewStudyLink.Click();

            InitialStudySF.NewSubmissionSmartformPage.TxtDescription.Value = "Random Automated test for IRB submission";
            InitialStudySF.NewSubmissionSmartformPage.TxtTitleStudy.Value = targetStudy;
            InitialStudySF.NewSubmissionSmartformPage.TxtShortTitle.Value = targetStudy;
            InitialStudySF.NewSubmissionSmartformPage.RdoExternalIrbNo.Selected = true;
            InitialStudySF.NewSubmissionSmartformPage.RdoFinancialInterestNo.Selected = true;
            InitialStudySF.NewSubmissionSmartformPage.AttachProtocol(@"\\pdxstor\public\Aaron.Bentley\automation\testDoc.docx");
            InitialStudySF.NewSubmissionSmartformPage.BtnContinue.Click();
            // Funding Sources
            InitialStudySF.FundingSourcesPage.BtnContinue.Click();
            // Study Team Members
            InitialStudySF.StudyTeamMembersPage.AddStudyTeamMember(false, false, "Bivens (pi2)", AddStudyTeamMemberPopup.Roles.CoInvestigator, AddStudyTeamMemberPopup.Roles.ResearchAssistant);
            InitialStudySF.StudyTeamMembersPage.BtnContinue.Click();
            // Study Scope
            InitialStudySF.StudyScopePage.SpecifyExternalSite(false);
            InitialStudySF.StudyScopePage.SpecifyDrugsInvolved(false);
            InitialStudySF.StudyScopePage.SpecifyDevicesInvolved(false);
            InitialStudySF.StudyScopePage.BtnContinue.Click();
            // Consent Forms and Recuitment Materials -- skip
            InitialStudySF.ConsentFormsRecruitmentPage.BtnContinue.Click();
            // title / description -- skip
            InitialStudySF.StudyModCustomPage.BtnContinue.Click();
            // Add supporting documents -- skip
            InitialStudySF.SupportingDocumentsPage.BtnContinue.Click();
            // Final Page
            InitialStudySF.FinalPage.BtnFinish.Click();
            // Assert the study appears in window title
            Wait.Until(h => Web.PortalDriver.Title == targetStudy);

            //As the PI, Submit the study.
            workspace.Submit(Users.Pi.UserName, Users.Pi.Password);
            Assert.IsTrue(workspace.GetStudyState() == "Pre-Review", "State expected not in 'Pre-Review'.  State currently: " + workspace.GetStudyState());

            //Log in as an IRB coordinator and Assign Coordinator.
            Store.LoginAsUser(Users.Irbc);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(targetStudy);
            workspace.AssignCoordinator("Orlando Max (irbc)");

            //As the IRBC, Submit Pre-Review (yes to “Are you ready to Submit this pre-review?)
            workspace.SubmitPreReviewForStudy(SubmitPreReviewPopup.TypeOfResearch.BiomedicalClinical);
            Assert.IsTrue(workspace.GetStudyState() == "Pre-Review Completed", "State expected not in 'Pre-Review Completed'.  State currently: " + workspace.GetStudyState());

            //As the IRBC, Assign Designated Reviewer.
            workspace.AssignDesignatedReviewer("Harry Smith (comm4)");

            //Log in as Designated Reviewer, Submit Designated Review (approved determination and “yes” to submit the review).
            Store.LoginAsUser(Users.Comm4);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(targetStudy);
            workspace.SubmitDesignatedReviewForStudy(SubmitDesignatedReview.StudyDeterminations.HumanResearchNotEngaged);
            Assert.IsTrue(workspace.GetStudyState() == "Post-Review", "State expected not in 'Post-Review'.  State currently:  " + workspace.GetStudyID());

            //Log in as assigned coordinator, Finalize Documents.
            Store.LoginAsUser(Users.Irbc);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(targetStudy);
            workspace.FinalizeDocuments();
            Assert.IsTrue(workspace.GetStudyState() == "Post-Review", "State expected not in 'Post-Review'.  State currently:  " + workspace.GetStudyID());

            //As the assigned coordinator, Prepare Letter (Approved should be the only choice).
            workspace.PrepareLetter();
            Assert.IsTrue(workspace.GetStudyState() == "Post-Review", "State expected not in 'Post-Review'.  State currently:  " + workspace.GetStudyID());

            //As the assigned coordinator, Send Letter.
            workspace.SendLetter();
            Assert.IsTrue(workspace.GetStudyState() == "Human Research, Not Engaged", "State expected not in 'Human Research, Not Engaged'.  State currently:  " + workspace.GetStudyID());
        }
        public void ModificationOtherPartsOfStudyCreationThroughNCRApproved()
        {
            string targetStudy = "AutoTest-" + DataGen.String(5);
            EntityClonerUtil.CloneEntity("STUDY00000024", targetStudy, true);

            var CRSmartForm = new InitialModCrSmartForm();
            var StudySF = new InitialStudySmartForm();
            var workspace = new IRBWorkspace();
            var irbSubmissionsPage = new IRBSubmissions();
            var actionsNav = new ActionsNav();

            // Log in as the PI and go to the IRB/Active tab and select an Approved study, Create Modification/CR ,
            // select “Modification and Continuing” and “Other parts of the study”.  Make changes to one or more views of the study.
            Store.LoginAsUser(Users.Pi);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(targetStudy);
            actionsNav.ImgCreateModCr.Click();
            // Fill in just required info
            CRSmartForm.ChooseModCRPurpose(SubmissionPurpose.Modification);
            CRSmartForm.ChooseModificationScope(Scope.OtherPartsOfTheStudy);
            CRSmartForm.BtnContinue.Click();
            // Modification Page
            CRSmartForm.TxtSummarizeModifications.Value = "These are the new modifications!  :/ :) :P";
            CRSmartForm.BtnContinue.Click();
            StudySF.NewSubmissionSmartformPage.TxtDescription.Value = "This is a modified description for this test.";
            StudySF.LnkSave.Click();
            StudySF.LnkExit.Click();

            //As the PI, Submit.
            workspace.Submit(Users.Pi.UserName, Users.Pi.Password);
            Assert.IsTrue(workspace.GetStudyState() == "Pre-Review", "State expected not in 'Pre-Review'.  State currently: " + workspace.GetStudyState());
            var ModName = Web.PortalDriver.Title;

            // Log in as IRBD and assign Coordinator (skip this this step if the copy option is enabled).
            Store.LoginAsUser(Users.Irbd);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(ModName);
            workspace.AssignCoordinator("Orlando Max (irbc)");

            // Log in as IRBC, Request Pre-Review Clarification
            Store.LoginAsUser(Users.Irbc);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(ModName);
            workspace.RequestPreReviewClarification();
            Assert.IsTrue(workspace.GetStudyState() == "Clarification Requested (Pre-Review)", "State expected not in 'Clarification Requested (Pre-Review)'.  State currently: " + workspace.GetStudyState());

            // Log in as PI, Submit Response.
            Store.LoginAsUser(Users.Pi);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(ModName);
            workspace.SubmitResponse(Users.Pi.UserName, Users.Pi.Password, "This is my response!");
            Assert.IsTrue(workspace.GetStudyState() == "Pre-Review", "State expected not in 'Pre-Review'.  State currently: " + workspace.GetStudyState());

            // Log in as IRBC and Assign Coordinator who is different than the IRBC in the initial study.
            Store.LoginAsUser(Users.Irbc);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(ModName);
            workspace.AssignCoordinator("Ira Stein (irbd)");
            Assert.IsTrue(workspace.GetStudyState() == "Pre-Review", "State expected not in 'Pre-Review'.  State currently: " + workspace.GetStudyState());

            //Log in as the assigned coordinator and Submit Pre-Review
            Store.LoginAsUser(Users.Irbd);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(ModName);
            workspace.SubmitPreReviewForCR();
            Assert.IsTrue(workspace.GetStudyState() == "Pre-Review Completed", "State expected not in 'Pre-Review Completed'.  State currently:  " + workspace.GetStudyState());

            // As the assigned IRBC, Assign Designated Reviewer.
            workspace.AssignDesignatedReviewer("Harry Smith (comm4)");
            Assert.IsTrue(workspace.GetStudyState() == "Non-Committee Review", "State expected not in 'Non-Committee Review'.  State currently:  " + workspace.GetStudyState());

            // Log in as the assigned coordinator, Submit Committee Review (approved determination).
            Store.LoginAsUser(Users.Irbd);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(ModName);
            workspace.SubmitDesignatedReviewForStudy(SubmitDesignatedReview.StudyDeterminations.Approved);
               Assert.IsTrue(workspace.GetStudyState() == "Post-Review", "State expected not in 'Post-Review'.  State currently:  " + workspace.GetStudyState());

            //As the assigned coordinator, Prepare Letter.
            workspace.PrepareLetter();
            Assert.IsTrue(workspace.GetStudyState() == "Post-Review", "State expected not in 'Post-Review'.  State currently:  " + workspace.GetStudyState());

            // As the assigned coordinator, Send Letter.
            workspace.SendLetter();
            Assert.IsTrue(workspace.GetStudyState() == "Approved", "State expected not in 'Approved'.  State currently:  " + workspace.GetStudyState());
        }
        public void InitialStudyCreationThroughCommitteeReview_ModsRequired_Approved()
        {
            string targetStudy = "AutoTestStudy-" + DataGen.String(5);
            var InitialStudySF = new InitialStudySmartForm();
            var irbSubmissionsPage = new IRBSubmissions();
            var actionsNav = new ActionsNav();
            var workspace = new IRBWorkspace();

            //Log in as PI and Create New Study.
            Store.LoginAsUser(Users.Pi);
            actionsNav.ImgCreateNewStudyLink.Click();

            InitialStudySF.NewSubmissionSmartformPage.TxtDescription.Value = "Random Automated test for IRB submission";
            InitialStudySF.NewSubmissionSmartformPage.TxtTitleStudy.Value = targetStudy;
            InitialStudySF.NewSubmissionSmartformPage.TxtShortTitle.Value = targetStudy;
            InitialStudySF.NewSubmissionSmartformPage.RdoExternalIrbNo.Selected = true;
            InitialStudySF.NewSubmissionSmartformPage.RdoFinancialInterestNo.Selected = true;
            InitialStudySF.NewSubmissionSmartformPage.AttachProtocol(@"\\pdxstor\public\Aaron.Bentley\automation\testDoc.docx");
            InitialStudySF.NewSubmissionSmartformPage.BtnContinue.Click();
            // Funding Sources
            InitialStudySF.FundingSourcesPage.BtnContinue.Click();
            // Study Team Members
            InitialStudySF.StudyTeamMembersPage.AddStudyTeamMember(false, false, "Bivens (pi2)", AddStudyTeamMemberPopup.Roles.CoInvestigator, AddStudyTeamMemberPopup.Roles.ResearchAssistant);
            InitialStudySF.StudyTeamMembersPage.BtnContinue.Click();
            // Study Scope
            InitialStudySF.StudyScopePage.SpecifyExternalSite(false);
            InitialStudySF.StudyScopePage.SpecifyDrugsInvolved(false);
            InitialStudySF.StudyScopePage.SpecifyDevicesInvolved(false);
            InitialStudySF.StudyScopePage.BtnContinue.Click();
            // Consent Forms and Recuitment Materials -- skip
            InitialStudySF.ConsentFormsRecruitmentPage.BtnContinue.Click();
            // title / description -- skip
            InitialStudySF.StudyModCustomPage.BtnContinue.Click();
            // Add supporting documents -- skip
            InitialStudySF.SupportingDocumentsPage.BtnContinue.Click();
            // Final Page
            InitialStudySF.FinalPage.BtnFinish.Click();
            // Assert the study appears in window title
            Wait.Until(h => Web.PortalDriver.Title == targetStudy);

            // As the PI, Submit the study.
            workspace.Submit(Users.Pi.UserName, Users.Pi.Password);
            Assert.IsTrue(workspace.GetStudyState() == "Pre-Review", "State expected not in 'Pre-Review'.  State currently: " + workspace.GetStudyState());

            // Log in as an IRB coordinator and Assign Coordinator.
            Store.LoginAsUser(Users.Irbc);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(targetStudy);
            workspace.AssignCoordinator("Orlando Max (irbc)");

            // Log in as the assigned IRBC, Submit Pre-Review (yes to submit pre-review).
            workspace.SubmitPreReviewForStudy(SubmitPreReviewPopup.TypeOfResearch.BiomedicalClinical);
            Assert.IsTrue(workspace.GetStudyState() == "Pre-Review Completed", "State expected not in 'Pre-Review Completed'.  State currently: " + workspace.GetStudyState());

            // Log in as the assigned IRB Coordinator, Assign to Meeting.
            workspace.AssignMeetingByFirstMeeting();
            Assert.IsTrue(workspace.GetStudyState() == "Committee Review", "State expected not in 'Committee Review'.  State currently: " + workspace.GetStudyState());

            //As the assigned IRB Coordinator,  Submit Committee Review (Modifications Required Secure to Approved)
            workspace.SubmitCommitteeReview(SubmitCommitteeReviewPopup.Determinations.ModificationsRequiredToSecureApproved, "Reason #1","2", "1", "0", "0", "0", "", true);
            Assert.IsTrue(workspace.GetStudyState() == "Post-Review", "State expected not in 'Post-Review'.  State currently:  " + workspace.GetStudyID());

            //Log in as assigned coordinator, Finalize Documents.
            Store.LoginAsUser(Users.Irbc);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(targetStudy);
            workspace.FinalizeDocuments();
            Assert.IsTrue(workspace.GetStudyState() == "Post-Review", "State expected not in 'Post-Review'.  State currently:  " + workspace.GetStudyID());

            //As the assigned coordinator, Prepare Letter (Approved should be the only choice).
            workspace.PrepareLetter();
            Assert.IsTrue(workspace.GetStudyState() == "Post-Review", "State expected not in 'Post-Review'.  State currently:  " + workspace.GetStudyID());

            //As the assigned coordinator, Send Letter.
            workspace.SendLetter();
            Assert.IsTrue(workspace.GetStudyState() == "Modifications Required", "State expected not in 'Modifications Required'.  State currently:  " + workspace.GetStudyID());

            // Log in as the PI and Submit Response.
            Store.LoginAsUser(Users.Pi);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(targetStudy);
            workspace.SubmitResponse(Users.Pi.UserName,Users.Pi.Password,"This is my respone!  :/ ");

            // Log in as the assigned IRB Coordinator and Assign to Committee Review.
            Store.LoginAsUser(Users.Irbc);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(targetStudy);
            workspace.AssignToCommitteeReview();
            Assert.IsTrue(workspace.GetStudyState() == "Committee Review", "State expected not in 'Committee Review'.  State currently:  " + workspace.GetStudyID());

            // As the assigned IRB Coordinator, Add Review Comments.
            workspace.AddReviewComments("Reviewed!");
            // TODO VERIFY THE REVIEW COMMENTS
            //Assert.IsTrue(workspace.ProjectLogReviews.DivComponentArea.Text.Contains("Reviewed!"));
            Assert.IsTrue(workspace.GetStudyState() == "Committee Review", "State expected not in 'Committee Review'.  State currently:  " + workspace.GetStudyID());

            // As the assigned IRB Coordinator, update review comments by Add Review Comments.
            workspace.AddReviewComments("More revised comments!");
            // TODO VERIFY THE REVIEW COMMENTS

            // Log in as the assigned IRB Coordinator, Assign to Meeting.
            workspace.AssignMeetingByFirstMeeting();
            Assert.IsTrue(workspace.GetStudyState() == "Committee Review", "State expected not in 'Committee Review'.  State currently:  " + workspace.GetStudyID());

            // As the assigned IRB Coordinator¸ Submit Committee Review (Approved determination, “yes” to submit).
            workspace.SubmitCommitteeReview(SubmitCommitteeReviewPopup.Determinations.Approved, "2", "1", "0", "0", "0", "", true);
            Assert.IsTrue(workspace.GetStudyState() == "Post-Review", "State expected not in 'Post-Review'.  State currently:  " + workspace.GetStudyID());

            // As the assigned IRB Coordinator and Prepare Letter.
            workspace.PrepareLetter();
            Assert.IsTrue(workspace.GetStudyState() == "Post-Review", "State expected not in 'Post-Review'.  State currently:  " + workspace.GetStudyID());

            // As the assigned IRB Coordinator, Send Letter.
            workspace.SendLetter();
            Assert.IsTrue(workspace.GetStudyState() == "Approved", "State expected not in 'Approved'.  State currently:  " + workspace.GetStudyID());
        }
        public void SignificantRNIThroughCommitteeReviewThroughClarificationRequestedWithNoRequiredAction()
        {
            // This test requires a meeting agenda created within next 60 days of current date
            string RNITitle = "AutoTestRNI-" + DataGen.String(5);
            var inboxPage = new Inbox();
            var rniSmartformPage = new RNISmartform();
            var studyWorkspacePage = new IRBWorkspace();
            var irbSubmissionsPage = new IRBSubmissions();

            Store.LoginAsUser(Users.Pi);
            inboxPage.ImgCreateNewRNI.Click();
            // Fill in just required info
            rniSmartformPage.TxtRNIShortTitle.Value = RNITitle;
            rniSmartformPage.TxtDateAware.Value = "03/02/2014";
            rniSmartformPage.TxtDescriptionOfProblem.Value = "This is a RNI test for " + RNITitle;
            rniSmartformPage.RdoIsIncreasedRiskNo.Click();
            rniSmartformPage.RdoNeedRevisionNo.Click();
            rniSmartformPage.RdoConsentRequiresRevisionkNo.Click();
            rniSmartformPage.BtnContinue.Click();
            rniSmartformPage.BtnFinish.Click();
            Wait.Until(h => new Link(By.LinkText("Reportable Information Opened")).Exists);
            Assert.IsTrue(new Link(By.LinkText("Reportable Information Opened")).Exists, "'Reportable Information Opened' activity not found for:  " + RNITitle);
            Assert.IsTrue(studyWorkspacePage.GetStudyState() == "Pre-Submission", "State expected not in 'Pre-Submission'.  State currently: " + studyWorkspacePage.GetStudyState());

            // Submit RNI as Pi
            studyWorkspacePage.SubmitRNI(Users.Pi.UserName, Users.Pi.Password);
            Assert.IsTrue(new Link(By.LinkText("RNI Submitted")).Exists, "'Pre-Review' activity not found for:  " + RNITitle);
            Assert.IsTrue(studyWorkspacePage.GetStudyState() == "Pre-Review", "State expected not in 'Pre-Review'.  State currently: " + studyWorkspacePage.GetStudyState());

            // Log in as IRBC
            Store.LoginAsUser(Users.Irbc);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(RNITitle);

            // Assign coordinator as IRBC
            studyWorkspacePage.AssignCoordinator("Orlando Max (irbc)");

            // Submit RNI-Preview as IRBC
            studyWorkspacePage.SubmitRNIPreReview("", true, SubmitRNIPreReview.Determinations.SeriousNonCompliance);
            Assert.IsTrue(new Link(By.LinkText("RNI Pre-Review Submitted")).Exists, "'RNI Pre-Review Submitted' activity not found for:  " + RNITitle);
            Assert.IsTrue(studyWorkspacePage.GetStudyState() == "Pre-Review Completed");

            // Assign to Meeting as IRBC
            studyWorkspacePage.AssignMeetingByFirstMeeting();
            Assert.IsTrue(new Link(By.PartialLinkText("Assigned to Meeting")).Exists, "'Assigned to Meeting' activity not found for:  " + RNITitle);
            Assert.IsTrue(studyWorkspacePage.GetStudyState() == "Committee Review");

            // Request Clarification By Committee Member
            studyWorkspacePage.RequestClarificationByCommitteeMember();
            Assert.IsTrue(new Link(By.LinkText("Clarification Requested by Committee Member")).Exists, "'Clarification Requested by Committee Member' activity not found for:  " + RNITitle);
            Assert.IsTrue(studyWorkspacePage.GetStudyState() == "Clarification Requested (Committee Review)");

            // Log in as submitt, Submit Response
            Store.LoginAsUser(Users.Pi);
            inboxPage.OpenStudy(RNITitle);
            studyWorkspacePage.SubmitResponse(Users.Pi.UserName, Users.Pi.Password);
            Assert.IsTrue(new Link(By.LinkText("Response Submitted")).Exists, "'Response Submitted' activity not found for:  " + RNITitle);
            Assert.IsTrue(studyWorkspacePage.GetStudyState() == "Committee Review");

            // Log in as irbd, Submit RNI Committee REview (no)
            Store.LoginAsUser(Users.Irbd);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(RNITitle);
            studyWorkspacePage.SubmitRniCommitteeReviewPopupRequiredOnlyFields("1");
            Assert.IsTrue(new Link(By.LinkText("Committee RNI Review Submitted")).Exists, "'Committee RNI Review Submitted' activity not found for:  " + RNITitle);
            Assert.IsTrue(studyWorkspacePage.GetStudyState() == "Post-Review");

            // log in as assigned coordinator, prepare letter
            Store.LoginAsUser(Users.Irbc);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(RNITitle);
            studyWorkspacePage.PrepareLetter("Review of New Information");
            Assert.IsTrue(new CCElement(By.LinkText("Prepared Letter")).Exists);
            Assert.IsTrue(studyWorkspacePage.GetStudyState() == "Post-Review");

            // Send Letter
            studyWorkspacePage.SendLetter();
            Assert.IsTrue(new CCElement(By.LinkText("Letter Sent")).Exists);
            Assert.IsTrue(studyWorkspacePage.GetStudyState() == "Complete");
        }
        public void SignificantRNISubmissionThroughDesignatedReviewToCommitteeReviewWithActionRequired()
        {
            string RNITitle = "AutoTestRNI-" + DataGen.String(5);
            var inboxPage = new Inbox();
            var rniSmartformPage = new RNISmartform();
            var workspace = new IRBWorkspace();
            var irbSubmissionsPage = new IRBSubmissions();
            var ActivitiesNav = new ActivitiesNav();

            Store.LoginAsUser(Users.Pi);
            inboxPage.ImgCreateNewRNI.Click();
            // Fill in just required info
            rniSmartformPage.TxtRNIShortTitle.Value = RNITitle;
            rniSmartformPage.TxtDateAware.Value = "03/02/2014";
            rniSmartformPage.TxtDescriptionOfProblem.Value = "This is a RNI test for " + RNITitle;
            rniSmartformPage.RdoIsIncreasedRiskNo.Click();
            rniSmartformPage.RdoNeedRevisionNo.Click();
            rniSmartformPage.RdoConsentRequiresRevisionkNo.Click();
            rniSmartformPage.BtnContinue.Click();
            rniSmartformPage.BtnFinish.Click();
            Wait.Until(h => new Link(By.LinkText("Reportable Information Opened")).Exists);
            Assert.IsTrue(new Link(By.LinkText("Reportable Information Opened")).Exists, "'Reportable Information Opened' activity not found for:  " + RNITitle);
            Assert.IsTrue(workspace.GetStudyState() == "Pre-Submission", "State expected not in 'Pre-Submission'.  State currently: " + workspace.GetStudyState());

            // Submit RNI as Pi
            workspace.SubmitRNI(Users.Pi.UserName, Users.Pi.Password);
            Assert.IsTrue(new Link(By.LinkText("RNI Submitted")).Exists, "'Pre-Review' activity not found for:  " + RNITitle);
            Assert.IsTrue(workspace.GetStudyState() == "Pre-Review", "State expected not in 'Pre-Review'.  State currently: " + workspace.GetStudyState());

            // Log in as IRBD, Assign coordinator as IRBD
            Store.LoginAsUser(Users.Irbd);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(RNITitle);
            workspace.AssignCoordinator("Orlando Max (irbc)");
            Assert.IsTrue(workspace.GetStudyState() == "Pre-Review", "State expected not in 'Pre-Review'.  State currently: " + workspace.GetStudyState());

            // As the assigned Coordinator (IRBD) and Submit RNI Pre-Review (One of the top four determinations)
            workspace.SubmitRNIPreReview("", true, SubmitRNIPreReview.Determinations.UnanticipatedProblem);
            Assert.IsTrue(workspace.GetStudyState() == "Pre-Review Completed", "State expected not in 'Pre-Review Completed'.  State currently:  " + workspace.GetStudyID());

            // As the IRB Director, Assign Designated Reviewer.  TODO
            workspace.AssignDesignatedReviewer("Harry Smith (comm4)");
            Assert.IsTrue(workspace.GetStudyState() == "Non-Committee Review", "State expected 'Non-Committee Review '.  State currently:  " + workspace.GetStudyID());

            // Log in as the Designated Reviewer and Submit RNI Designated Review (for significant RNI -one of the top 4 determinations). ??
            Store.LoginAsUser(Users.Comm4);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(RNITitle);
            workspace.SubmitRNIDesignatedReview();
            Assert.IsTrue(workspace.GetStudyState() == "Committee Review", "State expected not in 'Committee Review'.  State currently:  " + workspace.GetStudyID());

            // Log in as the assigned coordinator and Assign to Meeting.
            Store.LoginAsUser(Users.Irbc);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(RNITitle);
            workspace.AssignMeetingByFirstMeeting();
            Assert.IsTrue(workspace.GetStudyState() == "Committee Review", "State expected not in 'Committee Review'.  State currently:  " + workspace.GetStudyID());

            // As the Director (IRBD), Submit RNI Committee Review (further action required, add Responsible Party and Action Plan).
            Store.LoginAsUser(Users.Irbd);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(RNITitle);
            ActivitiesNav.LnkSubmitRNICommitteeReview.Click();
            var SubmitRNICommitteeReview = new SubmitRNICommitteeReviewPopup(workspace.GetStudyID(), "Submit RNI Committee Review");
            SubmitRNICommitteeReview.SwitchTo();
            SubmitRNICommitteeReview.RdoFurtherActionReqYes.Click();
            SubmitRNICommitteeReview.BtnResponsibleParty.Click();
            var SelectPerson = new SelectPerson("Person");
            SelectPerson.SwitchTo();
            SelectPerson.SelectUser("Max (irbc)");
            SelectPerson.SwitchBackToParent();
            SubmitRNICommitteeReview.TxtActionPlan.Value = "This is the action plan:  TODO";
            SubmitRNICommitteeReview.TxtFor.Value = "2";
            SubmitRNICommitteeReview.TxtAgainst.Value = "0";
            SubmitRNICommitteeReview.TxtRecused.Value = "0";
            SubmitRNICommitteeReview.TxtAbsent.Value = "0";
            SubmitRNICommitteeReview.TxtAbstained.Value = "0";
            SubmitRNICommitteeReview.RdoRdyForSubmissionYes.Click();
            SubmitRNICommitteeReview.BtnOk.Click();
            SubmitRNICommitteeReview.SwitchBackToParent();
            Wait.Until(h => new Link(By.LinkText("Committee RNI Review Submitted")).Exists);
            Wait.Until(h => workspace.GetStudyState() == "Post-Review");
            Assert.IsTrue(workspace.GetStudyState() == "Post-Review", "State expected not in 'Post-Review'.  State currently:  " + workspace.GetStudyID());

            //Log in as a Coordinator (IRBC), Prepare Letter.
            Store.LoginAsUser(Users.Irbc);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(RNITitle);
            workspace.PrepareLetter("Review of New Information");
            Assert.IsTrue(workspace.GetStudyState() == "Post-Review", "State expected not in 'Post-Review'.  State currently:  " + workspace.GetStudyID());

            //As the Director (IRBD), locate the above RNI by clicking on the IRB tab/New Information Reports/ and select the RNI and Submit Action Response.
            Store.LoginAsUser(Users.Irbd);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(RNITitle);
            // TODO MISSING SUBMIT ACTION RESPONSE
            workspace.SubmitActionResponse();
            Assert.IsTrue(workspace.GetStudyState() == "Action Required", "State expected not in 'Action Required'.  State currently:  " + workspace.GetStudyID());

            // Log in as one of the Responsible Parties determined in Step 7 and Submit Action Response.
            Store.LoginAsUser(Users.Irbc);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(RNITitle);
            workspace.SubmitActionResponse();
            Assert.IsTrue(workspace.GetStudyState() == "Action Submitted", "State expected not in 'Action Submitted'.  State currently:  " + workspace.GetStudyID());

            //Log in as assigned Coordinator and Review Required Actions (Were the actions completed as required? – YES)
            workspace.ReviewRequiredActions(true);
            Assert.IsTrue(workspace.GetStudyState() == "Post Review", "State expected not in 'Post Review'.  State currently:  " + workspace.GetStudyID());

            // As the assigned Coordinator, Prepare Letter.
            workspace.PrepareLetter("Review of New Information");
            Assert.IsTrue(workspace.GetStudyState() == "Post Review", "State expected not in 'Post Review'.  State currently:  " + workspace.GetStudyID());

            // As the assigned Coordinator, Send Letter.
            workspace.SendLetter();
            Assert.IsTrue(workspace.GetStudyState() == "Complete", "State expected not in 'Complete'.  State currently:  " + workspace.GetStudyID());
        }
        public void SignificantRNISubmissionThroughCommitteeReviewWithActionRequiredToComplete()
        {
            string RNITitle = "AutoTestRNI-" + DataGen.String(5);
            var inboxPage = new Inbox();
            var rniSmartformPage = new RNISmartform();
            var workspace = new IRBWorkspace();
            var irbSubmissionsPage = new IRBSubmissions();
            var ActivitiesNav = new ActivitiesNav();

            Store.LoginAsUser(Users.Pi);
            inboxPage.ImgCreateNewRNI.Click();
            // Fill in just required info
            rniSmartformPage.TxtRNIShortTitle.Value = RNITitle;
            rniSmartformPage.TxtDateAware.Value = "03/02/2014";
            rniSmartformPage.TxtDescriptionOfProblem.Value = "This is a RNI test for " + RNITitle;
            rniSmartformPage.RdoIsIncreasedRiskNo.Click();
            rniSmartformPage.RdoNeedRevisionNo.Click();
            rniSmartformPage.RdoConsentRequiresRevisionkNo.Click();
            rniSmartformPage.BtnContinue.Click();
            rniSmartformPage.BtnFinish.Click();
            Wait.Until(h => new Link(By.LinkText("Reportable Information Opened")).Exists);
            Assert.IsTrue(new Link(By.LinkText("Reportable Information Opened")).Exists, "'Reportable Information Opened' activity not found for:  " + RNITitle);
            Assert.IsTrue(workspace.GetStudyState() == "Pre-Submission", "State expected not in 'Pre-Submission'.  State currently: " + workspace.GetStudyState());

            // Submit RNI as Pi
            workspace.SubmitRNI(Users.Pi.UserName, Users.Pi.Password);
            Assert.IsTrue(new Link(By.LinkText("RNI Submitted")).Exists, "'Pre-Review' activity not found for:  " + RNITitle);
            Assert.IsTrue(workspace.GetStudyState() == "Pre-Review", "State expected not in 'Pre-Review'.  State currently: " + workspace.GetStudyState());

            // Log in as IRBC
            Store.LoginAsUser(Users.Irbc);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(RNITitle);

            // Assign coordinator as IRBC
            workspace.AssignCoordinator("Orlando Max (irbc)");
            Assert.IsTrue(workspace.GetStudyState() == "Pre-Review", "State expected not in 'Pre-Review'.  State currently: " + workspace.GetStudyState());

            // As the assigned Coordinator (IRBC) and Submit RNI Pre-Review (One of the top four determinations)
            workspace.SubmitRNIPreReview("", true, SubmitRNIPreReview.Determinations.UnanticipatedProblem);
            Assert.IsTrue(workspace.GetStudyState() == "Pre-Review Completed", "State expected not in 'Pre-Review Completed'.  State currently:  " + workspace.GetStudyID());

            // As IRBC, Assign to Meeting
            workspace.AssignMeetingByFirstMeeting();
            Assert.IsTrue(workspace.GetStudyState() == "Committee Review");

            // As the Director (IRBD), Submit RNI Committee Review (further action required, add Responsible Party and Action Plan).
            Store.LoginAsUser(Users.Irbd);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(RNITitle);
            ActivitiesNav.LnkSubmitRNICommitteeReview.Click();
            var SubmitRNICommitteeReview = new SubmitRNICommitteeReviewPopup(workspace.GetStudyID(), "Submit RNI Committee Review");
            SubmitRNICommitteeReview.SwitchTo();
            SubmitRNICommitteeReview.RdoFurtherActionReqYes.Click();
            SubmitRNICommitteeReview.BtnResponsibleParty.Click();
            var SelectPerson = new SelectPerson("Person");
            SelectPerson.SwitchTo();
            SelectPerson.SelectUser("Max (irbc)");
            SelectPerson.SwitchBackToParent();
            SubmitRNICommitteeReview.TxtActionPlan.Value = "This is the action plan:  TODO";
            SubmitRNICommitteeReview.TxtFor.Value = "2";
            SubmitRNICommitteeReview.TxtAgainst.Value = "0";
            SubmitRNICommitteeReview.TxtRecused.Value = "0";
            SubmitRNICommitteeReview.TxtAbsent.Value = "0";
            SubmitRNICommitteeReview.TxtAbstained.Value = "0";
            SubmitRNICommitteeReview.RdoRdyForSubmissionYes.Click();
            SubmitRNICommitteeReview.BtnOk.Click();
            SubmitRNICommitteeReview.SwitchBackToParent();
            Wait.Until(h => new Link(By.LinkText("Committee RNI Review Submitted")).Exists);

            workspace.PrepareLetter("Review of New Information");
            workspace.SendLetter();
            Assert.IsTrue(workspace.GetStudyState() == "Action Required", "State expected not in 'Action Required'.  State currently:  " + workspace.GetStudyID());

            Store.LoginAsUser(Users.Irbc);
            // why does Action Required RNI not show up under all submissions?
            inboxPage.OpenStudy(RNITitle);
            workspace.SubmitActionResponse("This is an action response!");
            Assert.IsTrue(workspace.GetStudyState() == "Action Submitted", "State expected not in 'Action Submitted'.  State currently:  " + workspace.GetStudyID());

            // Log in as assigned Coordinator and Review Required Actions (Were the actions completed as required? – NO)
            workspace.ReviewRequiredActions(false);
            Assert.IsTrue(workspace.GetStudyState() == "Action Required", "State expected not in 'Action Required'.  State currently:  " + workspace.GetStudyID());

            // Log in as the Responsible Party and Submit Action Response.
            workspace.SubmitActionResponse("this is a response!");
            Assert.IsTrue(workspace.GetStudyState() == "Action Submitted", "State expected not in 'Action Submitted'.  State currently:  " + workspace.GetStudyID());

            // Need new Assign to Committee Review
            workspace.AssignToCommitteeReview();
            Assert.IsTrue(workspace.GetStudyState() == "Committee Review", "State expected not in 'Committee Review'.  State currently:  " + workspace.GetStudyID());

            //As the assigned Coordinator (IRBC) Submit RNI Committee Review (Are further actions required - NO)
            // TODO MISSING THIS ACTIVITY
            workspace.SubmitRNICommitteeReview();  //-- need to update for NO

            // As the assigned coordinator, Prepare Letter.
            workspace.PrepareLetter("Review New Information");
            Assert.IsTrue(workspace.GetStudyState() == "Post-Review", "State expected not in 'Post-Review'.  State currently:  " + workspace.GetStudyID());

            // As the assigned coordinator, Send Letter.
            workspace.SendLetter();
            Assert.IsTrue(workspace.GetStudyState() == "Complete  ", "State expected not in 'Complete  '.  State currently:  " + workspace.GetStudyID());
        }
        public void ContinuingReviewThroughNonCommitteeReviewToApproved()
        {
            string targetStudy = "AutoTest-" + DataGen.String(5);
            EntityClonerUtil.CloneEntity("STUDY00000024", targetStudy, true);

            var CRSmartForm = new InitialModCrSmartForm();
            var workspace = new IRBWorkspace();
            var irbSubmissionsPage = new IRBSubmissions();
            var actionsNav = new ActionsNav();

            //Log in as the PI to an Approved study and select Create Modification/CR. Select “Continuing Review”  and on the Continuing Review/Study Closure Information select the top 4 Research milestones.
            Store.LoginAsUser(Users.Pi);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(targetStudy);
            actionsNav.ImgCreateModCr.Click();

            // Fill in just required info
            CRSmartForm.ChooseModCRPurpose(SubmissionPurpose.ContinuingReview);
            CRSmartForm.BtnContinue.Click();

            CRSmartForm.SpecifyEnrollmentTotals("2", "2", "1");
            CRSmartForm.ChooseResearchMilestone(InitialModCrSmartForm.MileStones.StudyPermanentlyClosedToEnrollment, InitialModCrSmartForm.MileStones.AllSubjectCompletedStudyRelatedInterventions,
                InitialModCrSmartForm.MileStones.CollectionOfPrivateInfoComplete, InitialModCrSmartForm.MileStones.AnalysisOfPrivateInfoComplete);
            CRSmartForm.RdoFinancialInterestNo.Click();
            CRSmartForm.BtnContinue.Click();
            CRSmartForm.BtnFinish.Click();

            //As the PI, Submit the Continuing Review.
            workspace.Submit(Users.Pi.UserName, Users.Pi.Password);
            Assert.IsTrue(new Link(By.LinkText("Submitted")).Exists, "'Submitted' activity not found for:  " + targetStudy);
            Assert.IsTrue(workspace.GetStudyState() == "Pre-Review", "State expected not in 'Pre-Review'.  State currently: " + workspace.GetStudyState());
            var CRName = Web.PortalDriver.Title;

            //Log in as the assigned coordinator and Submit Pre-Review
            Store.LoginAsUser(Users.Irbc);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(CRName);
            workspace.SubmitPreReviewForCR();

            // Log in as an IRB coordinator and Assign Coordinator
            Store.LoginAsUser(Users.Irbc);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(CRName);
            workspace.AssignCoordinator("Orlando Max (irbc)");

            // As the assigned IRBC, Assign Designated Reviewer.
            workspace.AssignDesignatedReviewer("Harry Smith (comm4)");
            Assert.IsTrue(workspace.GetStudyState() == "Non-Committee Review", "State expected not in 'Non-Committee Review'.  State currently:  " + workspace.GetStudyState());

            // Log in as the Designated Reviewer and Submit Designated Review (human research not engaged determination).
            Store.LoginAsUser(Users.Comm4);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(CRName);
            workspace.SubmitDesignatedReviewForStudy(SubmitDesignatedReview.StudyDeterminations.Approved);
            Assert.IsTrue(workspace.GetStudyState() == "Post-Review", "State expected not in 'Post-Review'.  State currently:  " + workspace.GetStudyState());

            // As the assigned IRB Coordinator, Finalize Documents.
            Store.LoginAsUser(Users.Irbc);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(CRName);
            workspace.FinalizeDocuments();
            Assert.IsTrue(workspace.GetStudyState() == "Post-Review", "State expected not in 'Post-Review'.  State currently:  " + workspace.GetStudyState());

            //As the assigned coordinator, Prepare Letter.
            workspace.PrepareLetter();
            Assert.IsTrue(workspace.GetStudyState() == "Post-Review", "State expected not in 'Post-Review'.  State currently:  " + workspace.GetStudyState());

            // As the assigned coordinator, Send Letter.
            workspace.SendLetter();
            Assert.IsTrue(workspace.GetStudyState() == "Approved", "State expected not in 'Approved'.  State currently:  " + workspace.GetStudyState());
        }