|
@@ -23,13 +23,46 @@ participantIdManager.set=
|
|
|
function(setup,data){
|
|
|
this.setup=setup;
|
|
|
this.data=data;
|
|
|
+ this.updateCrfEntry=function(){;}
|
|
|
+ this.mode='STUDY';
|
|
|
+ //this.generateTable();
|
|
|
+}
|
|
|
+
|
|
|
+participantIdManager.setMode=
|
|
|
+function(mode){
|
|
|
+ this.mode=mode;
|
|
|
+}
|
|
|
+
|
|
|
+participantIdManager.getMode=
|
|
|
+function(){
|
|
|
+ return this.mode;
|
|
|
+}
|
|
|
+
|
|
|
+participantIdManager.setReadonly=
|
|
|
+function(mode){
|
|
|
+ if (!("readonly" in this)){
|
|
|
+ this.readonly=new Object();
|
|
|
+ this.readonly['LOCAL']=false;
|
|
|
+ this.readonly['STUDY']=false;
|
|
|
+ }
|
|
|
+ if (mode=="LOCAL"){
|
|
|
+ this.readonly[mode]=true;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.readonly['STUDY']=true;
|
|
|
+}
|
|
|
+
|
|
|
+participantIdManager.isReadonly=
|
|
|
+function(mode){
|
|
|
+ if (mode=='LOCAL') return this.readonly['LOCAL'];
|
|
|
+ return this.readonly['STUDY'];
|
|
|
}
|
|
|
|
|
|
participantIdManager.addSelectOptions=
|
|
|
-function(pM){
|
|
|
- if (pM.mode=="LOCAL") return;
|
|
|
+function(mode=null){
|
|
|
+ if (mode=="LOCAL") return;
|
|
|
|
|
|
- let input=this.getInputElement(pM);
|
|
|
+ let input=this.getInputElement(mode);
|
|
|
|
|
|
let fName='addParticipantSelectOptions';
|
|
|
this.print(fName+' input '+input);
|
|
@@ -40,36 +73,23 @@ function(pM){
|
|
|
this.print(fName+" demoRows: "+demoRows.length);
|
|
|
let opts=new Object();
|
|
|
for (let i=0;i<demoRows.length;i++){
|
|
|
- let id=demoRows[i][this.getCrfEntryFieldName(pM)];
|
|
|
- let loc=demoRows[i][this.getCrfEntryFieldName(pM,'LOCAL')];
|
|
|
- opt2[i+1]=id+' (Local: '+loc+')';
|
|
|
+ opt2[i+1]=this.setup.getParticipantLabel(demoRows[i]);
|
|
|
}
|
|
|
crfHTML.addSelectOptions(input,opts);
|
|
|
}
|
|
|
|
|
|
participantIdManager.updateElements=
|
|
|
-function(pM){
|
|
|
+function(mode=null){
|
|
|
let fName='[updateElements]';
|
|
|
//reset all values (some might be different depending on the call timing)
|
|
|
|
|
|
//selector is with study
|
|
|
- pM.cellSelector=crfHTML.getElement(pM.cellSelectorId);
|
|
|
- pM.inputSelector=crfHTML.getElement(pM.inputSelectorId);
|
|
|
- pM.textStudy=crfHTML.getElement(pM.textStudyId);
|
|
|
-
|
|
|
- this.print(fName+' selector '+pM.inputSelector+' id '+pM.inputSelectorId);
|
|
|
- //value is with local
|
|
|
- pM.cellValue=crfHTML.getElement(pM.cellValueId);
|
|
|
- pM.inputValue=crfHTML.getElement(pM.inputValueId);
|
|
|
- pM.textLocal=crfHTML.getElement(pM.textLocalId);
|
|
|
-
|
|
|
- //pM.inputManageLocal=this.parent.getElement(pM.inputManageLocalId);
|
|
|
//pM.inputManageStudy=this.parent.getElement(pM.inputManageStudyId);
|
|
|
}
|
|
|
|
|
|
|
|
|
-participantIdManager.generateEntryField=
|
|
|
-function(pM){
|
|
|
+participantIdManager.generateTable=
|
|
|
+function(){
|
|
|
let fName='[generateParticipantEntryField]:';
|
|
|
this.print(fName);
|
|
|
|
|
@@ -78,10 +98,9 @@ function(pM){
|
|
|
this.print(fName+' master '+formName);
|
|
|
|
|
|
|
|
|
- pM.tb=crfHTML.createTable(formName);
|
|
|
- let tb=pM.tb;
|
|
|
- tb.className='t2';
|
|
|
- let row=tb.insertRow();
|
|
|
+ this.table=crfHTML.createTable(formName);
|
|
|
+ this.table.className='t2';
|
|
|
+ let row=this.table.insertRow();
|
|
|
|
|
|
//label for local ID
|
|
|
let cell=crfHTML.createTblHeader(null,row);
|
|
@@ -95,12 +114,13 @@ function(pM){
|
|
|
|
|
|
//value
|
|
|
let cellValue=row.insertCell();
|
|
|
- cellValue.id=pM.cellValueId;
|
|
|
+ //cellValue.id=pM.cellValueId;
|
|
|
|
|
|
- pM.cellManageLocal=row.insertCell();
|
|
|
+ let cellButton=row.insertCell();
|
|
|
+ this.getInputButton('LOCAL');
|
|
|
|
|
|
//second row for study id
|
|
|
- let rowStudy=tb.insertRow();
|
|
|
+ let rowStudy=this.table.insertRow();
|
|
|
|
|
|
//label for study ID
|
|
|
let cellStudy=crfHTML.createTblHeader(null,rowStudy);
|
|
@@ -111,92 +131,81 @@ function(pM){
|
|
|
cellStudy.innerText='Study ID';
|
|
|
|
|
|
//selector for study id
|
|
|
- let cellSelector=rowStudy.insertCell();
|
|
|
- cellSelector.id=pM.cellSelectorId;
|
|
|
+ cellValue=rowStudy.insertCell();
|
|
|
|
|
|
//manage
|
|
|
- pM.cellManageStudy=rowStudy.insertCell();
|
|
|
+ cellButton=rowStudy.insertCell();
|
|
|
this.print(fName+' done');
|
|
|
+ this.getInputButton('STUDY');
|
|
|
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-participantIdManager.getMode=
|
|
|
-function(pM,mode="NONE"){
|
|
|
- if (mode=="NONE") return pM.mode;
|
|
|
- return mode;
|
|
|
+participantIdManager.getRow=
|
|
|
+function(mode=null){
|
|
|
+ let row=this.table.rows[1];
|
|
|
+ if (mode=="LOCAL")
|
|
|
+ row=this.table.rows[0];
|
|
|
+ return row;
|
|
|
}
|
|
|
|
|
|
-//reslovers which operate depending on mode
|
|
|
-participantIdManager.getInputId=
|
|
|
-function(pM,mode="NONE"){
|
|
|
- let fName='[getInputId]';
|
|
|
- this.print(fName);
|
|
|
- if (this.getMode(pM,mode)=="LOCAL") return pM.inputValueId;
|
|
|
- return pM.inputSelectorId;
|
|
|
+
|
|
|
+participantIdManager.getValueCell=
|
|
|
+function(mode="NONE"){
|
|
|
+ return this.getRow(mode).cells[1];
|
|
|
}
|
|
|
|
|
|
|
|
|
-participantIdManager.getInputCell=
|
|
|
-function(pM,mode="NONE"){
|
|
|
- let fName='[getInputCell]';
|
|
|
- this.print(fName+' mode '+mode+' getMode '+this.getMode(pM,mode));
|
|
|
- if (this.getMode(pM,mode)=="LOCAL") return pM.cellValue;
|
|
|
- return pM.cellSelector;
|
|
|
+participantIdManager.getButtonCell=
|
|
|
+function(mode="NONE"){
|
|
|
+ return this.getRow(mode).cells[2];
|
|
|
}
|
|
|
|
|
|
+participantIdManager.getValueElement=
|
|
|
+function(mode=null){
|
|
|
+ return this.getValueCell(mode).firstChild;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
participantIdManager.getInputElement=
|
|
|
-function(pM,mode="NONE"){
|
|
|
+function(mode=null){
|
|
|
let fName='[getInputElement]';
|
|
|
this.print(fName);
|
|
|
- let elementType=this.getInputElementType(pM,mode);
|
|
|
- let id=this.getInputId(pM,mode);
|
|
|
- let cell=this.getInputCell(pM,mode);
|
|
|
- let el=crfHTML.getElement(id);
|
|
|
- this.print(fName+' mode '+this.getMode(pM,mode)+' type '+elementType+' id '+id+' cell '+cell+' el '+el);
|
|
|
+ let el=this.getValueElement(mode);
|
|
|
if (el) return el;
|
|
|
+ return this.createInputElement(mode);
|
|
|
+}
|
|
|
+
|
|
|
+participantIdManager.createInputElement=
|
|
|
+function(mode=null){
|
|
|
+ let elementType=this.getInputElementType(mode);
|
|
|
+ let cell=this.getInputCell(mode);
|
|
|
|
|
|
if (elementType=="input") el=crfHTML.createTextInput();
|
|
|
if (elementType=="select") el=crfHTML.createSelect(new Object());
|
|
|
this.print(fName+' input '+el);
|
|
|
- el.id=id;
|
|
|
|
|
|
cell.replaceChildren(el);
|
|
|
- this.addSelectOptions(pM);
|
|
|
+ this.addSelectOptions();
|
|
|
|
|
|
return el;
|
|
|
}
|
|
|
|
|
|
participantIdManager.getInputElementType=
|
|
|
-function(pM,mode="NONE"){
|
|
|
+function(mode=null){
|
|
|
let fName='[getInputElementType]';
|
|
|
this.print(fName);
|
|
|
- if (this.getMode(pM,mode)=="LOCAL") return "input";
|
|
|
+ if (mode=="LOCAL") return "input";
|
|
|
return "select";
|
|
|
}
|
|
|
|
|
|
|
|
|
-participantIdManager.getTextFieldId=
|
|
|
-function(pM,mode="NONE"){
|
|
|
- let fName='[getTextFieldId]';
|
|
|
- this.print(fName);
|
|
|
- if (this.getMode(pM,mode)=="LOCAL") return pM.textLocalId;
|
|
|
- return pM.textStudyId;
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
participantIdManager.getTextElement=
|
|
|
-function(pM,mode="NONE"){
|
|
|
+function(mode=null){
|
|
|
let fName='[getTextElement]';
|
|
|
- this.print(fName+' mode '+mode);
|
|
|
- let id=this.getTextFieldId(pM,mode);
|
|
|
- this.print(fName+' id '+id);
|
|
|
- let el=crfHTML.getElement(id);
|
|
|
- this.print(fName+' el '+el);
|
|
|
+ let el=this.getValueElement(mode);
|
|
|
if (el) return el;
|
|
|
el=crfHTML.createParagraph('');
|
|
|
- el.id=id;
|
|
|
- let cell=this.getInputCell(pM,mode);
|
|
|
+ let cell=this.getValueCell(mode);
|
|
|
//let oldEl=pM.getInputElement(mode);
|
|
|
cell.replaceChildren(el);
|
|
|
return el;
|
|
@@ -204,90 +213,100 @@ function(pM,mode="NONE"){
|
|
|
|
|
|
|
|
|
//get the button, create if not there yet
|
|
|
-participantIdManager.getInputManage=
|
|
|
-function(pM,mode="NONE"){
|
|
|
+participantIdManager.getInputButton=
|
|
|
+function(mode=null){
|
|
|
let fName='[getInputManage]';
|
|
|
//this.print(fName);
|
|
|
//this prevents from having two inputs; it is either local or global from the outset
|
|
|
- if ("inputManage" in pM) return pM.inputManage;
|
|
|
-
|
|
|
- let cell=pM.cellManageStudy;
|
|
|
- if (this.getMode(pM,mode)=="LOCAL") cell=pM.cellManageLocal;
|
|
|
- pM.inputManage=crfHTML.createButton(null,cell);
|
|
|
+ let cell=this.getButtonCell(mode);
|
|
|
+ let el=cell.firstChild;
|
|
|
+ if (el) return el;
|
|
|
+ el=crfHTML.createButton(null,cell);
|
|
|
let that=this;
|
|
|
- pM.inputManage.onclick=function(){that.manageId(pM);};
|
|
|
- //inputManageLocal.id=pM.inputManageLocalId;
|
|
|
- //this.print(fName+' inputManage '+pM.inputManage+' cell '+cell+' mode '+pM.mode);
|
|
|
- return pM.inputManage;
|
|
|
+ el.onclick=function(){that.manageId(mode);};
|
|
|
+ return el;
|
|
|
}
|
|
|
|
|
|
//callback that splits to edit or set/label mode
|
|
|
|
|
|
participantIdManager.manageId=
|
|
|
-function(pM){
|
|
|
+function(mode){
|
|
|
let fName='[manageId]';
|
|
|
this.print(fName);
|
|
|
//this can happen after object was created, so make sure current
|
|
|
//elements are used
|
|
|
- this.updateElements(pM);
|
|
|
- let x=this.getInputManage(pM);
|
|
|
+ //this.updateElements();
|
|
|
+ let x=this.getInputButton(mode);
|
|
|
|
|
|
if (x.value=="Set"){
|
|
|
- this.setId(pM);
|
|
|
+ this.setId(mode);
|
|
|
return;
|
|
|
}
|
|
|
if (x.value=="Edit"){
|
|
|
- this.editId(pM);
|
|
|
+ this.editId(mode);
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//set mode
|
|
|
participantIdManager.setId=
|
|
|
-function(pM){
|
|
|
+function(mode=null){
|
|
|
let fName='[setId]';
|
|
|
this.print(fName);
|
|
|
- let el=this.getInputElement(pM);
|
|
|
+ let el=this.getInputElement(mode);
|
|
|
|
|
|
this.print(fName+" value: "+el.value);
|
|
|
let pId=el.value;
|
|
|
let label=pId;
|
|
|
- if (pM.mode!="LOCAL"){
|
|
|
+ if (mode!="LOCAL"){
|
|
|
+ //extract from select
|
|
|
if (el.value<0) return;
|
|
|
let opt=el.options[el.selectedIndex];
|
|
|
label=opt.text;
|
|
|
- pId=label.replace(/\(.*\)/,'');
|
|
|
- label=label.replace(/ \(Local: /,':');
|
|
|
- label=label.replace(/\)/,'');
|
|
|
+ pId=crfSetup.getStudyId(label);
|
|
|
+ //label=label.replace(/ \(Local: /,':');
|
|
|
+ //label=label.replace(/\)/,'');
|
|
|
}
|
|
|
- this.setParticipantIdToCrfEntry(pM,pId);//no argument (should come from mode)
|
|
|
+ this.setParticipantIdToCrfEntry(mode,pId);//no argument (should come from mode)
|
|
|
this.print(fName+" new value "+pId);
|
|
|
- this.setLabelMode(pM,label);
|
|
|
+ this.setLabelMode(mode,label);
|
|
|
pM.updateCrfEntry();
|
|
|
}
|
|
|
|
|
|
participantIdManager.setLabelMode=
|
|
|
-function(pM,pId){
|
|
|
+function(mode,label){
|
|
|
let fName='[setLabelMode1]';
|
|
|
|
|
|
- this.print(fName+' id '+pId);
|
|
|
- let ids=pId.split(':');
|
|
|
+ this.print(fName+' id '+label);
|
|
|
+ //this will give two for study and one entry for local
|
|
|
+ //let ids=pId.split(':');
|
|
|
+ let id=label;
|
|
|
+ if (mode!='LOCAL'){
|
|
|
+ if (label=='NOT SET')
|
|
|
+ id=label;
|
|
|
+ else
|
|
|
+ id=crfSetup.getStudyId(label);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
- let textValue=this.getTextElement(pM);
|
|
|
+ let textValue=this.getTextElement(mode);
|
|
|
this.print(fName+' textElement '+textValue);
|
|
|
- textValue.innerText=ids[0];
|
|
|
+ textValue.innerText=id;
|
|
|
|
|
|
- if (pM.mode=="STUDY"){
|
|
|
- let loc=ids[1];
|
|
|
- //pM.getParticipantIdFromCrfEntry('LOCAL');
|
|
|
+ if (mode!="LOCAL"){
|
|
|
+ let loc=crfSetup.getLocalId(label);
|
|
|
this.print(fName+' setting local id '+loc);
|
|
|
- let tValLocal=this.getTextElement(pM,'LOCAL');
|
|
|
- tValLocal.innerText=loc;
|
|
|
+ if (loc && loc!='null'){
|
|
|
+ //pM.getParticipantIdFromCrfEntry('LOCAL');
|
|
|
+ let tValLocal=this.getTextElement('LOCAL');
|
|
|
+ tValLocal.innerText=loc;
|
|
|
+ }
|
|
|
//this.setParticipantIdToCrfEntry(pM,loc,'LOCAL');
|
|
|
}
|
|
|
|
|
|
- let x=this.getInputManage(pM);//getInputManage
|
|
|
- if ("readOnly" in pM){
|
|
|
+ let x=this.getInputButton(mode);//getInputManage
|
|
|
+ let readonly=this.isReadonly(mode);
|
|
|
+ if (readonly){
|
|
|
x.style.display="none";
|
|
|
}
|
|
|
x.value="Edit";
|
|
@@ -297,20 +316,20 @@ function(pM,pId){
|
|
|
|
|
|
//edit mode
|
|
|
participantIdManager.editId=
|
|
|
-function(pM){
|
|
|
- this.setEditMode(pM);
|
|
|
+function(mode){
|
|
|
+ this.setEditMode(mode);
|
|
|
}
|
|
|
|
|
|
|
|
|
participantIdManager.setEditMode=
|
|
|
-function(pM){
|
|
|
+function(mode){
|
|
|
|
|
|
let fName='[setEditMode1]';
|
|
|
- this.print(fName+' pM '+pM+' mode '+pM.mode);
|
|
|
+ this.print(fName+' pM '+this+' mode '+mode);
|
|
|
//input
|
|
|
- let el=this.getInputElement(pM);
|
|
|
+ let el=this.getInputElement(mode);
|
|
|
|
|
|
- let x=this.getInputManage(pM);
|
|
|
+ let x=this.getInputButton(mode);
|
|
|
x.value="Set";
|
|
|
|
|
|
}
|
|
@@ -322,84 +341,35 @@ function(){
|
|
|
}
|
|
|
|
|
|
participantIdManager.getCrfEntryFieldName=
|
|
|
-function(pM,mode="NONE"){
|
|
|
- let variable="Study";
|
|
|
- if (mode=="NONE") mode=pM.mode;
|
|
|
+function(mode=null){
|
|
|
if (mode=="LOCAL") return crfSetup.getLocalIdLabel();
|
|
|
return crfSetup.getStudyIdLabel();
|
|
|
}
|
|
|
|
|
|
participantIdManager.setParticipantIdToCrfEntry=
|
|
|
-function(pM,pId,mode="NONE"){
|
|
|
- this.data.getCrfEntry()[this.getCrfEntryFieldName(pM,mode)]=pId;
|
|
|
+function(mode,pId){
|
|
|
+ let id=pId;
|
|
|
+ this.data.getCrfEntry()[this.getCrfEntryFieldName(mode)]=id;
|
|
|
}
|
|
|
|
|
|
participantIdManager.getParticipantIdFromCrfEntry=
|
|
|
-function(pM,mode="NONE"){
|
|
|
- return this.data.getCrfEntry()[this.getCrfEntryFieldName(pM,mode)];
|
|
|
+function(mode=null){
|
|
|
+ return this.data.getCrfEntry()[this.getCrfEntryFieldName(mode)];
|
|
|
}
|
|
|
|
|
|
participantIdManager.verifyCrfStudyId=
|
|
|
-function(pM){
|
|
|
+function(){
|
|
|
|
|
|
//is studyId already set for the crf
|
|
|
- let studyId=this.getParticipantIdFromCrfEntry(pM,'STUDY');
|
|
|
+ let studyId=this.getParticipantIdFromCrfEntry('STUDY');
|
|
|
if (!studyId) return;
|
|
|
- pM.mode="STUDY";
|
|
|
- pM.readOnly="TRUE";
|
|
|
-}
|
|
|
-
|
|
|
-participantIdManager.verifyRegistration=
|
|
|
-function(pM, formConfig){
|
|
|
- //if registration is in,
|
|
|
- //then local id should not be changed any longer
|
|
|
- let idFieldName=this.getCrfEntryFieldName(pM,"STUDY");
|
|
|
- //let fQuery=config.formConfig.registrationData;
|
|
|
- let fQuery=formConfig.registrationData;
|
|
|
- if (fQuery.rows.length==0) return; //registration is empty
|
|
|
-
|
|
|
- let studyId=fQuery.rows[0][idFieldName];
|
|
|
- if (!studyId) return; //study id not set
|
|
|
- //set
|
|
|
- pM.mode="STUDY";
|
|
|
- pM.readOnly="TRUE";
|
|
|
- //set crf (this happens later, but probably before the form will be corrected)
|
|
|
- this.setParticipantIdToCrfEntry(pM,studyId,"STUDY");
|
|
|
- pM.updateCrfEntry();
|
|
|
+ this.setReadonly('STUDY');
|
|
|
+ this.setMode("STUDY");
|
|
|
+ this.setLabelMode('STUDY',this.setup.getParticipantLabel(this.data.getCrfEntry()));
|
|
|
+ //subject to content of localId
|
|
|
+ let localId=this.getParticipantIdFromCrfEntry('LOCAL');
|
|
|
+ if (localId) this.setReadonly('LOCAL');
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
|
-//main interface. Use this to generate object and to refer to it later on
|
|
|
-participantIdManager.getObject=
|
|
|
-function(){
|
|
|
-
|
|
|
- let fName='[getParticipantManagerObject]';
|
|
|
- this.print(fName);
|
|
|
-
|
|
|
- let pM=new Object();
|
|
|
-
|
|
|
- //this never change
|
|
|
- pM.participantField=this.getParticipantField();
|
|
|
-
|
|
|
-
|
|
|
- pM.cellSelectorId=pM.participantField+"_cellSelect";
|
|
|
- pM.inputSelectorId=pM.participantField+"_Select";
|
|
|
- pM.textStudyId=pM.participantField+"_textStudy";
|
|
|
-
|
|
|
- pM.cellValueId=pM.participantField+"_cellValue";
|
|
|
- pM.inputValueId=pM.participantField+"_Value";
|
|
|
- pM.textLocalId=pM.participantField+"_textLocal";
|
|
|
-
|
|
|
- pM.inputManageLocalId=pM.participantField+"_ManageLocal";
|
|
|
- pM.inputManageStudyId=pM.participantField+"_ManageStudy";
|
|
|
-
|
|
|
- pM.mode="LOCAL";//or "STUDY"
|
|
|
-
|
|
|
- //dummy function to be overloaded by calling class
|
|
|
- pM.updateCrfEntry=function(){;}
|
|
|
-
|
|
|
- //init
|
|
|
- this.generateEntryField(pM);
|
|
|
- this.updateElements(pM);
|
|
|
- return pM;
|
|
|
-}
|