Skip to content

Commit

Permalink
Merge branch 'BRAC-models' into 30-fix-failing-brac-models
Browse files Browse the repository at this point in the history
  • Loading branch information
njuguna-n authored Nov 9, 2023
2 parents 209e467 + 194b3d5 commit f3fa49d
Show file tree
Hide file tree
Showing 11 changed files with 779 additions and 23 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@ dbt_packages/
logs/
*/.env
*/dbt_packages/
tests/.user.yml
dbt-env/*
.user.yml
dbt-env/*
28 changes: 16 additions & 12 deletions dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
# Name your project! Project names should contain only lowercase characters
# and underscores. A good package name should reflect your organization's
# name or the intended use of these models
name: "pipeline"
version: "0.0.1"
name: 'pipeline'
version: '0.0.1'
config-version: 2

vars:
# The `start_date` variable will be accessible in all resources
end_date: '2023-06-01'

# This setting configures which "profile" dbt uses for this project.
profile: "default"
profile: 'default'

# These configurations specify where dbt should look for different types of files.
# The `source-paths` config, for example, states that models in this project can be
# found in the "models/" directory. You probably won't need to change these!
model-paths: ["models"]
analysis-paths: ["analysis"]
test-paths: ["tests"]
seed-paths: ["seeds"]
macro-paths: ["macros"]
snapshot-paths: ["snapshots"]
model-paths: ['models']
analysis-paths: ['analysis']
test-paths: ['tests']
seed-paths: ['seeds']
macro-paths: ['macros']
snapshot-paths: ['snapshots']

target-path: "target" # directory which will store compiled SQL files
target-path: 'target' # directory which will store compiled SQL files
clean-targets: # directories to be removed by `dbt clean`
- "target"
- "dbt_modules"
- 'target'
- 'dbt_modules'

vars:
end_date: "2020-12-12"
Expand Down
74 changes: 74 additions & 0 deletions models/brac/brac.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
version: 2

models:
- name: brac_hmis
columns:
- name: uuid
tests:
- not_null
- unique
- relationships:
to: ref('contactview_chp')
field: uuid
- name: households_registered
tests:
- not_null
- name: num_of_hh_visited
tests:
- not_null
- name: num_of_hh_bed_nets
tests:
- not_null
- name: num_of_hh_latrines
tests:
- not_null
- name: num_of_hh_safe_water
tests:
- not_null
- name: num_of_comm_members
tests:
- not_null
- name: num_of_health_forum
tests:
- not_null
- name: num_pregnant_care
tests:
- not_null
- name: num_pregnant_identified
tests:
- not_null
- name: num_facility_deliveries
tests:
- not_null
- name: num_home_deliveries
tests:
- not_null
- name: brac-kpis
columns:
- name: chp_uuid
tests:
- not_null
- relationships:
to: ref('contactview_chp')
field: uuid
- name: count_all_assessments
tests:
- not_null
- name: u5_malaria_treatment
tests:
- not_null
- name: u5_diarrhea_treatment
tests:
- not_null
- name: u5_pneumonia_treatment
tests:
- not_null
- name: u1_malaria_treatment
tests:
- not_null
- name: u1_diarrhea_treatment
tests:
- not_null
- name: u1_pneumonia_treatment
tests:
- not_null
143 changes: 143 additions & 0 deletions models/brac/contact_views/contact_views.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
version: 2

models:
- name: contactview_person
columns:
- name: uuid
tests:
- not_null
- unique
- relationships:
to: ref('couchdb')
field: doc ->> '_id'
- name: name
tests:
- not_null
- name: patient_id
tests:
- not_null
- name: contactview_person_fields
columns:
- name: uuid
tests:
- not_null
- unique
- relationships:
to: ref('contactview_metadata')
field: uuid
tests:
- dbt_utils.fewer_rows_than:
compare_model: ref('contactview_metadata')
- name: contactview_chw
columns:
- name: uuid
tests:
- not_null
- unique
- relationships:
to: ref('contactview_person_fields')
field: uuid
tests:
- dbt_utils.fewer_rows_than:
compare_model: ref('contactview_metadata')
- dbt_utils.fewer_rows_than:
compare_model: ref('contactview_person_fields')
- name: contactview_chp
columns:
- name: uuid
tests:
- not_null
- unique
- relationships:
to: ref('contactview_chw')
field: uuid
- name: branch_uuid
tests:
- not_null
- name: supervisor_uuid
tests:
- not_null
tests:
- dbt_utils.fewer_rows_than:
compare_model: ref('contactview_metadata')
- dbt_utils.fewer_rows_than:
compare_model: ref('contactview_person_fields')
- name: contactview_muted
columns:
- name: contact_uuid
tests:
- not_null
- unique
- relationships:
to: ref('contactview_metadata')
field: uuid
- name: type
tests:
- not_null
- accepted_values:
values:
[contact, clinic, district_hospital, health_center, person]
- name: mute_status
tests:
- not_null
- name: date
tests:
- not_null
tests:
- dbt_utils.fewer_rows_than:
compare_model: ref('contactview_metadata')
- name: contactview_hospital
columns:
- name: uuid
tests:
- not_null
- unique
- relationships:
to: ref('contactview_metadata')
field: uuid
tests:
- dbt_utils.fewer_rows_than:
compare_model: ref('contactview_metadata')
- name: contactview_hierarchy
columns:
- name: branch_uuid
tests:
- not_null
- relationships:
to: ref('contactview_branch')
field: uuid
- name: chw_uuid
tests:
- not_null
- relationships:
to: ref('contactview_chp')
field: uuid
- name: chw_area_uuid
tests:
- not_null
- name: contactview_branch
columns:
- name: uuid
tests:
- not_null
- unique
- relationships:
to: ref('contactview_hospital')
field: uuid
- name: contactview_clinic
columns:
- name: uuid
tests:
- not_null
- relationships:
to: ref('contactview_metadata')
field: uuid
- name: chw_uuid
tests:
- not_null
- relationships:
to: ref('contactview_chw')
field: uuid
tests:
- dbt_utils.fewer_rows_than:
compare_model: ref('contactview_metadata')
128 changes: 128 additions & 0 deletions models/brac/impact/impact.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
models:
- name: impact_ancview_danger_sign
columns:
- name: uuid
tests:
- not_null
- unique
- name: reported_by
tests:
- not_null
- name: form
tests:
- not_null
- name: impact_ancview_delivery
columns:
- name: uuid
tests:
- not_null
- name: impact_ancview_pregnancy_visit
columns:
- name: uuid
tests:
- not_null
- name: iccmview_assessment_follow_up
columns:
- name: uuid
tests:
- not_null
- unique
- relationships:
to: ref('useview_assessment_follow_up')
field: uuid
- name: form
tests:
- not_null
- accepted_values:
values: ['assessment_follow_up']
- name: iccmview_assessment
columns:
- name: uuid
tests:
- not_null
- relationships:
to: ref('useview_assessment')
field: uuid
- name: form
tests:
- not_null
- name: u1_iccmview_assessment_follow_up
columns:
- name: uuid
tests:
- not_null
- unique
- relationships:
to: ref('useview_assessment_follow_up')
field: uuid
- name: form
tests:
- not_null
- accepted_values:
values: ['assessment_follow_up']
- name: u1_iccmview_assessment
columns:
- name: uuid
tests:
- not_null
- relationships:
to: ref('useview_assessment')
field: uuid
- name: form
tests:
- not_null
- name: impact_pncview_actual_enrollments
columns:
- name: delivery_id
tests:
- not_null
- relationships:
to: ref('useview_postnatal_care')
field: uuid
- name: patient_id
tests:
- not_null
- name: impact_pncview_danger_sign
columns:
- name: uuid
tests:
- not_null
- relationships:
to: ref('useview_postnatal_care')
field: uuid
- name: date_of_event
tests:
- not_null
- name: patient_id
tests:
- not_null
- name: impact_pncview_expected_enrollments
columns:
- name: pregnancy_id
tests:
- not_null
- unique
- relationships:
to: ref('ancview_pregnancy')
field: uuid
- name: patient_id
tests:
- not_null
- name: reported_by
tests:
- not_null
- name: impact_pncview_visit
columns:
- name: uuid
tests:
- not_null
- unique
- relationships:
to: ref('useview_postnatal_care')
field: uuid
- name: form
tests:
- not_null
- name: patient_id
tests:
- not_null
Loading

0 comments on commit f3fa49d

Please sign in to comment.