Explorar o código

Infrastructure to set CRF from participantIdManager

Andrej Studen %!s(int64=2) %!d(string=hai) anos
pai
achega
5c50ac196a
Modificáronse 1 ficheiros con 48 adicións e 8 borrados
  1. 48 8
      web/crf/crfVisit.js

+ 48 - 8
web/crf/crfVisit.js

@@ -1886,6 +1886,30 @@ function setFlag(data,flag,action){
 	
 	
 }
 }
 
 
+function updateFlag1(flag,action){
+	let fName='[updateFlag 1]';
+	let debug=true;
+
+	let entry=config.formConfig.crfEntry;
+	entry.FormStatus=flag;
+	let uId=config.formConfig.currentUser.UserId;
+	entry[config.formConfig.operator]=uId;
+
+	print(fName+': Form: '+entry.Form);
+	print(fName+": set form status to "+entry.FormStatus);
+	
+	let qconfig=new Object();
+	qconfig.schemaName='lists';
+	qconfig.queryName='crfEntry';
+	qconfig.containerPath=getContainer('data');
+	qconfig.rows=[entry];
+	//qconfig.success=function(data){completeWithFlag(data,flag);}
+	qconfig.success=function(data){completeWithFlag(data,action);};
+	LABKEY.Query.updateRows(qconfig);
+	
+}
+
+
 function completeWithFlag(data,action){
 function completeWithFlag(data,action){
 	let fName='[completeWithFlag]';
 	let fName='[completeWithFlag]';
 	print(fName+': nrows '+data.rows.length);
 	print(fName+': nrows '+data.rows.length);
@@ -2574,21 +2598,37 @@ function afterData(){
 	let accessMode=config.formConfig.operator+'Mode';
 	let accessMode=config.formConfig.operator+'Mode';
 	let rowsSetup=config.formConfig.formSetupRows;
 	let rowsSetup=config.formConfig.formSetupRows;
 
 
-   print(fName+': '+'generatePariticpantEntry');
+   let allowNewLocalId=config.formConfig.form['allowNewLocalId'];
+   //set default value if no value is in the list (read value is null)
+   if (!allowNewLocalId) allowNewLocalId="FALSE";
+
+   print(fName+': '+'generatePariticpantEntry '+allowNewLocalId);
    //generateParticipantEntryField();
    //generateParticipantEntryField();
    //add print to config so participantManager can use it
    //add print to config so participantManager can use it
    config.print=print;
    config.print=print;
    let pM=getParticipantManagerObject(config);
    let pM=getParticipantManagerObject(config);
+   //if (allowNewLocalId=="TRUE") pM.allowNewLocalId=true;
+   if (allowNewLocalId=="TRUE") {
+      pM.mode="LOCAL";
+   }
+   else {
+      pM.mode="STUDY";
+   }
 
 
-   print(fName+': pariticpantManager: '+pM);
+   pM.updateCrfEntry=function(){updateFlag1(config.formConfig.crfEntry['FormStatus'],doNothing);};   
+   
+   print(fName+': pariticpantManager: '+pM+' config '+pM.config);
    //check if ParticipantId is set in crfEntry
    //check if ParticipantId is set in crfEntry
-   let pId=config.formConfig.crfEntry['ParticipantId'];
-   print(fName+' pId '+pId);
-   if (!pId){ 
-      pM.setParticipantManagerToEditMode();
+   //let pId=pM.getParticipantIdFromCrfEntry('Study');
+   //if (pM.allowNewLocalId) 
+   //   pId=pM.getParticipantIdFromCrfEntry('Local');
+   let pId=pM.getParticipantIdFromCrfEntry();
+   print(fName+' pId '+pId+' config '+pM.config);
+   if (!pId){
+      pM.setEditMode();
    }
    }
    else{
    else{
-      pM.setParticipantManagerToLabelMode(pId,'Record');
+      pM.setLabelMode(pId);
    }
    }
 
 
 	for (let i=0;i<rowsSetup.length;i++){
 	for (let i=0;i<rowsSetup.length;i++){
@@ -2939,7 +2979,7 @@ function setFormConfig(){
 	//add object to store form related data
 	//add object to store form related data
 	config.formConfig=new Object();
 	config.formConfig=new Object();
 
 
-	config.formConfig.softwareVersion='0.15.08';
+	config.formConfig.softwareVersion='0.15.10';
 	let debug=true;
 	let debug=true;
 
 
 	if (debug)
 	if (debug)