#!/usr/bin/env perl
use
lib (
'./lib'
,
'../lib'
);
my
$ohdsi_db
=
'share/db/ohdsi.db'
;
use_ok(
'Convert::Pheno'
) or
exit
;
my
$method
=
'omop2bff'
;
{
my
$out
=
't/omop2bff/out/individuals_drug_exposure.json.gz'
;
my
(
undef
,
$tmp_file
) =
tempfile(
DIR
=>
't'
,
SUFFIX
=>
".json.gz"
,
UNLINK
=> 1 );
my
$convert
= Convert::Pheno->new(
{
in_file
=>
undef
,
in_files
=> [
't/omop2bff/in/gz/omop_cdm_eunomia.sql.gz'
],
out_file
=>
$tmp_file
,
redcap_dictionary
=>
undef
,
mapping_file
=>
undef
,
self_validate_schema
=>
undef
,
schema_file
=>
'schema/mapping.json'
,
in_textfile
=> 1,
stream
=> 1,
omop_tables
=> [
'DRUG_EXPOSURE'
],
max_lines_sql
=> 2700,
sep
=>
','
,
test
=> 1,
search
=>
'exact'
,
method
=>
$method
}
);
$convert
->
$method
;
my
$z1
= new IO::Uncompress::Gunzip
$out
;
my
$z2
= new IO::Uncompress::Gunzip
$tmp_file
;
my
$content1
=
do
{
local
$/; <
$z1
> };
my
$content2
=
do
{
local
$/; <
$z2
> };
is(
$content1
,
$content2
,
qq/$method stream gzipped IO drug_exposure/
);
$z1
->
close
();
$z2
->
close
();
}
{
if
( -f
$ohdsi_db
) {
my
$out
=
't/omop2bff/out/individuals_csv.json.gz'
;
my
(
undef
,
$tmp_file
) =
tempfile(
DIR
=>
't'
,
SUFFIX
=>
".json.gz"
,
UNLINK
=> 1 );
my
$convert
= Convert::Pheno->new(
{
in_file
=>
undef
,
in_files
=> [
't/omop2bff/in/gz/PERSON.csv.gz'
,
't/omop2bff/in/gz/CONCEPT.csv.gz'
,
't/omop2bff/in/gz/DRUG_EXPOSURE.csv.gz'
],
out_file
=>
$tmp_file
,
redcap_dictionary
=>
undef
,
mapping_file
=>
undef
,
self_validate_schema
=>
undef
,
schema_file
=>
'schema/mapping.json'
,
in_textfile
=> 1,
ohdsi_db
=> 1,
stream
=> 1,
omop_tables
=> [],
max_lines_sql
=> 2700,
sep
=>
"\t"
,
test
=> 1,
search
=>
'exact'
,
method
=>
$method
}
);
$convert
->
$method
;
my
$z1
= new IO::Uncompress::Gunzip
$out
;
my
$z2
= new IO::Uncompress::Gunzip
$tmp_file
;
my
$content1
=
do
{
local
$/; <
$z1
> };
my
$content2
=
do
{
local
$/; <
$z2
> };
SKIP: {
skip
qq{because <$ohdsi_db> is required with <ohdsi_db>}
, 1
unless
-f
$ohdsi_db
;
is(
$content1
,
$content2
,
qq/$method stream gzipped IO CSV/
);
}
$z1
->
close
();
$z2
->
close
();
}
}