Browse Source

Prevent crfVisitNew from updating local ids for form 0 (which contains registration that might overload registration id)

Andrej Studen 1 week ago
parent
commit
74d3a65a11
2 changed files with 7 additions and 9 deletions
  1. 2 1
      web/crf/crfVisitNew.js
  2. 5 8
      web/crf/participantIdManager.js

+ 2 - 1
web/crf/crfVisitNew.js

@@ -1888,7 +1888,8 @@ function(){
       pM.setMode("LOCAL");
    }
    //OK, but check if CRF or registration indicate that study id is already set
-   pM.verifyCrfStudyId();
+   let formId=crfData.getCrfEntry()['Form'];
+   pM.verifyCrfStudyId(formId);
    //still local
    if (pM.getMode()=='LOCAL'){
       if (idModeArray.includes("READONLY")){

+ 5 - 8
web/crf/participantIdManager.js

@@ -406,7 +406,7 @@ function(name){
 }
 
 participantIdManager.verifyCrfStudyId=
-function(){
+function(formId=0){
    let fName='[verifyCrfStatusId]';
    //is studyId already set for the crf
    let studyId=this.getParticipantIdFromCrfEntry('STUDY');
@@ -426,12 +426,12 @@ function(){
    this.setLabelMode('STUDY',this.setup.getParticipantLabel(this.data.getCrfEntry()));
    //get registration map to fill local id
    let that=this;
-   let completeVerification=function(){that.completeVerification(studyId);}
+   let completeVerification=function(){that.completeVerification(studyId,formId);}
    this.data.setRegistration(completeVerification);
 }
    
 participantIdManager.completeVerification=
-function(studyId){
+function(studyId,formId=0){
    let fName='[completeVerification]';
    //subject to content of localId
    let rMapEntry=this.data.getRegistrationEntryMap(this.getCrfEntryFieldName('STUDY'))[studyId];
@@ -440,15 +440,12 @@ function(studyId){
    this.print(fName+' localId '+localId+' isNull '+(localId==null)+' is"null" '+(localId=="null"));
    
    let localIdFromEntry=this.getParticipantIdFromCrfEntry('LOCAL');
-   if (localIdFromEntry!=localId){
+//don't touch localId in registration form (typically 0)
+   if (localIdFromEntry!=localId && formId!=0){
       //update mismatches
       this.setParticipantIdToCrfEntry('LOCAL',localId);
       this.updateCrfEntry();
    }
-   //ignore the one set in the crfEntry, studyId prevails
-   //if (!this.isValid(localId)) {
-   //   let localId=this.getParticipantIdFromCrfEntry('LOCAL');
-   //}
    if (this.isValid(localId)) {
       this.setReadonly('LOCAL');
       this.setLabelMode('LOCAL',localId);