Skip to content

Commit

Permalink
Merge pull request #107 from OHDSI/ladams_add_snowflake_compatability
Browse files Browse the repository at this point in the history
Fix column declaration and enhance regexp_like support for Snowflake
  • Loading branch information
lawrenceadams authored Jan 9, 2025
2 parents 2ea5a6d + 4e473eb commit 87f347e
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 14 deletions.
9 changes: 5 additions & 4 deletions dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: 'synthea_omop_etl'
version: '0.1.0'
name: "synthea_omop_etl"
version: "0.1.0"
config-version: 2

profile: 'synthea_omop_etl'
profile: "synthea_omop_etl"

asset-paths: ["assets"]
docs-paths: ["docs"]
Expand All @@ -13,7 +13,7 @@ seed-paths: ["seeds"]
macro-paths: ["macros"]
snapshot-paths: ["snapshots"]

clean-targets: # directories to be removed by `dbt clean`
clean-targets: # directories to be removed by `dbt clean`
- "target"

vars:
Expand All @@ -34,3 +34,4 @@ seeds:
synthea:
+enabled: true
+schema: synthea_seeds
+quote_columns: true
11 changes: 11 additions & 0 deletions macros/regexp_like.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{%- macro regexp_like(subject, pattern) -%}
{{ return(adapter.dispatch("regexp_like")(subject, pattern)) }}
{%- endmacro -%}

{% macro default__regexp_like(subject, pattern) %}
{{ subject }} ~ '{{ pattern }}'
{% endmacro %}

{% macro snowflake__regexp_like(subject, pattern) %}
regexp_like({{ subject }}, '{{ pattern }}')
{% endmacro %}
2 changes: 1 addition & 1 deletion models/omop/measurement.sql
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ WITH snomed_measurements AS (
, 32827 AS measurement_type_concept_id
, 0 AS operator_concept_id
, CASE
WHEN o.observation_value ~ '^[-+]?[0-9]+\.?[0-9]*$'
WHEN {{ regexp_like("o.observation_value", "^[-+]?[0-9]+\.?[0-9]*$") }}
THEN {{ dbt.cast("o.observation_value", api.Column.translate_type("decimal")) }}
ELSE {{ dbt.cast("null", api.Column.translate_type("decimal")) }}
END AS value_as_number
Expand Down
18 changes: 9 additions & 9 deletions seeds/synthea/_sources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ seeds:
- name: careplans
config:
column_types:
ID: varchar
Id: varchar
START: date
STOP: date
PATIENT: varchar
Expand All @@ -32,7 +32,7 @@ seeds:
- name: claims
config:
column_types:
ID: varchar
Id: varchar
PATIENTID: varchar
PROVIDERID: varchar
PRIMARYPATIENTINSURANCEID: varchar
Expand Down Expand Up @@ -66,7 +66,7 @@ seeds:
- name: claims_transactions
config:
column_types:
ID: varchar
Id: varchar
CLAIMID: varchar
CHARGEID: integer
PATIENTID: varchar
Expand Down Expand Up @@ -121,7 +121,7 @@ seeds:
- name: encounters
config:
column_types:
ID: varchar
Id: varchar
START: timestamp
STOP: timestamp
PATIENT: varchar
Expand All @@ -139,7 +139,7 @@ seeds:
- name: imaging_studies
config:
column_types:
ID: varchar
Id: varchar
DATE: timestamp
PATIENT: varchar
ENCOUNTER: varchar
Expand Down Expand Up @@ -192,7 +192,7 @@ seeds:
- name: organizations
config:
column_types:
ID: varchar
Id: varchar
NAME: varchar
ADDRESS: varchar
CITY: varchar
Expand All @@ -206,7 +206,7 @@ seeds:
- name: patients
config:
column_types:
ID: varchar
Id: varchar
BIRTHDATE: date
DEATHDATE: date
SSN: varchar
Expand Down Expand Up @@ -245,7 +245,7 @@ seeds:
- name: payers
config:
column_types:
ID: varchar
Id: varchar
NAME: varchar
ADDRESS: varchar
CITY: varchar
Expand Down Expand Up @@ -281,7 +281,7 @@ seeds:
- name: providers
config:
column_types:
ID: varchar
Id: varchar
ORGANIZATION: varchar
NAME: varchar
GENDER: varchar
Expand Down

0 comments on commit 87f347e

Please sign in to comment.