MEDITECH DR, NPR, MEDITECH Reporting, MEDITECH Reports, MEDITECH DR Reports, MEDITECH BI, MEDITECH Data Repository
I'm your host, John Sharpe, a MEDITECH Consultant living in Spokane, WA. Read more ...
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
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
Current Articles | RSS Feed
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 startWhen 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=FREEJFY=LLEN=10VAL=/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!
An anonymous reader posted this elegant tip:",Sun,Mon,Tues,Wednes,Thurs,Fri,Satur"#(%Z.day.from.date(@date)_",")_"day"
Return current time: %Z.time.out(S(0))Return yesterday’s date as YYYYMMDD: %Z.date.in("T-1"). Return yesterday’s date as: MM/DD/YY: %Z.date.out(%Z.date.in("T-1")).Return a date from 4 days ago as YYYYMMDD: %Z.date.in.magic(@.sd-(86400*4)).Return first day of the current month: %Z.date.in.magic(@.sd)^/D,/D$6_"01"^/DATE.Return the number of days since the first day of the current month:%Z.date.in.magic(@.sd)$6_"01"^/MON.START.DATE,%Z.date.in.magic(@.sd)^/TODAY,%Z.date.sub(/TODAY,/MON.START.DATE)^/MTD.DAYSReturn Start & Stop Date for Last 3 Months:%Z.date.add(@.today$6_"01","0-1")^DATE^STOP.DATE,%Z.date.add(DATE$6_"01","0-1")^DATE,%Z.date.add(DATE$6_"01","0-1")^DATE,DATE$6_"01"^START.DATE
"Report Printed: "_(%Z.date.out(@.today))_" "_/R.TIME)