About MEDITECH Reports

 

View John Sharpe's profile on LinkedInI'm your host, John Sharpe, a MEDITECH Consultant living in Spokane, WA. Read more ...

Connect ...

Expand your network by connecting on these social media sites:

Sign up for the MEDITECH Reports Blog; details to attend MEDITECH workshops are sent out 1 week in advance to all MEDITECH Report blog subscribers.

These MEDITECH Workshops are sponsored by Donna Carroll at the MEDITECH Community Bulletin

MEDITECH NPR & RW RESOURCES:

Ascii Table: For NPR Report Writer
Loop Builder: For NPR Macros
Key Codes: For CDS Attributes
List Builder: For NPR Macros
MT Report Names: For NPR Reports
MT Structure Viewer: For Physicals
Strings: Format & Sort

HIT Topics

MEDITECH Reports

Current Articles | RSS Feed RSS Feed

Return Day (Monday) from Date (11/19/2007)

 

Today, we'll format a date (11/19/2007) into readable week day format (Monday) using Meditech's Magic programming language for the Client Server (CS) & Magic platforms.

Put this into a start macro:

"MONDAY"^/DAY^/DAY[/DAY:3T],
"TUESDAY"^/DAY^/DAY[/DAY:3T],
"WEDNESDAY"^/DAY^/DAY[/DAY:3T],
"THURSDAY"^/DAY^/DAY[/DAY:3T],
"FRIDAY"^/DAY^/DAY[/DAY:3T],
"SATURDAY"^/DAY^/DAY[/DAY:3T],
"SUNDAY"^/DAY^/DAY[/DAY:3T]

Call the start macro from the footnote: AL START start

When you run the report, this is what your array looks like in memory:

/DAY["MON"] = "MONDAY"
/DAY["TUE"] = "TUESDAY"
/DAY["WED"] = "WEDNESDAY"
/DAY["THU"] = "THURSDAY"
/DAY["FRI"] = "FRIDAY"
/DAY["SAT"] = "SATURDAY"
/DAY["SUN"] = "SUNDAY"

Put this in your xx.field which will be on the report picture to return a day from a date:

DAT=FREE
JFY=L
LEN=10
VAL=/DAY[%Z.day.out(%Z.day.from.date(@date))]

Walking thru the code:
- @date is returned from the SCH module I'm working in today as: 10/22/07.
- %Z.day.from.date(@date) OR %Z.day.from.date("10/22/07") returns: 2.
- %Z.day.out(%Z.day.from.date(@date)) OR %Z.day.from.date("2") returns: MON.
- /DAY[%Z.day.out(%Z.day.from.date(@date))] OR /DAY["MON"] returns: MONDAY.

You can change the format to match your business needs. Some reports look better with the day formatted as Monday. In that case, your start macro /DAY array would look more like this:

"MON"^/DAY.SUB,"Monday"^/DAY[/DAY.SUB],
"TUE"^/DAY.SUB,"Tuesday"^/DAY[/DAY.SUB],
"WED"^/DAY.SUB,"Wednesday"^/DAY[/DAY.SUB],
"THU"^/DAY.SUB,"Thursday"^/DAY[/DAY.SUB],
"FRI"^/DAY.SUB,"Friday"^/DAY[/DAY.SUB],
"SAT"^/DAY.SUB,"Saturday"^/DAY[/DAY.SUB],
"SUN"^/DAY.SUB,"Sunday"^/DAY[/DAY.SUB]

Your structure now looks like this:

/DAY["MON"] = "Monday"
/DAY["TUE"] = "Tuesday"
/DAY["WED"] = "Wednesday"
/DAY["THU"] = "Thursday"
/DAY["FRI"] = "Friday"
/DAY["SAT"] = "Saturday"
/DAY["SUN"] = "Sunday"

In review, we've formatted a date "11/19/2007" to print as a day in 2 formats "MONDAY" & "Monday". And we've done it only coding our xx.field once!


Happy Monday & Happy Thanksgiving!

Want an alert when the next post is published? Click the phone and Subscribe to the MEDITECH Reports Blog!

Subscribe to the Meditech Blog     

                                                                                                                                                                                                          

Comments

Currently, there are no comments. Be the first to post one!
Post Comment
Name
 *
Email
 *
Website (optional)
Comment
 *

Allowed tags: <a> link, <b> bold, <i> italics