| 
					
				 | 
			
			
				@@ -79,7 +79,7 @@ function generateDebugSection(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	debugArea.id=config.debugId; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	div.appendChild(debugArea); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	//print('ver: 0.10'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -326,6 +326,8 @@ function getParticipantCode(pid){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	//we should now which form we are in 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	let mfId=config.formConfig.form['masterQuery']; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	selectRows.queryName=config.formConfig.queryMap[mfId]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	//point to data container 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	selectRows.containerPath=getContainer('data'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	//selectRows.queryName='PET'; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -469,11 +471,14 @@ function showProbability(cell,k,row,rowSetup,j,obj,pid){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	selectRows.queryName=obj.queryName; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	selectRows.schemaName="study"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	selectRows.filterArray=[]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	selectRows.containerPath=getContainer('data'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	for (let f in obj.filters){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		selectRows.filterArray.push(LABKEY.Filter.create(f,pid[obj.filters[f]])); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		selectRows.filterArray.push( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				LABKEY.Filter.create(f,pid[obj.filters[f]])); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		print('Filter ['+f+']: '+pid[obj.filters[f]]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	selectRows.success=function(data){drawProbability(data,cell,obj,pid,probDensity);} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	selectRows.success=function(data){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		drawProbability(data,cell,obj,pid,probDensity);} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	LABKEY.Query.selectRows(selectRows); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -749,7 +754,8 @@ function updateListDisplay(divName,queryName,filters,readonlyFlag){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	var qconfig=new Object(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	qconfig.renderTo=divName; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	qconfig.containerPath=config.containerPath; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	//point to data container 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	qconfig.containerPath=getContainer('data'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	qconfig.schemaName='lists';  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	qconfig.queryName=queryName; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	qconfig.buttonBarPosition='top'; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1297,7 +1303,8 @@ function saveReview(queryName,elementId,setup){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			let ctx=new Object(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			ctx['dirName']='consent'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			ctx['ID']=entry['crfRef']; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			ctx['project']=config.containerPath; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			//should point to data container 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			ctx['project']=getContainer('data'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			//need ID->crf! 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			//assume crfRef will get set before this 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			//element is encountered 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1327,7 +1334,8 @@ function saveReview(queryName,elementId,setup){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	let qconfig=new Object(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	qconfig.rows=[entry]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	qconfig.containerPath=config.containerPath; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	//should point to data container 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	qconfig.containerPath=getContainer('data'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	qconfig.schemaName='lists'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	qconfig.queryName=queryName; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1367,6 +1375,8 @@ function onDatabaseUpload(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	let qconfig=new Object(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	qconfig.schemaName="lists"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	//redirect to configuration container 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	qconfig.containerPath=getContainer('config'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	qconfig.queryName="Forms"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	qconfig.filterArray=[LABKEY.Filter.create('Key',config.formId)]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1386,6 +1396,7 @@ function afterForms(configUpload,data){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	//queryMap holds mapping for queries in visit;  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	//masterQuery should be one of them, so this is safe. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	qconfig.schemaName='lists'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	qconfig.containerPath=getContainer('data'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	qconfig.filterArray=[LABKEY.Filter.create('crfRef',getCRFref())]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	qconfig.success=function(data){afterRegistration(configUpload,data);} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	LABKEY.Query.selectRows(qconfig); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1409,6 +1420,7 @@ function afterRegistration(configUpload,data){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	configUpload.participantId= 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		registrationData.rows[0][config.registrationParticipantIdField]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	//could be a lookup field 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	print('ID: '+configUpload.participantId);	 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	let fields=registrationData.metaData.fields; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	let field="NONE"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	for (f in fields){ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1421,7 +1433,8 @@ function afterRegistration(configUpload,data){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		let lookup=field["lookup"]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		print("Lookup: ["+lookup.schemaName+','+lookup.queryName+']'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		let qconfig=new Object(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		qconfig.containerPath=config.containerPath; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		//should point to data container 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		qconfig.containerPath=getContainer('data'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		qconfig.schemaName=lookup.schemaName; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		qconfig.queryName=lookup.queryName; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		qconfig.filterArray= 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1454,6 +1467,7 @@ function afterParticipantId(configUpload){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	qconfig.schemaName='lists'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	//qconfig.queryName=config.setupQueryName; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	qconfig.queryName="FormSetup"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	qconfig.containerPath=getContainer('config'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	qconfig.filterArray=[LABKEY.Filter.create("formName",config.formId)]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	qconfig.success=function(data){afterSetup(configUpload,data);} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	LABKEY.Query.selectRows(qconfig); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1503,6 +1517,7 @@ function copyToDataset(configUpload){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	let qconfig=new Object(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	qconfig.queryName=queryName; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	qconfig.schemaName="lists"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	qconfig.containerPath=getContainer('data'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	qconfig.filterArray=[LABKEY.Filter.create('crfRef',getCRFref())]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	qconfig.success=function(data){afterListData(configUpload,data)}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	LABKEY.Query.selectRows(qconfig); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1518,6 +1533,7 @@ function afterListData(configUpload,data){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	let qconfig=new Object(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	qconfig.queryName=queryName; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	qconfig.schemaName="study"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	qconfig.containerPath=getContainer('data'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	qconfig.filterArray=[LABKEY.Filter.create('crfRef',getCRFref())]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	qconfig.filterArray.push(LABKEY.Filter.create('ParticipantId',configUpload.participantId)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	qconfig.success=function(data){afterStudyData(configUpload,data)}; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1561,6 +1577,7 @@ function afterStudyData(configUpload,data){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		qconfig.queryName=queryName; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		qconfig.schemaName="study"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		qconfig.rows=studyRows; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		qconfig.containerPath=getContainer('data'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		qconfig.success=function(data){afterStudyUpload(configUpload,data);} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		LABKEY.Query.updateRows(qconfig) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1605,6 +1622,7 @@ function afterStudyUpload(configUpload,data){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		let qconfig=new Object(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		qconfig.queryName=queryName; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		qconfig.schemaName="study"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		qconfig.containerPath=getContainer('data'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		qconfig.success=function(data){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			afterListUpload(configUpload,data)}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		qconfig.rows=rows; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1643,6 +1661,7 @@ function updateFlag(flag){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	let qconfig=new Object(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	qconfig.schemaName='lists'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	qconfig.queryName='crfEntry'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	qconfig.containerPath=getContainer('data'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	qconfig.success=function(data){setFlag(data,flag);} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	qconfig.filterArray=[LABKEY.Filter.create("entryId",getCRFref())]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	LABKEY.Query.selectRows(qconfig); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1665,6 +1684,7 @@ function setFlag(data,flag){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	let qconfig=new Object(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	qconfig.schemaName='lists'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	qconfig.queryName='crfEntry'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	qconfig.containerPath=getContainer('data'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	qconfig.rows=[entry]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	qconfig.success=function(data){completeWithFlag(data,flag);} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	LABKEY.Query.updateRows(qconfig); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1736,6 +1756,7 @@ function modifyCRFEntry(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	let c1=new Object(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	c1.schemaName='lists'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	c1.queryName='crfEntry'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	c1.containerPath=getContainer('data'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	c1.filterArray=[LABKEY.Filter.create('entryId',getCRFref())]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	c1.success=changeCRFStatus; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	LABKEY.Query.selectRows(c1); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1750,7 +1771,8 @@ function changeCRFStatus(data){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	let c1=new Object(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	c1.schemaName=data.schemaName; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	c1.queryName=data.queryName; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	c1.containerPath=config.containerPath; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	//should point to data container 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	c1.containerPath=getContainer('data'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	c1.rows=[entry]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	//close window upon success 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	c1.success=sendEmail; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1830,7 +1852,8 @@ function checkForm(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			print("Setting status for "+f+" to "+ field.status); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		let selectRows=new Object(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		selectRows.containerPath=config.containerPath; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		//points to data container 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		selectRows.containerPath=getContainer('data'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		selectRows.schemaName="lists"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		selectRows.queryName=f; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		//select only entry related to present form 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1925,7 +1948,8 @@ function onRemoveCRF(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	let selectRows=new Object(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	selectRows.containerPath=config.containerPath; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	//points to data container 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	selectRows.containerPath=getContainer('data'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	selectRows.schemaName="lists"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	selectRows.queryName="inputLists"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	selectRows.success=afterInputLists; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1966,7 +1990,8 @@ function removeCRFLoop(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		print("["+i+"/"+config.inputLists.rows.length+"] "+queryName+"/"+idVar); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	let selectRows=new Object(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	selectRows.containerPath=config.containerPath; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	//points to data container 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	selectRows.containerPath=getContainer('data'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	selectRows.schemaName="lists"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	selectRows.queryName=queryName; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	selectRows.filterArray=[LABKEY.Filter.create(idVar,getCRFref())]; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1989,7 +2014,8 @@ function removeListCRF(data){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	let deleteRows=new Object(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	deleteRows.containerPath=config.containerPath; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	//points to data container 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	deleteRows.containerPath=getContainer('data'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	deleteRows.schemaName=data.schemaName; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	deleteRows.queryName=data.queryName; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	deleteRows.success=function(data){removeCRFLoop()}; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2018,7 +2044,8 @@ function redirect(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	params.name=formUrl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	params.pageId="CRF"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	let containerPath= config.containerPath; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	//points to crf container 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	let containerPath=getContainer('CRF'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				          
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	// This changes the page after building the URL.  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	//Note that the wiki page destination name is set in params. 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2193,18 +2220,19 @@ function generateMasterForm(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 function populateBasicData(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	config.document.getElementById('eudraCTNumber').innerHTML= 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	config.document.getElementById('version').innerText=config.formConfig.softwareVersion;	 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	config.document.getElementById('eudraCTNumber').innerText= 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		config.formConfig.crfEntry.EudraCTNumber; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	config.document.getElementById('studyCoordinator').innerHTML= 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	config.document.getElementById('studyCoordinator').innerText= 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		config.formConfig.crfEntry.StudyCoordinator; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	config.document.getElementById('studySponsor').innerHTML= 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	config.document.getElementById('studySponsor').innerText= 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		config.formConfig.crfEntry.StudySponsor; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	config.document.getElementById('siteName').innerHTML= 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	config.document.getElementById('siteName').innerText= 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		config.formConfig.site['siteName']; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	config.document.getElementById('sitePhone').innerHTML= 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	config.document.getElementById('sitePhone').innerText= 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		config.formConfig.site['sitePhone']; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	config.document.getElementById('investigatorName').innerHTML= 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	config.document.getElementById('investigatorName').innerText= 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		config.formConfig.user['DisplayName']; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2315,19 +2343,43 @@ function populateSection(queryName){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 }		 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 //entry point from generateMasterForm 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+function setContainer(label,container){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if (!(config.formConfig.hasOwnProperty('container'))){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		config.formConfig.container=new Array(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	config.formConfig.container[label]=container; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+function getContainer(label){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	return config.formConfig.container[label]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 function setFormConfig(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	//add object to store form related data 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	config.formConfig=new Object(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	config.formConfig.softwareVersion='0.11.a'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	let debug=true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	if (debug) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		print("generateMasterForm1");	 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	//set containers for data and configuration 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	//TODO: set this from a query 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	setContainer('data',LABKEY.ActionURL.getContainer()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	setContainer('config',LABKEY.ActionURL.getContainer()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	setContainer('CRF',LABKEY.ActionURL.getContainer()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	let selectRows=new Object(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	selectRows.containerPath=config.containerPath; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	//this is local data 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	selectRows.containerPath=getContainer('data'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	selectRows.schemaName='lists'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	selectRows.queryName='crfEntry'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	//use first-> we must first establish link to the rigth crf entry 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2342,11 +2394,13 @@ function afterCRFEntry(data){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	print("Setting crfEntry (x) to "+config.formConfig.crfEntry["entryId"]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	let selectRows=new Object(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	selectRows.containerPath=config.containerPath; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	//this should point to configuration container 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	selectRows.containerPath=getContainer('config'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	selectRows.schemaName='lists'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	selectRows.queryName='site'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	let selectedSite=config.formConfig.crfEntry.Site; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	selectRows.filterArray=	[ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		LABKEY.Filter.create('siteNumber',config.formConfig.crfEntry.Site)]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		LABKEY.Filter.create('siteNumber',selectedSite)]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	selectRows.success=afterSite; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	LABKEY.Query.selectRows(selectRows); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2360,7 +2414,8 @@ function afterSite(data){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			+" phone: "+config.formConfig.site["sitePhone"]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	let selectRows=new Object(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	selectRows.containerPath=config.containerPath; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	//this looks at local container 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	selectRows.containerPath=getContainer('CRF'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	selectRows.schemaName='core'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	selectRows.queryName='Users'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	selectRows.filterArray=[ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2375,7 +2430,8 @@ function afterUser(data){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	print("Setting user to "+config.formConfig.user["DisplayName"]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	let selectRows=new Object(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	selectRows.containerPath=config.containerPath; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	//This is part of data, don't rely on configuration container 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	selectRows.containerPath=getContainer('config'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	selectRows.schemaName='study'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	selectRows.queryName='Study'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	selectRows.columns="SubjectColumnName"; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2386,10 +2442,12 @@ function afterUser(data){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 function afterStudy(data){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	config.formConfig.studyData=data.rows[0]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	print("XSetting participantField to "+config.formConfig.studyData["SubjectColumnName"]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	print("XSetting participantField to "+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			config.formConfig.studyData["SubjectColumnName"]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	let selectRows=new Object(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	selectRows.containerPath=config.containerPath; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	//should point to configuration container 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	selectRows.containerPath=getContainer('config'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	selectRows.schemaName='lists'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	selectRows.queryName='FormStatus'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	selectRows.filterArray=[]; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2407,6 +2465,8 @@ function afterFormStatus(data){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	qconfig.schemaName="lists"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	qconfig.queryName="Forms"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	//this should point to configuration container 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	qconfig.containerPath=getContainer('config'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	qconfig.filterArray=[LABKEY.Filter.create('Key',config.formId)]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	//qconfig.filterArray=[LABKEY.Filter.create('formStatus',1)] 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2420,7 +2480,7 @@ function afterForms1(data){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	config.formConfig.form=data.rows[0]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	let selectRows=new Object(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	selectRows.containerPath=config.containerPath; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	selectRows.containerPath=getContainer('config'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	selectRows.schemaName='lists'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	selectRows.queryName='FormSetup'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	selectRows.filterArray=[LABKEY.Filter.create('formName',config.formId)]; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2449,7 +2509,8 @@ function afterFormSetup(data){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	print("Getting dataset names from "+lookup.queryName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	let selectRows=new Object(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	selectRows.containerPath=config.containerPath; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	//inputLists should be in configuration container 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	selectRows.containerPath=getContainer('config'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	selectRows.schemaName=lookup.schemaName; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	selectRows.queryName=lookup.queryName; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	selectRows.success=afterFormDatasets; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2553,6 +2614,7 @@ function setDataLayout(cb){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		let selectRows=new Object(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		selectRows.queryName=q; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		selectRows.schemaName='lists'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		selectRows.containerPath=getContainer('data'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		//we are only interested in metadata 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		selectRows.success=function(data){afterDatasets(data,cb);} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		LABKEY.Query.selectRows(selectRows); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2599,10 +2661,15 @@ function afterDatasets(data,cb){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		let selectRows=new Object(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		selectRows.schemaName=field.lookup.schemaName; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		selectRows.queryName=field.lookup.queryName; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		selectRows.columns=field.lookup.keyColumn+","+field.lookup.displayColumn; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		selectRows.containerPath=getContainer('data'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		selectRows.columns=field.lookup.keyColumn+","+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			field.lookup.displayColumn; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		//wait for all lookups to return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		selectRows.success=function(data){addLookup(data,qobject,f,cb);}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		print("Sending query: ["+field.lookup.queryName+"] "+field.lookup.keyColumn+'/'+field.lookup.displayColumn); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		print("Sending query: ["+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				field.lookup.queryName+"] "+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				field.lookup.keyColumn+'/'+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				field.lookup.displayColumn); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		LABKEY.Query.selectRows(selectRows); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		i+=1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2663,6 +2730,7 @@ function setData(cb){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		let fQuery=config.formConfig.dataQueries[q]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		fQuery.collectingData="STARTED"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		let selectRows=new Object(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		selectRows.containerPath=getContainer('data'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		selectRows.queryName=q; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		selectRows.schemaName='lists'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		selectRows.filterArray=[ 
			 |