a regular expression for the StudySujectID

Many OpenClinica users have asked for some way to check the StudySubjectID and so far, oc3141 Dec 2013, this is not possible. However what you can do is take the StudySubjectID from the header of the CRF, put it into a normal CRF-item and do some checking there. It is not the solution to end all your ID-problems, but it's definitely better than nothing!


fig. 1: example of a CRF with StudySubjectID duplicated

One way to do this would be to ask dataentry to re-type the ID, but then you run the risk of entry-errors. It makes more sense to get the ID from the upper-right corner of the CRF. You must use a tiny bit of javascript.
If you're in a hurry you can download an example-CRF here.

the javascript to get the ID

Here's the script to do the work and we can insert it in the RIGHT_ITEM_TEXT of the item to hold the ID.

<script src="includes/jmesa/jquery.min.js">// for OC versions before 3.1.4, use jquery-1.3.2.min.js !</script>
<div id="StudySubjectID"></div>
<script>
$.noConflict();
jQuery(document).ready(function($) { 
var fieldStudySubjectID = $("#StudySubjectID").parent().parent().find("input");
fieldStudySubjectID.attr("readonly", true);
function getSSID(){
 var SSID = $("#centralContainer").find("table:first").find("tbody:first").children("tr:nth-child(1)").children("td:nth-child(2)").children("h1").text();
 SSID = $.trim(SSID);
 if (fieldStudySubjectID.val() != SSID){
  fieldStudySubjectID.val(SSID);
  fieldStudySubjectID.change();
 }
};
getSSID();
})
</script>

In the first line we define a block or div and call it StudySubjectID. We get to the CRF-item we want to copy the ID into by going to the parent-of-the-parent of this div and then finding the input and we give this the name fieldStudySubjectID. The actual StudySubjectID can be found by starting at the DOM-object centralContainer and going the path from table to h1.
If this value is different from the value that is entered in the CRF-item, then we replace this.
To prevent the user from changing the copied ID, we set it read-only and then we're finished with the javascript-part.

This function, getSSID(), is called when the CRF is loaded.

and the checking?

The actual checking you do by applying a regular expression to the CRF-item. For example if you want your ID to have the format TDS followed by three digits, you add a validation to the item like
regexp: /TDS\d{3}/
A great site for experimenting with regular expressions is http://regexpal.com/.

What is probably the most difficult part is writing the instructions for your data-entry, because in your ValidationMessage you must instruct them to change the StudySubjectID outside the CRF!. This new ID will not be checked until they've opened the CRF and saved it.

Other how-to-pages can be found here.

this page was last reviewed December 2013