CohortExplorer
view release on metacpan or search on metacpan
lib/CohortExplorer/Application.pm view on Meta::CPAN
if ( catch my $e ) {
throw_app_init_exception( error => $e );
}
my $logger = Log::Log4perl->get_logger;
# Check command history file exists and is readable and writable
my $command_history_file =
File::Spec->catfile( File::HomeDir->my_home, ".CohortExplorer_History" );
if ( !-r $command_history_file || !-w $command_history_file ) {
throw_app_init_exception( error =>
"'$command_history_file' must exist with RW enabled (i.e. chmod 766) for CohortExplorer"
);
}
# Prompt for password if not provided at command line
if ( !$opts->{password} ) {
$app->render("Enter password: ");
ReadMode 'noecho';
$opts->{password} = ReadLine(300);
ReadMode 'normal';
$app->render("\n");
lib/CohortExplorer/Command/Query.pm view on Meta::CPAN
# Untaint and set command history file
$COMMAND_HISTORY_FILE = $1
if File::Spec->catfile( File::HomeDir->my_home, ".CohortExplorer_History" ) =~ /^(.+)$/;
my $fh = FileHandle->new(">> $COMMAND_HISTORY_FILE");
# Throw exception if command history file does not exist or
# is not readable and writable
if ( !$fh ) {
throw_cmd_run_exception( error =>
"'$COMMAND_HISTORY_FILE' must exist with RW enabled (i.e. chmod 766) for CohortExplorer"
);
}
$fh->close;
# Read command history file
eval {
$COMMAND_HISTORY_CONFIG =
Config::General->new(
-ConfigFile => $COMMAND_HISTORY_FILE,
-MergeDuplicateOptions => "false",
lib/CohortExplorer/Command/Query.pm view on Meta::CPAN
sub validate {
my ( $self, $opts, @args ) = @_;
my ( $ds, $csv, $verbose ) = @{ $self->cache->get('cache') }{qw/datasource csv verbose/};
print STDERR "\nValidating command options/arguments ...\n\n" if $verbose;
##----- VALIDATE ARG LENGTH, EXPORT AND OUT OPTIONS -----##
if ( !$opts->{out} || !-d $opts->{out} || !-w $opts->{out} ) {
throw_cmd_validation_exception( error =>
"Option 'out' is required. The directory specified in 'out' option must exist with RWX enabled (i.e. chmod 777) for CohortExplorer"
);
}
if ( $opts->{export} && $opts->{export_all} ) {
throw_cmd_validation_exception( error =>
'Mutually exclusive options (export and export-all) specified together' );
}
if ( @args == 0 || @args > $arg_max ) {
throw_cmd_validation_exception(
lib/CohortExplorer/Command/Query.pm view on Meta::CPAN
$dir = File::Spec->catdir( $1, 'CohortExplorer-' . time . $$ );
}
# Create dir to export data
eval { mkdir $dir };
if ( catch my $e ) {
warn $e . "\n";
$dir = $1;
}
else {
eval { chmod 0777, $dir };
if ( catch my $e ) {
warn $e . "\n";
$dir = $1;
}
}
$self->export( $opts, $rs, $dir, @args );
return {
headingText => 'summary statistics',
rows => $self->summary_stats( $opts, $rs, $dir )
lib/CohortExplorer/Command/Query/Compare.pm view on Meta::CPAN
Other variables in arguments/cond (option) must be referenced as <table>.<variable> or <visit>.<table>.<variable>
where visit can be vAny, vLast, v1, v2, v3 ... vMax. Here vMax is the maximum visit number for which data is
available.
Conditions can be imposed using the operators: =, !=, >, <, >=, <=, between, not_between, like, not_like, ilike, in,
not_in, regexp and not_regexp. The keyword undef can be used to specify null.
When condition is imposed on variable with no prefix such as vAny, vLast, v1, v2 and v3 the command assumes the
condition applies to all visits of the variable.
The directory specified in 'out' option must have RWX enabled (i.e. chmod 777) for CohortExplorer.
EXAMPLES
compare --out=/home/user/exports --stats --save-command --cond=v1.CER.Score='>, 20' v1.SC.Date
compare --out=/home/user/exports --export=CER --cond=SD.Sex='=, Male' v1.CER.Score v3.DIS.Status
compare --out=/home/user/exports --export=CER --cond=v2.CER.Score'!=, undef' vLast.DIS.Status
compare -o/home/user/exports -Ssa -c vLast.CER.Score='in, 25, 30, 40' DIS.Status
lib/CohortExplorer/Command/Query/Search.pm view on Meta::CPAN
The variables entity_id and visit (if applicable) must not be provided as arguments as they are already part of
the query-set. However, the user can impose conditions on both variables.
Other variables in arguments/cond (option) must be referenced as <table>.<variable>.
The conditions can be imposed using the operators such as =, !=, >, <, >=, <=, between, not_between, like,
not_like, ilike, in, not_in, regexp and not_regexp.
The keyword undef can be used to search for null values.
The directory specified in 'out' option must have RWX enabled (i.e. chmod 777) for CohortExplorer.
EXAMPLES
search --out=/home/user/exports --stats --save-command --cond=DS.Status='=, CTL, MCI' GDS.Score
search --out=/home/user/exports --stats --save-command --cond=CER.Score='<=, 30' GDS.Score
search --out=/home/user/exports --export-all --cond=SD.Sex='=, Male' CER.Score DIS.Status
search -o/home/user/exports -eDS -eSD -c entity_id='like, DCR%' DIS.Status
( run in 0.324 second using v1.01-cache-2.11-cpan-8d75d55dd25 )