You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -248,7 +248,7 @@ function changeSources(string $recordId,int $projectId,$fields=array(),array $al
248
248
error_log("Found a new aid $newAid");
249
249
// No need to change the target_field value in redcap_data. This remains the same.
250
250
if(!$this->query("update redcap_randomization_allocation set is_used_by = null where aid = '$currentAid' and is_used_by = '$recordId'")){
251
-
thrownewRandapiException("Could not unsed is_used_by for aid $currentAid");
251
+
thrownewRandapiException("Could not unset is_used_by for aid $currentAid");
252
252
}
253
253
error_log("updated is_used_by from old aid $currentAid to null");
254
254
if(!$this->query("update redcap_randomization_allocation set is_used_by = '$recordId' where aid = $newAid;")){
@@ -292,6 +292,142 @@ function changeSources(string $recordId,int $projectId,$fields=array(),array $al
292
292
}
293
293
}
294
294
295
+
/**
296
+
* In limited cases it might be necessary to change the outcome of the randomization. E.g. in an automated process a record was assigned to a certain target group.
297
+
* Due to some manual changes, the record is unrandomized. Correcting the error and randomizing the record again, results in a different target value.
298
+
* This can be done using the following steps
299
+
* 1) Check if an allocation record is available for the given recorid
300
+
* 2) Collect the current source_field value.
301
+
* 3) Look for a new allocation record (aid) for the new source_field values but for the same target_field.
302
+
* 4) Select the first free allocation. If none available, add new ones as defined in $newAllocations and select first (aid)
303
+
* 5) Update is_used_by field for the current allocation to null, update the new allocation to the new found aid.
304
+
* 6) Update the source field values in the record
305
+
*
306
+
* @param string $recordId
307
+
* @param int $projectId
308
+
* @param string $new_target The new target value
309
+
* @param string $group_id
310
+
* @param RandomizationAllocation[] $allocations These allocations will be added if no allocations are available for the given combination of source fields and the target field.
311
+
* @param string $arm_name (optional) The name of the arm. default = 'Arm 1'
312
+
* @param string $event_name (optional) The name of the event. default = 'Event 1'
thrownewRandapiException("Could not update target_field to value '".$new_target."' for project $projectId, record $recordId, event $event_name and arm $arm_name from aid $currentAid to aid $newAid");
418
+
}else{
419
+
error_log("updated target_field to value '".$new_target."' for project $projectId, record $recordId, event $event_name and arm $arm_name from aid $currentAid to aid $newAid");
420
+
}
421
+
return$newAid;
422
+
}else{
423
+
thrownewRandapiException("Could not find an empty allocation record for the given target and source fields");
424
+
}
425
+
426
+
}else{
427
+
thrownewRandapiException("Record $recordId has not yet been randomized");
428
+
}
429
+
}
430
+
295
431
/**
296
432
* @param int $projectId The project id
297
433
* @param int $project_status (0 = development, 1 = production)
@@ -509,6 +645,10 @@ public function handleRequest(stdClass $jsonObject, string $jsonText):void{
Copy file name to clipboardExpand all lines: help.php
+36Lines changed: 36 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -167,6 +167,42 @@
167
167
}
168
168
</code>
169
169
</pre>
170
+
171
+
<h2>changeTarget</h2>
172
+
<p>In limited cases it might be necessary to change the outcome of the randomization. E.g. in an automated process a record was assigned to a certain target group. Due to some manual changes, the record is unrandomized. Correcting the error and randomizing the record again, results in a different target value.</p>
173
+
<p>If possible, another allocation record for the preferred target will be used that maintains the current assigned sources.</p>
174
+
<p>If no such records exist, there is a possibility to provide additional allocation records</p>
175
+
176
+
<h3>parameters:</h3>
177
+
<ul>
178
+
<li><b>recordId</b>: The record that we want to change source fields for</li>
179
+
<li><b>target</b>: The new target value</li>
180
+
<li><b>allocations</b>: A list of new allocation records, in case there is no record available anymore.
181
+
<li><b>groupId</b>: (optional) The DAG identifier. default = '' (none)</li>
182
+
<li><b>armName</b>: (optional) The name of the arm. default = 'Arm 1'</li>
183
+
<li><b>eventName</b>: (optional) The name of the event. default = 'Event 1'</li>
184
+
</ul>
185
+
<h3>Example:</h3>
186
+
<p>This examples changes the target for record 1 to assignedto A. In case there is no allocation record available anymore, we allow the algorithm to add these 4 new allocations.</p>
0 commit comments