Skip to content

Commit fc00594

Browse files
fix: skip echo height PARSE when time regex misses
Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 0d80d2b commit fc00594

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

mimic-iii/concepts/pivot/pivoted_height.sql

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,16 @@ WITH ht_in AS
8383
subject_id
8484
-- extract the time of the note from the text itself
8585
-- add this to the structured date in the chartdate column
86-
, PARSE_DATETIME('%b-%d-%Y%H:%M',
87-
CONCAT(
88-
FORMAT_DATE("%b-%d-%Y", chartdate),
89-
REGEXP_EXTRACT(ne.text, 'Date/Time: [\\[\\]0-9*-]+ at ([0-9:]+)')
90-
)
91-
) AS charttime
86+
, CASE
87+
WHEN REGEXP_EXTRACT(ne.text, 'Date/Time: [\\[\\]0-9*-]+ at ([0-9:]+)') IS NOT NULL
88+
THEN PARSE_DATETIME('%b-%d-%Y%H:%M',
89+
CONCAT(
90+
FORMAT_DATE("%b-%d-%Y", chartdate),
91+
REGEXP_EXTRACT(ne.text, 'Date/Time: [\\[\\]0-9*-]+ at ([0-9:]+)')
92+
)
93+
)
94+
ELSE NULL
95+
END AS charttime
9296
-- sometimes numeric values contain de-id numbers, e.g. [** Numeric Identifier **]
9397
-- this case is used to ignore that text
9498
, case

0 commit comments

Comments
 (0)