//[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 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 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());
        }