Chapter 7. Writing Your Own Reports

Table of Contents

7.1. General Guidelines
7.2. Installing Your Reports
7.3. Input Data Files
7.4. Programming Tools
7.5. An Example
7.6. Writing Documentation for Study Specific Reports

DFdiscover comes with approximately 40 standard reports that are useful for most clinical trials. There will always be the need for custom reports for almost every trial. You can create reports using any of the programming tools that you are familiar with (e.g SAS®, a database report tool, UNIX shell scripts, etc.) and then install them in DFdiscover so that your DFdiscover users can execute them via Reports View in DFexplore. Also, don't hesitate to take a look at the standard DFdiscover reports included in your DFdiscover installation reports directory. Most are UNIX shell scripts, which can serve as models for creating your own study specific reports.

7.1. General Guidelines

  • After a report has been created the easiest way to make it available to study staff is through DFexplore's Reports View. It can then be executed by permitted users by simply clicking the report name.

  • If reports are to be executed from DFexplore they must be installed in the study reports directory and have execute permissions for at least owner and group.

  • When you install a new report in the study reports directory, be sure to update the .info file kept in that same directory with a complete description of how the report works, including what options it accepts and what output it generates. Take a look at the existing .info file in your DFdiscover reports directory for examples of how on-line documentation should be formatted. However, make sure you don't include your own documentation in this file, as it will be replaced with each new DFdiscover release, as new standard reports are added.

  • Reports executed from DFexplore are always provided with the study number as an argument, plus the options that the user has provided in DFexplore's Options field. Within a Bourne shell script, for example, the study number is always $1, so you can do things like:

    study=$1

  • Use the shell level program DFgetparam.rpc to obtain the values of configuration parameters from the study server rather than trying to parse the configuration file yourself, or even worse, hard coding in the values of study directories, etc. The following Bourne shell example shows how to use DFgetparam.rpc to get the study database directory, where the study number has already been set to $study:

    db=`/opt/dfdiscover/bin/DFgetparam.rpc -s $study DATABASE_DIR`

  • Temporary files created by your report should be written to the study work directory. Using DFgetparam.rpc you can evaluate the value of the work directory as follows:

    work=`/opt/dfdiscover/bin/DFgetparam.rpc -s $study WORKING_DIR`

    and then use the temporary file in one of these ways:

    $work/tmp
    $work/$$tmp

  • HTML markup can be used to format report output directed to the reports view in DFexplore. HTML reports must start with one of the following tags: <HTML>,<!DOC>,<!doc>,<TABLE>,<table>,<P>,<p>. Note: If DFexplore is run using the web-based DFnavigator, links are disabled. Page breaks are output when printing or saving report output to PDF.

7.2.  Installing Your Reports

Many study reports are re-executed at regular intervals throughout the trial. Such routine reports can be created by putting all of the computational steps (data retrieval, analysis and report creation) into a UNIX shell script. This script can then be documented and installed in the study reports directory. Once this is done, and tested, it can then be executed by anyone with access to the reports tool, the study, and privileges for the particular report. Of course some analyses must be performed by a skilled statistician each time they are done, but most of the summary reports created for trial and database management purposes are routine tables and graphs. In such cases setting up a shell script, which includes all of the steps needed to create the report, can relieve programmers and data analysts from those tasks which are simple, repetitive and time consuming and allow them to concentrate on those analyses which require more attention and skill.

7.3. Input Data Files

DFdiscover Study Files describes the location and format of all study files including: the data files created from the study CRFs, the quality control data base, the journal files used to record every transaction written to the study database, and all study configuration files. Any of these files might be needed as input to a study report program.

7.4.  Programming Tools

DFdiscover includes several shell level programs which are described in Shell Level Programs. These programs can be used to export and reformat data, and read study configuration parameters. Any number of other programming tools might also be incorporated into shell scripts to create study specific report programs. These might include other DFdiscover programs (e.g. DFsas), UNIX commands (e.g. awk, grep, sed, sort), third party packages (e.g. SAS), report generators (e.g. perl) or even low-level programming languages.

