dags: the timeline is always read with an explicit known_until
known_until is the build's conocida_hasta or, when the build has none, the moment of the read; it's a node, so the run can record it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+12
-5
@@ -5,11 +5,13 @@ which tables a model depends on (`persistance.assets.validate` with them as sour
|
||||
are inputs too: whoever builds the driver passes a domain's `cohorte_repository` and a
|
||||
`timeline_repository` already bound to its query.
|
||||
|
||||
The timeline is cut at the build's clinical date (`datos_as_of`) and at what had been loaded when the
|
||||
build was made (`conocida_hasta`), so reading it again gives the build's input.
|
||||
The timeline is cut at the build's clinical date (`datos_as_of`) and always at an explicit load cut-off
|
||||
(`known_until`): the build's `conocida_hasta`, or the moment of the read when the build has none. The run
|
||||
records `known_until`, so the read can be repeated once silver keeps its history.
|
||||
"""
|
||||
|
||||
from dataclasses import fields
|
||||
from datetime import datetime, timezone
|
||||
|
||||
import pandas as pd
|
||||
from persistance.aristas.oro import CohortBuild, CohortMember, CohorteRepository
|
||||
@@ -36,9 +38,14 @@ def members(cohorte_miembro: Asset, cohort_repository: CohorteRepository, cohort
|
||||
return pd.DataFrame(cohort_repository.members(cohort_build.armado_id), columns=list(MEMBER_COLUMNS))
|
||||
|
||||
|
||||
def timeline(linea_de_tiempo: Asset, members: pd.DataFrame, cohort_build: CohortBuild,
|
||||
def known_until(cohort_build: CohortBuild) -> datetime:
|
||||
"""The load cut-off of the read: the build's `conocida_hasta`, or now (UTC) when the build has none."""
|
||||
return cohort_build.conocida_hasta or datetime.now(timezone.utc)
|
||||
|
||||
|
||||
def timeline(linea_de_tiempo: Asset, members: pd.DataFrame, cohort_build: CohortBuild, known_until: datetime,
|
||||
timeline_repository: TimelineRepository) -> pd.DataFrame:
|
||||
"""The members' events (`TIMELINE_COLUMNS`), cut at the build's `datos_as_of` and `conocida_hasta`."""
|
||||
"""The members' events (`TIMELINE_COLUMNS`), cut at the build's `datos_as_of` and at `known_until`."""
|
||||
rows = timeline_repository.read(patients=members["pac_id"].tolist(), until=cohort_build.datos_as_of,
|
||||
known_until=cohort_build.conocida_hasta)
|
||||
known_until=known_until)
|
||||
return pd.DataFrame(rows, columns=list(TIMELINE_COLUMNS))
|
||||
|
||||
Reference in New Issue
Block a user