Migration for PhenoTips issue #2155: migrating old family studies data.
The migrator can only auto-generate a family/pedigree if there is no existing pedigree, all
members of the family are owned by the same user, and all members of the family can be included
in restricted pedigree shape (or a subset of the shape) as described below:
< >--*--< > < >--*--< >
| |
+-----+-----+ |
| | | |
< > <...> <R>---*---<P>
|
+---+---+------------+---...
| | | / \
< > <...> <...> <...> <...>
- R denotes "root" patient (not necessarily the proband)
- R may have at most one partner, P
- at most 3 generations: root patient, root parents and root children
- at most one partner for the root patient (P)
- R may have some siblings or twins, none of which should have a child
- P's parents are only related to P (and possibly as grandparents to P+R's children)
- R's parents are only related to R and R's siblings (and possibly as grandparents to R+P's children)
- all other nodes are children of R and P, can't be related to any other node other than
R, P or other children as twins (or their parents as grandchilren)
- "supported" relations are PARENT/CHILD/TWIN/SIBLING (because all other relationships
can not be converted to a pedigree in a uniform way, e.g. for "uncle" relationships it is not clear
if the uncle is on the maternal or paternal side)
- there may be other patients which are only linked by non-supported relation types
(e.g a patient which is only an uncle of someone - but not a parent or child or sibling of anyone).
Those patients are added as comments to the generated pedigree.
- a pedigree must have the root patient, and at least one more patient, which can be either a child,
a parent or a partner. It may also have more relatives, as long as they fit the shape outlined above.
It is assumed that the proband is the patient in the family with the earliest PT document creation time
(not necessarily the "root" patient in the pedigree above).
Otherwise, if there already exists a pedigree for the node which has an old family studies relationship,
that relationship is added to that node's pedigree comment.
Additionally and independently of the above, if a node in an existing pedigree has an external ID of an
existing PhenoTips record, that patient is linked to the pedigree node (unless that patient is a member
of another family or is also referenced from another pedigree).