public void SubmitRNI()
        {
            string RNITitle = "AutoTestRNI-" + DataGen.String(5);
            var Inbox = new Inbox();
            var RNISmartformPage = new RNISmartform();
            var StudyWorkspacePage = new IRBWorkspace();

            Store.LoginAsUser(Users.Pi);
            Inbox.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();
            // verify in history tab, pre-submission
            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);
            // SubmitRNI
            StudyWorkspacePage.SubmitRNI(Users.Pi.UserName, Users.Pi.Password);
            Assert.IsTrue(new Link(By.LinkText("RNI Submitted")).Exists, "'RNI Submitted' activity not found for:  " + RNITitle);
            Assert.IsTrue(StudyWorkspacePage.GetStudyState() == "Pre-Review", "State of RNI: Not in pre-review state");
        }
        //[Test]
        //[Ignore("Duplicated by System Test InsignificantRniWithClarificationRequestedToAcknowledged")]
        public void SubmitRNIPreReview()
        {
            // clone a RNI in pre-review state

            string targetStudy = "RNI-" + DataGen.String(5);
            // select something new
            EntityClonerUtil.CloneEntity("RNI00000005", targetStudy);

            var Inbox = new Inbox();
            var LeftActionNav = new ActivitiesNav();
            var StudyWorkspacePage = new IRBWorkspace();

            Store.LoginAsUser(Users.Irbd);

            Inbox.LnkAdvanced.Click();
            Wait.Until(h => Inbox.QueryField1.Displayed);
            Inbox.QueryField1.SelectByInnerText("State");
            Wait.Until(h => Inbox.QueryCriteria1.Enabled);
            Inbox.QueryCriteria1.Text = "Pre-Review";
            Wait.Until(d => Inbox.BtnGo.Enabled);
            Inbox.BtnGo.Click();
            Wait.Until(d => Inbox.BtnGo.Enabled);

            // change this
            Inbox.OpenStudy(targetStudy);

            string id = StudyWorkspacePage.GetStudyID();
            var AssignCordPopup = new AssignCoordinator(id, "Assign Coordinator");

            // Assign coordinator
            LeftActionNav.LnkAssignCoordinator.Click();
            AssignCordPopup.SwitchTo();
            AssignCordPopup.FirstUser.Click();
            AssignCordPopup.SwitchBackToParent();

            // Submit RNI-SubmitPreReviewPopup

            LeftActionNav.LnkSubmitRNIPreReview.Click();
            var SubmitRNIPreReviewPage = new SubmitRNIPreReview(id, "Submit RNI Pre-Review");
            SubmitRNIPreReviewPage.SwitchTo();
            SubmitRNIPreReviewPage.SelectDetermination(IRBStore.SubmitRNIPreReview.Determinations.NoneOfTheAbove);
            SubmitRNIPreReviewPage.rdoSubmitPreviewYes.Click();
            SubmitRNIPreReviewPage.BtnOk.Click();
            SubmitRNIPreReviewPage.SwitchBackToParent();

            Wait.Until(h => new Link(By.LinkText("RNI Pre-Review Submitted")).Exists);
            Assert.IsTrue(new Link(By.LinkText("RNI Pre-Review Submitted")).Exists, "'RNI Submitted Pre-Review' activity not found for:  " + targetStudy);

            Assert.IsTrue(StudyWorkspacePage.GetStudyState() == "Acknowledged", "State of RNI: Not in acknowledged state");
        }
        public void A1_CreateAndSubmitIRBSubmission()
        {
            string targetStudy = "AutoTest-" + DataGen.String(5);
            var Inbox = new Inbox();
            var actionsNav = new ActivitiesNav();
            var Workspace = new IRBWorkspace();
            var InitialStudySF = new InitialStudySmartForm();

            // Log in as PI and create a 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);

            // Verify a link called Study Created for this study exists
            Assert.IsTrue(new CCElement(By.LinkText("Study Created")).Exists, "Study does not exist:  " + targetStudy);
        }
        public void CreateAndSubmitStudyAsPIProxy()
        {
            string targetStudy = "AutoTestStudy-" + DataGen.String(5);
            var inboxPage = new Inbox();
            var InitialStudySF = new InitialStudySmartForm();
            var irbSubmissionsPage = new IRBSubmissions();
            var actionsNav = new ActionsNav();
            var workspace = new IRBWorkspace();
            var ActivitiesNav = new ActivitiesNav();

            //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);

            // get the id of the study
            string id = workspace.GetStudyID();
            ActivitiesNav.LnkAssignPIProxy.Click();

            // helper method for assignPI proxy?  not frequently used...
            var AssignPIProxyPopup = new AssignPIProxyPopup(id, "Assign PI Proxy");
            AssignPIProxyPopup.SwitchTo();
            AssignPIProxyPopup.SelectFirstPerson();
            AssignPIProxyPopup.BtnOk.Click();
            AssignPIProxyPopup.ConfirmCredentials(Users.Pi.UserName, Users.Pi.Password);
            AssignPIProxyPopup.SwitchBackToParent();

            Wait.Until(h => new Link(By.LinkText("PI Proxies updated")).Exists);
            Assert.IsTrue(new Link(By.LinkText("PI Proxies updated")).Exists, "'PI Proxies updated' activity not found for:  " + targetStudy);
            Assert.IsTrue(workspace.GetStudyState() == "Pre-Submission");

            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");
        }
        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 InsignificantRNIsubmissionthroughCommitteeReviewToPostReviewToAcknowledged()
        {
            // 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)");
            Assert.IsTrue(studyWorkspacePage.GetStudyState() == "Pre-Review", "State expected not in 'Pre-Review'.  State currently: " + studyWorkspacePage.GetStudyState());

            // Submit RNI-Preview as IRBC
            studyWorkspacePage.SubmitRNIPreReview("", true, SubmitRNIPreReview.Determinations.NoneOfTheAbove, SubmitRNIPreReview.Determinations.AdditionalReviewRequired);
            //studyWorkspacePage.SubmitRNIPreReview(SubmitRNIPreReview.Determinations.AdditionalReviewRequired);
            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");

            // Log in as irbd, Submit RNI Committee Review twice
            Store.LoginAsUser(Users.Irbd);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(RNITitle);
            // check none of the above, uncheck additional review required
            studyWorkspacePage.SubmitRNICommitteeReview("1", "0", "0", "0", "0");
            Assert.IsTrue(studyWorkspacePage.GetStudyState() == "Post-Review", "State not in 'Post-Review'.  Currently in state:  " + studyWorkspacePage.GetStudyState());
            studyWorkspacePage.SubmitRNICommitteeReview("1", "2", "0", "0", "0", SubmitRNICommitteeReviewPopup.Determinations.AdditionalReviewRequired);
            Assert.IsTrue(studyWorkspacePage.GetStudyState() == "Acknowledged", "State not in 'Acknowledged'.  Currently in state:  " + studyWorkspacePage.GetStudyState());
        }
        public void PutIntoReview()
        {
            // Take an existing study in the pre-review completed state, and clone it, put into non-committe review -- use one of the clones in this test
            string targetStudy = "AutoTest-" + DataGen.String(5);
            CloneEntity("STUDY-AutoTest-SMVPz", targetStudy);

            var ActionsNav = new ActivitiesNav();
            var Inbox = new Inbox();
            //var DesignatedReviewerPopup = new AssignDesignatedReviewer();
            var IRBSubmissionPage = new IRBSubmissions();
            var StudyWorkspace = new IRBWorkspace();

            // Login as irbd
            Store.LoginAsUser(Users.Irbd);
            IRBSubmissionPage.OpenSubmissionByAllSubmissions(targetStudy);

            // Assign Designated Reviewer
            var DesignatedReviewerPopup = new AssignDesignatedReviewer(StudyWorkspace.GetStudyID(),"Assign Designated Reviewer");
            ActionsNav.LnkAssignDesignatedReviewer.Click();
            DesignatedReviewerPopup.SwitchTo();
            DesignatedReviewerPopup.CmbDesignatedReviewer.SelectByInnerText("Harry Smith (comm4)");
            DesignatedReviewerPopup.OkBtn.Click();
            DesignatedReviewerPopup.SwitchBackToParent();

            Wait.Until((d) => new CCElement(By.LinkText("Assigned to Designated Reviewer")).Exists);
            Assert.IsTrue(new CCElement(By.LinkText("Assigned to Designated Reviewer")).Exists);
        }
        public void InsignificantRNIWithNoToSubmitRNIPreReviewToAcknowledged()
        {
            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();

            // verify in history tab, pre-submission
            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);

            // Grab the ID of the study, switch to submit RNI popup (move this functionality to page)
            StudyWorkspacePage.SubmitRNI(Users.Pi.UserName, Users.Pi.Password);

            // Log in as IRBC, assign coordinator
            Store.LoginAsUser(Users.Irbc);
            IRBSubmissionsPage.OpenSubmissionByAllSubmissions(RNITitle);
            StudyWorkspacePage.AssignCoordinator("Orlando Max (irbc)");

            //As the assigned Coordinator, Submit RNI Pre-Review
            //(select only 5 through 8 determinations to create an insignificant RNI and NO to “Are you ready to submit this pre-review?”)
            StudyWorkspacePage.SubmitRNIPreReview("",false,SubmitRNIPreReview.Determinations.NoneOfTheAbove);
            Assert.IsTrue(StudyWorkspacePage.GetStudyState() == "Acknowledged", "State not in 'Acknowledged'.  Currently in state:  " + StudyWorkspacePage.GetStudyState());
        }
        public void InsignificantRNIToAcknowledgedAndThenResubmittedRNIPreReviewForSignificantRNI()
        {
            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)");
            Assert.IsTrue(studyWorkspacePage.GetStudyState() == "Pre-Review", "State expected not in 'Pre-Review'.  State currently: " + studyWorkspacePage.GetStudyState());

            // As the assigned Coordinator, Submit RNI Pre-Review (select only 5 through 8 determinations to create an insignificant RNI and NO to “Are you ready to submit this pre-review?”)
            studyWorkspacePage.SubmitRNIPreReview("", false, SubmitRNIPreReview.Determinations.NoneOfTheAbove);
            Assert.IsTrue(studyWorkspacePage.GetStudyState() == "Acknowledged", "State not in 'Acknowledged'.  Currently in state:  " + studyWorkspacePage.GetStudyState());

            // As the assigned coordinator, Submit RNI Pre -Review (change the determination to be one of the top 4)
            studyWorkspacePage.SubmitRNIPreReview("", true, SubmitRNIPreReview.Determinations.NoneOfTheAbove, SubmitRNIPreReview.Determinations.UnanticipatedProblem);
            Assert.IsTrue(studyWorkspacePage.GetStudyState() == "Pre-Review Completed");
        }
        public void InsignificantRniWithClarificationRequestedToAcknowledged()
        {
            string RNITitle = "AutoTestRNI-" + DataGen.String(5);
            var InboxPage = new Inbox();
            var ActionsNav = new ActivitiesNav();
            var RNISmartformPage = new RNISmartform();
            var StudyWorkspacePage = new IRBWorkspace();
            var IRBSubmissionsPage = new IRBSubmissions();

            Store.LoginAsUser(Users.Irbc);

            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();

            // verify in history tab, pre-submission
            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);

            // Grab the ID of the study, switch to submit RNI popup (move this functionality to page)
            string id = StudyWorkspacePage.GetStudyID();
            var SubmitRNIPopup = new ActivityPopup(id, "Submit RNI");

            // Submit the RNI
            ActionsNav.LnkSubmitRNI.Click();
            SubmitRNIPopup.SwitchTo();
            SubmitRNIPopup.BtnOk.Click();
            // change this to "confirm credentials page"
            SubmitRNIPopup.ConfirmCredentials(Users.Irbc.UserName, Users.Irbc.Password);

            // Switch back to main page
            PopUpWindow.SwitchTo(RNITitle);
            Wait.Until(h => new Link(By.LinkText("RNI Submitted")).Exists);

            ActionsNav.LnkAssignCoordinator.Click();
            var AssignCoordinatorPopup = new AssignCoordinator(id, "Assign Coordinator");
            AssignCoordinatorPopup.SwitchTo();
            AssignCoordinatorPopup.FirstUser.Click();
            AssignCoordinatorPopup.BtnOk.Click();
            AssignCoordinatorPopup.SwitchBackToParent();

            // Log in as IRBD
            Store.LoginAsUser(Users.Irbd);

            IRBSubmissionsPage.AllSubmissionsTab.NavigateTo();
            IRBSubmissionsPage.AllSubmissionsTab.ProjectsComponent.LnkAdvanced.Click();
            IRBSubmissionsPage.AllSubmissionsTab.ProjectsComponent.SetCriteria("Name",RNITitle);
            IRBSubmissionsPage.OpenSubmission(RNITitle);

            ActionsNav.LnkRequestPreReviewClarification.Click();
            var RequestPreReviewPopup = new RequestPreReviewClarificationPopup(id, "Request Pre-Review Clarification");
            RequestPreReviewPopup.SwitchTo();
            RequestPreReviewPopup.TxtInfo.Value = "Addition information required regarding RNI";
            RequestPreReviewPopup.BtnOk.Click();
            RequestPreReviewPopup.SwitchBackToParent();

            Wait.Until(h => new Link(By.LinkText("Clarification Requested")).Exists);
            Assert.IsTrue(new Link(By.LinkText("Clarification Requested")).Exists, "'Clarification Requested' activity not found for:  " + RNITitle);
            Assert.IsTrue(StudyWorkspacePage.GetStudyState() == "Clarification Requested (Pre-Review)");

            // Log in as IRBC
            Store.LoginAsUser(Users.Irbc);
            //InboxPage.OpenStudy(RNITitle);
            IRBSubmissionsPage.AllSubmissionsTab.NavigateTo();
            IRBSubmissionsPage.AllSubmissionsTab.ProjectsComponent.LnkAdvanced.Click();
            IRBSubmissionsPage.AllSubmissionsTab.ProjectsComponent.SetCriteria("Name", RNITitle);
            IRBSubmissionsPage.OpenSubmission(RNITitle);

            ActionsNav.LnkSubmitResponse.Click();
            var SubmitResponsePage = new SubmitResponsePopup(id, "Submit Response");
            SubmitResponsePage.SwitchTo();
            SubmitResponsePage.TxtInfo.Value = "I cleared this up with batman.  We are good.";
            SubmitResponsePage.BtnOk.Click();
            SubmitResponsePage.ConfirmCredentials(Users.Irbc.UserName, Users.Irbc.Password);

            PopUpWindow.SwitchTo(RNITitle, true);
            Wait.Until(h => new Link(By.LinkText("Response Submitted")).Exists);
            Assert.IsTrue(new Link(By.LinkText("Response Submitted")).Exists, "'Response Submitted' activity not found for:  " + RNITitle);
            Assert.IsTrue(StudyWorkspacePage.GetStudyState() == "Pre-Review");

            // Log in as IRBD
            Store.LoginAsUser(Users.Irbd);
            IRBSubmissionsPage.AllSubmissionsTab.NavigateTo();
            IRBSubmissionsPage.AllSubmissionsTab.ProjectsComponent.LnkAdvanced.Click();
            IRBSubmissionsPage.AllSubmissionsTab.ProjectsComponent.SetCriteria("Name", RNITitle);
            IRBSubmissionsPage.OpenSubmission(RNITitle);

            ActionsNav.LnkSubmitRNIPreReview.Click();
            var SubmitRNIPreReviewPopup = new SubmitRNIPreReview(id, "Submit RNI Pre-Review");
            SubmitRNIPreReviewPopup.SwitchTo();
            SubmitRNIPreReviewPopup.SelectDetermination(SubmitRNIPreReview.Determinations.NoneOfTheAbove);
            SubmitRNIPreReviewPopup.rdoSubmitPreviewYes.Click();
            SubmitRNIPreReviewPopup.BtnOk.Click();
            SubmitRNIPreReviewPopup.SwitchBackToParent();

            Wait.Until(h => new Link(By.LinkText("RNI Pre-Review Submitted")).Exists);
            Assert.IsTrue(new Link(By.LinkText("RNI Pre-Review Submitted")).Exists, "'RNI Pre-Review Submitted' activity not found for:  " + RNITitle);
            Assert.IsTrue(StudyWorkspacePage.GetStudyState() == "Acknowledged");
        }
        public void InsignificantRNIThroughDesignatedReviewToAcknowledgedMadeSignificantAndTransitionToCommitteeReview()
        {
            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 IRBD
            Store.LoginAsUser(Users.Irbd);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(RNITitle);

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

            // Submit RNI-Preview as IRBD
            studyWorkspacePage.SubmitRNIPreReview("", true, SubmitRNIPreReview.Determinations.SuspensionOrTermination);
            //studyWorkspacePage.SubmitRNIPreReview(SubmitRNIPreReview.Determinations.AdditionalReviewRequired);
            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");

            // Login as IRBC, assign designated reviewer
            Store.LoginAsUser(Users.Irbc);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(RNITitle);
            studyWorkspacePage.AssignDesignatedReviewer("Harry Smith (comm4)");

            // Log in as the Designated Reviewer and Submit RNI Designated Review
            //(for insignificant RNI -one of last four determinations and YES to “Are you ready to submit this Review?).
            Store.LoginAsUser(Users.Comm4);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(RNITitle);
            studyWorkspacePage.SubmitRNIDesignatedReview(SubmitDesignatedRNIReviewPopup.Determinations.NoneOfTheAbove, SubmitDesignatedRNIReviewPopup.Determinations.SuspensionOrTermination);
            Assert.IsTrue(studyWorkspacePage.GetStudyState() == "Acknowledged", "State not in 'Acknowledged'.  Currently in state:  " + studyWorkspacePage.GetStudyState());

            // Log in as the IRB Director and Submit RNI Designated Review (changing the determination to one of the top 4).
            Store.LoginAsUser(Users.Irbd);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(RNITitle);
            studyWorkspacePage.SubmitRNIDesignatedReview(SubmitDesignatedRNIReviewPopup.Determinations.UnanticipatedProblem, SubmitDesignatedRNIReviewPopup.Determinations.NoneOfTheAbove);
            Assert.IsTrue(studyWorkspacePage.GetStudyState() == "Committee Review", "State not in 'Committee Review'.  Currently in state:  " + studyWorkspacePage.GetStudyState());
        }
        public void InsignificantRNIThroughAssignToMeetingThenWithdrawn()
        {
            // 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 ActivitiesNavPage = new ActivitiesNav();
            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();

            // verify in history tab, pre-submission
            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());

            // Grab the ID of the study, switch to submit RNI popup (move this functionality to page)
            string id = StudyWorkspacePage.GetStudyID();
            var SubmitRNIPopup = new ActivityPopup(id, "Submit RNI");

            // Submit the RNI
            ActivitiesNavPage.LnkSubmitRNI.Click();
            SubmitRNIPopup.SwitchTo();
            SubmitRNIPopup.BtnOk.Click();
            // change this to "confirm credentials page"
            SubmitRNIPopup.ConfirmCredentials(Users.Pi.UserName, Users.Pi.Password);
            SubmitRNIPopup.SwitchBackToParent();
            Wait.Until(h => new Link(By.LinkText("RNI Submitted")).Exists);

            // Log in as IRBC
            Store.LoginAsUser(Users.Irbc);
            IRBSubmissionsPage.AllSubmissionsTab.NavigateTo();
            IRBSubmissionsPage.AllSubmissionsTab.ProjectsComponent.LnkAdvanced.Click();
            IRBSubmissionsPage.AllSubmissionsTab.ProjectsComponent.SetCriteria("Name", RNITitle);
            IRBSubmissionsPage.OpenSubmission(RNITitle);

            // Assign coordinator as IRBC
            ActivitiesNavPage.LnkAssignCoordinator.Click();
            var AssignCoordinatorPopup = new AssignCoordinator(id, "Assign Coordinator");
            AssignCoordinatorPopup.SwitchTo();
            AssignCoordinatorPopup.FirstUser.Click();
            AssignCoordinatorPopup.BtnOk.Click();
            AssignCoordinatorPopup.SwitchBackToParent();

            // Submit RNI-Preview as IRBC
            ActivitiesNavPage.LnkSubmitRNIPreReview.Click();
            var SubmitRNIPreReviewPopup = new SubmitRNIPreReview(id, "Submit RNI Pre-Review");
            SubmitRNIPreReviewPopup.SwitchTo();
            SubmitRNIPreReviewPopup.SelectDetermination(SubmitRNIPreReview.Determinations.NoneOfTheAbove);
            SubmitRNIPreReviewPopup.SelectDetermination(SubmitRNIPreReview.Determinations.AdditionalReviewRequired);
            SubmitRNIPreReviewPopup.rdoSubmitPreviewYes.Click();
            SubmitRNIPreReviewPopup.BtnOk.Click();
            SubmitRNIPreReviewPopup.SwitchBackToParent();

            Wait.Until(h => new Link(By.LinkText("RNI Pre-Review Submitted")).Exists);
            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");

            PopUpWindow.SwitchTo(RNITitle);
            // Assign to Meeting as IRBC
            ActivitiesNavPage.LnkAssignToMeeting.Click();

            var assignToMeetingPage = new AssignToMeetingPopup(id, "Assign to Meeting");
            assignToMeetingPage.SwitchTo();
            assignToMeetingPage.RdoFirstMeeting.Click();
            assignToMeetingPage.BtnOk.Click();
            assignToMeetingPage.SwitchBackToParent();

            Wait.Until(h => new Link(By.PartialLinkText("Assigned to Meeting:")).Exists);
            Assert.IsTrue(new Link(By.PartialLinkText("Assigned to Meeting:")).Exists, "'Assigned to Meeting' activity not found for:  " + RNITitle);
            Assert.IsTrue(StudyWorkspacePage.GetStudyState() == "Committee Review");

            // Withdraw as PI
            Store.LoginAsUser(Users.Pi);
            IRBSubmissionsPage.AllSubmissionsTab.NavigateTo();
            IRBSubmissionsPage.AllSubmissionsTab.ProjectsComponent.LnkAdvanced.Click();
            IRBSubmissionsPage.AllSubmissionsTab.ProjectsComponent.SetCriteria("Name", RNITitle);
            IRBSubmissionsPage.OpenSubmission(RNITitle);

            ActivitiesNavPage.LnkWithdraw.Click();
            var WithDrawPage = new WithdrawPopup(id, "Withdraw");
            WithDrawPage.SwitchTo();
            WithDrawPage.BtnOk.Click();
            WithDrawPage.SwitchBackToParent();

            Wait.Until(h => new Link(By.LinkText("Withdrawn")).Exists);
            Assert.IsTrue(new Link(By.LinkText("Withdrawn")).Exists, "'Withdrawn' activity not found for:  " + RNITitle);
            Assert.IsTrue(StudyWorkspacePage.GetStudyState() == "Pre-Submission");
        }
        public void InsignificantRNISubmissionToAcknowledged()
        {
            // 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();

            // verify in history tab, pre-submission
            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());

            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.Irbd);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(RNITitle);

            // Assign coordinator as IRBD
            studyWorkspacePage.AssignCoordinator("Orlando Max (irbc)");
            Assert.IsTrue(studyWorkspacePage.GetStudyState() == "Pre-Review");

            // Submit RNI-Preview as IRBD
            studyWorkspacePage.SubmitRNIPreReview("",true,SubmitRNIPreReview.Determinations.NoneOfTheAbove);
            Assert.IsTrue(new Link(By.LinkText("RNI Pre-Review Submitted")).Exists, "'RNI Pre-Review Submitted' activity not found for:  " + RNITitle);
            Assert.IsTrue(studyWorkspacePage.GetStudyState() == "Acknowledged");
        }
        public void InitialCreationToNonCommitteeReview_Approved()
        {
            string targetStudy = "AutoTestStudy-" + DataGen.String(5);
            var inboxPage = new Inbox();
            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, Assign Primary Contact.
            workspace.AssignPrimaryContact("Bivens (pi2)");

            //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, Request Clarifications by Designated Reviewer.
            Store.LoginAsUser(Users.Comm4);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(targetStudy);
            workspace.RequestClarificationByDesignatedReviewer();

            //Log in as PI and Submit Response.
            Store.LoginAsUser(Users.Pi);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(targetStudy);
            workspace.SubmitResponse(Users.Pi.UserName, Users.Pi.Password,"Green Lantern here:  everything is green and good to go.");
            Assert.IsTrue(workspace.GetStudyState() == "Non-Committee Review", "State expected not in 'Non-Committee Review'.  State currently:  " + workspace.GetStudyID());

            //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.Approved);
            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();

            //As the assigned coordinator, Prepare Letter (Approved should be the only choice).
            workspace.PrepareLetter();

            //As the assigned coordinator, Send Letter.
            workspace.SendLetter();
            Assert.IsTrue(workspace.GetStudyState() == "Approved", "State expected not in 'Approved'.  State currently:  " + workspace.GetStudyID());
        }
        public void SignificantRNISubmissionClarificationRequestedToDesignatedReviewToAcknowledged()
        {
            string RNITitle = "AutoTestRNI-" + DataGen.String(5);
            var inboxPage = new Inbox();
            var rniSmartformPage = new RNISmartform();
            var workspace = 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(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
            Store.LoginAsUser(Users.Irbd);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(RNITitle);

            // Assign coordinator as IRBD
            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());

            // Log in as the assigned IRB Coordinator and Assign Designated Reviewer.
            Store.LoginAsUser(Users.Irbc);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(RNITitle);
            workspace.AssignDesignatedReviewer("Harry Smith (comm4)");

            // Log in as the assigned designated reviewer and Request Clarification by Designated Reviewer.
            Store.LoginAsUser(Users.Comm4);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(RNITitle);
            workspace.RequestClarificationByDesignatedReviewer();
            Assert.IsTrue(workspace.GetStudyState() == "Clarification Requested (Designated Review)", "State expected not in 'Clarification Requested (Designated Review)'.  State currently:  " + workspace.GetStudyID());

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

            // Log in as the asssigned Designated Reviewer, Submit RNI Designated Review (selecting one of the last four determinations – yes to submit).
            Store.LoginAsUser(Users.Comm4);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(RNITitle);
            workspace.SubmitRNIDesignatedReview(SubmitDesignatedRNIReviewPopup.Determinations.UnanticipatedProblem, SubmitDesignatedRNIReviewPopup.Determinations.NoneOfTheAbove);
            Assert.IsTrue(workspace.GetStudyState() == "Acknowledged", "State expected not in 'Acknowledged'.  State currently:  " + workspace.GetStudyID());
        }
        public void AddRelatedGrant()
        {
            string targetStudy = "AutoTest-" + DataGen.String(5);
            CloneEntity("STUDY00000017", targetStudy);

            var ActionsNav = new ActivitiesNav();
            var AddRelatedGrantPopup = new AddRelatedGrant("STUDY-" + targetStudy, "Add Related Grant");
            var ClickIRBGrantInfoPopup = new AddClickIRBGrantInfo();
            var Inbox = new Inbox();
            //var SelectPersonsPage = new ChooserPopup("Persons", true);

            Store.LoginAsUser(Users.Irbd);
            ActionsNav.LnkSubmissions.Click();
            Inbox.LnkAdvanced.Click();
            Wait.Until(h => Inbox.QueryField1.Displayed);
            Inbox.QueryField1.SelectByInnerText("Name");
            Wait.Until(h => Inbox.QueryCriteria1.Enabled);
            Inbox.QueryCriteria1.Text = targetStudy;
            Wait.Until(d => Inbox.BtnGo.Enabled);
            Inbox.BtnGo.Click();
            Wait.Until(d => Inbox.BtnGo.Enabled);

            var studyForReview = new CCElement(By.LinkText(targetStudy));
            studyForReview.Click();

            ActionsNav.LnkAddRelatedGrant.Click();
            AddRelatedGrantPopup.SwitchTo();
            AddRelatedGrantPopup.BtnAdd.Click();
            ClickIRBGrantInfoPopup.SwitchTo();
            ClickIRBGrantInfoPopup.TxtGrantId.Value = "Grant-" + DataGen.String(4);
            ClickIRBGrantInfoPopup.TxtGrantTitle.Value = "Grant Title Automation Test" + DataGen.String(4);
            ClickIRBGrantInfoPopup.BtnOk.Click();
            ClickIRBGrantInfoPopup.SwitchBackToParent();
            AddRelatedGrantPopup.BtnOk.Click();
            AddRelatedGrantPopup.SwitchBackToParent();

            Wait.Until(h => new CCElement(By.LinkText("Related Grants Updated")).Exists);
            Assert.IsTrue(new CCElement(By.LinkText("Related Grants Updated")).Exists, "'Related Grants Updated' activity not found for:  " + targetStudy);
        }
        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 PrepareLetter()
        {
            string targetStudy = "AutoTest-" + DataGen.String(5);
            CloneEntity("STUDY-AutoTest-hWfUU", targetStudy);

            var ActionsNav = new ActivitiesNav();
            var Inbox = new Inbox();
            var finalizeDocumentsPage = new FinalizeDocuments();
            //var prepareLetterPage = new PrepareLetterPopup();
            //var sendLetterPage = new SendLetterPopup();
            var IRBSubmissionPage = new IRBSubmissions();
            var studyworkspace = new IRBWorkspace();

            Store.LoginAsUser(Users.Irbd);

            ActionsNav.LnkSubmissions.Click();
            IRBSubmissionPage.AllSubmissionsTab.NavigateTo();
            IRBSubmissionPage.AllSubmissionsTab.ProjectsComponent.LnkAdvanced.Click();
            IRBSubmissionPage.AllSubmissionsTab.ProjectsComponent.SetCriteria("Name", targetStudy);
            IRBSubmissionPage.OpenSubmission(targetStudy);

            // finalize the documents
            ActionsNav.LnkFinalizeDocuments.Click();
            PopUpWindow.SwitchTo("Execute \"Finalize Documents\"",true);
            finalizeDocumentsPage.ChkApprove.Click();
            finalizeDocumentsPage.BtnOk.Click();
            // Assert that the "Finalized Documents" appear in History tab
            PopUpWindow.SwitchTo("AutoTest",true);
            Wait.Until((d) => new CCElement(By.LinkText("Finalized Documents")).Exists);
            Assert.IsTrue(new CCElement(By.LinkText("Finalized Documents")).Exists);
            Assert.IsTrue(ActionsNav.ContainerIRBState.Text == "Post-Review");

            // Prepare Letter
            var prepareLetterPage = new PrepareLetterPopup(studyworkspace.GetStudyID(),"Prepare Letter");
            ActionsNav.LnkPrepareLetter.Click();
            PopUpWindow.SwitchTo("Execute \"Prepare Letter\"",true);
            prepareLetterPage.CmbDraftLetterTemplate.SelectByInnerText("Approval");
            prepareLetterPage.BtnGenerate.Click();
            // wait for draft letter link to appear
            Wait.Until(d => new CCElement(By.PartialLinkText("Correspondence")).Exists);
            prepareLetterPage.BtnOk.Click();
            PopUpWindow.SwitchTo("AutoTest",true);
            Wait.Until((d) => new CCElement(By.LinkText("Prepared Letter")).Exists);
            Assert.IsTrue(new CCElement(By.LinkText("Prepared Letter")).Exists);
            Assert.IsTrue(ActionsNav.ContainerIRBState.Text == "Post-Review");

            // Send Letter
            var sendLetterPage = new SendLetterPopup(studyworkspace.GetStudyID(), "Send Letter");
            ActionsNav.LnkSendLetter.Click();
            PopUpWindow.SwitchTo("Execute \"Send Letter\"", true);
            sendLetterPage.BtnOk.Click();
            PopUpWindow.SwitchTo("AutoTest", true);
            Wait.Until((d) => new CCElement(By.LinkText("Letter Sent")).Exists);
            Assert.IsTrue(new CCElement(By.LinkText("Letter Sent")).Exists);
            Assert.IsTrue(ActionsNav.ContainerIRBState.Text == "Approved");
        }
        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 TerminateStudy()
        {
            // use STUDY00000024 as template
            string targetStudy = "AutoTest-" + DataGen.String(5);
            CloneEntity("STUDY00000024", targetStudy);

            var ActionsNav = new ActivitiesNav();
            var TerminatePopup = new Terminate("STUDY-" + targetStudy, "Terminate");
            var Inbox = new Inbox();

            Store.LoginAsUser(Users.Irbd);
            ActionsNav.LnkSubmissions.Click();
            Inbox.LnkAdvanced.Click();
            Wait.Until(h => Inbox.QueryField1.Displayed);
            Inbox.QueryField1.SelectByInnerText("Name");
            Wait.Until(h => Inbox.QueryCriteria1.Enabled);
            Inbox.QueryCriteria1.Text = targetStudy;
            Wait.Until(d => Inbox.BtnGo.Enabled);
            Inbox.BtnGo.Click();
            Wait.Until(d => Inbox.BtnGo.Enabled);

            var studyForReview = new CCElement(By.LinkText(targetStudy));
            studyForReview.Click();
            ActionsNav.LnkTerminate.Click();
            TerminatePopup.SwitchTo();
            TerminatePopup.TxtComments.Value = "Terminating this study for automation!";
            TerminatePopup.BtnOk.Click();
            TerminatePopup.SwitchBackToParent();

            Wait.Until(h => new CCElement(By.LinkText("Terminated")).Exists);
            Assert.IsTrue(new CCElement(By.LinkText("Terminated")).Exists, "'Terminated' activity not found for:  " + targetStudy);
        }
        public void SignificantRNIThroughRNIPreReviewThenDiscard()
        {
            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());

            // Log in as PI and Discard RNI.
            Store.LoginAsUser(Users.Pi);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(RNITitle);
            workspace.Discard();
            Assert.IsTrue(new CCElement(By.LinkText("Discarded")).Exists, "Discarded link does not exist for:  " + RNITitle);
        }