From 40378e1a3477080fad0a6a69fbcca54961a0f8f9 Mon Sep 17 00:00:00 2001 From: Jin-Zhang-Yaoguang <67220802+Jin-Zhang-Yaoguang@users.noreply.github.com> Date: Sun, 31 Dec 2023 11:41:53 +0800 Subject: [PATCH] Create validate.sql update --- .../buildmimic/postgres/validate.sql | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 mimic-iv-note/buildmimic/postgres/validate.sql diff --git a/mimic-iv-note/buildmimic/postgres/validate.sql b/mimic-iv-note/buildmimic/postgres/validate.sql new file mode 100644 index 000000000..737f5f4cc --- /dev/null +++ b/mimic-iv-note/buildmimic/postgres/validate.sql @@ -0,0 +1,28 @@ +WITH expected AS +( + SELECT 'discharge' AS tbl, 331793 AS row_count UNION ALL + SELECT 'radiology' AS tbl, 2321355 AS row_count UNION ALL + SELECT 'discharge_detail' AS tbl, 186138 AS row_count UNION ALL + SELECT 'radiology_detail' AS tbl, 6046121 AS row_count +) +, observed as +( + SELECT 'discharge' AS tbl, COUNT(*) AS row_count FROM mimiciv_note.discharge UNION ALL + SELECT 'radiology' AS tbl, COUNT(*) AS row_count FROM mimiciv_note.radiology UNION ALL + SELECT 'discharge_detail' AS tbl, COUNT(*) AS row_count FROM mimiciv_note.discharge_detail UNION ALL + SELECT 'radiology_detail' AS tbl, COUNT(*) AS row_count FROM mimiciv_note.radiology_detail +) +SELECT + exp.tbl + , exp.row_count AS expected_count + , obs.row_count AS observed_count + , CASE + WHEN exp.row_count = obs.row_count + THEN 'PASSED' + ELSE 'FAILED' + END AS ROW_COUNT_CHECK +FROM expected exp +INNER JOIN observed obs + ON exp.tbl = obs.tbl +ORDER BY exp.tbl +;