Documentation IndexFetch the complete documentation index at: /llms.txtUse this file to discover all available pages before exploring further.
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
End-to-end Sentinel CDM walkthrough with the sample PostgreSQL database.
Your Python code → register connector + connect → EventFrame / Cohort → IR → SQLAlchemy SQL → PostgreSQL sample (diagnosis / procedure / dispensing / …)
Register connector
import encodebox as eb eb.register_connector("connectors/postgres_local_sentinel/connector.yml")
Connect (returns Database)
db = eb.connect( "postgres", host="localhost", port=5433, database="encodebox_sample", username="postgres", password="postgres", connector="postgres_local_sentinel", )
pixi run db-up
Query events
diabetes = ( db.diagnosis .matching("E11", code_type="10", match="starts_with") ) df = diabetes.to_df() print(diabetes.to_sql())
index = ( diabetes .occurring(at_least=2, gap_days=30) .with_index_date() .first_per_patient() ) df_index = index.to_df()
Build a cohort
cohort = ( eb.Cohort("t2dm", database=db) .entry(index, index="first") .include(db.demographic.age_at_index(18, 89)) .include(db.enrollment.covering_index(days_before=365, days_after=0)) .exclude(db.diagnosis.matching("C", match="starts_with"), window=(-365, 0)) ) print(cohort.attrition()) final = cohort.to_df()
.to_sql()
.explain()