Преглед на файлове

solving reviewComment problem, solving the form update bproblem

Andrej Studen @ ONKO-NIX преди 2 години
родител
ревизия
0d68c585c8
променени са 1 файла, в които са добавени 23 реда и са изтрити 7 реда
  1. 23 7
      web/crf/crfVisit.js

+ 23 - 7
web/crf/crfVisit.js

@@ -323,7 +323,12 @@ function clearErrorMessage(listName){
 function getParticipantCode(pid){
 	let selectRows=new Object();
 	selectRows.schemaName='lists';
-	selectRows.queryName='PET';
+	//we should now which form we are in
+	let mfId=config.formConfig.form['masterQuery'];
+	selectRows.queryName=config.formConfig.queryMap[mfId];
+	
+
+	//selectRows.queryName='PET';
 	pid.afterId=setParticipantCode;
 	selectRows.success=function(data){afterRegistration(pid,data);}
 	selectRows.filterArray=[LABKEY.Filter.create("crfRef",getCRFref())];
@@ -1026,7 +1031,7 @@ function addFieldRow(tb,field,setup,additionalData){
 		
 function populateFieldRow(entry,field,setup){
 
-	print('populateFieldRow ['+field.name+']: '+entry[field.Name]+' ['+
+	print('populateFieldRow ['+field.name+']: '+entry[field.name]+' ['+
 		setup.getInputId(field.name)+']');
 	
 	let vName=field.name;
@@ -1038,6 +1043,8 @@ function populateFieldRow(entry,field,setup){
 	let varValue="UNDEF";
 	//if (vName in setup.filters) varValue=setup.filters[vName];
 	if (vName in entry) varValue=entry[vName];
+	//if part of the filter, set it to value
+	if (vName in setup.filters) varValue=setup.filters[vName];
 		
 	//date
 	if (vType=="date"){
@@ -1204,6 +1211,7 @@ function generateTable(listName,divName,additionalData,setup){
 }	
 	
 function saveReview(queryName,elementId,setup){
+	//loads any queryName
 
 	let debug=true;
 	if (debug) print("saveReview: elementId "+elementId+" queryName "+queryName);
@@ -1241,7 +1249,7 @@ function saveReview(queryName,elementId,setup){
 		if (debug) print("vType: "+vType);
 		
 		if (vName=="crfRef") continue;
-		if (vName=="queryName") continue;
+		//need to save queryName for reviewComments
 		
 		let eId=setup.getInputId(vName);
 		
@@ -1252,6 +1260,7 @@ function saveReview(queryName,elementId,setup){
 			continue;
 		}
 		if (debug) print("saveReview element: "+eId);
+
 		
 		let eType=el.nodeName.toLowerCase();
 
@@ -1276,6 +1285,7 @@ function saveReview(queryName,elementId,setup){
 
 		if (vType=="string"){
 			entry[vName]=el.value;
+			
 			if (vName.search('_file_')<0) 
 				continue;
 			
@@ -1298,8 +1308,13 @@ function saveReview(queryName,elementId,setup){
 			continue;
 			
 		}	
-		if (vType=="float"){
+		if (vType=="float" || vType=="int"){
 			entry[vName]=el.value;
+			if (vName=="queryName") {
+				print('Parsing queryName: '+el.innerText);
+				entry[vName]=config.formConfig.fields[el.innerText].queryId;
+				//use queryMap lookup
+			}
 			continue;
 		}	
 		if (vType=="boolean"){
@@ -1362,11 +1377,12 @@ function onDatabaseUpload(){
 }
 
 function afterForms(configUpload,data){	
+	print('afterForms');
 	let formEntry=data.rows[0];
 	configUpload.registrationQueryId=formEntry["masterQuery"];
 	configUpload.afterId=afterParticipantId;
 	let qconfig=new Object();
-	qconfig.queryName=config.queryMap[configUpload.registrationQueryId];
+	qconfig.queryName=config.formConfig.queryMap[configUpload.registrationQueryId];
 	//queryMap holds mapping for queries in visit; 
 	//masterQuery should be one of them, so this is safe.
 	qconfig.schemaName='lists';
@@ -1384,7 +1400,7 @@ function afterRegistration(configUpload,data){
 	clearErr();
 	if (registrationData.rows.length!=1){
 		let msg="ERROR: Found "+registrationData.rows.length;
-		msg+=" registration entries for crfrefid "+getCRFref();
+		msg+=" registration entries for crfrefid "+getCRFref()+" in "+data.queryName;
 		print(msg);
 		configUpload.afterId(configUpload);
 		return;
@@ -1452,7 +1468,7 @@ function afterSetup(configUpload,data){
 		//skip reviews
 		if (entry.showFlag=="REVIEW") continue;
 		//use lookup table to convert from id to name
-		let queryName=config.queryMap[entry.queryName];
+		let queryName=config.formConfig.queryMap[entry.queryName];
 		configUpload.queries.push({queryName:queryName,queryStatus:"QUEUED"});
 		if (entry.showQuery=="NONE")
 			continue