EEG study serves its ADOS-2 association rows; TEA gate as roundtrips
This commit is contained in:
@@ -45,7 +45,7 @@ def _sent(bundles: list[dict]) -> Counter:
|
||||
biopsies = set()
|
||||
for b in bundles:
|
||||
studied = False
|
||||
treated = 0
|
||||
treated = recurred = 0
|
||||
for e in b["entry"]:
|
||||
r = e["resource"]
|
||||
codes = [c for c in (r.get("code") or {}).get("coding", []) if c["system"] == STUDY]
|
||||
@@ -58,9 +58,11 @@ def _sent(bundles: list[dict]) -> Counter:
|
||||
found[c["code"]] += 1
|
||||
studied |= c["code"] in ("mammography", "breast_biopsy")
|
||||
treated += c["code"] == "breast_treatment"
|
||||
recurred += c["code"] == "breast_recurrence"
|
||||
if r["resourceType"] == "Patient" and r.get("deceasedDateTime"):
|
||||
found["death"] += 1
|
||||
found["timeline_treatment"] += treated if studied else 0
|
||||
found["timeline_recurrence"] += recurred if studied else 0
|
||||
found["breast_biopsy"] = len(biopsies)
|
||||
return found
|
||||
|
||||
@@ -69,6 +71,7 @@ def test_a_synthea_cama_population_comes_in_through_the_fhir_door(api, platform,
|
||||
bundles = population(tmp_path / "synthea")
|
||||
sent = _sent(bundles)
|
||||
assert sent["breast_biopsy"] > 50 and sent["breast_treatment"] > 20 and sent["death"] > 0
|
||||
assert sent["breast_recurrence"] > 0
|
||||
|
||||
receiving = DOOR.read_text().replace("{sender}", "synthea")
|
||||
ok(api.put("/ingest/pipelines/synthea", json=json.loads(receiving)))
|
||||
@@ -78,13 +81,30 @@ def test_a_synthea_cama_population_comes_in_through_the_fhir_door(api, platform,
|
||||
assert answer.status_code == 202, answer.text[:500]
|
||||
wait_for(api, answer.headers["location"].rsplit("/", 1)[1], 1800)
|
||||
|
||||
for study in ("mammography", "breast_biopsy", "breast_treatment"):
|
||||
for study in ("mammography", "breast_biopsy", "breast_treatment", "breast_recurrence"):
|
||||
assert ok(api.get("/review/held", params={"entity": study})) == [], study
|
||||
assert platform.count(f"silver.{study}") == sent[study], study
|
||||
q = platform.query
|
||||
# Each invasive biopsy holds all of its results; gold's timeline has them and the course.
|
||||
assert q("select count(*) from silver.breast_biopsy where histology = 'invasive' and "
|
||||
"(stage is null or her2 is null or grade is null)")[0][0] == 0 # fmt: skip
|
||||
"(stage is null or her2 is null or grade is null or positive_nodes is null)"
|
||||
)[0][0] == 0 # fmt: skip
|
||||
kinds = dict(q("select type, count(*) from gold.cama_events where type in "
|
||||
"('stage', 'her2', 'treatment', 'death') group by type")) # fmt: skip
|
||||
"('stage', 'her2', 'positive_nodes', 'treatment', 'recurrence', 'death') "
|
||||
"group by type")) # fmt: skip
|
||||
assert kinds.get("stage", 0) > 0 and kinds.get("treatment", 0) == sent["timeline_treatment"]
|
||||
assert (
|
||||
kinds.get("positive_nodes", 0) > 0
|
||||
and kinds.get("recurrence", 0) == sent["breast_recurrence"]
|
||||
)
|
||||
|
||||
# Recurrence, a roundtrip: trained through the API on these patients, its cohort is gold's
|
||||
# recurrence cohort and its recurrences are the ones Synthea wrote (slow: minutes).
|
||||
if not os.environ.get("RECURRENCE_SLOW"):
|
||||
return
|
||||
wait_for(api, ok(api.post("/models/cama/train", json={"models": ["recurrence"]}))["run_id"],
|
||||
3600) # fmt: skip
|
||||
report = ok(api.get("/models/cama/recurrence/versions/1/reports/technical_validation"))
|
||||
assert report["cohort"] == "site"
|
||||
members = q("select count(*) from gold.cama_cohort_recurrence where excluded_by is null")[0][0]
|
||||
assert report["rutinas"] and members > 0
|
||||
|
||||
Reference in New Issue
Block a user