our
@EXPORT_OK
=
qw(do_bff2jsonld do_pxf2jsonld)
;
sub
do_bff2jsonld {
my
(
$self
,
$bff
) =
@_
;
eval
{
JSONLD->
import
();
};
if
($@) {
die
"There were errors in installing dependencies on Windows, specifically: 'JSONLD' is not available: $@"
;
}
return
unless
defined
(
$bff
);
my
$jld
= JSONLD->new();
my
$context
= {
'bff'
=>
'id'
=>
'id'
,
'type'
=>
'type'
,
'subject'
=>
'bff:subject'
,
'phenotypicFeatures'
=>
'bff:phenotypicFeatures'
,
'description'
=>
'bff:description'
,
'severity'
=>
'bff:severity'
,
'diagnosis'
=>
'bff:diagnosis'
,
'disease'
=>
'bff:disease'
,
'ageAtCollection'
=>
'bff:ageAtCollection'
,
'sex'
=>
'bff:sex'
,
'MALE'
=>
'bff:MALE'
,
};
$bff
->{
'@context'
} =
$context
;
my
$compact
=
$jld
->compact(
$bff
);
return
$compact
;
}
sub
do_pxf2jsonld {
my
(
$self
,
$pxf
) =
@_
;
eval
{
JSONLD->
import
();
};
if
($@) {
die
"There were errors in installing dependencies on Windows, specifically: 'JSONLD' is not available: $@"
;
}
return
unless
defined
(
$pxf
);
my
$jld
= JSONLD->new();
my
$context
= {
'pxf'
=>
'id'
=>
'id'
,
'type'
=>
'type'
,
'subject'
=>
'pxf:subject'
,
'phenotypicFeatures'
=>
'pxf:phenotypicFeatures'
,
'description'
=>
'pxf:description'
,
'severity'
=>
'pxf:severity'
,
'diagnosis'
=>
'pxf:diagnosis'
,
'disease'
=>
'pxf:disease'
,
'ageAtCollection'
=>
'pxf:ageAtCollection'
,
'sex'
=>
'pxf:sex'
,
'MALE'
=>
'pxf:MALE'
,
};
$pxf
->{
'@context'
} =
$context
;
my
$compact
=
$jld
->compact(
$pxf
);
my
$expanded
=
$jld
->expand(
$pxf
);
return
$compact
;
}
1;