The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

CohortExplorer::Command::Query::Compare - CohortExplorer class to compare entities across visits

SYNOPSIS

compare [OPTIONS] [VARIABLE]

c [OPTIONS] [VARIABLE]

DESCRIPTION

The compare command enables the user to compare entities across visits. The user can also impose conditions on variables. Moreover, the command also enables the user to view summary statistics and export data in csv format. The command is only available to longitudinal datasources with data on at least 2 visits.

This class is inherited from CohortExplorer::Command::Query and overrides the following methods:

usage_text()

This method returns the usage information for the command.

get_valid_variables()

This method returns a ref to the list containing all variables (including visit variables) for validating arguments and condition option(s).

create_query_params( $opts, @args )

This method returns a hash ref with keys, static, dynamic or both depending on the variables supplied as arguments and conditions. The value of each key is a hash containing SQL parameters such as -columns, -from, -where, -group_by and -having.

process_result( $opts, $rs, $dir, @args )

This method writes result set into a csv file and returns a ref to the list containing entity_ids.

process_table( $table, $ts, $dir, $rs_entity )

This method writes the table data into a csv file. The data includes entity_id of all entities present in the result set followed by values of all visit variables.

create_dataset( $rs )

This method returns a hash ref with entity_id as keys and variable name-value pairs as values. The statistics in this command are calculated with respect to entity_id and the number of observations for each variable is the number of times (or visits) each variable was recorded for each entity during the course of the study.

OPTIONS

-o DIR, --out=DIR

Provide directory to export data

-e TABLE, --export=TABLE

Export table by name

-a, --export-all

Export all tables

-s, --save--command

Save command

-S, --stats

Show summary statistics

-c COND, --cond=COND

Impose conditions 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.

NOTES

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 and conditions must be referenced as table.variable or visit.table.variable where visit = vAny, vLast, v1, v2, v3 ... vMax. Here vMax is the maximum visit number for which data is available. When a condition is imposed on a 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 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 

 compare -o/home/user/exports -eCER -eSD -c vLast.CER.Score='between, 25, 30' DIS.Status

DIAGNOSTICS

This class throws throw_cmd_run_exception exception imported from CLI::Framework::Exceptions if Text::CSV_XS fails to construct a csv string from the list containing variable values.

SEE ALSO

CohortExplorer

CohortExplorer::Datasource

CohortExplorer::Command::Describe

CohortExplorer::Command::Find

CohortExplorer::Command::History

CohortExplorer::Command::Query::Search

CohortExplorer::Command::Query::Compare

LICENSE AND COPYRIGHT

Copyright (c) 2013-2014 Abhishek Dixit (adixit@cpan.org). All rights reserved.

This program is free software: you can redistribute it and/or modify it under the terms of either:

  • the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version, or

  • the "Artistic Licence".

AUTHOR

Abhishek Dixit