Review queues a scan read only in part, and an undated name one typo from a person

This commit is contained in:
Roberto Treviño
2026-11-27 14:02:08 -06:00
parent 7b9ae69de2
commit 3546269eaf
3 changed files with 21 additions and 26 deletions
+6 -18
View File
@@ -27,15 +27,8 @@ def graph(tmp: Path, hospital_tables: dict[str, list[str]], site_url: str) -> di
return {
"nodes": nodes
+ [
table("archivos", site_url, "ArchivosUni", schema="dbo"),
table("subrogados", site_url, "ResultadosSubrogados", schema="dbo"),
{"id": "archivos_text", "kind": "read", "inputs": ["archivos"], "column": "archivo"},
{
"id": "subrogados_text",
"kind": "read",
"inputs": ["subrogados"],
"column": "archivo",
},
table("resultados", site_url, "ResultadoSubrogado", schema="dbo"),
{"id": "text", "kind": "read", "inputs": ["resultados"], "column": "archivo"},
]
}
@@ -58,13 +51,8 @@ def test_a_site_reaches_bronze_once_and_its_documents_are_read(platform, site, t
by_place = {}
for r in truth:
by_place.setdefault(r["where"].split(":")[0], []).append(r)
documents = len(by_place["ArchivosUni"]) + len(by_place["ResultadosSubrogados"])
expected = {
"archivos": len(by_place["ArchivosUni"]),
"subrogados": len(by_place["ResultadosSubrogados"]),
"archivos_text": len(by_place["ArchivosUni"]),
"subrogados_text": len(by_place["ResultadosSubrogados"]),
}
documents = len(truth)
expected = {"resultados": documents, "text": documents}
for name, names in tables.items():
with sqlite3.connect(tmp_path / f"hospital_{name}.db") as con:
for t in names:
@@ -87,8 +75,8 @@ def test_a_site_reaches_bronze_once_and_its_documents_are_read(platform, site, t
assert query(corrected) == [("64000",)]
space = re.compile(r"\s+")
for table, node in (("ArchivosUni", "archivos"), ("ResultadosSubrogados", "subrogados")):
read = query(f"select id, text, ocr, error from bronze.n__site__{node}_text")
for table in ("ResultadoSubrogado",):
read = query("select id, text, ocr, error from bronze.n__site__text")
assert [error for *_, error in read if error is not None] == []
by_id = {i: (space.sub(" ", txt), ocr) for i, txt, ocr, _ in read}
for r in by_place[table]:
+3 -6
View File
@@ -2,7 +2,7 @@
can trust, and everything the platform can't decide alone is put in front of a reviewer.
The source hides its answers the way the real one does (synthetic.site): one PDF per study in
two SQL Server tables, the institute's forms and what outsourced labs send back; an HPV result
one SQL Server table, the institute's forms beside what outsourced labs send back; an HPV result
is a document of its own on its cytology's order; pathology comes scanned, the name surname
first and no birth date; some forms say "MA." for María or misspell the name and leave the
employee number out; some HPV reports were re-issued the other way; two women share a name.
@@ -106,11 +106,8 @@ def test_a_site_becomes_silver_and_review_gets_the_rest(platform, site, tmp_path
# another ("IIA" as "IA"), which nothing in the text betrays: at most 1% of a scan's
# values, each listed.
at = {r["where"]: r for r in truth}
place = {
r: f"ArchivosUni:{i}" for i, r in q("select id, _record from bronze.n__site__archivos")
}
place |= {r: f"ResultadosSubrogados:{i}"
for i, r in q("select id, _record from bronze.n__site__subrogados")} # fmt: skip
place = {r: f"ResultadoSubrogado:{i}"
for i, r in q("select id, _record from bronze.n__site__resultados")} # fmt: skip
record_of = {w: r for r, w in place.items()}
accepted: dict[str, dict[str, dict]] = {} # study -> record -> fields (from silver's long rows)
for entity in FIELDS: