From e0b58896c0eab1e0b9c07ac12e450968096bc3f1 Mon Sep 17 00:00:00 2001 From: Matt Garber Date: Tue, 9 Jan 2024 16:55:04 -0500 Subject: [PATCH] low hanging PR fruit --- cumulus_library/studies/core/builder_prereq_tables.py | 3 --- cumulus_library/studies/core/count_core.py | 2 +- cumulus_library/template_sql/statistics/count.sql.jinja | 2 +- cumulus_library/template_sql/utils.py | 1 - tests/test_counts_templates.py | 2 -- 5 files changed, 2 insertions(+), 8 deletions(-) diff --git a/cumulus_library/studies/core/builder_prereq_tables.py b/cumulus_library/studies/core/builder_prereq_tables.py index 18f66fe9..c31a2da0 100644 --- a/cumulus_library/studies/core/builder_prereq_tables.py +++ b/cumulus_library/studies/core/builder_prereq_tables.py @@ -21,6 +21,3 @@ def prepare_queries(self, cursor: object, schema: str, *args, **kwargs): with open(dir_path / sql_file) as file: queries = sqlparse.split(file.read()) self.queries += queries - self.comment_queries() - self.write_queries() - exit() diff --git a/cumulus_library/studies/core/count_core.py b/cumulus_library/studies/core/count_core.py index 6519a166..3e1f8140 100644 --- a/cumulus_library/studies/core/count_core.py +++ b/cumulus_library/studies/core/count_core.py @@ -1,6 +1,6 @@ from typing import List from pathlib import Path -import cumulus_library.statistics.counts as counts +from cumulus_library.statistics import counts class CoreCountsBuilder(counts.CountsBuilder): diff --git a/cumulus_library/template_sql/statistics/count.sql.jinja b/cumulus_library/template_sql/statistics/count.sql.jinja index 4e80d5f8..d55c40fd 100644 --- a/cumulus_library/template_sql/statistics/count.sql.jinja +++ b/cumulus_library/template_sql/statistics/count.sql.jinja @@ -62,7 +62,7 @@ CREATE TABLE {{ table_name }} AS ( {%- elif fhir_resource=='encounter' and filter_resource %} WHERE s.status = 'finished' {%- elif fhir_resource=='observation' and filter_resource %} - WHERE (s.status = 'final' OR status= 'amended') + WHERE (s.status = 'final' OR s.status= 'amended') {%- endif %} ), {% endif %} diff --git a/cumulus_library/template_sql/utils.py b/cumulus_library/template_sql/utils.py index 9bfa6300..bf2fee05 100644 --- a/cumulus_library/template_sql/utils.py +++ b/cumulus_library/template_sql/utils.py @@ -160,7 +160,6 @@ def _check_schema_if_exists( if cursor.fetchone() is None: return False - cursor.execute(query) schema_str = str(cursor.fetchone()[0]) required_fields = [coding_element] if not allow_partial: diff --git a/tests/test_counts_templates.py b/tests/test_counts_templates.py index c3951684..09806e2d 100644 --- a/tests/test_counts_templates.py +++ b/tests/test_counts_templates.py @@ -169,6 +169,4 @@ ) def test_count_query(expected, kwargs): query = get_count_query("test_table", "test_source", ["age", "sex"], **kwargs) - with open("output.sql", "w") as f: - f.write(query) assert query == expected