Documents no route recognises, and unnamed persons, for review

This commit is contained in:
Roberto Treviño
2026-11-27 19:17:49 -06:00
parent 1e878b8942
commit d3f7aeb537
2 changed files with 29 additions and 7 deletions
+20 -5
View File
@@ -102,8 +102,14 @@ def test_an_operator_connects_a_site_and_settles_its_review(api, platform, site,
held_by = platform.query("select id, _record from bronze.n__site__resultados")
record_of |= {f"ResultadoSubrogado:{i}": r for i, r in held_by}
assert len(record_of) == len(truth)
# Papers no route recognises wait for a reviewer, and only they.
unknown = ok(api.get("/review/unrecognised", params={"pipeline": "site"}))
assert {f"ResultadoSubrogado:{r['id']}" for r in unknown} == {
r["where"] for r in truth if r.get("document") == "unrecognised"} # fmt: skip
assert all("VIGENCIA" in r["preview"] for r in unknown)
forms = sum(1 for r in truth
if r["entity"] == "cervical_cytology" and "document" not in r) # fmt: skip
if r["entity"] == "cervical_cytology"
and r.get("document") in (None, "cytology_with_hpv")) # fmt: skip
assert len(ok(api.get("/ingest/pipelines/site/nodes/cytology/rows?limit=500"))) == forms
# Review: reports that contradict each other, rows held because their person is torn
@@ -136,12 +142,21 @@ def test_an_operator_connects_a_site_and_settles_its_review(api, platform, site,
merges += same
decision = {"person": entry["person"], "candidate": c["candidate"], "same": same}
ok(api.post("/review/persons", json=decision), status=201)
# The torn person: the pathology reports without a birth date get the one their woman's
# other documents show.
# A person nothing names (a scan whose name wasn't read): the reviewer reads whose
# document it is and joins it to her.
for entry in persons["unnamed"]:
scan = entry["records"][0]["_record"] # decisions are kept by record
owner = next(r for r, person in before.items()
if patient[r] == patient[scan] and person != entry["person"]) # fmt: skip
decision = {"person": scan, "candidate": owner, "same": True}
ok(api.post("/review/persons", json=decision), status=201)
merges += 1
# The torn person: each record without a birth date (pathology prints none; a scan's
# may not be read) gets the one its woman's other documents show.
at = {record_of[r["where"]]: r for r in truth}
for record in persons["torn"][0]["records"]:
r = at[record["_record"]]
if "birth_date" not in r["identity"]:
if record.get("birth_date") is None:
fix = {"record": record["_record"], "field": "birth_date",
"value": site.meta["birth_dates"][r["person"]]} # fmt: skip
ok(api.post("/review/corrections", json=fix), status=201)
@@ -175,7 +190,7 @@ def test_an_operator_connects_a_site_and_settles_its_review(api, platform, site,
for study in STUDIES:
assert ok(api.get("/review/held", params={"entity": study})) == [], study
left = ok(api.get("/review/persons", params={"pipeline": "site", "node": "persons"}))
assert left == {"to_settle": [], "torn": []}
assert left == {"to_settle": [], "torn": [], "unnamed": []}
people = {r["person"] for r in truth}
groups = {}
for record, person in platform.query("select _record, person_id from bronze.n__site__persons"):