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

            Store.LoginAsUser(Users.Pi);
            Inbox.ImgCreateNewRNI.Click();
            // Fill in just required info
            RNISmartformPage.TxtRNIShortTitle.Value = RNITitle;
            RNISmartformPage.TxtDateAware.Value = "03/02/2014";
            RNISmartformPage.TxtDescriptionOfProblem.Value = "This is a RNI test for " + RNITitle;
            RNISmartformPage.RdoIsIncreasedRiskNo.Click();
            RNISmartformPage.RdoNeedRevisionNo.Click();
            RNISmartformPage.RdoConsentRequiresRevisionkNo.Click();
            RNISmartformPage.BtnContinue.Click();
            RNISmartformPage.BtnFinish.Click();
            // verify in history tab, pre-submission
            Wait.Until(h => new Link(By.LinkText("Reportable Information Opened")).Exists);
            Assert.IsTrue(new Link(By.LinkText("Reportable Information Opened")).Exists, "'Reportable Information Opened' activity not found for:  " + RNITitle);
            // SubmitRNI
            StudyWorkspacePage.SubmitRNI(Users.Pi.UserName, Users.Pi.Password);
            Assert.IsTrue(new Link(By.LinkText("RNI Submitted")).Exists, "'RNI Submitted' activity not found for:  " + RNITitle);
            Assert.IsTrue(StudyWorkspacePage.GetStudyState() == "Pre-Review", "State of RNI: Not in pre-review state");
        }
        public void ContinuingReviewThroughCommitteeReviewToApprovedAndStudyClosed()
        {
            string targetStudy = "AutoTest-" + DataGen.String(5);
            EntityClonerUtil.CloneEntity("STUDY00000024", targetStudy, true);

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

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

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

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

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

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

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

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

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

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

            // As the assigned coordinator, Prepare Letter.
            workspace.SendLetter();
            Assert.IsTrue(workspace.GetStudyState() == "Approved", "State expected not in 'Approved'.  State currently:  " + workspace.GetStudyState());
        }
        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.
        }
        //[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 ModificationStudyTeamOnlyCreation_NCR_ModsRequired_Approved()
        {
            string targetStudy = "AutoTest-" + DataGen.String(5);
            EntityClonerUtil.CloneEntity("STUDY00000024", targetStudy, true);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            // As the assigned coordinator, Send Letter.
            workspace.SendLetter();
            Assert.IsTrue(workspace.GetStudyState() == "Approved", "State expected not in 'Approved'.  State currently:  " + workspace.GetStudyState());
        }
        public void InsignificantRNIWithNoToSubmitRNIPreReviewToAcknowledged()
        {
            string RNITitle = "AutoTestRNI-" + DataGen.String(5);
            var InboxPage = new Inbox();
            var RNISmartformPage = new RNISmartform();
            var StudyWorkspacePage = new IRBWorkspace();
            var IRBSubmissionsPage = new IRBSubmissions();

            Store.LoginAsUser(Users.Pi);

            InboxPage.ImgCreateNewRNI.Click();
            // Fill in just required info
            RNISmartformPage.TxtRNIShortTitle.Value = RNITitle;
            RNISmartformPage.TxtDateAware.Value = "03/02/2014";
            RNISmartformPage.TxtDescriptionOfProblem.Value = "This is a RNI test for " + RNITitle;
            RNISmartformPage.RdoIsIncreasedRiskNo.Click();
            RNISmartformPage.RdoNeedRevisionNo.Click();
            RNISmartformPage.RdoConsentRequiresRevisionkNo.Click();
            RNISmartformPage.BtnContinue.Click();
            RNISmartformPage.BtnFinish.Click();

            // verify in history tab, pre-submission
            Wait.Until(h => new Link(By.LinkText("Reportable Information Opened")).Exists);
            Assert.IsTrue(new Link(By.LinkText("Reportable Information Opened")).Exists, "'Reportable Information Opened' activity not found for:  " + RNITitle);

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

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

            //As the assigned Coordinator, Submit RNI Pre-Review
            //(select only 5 through 8 determinations to create an insignificant RNI and NO to “Are you ready to submit this pre-review?”)
            StudyWorkspacePage.SubmitRNIPreReview("",false,SubmitRNIPreReview.Determinations.NoneOfTheAbove);
            Assert.IsTrue(StudyWorkspacePage.GetStudyState() == "Acknowledged", "State not in 'Acknowledged'.  Currently in state:  " + StudyWorkspacePage.GetStudyState());
        }
        public void MODCRStudyTeamOnlyCreationThroughNonCommitteeReviewWithModificationsRequiredToApproved()
        {
            string targetStudy = "AutoTest-" + DataGen.String(5);
            EntityClonerUtil.CloneEntity("STUDY00000024", targetStudy, true);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            // As the assigned IRB Coordinator, Send Letter.
            workspace.SendLetter();
            Assert.IsTrue(workspace.GetStudyState() == "Approved", "State expected not in 'Approved'.  State currently:  " + workspace.GetStudyID());
        }
        public void 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 InitialStudyCreationWithExternalIRB()
        {
            string targetStudy = "AutoTestStudy-" + DataGen.String(5);
            var InitialStudySF = new InitialStudySmartForm();
            var irbSubmissionsPage = new IRBSubmissions();
            var actionsNav = new ActionsNav();
            var workspace = new IRBWorkspace();

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

            InitialStudySF.NewSubmissionSmartformPage.TxtDescription.Value = "Random Automated test for IRB submission";
            InitialStudySF.NewSubmissionSmartformPage.TxtTitleStudy.Value = targetStudy;
            InitialStudySF.NewSubmissionSmartformPage.TxtShortTitle.Value = targetStudy;
            InitialStudySF.NewSubmissionSmartformPage.RdoFinancialInterestNo.Selected = true;
            InitialStudySF.NewSubmissionSmartformPage.RdoExternalIrbYes.Selected = true;
            //InitialStudySF.NewSubmissionSmartformPage.AttachProtocol(@"\\pdxstor\public\Aaron.Bentley\automation\testDoc.docx");
            InitialStudySF.NewSubmissionSmartformPage.BtnContinue.Click();

            // External IRB Page

            InitialStudySF.ExternalIrbPage.BtnSelectExternalIRB.Click();
            InitialStudySF.ExternalIrbPage.SelectOrgPopup.SwitchTo();
            InitialStudySF.ExternalIrbPage.SelectOrgPopup.SelectValue("Dummy External Institute");
            InitialStudySF.ExternalIrbPage.SelectOrgPopup.BtnOk.Click();
            InitialStudySF.ExternalIrbPage.SelectOrgPopup.SwitchBackToParent();
            InitialStudySF.ExternalIrbPage.BtnFinish.Click();
            Wait.Until(h => new Link(By.LinkText("Study Created")).Exists);

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

            //Log in as an IRB coordinator and Confirm External IRB.
            Store.LoginAsUser(Users.Irbc);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(targetStudy);
            workspace.ConfirmExternalIRB();
            Assert.IsTrue(workspace.GetStudyState() == "External IRB", "State expected not in 'External IRB'.  State currently: " + workspace.GetStudyState());

            //Log in as the PI and Update External IRB Status (yes to close study).
            Store.LoginAsUser(Users.Pi);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(targetStudy);
            workspace.UpdateExternalIRBStatus();
            Assert.IsTrue(workspace.GetStudyState() == "Closed", "State expected not in 'Closed'.  State currently: " + workspace.GetStudyState());
        }
        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 InitialStudyCreationWithNonCommitteeReview_HumanResearchNotEngaged()
        {
            string targetStudy = "AutoTestStudy-" + DataGen.String(5);
            var InitialStudySF = new InitialStudySmartForm();
            var irbSubmissionsPage = new IRBSubmissions();
            var actionsNav = new ActionsNav();
            var workspace = new IRBWorkspace();

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

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

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

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

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

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

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

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

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

            //As the assigned coordinator, Send Letter.
            workspace.SendLetter();
            Assert.IsTrue(workspace.GetStudyState() == "Human Research, Not Engaged", "State expected not in 'Human Research, Not Engaged'.  State currently:  " + workspace.GetStudyID());
        }
        public void 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 InsignificantRNIThroughDesignatedReviewToAcknowledgedMadeSignificantAndTransitionToCommitteeReview()
        {
            string RNITitle = "AutoTestRNI-" + DataGen.String(5);
            var inboxPage = new Inbox();
            var rniSmartformPage = new RNISmartform();
            var studyWorkspacePage = new IRBWorkspace();
            var irbSubmissionsPage = new IRBSubmissions();

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

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

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

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

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

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

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

            // Log in as the IRB Director and Submit RNI Designated Review (changing the determination to one of the top 4).
            Store.LoginAsUser(Users.Irbd);
            irbSubmissionsPage.OpenSubmissionByAllSubmissions(RNITitle);
            studyWorkspacePage.SubmitRNIDesignatedReview(SubmitDesignatedRNIReviewPopup.Determinations.UnanticipatedProblem, SubmitDesignatedRNIReviewPopup.Determinations.NoneOfTheAbove);
            Assert.IsTrue(studyWorkspacePage.GetStudyState() == "Committee Review", "State not in 'Committee Review'.  Currently in state:  " + studyWorkspacePage.GetStudyState());
        }
        public void MODCRStudyTeamOnlyCreationThroughCommitteeReviewToDeferred()
        {
            string targetStudy = "AutoTest-" + DataGen.String(5);
            EntityClonerUtil.CloneEntity("STUDY00000024", targetStudy, true);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            // As the assigned coordinator, Send Letter.
            workspace.SendLetter();
            Assert.IsTrue(workspace.GetStudyState() == "Approved", "State expected not in 'Approved'.  State currently:  " + workspace.GetStudyState());
        }
        public void 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");
        }