From a9bc3095986cd2d966f04f17590bb5a3eb27cea9 Mon Sep 17 00:00:00 2001 From: Maria Lorena Rodriguez Viruel Date: Fri, 17 Nov 2023 17:15:58 -0300 Subject: [PATCH] Add audit for impact PNC view and delivery relationship and organize folders --- .../impact_pncview_visit_delivery_audit.sql} | 14 ++++--- .../audits/impact_pncview_visit_pnc_audit.sql | 38 +++++++++++++++++++ 2 files changed, 46 insertions(+), 6 deletions(-) rename models/brac/impact/PNC/{impact_pncview_visit_audit.sql => audits/impact_pncview_visit_delivery_audit.sql} (54%) create mode 100644 models/brac/impact/PNC/audits/impact_pncview_visit_pnc_audit.sql diff --git a/models/brac/impact/PNC/impact_pncview_visit_audit.sql b/models/brac/impact/PNC/audits/impact_pncview_visit_delivery_audit.sql similarity index 54% rename from models/brac/impact/PNC/impact_pncview_visit_audit.sql rename to models/brac/impact/PNC/audits/impact_pncview_visit_delivery_audit.sql index dcbdbd51..c7365d48 100644 --- a/models/brac/impact/PNC/impact_pncview_visit_audit.sql +++ b/models/brac/impact/PNC/audits/impact_pncview_visit_delivery_audit.sql @@ -1,12 +1,13 @@ {# in dbt Develop #} -{% set old_useview_postnatal_care %} +{% set old_pncview_actual_enrollments %} select - uuid, + delivery_id as uuid, patient_id, - form -from dbt.useview_postnatal_care + facility_delivery, + delivery_date +from dbt.pncview_actual_enrollments {% endset %} @@ -14,13 +15,14 @@ from dbt.useview_postnatal_care select uuid, patient_id, - form + facility_delivery, + delivery_date from {{ ref("impact_pncview_visit") }} {% endset %} {{ audit_helper.compare_queries( - a_query=old_useview_postnatal_care, + a_query=old_pncview_actual_enrollments, b_query=new_impact_pncview_visit, primary_key="uuid" ) }} diff --git a/models/brac/impact/PNC/audits/impact_pncview_visit_pnc_audit.sql b/models/brac/impact/PNC/audits/impact_pncview_visit_pnc_audit.sql new file mode 100644 index 00000000..58e5d4bc --- /dev/null +++ b/models/brac/impact/PNC/audits/impact_pncview_visit_pnc_audit.sql @@ -0,0 +1,38 @@ +{# in dbt Develop #} + + +{% set old_useview_postnatal_care %} +select + uuid, + patient_id, + form, + reported_by, + reported_by_parent, + reported::DATE AS pnc_visit_date, + follow_up_count AS pnc_visit_number, + reported, + baby_danger_signs <> '' AS visit_with_danger_sign +from dbt.useview_postnatal_care +{% endset %} + + +{% set new_impact_pncview_visit %} +select + uuid, + patient_id, + form, + reported_by, + reported_by_parent, + pnc_visit_date, + pnc_visit_number, + reported, + visit_with_danger_sign +from {{ ref("impact_pncview_visit") }} +{% endset %} + + +{{ audit_helper.compare_queries( + a_query=old_useview_postnatal_care, + b_query=new_impact_pncview_visit, + primary_key="uuid" +) }}