Documents no route recognises, and unnamed persons, for review
This commit is contained in:
+20
-5
@@ -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")
|
held_by = platform.query("select id, _record from bronze.n__site__resultados")
|
||||||
record_of |= {f"ResultadoSubrogado:{i}": r for i, r in held_by}
|
record_of |= {f"ResultadoSubrogado:{i}": r for i, r in held_by}
|
||||||
assert len(record_of) == len(truth)
|
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
|
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
|
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
|
# 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
|
merges += same
|
||||||
decision = {"person": entry["person"], "candidate": c["candidate"], "same": same}
|
decision = {"person": entry["person"], "candidate": c["candidate"], "same": same}
|
||||||
ok(api.post("/review/persons", json=decision), status=201)
|
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
|
# A person nothing names (a scan whose name wasn't read): the reviewer reads whose
|
||||||
# other documents show.
|
# 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}
|
at = {record_of[r["where"]]: r for r in truth}
|
||||||
for record in persons["torn"][0]["records"]:
|
for record in persons["torn"][0]["records"]:
|
||||||
r = at[record["_record"]]
|
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",
|
fix = {"record": record["_record"], "field": "birth_date",
|
||||||
"value": site.meta["birth_dates"][r["person"]]} # fmt: skip
|
"value": site.meta["birth_dates"][r["person"]]} # fmt: skip
|
||||||
ok(api.post("/review/corrections", json=fix), status=201)
|
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:
|
for study in STUDIES:
|
||||||
assert ok(api.get("/review/held", params={"entity": study})) == [], study
|
assert ok(api.get("/review/held", params={"entity": study})) == [], study
|
||||||
left = ok(api.get("/review/persons", params={"pipeline": "site", "node": "persons"}))
|
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}
|
people = {r["person"] for r in truth}
|
||||||
groups = {}
|
groups = {}
|
||||||
for record, person in platform.query("select _record, person_id from bronze.n__site__persons"):
|
for record, person in platform.query("select _record, person_id from bronze.n__site__persons"):
|
||||||
|
|||||||
+9
-2
@@ -26,10 +26,17 @@ def conflicts(entity: EntityName) -> Rows:
|
|||||||
return review.conflicts(entity)
|
return review.conflicts(entity)
|
||||||
|
|
||||||
|
|
||||||
|
@router.get("/unrecognised")
|
||||||
|
def unrecognised(pipeline: Id) -> Rows:
|
||||||
|
"""Documents a pipeline's routes don't recognise (what its `otherwise` routes took):
|
||||||
|
a new layout, a study the platform doesn't know, a scan nothing could read."""
|
||||||
|
return review.unrecognised(pipeline)
|
||||||
|
|
||||||
|
|
||||||
@router.get("/persons")
|
@router.get("/persons")
|
||||||
def persons(pipeline: Id, node: Id) -> dict[str, Rows]:
|
def persons(pipeline: Id, node: Id) -> dict[str, Rows]:
|
||||||
"""Persons to settle (with their possible owners) and torn persons (with their
|
"""Persons to settle (with their possible owners), torn persons and persons nothing
|
||||||
records) left by a pipeline's link node."""
|
names (with their records) left by a pipeline's link node."""
|
||||||
return review.persons(pipeline, node)
|
return review.persons(pipeline, node)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user