Quitar el corte de periodo de las medidas
This commit is contained in:
@@ -78,50 +78,3 @@ def test_the_nci_operation_is_refused_while_the_flag_is_off(client, monkeypatch)
|
||||
monkeypatch.delenv(fhir.NCI_REFERENCE, raising=False)
|
||||
response = client.get("/cacu/fhir/Patient/any/$reference-risk")
|
||||
assert response.status_code == 404
|
||||
|
||||
|
||||
@pytest.mark.parametrize("domain,measure", [("cacu", "cacu-eu7"), ("cama", "cama-birads")])
|
||||
@pytest.mark.parametrize("period", ["2026-02", "2026-S1"])
|
||||
def test_measure_cutoff_recalculates_the_partial_period(
|
||||
monkeypatch, domain, measure, period
|
||||
):
|
||||
from datetime import UTC, date, datetime
|
||||
|
||||
from fastapi import Request
|
||||
|
||||
from core.domains import Domain
|
||||
|
||||
def row(day, person):
|
||||
if domain == "cacu":
|
||||
return {
|
||||
"sample_id": person, "person_id": person, "sample_date": day,
|
||||
"valid": 1, "result": "NILM", "birth_date": "1990-01-01",
|
||||
"screening_history": "never", "detection": "initial", "first_case": None, "first_treatment": None,
|
||||
"first_colposcopy": None, "first_postcolposcopy_cytology": None,
|
||||
"known_at": "2026-02-01", "report_known_at": "2026-02-01",
|
||||
}
|
||||
return {
|
||||
"person_id": person, "exam_date": day, "birads": "4", "birads_rank": 4,
|
||||
"report_date": day, "known_at": "2026-02-01", "report_known_at": "2026-02-01",
|
||||
}
|
||||
|
||||
monkeypatch.setattr(fhir.measure_reads, "rows", lambda *args, **kwargs: [
|
||||
row("2026-02-05", "a"), row("2026-02-20", "b"),
|
||||
])
|
||||
request = Request({"type": "http", "method": "GET", "scheme": "http", "server": ("test", 80),
|
||||
"path": f"/{domain}/fhir/MeasureReport", "query_string": b"", "headers": []})
|
||||
|
||||
def count(cutoff):
|
||||
answer = fhir.search_measure_report(
|
||||
request=request, domain=Domain(domain), measure=measure, periods=period,
|
||||
as_of=datetime(2026, 2, 15, 23, 59, 59, tzinfo=UTC) if cutoff else None,
|
||||
event_cutoff=date(2026, 2, 15) if cutoff else None,
|
||||
period_cutoff=date(2026, 2, 15) if cutoff else None, _count=None, _offset=0,
|
||||
)
|
||||
report = json.loads(answer.body)["entry"][0]["resource"]
|
||||
return report["group"][0]["population"][0]["count"], report["period"]
|
||||
|
||||
uncut, original = count(False)
|
||||
cut, reported = count(True)
|
||||
assert (uncut, cut) == (2, 1)
|
||||
assert original == reported # report retains the requested month or semester
|
||||
|
||||
Reference in New Issue
Block a user