2013-11-14 07:00:38 -08:00
|
|
|
#!/usr/bin/env perl
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
use Test::More;
|
|
|
|
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 {
|
2015-07-11 02:02:59 -07:00
|
|
|
id => 'blood_donor',
|
|
|
|
name => 'Blood Donors',
|
2015-07-08 15:17:35 -07:00
|
|
|
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
|
|
|
),
|
2013-11-14 07:00:38 -08:00
|
|
|
);
|
|
|
|
|
|
|
|
done_testing;
|