ソースを参照

Adding checks for valid registration by providing crfData.validRegistration() function and its use in participantOverview and participantPortal

Andrej Studen 1 週間 前
コミット
bb0431347f
3 ファイル変更33 行追加2 行削除
  1. 17 0
      web/crf/crfData.js
  2. 13 2
      web/crf/participantOverview.js
  3. 3 0
      web/crf/participantPortal.js

+ 17 - 0
web/crf/crfData.js

@@ -414,6 +414,23 @@ function(cb=null){
    runQuery.getDataFromQueries(this,queryArray,cb);
 }
 
+crfData.validRegistration=
+function(regEntry){
+
+//compare regStatus to list of valid states from settings
+   //if none are given, check against a value of 1 which is normally associated with a VALID state
+   regStatus=regEntry['registrationStatus'];
+
+   let validRegistrationStatus=this.setup.getSettings('validRegistrationStatus');
+   if (validRegistrationStatus==null){
+      return regStatus==1;
+   }
+   //if multiple states are valid, split by semicolon
+   let strArray=validRegistrationStatus.split(";");
+   validStates=strArray.map(Number);
+   return validStates.includes(regStatus);
+}
+
 crfData.setCrfEntry=
 function(crfRef,cb=null){
    let q='crfEntry';

+ 13 - 2
web/crf/participantOverview.js

@@ -51,6 +51,7 @@ participantOverview.matchRegistration=
 function(entry){
    let fName='matchRegistration';
    let sF='participantStudyId';
+   //this was set by crfData.setRegistration()
    let studyRegMap=crfData.getRegistrationEntryMap(sF);//should be unique for registration
    let nS=Object.keys(studyRegMap).length;
    //this.print(fName+' study registration entries '+nS);
@@ -73,10 +74,13 @@ function(entry){
    return null;
 }
 
-
 participantOverview.makeArray=
 function(){
+
+
    let fName='makeArray';
+
+
    let entries=crfSetup.getEntryMap('crfEntries'); 
    let n=Object.keys(entries).length;
    this.print(fName+' entries '+n);
@@ -111,8 +115,15 @@ function(){
          i++;
          continue;
       }
-      //link crfEntry to registration row
       let idLabel=crfSetup.getParticipantLabel(regEntry);
+      //check if this is a valid participant
+      if (!crfData.validRegistration(regEntry)){
+         regStatus=regEntry['registrationStatus'];
+         this.print(fName+" ["+idLabel+"]: illegal registration status ("+regStatus+")");
+         i++;
+         continue;
+      }
+      //link crfEntry to registration row
       let form=entry['Form'];
       this.addObjectToIdFormMap(entry,entryMap,idLabel,form);
    }

+ 3 - 0
web/crf/participantPortal.js

@@ -195,6 +195,9 @@ function(){
    this.clearKeyMap();
    let updatedMap=new Object();
    for (q in regMap){
+      if (!crfData.validRegistration(regMap[q])){
+         continue
+      }
       let key=regMap[q]['Key'];
       let label=crfSetup.getParticipantLabel(regMap[q]);
       let crfInProgress=this.anyCrfInProgress(label);