TEA on its new staging: silver load, ten measures answered on request with the status at the period's end, several groups and column strata, and FHIR R4 endpoints for measures, follow-up and patient summary
This commit is contained in:
+10
-2
@@ -6,7 +6,8 @@ cut-offs apply to, and the horizon: a unit without a value whose horizon hasn't
|
||||
measured yet, so it's left out of the initial population. Days are differences of `dim_fecha.dia_num`, computed in
|
||||
dbt's event model; the cut-off's day is looked up the same way. Quartiles are ANSI (`inclusive_quartiles`).
|
||||
|
||||
The event cut-off defaults to the day of the last load, as the horizon needs a day to count to.
|
||||
The event cut-off defaults to the day of the last load, as the horizon needs a day to count to. With a population at
|
||||
the period's end (`webapi.metrics.StatusAtEnd`), a unit's interval has a value only if it ended by the period's end.
|
||||
"""
|
||||
|
||||
import dataclasses
|
||||
@@ -28,6 +29,7 @@ from webapi.metrics import (
|
||||
MeasureQueries,
|
||||
Population,
|
||||
Question,
|
||||
StatusAtEnd,
|
||||
_population,
|
||||
_semantic_model_of,
|
||||
key_of,
|
||||
@@ -90,6 +92,8 @@ class DurationDefinition:
|
||||
rules: dict[str, str]
|
||||
improvement_notation: str | None = None
|
||||
strata: tuple = ()
|
||||
population: StatusAtEnd | None = None
|
||||
meta: dict = dataclasses.field(default_factory=dict, compare=False, hash=False)
|
||||
|
||||
@property
|
||||
def measure_id(self) -> str:
|
||||
@@ -127,7 +131,8 @@ def duration_definitions(manifest: Path) -> dict[str, DurationDefinition]:
|
||||
rule["horizonte"].get("regla"), rule["horizonte"]["dia_inicio"],
|
||||
int(rule["horizonte"]["dias"]) if "dias" in rule["horizonte"] else None),
|
||||
group=meta["grupo"], basis=meta["basis"], rules=dict(meta.get("parametros", {})),
|
||||
improvement_notation=meta.get("improvement_notation"),
|
||||
improvement_notation=meta.get("improvement_notation"), population=StatusAtEnd.of(meta.get("poblacion")),
|
||||
meta=meta,
|
||||
)
|
||||
return definitions
|
||||
|
||||
@@ -145,6 +150,9 @@ class DurationQueries(MeasureQueries):
|
||||
o, q = self.d.observation, self.q
|
||||
conditions = [self._column(o.value).is_not(None)]
|
||||
conditions += [self._column(n) <= q.event_cutoff.isoformat() for n in o.dated_at]
|
||||
if self.status is not None:
|
||||
# Counted at the period's end: the interval has to have ended by then.
|
||||
conditions += [self._column(n) < self.events.c.periodo_fin for n in o.dated_at]
|
||||
if q.knowledge_cutoff is not None:
|
||||
conditions += [self._column(n) <= q.knowledge_cutoff for n in o.known_at]
|
||||
return and_(*conditions)
|
||||
|
||||
Reference in New Issue
Block a user