FHIR Measures carry each metric's technical sheet; the live estimator uses the scenario dataflow and the cohort check

This commit is contained in:
2026-11-16 22:57:47 -06:00
parent 9737b5a67f
commit d5413b7e7a
3 changed files with 69 additions and 24 deletions
+24
View File
@@ -58,3 +58,27 @@ def test_the_patient_routes_are_tea_s_only(domain_client):
domain, client = domain_client
response = client.get(f"/{domain}/fhir/EpisodeOfCare")
assert response.status_code == 404 and valid(response.get_json())["resourceType"] == "OperationOutcome"
def test_a_measure_carries_its_technical_sheet(domain_client):
"""Pins down: what a metric's `meta` writes for the technical sheet reaches its Measure: `ficha` and
`figuras_detalle` as extensions, `referencias` as `relatedArtifact` and `descripcion_poblaciones` as the
populations' descriptions. Fails if `measure_resource` stops reading one of them, or CACU_EU7's or
CAMA_BIOPSIAS' `meta` loses it."""
domain, client = domain_client
measure_id = {"cacu": "CACU-EU7", "cama": "CAMA-BIOPSIAS"}[domain]
measure = client.get(f"/{domain}/fhir/Measure/{measure_id}").get_json()
by_name = {}
for extension in measure["extension"]:
by_name.setdefault(extension["url"].rsplit("/", 1)[-1], []).append(extension)
sheet = {e["url"]: e["valueString"] for e in by_name["ficha"][0]["extension"]}
assert sheet["para"] == "Médico" and sheet["pregunta"].startswith("¿Cómo se distribuyen")
if domain == "cacu":
assert measure["relatedArtifact"] == [{
"type": "citation", "display": "European Guidelines for QA in Cervical Cancer Screening, 2ª ed. (2008)",
"citation": "indicador 7"}]
texts = {e["extension"][0]["valueString"]: e["extension"][1:] for e in by_name["figura-detalle"]}
assert set(texts) == {"fig_c2_barras", "fig_c2_donas"}
assert [e["url"] for e in texts["fig_c2_donas"]][:2] == ["descripcion", "como-leer"]
population = measure["group"][0]["population"][0]
assert population["description"].startswith("Pacientes con al menos una citología tomada en el periodo.")