|
@@ -74,7 +74,7 @@ function generateDebugSection(config){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-function setAdditionalData(config,additionalData,entry){
|
|
|
|
|
|
+function setAdditionalData(config, additionalData,entry){
|
|
let debug=true;
|
|
let debug=true;
|
|
if (debug) print(config,"setAdditionalData");
|
|
if (debug) print(config,"setAdditionalData");
|
|
if (entry["showFlag"]==="NONE") {
|
|
if (entry["showFlag"]==="NONE") {
|
|
@@ -115,9 +115,106 @@ function readonlySetup(config){
|
|
return setup;
|
|
return setup;
|
|
}
|
|
}
|
|
|
|
|
|
-function generateSection(config, sectionName, sectionTitle, listName, additionalData){
|
|
|
|
|
|
+function afterFormSetup(config,formConfig,data){
|
|
|
|
|
|
- let formName=config.masterForm;
|
|
|
|
|
|
+ let debug=true;
|
|
|
|
+ if (debug) print(config,"afterFormSetup ["+data.rows.length+"]");
|
|
|
|
+ formConfig.formSetup=data;
|
|
|
|
+
|
|
|
|
+ //get list of queries
|
|
|
|
+ let fields=formConfig.formSetup.metaData.fields;
|
|
|
|
+
|
|
|
|
+ if (debug) print(config,"generateForm: fields: "+fields);
|
|
|
|
+ let field="NONE";
|
|
|
|
+ //if (debug) printTableSetup(config,data);
|
|
|
|
+ for (f in fields){
|
|
|
|
+ if (fields[f]['name']!='queryName') continue;
|
|
|
|
+ field=fields[f];
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ if (debug) print(config,"generateForm: field: "+field);
|
|
|
|
+ let lookup=field.lookup;
|
|
|
|
+ if (debug) print(config,"generateForm: lookup: "+lookup);
|
|
|
|
+ let qconfig=new Object();
|
|
|
|
+ qconfig.containerPath=config.containerPath;
|
|
|
|
+ qconfig.schemaName=lookup.schemaName;
|
|
|
|
+ qconfig.queryName=lookup.queryName;
|
|
|
|
+
|
|
|
|
+ //qconfig.filterArray=[LABKEY.Filter.create(lookup.keyColumn,entry['queryName'])];
|
|
|
|
+ qconfig.filterArray=[];
|
|
|
|
+ qconfig.success=function(data){afterFormSetupLookup(config,formConfig,data)};
|
|
|
|
+ LABKEY.Query.selectRows(qconfig);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+function afterFormSetupLookup(config,formConfig,data){
|
|
|
|
+ //walk through the list of datasets/list and generate tables for each list
|
|
|
|
+ let debug=true;
|
|
|
|
+
|
|
|
|
+ formConfig.formSetupLookup=data;
|
|
|
|
+
|
|
|
|
+ let rows=formConfig.formSetup.rows;
|
|
|
|
+ //extract list of forms from formConfig
|
|
|
|
+ for (let i=0;i<rows.length;i++){
|
|
|
|
+
|
|
|
|
+ //each from has multiple lists associated with it
|
|
|
|
+ if (debug) print(config,"generateForm ["+i+"/"+rows.length+"]");
|
|
|
|
+
|
|
|
|
+ let entry=rows[i];
|
|
|
|
+ //this is actually a pointer into another list (==lookup)
|
|
|
|
+ //another selectRows is needed to actually get the name for the queryName
|
|
|
|
+
|
|
|
|
+ //id : entry[queryName]
|
|
|
|
+ //name: dentry[queryName]
|
|
|
|
+
|
|
|
|
+ let queryId=entry['queryName'];
|
|
|
|
+
|
|
|
|
+ //walk over keys to get the right lookup entry
|
|
|
|
+ let lookupRows=formConfig.formSetupLookup.rows;
|
|
|
|
+ let dentry=undefined;
|
|
|
|
+ for (let j=0;j<lookupRows.length;j++){
|
|
|
|
+
|
|
|
|
+ if (lookupRows[j].Key!=queryId)
|
|
|
|
+ continue;
|
|
|
|
+ dentry=lookupRows[j];
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ if (dentry===undefined){
|
|
|
|
+ print(config,"generateForm ["+i+"] no list found");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ if (debug)
|
|
|
|
+ for (f in dentry)
|
|
|
|
+ print(config,"generateFormLookup field: "+f+" value: "+dentry[f]);
|
|
|
|
+
|
|
|
|
+ let queryName=dentry["queryName"];
|
|
|
|
+
|
|
|
|
+ if (debug) print(config,"generateFormLookup: ID: "+queryId+" name: "+queryName);
|
|
|
|
+
|
|
|
|
+ //update fields for review
|
|
|
|
+ if (!(queryName in config.fields))
|
|
|
|
+ config.fields[queryName]=new Object();
|
|
|
|
+
|
|
|
|
+ if (!(queryId in config.queryMap))
|
|
|
|
+ config.queryMap[queryId]=queryName;
|
|
|
|
+
|
|
|
|
+ let field=config.fields[queryName];
|
|
|
|
+
|
|
|
|
+ field.title=entry["title"];
|
|
|
|
+ field.queryId=queryId;
|
|
|
|
+
|
|
|
|
+ if (debug) print(config,"entry[showFlag]: "+entry["showFlag"]);
|
|
|
|
+
|
|
|
|
+ let additionalData=new Object();
|
|
|
|
+ setAdditionalData(config,additionalData,entry);
|
|
|
|
+ //section fits one dataset/list
|
|
|
|
+ generateSection(config,formConfig,queryName,entry["title"],queryName, additionalData);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+function generateSection(config, formConfig, sectionName, sectionTitle, listName, additionalData){
|
|
|
|
+
|
|
|
|
+ let formName=config.masterForm;//this is HTML designator of area on page
|
|
let debug=true;
|
|
let debug=true;
|
|
if (debug) print(config,"generateSection "+sectionName);
|
|
if (debug) print(config,"generateSection "+sectionName);
|
|
let tb=config.document.createElement('table');
|
|
let tb=config.document.createElement('table');
|
|
@@ -165,18 +262,28 @@ function generateSection(config, sectionName, sectionTitle, listName, additional
|
|
}
|
|
}
|
|
if (debug) print(config,"generate master table");
|
|
if (debug) print(config,"generate master table");
|
|
|
|
|
|
-
|
|
|
|
|
|
+
|
|
let setup=fullAccessSetup(config,listName);
|
|
let setup=fullAccessSetup(config,listName);
|
|
- if ("reviewMode" in config)
|
|
|
|
|
|
+ if (formConfig.formStatus=="Submitted")
|
|
setup=readonlySetup(config);
|
|
setup=readonlySetup(config);
|
|
|
|
+ if (formConfig.formStatus=="Approved")
|
|
|
|
+ setup=readonlySetup(config);
|
|
|
|
+
|
|
|
|
+
|
|
//master table is unique per visit
|
|
//master table is unique per visit
|
|
|
|
+
|
|
|
|
+
|
|
setup.unique=true;
|
|
setup.unique=true;
|
|
- generateTable(config,listName,divTable.id,true,additionalData,setup);
|
|
|
|
|
|
+ generateTable(config,formConfig,listName,divTable.id,true,additionalData,setup);
|
|
|
|
|
|
if (debug) print(config,"generate master table: done");
|
|
if (debug) print(config,"generate master table: done");
|
|
|
|
|
|
let generateSubTable=true;
|
|
let generateSubTable=true;
|
|
- if ("reviewMode" in config) generateSubTable=false;
|
|
|
|
|
|
+ if (formConfig.formStatus=="Submitted")
|
|
|
|
+ generateSubTable=false;
|
|
|
|
+ if (formConfig.formStatus=="Approved")
|
|
|
|
+ generateSubTable=false;
|
|
|
|
+
|
|
if (! ("showFlag" in additionalData) ) generateSubTable=false;
|
|
if (! ("showFlag" in additionalData) ) generateSubTable=false;
|
|
|
|
|
|
if (generateSubTable){
|
|
if (generateSubTable){
|
|
@@ -185,11 +292,12 @@ function generateSection(config, sectionName, sectionTitle, listName, additional
|
|
|
|
|
|
|
|
|
|
let setup=fullAccessSetup(config,qName);
|
|
let setup=fullAccessSetup(config,qName);
|
|
- if ("reviewMode" in config)
|
|
|
|
- setup=readonlySetup(config);
|
|
|
|
- generateTable(config,qName,dName,false,additionalData,setup);
|
|
|
|
|
|
+ //if (readonly) setup=readonlySetup(config);
|
|
|
|
+ generateTable(config,formConfig,qName,dName,false,additionalData,setup);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ print(config,"generate review");
|
|
|
|
+
|
|
let divReviewList=config.document.createElement('div');
|
|
let divReviewList=config.document.createElement('div');
|
|
divReviewList.id=sectionName+"ReviewList";
|
|
divReviewList.id=sectionName+"ReviewList";
|
|
div.appendChild(divReviewList);
|
|
div.appendChild(divReviewList);
|
|
@@ -201,34 +309,16 @@ function generateSection(config, sectionName, sectionTitle, listName, additional
|
|
|
|
|
|
//assume we already have listId (content of config.setupQueryName is listId)
|
|
//assume we already have listId (content of config.setupQueryName is listId)
|
|
//we need listName also
|
|
//we need listName also
|
|
- let qconfig=new Object();
|
|
|
|
- qconfig.containerPath=config.containerPath;
|
|
|
|
- qconfig.schemaName='lists';
|
|
|
|
//qconfig.queryName=config.setupQueryName;
|
|
//qconfig.queryName=config.setupQueryName;
|
|
- qconfig.queryName="FormSetup";
|
|
|
|
- qconfig.filterArray=[LABKEY.Filter.create("formName",config.formId)];
|
|
|
|
-
|
|
|
|
- qconfig.success=function(data){
|
|
|
|
- generateReview(config,data,divReview.id,divReviewList.id,listName)};
|
|
|
|
- LABKEY.Query.selectRows(qconfig);
|
|
|
|
|
|
+ generateReview(config,formConfig,divReview.id,divReviewList.id,listName);
|
|
}
|
|
}
|
|
|
|
|
|
-function generateReview(config,data,divReviewId,divReviewListId, listName){
|
|
|
|
|
|
+function generateReview(config,formConfig,divReviewId,divReviewListId, listName){
|
|
let listId=config.fields[listName].queryId;
|
|
let listId=config.fields[listName].queryId;
|
|
|
|
|
|
let debug=true;
|
|
let debug=true;
|
|
if (debug) print(config,"Generate review for: "+listId);
|
|
if (debug) print(config,"Generate review for: "+listId);
|
|
|
|
|
|
- //don't need this
|
|
|
|
- //let listId=-1;
|
|
|
|
- //for (let i=0;i<data.rows.length;i++){
|
|
|
|
- // let entry=data.rows[i];
|
|
|
|
- // if (entry["queryName"]!=listName) continue;
|
|
|
|
- // listId=entry["Key"];
|
|
|
|
- // break;
|
|
|
|
- //}
|
|
|
|
- //if (debug) print(config,"Review: setting listId: "+listId);
|
|
|
|
-
|
|
|
|
let reviewSetup=new Object();
|
|
let reviewSetup=new Object();
|
|
reviewSetup.readonlyFlag=function(vName){
|
|
reviewSetup.readonlyFlag=function(vName){
|
|
if (vName=="queryName") return true;
|
|
if (vName=="queryName") return true;
|
|
@@ -238,7 +328,7 @@ function generateReview(config,data,divReviewId,divReviewListId, listName){
|
|
reviewSetup.addApply="Add Review";
|
|
reviewSetup.addApply="Add Review";
|
|
|
|
|
|
let generateTableFlag=true;
|
|
let generateTableFlag=true;
|
|
- if ("reviewMode" in config && config.reviewMode == "APPROVED" ){
|
|
|
|
|
|
+ if (formConfig.formStatus == "Approved" ){
|
|
delete reviewSetup.addApply;
|
|
delete reviewSetup.addApply;
|
|
reviewSetup.readonlyFlag=function(vName){return false;}
|
|
reviewSetup.readonlyFlag=function(vName){return false;}
|
|
generateTableFlag=false;
|
|
generateTableFlag=false;
|
|
@@ -246,9 +336,10 @@ function generateReview(config,data,divReviewId,divReviewListId, listName){
|
|
|
|
|
|
reviewSetup.filters=new Object();
|
|
reviewSetup.filters=new Object();
|
|
reviewSetup.filters["crfRef"]=getCRFref(config);
|
|
reviewSetup.filters["crfRef"]=getCRFref(config);
|
|
- reviewSetup.filters["queryName"]=listId;//entry in reviewComments list is queryname, all in small caps
|
|
|
|
- //reviewSetup.filters["ModifiedBy"]=LABKEY.Security.currentUser.id;
|
|
|
|
|
|
+
|
|
|
|
+ reviewSetup.filters["queryName"]=listId;//entry in reviewComments list is queryname, all in small caps
|
|
//needs listName, in argument
|
|
//needs listName, in argument
|
|
|
|
+
|
|
reviewSetup.getInputId=function(vName){return listName+"_add"+vName};
|
|
reviewSetup.getInputId=function(vName){return listName+"_add"+vName};
|
|
reviewSetup.divReviewListId=divReviewListId;
|
|
reviewSetup.divReviewListId=divReviewListId;
|
|
|
|
|
|
@@ -262,10 +353,11 @@ function generateReview(config,data,divReviewId,divReviewListId, listName){
|
|
|
|
|
|
if (! generateTableFlag) return;
|
|
if (! generateTableFlag) return;
|
|
|
|
|
|
- generateTable(config,"reviewComments",divReviewId,false,new Object(),reviewSetup);
|
|
|
|
|
|
+
|
|
|
|
+ generateTable(config, formConfig,"reviewComments",divReviewId,false,new Object(),reviewSetup);
|
|
}
|
|
}
|
|
|
|
|
|
-function setListVisibility(config,setup,additionalData,readonlyFlag){
|
|
|
|
|
|
+function setListVisibility(config, setup,additionalData,readonlyFlag){
|
|
let debug=true;
|
|
let debug=true;
|
|
if (debug){
|
|
if (debug){
|
|
print(config,"Set list visibility ");
|
|
print(config,"Set list visibility ");
|
|
@@ -289,16 +381,18 @@ function setListVisibility(config,setup,additionalData,readonlyFlag){
|
|
let filters=new Object();
|
|
let filters=new Object();
|
|
if ("filters" in additionalData) filters=additionalData.filters;
|
|
if ("filters" in additionalData) filters=additionalData.filters;
|
|
x.style.display = "block";
|
|
x.style.display = "block";
|
|
- updateListDisplay(config,additionalData.divQueryName,additionalData.queryName,filters,readonlyFlag);
|
|
|
|
|
|
+ updateListDisplay(config,
|
|
|
|
+ additionalData.divQueryName,additionalData.queryName,filters,readonlyFlag);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-function updateListDisplay(config,divName,queryName,filters,readonlyFlag){
|
|
|
|
|
|
+function updateListDisplay(config, divName,queryName,filters,readonlyFlag){
|
|
let debug=true;
|
|
let debug=true;
|
|
|
|
|
|
if (debug) print(config,"UpdateListDisplay: Query - "+queryName+" div - "+divName);
|
|
if (debug) print(config,"UpdateListDisplay: Query - "+queryName+" div - "+divName);
|
|
|
|
|
|
if (divName=="NONE") return;
|
|
if (divName=="NONE") return;
|
|
|
|
+
|
|
let crfRef=getCRFref(config);
|
|
let crfRef=getCRFref(config);
|
|
let div=config.document.getElementById(divName);
|
|
let div=config.document.getElementById(divName);
|
|
|
|
|
|
@@ -382,12 +476,14 @@ function generateButton(config,divName,title,buttonName,callback,callbackParamet
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-function generateTable(config,listName,divName,unique,additionalData,setup){
|
|
|
|
|
|
+function generateTable(config,formConfig,listName,divName,unique,additionalData,setup){
|
|
let debug=true;
|
|
let debug=true;
|
|
|
|
|
|
if (debug) print(config,"generateTable: "+listName);
|
|
if (debug) print(config,"generateTable: "+listName);
|
|
|
|
+ //these objects will contain respective data for the entry
|
|
|
|
|
|
//add temp variables
|
|
//add temp variables
|
|
|
|
+ //this will capture the state of the data prior to updating
|
|
let qconfig=new Object();
|
|
let qconfig=new Object();
|
|
qconfig.containerPath=config.containerPath;
|
|
qconfig.containerPath=config.containerPath;
|
|
qconfig.schemaName='lists';
|
|
qconfig.schemaName='lists';
|
|
@@ -397,7 +493,7 @@ function generateTable(config,listName,divName,unique,additionalData,setup){
|
|
for (f in setup.filters){
|
|
for (f in setup.filters){
|
|
qconfig.filterArray.push(LABKEY.Filter.create(f,setup.filters[f]));
|
|
qconfig.filterArray.push(LABKEY.Filter.create(f,setup.filters[f]));
|
|
}
|
|
}
|
|
- qconfig.success=function(data){populateTable(config,data,divName,unique,additionalData,setup)};
|
|
|
|
|
|
+ qconfig.success=function(data){populateTable(config,formConfig, data,divName,unique,additionalData,setup)};
|
|
LABKEY.Query.selectRows(qconfig);
|
|
LABKEY.Query.selectRows(qconfig);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -417,11 +513,14 @@ function printTableSetup(config,data){
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-function populateTable(config,data,divName,unique,additionalData,setup){
|
|
|
|
|
|
+function populateTable(config,formConfig, data,divName,unique,additionalData,setup){
|
|
//generate and populate table with the first suitable entry
|
|
//generate and populate table with the first suitable entry
|
|
let debug=true;
|
|
let debug=true;
|
|
|
|
+ //avoid resetting of values
|
|
|
|
+ if (!(data.queryName in formConfig.dataFields))
|
|
|
|
+ formConfig.dataFields[data.queryName]=data.metaData.fields;
|
|
|
|
+
|
|
|
|
|
|
-
|
|
|
|
if (debug){
|
|
if (debug){
|
|
print(config,"populateTable Query: "+data.queryName+" divName: "+divName+" setup: "+setup);
|
|
print(config,"populateTable Query: "+data.queryName+" divName: "+divName+" setup: "+setup);
|
|
|
|
|
|
@@ -434,14 +533,21 @@ function populateTable(config,data,divName,unique,additionalData,setup){
|
|
|
|
|
|
if (debug)
|
|
if (debug)
|
|
print(config,"Data: nrows "+data.rows.length);
|
|
print(config,"Data: nrows "+data.rows.length);
|
|
-
|
|
|
|
- if (data.rows.length > 0) entry=data.rows[0];
|
|
|
|
|
|
+
|
|
|
|
+ //copy values from queryName to formConfig.entries
|
|
|
|
+ if (data.rows.length > 0) formConfig.entries[data.queryName]=data.rows[0];
|
|
|
|
+
|
|
|
|
+ //this is the current data snapshot
|
|
|
|
+ if (data.queryName in formConfig.entries)
|
|
|
|
+ entry=formConfig.entries[data.queryName];
|
|
|
|
+
|
|
|
|
|
|
let tb=config.document.createElement('table');
|
|
let tb=config.document.createElement('table');
|
|
tb.className="t2";
|
|
tb.className="t2";
|
|
config.document.getElementById(divName).appendChild(tb);
|
|
config.document.getElementById(divName).appendChild(tb);
|
|
|
|
|
|
- let fields=data.metaData.fields;
|
|
|
|
|
|
+ //this are the fields (probably constant)
|
|
|
|
+ let fields=formConfig.dataFields[data.queryName];
|
|
for (f in fields){
|
|
for (f in fields){
|
|
let field=fields[f];
|
|
let field=fields[f];
|
|
if (field.hidden) continue;
|
|
if (field.hidden) continue;
|
|
@@ -803,7 +909,22 @@ function onDatabaseUpload(config){
|
|
//figure out the participantId
|
|
//figure out the participantId
|
|
|
|
|
|
let qconfig=new Object();
|
|
let qconfig=new Object();
|
|
- qconfig.queryName=config.queryMap[config.registrationQueryId];
|
|
|
|
|
|
+
|
|
|
|
+ qconfig.schemaName="lists";
|
|
|
|
+ qconfig.queryName="Forms";
|
|
|
|
+ qconfig.filterArray=[LABKEY.Filter.create('Key',config.formId)];
|
|
|
|
+
|
|
|
|
+ //qconfig.filterArray=[LABKEY.Filter.create('formStatus',1)]
|
|
|
|
+ qconfig.success=function(data){afterForms(config,configUpload,data)};
|
|
|
|
+ LABKEY.Query.selectRows(qconfig);
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+function afterForms(config,configUpload,data){
|
|
|
|
+ let formEntry=data.rows[0];
|
|
|
|
+ configUpload.registrationQueryId=formEntry["masterQuery"];
|
|
|
|
+ let qconfig=new Object();
|
|
|
|
+ qconfig.queryName=config.queryMap[configUpload.registrationQueryId];
|
|
//queryMap holds mapping for queries in visit;
|
|
//queryMap holds mapping for queries in visit;
|
|
//masterQuery should be one of them, so this is safe.
|
|
//masterQuery should be one of them, so this is safe.
|
|
qconfig.schemaName='lists';
|
|
qconfig.schemaName='lists';
|
|
@@ -1087,7 +1208,7 @@ function completeWithFlag(config,data,flag){
|
|
if (debug){
|
|
if (debug){
|
|
if (flag==4) print(config,"complete with review");
|
|
if (flag==4) print(config,"complete with review");
|
|
}
|
|
}
|
|
- //redirect(config);
|
|
|
|
|
|
+ redirect(config);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -1127,7 +1248,8 @@ function finalValidation(config){
|
|
finalRedirect(config);
|
|
finalRedirect(config);
|
|
}
|
|
}
|
|
else{
|
|
else{
|
|
- updateSubmitStatus(config,"Form invalid");
|
|
|
|
|
|
+ let el=document.getElementById(config.submitReportId);
|
|
|
|
+ el.innerHTML="Form invalid";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1137,27 +1259,25 @@ function finalRedirect(config){
|
|
c1.schemaName='lists';
|
|
c1.schemaName='lists';
|
|
c1.queryName='crfEntry';
|
|
c1.queryName='crfEntry';
|
|
c1.filterArray=[LABKEY.Filter.create('entryId',getCRFref(config))];
|
|
c1.filterArray=[LABKEY.Filter.create('entryId',getCRFref(config))];
|
|
- c1.success=function(data){setSubmitStatus(config,data)};
|
|
|
|
|
|
+ c1.success=function(data){uploadData(config,data)};
|
|
LABKEY.Query.selectRows(c1);
|
|
LABKEY.Query.selectRows(c1);
|
|
}
|
|
}
|
|
|
|
|
|
-function setSubmitStatus(config,data){
|
|
|
|
|
|
+function uploadData(config,data){
|
|
let entry=data.rows[0];
|
|
let entry=data.rows[0];
|
|
entry.formStatus=2;//Submitted
|
|
entry.formStatus=2;//Submitted
|
|
|
|
+ let el=document.getElementById(config.submitReportId);
|
|
|
|
+ el.innerHTML="Submitting form";
|
|
let c1=new Object();
|
|
let c1=new Object();
|
|
c1.schemaName=data.schemaName;
|
|
c1.schemaName=data.schemaName;
|
|
c1.queryName=data.queryName;
|
|
c1.queryName=data.queryName;
|
|
c1.containerPath=config.containerPath;
|
|
c1.containerPath=config.containerPath;
|
|
c1.rows=[entry];
|
|
c1.rows=[entry];
|
|
- c1.success=function(data){updateSubmitStatus(config,"Form submitted")};
|
|
|
|
|
|
+ //close window upon success
|
|
|
|
+ c1.success=function(data){redirect(config)};
|
|
LABKEY.Query.updateRows(c1);
|
|
LABKEY.Query.updateRows(c1);
|
|
}
|
|
}
|
|
|
|
|
|
-function updateSubmitStatus(config,msg){
|
|
|
|
- let el=document.getElementById(config.submitReportId);
|
|
|
|
- el.innerHTML=msg;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
function hideErr(config){
|
|
function hideErr(config){
|
|
let el=config.document.getElementById("errorDiv");
|
|
let el=config.document.getElementById("errorDiv");
|
|
el.style.display="none";
|
|
el.style.display="none";
|
|
@@ -1455,54 +1575,114 @@ function afterConfig(config){
|
|
|
|
|
|
if (debug)
|
|
if (debug)
|
|
print(config,"generateMasterForm");
|
|
print(config,"generateMasterForm");
|
|
|
|
+
|
|
|
|
+ let selectRows=new Object();
|
|
|
|
+ selectRows.containerPath=config.containerPath;
|
|
|
|
+ selectRows.schemaName='lists';
|
|
|
|
+ selectRows.queryName='crfEntry';
|
|
|
|
+ selectRows.filterArray=[LABKEY.Filter.create('entryId',getCRFref(config))];
|
|
|
|
+
|
|
|
|
+ let formConfig=new Object();
|
|
|
|
+ //selectRows.success=function(data){populateBasicData(config,data)};
|
|
|
|
+ selectRows.success=function(data){afterCrf(config,formConfig,data)};
|
|
|
|
+ LABKEY.Query.selectRows(selectRows);
|
|
|
|
+}
|
|
|
|
|
|
|
|
+//requires populateBasicData
|
|
|
|
+function afterCrf(config,formConfig,data){
|
|
|
|
+ formConfig.crfEntry=data.rows[0];
|
|
|
|
+ //schedule basic data for later
|
|
|
|
+ populateBasicData(config,data);
|
|
|
|
|
|
- config.document.getElementById('investigatorName').innerHTML=config.formConfig.user['DisplayName'];
|
|
|
|
- config.document.getElementById('eudraCTNumber').innerHTML=config.formConfig.crfEntry['EudraCTNumber'];
|
|
|
|
- config.document.getElementById('studyCoordinator').innerHTML=config.formConfig.crfEntry['StudyCoordinator'];
|
|
|
|
- config.document.getElementById('studySponsor').innerHTML=config.formConfig.crfEntry['StudySponsor'];
|
|
|
|
- config.document.getElementById('siteName').innerHTML=config.formConfig.site['siteName'];
|
|
|
|
- config.document.getElementById('sitePhone').innerHTML=config.formConfig.site['sitePhone'];
|
|
|
|
|
|
+ let selectRows=new Object();
|
|
|
|
+ selectRows.containerPath=config.containerPath;
|
|
|
|
+ selectRows.schemaName='lists';
|
|
|
|
+ selectRows.queryName='FormStatus';
|
|
|
|
+ selectRows.filterArray=[];
|
|
|
|
+
|
|
|
|
+ selectRows.success=function(data){afterFormStatus(config,formConfig,data)};
|
|
|
|
+ LABKEY.Query.selectRows(selectRows);
|
|
|
|
|
|
|
|
|
|
- for (let i=0;i<config.formConfig.formSetup.rows.length;i++){
|
|
|
|
- let entry=config.formConfig.formSetup.rows[i];
|
|
|
|
- let queryName=config.formConfig.queryMap[entry['queryName']];
|
|
|
|
- let additionalData=new Object();
|
|
|
|
|
|
+ //use crfEntry['FormStatus'] to determine what configuration to display
|
|
|
|
+ //reviewMode equivalence table:
|
|
|
|
+ //
|
|
|
|
+ //FormStatus reviewMode
|
|
|
|
+ //In Progress undefined/EDIT
|
|
|
|
+ //Review Pending undefined/EDIT
|
|
|
|
+ //Submitted REVIEW
|
|
|
|
+ //Approved APPROVED
|
|
|
|
+
|
|
|
|
+ //two level indirect -
|
|
|
|
+ //
|
|
|
|
+ //1. learn of the FormStatus options by reading in the FormStatus list
|
|
|
|
+ //
|
|
|
|
+ //2. Load the crfEntry for this crfId
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
|
|
- setAdditionalData(config,additionalData,entry);
|
|
|
|
|
|
+
|
|
|
|
+function afterFormStatus(config, formConfig, data){
|
|
|
|
+ print(config,"afterFormStatus: ");
|
|
|
|
+ formConfig.formStatusData=data;
|
|
|
|
+
|
|
|
|
+ let rows=formConfig.formStatusData.rows;
|
|
|
|
|
|
- generateSection(config,queryName,entry['title'],queryName,additionalData);
|
|
|
|
- print(config,'Running this');
|
|
|
|
|
|
+ for (let i=0; i<rows.length; i++){
|
|
|
|
+ let key=rows[i].Key;
|
|
|
|
+ if (formConfig.crfEntry["FormStatus"]!=key)
|
|
|
|
+ continue;
|
|
|
|
+ formConfig.formStatus=rows[i].formStatus;
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
- //config.fields=new Object();
|
|
|
|
- //config.queryMap=new Object();
|
|
|
|
- config.fields=config.formConfig.fields;
|
|
|
|
- config.queryMap=config.formConfig.queryMap;
|
|
|
|
|
|
|
|
-
|
|
|
|
- if (debug)
|
|
|
|
- print(config,"Generating buttons");
|
|
|
|
-
|
|
|
|
- //requires onSubmit
|
|
|
|
- if ("reviewMode" in config){
|
|
|
|
- if (config.reviewMode=="REVIEW"){
|
|
|
|
|
|
+ print(config,"Generating buttons for formStatus \""+formStatus+"\"");
|
|
|
|
+
|
|
|
|
+ let done="FALSE";
|
|
|
|
+ if (formConfig.formStatus=="Submitted"){
|
|
|
|
+ generateButton(config,"submitDiv","Complete submission",
|
|
|
|
+ "Upload to database",onDatabaseUpload,config);
|
|
|
|
+ generateButton(config,"submitDiv","Review submission",
|
|
|
|
+ "Ask for further review",onUpdateForReview,config);
|
|
|
|
+ generateButton(config,"submitDiv","Remove submission",
|
|
|
|
+ "Remove CRF form",onRemoveCRF,config);
|
|
|
|
+ done="TRUE";
|
|
|
|
+ }
|
|
|
|
+ if (formConfig.formStatus=="Approved"){
|
|
|
|
+ generateButton(config,"submitDiv","Review submission",
|
|
|
|
+ "Restore form for further review",onUpdateForReview,config);
|
|
|
|
+ done="TRUE";
|
|
|
|
+ }
|
|
|
|
+ if (done=="FALSE"){
|
|
|
|
+ generateButton(config,"submitDiv","Complete submission",
|
|
|
|
+ "Submit",onSubmit,config);
|
|
|
|
+ generateButton(config,"submitDiv","Remove submission",
|
|
|
|
+ "Remove CRF form",onRemoveCRF,config);
|
|
|
|
|
|
- generateButton(config,"submitDiv","Complete submission","Upload to database",onDatabaseUpload,config);
|
|
|
|
- generateButton(config,"submitDiv","Review submission","Ask for further review",onUpdateForReview,config);
|
|
|
|
- generateButton(config,"submitDiv","Remove submission","Remove CRF form",onRemoveCRF,config);
|
|
|
|
- }
|
|
|
|
- if (config.reviewMode=="APPROVED"){
|
|
|
|
- generateButton(config,"submitDiv","Review submission","Restore form for further review",onUpdateForReview,config);
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- else{
|
|
|
|
- generateButton(config,"submitDiv","Complete submission","Submit",onSubmit,config);
|
|
|
|
- generateButton(config,"submitDiv","Remove submission","Remove CRF form",onRemoveCRF,config);
|
|
|
|
}
|
|
}
|
|
- generateButton(config,"submitDiv","Print Form (Experimental)","Print",printForm,config);
|
|
|
|
|
|
+
|
|
generateButton(config,"submitDiv","Done","Exit",redirect,config);
|
|
generateButton(config,"submitDiv","Done","Exit",redirect,config);
|
|
|
|
+
|
|
|
|
+ //schedule actual forms
|
|
|
|
+ config.fields=new Object();
|
|
|
|
+ config.queryMap=new Object();
|
|
|
|
+
|
|
|
|
+ //data and layout of actual forms
|
|
|
|
+ //filled in generateTable
|
|
|
|
+ formConfig.entries=new Object();
|
|
|
|
+ formConfig.dataFields=new Object();
|
|
|
|
+
|
|
|
|
+ let configSelectRows=new Object();
|
|
|
|
+ configSelectRows.containerPath=config.containerPath;
|
|
|
|
+ configSelectRows.schemaName='lists';
|
|
|
|
+ configSelectRows.queryName=config.setupQueryName;
|
|
|
|
+ //this is new
|
|
|
|
+ configSelectRows.queryName="FormSetup";
|
|
|
|
+ configSelectRows.filterArray=[LABKEY.Filter.create("formName",config.formId)];
|
|
|
|
+
|
|
|
|
+ configSelectRows.success=function(data){afterFormSetup(config,formConfig,data);};
|
|
|
|
+ configSelectRows.failure=onFailure;//function(errorTxt){print(config,"generateForm fail" + errorTxt)};
|
|
|
|
+ LABKEY.Query.selectRows(configSelectRows);
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|