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:
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.time.out(@.sd) will convert the S(0) value into an NPR time HHMM
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.
We need to pad the seconds with a leading zero, and %Z.zero.fill will do that as follows:
Finally, we need to format the time and the leftover seconds with some colons and concatenate the string and return to the calling program:
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:
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.
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.
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.
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.
|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:
For more information or to reserve a seat, please contact our NPR report writing team at firstname.lastname@example.org.
(This article originally appeared in the August 2011 issue of Iatric Systems’ Updates! newsletter.)