Architecture¶
ehr2rl is a small package organized by stage of the pipeline. Each
subpackage owns one stage and exchanges data with the others only through
EHRDataset and PatientTrajectory. See
Pipeline for the data flow.
Package layout¶
Package |
Owns |
Key modules |
|---|---|---|
|
Trajectories, datasets, CSV loading and alignment, state construction, feature presets, itemid maps |
|
|
Bounded cohort SQL, guarded query execution, assembling real datasets |
|
|
Medication aggregation, vasopressor dose conversion, dose discretization |
|
|
The |
|
|
Estimating observed action probabilities |
|
|
Adapting datasets to external RL libraries |
|
|
Credential-free synthetic data |
|
|
Provenance records and sidecar files |
|
The built-in itemid map is JSON stored with a .yaml extension and shipped as
package data.
Dependency direction¶
Dependencies point one way, from assembly toward the core:
bigquery ──► actions ──► (pandas, numpy)
│
└──► data ◄── reward, policy, export, testing
export ──► provenance
dataimports nothing else fromehr2rlexcept its own modules.reward,policy,export, andtestingdepend only ondata(andexportonprovenance). They never importbigquery.bigqueryis the only package that combines stages.
Keep it this way: a new reward or exporter should not need anything from
bigquery.
Optional dependencies¶
d3rlpy and the Google Cloud packages are optional extras. They are imported
inside the functions that need them, never at module level, so
import ehr2rl and every submodule work on a base install. The documentation
build relies on this: it imports every public object without either extra.
When a function needs an optional package, catch ImportError and re-raise
with the extra to install, as to_d3rlpy() does.
Public API¶
The supported API is exactly what the __all__ lists export, at the import
paths shown in the API reference. Everything else,
including modules without an underscore prefix, is internal.
ehr2rl/__init__.pyre-exports the most used objects.Each subpackage’s
__init__.pylists its own public objects.ehr2rl.data.itemid_mapsandehr2rl.provenanceare public modules with their own__all__.