craig villacorta dot com

//

Selecting a Date and Time Range in NPR

Posted by craigvillacorta on 080507

As you know, Meditech stores Dates and Times in separate fields. If you wanted to write a report to select records between specific dates/times, it’s a little more complex than using the “BETWEEN” keyword like SQL. Here’s an example to select patients admitted between a specific date and time range:

Setup your report to Select on a date range as usual:

admit.date
GE
FROM DATE

admit.date
LE
THRU DATE

Add the following Select Fields as well:

xx.time.1
IG
FROM TIME

xx.time.2
IG
THRU TIME

xx.check
EQ
1

Now define the following fields:

xx.time.1
DAT=HHMM
LEN=4
VAL=c.xx.time.1

xx.time.2
DAT=HHMM
LEN=4
VAL=c.xx.time.2

xx.check
DAT=FREE
LEN=1
VAL=IF{@admit.date_._@admit.time’<(b.admit.date_._c.xx.time.1)’>(e.admit.date_
VAL=._c.xx.time.2) 1}

This method works because dates are stored internally in Meditech in the format YYYYMMDD, and times are stored in the format HHMM. Your xx.check field concatenates the two values and treats them as numeric values allowing a simple numeric comparison.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>