var participantPortal={}; participantPortal.print=function(msg){ console.log(msg); } participantPortal.idField='participantStudyId'; participantPortal.init= function(cb=null){ let that=this; let action=function(){that.scriptsLoaded(cb);}; LABKEY.Utils.requiresScript(["crfTecant/crfSetup.js","crfTecant/crfData.js","crfTecant/crfHTML.js"],action); } participantPortal.scriptsLoaded= function(cb=null){ //if other script need init, just stack the init scripts //let action=function(){runQuery.init(cb);} crfData.setSetup(crfSetup); crfHTML.init(); let action=function(){crfData.init(cb);}; crfSetup.init(action); } participantPortal.getParticipantMap= function(){ if (!("participantMap" in this)){ this.participantMap=new Object(); this.sortByParticipantId(); } return this.participantMap; } participantPortal.getParticipantArray= function(id,formId){ let fName='[getParticipantArray/'+id+','+formId+']'; //this.print(fName); let pMap=this.getParticipantMap(); if (!(id in pMap)) pMap[id]=new Object(); if (!(formId in pMap[id])) pMap[id][formId]=new Array(); return pMap[id][formId]; } participantPortal.getParticipantLabel= function(entry){ let pid=entry['participantStudyId']; let loc=entry['participantLocalId']; let label=''; if (pid) label+=pid+' '; if (loc) label+='(Local: '+loc+')'; if (label.length==0) label="NONE"; return label; } participantPortal.generateFormArray= function(){ let fName='[generateFormArray]'; this.print(fName); //gang callbacks (last to first) let that=this; let makePortal=function(){that.makePortal();}; let setRegistration=function(){crfData.setRegistration(makePortal);}; let action=function(){crfSetup.parseSetup(setRegistration);} crfSetup.setContainers(action); } participantPortal.sortByParticipantId= function(){ let fName='[sortByParticipantId]'; //this.print(fName); //let pMap=this.getParticipantMap(); let rows=crfSetup.getRows('crfEntries'); for (let i=0;ifn) fn=n; for (let i=0;i