<!-- DEMO RESULTS PREFERENCES CHILD PAGE -->
<?php
//Demo var
$demo_my46id = 'My46DemoConsumer0001';
//Get Variable
$parent_cat = $_GET['a'];
$parent_name = ucwords(str_replace("-", " ", $parent_cat));
if ($parent_name == 'Acmg Recommended Conditions') {
$parent_name = 'ACMG Recommended Conditions';
}
//Other vars
$selected_counter = 0;
$unselected_counter = 0;
$trait_count = 0;
$selected_array = array();
$search_directory = getcwd();
//Get tsid for pre-set demo person tested
$tsid = db_query('
SELECT tsid
FROM my46_user_tested_info
WHERE my46id = :my46id',
array(
':my46id' => $demo_my46id
))
->fetchField();
//Parent Categories
$parent = db_query('
SELECT p.pcid
FROM parent_categories p
WHERE p.parent_category = :pc',
array(
':pc' => $parent_name
))
->fetchField();
//Subcategory cids for this parent category
$children = db_query('
SELECT cid
FROM categories
WHERE pcid = :pcid',
array(
':pcid' => $parent
))
->fetchCol();
//Sub categories
$sub = db_query('
SELECT c.*, ce.example
FROM categories c
INNER JOIN categories_examples ce
ON ce.cid = c.cid
WHERE pcid = :pcid
ORDER BY category',
array(
':pcid' => $parent
))
->fetchAll();
//Get the demo traits selected from session
$demo_traits = $_SESSION['demo_traits'];
//Get total number of traits for this user in this parent category
$trait_tids = db_query('
SELECT DISTINCT(t.tid)
FROM my46_traits_to_users u
INNER JOIN my46_traits_to_categories tc
ON u.tid = tc.tid
INNER JOIN my46_traits t
ON u.tid = t.tid
WHERE u.tsid = :tsid
AND cid IN (
SELECT cid
FROM categories
WHERE pcid = :pcid
)',
array(
':tsid'=>$tsid,
':pcid' => $parent
))
->fetchCol();
//Get the associated cids for each trait (each trait can belong to multiple categories)
foreach ($trait_tids as $trait_tid) {
$trait_cids = db_query('
SELECT cid
FROM my46_traits_to_categories
WHERE tid = :tid',
array(
':tid' => $trait_tid
))
->fetchCol();
//Filter for the matching cids for each possible categories
foreach ($children as $child) {
if (in_array($child, $trait_cids)) {
$trait_count++;
}
}
}
//Filter the demo_traits for the selected traits in this parent category
foreach ($demo_traits as $demo_trait) {
if (in_array($demo_trait->tid, $trait_tids) && !empty($demo_trait->setting)) {
$selected_counter++;
array_push($selected_array, $demo_trait);
}
}
$not_selected_count = $trait_count - $selected_counter;
//Counters
$sub_category_count = count($sub);
$selected_count = (empty($trait_count)) ? 0 : $selected_counter;
//$not_selected_count = (empty($trait_count)) ? 0 : $unselected_counter;
?>
<div id="demo">
<div id="results-preferences">
<div id="my46-my-preferences-div">
<form action="/consumer-demo/preference-processor?a=<?php echo $parent_cat; ?>" method="post" id="my46-my-preferences">
<div id="my-preferences-table">
<div id="button-headers">
<div class="result-type col1 beautytips" title="A trait category is a group of traits that are similar to each other such as traits associated with heart conditions or blood disorders.">Trait Categories</div>
<div class="radio-cell col2">YES, I want results</div>
<div class="radio-cell col3">NO, I do not want results</div>
<div class="radio-cell col4">I am undecided</div>
</div>
<div id="pref-counter-div">
<div id="counter-not-selected">
<div class="header">Not selected</div>
<div class="number <?php if ($not_selected_count > 0) { echo "red-border-number"; } ?>"><?php echo $not_selected_count; ?></div>
</div>
<div id="counter-selected">
<div class="header">Selected</div>
<div class="number"><?php echo $selected_count; ?></div>
</div>
</div>
<div id="select-all-buttons">
<div id="submit-button-div"><input id="next-steps-button" type="submit" name="submit" value="Save preferences"></div>
<div id="select-all-yes" class="<?php echo $parent_cat; ?> select-all col2">Select all</div>
<div id="select-all-no" class="<?php echo $parent_cat; ?> select-all col3">Select all</div>
<div id="select-all-undecided" class="<?php echo $parent_cat; ?> select-all col4">Select all</div>
</div>
<div id="scroll">
<ul id="slide-prefs">
<?php
//if parent category has no subcategories
if($sub_category_count == 0) {
$traits = db_query('
SELECT DISTINCT(trait), trait_abbr
FROM my46_traits_to_users u
INNER JOIN my46_traits_to_categories tc
ON u.tid = tc.tid
INNER JOIN my46_traits t
ON u.tid = t.tid
WHERE u.tsid = :tsid
AND cid IN (
SELECT cid
FROM categories
WHERE pcid = :pcid)
ORDER BY trait',
array(
':tsid'=> $tsid,
':pcid' => $parent
))
->fetchAll();
$sub_map = function($t) {return $t->setting;};
$temp_pref_count = array_count_values(array_map($sub_map, $selected_array));
$number_of_yes = $temp_pref_count['yes'];
$number_of_no = $temp_pref_count['no'];
$number_of_undecided = $temp_pref_count['undecided'];
?>
<!-- Setup for parent categories with no subcategories -->
<li class="slide no-example <?php if($trait_count != $selected_count){ echo 'incomplete'; } ?>">
<div id="cat-<?php echo $parent; ?>" class="category <?php echo $parent_cat; ?>">
<div class="col-type slide-title">
<span class="slide-name"><?php echo $parent_name; ?></span>
<span class="slide-arrow"> </span><br />
</div>
<div class="<?php echo $parent_cat; ?> category button">
<input class="category-radio yes <?php echo $parent_cat; ?>" type="radio" name="<?php echo $parent_cat; ?>" value="yes" <?php if($number_of_yes == $trait_count && $trait_count != 0){?> checked="checked" <?php } ?>>
</div>
<div class="<?php echo $parent_cat; ?> category button">
<input class="category-radio no <?php echo $parent_cat; ?>" type="radio" name="<?php echo $parent_cat; ?>" value="no" <?php if($number_of_no == $trait_count && $trait_count != 0){?> checked="checked" <?php } ?>>
</div>
<div class="<?php echo $parent_cat; ?> category button">
<input class="category-radio undecided <?php echo $parent_cat; ?>" type="radio" name="<?php echo $parent_cat; ?>" value="undecided" <?php if($number_of_undecided == $trait_count && $trait_count != 0){?> checked="checked" <?php } ?>>
</div>
</div>
<?php
$trait_counter = 0;
foreach($traits as $trait) {
$trait_counter++;
foreach($demo_traits as $demo_trait) {
if ($demo_trait->trait == $trait->trait) {
$preference_setting = $demo_trait->setting;
}
}
$lc_trait = strtolower($trait->trait_abbr);
$trait_handle = str_replace(" ", "-", $lc_trait);
?>
<div id="<?php echo $trait_handle;?>" class="subcat <?php echo $parent_cat; ?> trait <?php echo $trait_handle; ?> slide-body <?php print ($trait_counter % 2 == 0 ? even : odd); ?>">
<div class="row">
<div class="col1 subtype">
<?php
$filename = $search_directory . "/sites/
www.my46.org/files/audio/trait_". $trait->trait .".mp3";
if (file_exists($filename)) { ?>
<div class="playback trait"></div>
<audio>
<source src="/sites/
www.my46.org/files/audio/trait_<?php echo $trait->trait; ?>.mp3" type="audio/mpeg">
<source src="/sites/
www.my46.org/files/audio/trait_<?php echo $trait->trait; ?>.ogg" type="audio/ogg">
</audio>
<?php } ?>
<a id="" class="simple-dialog trait" title="My46 Trait Profile" name="node-543" rel="width:942;height:600;resizable:true;position:[center,20];" href="/trait-document?trait=<?php echo $trait->trait;?>&type=profile"><?php echo $lc_trait;?></a>
<br />
</div>
<div class="<?php echo $trait_handle; ?> trait button" >
<input class="preference-radio yes <?php echo $category->preference . ' ' . $parent_cat; ?>" type="radio" name="<?php echo $trait_handle; ?>" value="yes" <?php if($preference_setting == 'yes'){?> checked="checked" <?php } ?>>
</div>
<div class="<?php echo $trait_handle; ?> trait button" >
<input class="preference-radio no <?php echo $category->preference . ' ' . $parent_cat; ?>" type="radio" name="<?php echo $trait_handle; ?>" value="no" <?php if($preference_setting == 'no'){?> checked="checked" <?php } ?>>
</div>
<div class="<?php echo $trait_handle; ?> trait button" >
<input class="preference-radio undecided <?php echo $category->preference . ' ' . $parent_cat; ?>" type="radio" name="<?php echo $trait_handle; ?>" value="undecided" <?php if($preference_setting == 'undecided'){?> checked="checked" <?php } ?>>
</div>
</div>
</div>
<?php
unset($preference_setting);
}
?>
</li>
<?php
} else {
foreach($sub as $category){
$traits = db_query('
SELECT trait, u.tid, tc.cid, trait_abbr
FROM my46_traits_to_users u
INNER JOIN my46_traits_to_categories tc
ON u.tid = tc.tid
INNER JOIN my46_traits t
ON u.tid = t.tid
WHERE u.tsid = :tsid
AND cid = :cid
ORDER BY trait',
array(
':tsid'=> $tsid,
':cid' => $category->cid
))
->fetchAll();
//print_r($traits);
foreach($traits as $trait) {
foreach($demo_traits as $demo_trait) {
if ($demo_trait->trait == $trait->trait) {
$trait->setting = $demo_trait->setting;
}
}
}
//print_r($subcat_traits);
$sub_map = function($v) {return $v->cid;};
$sub_count = array_count_values(array_map($sub_map, $traits));
$trait_count_subcat = $sub_count[$category->cid];
$map = function($v) {return $v->setting;};
$count = array_count_values(array_map($map, $traits));
$number_of_yes = $count['yes'];
$number_of_no = $count['no'];
$number_of_undecided = $count['undecided'];
$selected_count_subcat = $number_of_yes + $number_of_no + $number_of_undecided;
$example_full_name = strtolower($category->example);
$example_name = str_replace(" ", "-", $example_full_name);
$example_uppercase = ucwords($category->example);
?>
<li class="slide <?php if (($selected_count_subcat != $trait_count_subcat) && ($trait_count_subcat > 0)) { echo 'incomplete'; } ?>">
<div id="cat-<?php echo $category->preference; ?>" class="category <?php echo $category->preference; ?>">
<div class="col-type slide-title">
<span class="slide-name"><?php echo $category->category; ?></span>
<span class="slide-arrow"> </span><br />
<a href="/demo/my-preferences/<?php echo $parent_cat; ?>/examples" class="simple-dialog" rel="width:700;height:auto;resizable:true;position:[center,60]" name="<?php echo $example_name; ?>" title="<?php echo $example_uppercase; ?>">example: <?php echo $category->example; ?></a>
</div>
<div class="<?php echo $category->preference; ?> category button">
<input class="category-radio yes <?php echo $category->preference; ?>" type="radio" name="<?php echo $category->preference; ?>" value="yes" <?php if($number_of_yes == $trait_count_subcat && !empty($sub_count)){?> checked="checked" <?php } ?>>
</div>
<div class="<?php echo $category->preference; ?> category button">
<input class="category-radio no <?php echo $category->preference; ?>" type="radio" name="<?php echo $category->preference; ?>" value="no" <?php if($number_of_no == $trait_count_subcat && !empty($sub_count)){?> checked="checked" <?php } ?>>
</div>
<div class="<?php echo $category->preference; ?> category button">
<input class="category-radio undecided <?php echo $category->preference; ?>" type="radio" name="<?php echo $category->preference; ?>" value="undecided" <?php if($number_of_undecided == $trait_count_subcat && !empty($sub_count)){?> checked="checked" <?php } ?>>
</div>
</div>
<?php
$trait_counter = 0;
foreach($traits as $trait){
$trait_counter++;
$preference_setting = $trait->setting;
$lc_trait = strtolower($trait->trait_abbr);
$trait_handle = str_replace(" ", "-", $lc_trait);
?>
<div id="<?php echo $trait_handle;?>" class="subcat <?php echo $parent_cat; ?> trait <?php echo $trait_handle; ?> slide-body <?php print ($trait_counter % 2 == 0 ? even : odd); ?>">
<div class="row">
<div class="col1 subtype">
<?php
$filename = $search_directory . "/sites/
www.my46.org/files/audio/trait_". $trait->trait .".mp3";
if (file_exists($filename)) { ?>
<div class="playback trait"></div>
<audio>
<source src="/sites/
www.my46.org/files/audio/trait_<?php echo $trait->trait; ?>.mp3" type="audio/mpeg">
<source src="/sites/
www.my46.org/files/audio/trait_<?php echo $trait->trait; ?>.ogg" type="audio/ogg">
</audio>
<?php } ?>
<a id="" class="simple-dialog trait" title="My46 Trait Profile" name="node-543" rel="width:942;height:600;resizable:true;position:[center,20];" href="/trait-document?trait=<?php echo $trait->trait;?>&type=profile"><?php echo $lc_trait;?></a>
<br />
</div>
<div class="<?php echo $trait_handle; ?> trait button" >
<input class="preference-radio yes <?php echo $category->preference . ' ' . $parent_cat; ?>" type="radio" name="<?php echo $trait_handle; ?>" value="yes" <?php if($preference_setting == 'yes'){?> checked="checked" <?php } ?>>
</div>
<div class="<?php echo $trait_handle; ?> trait button" >
<input class="preference-radio no <?php echo $category->preference . ' ' . $parent_cat; ?>" type="radio" name="<?php echo $trait_handle; ?>" value="no" <?php if($preference_setting == 'no'){?> checked="checked" <?php } ?>>
</div>
<div class="<?php echo $trait_handle; ?> trait button" >
<input class="preference-radio undecided <?php echo $category->preference . ' ' . $parent_cat; ?>" type="radio" name="<?php echo $trait_handle; ?>" value="undecided" <?php if($preference_setting == 'undecided'){?> checked="checked" <?php } ?>>
</div>
</div>
</div>
<?php
unset($preference_setting);
}
?>
</li>
<?php
}
}
?>
</ul>
</div>
</div>
<div id="submit-button-div2">
<input id="next-steps-button2" type="submit" name="submit" value="Save preferences">
</div>
</form>
</div>
</div>
</div>
<?php
$parent_cat = $_GET['a'];
global $user;
$learn_more_node_ids = array("disease-risk" => 209, "carrier-status" => 207, "medication-response" => 208,
"ancestry" => 210, "genetic-syndromes" => 524, "metabolic-disorders" => 527, "newborn-screening-conditions" => 531, "copy-number-variants" => 637, "acmg-recommended-conditions" => 644);
$node_id = $learn_more_node_ids[$parent_cat];
$node = node_load($node_id);
$body_content = $node->body[$node->language][0]['value'];
print $body_content;
<?php
$parent_cat = $_GET['a'];
$examples_node_ids = array("disease-risk" => 213, "carrier-status" => 634, "medication-response" => 212,
"ancestry" => 210, "genetic-syndromes" => 523, "metabolic-disorders" => 528, "newborn-screening-conditions" => 532, "copy-number-variants" => 638, "acmg-recommended-conditions" => 645);
$node_id = $examples_node_ids[$parent_cat];
$node = node_load($node_id);
$body_content = $node->body[$node->language][0]['value'];
print $body_content;
<?php
$parent_cat = $_GET['a'];
$pro_con_node_ids = array("disease-risk" => 214, "carrier-status" => 216, "medication-response" => 215,
"ancestry" => 210, "genetic-syndromes" => 533, "metabolic-disorders" => 529, "newborn-screening-conditions" => 533, "copy-number-variants" => 639, "acmg-recommended-conditions" => 646);
$node_id = $pro_con_node_ids[$parent_cat];
$node = node_load($node_id);
$body_content = $node->body[$node->language][0]['value'];
print $body_content;
<?php
$parent_cat = $_GET['a'];
$resources_node_ids = array("disease-risk" => 217, "carrier-status" => 219, "medication-response" => 218,
"ancestry" => 210, "genetic-syndromes" => 526, "metabolic-disorders" => 530, "newborn-screening-conditions" => 534, "copy-number-variants" => 640, "acmg-recommended-conditions" => 647);
$node_id = $resources_node_ids[$parent_cat];
$node = node_load($node_id);
$body_content = $node->body[$node->language][0]['value'];
print $body_content;