Skip to content

Commit

Permalink
Merge pull request #1687 from Jin-Zhang-Yaoguang/main
Browse files Browse the repository at this point in the history
add validate.sql for mimic-iv-note
  • Loading branch information
alistairewj authored Aug 25, 2024
2 parents 3185933 + 40378e1 commit 563ac8a
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions mimic-iv-note/buildmimic/postgres/validate.sql
Original file line number Diff line number Diff line change
@@ -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
;

0 comments on commit 563ac8a

Please sign in to comment.