16 Validation and Derivation Procedures

This section includes the following topics:

Validation and Derivation Procedures serve two different purposes. Validation Procedures compare multiple Question responses for the same patient for the purpose of ensuring that patient data is valid. Derivation Procedures use calculations to derive values from collected data. However, both types of Procedures are defined the same way, have the same internal structure, and are executed during batch validation.

Procedures operate on data for only one patient at a time. You cannot write a Procedure to compare the data of different patients. When a Procedure is executed during batch validation, the system processes only those patients whose data has changed (including having new data entered) since the last batch validation. The system runs every Procedure over all the data specified in each Procedure for the patient, not just the new or changed data.

Notes:

If you want to run a Procedure over all patients, you can run the Procedure manually; see "Executing a Single Procedure".

In addition, batch validation automatically runs a Procedure over specified data for all patients if you change the Procedure definition itself.

Batch validation is usually scheduled to run at regular Intervals, such as nightly. During batch validation, all Derivation Procedures are executed before all Validation Procedures, so that you can use the derived values in Validation Procedures. For further information on batch validation, see the Batch Validation section of the chapter "Using the Discrepancy Database" in Oracle Clinical Conducting a Study.

You can create an entirely new Procedure or, if your company has standard DCMs and Procedures, copy one or more to a new study and make any necessary modifications. You can revise a Procedure in an ongoing study and save its current discrepancies by creating a new version of it (see "Where to Start"). You can test a Procedure before making it active and running it against production data (see "Testing a Procedure").

If you want to use the Patient Status feature, you must create a Procedure in each study to populate the Patient Statuses table. Packaged functions with the necessary logic are included with Oracle Clinical. See "Maintaining Patient Statuses".

For information about the Oracle Clinical tables and columns you may want to reference in Procedures, see the Oracle Clinical Stable Interface Technical Reference Manual. Contact Oracle Support to receive a copy of this PDF-format manual. There is no charge.

Note:

In order to reference tables that are not already accessible to the Procedure compilation (including basic tables such as RESPONSES and PATIENT_POSITIONS) you must explicitly grant select privileges on the table to the RXC_PD account.

16.1 About Validation Procedures

You can create Validation Procedures to clean and compare patient data, and to check for inconsistencies and other discrepancies among Question responses for a single patient. For example, you can compare a patient's dosage amount over several visits, or compare a patient's diastolic blood pressure to his systolic blood pressure at the same visit. You must write an expression that, if true, indicates that the collected data is discrepant (inconsistent). Oracle Clinical then creates a discrepancy in its Discrepancy Database, associated with the discrepant response(s), a comment, and any other response values you specify. Clinical personnel must then determine whether the discrepant response is medically significant or the result of a data entry or other error, and handle it accordingly (see "Using the Discrepancy Database" in Oracle Clinical Conducting a Study).

Because Validation Procedures compare multiple responses, the discrepancies they generate are called multivariate discrepancies. The Discrepancy Database also holds univariate discrepancies, which are automatically generated by the system when a Question response does not conform to the limits defined for the Question, such as length, data type, upperbound, or lowerbound (see "Using the Discrepancy Database" in Oracle Clinical Conducting a Study). When you create a Procedure, you can choose whether or not to run the Procedure on data that the system has already found to have a univariate discrepancy.

Validation Procedures can compare multiple responses from a single Received DCM or make complex comparisons of data from multiple RDCMs and visits. Validation Procedures can include arithmetic functions and data manipulations, and can compare both collected and derived data. Several types of special processing are available, including aggregation, lag functions, and limiting the data processed by correlating data by response value, event, or qualifying value (see "Special Processing"). The system makes many key, response, and related values available to Procedures as variables (see "Procedure Variables").

16.1.1 Examples of Validation Procedures

This section includes examples of Validation Procedures:

16.1.1.1 Simple Validation Procedure

Is a patient's diastolic blood pressure greater than or equal to his systolic blood pressure?

A.BP_DIASTOLIC >= A.BP_SYSTOLIC

The system tests whether the diastolic is greater than or equal to the systolic blood pressure, and creates a discrepancy if it is.

This Procedure references responses to a Question Group that includes the blood pressure-related Questions BP_DIASTOLIC and BP_SYSTOLIC. Within the Procedure, that Question Group has an alias of "A." The statement above is the expression in a Procedure detail.

16.1.1.2 Validation Procedure with an Arithmetic Function

Is the difference between a patient's systolic blood pressure and his diastolic blood pressure less than 20?

A.BP_SYSTOLIC - A.BP_DIASTOLIC < 20

The system subtracts the diastolic blood pressure from the systolic and then checks if the difference is less than 20; if it is, a discrepancy is created.

Because this Procedure references the same Questions as the example Procedure above, you may want to include both tests in a single Procedure as separate details. If both tests evaluate to True, the system creates two discrepancies against the same data.

16.1.1.3 More Complex Validation Procedure

This Validation Procedure compares the reported onset date and stop date for an adverse event. If the reported onset date of the adverse event is later than the reported stop date, the Validation Procedure creates a discrepancy.

In this example, the Procedure operates on a single event and a single DCM. The Questions are both in the same Procedure Question Group, which is the Question Group ADVERSE_EVENTS. The first Question is AE_ONSET_DATE, and the second is AE_STOP_DATE.

Instead of directly comparing the values of the date Questions, you can create two user variables to hold those values after you have converted them to Oracle date type so they can simply be subtracted. For example, create user variable i to define the variable ONSET_DATE, and j to define the variable STOP_DATE. You must also define pre-detail custom code to convert the date character values stored in Oracle Clinical to Oracle variables of type DATE (for example, convert June 30, 2005 to 20050630). The custom code can also check for invalid dates (such as June 31, 2005) and take care of a type DATE of length 6 (such as June 2005, or 200506, to which a mid-month TO_DATE of 15 might be consistently appended for a length 8-type DATE of 20050615).

Finally, the Validation Procedure tests ONSET_DATE > STOP_DATE (for example, 20050630 > 20050603) and creates a discrepancy if True. The user variables are used in the actual comparison, not the underlying raw data values. The purpose of the user variables and the pre-detail custom code is to create variables of type DATE so that this simple numerical comparison can be effected.

No system variables are used by this Procedure definition.

16.2 About Derivation Procedures

Derivation Procedures perform calculations on collected data to derive related values; for example, convert values to alternate units (such as pounds to kilos), or compute a value from other data (such as patient age from birth date and visit date). You specify the Question Groups, Questions and clinical planned events (CPEs; usually visits) to use as input and write a calculation that results in the response to a derived Question.

You must create a derived Question to receive the derived value. You define derived Questions in the Global Library the same way as other Questions, except that you must select their Derived? box. You then add them to a Question Group in a study DCM. Alternatively, you can mark a Question as derived in a study DCM Question Group, even if it is not defined as derived in the Global Library. You can also choose whether or not to display the derived Question in the Data Entry window (though it cannot be enterable).

You can include validation tests in a Derivation Procedure to test data before you perform calculations on it. Oracle Clinical reports any discrepancies it finds to the Discrepancy Database. See "Using the Discrepancy Database" in Oracle Clinical Conducting a Study.

Note:

You can test data values before derivation in the same procedure, but to test the derived value you must create a separate procedure.

You can specify the order in which Derivation Procedures are executed during batch validation in the same study, so that you can use the derived value in other Derivation Procedures.

16.2.1 Restrictions on Derivation Procedures

The following restrictions apply to Derivation Procedures:

  • Each derived Question is derived by one and only one Derivation Procedure, and each Derivation Procedure calculation detail derives one and only one derived Question. It is possible to have multiple calculation details in a single procedure, each one deriving a value for a different derived Question.

  • You must denote the Question Group that contains the derived Question as the primary reference Question Group.

    Note:

    The cursor for the primary reference Question Group is the outermost Procedure Question Group Cursor (see "How Procedures Work Internally"). The response values to the primary Question Group are therefore fetched before any other responses in the Procedure, and the derived value is derived once for each instance of that outermost Procedure Question Group Cursor, with the final value derived at the end of the Procedure (only the final derived value is stored). In other words, if the derivation involves multiple Question Groups/cursors, the value of the derived response can change until all of the inner cursors are through looping for a given derived outer cursor.

    Since validation tests are performed in the innermost loop, use caution when testing the derived value in such procedures. You may prefer to use a separate validation procedure to validate derived values.

  • You cannot create a DCM based entirely on derived Questions or populate a DCM entirely with derived data.

  • You must create the derived Question before you create the Procedure that will derive its response (see Chapter 7, "Questions and Question Groups").

16.2.2 Examples of Derivation Procedures

Following are two examples of simple Derivation Procedure calculation expressions.

Temperature Unit Conversion Given a temperature measured in centigrade, calculate the equivalent Fahrenheit value:

(9/5*TEMPERATURE_C)+32

Weight Unit Conversion Given a weight measured in pounds, calculate the equivalent metric (kg) value:

A.WEIGHT_LBS/2.21

16.3 Overview of Defining a Procedure

To create a Procedure, you must do the following:

It usually makes sense to include all the tests you need to do for the same set of data in the same Validation Procedure. See "Structure of Procedure PL/SQL Programs" for further information.

16.4 How Procedures Work Internally

This section contains the following topics:

