Well, that's no ordinary rabbit!

Caution: This has not yet been updated to work with the new spool file graphics format in 5.5

Note: See the MIS.OA.MSG.auto page for an introduction to emailing from attributes and reports.

Sending a scheduled report to a MOX mailbox is possible. If it is a custom report is simply a matter of putting report data in your / variable and calling the OA MSG program (example on MIS.OA.MSG.auto page) in the report trailer or close up macro. For standard reports you need a different approach.

Standard Meditech reports almost always have some kind of graphics commands in them. The email program simply sends these along with the text. Since the email program considers everthing as text the graphics commands need to be removed before sending the message.

The basic steps in the following method of emailing scheduled reports involves scheduling the report you want emailed to a unique spool group and creating a second scheduled report that does these things:

1. Identify the spool file to be sent.
2. Get the spool file from its hiding place (involves opening prefixes)
3. Remove graphics commands and copy the spool file to / file1
4. Reprocess / file1 to remove non-printing characters and save in / file2
5. Send / file2 using the MIS.OA.MSG.auto program

The code below should work for any magic site but I would appreciate any suggestions or improvements anyone has to offer.

Identify the spool file

The easiest way to identify the spool file is to use a unique spool group. If the report gets run once a day it is then as easy as creating a report that finds any spool file for the spool group for a certain date. The report should be in MIS.SPOOL and only needs to select on group and date.created. See the report specifics below.

Get the spool file

Once the report has identified the spool file urn the spool file needs to be retrieved from where Meditech has stored it (%.MIS.spool.rad). This involves opening prefixes so don't ask Meditech for any help on it.

Loop thru the spool file, strip the graphics commands and save in a / file

Get each line from the spool file, run it thru the standard Meditech program Z.rw.strip.graphics to remove any graphics commands, and save the result in / file1.

Reprocess the / file to join split lines and save in a second / file

Meditech splits the spool file into 80 character lines. If the report you want to email is wider that 80 characters lines will need to be concatonated in order to keep the correct output format. This code should work for reports up to 160 characters wide but will need to be modified if the report CPL is greater than that. Save the resulting line in / file2.

Determine the recipients

If the report is being used to email several spool files to different users the report title which is in the first line of the spool file can be used to determine who gets the email.

Send the file


Second Scheduled Report Specifics

This is for the second report, the one that finds and processes the spool file of the report you want emailed. It doesn't need any output, just some selects and a detail macro.

Report:  MIS.SPOOL mis.spool.main
Index: None

1. group    EQ   Group:
2. date.created   EQ   Creation Date:

AL D detail

;--- detail macro ---
;--- clear / files ---
DO{+/MSG[XX]^XX ""^/MSG[XX]},
DO{+/MSG2[XX]^XX ""^/MSG2[XX]},
;--- open the spool file ---
;--- change MEM in the next line to the name of your MIS database
;--- Loop thru the SAFs for the spool file
;--- There is a 0 SAF but the actual spool text begins in SAF 1
DO{+&[urn,SF]^SF ZZ%OP(?,&[urn,SF]),
;--- loop thru the spool file ---
DO{+? ?^BUF,
;--- close the prefixes
;-- search report title for text and load appropriate recipients
IF{L(/MSG[1],"Report 1")<L(/MSG[1]) @LOAD.MSG1;
(/MSG[1],"Report 2")<L(/MSG[1]) @LOAD.MSG2;
;--- call the program to email /file2

;--- load /file2 and the recipients for report 1 into ARG ---

;--- load /file2 and the recipients for report 2 into ARG ---

;--- load /file2 and the recipients for all other reports into ARG ---

;--- define graphics commands
   ;--- use standard Meditech routine to remove graphics commands ---
   IF{L(REC,"~")<L(REC) %Z.rw.strip.graphics(REC_(""^REC),80,1)^REC},
   ;--- use custom routine to remove printer commands and non-printing characters ---

;-- format max 80 characters per line for email
                   L(/MSG[XX]_/MSG[XX+1])>80 /MSG[XX];

The Macro - MIS.zcus.pgm.M.strip.np

This macro strips non printing characters from the string

;--- the following must all be entered on one line.
;--- you can enter it as 2 and then use F6 to join the 2 lines
A'~(D(255):32_" "_"!"_D(34)_"#$%&'"_D(40,41)_"*+,-./0123456789:;<=>?@ABCDEFGHI

Other Magic Pages

CDS Attributes Emailing Messages Emailing Scheduled Reports
@W. prompts String Manipulation NPR Viewer
Text Edit/View Attribute Meds in an NUR CDS NUI Desktop Icons
Field Attributes Lab results in a CDS Ultimate Message Box
Display Message Attributes Run NPR Report Attribute Multiple Query Checklist
NUR Canned Text in Query Mousetributes LAB TEST VIEW GROUP
OA Msg from PHA Rule FTP Standard Report HTML Pt Master Logs
PCI NPR Report

Don't see what you need?  Visit one of these other sites

Iatric Systems web site
NPR tips
NPR reports
Magic and C/S Products
Hosted by Daniel Davis
Resources for the IT Nurse
Articles and Discussion Forum
Debbie Kelly web site
Meditech tips
Nursing Informatics
Debbie Bate-Travis web site
Links to other attribute sites
Links to Nursing Informatics sites
Magic NPR Report Writing
Blogged by John Sharpe
NPR Report Writing Tips

or email me your request (tomt at thomast357.com).