Compare commits

...

2 Commits

Author SHA1 Message Date
Roberto Treviño 1e878b8942 Erick's site as one table, ResultadoSubrogado 2026-11-27 14:02:09 -06:00
Roberto Treviño dffd33a7bc Synthea's dead come on top of the living it was asked for 2026-11-27 08:46:05 -06:00
2 changed files with 12 additions and 9 deletions
+10 -8
View File
@@ -36,20 +36,22 @@ def test_an_operator_connects_a_site_and_settles_its_review(api, platform, site,
# What the site has, and what one of its tables holds (documents shown by size).
found = ok(api.post("/ingest/sources/resources", json={"source": SQL, "args": database}))
assert found == ["ArchivosUni", "ResultadosSubrogados"]
assert found == ["ResultadoSubrogado"]
missing = {"credentials": "mssql+pymssql://sa:x@nowhere.invalid:1433/Pruebas"}
unreachable = api.post("/ingest/sources/resources", json={"source": SQL, "args": missing})
assert unreachable.status_code == 422, unreachable.text
reports = {"id": "reports", "kind": "source", "source": SQL, "args": database}
sample = ok(
api.post("/ingest/sources/preview?limit=3", json=reports | {"resource": "ArchivosUni"})
api.post(
"/ingest/sources/preview?limit=3", json=reports | {"resource": "ResultadoSubrogado"}
)
)
assert len(sample) == 3 and all(r["Archivo"].endswith(" bytes>") for r in sample)
# A file someone uploads (a report sent by mail) becomes a source like any other.
engine = create_engine(site.url)
with engine.connect() as con:
pdf = con.execute(text("select Archivo from dbo.ArchivosUni where Id = 1")).scalar()
pdf = con.execute(text("select Archivo from dbo.ResultadoSubrogado where Id = 1")).scalar()
engine.dispose()
uploaded = ok(api.post("/ingest/uploads", files={"file": ("informe.pdf", pdf)}))
mailed = {
@@ -96,12 +98,12 @@ def test_an_operator_connects_a_site_and_settles_its_review(api, platform, site,
# Run it, and look at what any node produced.
run(api, "site")
record_of = {}
for table, node in (("ArchivosUni", "archivos"), ("ResultadosSubrogados", "subrogados")):
rows = ok(api.get(f"/ingest/pipelines/site/nodes/{node}/rows?limit=500"))
record_of |= {f"{table}:{r['id']}": r["_record"] for r in rows}
assert ok(api.get("/ingest/pipelines/site/nodes/resultados/rows?limit=3"))
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)
forms = sum(1 for r in truth if r["where"].startswith("ArchivosUni:")
and r["entity"] == "cervical_cytology") # fmt: skip
forms = sum(1 for r in truth
if r["entity"] == "cervical_cytology" and "document" not in r) # 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
+2 -1
View File
@@ -43,7 +43,8 @@ def test_a_synthea_population_comes_in_through_the_fhir_door(api, platform, tmp_
bundles = _population(tmp_path / "synthea")
patients = sum(1 for b in bundles for e in b["entry"]
if e["resource"]["resourceType"] == "Patient") # fmt: skip
assert patients == 20 and _reports(bundles, "cervical_cytology") > 40
# Synthea counts the living: the women who died come on top of the twenty.
assert patients >= 20 and _reports(bundles, "cervical_cytology") > 40
receiving = DOOR.read_text().replace("{sender}", "synthea")
ok(api.put("/ingest/pipelines/synthea", json=json.loads(receiving)))