When you invoke generation, Oracle Clinical takes the Procedure definitions you create and generates PL/SQL code that retrieves patient records (Question responses and related data) for evaluation or computation one at a time. To create complex Procedures it is important to understand:

  • Which records are retrieved, and the order of retrieval (see "Structure of Procedure PL/SQL Programs")

  • How to modify the way records are retrieved to best suit your needs and to enhance performance (see "Special Processing")

  • Given a certain order of record retrieval, how to best save any data that may be needed later in the Procedure—for example, to compare values across visits (see "User Variables", "Aggregate Functions", "Aggregate Lag Functions", and "Lag Checks".

  • Do not use special characters in your code, including messages. Special characters include: ! & ( ) * + , - . / : < = > [ ] ^ |. For further information see the Oracle Database PL/SQL Language Reference 11g Release 2 (11.2). Or, for the latest information, you can generate a list of all keywords and reserved words with the V$RESERVED_WORDS view, described in the Oracle Database Reference 11g Release 2 (11.2); see "Finding Oracle Clinical Documentation".

16.4.1 Cursors

A cursor is a PL/SQL data structure that retrieves one record at a time, as specified in a SELECT statement. The system places each column value retrieved by the cursor into a variable. When you generate a Procedure, the system creates two kinds of cursors:

16.4.1.1 Patient Information Cursors

The Patient Information Cursor becomes the outermost loop in the Procedure. The system generates a standard Select statement for the Patient Information Cursor so that it always fetches values for the same columns. The cursor retrieves patient records sequentially, putting the information into standard variables such as Clinical Study ID and Patient Position ID. See "Standard Variables" for a complete list.

16.4.1.2 Procedure Question Group Cursors

Procedure Question Group (Procedure QG) Cursors are nested inside the Patient Cursor. The system creates one Procedure QG Cursor for each Procedure Question Group, and generates a Select statement for it based on your Procedure Question Group definition (see "Defining Procedure Question Groups"). The Procedure QG Cursors retrieve key values, Question responses, and response-related information (entry timestamp, response ID, and exception value text).

The system puts the values of the key fields and response-related information into Question Group variables (see "Question Group Variables") and puts Question response values into Question variables (see "Question Variables").

16.4.2 Structure of Procedure PL/SQL Programs

For each patient, a Procedure fetches records for each nested cursor, running each expression for every set of records.

Each Procedure includes the following logical parts:

  • Declaration of variables and cursors. The system converts your Procedure definitions to PL/SQL code to declare each of the following:

    • Variables. All the variables—user, Question, and system variables—that you have included in the Procedure. See "Procedure Variables".

    • Patient Cursor. The Patient Cursor is not based on your definitions, but is standard in every Procedure. See "Patient Information Cursors".

    • Procedure Question Group Cursors. Each alias (Procedure Question Group) defined in the Procedure is declared as a cursor, with aggregate Question Groups (if any) first, then the primary reference Question Group, and then all other Question Groups in the order they are displayed in the Question Groups window. See "Procedure Question Group Cursors".

  • Patient Cursor. The patient cursor is the outermost loop in the Procedure. It fetches information from the Patient Positions table about the next patient to be processed, and populates standard system variables with the information.

  • First...n Procedure QG Cursors. The system creates a cursor for each Question Group, and orders them as follows:

    1. Aggregate Question Groups (if any)

    2. The primary reference Question Group

    3. All other Question Groups, in the order they are displayed in the Question Groups window

    The first Procedure QG Cursor is the loop immediately inside the patient loop, and each successive cursor forms the next inner loop.

    For each Question you specify in the Procedure Question Group, each Procedure QG Cursor fetches response values collected for the current patient at all CPEs (unless otherwise specified in the Question Group Event Range or correlation by event) in the order you specify in the Sort Order fields for the Question Group (see "Sort Order").

    The cursor also fetches values for any other variables you specify in the Procedure (see "Procedure Question Group Cursors").

  • Detail. The system picks up your definitions from the Detail and Detail Variable windows to determine whether to run the expression on the current record.

  • Expression. The system runs each expression, referencing values for Questions and other variables as specified in the expression.

    For Derivation Procedures, the system populates derived Question with the derived value (see "About Derivation Procedures"). For Derivation and Validation Procedures, the system reports any discrepancies found, and associates each discrepancy with the variables and comments specified in the Procedure.

  • The system closes each cursor in turn and starts processing the next patient.

16.4.2.1 Example: Procedure with More Than One Procedure Question Group

The structure can be represented as follows:

/* cursor for getting VITALS Production */
cursor V_CUR(
ORDER BY RDCM.VISIT_NUMBER ASC,RDCM.SUBEVENT_NUMBER ASC, RES.REPEAT_SN ASC;
V V_CUR%rowtype;
V$BEGIN_SEQNUM  number := -99999;
V$END_SEQNUM  number := 99999;
/* cursor for getting AE Production */
cursor A_CUR(
...
ORDER BY RDCM.VISIT_NUMBER ASC,RDCM.SUBEVENT_NUMBER ASC, RES.REPEAT_SN ASC;
A A_CUR%rowtype;
A$BEGIN_SEQNUM  number := -99999;
A$END_SEQNUM  number := 99999;
   /****** Main Begin ******/
loop <<fetch_next_patient>>
         /****** Post Patient ******/
 loop << fetch_V_cur>>
            /****** Post QG V ******/
 loop << fetch_A_cur>>
               /****** Post QG A ******/
 <<detail_1>>
 <<detail_2>>
  /****** Post Details ******/
          end loop; /* A cursor loop */
        end loop; /* V cursor loop */ 
 end loop; /* patients cursor loop */
   /****** Main End ******/
 /* Populate discrepancy check table */
  /*  Populate response check table with derived values*/
end;

16.4.2.2 Example: Procedure Containing One Procedure Question Group

A Procedure fetches information as follows when it includes only one Procedure Question Group, and therefore only one Procedure QG Cursor. In this example, the Procedure Question Group is called Physical Exam, and two visits have occurred so far. The sort order is set to the default: by Event and Subevent in ascending order (see "Sort Order").

Retrieve Patient 1 information

Retrieve responses and key values for Visit 1 Physical Exam for Patient 1

For each detail, execute expression(s)

Retrieve responses and key values for Visit 2 Physical Exam for Patient 1

For each detail, execute expression(s)

Retrieve Patient 2 information

Retrieve responses and key values for Visit 1 Physical Exam for Patient 2

For each detail, execute expression(s)

Retrieve responses and key values for Visit 2 Physical Exam for Patient 2

For each detail, execute expression(s)

16.4.2.3 Example: Procedure with Multiple DCMs

In this example, the Procedure retrieves information from two DCM Question Groups, Physical Exam and Lab Tests, that are collected at the same visit. The sort order is set to the default: by Event and Subevent in ascending order (see "Sort Order"). Each Question Group has its own Procedure QG Cursor:

Retrieve Patient 1 information

Retrieve responses and key values for Visit 1 Physical Exam for Patient 1

Retrieve responses and key values for Visit 1 Lab Tests for Patient 1

For each detail, execute expression(s)

Retrieve responses and key values for Visit 2 Lab Tests for Patient 1

For each detail, execute expression(s)

Retrieve responses and key values for Visit 2 Physical Exam for Patient 1

Retrieve responses and key values for Visit 1 Lab Tests for Patient 1

For each detail, execute expression(s)

Retrieve responses and key values for Visit 2 Lab Tests for Patient 1

For each detail, execute expression(s)

Retrieve Patient 2 information

Retrieve responses and key values for Visit 1 Physical Exam for Patient 2

Retrieve responses and key values for Visit 1 Lab Tests for Patient 2

For each detail, execute expression(s)

Retrieve responses and key values for Visit 2 Lab Tests for Patient 2

For each detail, execute expression(s)

Retrieve responses and key values for Visit 2 Physical Exam for Patient 2

Retrieve responses and key values for Visit 1 Lab Tests for Patient 2

For each detail, execute expression(s)

Retrieve responses and key values for Visit 2 Lab Tests for Patient 2

For each detail, execute expression(s)

16.4.2.4 Sort Order

In the Question Groups window you can specify the order in which you want the system to retrieve records within the Procedure Question Group Cursor for each Question Group. Order matters primarily when you use lag variables or perform a similar function yourself by using user variables to hold information from record instance to instance. You may want to compare each visit with the previous visit by Visit and Subevent Order or by DCM Date and Time (which, particularly for subevents, could differ from the Subevent Order). There are two fields for this purpose: Event and Extension.

In the Event field, you can choose to order by either:

  • Visit Number and Subevent Number

  • DCM Date and Time

The default behavior is: Visit Number ascending order, Subevent Number ascending order.

Within the context you choose in the Event field, in the Extension field you can choose to order by either:

  • Repeat Sequence Number (SN) alone (applicable only to repeating Question Groups; the setting has no effect if repeats are not collected)

  • Qualifying Value followed by Repeat Sequence Number (applicable only to DCMs with qualifying values; not available in pre-V3.1-style Procedures)

The default value is Response Repeat Sequence Number ascending.

In both fields, you can choose any combination of ascending or descending order.

16.4.2.5 Sample Procedure Code, with Custom Code Locations

Following is more detailed sample Procedure code. The places where you can insert custom code are highlighted. See "Custom Code" for further information.

PROCEDURE main /*-------------------------------------------------------------*/
(i_clinical_study_id         IN patient_positions.clinical_study_id%TYPE,
 i_clinical_study_version_id IN patient_positions.clinical_study_version_id%TYPE,
 i_data_modified_flag        IN patient_positions.data_modified_flag%TYPE,
 ...
 i_current_location          IN patient_positions.owning_location%TYPE,
 i_timer                     IN BOOLEAN := FALSE ) IS
 v_duplicate_discrepancy     BOOLEAN;

/* << Oracle Clinical puts DECLARATION custom code here >> */



BEGIN
 IF i_timer THEN timer.capture; END IF;

BEGIN
  ...
 std.v_code_location := 'Main Begin';

/* << Oracle Clinical puts MAIN-BEGIN custom code here >> */

 OPEN std.patients_cur; 
 LOOP <<fetch_next_patient>>
   FETCH std.patients_cur INTO std.patients_rec; 
   std.v_code_location := 'Post Patient';
   EXIT WHEN std.patients_cur%NOTFOUND;

/* <<Oracle Clinical puts POST-PATIENT custom code here >> */

  IF std.v_debug = 'Y' 
      THEN DBMS_OUTPUT.PUT_LINE (' ');
           DBMS_OUTPUT.PUT_LINE ('--> Patient: '||std.patients_rec.patient);
   END IF;
   BEGIN
     OPEN b_cur(std.patients_rec.patient_position_id,b$begin_seqnum,b$end_  seqnum);
     std.v_code_location := 'Fetching B data';
     FETCH b_cur INTO b;
     IF b_cur%FOUND 
         THEN  b$has_data := 'Y';
          ELSE IF b$has_data = 'Y'  
                         THEN EXIT;
                           ELSE b := null_b_record; 
                     END IF;
     END IF;
     std.v_code_location := 'Post QG B';

/* << Oracle Clinical puts POST-QG-B custom code here >> */

                                ...  std.v_code_location := 'Pre Details';

/* << Oracle Clinical puts PRE-DETAILS custom code here >> */

            <<detail_1>>
            std.v_code_location := 'First prototype detail - 1 = 1 test';
            IF (1 = 1)
                                        ...
            END IF;
            GOTO detail_2; /* NextDetail=detail_2 */
            <<detail_2>>
            std.v_code_location := 'Second prototype detail - 2 = 2 test';
            IF (2 = 2)
                                        ...
            END IF;
            GOTO detail_3; /* NextDetail=detail_3 */
            <<detail_3>>
            std.v_code_location := 'Third prototype detail - 3 = 3 test';
            IF (NOT(c.diasbp IS NULL OR c.sysbp IS NULL OR c$sysbp$l1 IS NULL))
               AND (3 = 3)
               ...
            END IF;
            GOTO no_more_details; /* NextDetail=no_more_details, could omit */
         <<no_more_details>> 
         NULL;
                                  ...
                                  std.v_code_location := 'Post Details';

/* << Oracle Clinical puts POST-DETAILS custom code here >> */

  ...
     END LOOP; /* b_cur */
 END;
 END LOOP; /* Patients cursor */
 CLOSE std.patients_cur;
 IF i_timer THEN timer.show_elapsed; END IF;

std.v_code_location := 'Main End';

/* << Oracle Clinical puts MAIN-END custom code here >> */

EXCEPTION WHEN OTHERS THEN exception_handling(SQLERRM);

END main;

16.4.3 Viewing Generated PL/SQL Code

After you have created the necessary elements of a Procedure, from the Procedures w Edit window (which is visible only if you have the privileges necessary to edit the code) you can generate the code and view the result (both from the Special menu).

Note that V3.1-style Procedures are implemented using a static package, and the Patient Cursor declaration is contained in the package spec, so that you do not see it in the generated code. You do see the Question Group Cursor declarations, which are specific to the Procedure.

In addition, the generated code includes a test and production version of each cursor. The test version has a T appended to its name (A_CURT instead of A_CUR for Alias A) and is not shown in the examples in this documentation.

16.5 Special Processing

Oracle Clinical provides a user interface (UI) for defining several types of algorithms for processing your data. You enter information in the UI as specified in each section below. When you invoke Procedure generation, the system creates PL/SQL code based on your definitions, and inserts the code in the appropriate place in the generated Procedure. Special processing types include:

16.5.1 Correlation

By default, a given Procedure fetches data from all Questions at all visits for each Procedure Question Group you specify. You can use correlation to limit the data processed by inner Procedure Question Group Cursors to data that matches values in outer Procedure Question Group Cursors.

Correlation processing is driven by the Question Group in the outer loop of the two Question Groups (which is the one displayed further up in the Question Groups window) because the outer loop is processed before the inner loop, but you must define correlation in the definition of the inner loop (the Question Group displayed lower in the window). See "Procedure Question Group Cursors" and "Defining Procedure Question Groups".

As the Procedure processes the data in the outer loop, it processes only data in the inner loop that satisfy the correlation condition(s) you define. The current record, or record currently being processed, is a Question response of the Question Group displayed higher in the window, fetched in the outer loop. The Question Group whose data is limited by correlation is the one displayed lower in the window, for which you define correlation conditions, and whose cursor becomes the inner loop of the Procedure.

You can specify the same Question Group as the correlating Question Group (outer loop) for any number of Question Groups displayed lower in the Question Groups window.

Note:

You can use the Create Placeholder setting in combination with correlation to keep track of missing data. See "Create Place Holder?".

You can use as many combinations of correlation types as you need; for example, correlate the same two Question Groups on both Event and Question in the Time Since Dose example.

You can define three types of correlation, as follows. In each example, Question Group A is displayed higher in the window (forming the outer loop) and Question Group B is displayed lower (forming the inner loop of the two).

16.5.1.1 Correlation on Event

Use correlation on an event, or visit, to process data collected only for certain events relative to the Event Number of the current record (from Procedure Question Group A). Choose Previous, Actual, or Next Event.

For example, you commonly need to compare responses from different Question Groups only with other responses collected at the same visit. In that case, correlate on the Actual Event. Then, when Question Group B is defined as correlated with Question Group A on the Actual Event, the Procedure runs an expression that compares responses from the two Question Groups only when the response from Question Group B was collected at the same visit as the response from Question Group A. If correlation by Event was not specified, the Procedure would run the expression comparing Question Group A's response to Question Group B's response from every visit.

If you specify correlation on the Previous or Next Event, you specify it in the definition of Procedure Question Group B, but it is from the perspective of Question Group A. For example, if Question Group B is defined as correlating with Question Group A on Event (Next), the Procedure runs the expression only when the response from Question Group B was collected at the visit after the visit of the current response from Question Group A. In other words, if the response from Question Group A was collected during Visit 5, the Procedure runs the expression only for the response collected from Question Group B at Visit 6.

Note:

To compare responses to the same Question for several visits, use a lag check. See "Lag Checks".

Note:

In pre-V3.1-style Procedures you can correlate only with the Actual Event.

Example: Correlation on Event This example shows the same situation as in "Example: Procedure with Multiple DCMs", except that the two Question Groups are correlated by Event. Therefore the Procedure processes the record from the Lab Tests Procedure Question Group only when it was collected at the same visit as the current Physical Exam record.

Retrieve Patient 1 information

Retrieve responses and key values for Visit 1 Physical Exam for Patient 1

Retrieve responses and key values for Visit 1 Lab Tests for Patient 1

For each detail, execute expression(s)

Retrieve responses and key values for Visit 2 Lab Tests for Patient 1

(No expressions are executed because the visit number does not match.)

Retrieve responses and key values for Visit 2 Physical Exam for Patient 1

Retrieve responses and key values for Visit 1 Lab Tests for Patient 1

(No expressions are executed because the visit number does not match.)

Retrieve responses and key values for Visit 2 Lab Tests for Patient 1

For each detail, execute expression(s)

Retrieve Patient 2 information

Retrieve responses and key values for Visit 1 Physical Exam for Patient 2

Retrieve responses and key values for Visit 1 Lab Tests for Patient 2

For each detail, execute expression(s)

Retrieve responses and key values for Visit 2 Lab Tests for Patient 2

(No expressions are executed because the visit number does not match.)

Retrieve responses and key values for Visit 2 Physical Exam for Patient 2

Retrieve responses and key values for Visit 1 Lab Tests for Patient 2

(No expressions are executed because the visit number does not match.)

Retrieve responses and key values for Visit 2 Lab Tests for Patient 2

For each detail, execute expression(s)

16.5.1.2 Correlation by Qualifying Value

Use correlation by qualifying value to compare responses to Questions that belong to DCMs with Qualifying Questions, only when the value of the DCM Qualifying Question is the same. The actual qualifying value is not specified, so the system will run the expression over the specified responses whenever their RDCMs' qualifying values are the same.

For example, you might have two DCMs with a qualifying value of either Left or Right, one DCM to collect general information about either the left eye or the right eye, and the other to collect information about abnormalities in one eye or the other. Correlation by qualifying value ensures that left eye general information at each visit is compared only with left eye abnormality information, and right eye general information is compared only with right eye abnormality information.

For information on DCMs with qualifying values, see "Configuring Qualifying Questions".

Note:

If you want to run the expression only when the RDCM has a particular qualifying value, you can use the Where Clause Extension to specify the value in the DCM key variable qualifying_value (see "DCM Key Variables").

Example: Correlation by Qualifying Value This example shows a similar situation to "Example: Procedure with Multiple DCMs", except that both Question Groups belong to a DCM with a qualifying value, and are correlated by DCM qualifying value. Therefore the Procedure processes the record from the Lab Tests Procedure Question Group only when its DCM qualifying value is the same as the current Physical Exam record's DCM qualifying value.

Retrieve Patient 1 information

Retrieve responses and key values for V1 Physical Exam for Pat. 1 (DCMQV=Y)

Retrieve responses and key values for V1 Lab Tests for Pat. 1 (DCMQV=Y)

For each detail, execute expression(s)

Retrieve responses and key values for V1 Lab Tests for Pat. 1 (DCMQV=N)

(No expressions are executed because qualifying value does not match.)

Retrieve responses and key values for V2 Lab Tests for Pat. 1 (DCMQV=Y)

For each detail, execute expression(s)

Retrieve responses and key values for V2 Lab Tests for Pat. 1 (DCMQV=N)

(No expressions are executed because qualifying value does not match.)

Retrieve responses and key values for V2 Physical Exam for Pat. 1 (DCMQV=N)

Retrieve responses and key values for V1 Lab Tests for Pat. 1(DCMQV=Y)

(No expressions are executed because qualifying value does not match.)

Retrieve responses and key values for V1 Lab Tests for Pat. 1 (DCMQV=N)

For each detail, execute expression(s)

Retrieve responses and key values for V2 Lab Tests for Pat. 1(DCMQV=Y)

(No expressions are executed because qualifying value does not match.)

Retrieve responses and key values for V2 Lab Tests for Pat. 1 (DCMQV=N)

For each detail, execute expression(s)

Retrieve Patient 2 information--same processing as for Pat. 1 above

16.5.1.3 Correlation by Question Value

When the Procedure compares values from paired sets of Question responses (a Question response common to both the current Question Group and the correlated Question Group), use correlating Questions. If two Question Groups collect data for a common series of nominal times (such as Time Since Dose), you can use the response value of the Time Since Dose Question to allow comparison testing with other Question responses collected at the same nominal time in the correlated Question Group.

Example: Correlation by Question Value The processing of Question Groups correlated on Question Value looks the same as in "Example: Correlation by Qualifying Value". The difference is that the system compares a Question response instead of the DCM qualifying value before running the detail.

16.5.1.4 Restrictions

The following restrictions apply to correlation:

  • You can correlate a Question Group only to Question Groups listed above it in the Procedure Question Groups window.

  • Correlation and aggregation cannot coexist in a single Procedure.

16.5.1.5 Setting Up Correlation

To use correlation, do the following:

  1. In the Procedure Question Groups window, in the Correlate With Alias field, enter the alias of the Question Group with which you want to correlate the highlighted Question Group. The alias must be for a Question Group listed higher in the window than the highlighted Question Group.

  2. Enter a value for one or more of the following types of correlation:

    • Event. From the list of values, choose Previous, Actual, or Next. The system will run an expression on a Question response only against the correlated Question Group's response(s) that were collected at the previous, same, or next event, compared to the event of the current Question response.

    • Qualifying Question. Applicable only for Question Groups that belong to DCMs with qualifying values. If selected, the system will run an expression that compares Question responses from Question Groups correlated on Qualifying Value only when the value of both Question Groups' DCM's Qualifying Question is the same.

    • Correlating Question. Click the Correlating Questions button and enter the name of a Question from each of the correlated Question Groups (use the list of values). You can enter one or more pairs of Questions, one from each Question Group. The system will run the Procedure only when the values of each pair of Question responses are the same.

16.5.2 Aggregate Functions

Aggregate functions compute an aggregate value for response values for a particular Question for a patient. Aggregate functions available are:

  • Maximum. The highest value.

  • Minimum. The lowest value.

  • Sum. A running total.

  • Average. The average of all specified responses.

  • Count. The number of specified responses collected.

Oracle Clinical creates a system variable for each function you specify and automatically populates the variable to hold the information generated by the function. By default, the system includes all values for the same Question for the same patient, but you can use a Where Clause Extension to filter the responses included in the aggregate function by the value of any of the keys available in that field (see "Where Clause Extension").

Oracle Clinical aggregate functions are based on standard Oracle aggregate functions. Except for the Count function, none of them include null values in their calculations.

The system fetches one row per patient for an aggregate Question Group for all visits. You cannot use an aggregate function, for example, to compute an average of repeated Question values at a single visit (you can use an aggregate lag function for that purpose; see "Aggregate Lag Functions").

You define a Question Group as aggregate by selecting its Aggregate? box, then clicking the Questions button, selecting one or more Questions, and specifying the aggregate function for each selected Question.

The system displays aggregate Question Groups before all other Question Groups, regardless of the order in which you define them. It fetches their values before other Question Groups' values, and executes details with aggregate functions before other details in a Procedure.

16.5.2.1 Variable Names

The naming convention for the system variables is: alias.question_name[occurrence#]$suffix. The suffixes are: mn, mx, sm, av, and ct for the five functions available. The occurrence number is present only when there is more than one occurrence of the Question in the DCM Question Group.

16.5.2.2 Restrictions

The following restrictions apply to aggregate functions:

  • A single Procedure cannot include both aggregate functions and correlation.

  • Qualifying expressions cannot be applied to an Aggregation Question Group (a Question Group with its Aggregate? box selected).

  • All Questions in an Aggregation Question Group must use at least one aggregate function.

  • Questions that use aggregate functions cannot use aggregate lag functions (see "Aggregate Lag Functions").

16.5.2.3 Setting up Aggregate Functions

To use aggregate functions, you must:

  1. In the Procedure Question Group window, select the Aggregate? box for the Question Group that contains the Question(s) on whose responses you want to run an aggregate function.

  2. In the Questions window for that Question Group, for each Question on whose responses you want to run an aggregate function, in the Aggregate Functions field enter each aggregate function you want to have performed. Use the list of values or enter more than one value by entering a value followed by a comma, followed by another value, and so on.

  3. From the main Procedures window, click the Details button. The Details window opens.

  4. Click the Variables button. The Variables window opens.

  5. In a new row in the Variables column, press F9 to open the System Variables window.

  6. Select all the aggregate variable(s) you need to use in the Procedure and click OK.

  7. Select Report? for each variable whose value you want to be able to see in the Discrepancy Database and in DCFs.

You can use the variables in detail expressions and custom code by pressing F9 from the Expression or Custom Code field and selecting them from the list of values.

16.5.3 Aggregate Lag Functions

To compare responses to the same Question for the same patient over a set number of visits, and flag those that are inconsistent, use an aggregate lag function.

Aggregate lag functions operate over the last n responses to a particular Question collected for a particular patient. You set the Lag Depth n to the number of immediate past responses you want to include, and select the aggregate function you want to calculate for those responses.

For example, to obtain the average of a patient's heart rates at his last three visits, mark the Procedure Question HEART_RATE with a Lag Depth of 3 and enter AVG into the Aggregate Lag Function field for that Procedure Question.

In aggregate lag functions you have two choices that are unavailable in aggregate functions:

  • You can choose to include the current value in the aggregate lag function or not. If you include the current value, the system calculates the aggregate lag function on the current value plus the most recent n values.

  • You can choose to include null values in the aggregate lag function calculation or not.

    • If you do not include null values, the system calculates the aggregate lag function on the n most recent non-null values.

    • If you do include null values, the system calculates the aggregate lag function on the n most recent values, whether the values are null or non-null.

You can use aggregate lag functions on any numeric Question in any Question Group that does not have its Aggregate? box selected. The Aggregate? box applies only to aggregate functions (see "Aggregate Functions").

Oracle Clinical creates a system variable for each function you specify and automatically populates the variable to hold the information generated by the function, as follows:

  • Maximum. The highest of the last n values entered as a response to the Question for the patient.

  • Minimum. The lowest of the last n values entered as a response to the Question for the patient.

  • Sum. A total of the last n responses to the Question for the patient.

  • Average. The average of the last n responses to the Question for the patient.

  • Count. The number of the last n responses collected for the Question for the patient. In aggregate lag functions, Count will equal n except at the beginning of the study, when fewer than n responses have been collected for a Question for a patient.

16.5.3.1 Variable Names

Oracle Clinical creates two types of system variables for aggregate lag functions:

  • Lag Variable. The system creates a lag variable to hold each value needed for the Lag Depth you specify. If you specify a Lag Depth of 3, the system creates three lag variables to hold the values of the three most recent Question responses. These variables follow the naming convention alias.question_name[occurrence#]$Ln. The occurrence number is present only when there is more than one occurrence of the Question in the DCM Question Group.

  • Aggregate Variable. The system creates a variable for each aggregate function you specify for the Question. The naming convention for the system variables is the same as for the aggregate function: alias.question_name[occurrence#]$suffix. The suffixes are: mn, mx, sm, av, and ct for the five functions available. The occurrence number is present only when there is more than one occurrence of the Question in the DCM Question Group.

16.5.3.2 Restrictions on Aggregate Lag Functions

A Question Group cannot support both aggregate functions and aggregate lag functions. If you want to use an aggregate lag function, do not define the Question Group as an aggregate one (do not select its Aggregate? box).

16.5.3.3 Using Aggregate Lag Functions

Do not select the Aggregate? box for the Question Group. That flag is for the aggregate function. See "Aggregate Functions".

To use aggregate lag functions, you must:

  1. In the Questions window, for each Question on whose responses you want to run an aggregate function, enter values in the following fields:

    • Lag Depth. Enter the number of responses whose values you want to include in the lag function's calculation. For example, if you enter "5" the system will include the last five responses collected, within the limits you specify in the fields Include Null in Lag? and Include Current Event in Aggregate Lag?.

    • Include Null in Lag? Select this box if you want to include null values in the lag function's calculations. The default value is deselected.

    • Aggregate Lag Function. Enter each aggregate function you want to use. Use the list of values or enter more than one value by entering a value followed by a comma, followed by another value, and so on.

    • Include Current Event in Aggregate Lag? If selected, the aggregate lag function includes the value of the current event in its calculations.

  2. In the Details window, click the Variables button.

  3. Press F9 to open the System Variables window.

  4. Select the aggregate lag variables and click OK.

  5. Select Report? for each variable whose value you want to be able to see in the Discrepancy Database and in DCFs.

You can use the variables in expressions and custom code.

16.5.4 Lag Checks

In a lag check, you write the logic to compare the most recent n response values to the same Question for the same patient, where n is the Lag Depth you specify. Oracle Clinical creates a system variable for each of the last n responses. You can use these variables in writing expressions and custom code.

For example, if you want a Procedure to check whether a value is increasing over time, you can compare the current value with the single most recent previous value of a Question by using a Lag Depth of 1.

You can choose to include null values in the lag check or not.

In the code you write, you can include the current value in any way you choose.

16.5.4.1 Variable Names

The naming convention for the system variables is: alias.question_nameoccurrence#$Ln.

The occurrence number is present only when there is more than one occurrence of the Question in the DCM Question Group.

16.5.4.2 Setting Up Lag Checks

Do not select the Aggregate? box for the Question Group that contains a Question on whose responses you want to run a lag check.

To create a lag check, you must:

  1. In the Questions window, for each Question on whose responses you want to run a lag check, in the Lag Depth field enter the number of responses whose values you want to include in the lag check. For example, if you enter "5" the system will create system variables for the values of the last five responses to the Question for the patient.

  2. In the Details window, click the Variables button.

  3. Click F9 to open the System Variables window.

  4. Select the lag variables and click OK.

  5. Use the variables in custom code.

Note:

Lags are not reset to null after each visit, so you need to design Procedures to take that into account when testing the first n Questions in repeating Question Groups.

16.5.4.3 Lag Check Examples

If you have a Procedure Question Group called MEDS, alias M, and in it a Question named DOSE, when you specify a Lag Depth of 3, the system creates three lag variables: M$dose$L1, M$dose$L2, and M$dose$L3. In addition, you still have access to the current value of the Question M.DOSE. You could create a discrepancy if the dose did not increase from one visit/repeat combination to the next by making this statement in the test detail: M$DOSE$L1>= M.DOSE. This evaluates to TRUE if the value from the previous visit/repeat combination is greater than or equal to the current visit/repeat, and therefore creates a discrepancy.

The first lag ($L1) of the first repeat of a visit is null. In general, the nth lag of the first n values seen by the system are null.

Other lag check examples:

16.5.4.3.1 Populating Lag Variables

Suppose the data for a non-repeating Question Group on a given Question, DOSE, is as follows (note that here the sort order of the Question Group is ascending):

Visit D.Dose
1 10
2 20
3 30
4 40
5 100

As the data is fetched in the Procedure, the variables are populated as follows:

Visit D.DOSE D$DOSE$L1 D$DOSE$L2 D$DOSE$L3
1 10 null null null
2 20 10 null null
3 30 20 10 null
4 40 30 20 10
5 100 40 30 20

16.5.4.3.2 Lag Values for Data from a Repeating Question Group

The Lag Depth applies to previous repeats in the same visit and then previous visits, in descending order. For example, for the Question Group alias AE with three repeats, Question AMOUNT, the lag variables would be populated as follows with successive values 10, 20, 50, 40, and 60:

Visit Repeat AE.AMOUNT AE$AMOUNT$L1 AE$AMOUNT$L2
1 1 10 null null
1 2 20 10 null
1 3 50 20 10
2 1 40 50 20
2 2 60 40 50

16.5.4.3.3 Including Null in Lag

When Include Null in Lag? is selected, variables are populated with the null value when no value is collected:

Visit AE.AMOUNT AE$AMOUNT$L1 AE$AMOUNT$L2
1 10 null null
2 20 10 null
3 null 20 10
4 40 null 20

16.5.4.3.4 Not Including Null in Lag

When Include Null in Lag? is deselected, the system populates the lag value with the previous non-null value:

Visit AE.AMOUNT AE$AMOUNT$L1 AE$AMOUNT$L2
1 10 null null
2 20 10 null
3 null 20 10
4 40 20 10

16.5.4.3.5 Qualifying Expressions and Lags

Qualifying expressions and lags interact in that lag variables are allowed in qualifying expressions; but the expression is evaluated before the lag is calculated. For example, if the qualifying expression is Q1=10, and the data is originally:

Qualifying Expression Value 1 Value 2 Value 3 Value 4
Q1 10 20 10 10
Q2 a b c d

then the values seen in the test detail and qualifying expressions would be:

Pass Test Details Q1 Value Q2 Value
1st Pass Q1=10, Q2=a Q1$L1 is null Q2$L1 is null
2nd Pass Q1=10, Q2=c Q1$L1 = 10 (not 20) Q2$L1 = a (not b)
3rd Pass Q1=10, Q2=d Q1$L1 = 10 Q2$L1 = c

16.5.5 Where Clause Extension

For each Procedure Question Group, you can write a PL/SQL Where clause statement (up to 200 characters) specifying DCM key value(s) and/or a Response Repeat Sequence Number as criteria to filter the records retrieved for processing by the Procedure. See "DCM Key Variables" for a list of DCM keys. To filter on other criteria, use the Qualifying Expression field (see "Qualifying Expression").

The Where clause extension is very efficient because the filter occurs before each Question Group fetch.

Note:

Do not use the Where clause extension in Derivation Procedures.

To define a Where clause extension:

  1. In the Procedure Definitions window, highlight the Procedure and click the Question Groups button. The Question Groups window opens.

  2. In the Where Clause Extension field, enter the Where clause.

    • Do not include the word "where." The system supplies it in the generated code.

    • Use the list of values to select variables to use as criteria in the statement.

  3. Save.

16.5.6 Qualifying Expression

For each Procedure Question Group, you can write a PL/SQL statement (up to 2,000 characters) specifying variable values as criteria to filter the records processed by the Procedure.

The qualifying expression approach is less efficient than the Where clause because the filter occurs after data has been fetched. However, because the cursor evaluates each Question Group after the fetch, you can filter on any criteria.

In V3.1-style Procedures, the Where clause extension is more efficient because it filters before the fetch, but the criteria are limited to DCM key fields.

Note:

Do not use the Qualifying Expression field in Derivation Procedures.

To define a qualifying expression:

  1. In the Procedure Definitions window, highlight the Procedure and click the Question Groups button. The Question Groups window opens.

  2. In the Qualifying Expression field for the Question Group, enter the expression. Use the list of values to select Question variables to use as criteria in the statement. You can use other variables as well; for lists of all the different types of variables, see "Procedure Variables".

    Note:

    The list of values includes all the Questions defined for the Procedure Question Group, even if they have not been selected for use in this Procedure. If you select a Question here, you must also define it as part of the Procedure by selecting Questions under Question Groups.
  3. Save.

16.5.7 Custom Code

You can add your own PL/SQL code at certain points in the generated PL/SQL Procedure code. An extended list of values for variables is available by pressing F9. From the list of values, discrete value group information is available. You can enter up to 4000 characters.

For example, use pre-Details custom code to perform procedural logic prior to the Detail, accumulate information for previously retrieved DCM or patient records, or retrieve information not available in the generated cursors. Or, in post-Details code you can make calculations in preparation for the next cursor fetch, or maintain indexes for array variables. You must define variables before referencing them in code (see "Defining User Variables" and "Using Variables in V3.1-Style Procedures").

Oracle Clinical places your custom code in the generated PL/SQL code at the location you specify in the Custom Code Location menu. See "Sample Procedure Code, with Custom Code Locations" for the exact location of the custom code types.

In pre-V3.1-style Procedures your custom code choices are limited to:

  • PRE-DETAILS, immediately before the Details block; previously called Pre-Code

  • POST-DETAILS, immediately after the Details block; previously called Post-Code

In V3.1-style Procedures your choices include:

  • PRE-DETAILS, immediately before the Details block; previously called Pre-Code

  • POST-DETAILS, immediately after the Details block; previously called Post-Code

  • DECLARATION — at the main Procedure declaration section

  • MAIN-BEGIN — at the beginning of the main Procedure

  • POST-PATIENT — immediately after the patient fetch

  • POST-QG — after Question Group fetch and any placeholder logic

  • MAIN-END — at the end of the main Procedure

Note:

In 3.1-style Procedures, you must explicitly allow for the possibility of pointing to either test or production database tables. See "Converting to the V3.1 Style".

16.6 Procedure Variables

There are several different kinds of variables available for use in Procedures. Some are automatically created by the system (see "Question Variables" and "System Variables"). You can create others as necessary (see "User Variables").

To use a variable in a Procedure, you must first add it to the Procedure. See "Defining User Variables" and "Using Variables in V3.1-Style Procedures". You then add it to a Procedure Detail Expression or custom code by selecting it from the list of values in the appropriate field. To see the list of values, press F9.

When you use a variable in a detail expression, you must also define various settings for the variable. Click the Variables button and specify whether or not you want to report its value to the Discrepancy Database. For Question variables, you can also specify whether or not the system should run the Procedure if the response value for the Question is null or discrepant (see "Using Variables in V3.1-Style Procedures").

16.6.1 Question Variables

Use Question variables to compare Question response values in detail expressions, custom code, or qualifying expressions.

The system automatically creates a Question variable for each Question you include for each Question Group in the Procedure, and populates it with the value for the current patient record during Procedure execution.

The cursor retrieves NULL if the conversion fails, or if no response for the Question can be found for the current DCM.

The system creates Question variables using the following naming convention:

alias.question_name

16.6.2 Aggregate and Lab Attribute Variables

When you define a Procedure as including aggregation processing, the system automatically creates the variable necessary to hold the aggregate value. Similarly, when you define a Question as lab-related, the system creates several lab attribute variables.

All these variables are displayed with Question variables in the list of values for detail variables.

16.6.2.1 Aggregate Variables

The system creates aggregate variables using the following naming convention:

alias.question_name[occurrence#]$suffix

The suffixes are: mn, mx, sm, av, and ct for the five functions available. The occurrence number is present only when there is more than one occurrence of the Question in the DCM Question Group.

16.6.2.2 Lab Attribute Variables

The system creates lab attribute variables using the following naming convention:

question_group_alias$question_name[occurrence#]$suffix

The occurrence number is present only when there is more than one occurrence of the Question in the DCM Question Group.

The four two-letter suffixes are:

  • hi (high value) Contains the value at the high end of the range for the Question defined in Lab Ranges. The high value variable is data type Number (13,5).

  • lo (low value) Contains the value at the low end of the range for the Question defined in Lab Ranges. The low value variable is data type Number (13,5).

  • un (unit) Contains the name of the unit used to define the range in Lab Ranges. The unit variable is data type Varchar2 (10).

  • nf (Not Found) The system sets this flag to Y if no lab range is found for the age and sex of a patient. If the lab range is not gender- or age-specific, the patient's sex or age is not taken into account. The "not found" variable is data type Varchar2 (1).

16.6.3 System Variables

There are several types of system variables: Standard Variables, Question Group Variables, and DVG Variables. To see them, you must press F9 in either the Detail Expression field or the Custom Code field, which opens the System Variable window. This window displays any user or Question variables you have already created for use in the Procedure. There are buttons for DVG, QG, and Std variables below. When you click one of these buttons, you see the system variables of that type related to the highlighted user or Question variable. You can then select the system variables you want to use in that detail expression or custom code location.

16.6.3.1 Standard Variables

The system generates a fixed set of variables for each Procedure. The patient cursor fetches the values for the following patient information fields in the outermost loop of the generated Procedure:

  • patient_position_id Internal ID of the patient.

  • clinical_study_id Internal ID of the study.

  • reported_sex Sex (M or F), from enrollment.

  • reported_birth_date Birthdate, from enrollment.

  • patient Patient number.

  • Site_id Internal ID of site.

  • Investigator_id Internal ID of Investigator.

  • early_termination_flag *If checked, patient has left study ahead of schedule.

  • patient_enrollment_date *Date the patient was allocated this patient position.

  • clinical_subject_id Internal ID of clinical subject.

  • inclusion_exclusion_date Date of decision to include or exclude the patient from the final analysis.

  • reported_death_date I*Date of patient's death.

  • reported_patient_reference *Code the patient was known by in a previous study; according to patient (not validated).

  • reported_initials * Patient's initials, from enrollment.

  • reported_date_last_pregnancy *Date of patients's last pregnancy, from enrollment.

  • first_screening_date Patient's first screening date.

  • termination_date *Date patient position was terminated.

An asterisk (*) indicates that the variable is available in 3.1-style Procedures only.

The naming convention for standard patient-related variables is rxcpdstd.patients_rec.question name; for example, the Question variable name for the Question REPORTED_BIRTH_DATE would be rxcpdstd.patients_rec.reported_birth_date.

Note:

Pre-V3.1-style Procedures use the prefix patients_rec, so that the variable name for the same Question would be patients_rec.reported_birth_date.

16.6.3.2 Question Group Variables

Three types of automatically generated variables appear when you click the QG Vars button from the System Variables window that you display by pressing F9 from the Expressions field in the Details window, or in the Custom Code window:

16.6.3.2.1 DCM Key Variables

The Procedure QG Cursor fetches DCM key (login) information for each Question Group as follows:

  • received_dcm_id Internal ID of Received DCM

  • received_dcm_entry_ts Timestamp of Received DCM

  • Investigator_id Internal ID of Investigator

  • Site_id Internal ID of site

  • dcm_id Internal ID of DCM Definition

  • dcm_subset_sn DCM Subset Number

  • dcm_date DCM Date (YYYYMMDD)

  • dcm_time DCM Time (if Time Collected)

  • actual_event_id Internal ID of Actual Event

  • lab_id Internal ID of Lab (if Lab Data)

  • qualifying_value Value for Qualifying Question

  • subevent_number Subevent (0 for Planned Visits)

  • clin_plan_eve_id Internal ID for Planned Event

  • visit_number Visit Number for Planned Event

  • repeat_sn Repeat Sequence Number

  • lab.* Name of the Lab

  • clin_planned_eve_name.* Event (CPE) Name

  • lab_range_subset_num.* Lab Range Subset Number

*V3.1-style Procedures only

16.6.3.2.2 Question Group Standard Variables

The system generates a fixed set of variables for each Procedure Question Group. They may not all be applicable to a particular Question Group. For example, there are lab-related variables regardless of whether the Question is lab-related or not. The variables are:

16.6.3.2.3 Response-Related Variables

The DCM cursor creates Question variables to hold the actual response value for each Question you specify. However, it also fetches information about the response as Question Group variables, as follows:

  • resp_id Internal Unique ID for the Response.

  • ent_ts Response Timestamp.

  • exc_val Response Exception Value Text; contains text entered during data entry, usually if there was a problem with the actual response, including alpha DVG codes.

16.6.3.2.4 Other Question Group Variables

In addition, the system generates the variable alias$has_data if you select the Procedure Question Group's Create Placeholder? box. The system sets the variable's value to Y if any data is collected for that Question Group. The default is N. You can use this variable to help track missing DCMs.

16.6.3.3 DVG Variables

Discrete Value Groups (DVGs) are assigned to Questions to define the acceptable responses to the Question. There are three types: Internal, Alpha, and Thesaurus. The system creates variables based on the values of internal and thesaurus DVGs. See "Creating and Using DVGs" for further information.

To see DVG variables, open the System Variables window by pressing F9 from the Expressions field in the Details window, or in the Custom Code window, select a Question variable based on a Question with a DVG, and click the DVG button. The DVG button is grayed out when the selected Question variable is based on a Question that does not have a DVG.

Internal DVG Variables Internal DVG variables are not true variables, but a set of fixed values determined by the DVG, not the Question response. The system creates a variable for each value in the DVG. The variable is simply the short DVG value text surrounded by single quotation marks; for example, if the DVG associated with a Question is YES_NO and the short value for YES is Y, the corresponding variable is 'Y'.

Thesaurus DVG Variables If you select the Include Thesaurus Terms box in the Procedure Questions window for a Question with a thesaurus DVG, the system creates a variable for each of the (up to) three columns specified in the DVG to provide supplementary information about the term (response) from the external decode table specified in the DVG definition. The naming convention is: alias$question_nameoccurrence#$suffix where the suffix corresponds to the Short Label defined for each column. The occurrence number is present only when there is more than one occurrence of the Question in the DCM Question Group.

See "Thesaurus DVGs" for further information.

16.6.4 User Variables

You can create variables as necessary for use in internal processing and for reporting values you want to see associated with the discrepancy in the Discrepancy Database and in discrepancy reports.

You reach the User Variables window by clicking the User Variables button in the main Procedure Definitions window.

You can use user variables in Detail Expressions and Custom Code. From either field, press F9 to see the list of values and select a variable.

When you use a user variable in a detail expression, click the Variables button and specify whether or not you want to report its value to the Discrepancy Database.

16.7 Using Lab Ranges

You set lab ranges to define medically appropriate values for Question responses. A Question's lab range may vary according to a patient's age or sex. You can create a Procedure to check if a response falls into the range defined for its Question, creating a discrepancy if it does not. To reference lab ranges in a Procedure:

  • In the Procedure Definitions window, select the Lab Range Dependent? box. If you select this box and then run the PSUB job Lab Procedures Re-execution Pre-process (under the Labs navigation path) after changes are made to lab ranges or lab range subsets, any Procedures that reference Questions with changed lab ranges will be re-executed for all patients during the next batch validation. This functionality is available in V3.1-style Procedures only. See "Lab Procedures Re-execution Pre-process Job Limitations".

    • If responses are no longer discrepant, according to the new range definition, associated discrepancies are obsoleted.

    • If responses are now discrepant, the system generates new discrepancies.

  • In the Procedure Questions window, select the Include Lab Range? box for a Question that is defined with a Question type of Lab Test .

    When a lab-dependent Procedure is executed, the system executes an internal function that brings lab range information into four system variables (High, Low, Unit, and Not Found) for each record fetched. See "Aggregate and Lab Attribute Variables".

    Note:

    The function requires a value for DCM_DATE. If the lab range is date- or age-dependent, the function uses the entered DCM date to identify the correct range for the patient's data. Even if the lab range is not date- or age-dependent the DCM date is required.

    You can ensure that a DCM_DATE value is available by enabling the Data Entry Configuration setting DCI and DCM Date Required, and either checking Use DCI Date? for the DCI Module containing the lab Questions or entering the DCM date during data entry.

  • In a Procedure detail expression, reference one or more of the lab-related system variables.

Example  You could define a nonaggregate Procedure Question Group PHARMACOKINETIC, alias PK, with a Procedure Question named HEMOGLOBIN. You can check the high and low ranges for hemoglobin, given the patient's age and sex, using the variables PK$hemoglobin$hi and PK$hemoglobin$lo. These variables are populated from the values in the Lab Reference Range system.

Different users may enter responses to lab range Questions in different units, and the units associated with the high and low values in the Lab Ranges system may not match the user-entered units. For this reason, it is important that Procedure designers not write Procedures that depend on values being expressed in the same units. Oracle Clinical creates a system variable to contain the unit of the ranges given by the Lab Reference Range system, for example:

PK$hemoglobin$un

No unit conversion (normalization) facility in Procedures exists, but you can convert and store values with custom code and user variables. You can write Procedures that compare values only when the units match. For example:

PK.hemoglobin > PK$hemoglobin$hi * 1.1 and PK.hemo_unit = PK$hemoglobin$un

The expression above creates a discrepancy when the hemoglobin count is higher than the upper lab range value by 10%, only if it is expressed in the same units.

In this example, you must define the Question Hemo_unit in the PK Question Group, to collect the unit in which the response is entered. You must also select the Question variable based on Hemo_unit in the detail expression.

Lab Procedures Re-execution Pre-process Job Limitations The Lab Range Re-execution Pre-process job does not obsolete discrepancies and create new ones in the following circumstances:

  • When changes are made to RDCM keys, except for the keys: Patient, Clinical Planned Event, and Subevent Number.

  • When the Lab Range is changed in such a way that it no longer applies to a patient record. For example, if the Effective End Date is changed to a date before the patient data was collected, the job does not process the record and does not make the discrepancy obsolete.

  • When the Question tested by the Procedure is removed from the lab definition.

16.8 Defining Validation and Derivation Procedures

This section gives explicit instructions on how to define Validation and Derivation Procedures. It includes the following topics:

16.8.1 Where to Start

You define a Procedure following one of three basic approaches: Creating an Entirely New Procedure, Creating a New Version of a Procedure, or Modifying an Existing Procedure from another study or the Global Library.

16.8.1.1 Creating an Entirely New Procedure

Define a new Procedure if your company is a new Oracle Clinical user, or if you are creating a Procedure for a new DCM. See "Naming and Describing a Procedure".

Always create new Procedures in the study, not the Global Library. You cannot generate or test procedures in the Global Library. To add a procedure to the Global Library, you must define and test it within a study (via the Definition subsystem), activate it, and then copy it into the Global Library.

From the Definition menu, select Validation Procedures, and then Procedures, or from Definition, choose Derivation Procedures, and Procedures.

16.8.1.2 Creating a New Version of a Procedure

Use a new version for modest changes in functionality with the option to save discrepancies created by the original version. The new version replaces the current Procedure, which is saved with a status of Retired. Select Create New Vers from the Special menu in the Procedure Definitions window.

16.8.1.3 Modifying an Existing Procedure

From either the Global Library or another study, copy, then modify, an existing Procedure that references the same or functionally equivalent Questions and DCMs. Select either Copy Proc-Study or Copy Proc-GLIB from the Special menu in the Procedure Definitions window, then modify as necessary. To view existing Procedures in detail, from the Glib menu, select DCIs DCMs Procedures, and choose Qry Validation/Derivation Procedures, or from Definition, select Validation (or Derivation) Procedures, then Procedures, then choose a study. The following restrictions apply:

  • You can copy only Active Procedures.

  • The Data Collection Modules, Questions Groups, and Questions referenced in the Procedure (or their functional equivalents) must exist in the study to which you copy the Procedure; otherwise the copy action is terminated with an error message.

  • You can copy only Procedures with domains in the current study domain searchlist.

16.8.2 Procedure Definition Sequence

To define a Procedure you must perform the following tasks, the first four in the order given:

  1. Naming and Describing a Procedure

  2. Defining Procedure Question Groups

  3. Defining Procedure Questions

  4. Defining Correlating Questions for Procedure Question Groups (optional)

The following tasks have no required definition sequence, though you must define variables before you can reference them in Details:

16.8.3 Naming and Describing a Procedure

To reach the Procedure Definitions window, from the Definition menu, select Validation (or Derivation) Procedures, then choose one of the options listed in the table below, according to your access privileges.

16.8.3.1 Access Privileges

The navigation option(s) you see under Definition are determined by your access privileges. You can perform the following tasks through these menu options:

Menu Option View and Define Procedures Set Procedures to Active Edit Generated PL/SQL Code
Procedures Allowed Allowed Not allowed
Prov Procedures Allowed Not allowed Not allowed
Procedures w Edit Allowed Allowed Allowed

16.8.3.2 Defining a Procedure

To define the Procedure, enter the information requested, including:

16.8.3.2.1 Name

Each Procedure Name must be unique within the clinical study.

16.8.3.2.2 Domain

Display only. The system enters the name of the current Oracle Clinical domain.

16.8.3.2.3 Version

A display-only number automatically assigned to each new version of a Procedure after its creation, which is version 0. The status of a new version of a Procedure defaults to Provisional. (You can revise a Procedure in an ongoing study and save its current discrepancies by creating a new version of it—select Create New Vers from the Special menu in the Procedure Definitions window.)

16.8.3.2.4 Status

There are three possible statuses: Provisional (P), Active (A), and Retired (R). You can modify and test Procedures only when they are set to Provisional. See "Assigning Procedure Status".

Note:

If you set an Active Procedure's status back to Provisional, all the discrepancies already created by the Procedure are hard-deleted during the next batch validation run. To avoid this, create a new version of the Procedure from the Special menu.
16.8.3.2.5 Sort Order

(Derivation Procedures only) Determines the order in which batch validation executes this Derivation Procedure relative to other Derivation Procedures in the same study.

Tip: If the execution order makes no difference, give the Procedure a Sort Order of 100, for example. Any number of Procedures can have the same Sort Order Number. Give a lower Sort Order Number to Procedures that generate a derived value that is used by other Validation or Derivation Procedures.

Note:

During batch validation, the system executes all Derivation Procedures before all Validation Procedures for a particular study. Validation Procedures are executed in alphabetical order by Procedure Name. Derivation Procedures are executed by Sort Order Number. If multiple Derivation Procedures have the same Sort Order Number, the system executes those Procedures in alphabetical order by Procedure Name.
16.8.3.2.6 Execution Context

The default setting, Off-line, is appropriate for Procedures you want to execute within the context of Oracle Clinical, either as part of batch validation or individually.

The other two settings are for use with the Remote Data Capture (RDC) option for Oracle Clinical, or with your own DCAPI application. They enable you to run a Procedure on data soon after it is entered into the system, without waiting for batch validation to run:

  • On-line/DCM. Procedures with this setting are run when the RDC user saves work for a particular patient, if the Procedure's primary reference Question Group belongs to the DCM the user has just entered. Any discrepancies generated by the Procedure become visible to the user. Use this setting only if the Procedure runs on responses from only one DCM.

  • On-line. Use this setting if the Procedure compares more than one DCM, or if you prefer not to have the Procedure run automatically on save in RDC.

The Validate Patient and Validate Site options in RDC's Validate menu execute both On-line and On-line/DCM Procedures for a patient or a site, respectively. For information on DCAPI implementation, see the Oracle Clinical Application Programming Interface Guide manual.

Oracle Clinical batch validation runs all Procedures, regardless of their Execution Context setting.

Note:

If you make a change to a Procedure, you must run batch validation to run the Procedure against all patients, including patients with no data changes. When On-line and On-line/DCM Procedures are executed from outside Oracle Clinical, Procedures are run only against patients with changed data, even if the Procedure itself has been modified.
16.8.3.2.7 Category

Choose the combination of one or multiple events (visits) and one or multiple DCMs that describes the data compared in this Procedure.

The Thes_Derivation option is for use with thesaurus DVGs. It has nothing to do with the current Thesaurus Management System (TMS).

16.8.3.2.8 Ver 3.1 Style?

Select the Ver 3.1 Style? box to get the best performance and functionality. See "V3.1-Style and Pre-V3.1-Style Procedures".

16.8.3.2.9 Lab Range Dependent?

Select this box if this Procedure references a Question that is associated with a lab range. Oracle Clinical then creates lab range-related system variables for use in the Procedure. In addition, if you change the definition of a lab range and then run the Lab Procedures Re-execution Pre-Process PSUB job (under Labs), the next batch validation executes all Procedures that both

  • have this box selected

  • reference Questions with changed lab ranges

for all patients, even if the patients' data has not changed.

16.8.4 Defining Procedure Question Groups

To reach the Question Groups window, click the Q-Grps button in the Procedure Definitions window. In this window you list the DCMs and Question Groups that the Procedure will reference and define how the Procedure will process them.

16.8.4.1 Performance Issues

The choices you make in this window have important implications for the efficiency of the Procedures you create. This section gives tips on how to design your Procedure for optimal performance. For more detailed information, see "How Procedures Work Internally".

Each cursor, or Question Group Alias, is nested inside those declared before it. So for each A record fetched, the B cursor must be opened and closed. To minimize need for cursors and maximize performance, use these design strategies:

  • Use correlation whenever possible (See "Correlate With").

    Note:

    You can correlate a Question Group only to Question Groups listed above it in the Question Groups window, so order Question Groups accordingly.
  • Use qualifying expressions and Where clause extensions whenever possible in Validation Procedures. You cannot use them in Derivation Procedures. See "Qualifying Expression" and"Where Clause Extension".

  • If you need two types of aggregate functions—for example, sum and count—from the same Question Group, use only one cursor. You can specify as many aggregates as you need using one alias for all the Questions in that Procedure Question Group.

  • Use Event Range and First/Last Event Only whenever possible.

  • Bear in mind the fact that the Procedure QG Cursor fetches aggregate Question Groups first, followed by the primary reference Question Group. The cursor then fetches the remaining Question Groups in the order they appear in the window, which is determined by the order in which you define them.

16.8.4.2 About the Question Groups Window

Be sure to read "Performance Issues" before proceeding.

In order to use a Question response value in a Validation or Derivation Procedure, you must define the Question and its DCM Question Group as part of the Procedure. In the Question Group window you can also define special processing for the Question Group.

When you include a DCM Question Group in a Procedure, you create a reference to it. A single DCM Question Group can be referenced by several Procedure Question Groups in the same Procedure. For example, to compute an average baseline value for a group of DCM Questions and compare baseline values to the latest values at each subsequent visit, you need to create two Procedure Question Groups for that DCM Question Group: one an aggregate Question Group to compute average baseline value; one to compare each subsequent value to the average baseline value.

The window includes the following fields:

16.8.4.2.1 Alias

A short name that uniquely identifies the Question Group and its Questions in Procedure details, correlated Question Groups, and some system variables. The name may be up to 4 characters and may not begin or end with a number. You can change this field only for Provisional Procedures. Changes automatically cascade to all uses of the alias throughout the Procedure.

16.8.4.2.2 Aggregate?

Select this box to use the Aggregate function to keep track of the minimum, maximum, sum, count, or average of a given Question response over all patients and visits; see "Aggregate Functions". If you want to track an aggregate value for only the last n visits, do not select this box and define an aggregate lag function for the Question in the Questions window.

16.8.4.2.3 Primary Reference

If selected, this Procedure Question Group is the primary reference Question Group. Any discrepancies found by the Procedure are associated with this Procedure Question Group in the Discrepancy Database. If this is a Derivation Procedure, the target derived Question must be part of the primary reference Question Group. The primary reference Question Group is fetched after any aggregate Question Groups but before all others.

16.8.4.2.4 First in the Event Range

The first visit (clinical planned event) you want the Procedure to process.

16.8.4.2.5 Last in the Event Range

The final visit (clinical planned event) you want the Procedure to process.

16.8.4.2.6 Sort Order Event

Controls the sort order for responses to the Questions in this Procedure Question Group, based on Event and Subevent or DCM Date and Time. You must choose an ascending order you plan to enter a value in the First/Last Event Only field. Use the list of values to select the sort order type. See "Sort Order".

16.8.4.2.7 Sort Order Extension

From the list of values, specify the innermost sort criteria for responses to the Questions in this Procedure Question Group. Default: REPEAT_SN ASC, or, where the corresponding DCM has a Qualifying Question, QUALIFYING_VALUE ASC, REPEAT_SN ASC.

16.8.4.2.8 First/Last Event Only

Specifies that the Procedure will process only the first or only the last event it finds for each patient.

Note:

Do not use this field in Derivation Procedures.
16.8.4.2.9 Single Repeat Only?

In V3.1-style Procedures, you can specify that you want to fetch only the first occurrence of a repeating Question Group.

16.8.4.2.10 Create Place Holder?

The Procedure creates a null DCM record when data the Procedure needs to run an expression is missing (equivalent to a SQL outer join). Since a particular Question response might be null because the data entry operator did not fill it in, rather than because the entire RDCM is missing, refine your code by referencing the Has_Data variable that Oracle Clinical creates for each Procedure Question Group with Create Place Holder? selected. Its default value is N. If data is entered for any Question in the RDCM, the system changes the value of the Has_Data variable to Y. Reference it as Alias$Has_Data.

You can use this setting to create a discrepancy if a Question response is missing, and to detect missing RDCMs.

Note:

Do not use this field in Derivation Procedures.
16.8.4.2.11 Correlate With

By default, Oracle Clinical fetches all data for patients with changed data, and runs each Procedure on all Question responses at all visits for the RDCM Question Group Questions specified in the Procedure definition. You can avoid unnecessary processing by setting up correlation where appropriate. See "Correlation".

Note:

You cannot have both correlation and aggregation defined in the same Procedure.

To use correlation, you must specify an Alias—a Question Group with which to correlate this Question Group. The correlating alias must be displayed higher in this window than the current Question Group. You can then choose Event, Qualifying Question, or Correlating Question, or any combination of the three. See "Correlation".

16.8.4.2.12 Where Clause Extension

A PL/SQL Where clause statement (up to 200 characters) that limits the retrieval of records for processing by the Procedure by filtering on the value of DCM key fields before each Question Group fetch. Use the List function to obtain a list of DCM key fields to use as criteria. To filter on other criteria, use the Qualifying Expression field. See "Where Clause Extension".

Note:

Do not use this field in Derivation Procedures.
16.8.4.2.13 Qualifying Expression

A PL/SQL statement that limits the retrieval of records for processing by the Procedure. Use the List function to obtain a list of available QG Questions. You can filter on any criteria because the cursor evaluates each Question Group after the fetch. See "Qualifying Expression".

Notes:

  • Do not use this field in Derivation Procedures.

  • If you use a Question here, you must also define it as part of the Procedure by selecting Questions under Question Groups.

16.8.4.2.14 Custom Code

You can add code to be executed after the system fetches the Procedure Question Group you are defining by clicking the Custom Code button and entering the code. See "Adding Custom Code".

16.8.5 Defining Procedure Questions

Reach this window by selecting Question Groups under Procedure Definition. In the Procedure Question Groups window, highlight a Question Group and click Questions.

List the DCM Questions you want to reference in the current Procedure Question Group and specify special processing, such as referencing lab ranges, as needed. When you define the Detail, or test, for the Procedure, you can use Procedure Questions' values as variables of type QUESTION using the naming convention alias.question_name.

Information on each field in the window follows:

Question Name Use the list to define the DCM Questions that you want to reference in this Procedure Question Group.

Derived Questions that are the target of the Procedure have the following constraints:

  • They must be in the primary reference Procedure Question Group.

  • They cannot occur as the target of any other Detail in any other Procedure.

  • You must include at least one non-derived Question in a Procedure Question Group.

Occurrence Number Select the occurrence sequence number of the Question in the DCM Question Group. The list displays valid numbers for each available Question.

DCM Derived Question? If the Question has been defined as a derived Question, this field is selected.

Report? For pre-V3.1-style Procedures only. Select this box if you want this Question response included in discrepancy reports. (For V3.1-style Procedures see "Using Variables in V3.1-Style Procedures".)

Aggregate Function The Aggregate function allows you to keep track of the minimum, maximum, sum, count, or average of a given Question response over all patients and visits. (You cannot define a Question as aggregate unless its Question Group's Aggregate? box is selected in the Procedure Question Groups window.) See "Aggregate Functions".

Include Lab Range? If this Question is defined as a lab test Question, select this field. See "Using Lab Ranges".

Note:

When you change a lab range (from the Labs menu, choose Labs, then Labs, then choose Ranges) you must run the Lab Procedures Re-execution Pre-Process PSUB job (under Labs). Oracle Clinical will then re-execute all Procedures that reference that changed lab range for all patients during the next batch validation.

Include Thesaurus Terms? Select if the Question is defined as having a thesaurus DVG. The system generates up to three system variables to receive the values defined in the thesaurus DVG definition. See "Thesaurus DVG Variables".

Lag Depth Specifies the number of values of a single Procedure Question for a single patient (immediately before the current value) to make available for use in detail expressions and custom code. Oracle Clinical creates a system variable to hold each of the last n values for a Question, where n is the Lag Depth you specify. Used in aggregate lag functions and in lag checks. See "Aggregate Lag Functions" and "Lag Checks".

Include Null in Lag? If this field is not selected, null values are not included for lag variables, so a previous non-null value is retained until a new non-null value is available. Controls whether re-initialization occurs for each process loop, or only LAG_FLAG when the lag variable is not null. See "Aggregate Lag Functions" and "Lag Checks".

Aggregate Lag Function? If you want to calculate an aggregate value over only the last n values, use the aggregate lag function. See "Aggregate Lag Functions".

Include Current Event in Aggregate Lag? If selected, the aggregate lag function includes the value from the current visit. See "Aggregate Lag Functions".

16.8.6 Defining Correlating Questions for Procedure Question Groups

To reach this window, select a Question Group in the Question Groups window that has Correlate w/ Alias? selected, and click Correlating Questions. In this window, you specify the name and occurrence number of the two Questions you are correlating. The system will run the Procedure on the response to the Question in the Question Group displayed higher in the Question Groups window only when the response value of the Question from the lower group is the same. See "Correlation".

Before you can carry out the task, you must do the following:

  • Select the Correlate w/ Alias? field for the current Question Group.

  • Define the Questions you want to correlate in the Questions window for the current Question Group and the correlated Question Group.

16.8.7 Defining User Variables

To reach the User Variables window, click User Vars in the Procedure Definitions window.

User variables are variables you define and use to store values for testing and to provide temporary placeholders for generated PL/SQL code. You can use them for internal processing and/or to report values to the Discrepancy Database and in discrepancy reports. They can represent a single value or an array of values, and can be of data types character, numeric, or date/time.

You must define user variables here before you can use them in Procedure Detail expressions or custom code.

Oracle Clinical also creates system variables for use in Procedures (see "Using System Variables in Pre-v3.1-Style Procedures").

16.8.7.1 Variable Name

Name of a user variable, unique within a Procedure; up to 30 characters.

16.8.7.2 Init Alias

Specify when to initialize a variable; if the field is left blank, Oracle Clinical initializes the variable for each new patient; if you specify an alias, the variable is initialized after each fetch of that alias (Question Group) cursor.

16.8.7.3 Data Type

Choose the appropriate value from the list.

16.8.7.4 Length

Specify the maximum length of the value of the variable. If you want to limit the length of a text string, or to cause number rounding, enter the limit here.

16.8.7.5 Decimal Places

Set the precision of the value of a user variable with data type NUMBER.

16.8.7.6 Initial Value

Specify the value to which the user variable is initialized. If you leave this field blank, the user variable initializes to a null value.

16.8.7.7 Report

For pre-V3.1-style Procedures only, select if you want discrepancies found on this variable to be reported. In V3.1-style Procedures you set this in the Detail Variable Settings window. See "Using Variables in V3.1-Style Procedures".

16.8.7.8 Description

Description of the variable, up to 70 characters.

16.8.8 Defining Procedure Details

To reach the Details window, click Details in the Procedure Definitions window.

A detail is the logical test or calculation performed on data during a Procedure. It consists of a single Boolean statement that, if true, results in an entry in the Discrepancy Database. A given Procedure may contain many details, each testing a particular condition. You must define user variables before referencing them in detail expressions. See "Defining User Variables" and "Alternative Approaches to Error Reporting".

Define a detail as follows:

16.8.8.1 Order Number

Enter the order in which you want this detail to be executed in relation to the other details in the Procedure. You can change this number in Provisional Procedures only.

16.8.8.2 Continue If Discrepancy

Select this box if you want the Procedure to continue executing other details if this one finds a discrepancy. If so, specify the number of the detail you want to execute next in the Cont at Detail# field. (This functionality is available only in V3.1-style Procedures.)

16.8.8.3 Test Not Null Only

Select this box if you want the Procedure to execute this detail only if the Question response is not Null.

16.8.8.4 Detail Types

This field is found in the Derivation Procedure window only, since Calculation-type details are used only by Derivation Procedures to calculate derived Question responses. All other details (all details in Validation Procedures and details in Derivation Procedures that do not directly derive data) are of type Test, even if they include arithmetic functions and data manipulations. You can use Test details in a Derivation Procedure to ensure that your data is valid before you calculate the derived response, or to check the calculation after deriving it.

16.8.8.5 Externally Derived

Select this box if the response to this Question is derived by a system outside Oracle Clinical, for example, the Thesaurus Management System (TMS).

16.8.8.6 Failure Type

Specify the severity of a discrepancy generated by the Detail expression in this detail line. The failure type is associated with the discrepancy in the Discrepancy Database. You can change this field only for Provisional Procedures. Select from the list. The choices Thesaurus_PT and Thesaurus_SCT are used by the outdated Thesaurus Management Option (TMO) of Oracle Clinical; TMS does not use them. (These values are set in the installation reference codelist VALIDATION FAILURE TYPE CODE; you may want to set the TMO values to Inactive so they do not appear in this list of values.)

Note: Calculation-type details in Derivation Procedures do not generate discrepancies, and therefore, do not use this field.

16.8.8.7 Description

Free form text, up to 200 characters of mixed case, describing the Detail expression in this detail line of the Procedure. The system enters the text you enter here as the default text in the Message field. You can edit and expand it there.

16.8.8.8 Expression

In Validation Procedures and in Test-type details in Derivation Procedures, the expression is a single Boolean statement that, if true, results in a discrepancy being created. For example, in the test detail A.BP_SYSTOLIC - A.BP_DIASTOLIC < 20, the system subtracts the diastolic blood pressure from the systolic and creates a discrepancy if it is less than 20.

You can see all the variables available for use in this expression (Question, system, and user variables) by pressing F9 from this field. See "Procedure Variables" for further information.

In details of type Calculation in Derivation Procedures, the expression generates the derived response to a derived Question. Constraints for derivation details of type Calculation:

  • You must give the Calculation Detail a lower order number than any other details that use the response.

  • You can include user-entered (non-derived) Questions as input to a calculation or test detail, but not as the subject or target of the calculation detail.

  • The Derivation Procedure must generate a value of the same data type as the derived Question.

16.8.8.9 Message

Free form text, up to 500 characters, that appears as a comment associated with any discrepancies this detail generates. The system enters the Description text as the default message.

16.8.8.10 Discrepancy Code

Select the code to be associated with the discrepancy in the Discrepancy Database according to your company's policy.

16.8.9 Using System Variables in Pre-v3.1-Style Procedures

Reach this window by the Sys Vars button in the Procedure Definitions window. In V3.1-style Procedures, this button is grayed out; you mark system variables for reporting with the Variables button in the Details window. See "Using Variables in V3.1-Style Procedures".

System variables are created by the system when you create Procedure Questions that require them—for example, if you define lags as part of the Procedure, a system variable is created for each lag of the Lag Depth. View the system variables to decide whether to report related test failures as discrepancies.

16.8.10 Using Variables in V3.1-Style Procedures

To reach the Variables Settings window, click Variables in the Details window (not available for Calculation-type Details in Derivation Procedures or in pre-V3.1-style Procedures). You can specify the interaction of each detail and each variable as follows:

16.8.10.1 Variable

The Variable field lists all variables (user, system, and Question) currently selected for the detail. You can add variables to the detail by pressing F9 and making selections from the multipick list of values. It includes all remaining variables available to the Procedure. Question variables are Questions you have selected from the Procedures menu, by selecting Question Groups, and then Questions.

16.8.10.2 Perform Detail Only If...

You can select any combination of the three fields included in this section, each of which is designed to avoid processing inappropriate data.

16.8.10.2.1 Not Null

If selected, Oracle Clinical will run this detail on a variable only if the variable actually contains a response value. If the variable is null (because no data was entered for the Question for a patient at a particular visit) Oracle Clinical will skip this detail.

Note that the Procedure treats the value as null if an alpha DVG value has been entered, because alpha DVG values are stored in a different field: the Exception Value Text field. Treating alpha DVG values as null is appropriate because the presence of an alpha DVG value indicates a problem with the response: either the response was missing or an alphabetical value was entered for a numeric-type field (such as TRACE for lab data). Variables can have alpha DVG values only if they are Question variables and the Question on which they are based is defined as having an alpha DVG. See "Alpha DVG Subset Examples".

16.8.10.2.2 No Univariate Error(s)

Applicable to Question variables only. If selected, Oracle Clinical will run this detail on this variable (Question response) only if the response does not have a univariate error of the type(s) you specify in the list of values. If the response has a univariate error of the type(s) you specify, the system will skip this detail. You can choose more than one.

A univariate error is a Question response that is invalid because it does not satisfy conditions specified in the Question definition. The system creates a discrepancy for each univariate error automatically. You may not want to create additional discrepancies based on known discrepancies. The univariate error types are:

  • Data Type. The response does not match the defined data type; for example, an alphabetical response for a numeric field, or an incorrect date format.

  • DCM Level. Not used.

  • DVG. The response entered is not included in the DVG associated with the Question.

  • DVG Subset. The response entered is not included in the DVG Subset associated with the Question.

  • Length. The response exceeds the length defined for the Question.

  • Lowerbound. The response value is lower than the lowerbound limit defined for the Question.

  • Mandatory. A mandatory response is missing.

  • Upperbound. The response value is higher than the upperbound limit defined for the Question.

  • Missing PT. This choice is a vestige of the Thesaurus Management Option, which is no longer supported. It has nothing to do with the current Thesaurus Management System.

  • Missing SCT. This choice is a vestige of the Thesaurus Management Option, which is no longer supported. It has nothing to do with the current Thesaurus Management System.

16.8.10.2.3 Unresolved

If selected, Oracle Clinical will skip this detail if this variable has an irresolvable univariate error.

16.8.10.3 Discrepancy Test

If selected, Oracle Clinical will test any discrepancies found on this variable to determine whether a they are new or the same as an existing one. If the same, the system does not create a new discrepancy. This field must be selected for at least one variable in each detail. If selected, the system automatically selects Report also.

Batch validation processes only changed data, so it does not create duplicate discrepancies. Flag variables whose values you may want to compare between batch validation runs. Do not flag variables—such as Patient Name—that might trigger a discrepancy due to a simple misspelling.

16.8.10.4 Report

If selected, the value of this variable is visible in the Maintain Discrepancy Database window, associated with the discrepancy. In that window, users can choose whether or not to include the value in the Data Clarification Form as well. Be sure to report the value of the Question being tested so that, if its response value triggers the creation of a discrepancy through this Procedure, it will be possible to see the discrepant value in the Discrepancy Database window and in the Data Clarification Form. This field must be selected for at least one variable in each detail.

16.8.10.5 Report Order

If you want the variable to be reported, specify the order in which you want it to appear, in relation to other variables from this detail.

16.8.11 Adding Custom Code

If you need to refine Procedure tests, you can add your own PL/SQL statements of up to 4000 characters at certain points in the generated PL/SQL Procedure.

For example, use pre-details custom code to perform procedural logic prior to the detail, accumulate information for previously retrieved DCM or patient records, or retrieve information not available in the generated cursors. Or, in post-details code you can make calculations in preparation for the next cursor fetch, or maintain indexes for array variables. For more information, see "Custom Code".

Oracle Clinical places your custom code in the generated PL/SQL code at the location you specify in the Custom Code Location box. See "Sample Procedure Code, with Custom Code Locations" for the exact location of the custom code types.

An extended list of values for variables is available by pressing F9. See "Procedure Variables" for information on the automatically generated variables available for you to use in custom code. See "Defining User Variables" for information about creating variables.

16.8.11.1 Adding Custom Code

To reach the Custom Code window, click Custom Code from the Procedures Definitions window. To add custom code of type Post-QG only, you can also click Custom Code from the Question Groups window.

To add custom code you must:

  1. From the Custom Code Location list, choose the place you want to put your code.

  2. In the main field, enter the PL/SQL code you want to insert into the generated Procedure code at that location. Press F9 for a list of available variables. You can enter up to 4000 characters.

  3. Save.

  4. Repeat for each custom code location you need.

  5. Generate the Procedure. From the Procedure Definition window, select Generate from the Special menu.

To view the full, generated PL/SQL code of the Procedure, go to Edit Proc in the Special menu. You must use the Procedure with Edit navigation path to reach the Procedures window. If you do not see that path, you need additional privileges to see the code.

If you have the necessary privileges, you can edit the generated code. However, if you ever generate the code again, your edits are lost. Custom code is not lost when you regenerate the Procedure.

16.9 Testing and Activating Procedures

After you define a Procedure, you must generate it and set its status to Active before you can execute it. Oracle Clinical does not enforce Procedure testing, but provides for it (see "Testing a Procedure").

This section includes the following topics:

16.9.1 Generating and Compiling a Procedure

When you invoke generation, Oracle Clinical takes the definitions you have specified and converts them to the PL/SQL code that will perform the Procedure.

  1. In the Procedure Definitions window, highlight the Procedure you want to generate and compile.

  2. Select Generate Proc from the Special menu. Oracle Clinical generates the PL/SQL code to execute the Procedure in the background and updates the Last Generated field with the current date, or displays an error message. A message confirms when the generation is complete.

  3. To view error messages resulting from a failed generation, choose View Parse Errors from the Special menu.

    Note:

    If you receive an error on generation that refers to a naming conflict with the Question QGalias.LAB, you have a study Question named Lab that conflicts with the standard procedures lab Question named Lab. To resolve the problem, you can change the standard lab Question alias in the OCL_STATE local reference codelist (under Admin).

16.9.2 Editing Generated PL/SQL Code

If you have the required security privileges, you can edit the actual generated PL/SQL code. However, you should take extreme care and use custom code whenever possible (see "Adding Custom Code").

Note:

Changes that you make directly to the generated code (not through the Custom Code window) will be lost the next time the Procedure is generated.

You can also use the editing window to view the generated code and better understand what effect your Procedure definitions and settings have on the generated code.

If you have a navigation path choice called Procedures w Edit after either Validation or Derivation Procedures, you have the required privileges to edit generated Procedure code.

  1. In the Procedure Definitions window, highlight the Procedure with the generated PL/SQL code you want to edit.

  2. From the Special menu, select Edit Gen Proc to display the generated PL/SQL text.

  3. Modify the text.

  4. Save. Oracle Clinical returns to the Procedure Definitions window, sets the value in the Edited? field to selected, and re-parses the code.

  5. Enter a comment about why you edited the text.

  6. Click Back to return to the original window.

  7. From the Special menu, select View Parse Errors.

16.9.3 Testing a Procedure

This section contains the following topics:

Testing a Procedure from Definition

Testing a Procedure from Test a Study

Before making a Provisional Procedure active and running it against production data, you should test it (see Chapter 17, "Test Mode" for information on Oracle Clinical's Test mode). You can then modify the Procedure components as necessary while the Procedure is still Provisional.

You can test the Procedure from either Procedure definition or study testing. You can view the results of testing Validation Procedures in the Test Discrepancy Database; from the Definition menu, select Test a Study, then choose Discrepancy Database. Unlike Production mode, in Test mode each time you run a test, the previous discrepancy data for that test is erased.

16.9.3.1 Testing a Procedure from Definition

To test a Procedure from Definition, do the following:

  1. In the Procedure Definition window, highlight the Procedure and select Execute in Test from the Special menu. A dialog box appears.

  2. If you want to run the Procedure in Debug mode, which lets you view the individual values as they are validated in the .out file, choose Yes. A message appears, giving you the batch job ID number.

  3. To check on the job's progress and see the .out and .log file names, select Batch Jobs from the Action menu.

  4. View the results:

    • See the .log and .out files in the procedure output files on the server.

    • See the discrepancies created by the Procedure in the Discrepancy Database by selecting Show Test Discrep from the Special menu in the Procedure Definition window. Alternatively, from the Conduct menu, select Data Validation, then Discrepancy Database.

16.9.3.2 Testing a Procedure from Test a Study

To test a Procedure from Test a Study, from the Definition menu, select Test a Study, then Execute Single Procedure, and follow standard procedure for submitting batch jobs. To view the results:

  • See the .log and .out files in the procedure output files on the server.

  • See the discrepancies created by the Procedure in the Discrepancy Database by selecting Show Test Discrep from the Special menu in the Procedure Definition window. Alternatively, from the Conduct menu, select Data Validation, then Discrepancy Database.

16.9.4 Assigning Procedure Status

Oracle Clinical automatically assigns a status of Provisional (P) to new or copied procedures. You can delete, modify, and test only Provisional Procedures. You can copy and run only Active (A) Procedures. Procedures you no longer want to run during batch validation should be set to Retired (R).

If you have the appropriate security privileges, you can:

  • Change a Provisional Procedure to Active.

  • Change a Retired Procedure back to Active.

  • Change an Active Procedure to Provisional (although this action deletes all discrepancies associated with the Procedure).

Note:

When a Procedure's status is changed from Active to Provisional, all discrepancies associated with it are deleted during the next batch validation run. To avoid this, create a new version of the Procedure from the Special menu."

To change the status, enter the appropriate letter (P, A, or R) in the Status field in the Procedure Definitions window.

Oracle Clinical runs all Active Procedures during each batch validation.

16.9.5 Assigning Standards Affiliation

After you have defined a Procedure in a study, generated and tested it, work with the Global Librarian to copy it into the Global Library so that you can use it in other studies. In the Global Library you can also assign it one or more standards affiliation types to identify its purpose, to mark the Procedure as Required (or not) in a study with a particular standards affiliation, and to make the Procedure easier to find for future reference. You cannot define Procedures in the Global Library. (See the Oracle Clinical Getting Started manual for information on the Global Library.)

16.10 Executing Procedures

Procedures are executed as part of every batch validation, usually scheduled to run at regular Intervals. You can also execute a single procedure or batch validation at any time:

16.10.1 Executing a Single Procedure

You can explicitly execute a single Active Procedure at any time. When you do, the system runs the Procedure over all patients in the current study, not just those patients for whom data has been added or modified (as in batch validation).

The output file displays the number of discrepancies created during this run, the number that remain current and the number that have become obsolete since the last run. The number remaining current reflects the total number of open discrepancies in the study that have been generated by this Procedure.

View discrepancies created by the Procedure from the Special menu (Show Prod Discrep), or from the Definition menu, select Data Validation, then Discrepancy Database.

You can execute a single Procedure from two locations in Oracle Clinical: the Procedures window and the Execute Single Procedure PSUB window. To execute a Procedure against a Test database, you must execute it from the Procedures window.

16.10.1.1 Execute a Single Procedure from the PSUB Window

From the Conduct menu, select Data Validation, then Execute Single Procedure, and do the following:

  1. From the list of values, choose the Procedure you want to run.

  2. From the list of values, choose the version sequence number of the Procedure you want to run.

  3. From the list of values, choose Y to run the Procedure in Debug mode, which lets you view the individual values as they are validated in the .out file. The default value is N.

  4. Click Submit Job.

To check on the job's progress and see the .out and .log files, click Job Status.

16.10.1.2 Execute a Single Procedure from the Procedures Window

From the Definition menu, select Validation Procedures or Derivation Procedures, then Procedures (or Prov Procedures or Procedures w Edit; the menu path you see depends on your privileges) and do the following:

  1. In the Procedure Definitions window, select the Procedure you want to execute. You can also execute a Procedure from any of the child windows.

  2. From the Special menu, choose Execute in Prod (or Execute in Test to run against a test data database). A dialog box appears.

  3. If you want to run the Procedure in Debug mode, which lets you view the individual values as they are validated in the .out file, choose Yes. A message appears, giving you the batch job ID number.

To check on the job's progress and see the .out and .log files, open the PSUB form (from the Conduct menu, select Data Validation, then Execute Single Procedure) and click Job Status.

16.10.2 Executing Batch Validation

You can schedule batch validation to run at regular Intervals (such as nightly) or once at a particular time, or you can manually invoke a batch validation at any time. By selecting Data Validation from the Conduct menu, and then Batch Validation Session, you open a PSUB window. You do not need to enter information in this window. All Procedures in the current study are automatically run every time you run a batch validation.

For further information on batch validation, see Chapter 4, "Using the Discrepancy Database" in Oracle Clinical Conducting a Study. For information on submitting batch validation and viewing its output file, see Chapter 3, "Submitting batch jobs and reports" in Oracle Clinical Getting Started.

16.10.2.1 Facts About Procedure Execution During Batch Validation

  • During batch validation, Oracle Clinical runs all Derivation Procedures before any Validation Procedures.

  • Batch validation always executes incrementally; that is, it processes only data that has changed since the last batch validation run.

  • Oracle Clinical detects changes made in the definition of the length of a DCM Question and automatically regenerates any Active Procedure that references that Question before executing the Procedure.

    That is, the procedure is regenerated if and when it needs to be executed in a subsequent batch validation run because data has been modified for one or more patients in fields referenced by the Procedure. The Procedure is then run on patients with modified data.

  • Whenever a derivation calculation is re-executed, Oracle Clinical compares the resulting value with any existing value for the response. If the new value differs, Oracle Clinical creates a new version of the response and records DATA CHANGE or DERIVATION CHANGE, depending on whether the recalculation resulted from a change to data or to the derivation calculation.

  • A study-specific parameter (the study's Second Pass Required option) controls if data that has only completed first-pass entry participates in derivation.

16.10.2.2 Batch Validating TMS Derivation Procedures

Oracle Clinical executes derivation procedures before TMS processing in batch validation runs. This feature enables you to perform the following processes on TMS derivation procedures:

  • You can derive a value from TMS into an Oracle Clinical derived Question in the first TMS portion of batch validation, and derive related TMS values for the derived Oracle Clinical Question during the second TMS portion of the same batch validation.

  • You can use an Oracle Clinical derivation procedure to derive a value in Oracle Clinical, and send that value to TMS for processing during the second TMS portion of the same batch validation.

These are examples of how this feature can be useful:

  • you would like to derive values from two different dictionaries for a single verbatim term.

  • You would like to substitute the original collected term with another term, leaving the original response intact; for example, in a historic study or a study conducted by a company you have acquired.

Note that you cannot have more than two levels of derivation for TMS Questions. The TMS code only handles the following scenario:

  • TMS parent Question

  • Derived Question (This Question is in turn used as a parent Question.)

  • Derived Question

You cannot create a fourth derived Question.

See the Oracle Thesaurus Management System User's Guide for more information.

16.10.2.3 Procedures and Frozen-status Patients

Oracle Clinical runs Derivation Procedures even for patients whose status is Frozen; in these cases, recalculation can take place when:

  • an existing Procedure is changed

  • a new Procedure is created

  • an existing, unchanged Procedure is explicitly executed over all patients, and calculation is based on external data that has changed

  • a patient was frozen before having new or modified data processed by batch validation

Derivation Procedures containing validation expressions may produce discrepancies for patients with a status of Frozen.

16.11 V3.1-Style and Pre-V3.1-Style Procedures

Oracle Clinical V3.1 introduced a new style of Procedure, with functional enhancements. V3.1-style Procedures consist of static packages in the database rather than anonymous PL/SQL blocks, eliminating the need to parse a Procedure each time it is executed, for greater efficiency and speed.

You can continue to run existing pre-V3.1-style Procedures in V3.2 and later releases with their current functionality, or you can explicitly convert them to the V3.1 style for enhanced performance. After converting a Procedure to the V3.1 style, you can modify it to take advantage of the additional functionality. You can create new Procedures in either the newer V3.1 style (the default) or the old (pre-V3.1) style.

This section includes the following topics:

16.11.1 V3.1-Style Procedure Enhancements

  • Increased speed of execution

  • Possible to add custom code in more locations in the code without editing generated PL/SQL

  • Separate Report?, Test Not Null?, Continue If Discrepancy? boxes and other settings for each variable as it is associated with each detail, making it possible to include more details in a single Procedure

  • Ability to prevent processing Question responses with current univariate discrepancies, and a multipick list of values to select which univariate discrepancies prevent processing in each detail

  • Option to choose which detail to process next, if Oracle Clinical finds a discrepancy and the Continue If Discrepancy? box is selected

  • Embedded data values in discrepancy messages to improve context sensitivity

  • Additional event order processing choices based on:

    • the leading fields DCM Date and Time, plus Visit and Subevent Numbers

    • acceptance of manually coded processing order based on trailing fields, usually Qualifying_Value and/or Repeat_SN

  • Single repeat only option for repeating Question Groups

  • Capacity to correlate Questions with the previous or next event, as well as the actual event

  • A new standard variable, question$exc_val, which provides the EXCEPTION_VALUE_TEXT field value for all Question Group Questions

  • An extended multipick list of values for variables, including Question Group Cursor key fields, Patient Position Cursor fields, internal Procedure variables, and DVG information, customized according to the field from which it is invoked

  • Optional re-execution of Procedures for patient records affected by lab range and lab range subset changes made since the last batch validation

16.11.2 Converting to the V3.1 Style

When converting a pre-V3.1-style Procedure to the V3.1 style, it is helpful to understand what Oracle Clinical does internally to accomplish the conversion:

  1. Populates the data structure, Variable Settings, for each detail, as appropriate.

  2. Generates the Procedure in V3.1 style, as a packaged object. This step occurs only if the Procedure being converted has been successfully generated; if not, you are prompted to generate the Procedure after conversion. Oracle Clinical will not generate Global Library Procedures.

  3. Switches the Ver 3.1 Style? box to selected if the conversion was successful.

    Note:

    Oracle Clinical saves the pre-V3.1 version of the Procedure, and reverts to it if problems are encountered in conversion.

Oracle Clinical preserves all current discrepancies associated with a Procedure when you convert the Procedure.

To convert a single existing pre-V3.1-style Procedure to the V3.1 style:

  1. Before beginning the automatic Procedure conversion, if the following three internal variable names appear in existing Pre-Details or Post-Details custom code, manually change them from the pre-V3.1-style to their V3.1-style names.

    Table 16-1 Style Variables Comparison

    Pre-V3.1-style Variable V3.1-style Variable Name

    patients_rec

    rxcpdstd.patients_rec

    test_or_prod

    rxcpdstd.v_mode

    batch_start_ts

    rxcpdstd.v_current_batch_ts


  2. Start the automatic Procedure conversion process by choosing Convert to 3.1 Style from the Special menu in the Procedure Definitions window.

    Note:

    You can convert only Procedures with a status of Active or Provisional (not Retired).
  3. If the original Procedure had Pre- or Post-Details custom code (Pre-Code or Post-Code), and that code accessed database tables (such as Patient_Positions, Responses, or Received_DCMs), you must edit the code to explicitly account for Production and Test environments. (In pre-V3.1-style Procedures, Oracle Clinical pointed to test or production tables through synonyms, which is no longer possible in the Packaged Object Model.)

    Note:

    Convert Procedures in bulk with the GEN_PROCS utility. See Chapter 8, "Utilities" in the Administrator's Guide.

16.11.2.1 Conversion Example

Original, pre-V3.1-style Procedure Pre-Details custom code:

...
SELECT DATA_COMMENT_TEXT
INTO COMMENT_VAR
FROM RESPONSES
WHERE RESPONSE_ID = A.QUESTION1$RESP_ID
AND RESPONSE_TS = A.QUESTION1$ENT_TS;
...

The code after conversion by Oracle Clinical (the same, in this case; if the code had included the variables PATIENTS_REC., TEST_OR_PROD, or BATCH_START_TS, they would have been renamed RXCPDSTD.PATIENTS_REC., RXCPDSTD.V_MODE, or RXCPDSTD.V_CURRENT_BATCH_TS, respectively):

...
SELECT DATA_COMMENT_TEXT
INTO COMMENT_VAR
FROM RESPONSES
WHERE RESPONSE_ID = A.QUESTION1$RESP_ID
AND RESPONSE_TS = A.QUESTION1$ENT_TS;
...

The code after you have made the required edits to account for test and production tables' references:

IF RXCPDSTD.V_MODE = 'P' 
THEN /* PRODUCTION RUN*/
...
SELECT DATA_COMMENT_TEXT
INTO COMMENT_VAR
FROM RESPONSES
WHERE RESPONSE_ID = A.QUESTION1$RESP_ID
AND RESPONSE_TS = A.QUESTION1$ENT_TS;
...
ELSE /* TEST RUN*/
...
SELECT DATA_COMMENT_TEXT
INTO COMMENT_VAR
FROM RESPONSEST
WHERE RESPONSE_ID = A.QUESTION1$RESP_ID
AND RESPONSE_TS = A.QUESTION1$ENT_TS;
...
END IF;

Note:

For a test run, add a "T" to the name of the table to indicate the test table with the same type of data as the production table of the same name. For example, ResponsesT, not Responses.

16.11.3 Creating a New Pre-V3.1-Style Procedure

The default style for new Procedures from 3.1 on is the 3.1 style. However, you can create a new, pre-V3.1-style Procedure by deselecting the Ver 3.1 Enabled? box for the Procedure in the Procedure Definitions window.

You can do this only when you first create the Procedure definition, before saving it.

16.12 Maintaining Patient Statuses

You must create a Validation Procedure to populate the Patient Statuses table for each study using two packaged procedures provided with Oracle Clinical. Data in the Patient Statuses table is used by the Oracle Clinical Enrollment form and in several reports, including the Patient Enrollment Report.

To populate the table initially, use the RXC_PAT_STAT package. To ensure that the information in the Patient Statuses table reflects any change in status entered in a CRF, use PAT_SYNCH, a function in RXC_PAT_STAT; see "Patient Synchronization".

This section includes the following topics:

16.12.1 Populating the Patient Statuses Table

As patients progress through a study, they achieve various statuses, such as ENROLLED and TERMINATED. The status ENROLLED is used by the Enrollment form and reports to define when a patient is considered to be enrolled in a study. All studies must use the status of ENROLLED, and can use as many or as few other statuses as are relevant for tracking patients in that study. Other statuses are user-defined in the installation reference codelist PATIENT STATUS CODE.

Note:

The ENROLLED status has no effect on the unenrolled patient alert, lab criteria assignment, batch loading enrollment data, or access to studies in Oracle Clinical Remote Data Capture.

Each patient status has associated with it a Status Date—the date the patient achieved the status. So, the Status Date associated with a patient status of ENROLLED is the Enrollment Date; the Status Date associated with the patient status of TERMINATED is the Termination Date. A patient can therefore have several statuses at the same time, one for each status achieved so far:

Patient Status Status Date
100 ENROLLED 01092003
100 TERMINATED 12092003
101 ENROLLED 03092003
102 ENROLLED 04092003
102 TERMINATED 10092003
103 ENROLLED 07092003
104 ENROLLED 19092003

You must create a special Validation Procedure in each study to populate the Oracle Clinical Patient Statuses table. In the Pre-Details custom code within the Procedure, use a package, RXC_PAT_STAT provided with Oracle Clinical to insert and delete status codes for each patient. The package includes two functions:

  • The CLEAR_STAT function takes as input a patient_position_id, and deletes all existing patient status records for a particular patient: Procedure CLEAR_STAT(PATIENT_ID IN NUMBER)

  • The SET_STAT function takes as input several keys for a patient, as well as a Status (code), a Status Date, and a Comment. These status fields are inserted into the patient statuses table as follows:

Procedure set_stat(clinical_study_id in number,
site_id in number,
patient_id in number, 
status in varchar2,
status_date in date,
status_comment varchar2)

You must ensure that the CLEAR_STAT function is executed only once per patient, and that a given status is inserted only once. You can use any of the following techniques:

  • Access DCMs that can only have a single occurrence, such as Demography and Termination. This is the approach used in the example below.

  • Use only aggregate Procedure Question Groups with the MAX function. Each one returns a single row, so the Pre-Code executes only once. However, you can not access the DCM_Date in an aggregate Procedure Question Group.

  • Define variables to set flags indicating that the CLEAR_STAT Procedure has been called for the patient, to ensure it is called only once. Write the status calculation logic so that a given status can be recorded only once.

16.12.1.1 Example

Following is an example of a Procedure to track ENROLLED and TERMINATED statuses along with Enrollment Date and Termination Date, referencing DCMs with a single occurrence. The Enrollment Date is the DCM_DATE of the Demog DCM, and the Termination Date is the Question TERM_DATE asked on the Term DCM. Create the Validation Procedure for synchronizing the statuses and dates between the responses and the Patient Statuses table in the following manner:

16.12.1.1.1 Procedures

Define the Validation Procedure itself (see "Naming and Describing a Procedure".

16.12.1.1.2 Procedure Question Groups

Select two Questions Groups, one from each DCM that contains the Question that affects the patient status: DEMOG and TERM. Select Create Place Holder? for each group. Do not correlate the groups. (See "Defining Procedure Question Groups".

16.12.1.1.3 Procedure Questions

In the example code below, the alias of the DEMOG Procedure Question Group is D. Select DCM_DATE as its Procedure Question. The alias of the TERM Procedure Question Group is T. Select TERM_DATE as its Procedure Question. (See "Defining Procedure Questions".

16.12.1.1.4 Procedure Details

Define one Procedure detail with a FALSE Boolean expression to prevent the Procedure from creating discrepancies (for example, 2<1). Leave the other fields in the window alone; no other field is relevant to the purpose of this Procedure.

16.12.1.1.5 Variable Settings

Procedure definition rules require that you mark at least one variable of this detail for Report and for Discrepancy Test. Because the expression is false, the Procedure never creates a discrepancy and it does not matter which variable you set.

16.12.1.1.6 Custom Code

In the Custom Code window, choose Pre-Detail and enter the following:

         /* clear existing patient statuses */
         /* current patient key is RXCPDSTD.patients_rec.patient_position_id */
         rxc_pat_stat.clear_stat(RXCPDSTD.patients_rec.patient_position_id);

         /* Set enrollment date into patient_status */
         if D$has_data = 'Y' then
            rxc_pat_stat.set_stat(i_clinical_study_id         /* clinical_study_id */,
               RXCPDSTD.patients_rec.site_id      /* site_id */,
               RXCPDSTD.patients_rec.patient_position_id           /* patient_id */,
               'ENROLLED'       /* status */,
               rxc_date.convert(D.DCM_DATE)        /* date must be converted to native Oracle date format for storage */,
               " "      /* status_comment */);
         end if;
         /* Set termination date into patient_status */
         if T$has_data='Y' then
            rxc_pat_stat.set_stat(i_clinical_study_id         /* clinical_study_id */,
               RXCPDSTD.patients_rec.site_id      /* site_id */,
               RXCPDSTD.patients_rec.patient_position_id   /* patient_id */,
               'TERMINATED'     /* status */,
               rxc_date.convert(T.TERM_DATE)      /* date - must be converted to native Oracle date format for storage */,
               " "      /* status_comment */);
         end if;

This logic guarantees that the Termination and Enrollment Dates for each patient in the study will be obtained if they exist. The algorithm is:

loop over each patient{

get the termination date (if any of these CRFs exist)

get the enrollment date (if any of these CRFs exist)

delete all status information for the current patient

if a termination form is present, store the termination status with the
termination date

if an enrollment form is present, store the enrollment status with the
enrollment date

}

Each Procedure Question Group has Create Placeholder? selected, so that if a patient has no Termination or Enrollment data, the Pre-Code still executes and the CLEAR_STAT function removes any previous statuses. If an Enrollment record is removed from the system because it was mistakenly logged in, the Enrollment status code is cleared by CLEAR_STAT and not reinserted by SET_STAT.

The test on alias$has_data is present to force the insertion of a status only in the case where a relevant Question contains response data.

16.12.2 Patient Synchronization

The Patient Positions table includes information that may be collected as part of clinical trials data. To ensure that the information in the Patient Positions table reflects updates to a patient's data entered in Data Entry, you can use the packaged function RXC_PAT_STAT.PAT_SYNCH in any Derivation or Validation Procedure.

Since Validation and Derivation Procedures are automatically executed during batch validation whenever a patient's data changes or when a Patient Enrollment Record is modified, the PAT_SYNCH function is also re-executed after any event that might change the consistency between the patient enrollment data and the CRF data. If you access any patient information in other Derivation or Validation Procedures (including through access to lab ranges) you should call the PAT_SYNCH function from a Derivation Procedure executed before any Procedure that uses the information.

The function compares the current values of the Patient Enrollment information with the values passed in and returns results as follows:

  • If the values are identical, the function changes nothing and returns SUCCESS.

  • If any value in the Patient Positions table is null and the corresponding value passed in is non-null, the function updates the enrollment values in the Patient Positions table to the passed values, sets the Modification TS to the Batch Start TS of the batch validation run, and returns SUCCESS.

  • If any value in the Patient Positions table for a given patient is non-null and differs from the corresponding value passed in, and the value passed in is non-null, then the function returns FAILURE. You should set the Report? option for the variable to create a discrepancy.

16.12.2.1 Procedure Definition

Incorporate the PAT_SYNCH function into your Procedure in the same way as the other two packaged functions (see "Example").

  • Reference the Question Groups and Questions that collect patient status data. The names of the Questions (and therefore Procedure variables) need not be the same as the arguments to the function or the fields in the Patient Positions table (for instance BIRTH_DATE and DOB).

  • Call the function from the Pre-details custom code of the Procedure.

  • If necessary, the collected data values should be converted to the data type (for instance, DATE) of the same values in the Patient Positions table.

  • Declare user variables to receive the return status and the returned values from the Patient Positions table, and also to act as placeholders in the Procedure call for any input arguments you do not want to update.

  • Mark as Report? only those user variables you want to report as part of the discrepancy.

  • The input arguments can include both Procedure variables (for instance D.INITIALS) and user variables (for instance TEMP_SEX).

  • Do not select Continue If Discrepancy? in the Details window. See "Type Coercion and Comparison of Derived Values".

Arguments passed to PAT_SYNCH as nulls are ignored. This means you need not synchronize a particular patient's data if it is not collected. It also means that PAT_SYNCH can be called from several Procedures as long as each Procedure passes in different variables.

For instance, one Procedure could update SEX, BIRTH_DATE, and INITIALS, while another updates FIRST_SCREENING_DATE, ENROLLMENT_DATE, and TERMINATION_DATE (perhaps the same Procedure that records patient status information using the RXC_PAT_STAT package).

The return status of the Procedure can be tested in Procedure Details to enable reports on conflicts. Optionally, a new validation failure severity and/or Procedure type could be used to distinguish this new type of validation failure. See "Alternative Approaches to Error Reporting".

Table 16-2 lists the variables you must define in order to pass them as arguments to the functional call, with D_ arguments as the input data values and the P_ arguments as the return patient enrollment values.

Table 16-2 List of Arguments for Procedure Definition

Argument Name In/Out Data Type Comment

test_or_prod

in

varchar2

Indicates whether the Procedure was called in test (T) or production (P) mode

batch_start_ts

in

date

Date/time of beginning of batch run

d_patient_position_id

in

number

Internal ID of Patient

d_reported_first_name

in

varchar2

 

d_reported_last_name

in

varchar2

 

d_reported_sex

in

varchar2

Value must be M or F

d_reported_patient_reference

in

varchar2

 

d_reported_initials

in

varchar2

 

d_reported_birth_date

in

date

 

d_reported_date_last_pregnancy

in

date

 

d_first_screening_date

in

date

 

d_patient_enrollment_date

in

date

 

d_termination_date

in

date

 

d_early_termination_flag

in

varchar2

Value must be Y or N

p_reported_first_name

out

varchar2

 

p_reported_last_name

out

varchar2

 

p_reported_sex

out

varchar2

 

p_reported_patient_reference

out

varchar2

 

p_reported_initials

out

varchar2

 

p_reported_birth_date

out

date

 

p_reported_date_last_pregnancy

out

date

 

p_first_screening_date

out

date

 

p_patient_enrollment_date

out

date

 

p_termination_date

out

date

 

p_early_termination_flag

out

varchar2

 

16.12.3 Example

This Procedure handles synchronization of SEX, BIRTH_DATE, INITIALS, and TERMINATION_DATE.

Validation Procedure: PATIENT_DATA_SYNCH

Procedure Question Group: DEMOGRAPHICS, Alias: D

Procedure variable: SEX
Procedure variable: DOB
Procedure variable: INITIALS

Procedure Question Group: TERMINATION, Alias: T, No correlation, Create Placeholder:

Procedure variable: TERMINATION_DATE

This structure results in a single execution of the Pre-details custom code for each patient. The execution occurs even if the termination data has not been received.

User Variable Name Report? Data Type Length
d_date_last_pregnancy n date  
d_early_termination_flag n varchar2 1
d_first_name n varchar2 15
d_first_screening_date n date  
d_last_name n varchar2 20
d_patient_enrollment_date n date  
d_patient_reference n varchar2 25
enr_birth_date {1} y date  
enr_date_last_pregnancy n date  
enr_early_termination_flag n varchar2 1
enr_first_name n varchar2 15
enr_first_screening_date n date  
enr_initials y varchar2 4
enr_last_name n varchar220  
enr_patient_enrollment_date n date  
enr_patient_reference n varchar2 25
enr_sex y varchar2 1
enr_termination_date y date  
pat_synch_return n varchar2 7
temp_dob n date  
temp_sex n varchar2 1
temp_term_date n date  

16.12.4 Pre-Details Custom Code

{2}
if (D.SEX = 'MALE') then TEMP_SEX = 'M';
elsif (D.SEX = 'FEMALE') then TEMP_SEX := 'F';
end if;
{3}
TEMP_TERM_DATE := to_date(T.TERMINATION_DATE, 'YYYYMMDD');
TEMP_DOB := to_date(D.DOB, 'YYYYMMDD);
PAT_SYNCH_RETURN := RXC_PAT_STAT.PAT_SYNCH(
RXCPDSTD.V_MODE,
RXCPDSTD.V_CURRENT_BATCH_TS,
RXCPDSTD.patients_rec.PATIENT_POSITION_ID,
D_FIRST_NAME,
D_LAST_NAME,
{4}       TEMP_SEX,
D_PATIENT_REFERENCE,
{5}       D.INITIALS,
TEMP_DOB,
D_DATE_LAST_PREGNANCY,
D_FIRST_SCREENING_DATE,
D_PATIENT_ENROLLMENT_DATE,
TEMP_TERM_DATE,
D_EARLY_TERMINATION_FLAG,
ENR_FIRST_NAME,
ENR_LAST_NAME,
ENR_SEX,
ENR_PATIENT_REFERENCE,
ENR_INITIALS,
ENR_BIRTH_DATE,
ENR_DATE_LAST_PREGNANCY,
ENR_FIRST_SCREENING_DATE,
ENR_PATIENT_ENROLLMENT_DATE,
ENR_TERMINATION_DATE,
ENR_EARLY_TERMINATION_FLAG);

In lines 9, 10, and 11 the internal variable names are: TEST_OR_PROD, BATCH_START_TS, and PATIENTS_REC.Site_ID.

16.12.5 Alternative Approaches to Error Reporting

You can choose to create one or potentially multiple failures using one of these approaches:

16.12.5.1 Single Failure

A single Validation Detail can test the return status variable and issue a single failure covering all inconsistencies. For instance:

Detail 1:

Test: PAT_SYNCH_RETURN = 'FAILURE'

Message: Patient Enrollment information differs from CRF data.

Since the error is a multivariate error, all the potentially differing values are associated with the resulting discrepancy.

16.12.5.2 Multiple Failure

Multiple Details can test for each potential mismatch and report them individually. For instance, assuming that input values come from the Procedure Question Group with alias D (Demography):

Detail 1:

Test: PAT_SYNCH_RETURN = 'FAILURE' AND D.SEX != ENR_SEX

Message: Patient's Sex differs between Patient Enrollment and the CRF data.

Detail 2:

Test: PAT_SYNCH_RETURN = 'FAILURE' AND D.BIRTH_DATE != ENR_BIRTH_DATE

Message: Patient's Birth Date differs between Patient Enrollment and the CRF data.

16.12.6 Type Coercion and Comparison of Derived Values

Be sure to convert data types before passing them to the PAT_SYNCH function.

If you have not selected Continue If Discrepancy? and an incorrect value is derived, whether a length or a data type error, the Procedure's execution stops. All derivations and validations performed by that Procedure are rolled back to reflect the last correct values. Errors are written to the log file (the batch validation log file or the single procedure execution log file). However, the next time the Procedure is run, it is run for all patients.

Calculation expressions specified by users can be one of three data types: VARCHAR2, NUMBER, and DATE. Derived Questions can be one of four types: CHAR, NUMBER, DATE, and TIME. TIME Questions have a length of 4 or 6, and DATE Questions have a length of 4, 6, or 8 and are stored in YYYYMMDD format. CHAR and NUMBER Questions also have predefined lengths that must be enforced.

The following table shows conversions of Oracle Clinical types to Oracle native types. These CHAR conversions are automatically performed by the Procedure in the Calculation phase. Note that decimal precision on numbers is not enforced nor coerced.

Oracle Clinical Derived Question Type Oracle Native Type of Derived Expression
varchar2 number date
char Length is checked Error 20104 Error 20104
number Error 20104 Length is Error 20104 checked Error 20104
date Date is checked in YYYYMMDD format; partial dates allowed Error 20104 Date is converted to YYYYMMDD format before being stored
time Time is checked in hhmm or hhmmss format, depending on the length of the varchar2 passed in Error 20104 Error 20104