Quellcode durchsuchen

Merge branch 'hypoAfrica' of ssh://git0.fmf.uni-lj.si:2222/medfiz-clinical/crf into hypoAfrica

Andrej Studen vor 2 Jahren
Ursprung
Commit
c4dde6c231
1 geänderte Dateien mit 12 neuen und 3 gelöschten Zeilen
  1. 12 3
      web/crf/crfVisit.js

+ 12 - 3
web/crf/crfVisit.js

@@ -1519,6 +1519,11 @@ function getHelpVar(queryName,code,setup){
          value=setup.setVariables[vField];
       }
       else{
+         //robustify
+         if (config.formConfig.dataQueries[query].rows.length==0){
+            print(fName+' returning INVALID');
+            return "INVALID";
+         }
          value=config.formConfig.dataQueries[query].rows[0][vField];
       }
       if (lField==undefined){
@@ -1547,7 +1552,7 @@ function getHelpVar(queryName,code,setup){
    for (let x in rpc){
       code=code.replace(x,rpc[x]);
    }
-   print('Returning '+code);
+   print(fName+' returning '+code);
    return code;
 }
 
@@ -1595,18 +1600,22 @@ function populateHelp(listName,helpRows,setup){
    print(fName);
    for (let i=0; i<helpRows.length; i++){
       let eh=helpRows[i];
+      let id=setup.sectionId+'_help'+eh.setup['Key']
+      let el=config.document.getElementById(id);
       let lookup=eh.field['lookup'];
       let qName=lookup.queryName;
       let tLookup=config.formConfig.lookup[qName];
       let varName=getHelpVar(listName,eh.setup['fieldDescriptor'],setup);
+      if (varName=="INVALID"){
+         el.value="Please select patient/timepoint";
+         continue;
+      }
       let text="";
       for (let j=0;j<tLookup.rows.length;j++){
          //print(tLookup.rows[j][tLookup.keyColumn]+' '+tLookup.rows[j][tLookup.displayColumn]+
          //' '+tLookup.rows[j][varName]);
          text+=tLookup.rows[j][tLookup.displayColumn]+" - "+tLookup.rows[j][varName]+"\n";
       }
-      let id=setup.sectionId+'_help'+eh.setup['Key']
-      let el=config.document.getElementById(id);
       print(fName+' setting '+id+': '+el);
       el.value=text;
    }