Skip to content

Commit

Permalink
Check for uncles and aunts, now checking both of the grandparents chi…
Browse files Browse the repository at this point in the history
…ldren
  • Loading branch information
Brem committed Jan 17, 2025
1 parent 08bda27 commit 050a306
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 5 deletions.
15 changes: 15 additions & 0 deletions v4/common/fhh_common.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,18 @@ function find_children(parent_id, exception_id) {
return children;
}

function find_children_from_both_parents(father_id, mother_id, exception_id) {
var children = [];
$.each(data['people'], function(person_id, details){
if (details['father'] == father_id || details['mother'] == mother_id) {
if (person_id != exception_id) children.push(person_id);
}
});
sort_people_by_age_name_id(children);

return children;
}

function find_all_partners(person_id) {
var partners = [];

Expand Down Expand Up @@ -242,6 +254,7 @@ function find_and_set_partners() {
var mother_id = details['mother'];

if (father_id && father_id != "Unknown") {
console.log(father_id);
if (!data['people'][father_id]['partners']) {
data['people'][father_id]['partners'] = [ mother_id ];
} else if (data['people'][father_id]['partners'].indexOf(mother_id) === -1) {
Expand Down Expand Up @@ -280,11 +293,13 @@ function find_and_set_blood_relatives() {

function find_and_set_blood_relatives_for_great_grandparents(great_grandparents) {
$.each(great_grandparents, function(index, person_id) {
console.log(person_id);
data["people"][person_id]['blood'] = true;
});
}

function set_blood_and_check_children(id) {
console.log(id);
data['people'][id]['blood'] = true;

var children = find_children(id);
Expand Down
2 changes: 2 additions & 0 deletions v4/mfhp/fhh_card.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
display_element : function () {
var d = this.options.data;

console.log(this.element.attr("person_id"));
var relationship_box = get_title_box(d, this.element.attr("relationship"), this.element.attr("person_id"));
var stats_box = get_stats_box(d, this.element.attr("person_id"));
var race_ethnicity_box = get_race_ethnicity_box(d);
Expand Down Expand Up @@ -88,6 +89,7 @@ function get_name(d) {
}

function get_title_box(d, relationship, person_id) {
console.log(person_id)
var person_name = "Unknown";
if (d && d["name"]) person_name = d["name"];
if (d["deceased"] == true) deceased_status = " - deceased "; else deceased_status = "";
Expand Down
25 changes: 20 additions & 5 deletions v4/pedigree/fhh_pedigree.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ $.widget("fhh.pedigree",{
var great_grandparents = find_great_grandparents();
find_and_set_blood_relatives_for_great_grandparents(great_grandparents);

var dads_siblings = find_children(paternal_grandfather_id, father_id);
var dads_siblings = find_children_from_both_parents(paternal_grandfather_id, paternal_grandmother_id, father_id);
var dads_extra_partners = find_dads_extra_partners(father_id);

var moms_siblings = find_children(maternal_grandfather_id, mother_id);
var moms_siblings = find_children_from_both_parents(maternal_grandfather_id, maternal_grandmother_id, mother_id);
var moms_extra_partners = find_moms_extra_partners(mother_id);

var paternal_cousins = find_all_children_from_list(dads_siblings);
Expand Down Expand Up @@ -106,12 +106,18 @@ $.widget("fhh.pedigree",{

// Now, Starting at the bottom, set the Pedigree Location for each couple

console.log("Setting Location for Grandchildren");
set_location_grandchildren_generation(older_siblings_grandchildren, grandchildren, younger_siblings_grandchildren);
console.log("Setting Location for Children");
set_location_children_generation(paternal_cousins_children, older_siblings_children, children, younger_siblings_children, maternal_cousins_children);
console.log("Setting Location for Proband");
set_location_proband_generation(paternal_cousins, paternal_half_siblings, older_siblings,
proband_id, younger_siblings, maternal_half_siblings, maternal_cousins);
console.log("Setting Location for Parents");
set_location_parents_generation(dads_siblings, dads_extra_partners, father_id, mother_id, moms_extra_partners, moms_siblings);
console.log("Setting Location for Grandparents");
set_location_grandparents_generation(paternal_grandfather_id, paternal_grandmother_id, maternal_grandfather_id, maternal_grandmother_id);
console.log("Setting Location for GreatGrandparents");
set_location_great_grandparents_generation(great_grandparents, paternal_grandfather_id, paternal_grandmother_id, maternal_grandfather_id, maternal_grandmother_id);

// var proband_row = build_row();
Expand Down Expand Up @@ -1236,9 +1242,15 @@ function find_first_child_pedigree(parent_id) {
var children = find_children(parent_id);
var num_children = children.length;
if (num_children && num_children > 0) {
console.log(data["people"][children[0]]);
var pedigree = data["people"][children[0]]["pedigree"];
console.log(parent_id);
console.log(data["people"][parent_id]);

return pedigree;
} else {
console.log("PROBLEM No pedigree");
console.log(parent_id);
return 0;
}
}
Expand Down Expand Up @@ -1361,9 +1373,10 @@ function set_location_proband_generation(paternal_cousins, paternal_half_sibling
}

function set_location_parents_generation(dads_siblings, dads_extra_partners, father_id, mother_id, moms_extra_partners, moms_siblings) {
console.log("DS:" + dads_siblings + ", MS:" + moms_siblings);
console.log("HEREREREREREE");
var index_left = 0;
var index_right = 1;

// data["people"][father_id]["pedigree"] = {"location":0,"generation":4};
// data["people"][mother_id]["pedigree"] = {"location":0,"generation":4};

Expand Down Expand Up @@ -1416,19 +1429,21 @@ function set_location_great_grandparents_generation(great_grandparents,
function set_location_individual (person_id, direction, starting_index, generation) {
var location_index = starting_index;

console.log("Setting location for:" + data['people'][person_id]['name']);
console.log(data['people'][person_id]);
var child_pedigree = find_last_child_pedigree(person_id);
var first_child_pedigree = find_first_child_pedigree(person_id);
var num_children = find_children(person_id).length;


data["people"][person_id]["pedigree"] = {};
data["people"][person_id]["pedigree"]["generation"] = generation;
if (child_pedigree != null && child_pedigree["location"] != null) {
location_index = child_pedigree["location"] + direction;

var new_location = Math.floor( (child_pedigree["location"] + first_child_pedigree["location"]) / 2);
if (num_children == 1) new_location = location_index;
data["people"][person_id]["pedigree"]["location"] = new_location;
if (person_id == "ef77435b-5311-4629-982f-457e6f323913") console.log (num_children);
if (person_id == "4e3796a4-eea3-454a-bdd4-b967a69680b3") console.log (num_children);

} else {
location_index = location_index + direction;
Expand Down

0 comments on commit 050a306

Please sign in to comment.