CRF Migration
store 2 eventCol
store TRACER Kosten crfName
store 1.03 toVersion
store https://yourserver/OpenClinica/ instanceURL
open ${instanceURL}ListStudySubjects
store 1 curRowTotal
store 1 curRowOnPage
storeEval window.document.getElementsByClassName("header")[2].children.length-7 nrEvents
storeEval myString = window.document.getElementsByClassName("statusBar")[0].textContent.trim(); myString.substring(myString.lastIndexOf(" ")+1, myString.lastIndexOf(".")); nrRows
storeEval javascript{String("\""+storedVars['toVersion']+"\"").replace(".", "\\.")} regToVersion
store 1 pageNr
storeEval storedVars['instanceURL']+"ListStudySubjects?module=admin&maxRows=15&showMoreLink=true&findSubjects_tr_=true&findSubjects_p_="+storedVars['pageNr']+"&findSubjects_mr_=15" page
goto next
label newPage
store 1 curRowOnPage
storeEval ${pageNr}+1 pageNr
storeEval storedVars['instanceURL']+"ListStudySubjects?module=admin&maxRows=15&showMoreLink=true&findSubjects_tr_=true&findSubjects_p_="+storedVars['pageNr']+"&findSubjects_mr_=15" page
goto next
label openPageMain
open ${page}
goto ${returnTo}
label loop
storeEval ${curRowTotal}+1 curRowTotal
storeEval ${curRowOnPage}+1 curRowOnPage
gotoIf ${curRowOnPage}%16==0 newPage
label next
store 0 curRepeat
storeEval ((${curRowOnPage}-1)*${nrEvents})+${eventCol}-1 index
echo ${index}
store continueMain returnTo
gotoIf !window.location.href.contains(storedVars['page']) openPageMain
label continueMain
storeEval myString = window.document.getElementsByClassName("ViewSubjectsPopup")[${index}].innerHTML; myRegexp = /.*Occurrence#1 of (\d+).*/i; match = myRegexp.exec(myString); if(match!==null) maxRepeat = match[1]; else maxRepeat = 1; maxRepeat
storeEval -1 curRepeat
storeEval if(${maxRepeat}>1) offset = 1; else offset = 0; offset
label handleEvents
store continueHandle returnTo
gotoIf !window.location.href.contains(storedVars['page']) openPageMain
label continueHandle
storeEval ${curRepeat}+1 curRepeat
gotoIf ${curRepeat} >= ${maxRepeat} checkQuit
storeEval ${offset}+(${curRepeat}*2) repeatIndex
storeEval window.document.getElementsByClassName("ViewSubjectsPopup")[storedVars['index']].querySelectorAll("tbody")[storedVars['repeatIndex']].innerHTML.contains("not scheduled") skipEntry
gotoIf ${skipEntry}==true handleEvents
storeEval window.document.getElementsByClassName("ViewSubjectsPopup")[storedVars['index']].querySelectorAll("tbody")[(storedVars['curRepeat']*2)+1].querySelector("a[href^=Enter]") myLink
goto selectCRFPage
label findCRFRow
store 0 crfIndex
label loopFind
storeEval ${crfIndex}+1 crfIndex
storeEval window.document.getElementsByClassName("tablebox_center")[1].firstElementChild.firstElementChild.children[${crfIndex}].firstElementChild.textContent.trim() crfNameFound
gotoIf storedVars['crfNameFound']==storedVars['crfName'] continueSelectCRFPage
goto loopFind
label selectCRFPage
echo ${myLink}
open ${myLink}
goto findCRFRow
label continueSelectCRFPage
storeEval window.document.getElementsByClassName("tablebox_center")[1].firstElementChild.firstElementChild.children[${crfIndex}].children[2].firstElementChild.getAttribute("alt") dataEntryStatus
storeEval (storedVars['dataEntryStatus'] =="Initial Data Entry") || (storedVars['dataEntryStatus']=="Data Entry Complete") changeDataEntry
gotoIf ${changeDataEntry}==false handleEvents
storeEval window.document.getElementsByClassName("tablebox_center")[1].firstElementChild.firstElementChild.children[${crfIndex}].children[5].firstElementChild.firstElementChild.firstElementChild.lastElementChild.lastElementChild.getAttribute("href") myLink2
label openLink
open ${instanceURL}${myLink2}
storeEval window.document.getElementById("selectedVersion").innerHTML.contains(">&nbsp;"+storedVars['toVersion']+"&nbsp;<") hasVersion
gotoIf ${hasVersion}==false handleEvents
select id=selectedVersion regexp:\s${regToVersion}\s
clickAndWait name=confirmCRFVersionSubmit
clickAndWait name=Submit
goto handleEvents
label checkQuit
gotoIf ${curRowTotal}<(${nrRows}) loop
label end
open ${instanceURL}ListStudySubjects
echo Done