Blogs Home
Wednesday, August 31, 2011 9:37 AM

NPR Tip: Date/Time Stamp with Seconds (Client/Server or MAGIC)

Written by Joe Cocuzzo, Senior VP of Report Writing Services - iatricSystems

Recently, a vendor receiving two exports of billing data from a MEDITECH system requested a time stamp be included so that if data from the same account appeared in both files, they could pick the more recent record. The MEDITECH scheme of storing the current time as number of seconds since March 1 of 1980 did not appeal to them.

Getting a date/time stamp of the format YYYYMMDDHHMM could be done with a computed field:

NPR Tip 1 image

If you use S(0) directly in your code, the translator will report an error, even though this is a valid MAGIC command, so @.sd is a better choice.

Once we have the value of "NOW" in seconds with @.sd we need to do four things:

Convert NOW into an NPR date (YYYYMMDD)

Convert NOW into an NPR time (HHMM)

Figure out the seconds that are "left over" so we can figure out the SS for a time expressed like this: HH:MM:SS

Format the time with some colons.

This would be daunting, except that we have some handy Z programs that will do most of our work for us.

%Z.date.in.magic(@.sd) will convert the S(0) value into an NPR Date YYYYMMDD

%Z.date.in.magic(@.sd)^DATE

%Z.time.out(@.sd) will convert the S(0) value into an NPR time HHMM

%Z.time.out(@.sd)^TIME

And if we remember (or calculate) that there are 86400 seconds in a day, we can use the \ operator (remainder on division) to figure out the leftover seconds:

If we get the remainder of the current time in seconds divided by 86400, we have the number of elapsed seconds since midnight. Getting the remainder of that value divided by 60 gets the leftover seconds.

@.sd\86400\60^REM

We need to pad the seconds with a leading zero, and %Z.zero.fill will do that as follows:

%Z.zero.fill(REM,2))^REM

Finally, we need to format the time and the leftover seconds with some colons and concatenate the string and return to the calling program:

DATE_" "_(TIME$2)_":"_(TIME%1)_":"_REM;

It is more efficient to get the system time once and put it into a variable, so the code in our utility macro program %Z.zcus.is.time.stamp.M.internal is:

DATE_" "_(TIME$2)_":"_(TIME%1)_":"_REM;

NPR Tip 2 image

A second version %Z.zcus.is.time.stamp.M.external puts the date in MM/DD/YYYY format

To test, call this Z utility from a computed field and place the field on a report. To see the seconds pass between records for this demo, I added a H(1) command to an AL D footnote also.

NPR Tip 3 image

With the H(1) to pause 1 second between records, here is some sample output from the two utilities %Z.zcus.is.time.stamp.M.internal("") on the left and %Z.zcus.is.time.stamp.M.external("") on the right.

NPR Tip 3 image

To save you the trouble of building this utility yourself. I have written both a C/S and a MAGIC version of the Z report that holds this macro. The reports have been placed in our library.
Z.zcus.is.time.stamp

http://www.iatric.com/information/NPRReportLibrarySearch.aspx.

You can find additional NPR Tips on our website at http://www.iatric.com/Information/NPRTips.aspx, as well as information about our on-site NPR Report Writer Training and NPR Report Writing Services.

Upcoming NPR Training Opportunities:

We are pleased to offer NPR Report Writer training sessions at host sites. Details and a course description are available on our website at http://www.iatric.com/Information/Classes.aspx.

Location Level Instructor Date Cost
Greater Baltimore Medical CenterBaltimore, MD Beginner / Intermediate Jim Fahnestock September 13-15, 2011 $750
Greater Baltimore Medical CenterBaltimore, MD Intermediate / Advanced Philip Sherry October 10-12, 2011 $750

To subscribe for email notifications for new classes, please follow this link:

http://www.iatric.com/Information/Classes.aspx

For more information or to reserve a seat, please contact our NPR report writing team at reportwriting@iatric.com.

(This article originally appeared in the August 2011 issue of Iatric Systems’ Updates! newsletter.)