Review queues a scan read only in part, and an undated name one typo from a person
This commit is contained in:
+12
-2
@@ -340,6 +340,8 @@ def run_link(p: str, node: Link):
|
||||
|
||||
known = [f for f in ("birth_date", "sex") if f in fields]
|
||||
orphan = set(whole.unique_id[whole[facts].isna().all(axis=1)]) if facts else set()
|
||||
# no birth date to tell her apart (a pathology scan: a name, misread or not, and a sex)
|
||||
undated = set(whole.unique_id[whole["birth_date"].isna()]) if "birth_date" in fields else set()
|
||||
lone = set() # persons whose identifier is carried by one record only
|
||||
for f in ids:
|
||||
carried = persons.dropna(subset=[f]).groupby(["cluster_id", f]).size()
|
||||
@@ -349,15 +351,23 @@ def run_link(p: str, node: Link):
|
||||
"""(the person to settle, a possible owner), or None when the pair is implausible:
|
||||
they contradict each other, or one typo apart is all they share (with sequential
|
||||
record numbers every patient has such neighbours) unless one side has no
|
||||
demographics and the other's identifier stands on a single record."""
|
||||
demographics and the other's identifier stands on a single record. Names one typo
|
||||
apart are rare: an undated side (a misread pathology scan) is always queued; so is the
|
||||
very same identifier on a record that says nothing else (a scan read only in part)."""
|
||||
a, b = r.unique_id_l, r.unique_id_r
|
||||
sides = [(getattr(r, f"{f}_l"), getattr(r, f"{f}_r")) for f in known]
|
||||
if frozenset((a, b)) in decided or any(
|
||||
pd.notna(x) and pd.notna(y) and x != y for x, y in sides
|
||||
):
|
||||
return None
|
||||
if not reasons[int(r.match_key)].endswith("typo apart"):
|
||||
reason = reasons[int(r.match_key)]
|
||||
if not reason.endswith("typo apart"):
|
||||
return a, b
|
||||
field = reason.removesuffix(" one typo apart")
|
||||
if getattr(r, f"{field}_l") == getattr(r, f"{field}_r"): # the very same identifier
|
||||
return (a, b) if a in undated or b not in undated else (b, a)
|
||||
if field == "full_name" and (a in undated) != (b in undated):
|
||||
return (a, b) if a in undated else (b, a) # names are rarely one typo apart
|
||||
if a in orphan and b in lone:
|
||||
return a, b
|
||||
if b in orphan and a in lone:
|
||||
|
||||
Reference in New Issue
Block a user