Convert-Pheno
view release on metacpan or search on metacpan
t/19-cli-regression.t view on Meta::CPAN
unshift @cmd, $^X, $cli;
push @cmd, '-O', '--test';
my $actual_file = $case->{entity_output}
? File::Spec->catfile( $tmpdir, $case->{entity_output} )
: $tmp_file;
my ( $status, $output ) = run_cli(@cmd);
diag($output) if $status != 0 && defined $output && length $output;
is( $status, 0, "CLI $case->{name} exits successfully" );
ok(
compare_case_output( $case->{compare}, $case->{expected}, $actual_file ),
"CLI $case->{name} matches reference output",
);
}
{
my $omop_dir = tempdir( CLEANUP => 1 );
my @cmd = (
$^X, $cli,
'-ifhir', 't/fhir2bff/in/patient-bundle.json',
'-oomop',
'--out-dir', $omop_dir,
'--ohdsi-db',
'--path-to-ohdsi-db', $test_ohdsi_db_dir,
'-O',
'--test',
);
my ( $status, $output ) = run_cli(@cmd);
diag($output) if $status != 0 && defined $output && length $output;
is( $status, 0, 'CLI fhir2omop exits successfully' );
for my $table (qw(
CONDITION_OCCURRENCE
DRUG_EXPOSURE
MEASUREMENT
OBSERVATION
PERSON
PROCEDURE_OCCURRENCE
)) {
ok(
csv_files_match(
"t/fhir2omop/out/$table.csv",
File::Spec->catfile( $omop_dir, "$table.csv" ),
),
"CLI fhir2omop $table matches reference output",
);
}
}
{
my $tmp_file = temp_output_file( suffix => '.json', dir => $tmpdir );
my $input_file = temp_output_file( suffix => '.json', dir => $tmpdir );
my $payload = {
patient => { id => 'openehr-patient-2' },
compositions => [
load_json_file('t/openehr2bff/in/gecco_personendaten.json'),
load_json_file('t/openehr2bff/in/ips_canonical.json'),
load_json_file('t/openehr2bff/in/laboratory_report.json'),
load_json_file('t/openehr2bff/in/compo_corona.json'),
],
};
write_json_file( $input_file, $payload );
my @cmd = ( $^X, $cli, '-iopenehr', $input_file, '-opxf', $tmp_file, '-O', '--test' );
my ( $exit, $output ) = run_cli(@cmd);
is( $exit, 0, 'CLI openehr2pxf exits successfully' )
or diag $output;
ok(
structured_files_match( 't/openehr2pxf/out/pxf.json', $tmp_file ),
'CLI openehr2pxf matches reference output'
);
}
{
my $tmp_file = temp_output_file( suffix => '.json', dir => $tmpdir );
my @cmd = (
$^X, $cli,
'-ibff', 't/bff2pxf/in/individuals.json',
'-opxf', $tmp_file,
'--default-vital-status', 'UNKNOWN_STATUS',
'-O',
'--test',
);
my ( $status, $output ) = run_cli(@cmd);
diag($output) if $status != 0 && defined $output && length $output;
is( $status, 0, 'CLI bff2pxf accepts --default-vital-status' );
my $pxf = load_json_file($tmp_file);
is(
$pxf->[0]{subject}{vitalStatus}{status},
'UNKNOWN_STATUS',
'CLI bff2pxf applies the configured default vitalStatus when no source value is available',
);
}
done_testing();
( run in 1.525 second using v1.01-cache-2.11-cpan-c221a9de4ec )