2013-11-14 07:00:38 -08:00
|
|
|
#!/usr/bin/env perl
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
use Test::More;
|
2016-05-16 06:07:57 -07:00
|
|
|
use Test::Deep;
|
2013-11-14 07:00:38 -08:00
|
|
|
use DDG::Test::Goodie;
|
|
|
|
|
|
|
|
zci answer_type => "blood_donor";
|
2014-09-27 06:42:57 -07:00
|
|
|
zci is_cached => 1;
|
2013-11-14 07:00:38 -08:00
|
|
|
|
2015-07-08 15:17:35 -07:00
|
|
|
sub build_structure
|
|
|
|
{
|
|
|
|
my ($blood_type, $data, $keys) = @_;
|
|
|
|
return {
|
|
|
|
description => 'Returns available donors for a blood type',
|
2015-07-11 02:02:59 -07:00
|
|
|
meta => {
|
|
|
|
sourceName => 'Wikipedia',
|
|
|
|
sourceUrl => 'https://en.wikipedia.org/wiki/Blood_type'
|
|
|
|
},
|
2015-07-08 15:17:35 -07:00
|
|
|
templates => {
|
|
|
|
group => 'list',
|
|
|
|
options => {
|
|
|
|
content => 'record'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
data => {
|
|
|
|
title => "Donors for blood type $blood_type",
|
|
|
|
record_data => $data,
|
|
|
|
record_keys => $keys
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2013-11-14 07:00:38 -08:00
|
|
|
ddg_goodie_test(
|
2014-05-08 14:05:09 -07:00
|
|
|
['DDG::Goodie::BloodDonor'],
|
2015-07-08 15:17:35 -07:00
|
|
|
'donor A+' => test_zci("Ideal donor: A+\nOther donors: A+ or O+\nOnly if no Rh(+) found: A- or O-",
|
|
|
|
structured_answer => build_structure("A+",{
|
|
|
|
"Ideal donor" => "A+",
|
|
|
|
"Other donors" => "A+ or O+",
|
|
|
|
"Only if no Rh(+) found" => "A- or O-"
|
|
|
|
},
|
|
|
|
["Ideal donor", "Other donors", "Only if no Rh(+) found"]
|
|
|
|
)
|
|
|
|
),
|
|
|
|
'donors for A+' => test_zci("Ideal donor: A+\nOther donors: A+ or O+\nOnly if no Rh(+) found: A- or O-",
|
|
|
|
structured_answer => build_structure("A+",{
|
|
|
|
"Ideal donor" => "A+",
|
|
|
|
"Other donors" => "A+ or O+",
|
|
|
|
"Only if no Rh(+) found" => "A- or O-"
|
|
|
|
},
|
|
|
|
["Ideal donor", "Other donors", "Only if no Rh(+) found"]
|
|
|
|
)
|
|
|
|
),
|
|
|
|
'blood donor A+' => test_zci("Ideal donor: A+\nOther donors: A+ or O+\nOnly if no Rh(+) found: A- or O-",
|
|
|
|
structured_answer => build_structure("A+",{
|
|
|
|
"Ideal donor" => "A+",
|
|
|
|
"Other donors" => "A+ or O+",
|
|
|
|
"Only if no Rh(+) found" => "A- or O-"
|
|
|
|
},
|
|
|
|
["Ideal donor", "Other donors", "Only if no Rh(+) found"]
|
|
|
|
)
|
|
|
|
),
|
|
|
|
'blood donors for A+' => test_zci("Ideal donor: A+\nOther donors: A+ or O+\nOnly if no Rh(+) found: A- or O-",
|
|
|
|
structured_answer => build_structure("A+",{
|
|
|
|
"Ideal donor" => "A+",
|
|
|
|
"Other donors" => "A+ or O+",
|
|
|
|
"Only if no Rh(+) found" => "A- or O-"
|
|
|
|
},
|
|
|
|
["Ideal donor", "Other donors", "Only if no Rh(+) found"]
|
|
|
|
)
|
2014-06-22 12:24:50 -07:00
|
|
|
),
|
2015-07-08 15:17:35 -07:00
|
|
|
'donor o+' => test_zci("Ideal donor: O+\nOther donors: O+\nOnly if no Rh(+) found: O-",
|
|
|
|
structured_answer => build_structure("O+",{
|
|
|
|
"Ideal donor" => "O+",
|
|
|
|
"Other donors" => "O+",
|
|
|
|
"Only if no Rh(+) found" => "O-"
|
|
|
|
},
|
|
|
|
["Ideal donor", "Other donors", "Only if no Rh(+) found"]
|
|
|
|
)
|
2014-06-22 12:24:50 -07:00
|
|
|
),
|
2015-12-06 20:56:48 -08:00
|
|
|
'donor o+ve' => test_zci("Ideal donor: O+VE\nOther donors: O+ve\nOnly if no Rh(+) found: O-ve",
|
|
|
|
structured_answer => build_structure("O+VE",{
|
|
|
|
"Ideal donor" => "O+VE",
|
|
|
|
"Other donors" => "O+ve",
|
|
|
|
"Only if no Rh(+) found" => "O-ve"
|
|
|
|
},
|
|
|
|
["Ideal donor", "Other donors", "Only if no Rh(+) found"]
|
|
|
|
)
|
|
|
|
),
|
2013-11-14 07:00:38 -08:00
|
|
|
);
|
|
|
|
|
2016-05-16 06:18:04 -07:00
|
|
|
done_testing;
|