Announcement

Collapse
No announcement yet.

EDC - Subsetting site reports

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • EDC - Subsetting site reports

    When working with an EDC study, a site user’s reports should only display the data that they have access to. To accomplish this, the data used in the report generation must be filtered for the current user’s assigned investigators.

    The following program provides 2 ways of doing this. It creates a work data set and a macro variable populated with all of the users' assigned investigators. The data set will contain 1 record per investigator. The macro variable contains a list of quoted values that can be used with an IN operator.

    The easiest way to implement this in an EDC study is to %include this program into the onLoad(); method of the NON-CRF screen used to expose the reports to the user. This way, it is processed once when the user opens the screen. Your program code can then incorporate the use of this either by way of a MERGE, SQL join, or a WHERE Statement. For this code to work correctly, it must be referenced with a %include statement.

    Objects created by program
    Dataset: WORK.USERINVESTIGATORS
    Variables: INVESTIGATORNUMBER

    Macro Variable: &USERINVESTIGATORS
    Example: "003" "002" "001"


    Example of onLoad();
    Code:
    /** onLoad Method **/
    
    %include objfile;
    
    _onLoad: method _self_:u:object;
    link createobj;
    ************************;
    ** Add user code here **;
    ************************;
    
    %include 'L:\software\SUPPORT\dm\CPDM321v3\Macros\sclGetUserInvestigators.sas';
    
    
    endmethod;
    Example Report Using Macro Variable
    Following is an example of a simple program to list the patient enrollment records for a site using the macro variable USERINVESTIGATORS to subset the data as it is being read in from the data source.

    Code:
    ** Create list of patients from enrollment table **;
    data report;
        set pviews.enrollment (where=(investigatorNumber in(&userinvestigators)));
    run;
    
    title 'Listing of Patients';
    proc print data=work.report;
    run;
    Example Report Using Dataset
    Following is an example of a simple program to list the patient enrollment records for a site using the dataset USERINVESTIGATORS to join to the enrollment data in order to get only the records we want. This could also be done with a SAS Merge.

    Code:
    proc sql;
        create table work.report as 
        select a.* 
        from pviews.enrollment as a
        inner join work.userinvestigators as b
        on a.investigatornumber = b.investigatornumber;
    quit;
    
    
    title 'Listing of Patients';
    proc print data=work.report;
    run;

    sclGetUserInvestigators Program Code

    Following is the sclGetUserInvestigators code. It is also attached to this post here… or by browsing to the bottom of this post.
    Code:
    /****************************************************************************** 
    Program:     sclGetUserInvestigators
    By:         G. Wagner
    
    This program is intended to be used in a data entry screen to get the
    current users' investigators for an EDC study. It must be used via a
    %include statement as SUBMIT blocks are not allowed in macros. 
    
    Creates 
    TABLE:     WORK.userInvestigators
    Contains one column called investigatorNumber.
    
    MACROVARIABLE: userInvestigators
    Contains a quoted list of investigatorNumbers that can be used
    in a where clause with an in statement. 
            
    *******************************************************************************/                
    
    ** Get identifier for record information object **;
    dcl object f info;
    f=_self_.frameid;
    f._getNumVar('recordInfo',info);
    
    
    ** Declare local list vairables and get references to the protocol and user information in the environment list **;
    dcl list CurrentProtocolInfo;
    dcl list CurrentUserInfo;
    CurrentProtocolInfo=getniteml(getniteml(envlist(),'CURPROTO'),'PROTOINFO');
    CurrentUserInfo=getniteml(getniteml(envlist(),'GLOBALINFO'),'CURRENTUSERINFORMATION');
    
    ** Get the current users key into a local variable from **;
    dcl num userskey=getnitemn(CurrentUserInfo,'RECORDID');
    
    ** Get the global system data set password into a local variable **;
    dcl char gpw = getnitemc(getniteml(envlist(),'SYSTEMINFO'),'GLOBALPW');
    
    
    ** Default macro variable userInvestigators to missing **;
    call symput('userInvestigators','');
    
    
    /******************************************************************************
    Get a list of the users' investigators from cpglobal._userInvestigators **
    Create a work data set and a macro variable with a list of the
    investigators.
    *******************************************************************************/
    submit continue sql;
        create table userInvestigators as
        select a.investigatorNumber from pviews.Investigators a
        inner join cpglobal._userInvestigators(read=&gpw) b
        on a.datestamp=b._investigatorsKey
        where b._userskey = &userskey;
        
        select quote(compress(investigatorNumber)) into :userInvestigators
        separated by ' '
        from work.userInvestigators;
    endsubmit;
    Attached Files
    Last edited by Ronni Rubenstein; 11-17-2008, 09:28 AM.
Working...
X