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

            var ActionsNav = new ActivitiesNav();
            var submissionPage = new IRBSubmissions();
            var ModificationsPage = new InitialModCrSmartForm();
            var ModificationInfoPage = new ModificationInformation();
            var Workspace = new IRBWorkspace();
            var StudySF = new InitialStudySmartForm();

            Store.LoginAsUser(Users.Pi);
            submissionPage.OpenSubmissionByAllSubmissions(targetStudy);

            // Log in as the PI and go to the IRB/Active tab and select an Approved study,
            // Create Modification/CR , select “Modification” and “Other parts of the study”.
            // Make changes to one or more views of the study.
            ActionsNav.ImgCreateModCr.Click();
            ModificationsPage.RdoModification.Click();
            ModificationsPage.ChooseModificationScope(Scope.OtherPartsOfTheStudy);

            //ModificationsPage.BtnContinue
            ModificationsPage.BtnContinue.Click();
            ModificationInfoPage.TxtSummary.Value = "This is a test summary for modification.";
            ModificationsPage.BtnContinue.Click();

            //StudySF.StudyTeamMembersPage.AddStudyTeamMember("Elmira (comm1)", false, false, AddStudyTeamMemberPopup.Roles.CoInvestigator, AddStudyTeamMemberPopup.Roles.ResearchAssistant);
            //StudySF.StudyTeamMembersPage.BtnContinue.Click();

            // save and exit smartform
            StudySF.LnkSave.Click();
            StudySF.LnkExit.Click();

            // As the PI, Submit the modification.
            Workspace.SubmitMod(Users.Pi.UserName, Users.Pi.Password);
            PopUpWindow.SwitchTo(targetStudy, true);

            // why does Exists not retry?
            Wait.Until(h => new CCElement(By.LinkText("Submitted")).Exists);
            Assert.IsTrue(new CCElement(By.LinkText("Submitted")).Exists, "Attempted submitted mod does not exist for:  " + targetStudy);

            // Log in as the assigned IRB Coordinator and Submit Pre-Review.

            // Log in as assigned IRB Coordinator, Assign to Meeting.

            // As the assigned IRB Coordinator,  Submit Committee Review (modifications required to secure “approved” determination)

            // Log in as assigned IRB Coordinator and Finalize Documents.

            // As the assigned IRB Coordinator, Prepare Letter.

            // As the assigned IRB Coordinator, Send Letter.
        }
        public void A1_CR_TestFixtureSetup()
        {
            var ActivitiesNavPage = new ActivitiesNav();
            var ActionsNavPage = new ActionsNav();
            var NewMeetingPage = new CreateNewMeeting();

            Store.LoginAsUser(Users.Admin);
            ActivitiesNavPage.LnkMeetings.Click();
            ActionsNavPage.ImgCreateNewMeeting.Click();
            string location = "Conference Room " + DataGen.String(4);
            NewMeetingPage.CreateMeeting("IRB Committee", location);
        }
        //[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 A2_SubmitPreReview()
        {
            // take a study in the previous pre-review state, clone it.

            string targetStudy = "AutoTest-" + DataGen.String(5);
            CloneEntity("STUDY00000011", targetStudy);

            var ActionsNav = new ActivitiesNav();
            var AssignCoordinator = new AssignCoordinator("STUDY-" + targetStudy, "Assign Coordinator");

            var IRBSubmissionsPage = new IRBSubmissions();
            var Workspace = new IRBWorkspace();

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

            // Assign a coordinator
            Workspace.AssignCoordinator("Orlando Max (irbc)");

            // verify link IRB Coordinator Assigned
            Assert.IsTrue(new CCElement(By.LinkText("IRB Coordinator Assigned")).Exists, "Cannot find 'IRB Coordinator Assigned' activity in history");

            // Submit Pre-Review
            var PreReview = new SubmitPreReviewPopup(Workspace.GetStudyID(), "Submit Pre-Review");

            ActionsNav.LnkSubmitPreReview.Click();
            PreReview.SwitchTo();
            PreReview.RdoRiskLevelGreater.Click();
            PreReview.ChkBoxBioMedicalClinical.Click();
            PreReview.RadioBtnSubmitPreReviewYes.Click();
            PreReview.BtnOk.Click();
            PreReview.SwitchBackToParent();
            // verify link Pre-Review Submitted exists
            Wait.Until((d) => new CCElement(By.LinkText("Pre-Review Submitted")).Exists);
            Assert.IsTrue(new CCElement(By.LinkText("Pre-Review Submitted")).Exists, "Cannot find 'Pre-Review Submitted' activity in history");
        }
        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 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 ManageGuestList()
        {
            string targetStudy = "AutoTest-" + DataGen.String(5);
            CloneEntity("STUDY00000017", targetStudy);

            var ActionsNav = new ActivitiesNav();
            var ManageGuestListPagePopup = new ManageGuestList("STUDY-" + targetStudy, "Manage Guest List");
            var SelectPersonsPage = new ChooserPopup("Persons", true);

            Store.LoginAsUser(Users.Irbd);

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

            ActionsNav.LnkManageGuestList.Click();
            ManageGuestListPagePopup.SwitchTo();
            ManageGuestListPagePopup.BtnAddGuest.Click();

            SelectPersonsPage.SwitchTo();
            SelectPersonsPage.SelectValue("Jones (irbc2)", "Last");
            SelectPersonsPage.BtnOk.Click();
            SelectPersonsPage.SwitchBackToParent();

            ManageGuestListPagePopup.BtnOk.Click();
            ManageGuestListPagePopup.SwitchBackToParent();

            Wait.Until(h => new CCElement(By.LinkText("Guest List Updated")).Exists);
            Assert.IsTrue(new CCElement(By.LinkText("Guest List Updated")).Exists, "'Guest List Updated' activity not found for:  " + targetStudy);
        }
        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 FinalizeDocuments()
        {
            // Using STUDY-AutoTest-uqqHJ as template
               string targetStudy = "AutoTest-" + DataGen.String(5);
               CloneEntity("STUDY-AutoTest-nGPTf", targetStudy);

            var ActionsNav = new ActivitiesNav();
            var Workspace = new IRBWorkspace();
            var irbSubmissionsPage = new IRBSubmissions();

            Store.LoginAsUser(Users.Comm4);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(targetStudy);

            var submitDesignatedReviewPopup = new SubmitDesignatedReview(Workspace.GetStudyID(), "Submit Designated Review");
            ActionsNav.LnkSubmitDesignatedReview.Click();
            submitDesignatedReviewPopup.SwitchTo();
            submitDesignatedReviewPopup.ChkConflictingInterest.Click();
            submitDesignatedReviewPopup.RdoBtnFirstDetermination.Click();
            submitDesignatedReviewPopup.RdoFirstReviewLevel.Click();
            submitDesignatedReviewPopup.ChkFirstExemptCategory.Click();
            submitDesignatedReviewPopup.TxtLastDayApproval.Text = "2/6/2030";
            submitDesignatedReviewPopup.RdoReadyToSubmitThisReviewYes.Click();
            submitDesignatedReviewPopup.BtnOk.Click();
            submitDesignatedReviewPopup.SwitchBackToParent();

            Wait.Until((d) => new CCElement(By.LinkText("Designated Review Submitted")).Exists);
            Assert.IsTrue(new CCElement(By.LinkText("Designated Review Submitted")).Exists);
            Assert.IsTrue(Workspace.GetStudyState() == "Post-Review");
        }
        public void DiscardModification()
        {
            string targetStudy = "AutoTest-" + DataGen.String(5);
            CloneEntity("STUDY00000024", targetStudy, true);

            var ActionsNav = new ActivitiesNav();
            var IRBSubmissionPage = new IRBSubmissions();
            var ModificationsPage = new InitialModCrSmartForm();
            var ModificationInfoPage = new ModificationInformation();
            var StudyTeamMembersPage = new StudyTeamMembers();
            var Workspace = new IRBWorkspace();
            var InitialStudySF = new InitialStudySmartForm();

            Store.LoginAsUser(Users.Pi);

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

            // Create modification
            ActionsNav.ImgCreateModCr.Click();
            ModificationsPage.RdoModification.Click();
            ModificationsPage.ChkAddStudyMemeber.Click();
            ModificationsPage.BtnContinue.Click();
            ModificationInfoPage.TxtSummary.Value = "This is a test summary for modification.";
            ModificationsPage.BtnContinue.Click();

            InitialStudySF.StudyTeamMembersPage.AddStudyTeamMember(false, false, "Czerch (comm2)", AddStudyTeamMemberPopup.Roles.CoInvestigator, AddStudyTeamMemberPopup.Roles.ResearchAssistant);
            InitialStudySF.StudyTeamMembersPage.BtnContinue.Click();

            // save and exit smartform
            InitialStudySF.LnkSave.Click();
            InitialStudySF.LnkExit.Click();

            // Discard the modification
            ActionsNav.LnkDiscard.Click();
            PopUpWindow.SwitchTo("Execute \"Discard\" on", true);
            new Button(By.Id("okBtn")).Click();

            PopUpWindow.SwitchTo("Modification",true);
            Wait.Until(h => new CCElement(By.LinkText("Discarded")).Exists);
            Assert.IsTrue(new CCElement(By.LinkText("Discarded")).Exists, "Discarded link does not exist:  " + 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 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 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 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 AssignIRB()
        {
            string targetStudy = "AutoTest-" + DataGen.String(5);
            CloneEntity("STUDY00000017", targetStudy);

            var ActionsNav = new ActivitiesNav();
            var AssignIRBPage = new AssignIRB("STUDY-" + targetStudy, "Assign IRB");

            Store.LoginAsUser(Users.Irbd);

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

            ActionsNav.LnkAssignIRB.Click();

            AssignIRBPage.SwitchTo();
            AssignIRBPage.SelIrbOffice.SelectOption("IRB 1");
            AssignIRBPage.BtnOk.Click();
            //AssignIRBPage.SwitchBackToParent();
            PopUpWindow.SwitchTo(targetStudy);

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

            var ActionsNav = new ActivitiesNav();
            var AddPrivateCommentsPage = new AddPrivateComments("STUDY-" + targetStudy, "Add Private Comment");

            Store.LoginAsUser(Users.Irbd);

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

            ActionsNav.LnkAddPrivateComment.Click();
            AddPrivateCommentsPage.SwitchTo();
            AddPrivateCommentsPage.TxtComment.Value = "This is a private comment";
            AddPrivateCommentsPage.BtnOk.Click();
            AddPrivateCommentsPage.SwitchBackToParent();

            Wait.Until(h => new CCElement(By.LinkText("Private Comment Added")).Exists);
            Assert.IsTrue(new CCElement(By.LinkText("Private Comment Added")).Exists, "Private Comment Added not found for:  " + 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 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 CreateModification()
        {
            string targetStudy = "AutoTest-" + DataGen.String(5);
            CloneEntity("STUDY00000024", targetStudy, true);

            var ActionsNav = new ActivitiesNav();
            var IRBSubmissionPage = new IRBSubmissions();
            var ModificationsPage = new InitialModCrSmartForm();
            var ModificationInfoPage = new ModificationInformation();
            var StudyTeamMembersPage = new StudyTeamMembers();
            var Workspace = new IRBWorkspace();
            var InitialStudySF = new InitialStudySmartForm();

            Store.LoginAsUser(Users.Pi);

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

            // Create modification
            ActionsNav.ImgCreateModCr.Click();
            ModificationsPage.RdoModification.Click();
            ModificationsPage.ChkAddStudyMemeber.Click();
            ModificationsPage.BtnContinue.Click();
            ModificationInfoPage.TxtSummary.Value = "This is a test summary for modification.";
            ModificationsPage.BtnContinue.Click();
            InitialStudySF.StudyTeamMembersPage.AddStudyTeamMember(false, false, "Elmira (comm1)", AddStudyTeamMemberPopup.Roles.CoInvestigator, AddStudyTeamMemberPopup.Roles.ResearchAssistant);
            InitialStudySF.StudyTeamMembersPage.BtnContinue.Click();

            // save and exit smartform
            InitialStudySF.LnkSave.Click();
            InitialStudySF.LnkExit.Click();

            Workspace.SubmitMod(Users.Pi.UserName, Users.Pi.Password);
            PopUpWindow.SwitchTo(targetStudy,true);

            // why does Exists not retry?
            Wait.Until(h => new CCElement(By.LinkText("Submitted")).Exists);
            Assert.IsTrue(new CCElement(By.LinkText("Submitted")).Exists, "Attempted submitted mod does not exist 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 CopySubmission()
        {
            string targetStudy = "AutoTest-" + DataGen.String(5);
            CloneEntity("STUDY00000017", targetStudy);

            var ActionsNav = new ActivitiesNav();
            var CopySubmissionPage = new CopySubmission("STUDY-" + targetStudy, "Copy Submission");
            //var CopySubmissionPage = new CopySubmission("STUDY-AutoTest-iyULl", "Copy Submission");

            Store.LoginAsUser(Users.Irbd);

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

            string copyId = "Auto-SubmissionCopy" + DataGen.String(5);

            ActionsNav.LnkCopySubmission.Click();
            CopySubmissionPage.SwitchTo();
            CopySubmissionPage.TxtNewSubmissionName.Value = copyId;
            CopySubmissionPage.BtnOk.Click();
            CopySubmissionPage.SwitchBackToParent();

            Wait.Until(h => new CCElement(By.LinkText("Copied Submission")).Exists);
            Assert.IsTrue(new CCElement(By.LinkText("Copied Submission")).Exists, "Copied Submission not found for:  " + targetStudy);

            // Move this validation logic to page object
            Container divContainer = new Container(By.XPath("//div[@class='Component_ProjectLog_Notes'][\"Auto-SubmissionCopy\"]"));
            int i = 0;
            const int maxRetries = 15;
            while (!(divContainer.Text.Contains(copyId)) && i < maxRetries)
            {
                System.Threading.Thread.Sleep(1000);
                // have to manually refresh
                Web.PortalDriver.Navigate().Refresh();
                i++;
            }
            Assert.IsTrue(divContainer.Text.Contains(copyId), "Cannot find the 'submission copy':  " + copyId);
        }
        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);
        }