We need to try and convert existing family studies into new ones, e.g. automatically create families and put persons who are specified as relatives into those families.
List of possible relations: Parent, Child, Sibling, Twin, Cousin, Aunt / Uncle, Niece / Nephew, Grandparent, Grandchild.
List for a pedigree auto-creation: Parent, Child, Sibling, Twin.
We can assume that migrator will run first.
If any of relations are not linked to a real existing patient, we skip this relation.
If a patient has a pedigree (and thus a family, already migrated by PT-2154), we add all relatives as comments for the pedigree node linked to the patient.
Next, all relatives are checked for "linkability". A relative is not "linkable" if at leastone of the following conditions is true:
– it has a pedigree/family
– it has relatives specified in family studies section
– it is owned by another user
– the relationship type is NOT one of Parent, Child, Sibling or Twin (e.g. we can not unambiguously assign the relative to a node in pedigree)
If all relatives are not linkable nothing is done.
If at least one relative is linkable, then we create a new family and a pedigree object, link all linkable relatives and mention all others in the comment for the pedigree node representing the patient.