diff --git a/biasanalyzer/database.py b/biasanalyzer/database.py index 2be453a..b3f4713 100644 --- a/biasanalyzer/database.py +++ b/biasanalyzer/database.py @@ -51,6 +51,9 @@ def _initialize(self, db_url, omop_db_url=None): else: raise ValueError("Unsupported OMOP database backend") + # Set self.schema as default schema + self.conn.execute(f"SET schema '{self.schema}'") + self._create_cohort_definition_table() self._create_cohort_table() diff --git a/biasanalyzer/sql.py b/biasanalyzer/sql.py index 05ac55d..a47c7c6 100644 --- a/biasanalyzer/sql.py +++ b/biasanalyzer/sql.py @@ -39,7 +39,7 @@ SELECT age_bin, bin_count, - ROUND(bin_count * 1.0 / SUM(bin_count) OVER (), 4) AS probability -- Normalize to get probability + ROUND(bin_count * 1.0 / SUM(bin_count) OVER (), 2) AS probability -- Normalize to get probability FROM Age_Distribution ORDER BY age_bin ''' @@ -73,7 +73,7 @@ SELECT gender, COALESCE(gender_count, 0) AS gender_count, -- Ensure that NULL gender counts are treated as 0 - ROUND(COALESCE(gender_count, 0) * 100.0 / SUM(COALESCE(gender_count, 0)) OVER (), 2) AS probability + ROUND(COALESCE(gender_count, 0) * 1.0 / SUM(COALESCE(gender_count, 0)) OVER (), 2) AS probability FROM Gender_Distribution ORDER BY gender; '''