With these tools, programmers can extract the data they need from the study database, and then analyze and summarize it using whatever programming tools they are familiar with or think most suitable to the task at hand.

7.5. An Example

The following shows a simple example of a UNIX shell script that reports subject entry by site for the past 9 months, as well as the total to date, for an example study.

The basic outline of this program is documented with comments (which begin with the # symbol). This hopefully is enough to give you an idea of the level of effort required to produce simple study specific reports. For those unfamiliar with UNIX shell programming, this may whet your appetite for an exploration of the many useful tools built into the UNIX operating system. You can accomplish a great deal without invoking big systems like SAS, and it's really not that hard, honest!

#!/bin/sh
# RANDOMIZATIONS BY SITE FOR PAST 9 MONTHS AND TOTAL TO DATE
# $1 is study number.
# yy = current year
# mm = current month
# hx = number of months to be printed
yy=`date +"%y"`
mm=`date +"%m"`
hx=9
# Export all primary randomization records (plate 1) received to date
# and use field 13 as the visit date. Site number is assumed to be pid/1000
/opt/dfdiscover/bin/DFexport.rpc -s primary $1 1 - | nawk -F\| '
BEGIN { YY="'$yy'"+0; m=MM="'$mm'"+0; HX="'$hx'"+0
    # determine which months are to be printed
    if(m >= HX) {
       for(i=HX;i>=1;i--) {k[i]=YY*100+m;--m}
    } else {
       jn = HX - MM
       jm = 13 - jn
       jy = YY - 1
       for(i=1 ;i<=jn;i++) {k[i]=jy*100+jm; ++jm}
       for(jm=1;i<=HX;i++) {k[i]=YY*100+jm; ++jm}
    }
}
{ # Read each exported record and count cases by month and center
    mon=substr($13,4,2); yr=substr($13,7,2)
    center=int($7/1000); yymm= yr*100 + mon
    n[yymm,center] +=1
    mtot[yymm] +=1
    ctot[center] +=1
}
END{ # Print Report
    printf"RECENT AND TOTAL RANDOMIZATIONS BY SITE\n"
    printf"SITE "
    for(i=1;i<=HX;i++) printf"%6d",k[i]
    printf" TOTAL\n\n"
    for(i=1;i<=200;i++) { # center number range is 1~200
        if( ctot[i]>0 ) {
           printf"%5d: ",i
           for(j=1;j<=HX;j++)
               if (n[k[j],i] > 0) printf"%6d",n[k[j],i];
               else printf "      ";
           printf" :%6d\n", ctot[i]
           SUM += ctot[i]
       }
    }
    printf"\nTOTAL: "
    for(j=1;j<=HX;j++)
        if (mtot[k[j]] > 0) printf "%6d",mtot[k[j]];
        else printf "      ";
    printf" : %5d\n", SUM
}'

When this UNIX shell script is installed in the study reports directory, and given execute permissions for the permitted members of the study group, it can be executed.

7.6.  Writing Documentation for Study Specific Reports

The documentation for study specific reports must be kept in a separate file from the documentation for all standard DFdiscover reports. Specifically, it must be kept in the .info file in the study reports directory.

Report titles appear in the scrolling list of reports in the order in which they are defined in the file. Any reports not defined in this file will appear in alphabetical order at the end of the list of reports that have been defined.

The general layout of the file is repeating blocks, of the following structure, where each block contains the documentation for one report:

.BEGIN report_name       (1)
.TITLE report_title      (2)
.OPTION first_option     (3)
.OPTION next_option      (4)
documentation text       (5)
.END                     (6)

(1)

The keyword .BEGIN indicates the beginning of the documentation for the report whose unique name is report_name. The name must exactly match the name of the report as it is located in the study reports directory.

(2)

A descriptive title for the report.

(3) (4)

The .OPTION lines appear in the pop-up options menu when Options is selected.

(5)

This text appears in the reports output window when Explain is clicked.

(6)

This marker indicates where the end of the documentation for the report is.