the Event-date in your CRF

Many OpenClinica-users would like to use the Event-date in Validations. But this date can not be used in Rules, because only CRF-items can be used. An example would be that you want the Event-date to be after the Study-start-date or after the Inclusion-date or between 12 and 16 days after the previous Event. A work-around for this is copying the Event-date from the header of the CRF to a CRF-item.

fig. 1: example of what we want

As you can see are both the Event-name and Event-date are displayed in the box CRF Header Info and we can copy it from there using javascript.
You can download the example-CRF here.

the script

To get the Event-date-copy you create an item VDATE and insert the script in the RIGHT_ITEM_TEXT:

fig. 2: the script

This is the script:

<div id="event"></div>
<script src="includes/jmesa/jquery.min.js"></script>
    jQuery(document).ready(function($) { 
        var fieldEvent = $("#event").parent().parent().find("input");
        fieldEvent.attr("readonly", true);
        var event = $(".tablebox_center").find("tbody:first").children("tr:nth-child(1)").children("td:nth-child(2)").text();
        event = $.trim(event);
        var posBracket = event.indexOf("(");
        event = event.substring(posBracket + 1, posBracket + 12);

In the first line we define a block or div and call it event. 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 fieldEvent. To prevent the user from changing the date, we set it read-only.
The Event-date can be found by starting at tablebox_center and going the path from tbody to the second td of the first tr.
As you can see in the screen-shot, first the Event-name is displayed and then the Event-date between brackets. Therefore we look for the first position of a left-bracket and from there take 11 characters. We compare this value with the the content of the CRF-item and if that's different, we replace the CRF-item with the value from the header.

Now we can write our Validations using the CRF-item VDATE. Do not forget to instruct your users that if a change is required they must exit the CRF and then change the Event-date!

Other how-to-pages can be found here.

this page was last reviewed January 2014