public void ManageAncillaryReviews()
        {
            string targetStudy = "AutoTest-" + DataGen.String(5);
            CloneEntity("STUDY00000017", targetStudy);

            var ActionsNav = new ActivitiesNav();
            var ManageAncillaryReviewsPage = new ManageAncillaryReviews("STUDY-" + targetStudy,"Manage Ancillary Reviews");
            var SelectPersonPage = new SelectPerson("Person");
            var AddAncillaryReviewPage = new AddAncillaryReview();

            Store.LoginAsUser(Users.Irbd);

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

            ActionsNav.LnkManageAncillaryReviews.Click();
            ManageAncillaryReviewsPage.SwitchTo();
            ManageAncillaryReviewsPage.BtnAdd.Click();
            AddAncillaryReviewPage.SwitchTo();
            AddAncillaryReviewPage.SelectPerson("Max (irbc)");
            //AddAncillaryReviewPage.BtnSelectPerson.Click();
            //SelectPersonPage.SwitchTo();
            //SelectPersonPage.SelectFirstUser();
            //PopUpWindow.SwitchTo("Add Ancillary Review",true);
            AddAncillaryReviewPage.SelReviewType.SelectOption("Faculty");
            AddAncillaryReviewPage.RdoResponseRequiredNo.Click();
            AddAncillaryReviewPage.BtnOk.Click();
            PopUpWindow.SwitchTo("Manage Ancillary Review", true);
            ManageAncillaryReviewsPage.BtnOk.Click();
            PopUpWindow.SwitchTo(targetStudy);

            Wait.Until(h => new CCElement(By.LinkText("Managed Ancillary Reviews")).Exists);
            Assert.IsTrue(new CCElement(By.LinkText("Managed Ancillary Reviews")).Exists, "Managed Ancillary Reviews not found for:  " + targetStudy);
        }
        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 AssignPrimaryContact()
        {
            string targetStudy = "AutoTest-" + DataGen.String(5);
            CloneEntity("STUDY00000017", targetStudy);

            var ActionsNav = new ActivitiesNav();
            var workspace = new IRBWorkspace();
            var SelectPersonPage = new SelectPerson("Person");

            Store.LoginAsUser(Users.Irbd);

            var studyForReview = new CCElement(By.LinkText(targetStudy));
            studyForReview.Click();
            var assignPrimaryContact = new AssignPrimaryContact(workspace.GetStudyID(), "Assign Primary Contact");
            ActionsNav.LnkAssignPrimaryContact.Click();
            assignPrimaryContact.SwitchTo();
            PopUpWindow.SwitchTo("Execute \"Assign Primary Contact\"",true);
            assignPrimaryContact.SelectPrimaryContact("Bivens (pi2)");

            PopUpWindow.SwitchTo(targetStudy);
            Wait.Until(h => new CCElement(By.LinkText("Assigned Primary Contact")).Exists);
            Assert.IsTrue(new CCElement(By.LinkText("Assigned Primary Contact")).Exists, "Assigned primary contact 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());
        }