Well, that's no ordinary rabbit!

FTP'ing Standard Meditech Reports

Meditech MAGIC v4.8 introduced the FTP type spool group which makes FTP'ing reports automatically easy provided the report is a custom report where you can make sure there are no graphics or printer commands. To FTP a standard report a little more work is required.

Standard Meditech reports almost always have some kind of graphics commands in them. The FTP program simply sends these along with the text. In order to send a clean FTP file the graphics commands need to be removed before the file is sent.

The basic steps in the following method of FTPing standard reports involves scheduling the report you want FTP'ed 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 save the new text in a / file
4. Reprocess the / file to get it in the correct line format and store it in an MV array
5. Use the MV array as the second report output.
6. FTP the second spool file

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 a / file.

Reprocess the / file to join split lines and save in an MV array

Meditech splits the spool file into lines with a maximum of 80 character when storing it in a saf. Loop thru the lines concatonating them until a carriage return is found. Save the resulting line in an MV array.

Use the MV array as the second report output

Create an xx.field that has LEN equal to the width of the standard report and use it as to print the MV array.

FTP the second spool file

This can be done by either spooling the report to an FTP type spool group or using the FTP spool file routine.

Second Scheduled Report Specifics

This is for the second report, the one that finds and processes the spool file of the report you want FTP'ed. It only needs a couple selects, a detail macro and an MV array. This assumes only one spool file will meet the criteria. If there are more then all will be combined into a single spool file in the second report, probably not what you want.

DPM's
Report:  MIS.SPOOL mis.spool.main
Index: None

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

Footnotes
AL D detail

Output - An MV array
xx.field
DAT=FREE
LEN=width of standard report
VAL=1

NOTE: This code has not been updated to work with the new graphics format in 5.5.

; -- detail macro
""^XX,
DO{+/MSG[XX]^XX ""^/MSG[XX]},
CL(&S),
;-- open a prefix to where the spool file info is stored
ZZ%OP(&,%[".MIS.spool.rad",/.MIS,"MIS"]),
;-- each page of the spool file is stored in a separate saf
;-- loop thru the pages, open the corresponding saf and process it
""^PGN,
DO{+&[urn,PGN]^PGN ZZ%OP(?S,&[urn,1]),
""^SL,
DO{+? ?^BUF,
@PROCESS.LINE},
CL(?U)},
CL(&U),
@LOAD.MV

PROCESS.LINE
;-- the spool file might contain graphics commands.
;-- check for them and remove them using Z.rw.strip.graphics program
;-- add a space to the beginning of any lines that begin with a carriage return
;-- since a line in an MV array cannot be nil
IF{L(BUF,"~*","~g","~H","~G","~Z")<L(BUF);
BUF^REC,
IF{L(REC,"~")<L(REC) %Z.rw.strip.graphics(REC_(""^REC),@cpl,1)^REC},
IF{L(REC,D(13))=0 " "}_REC^/MSG[XX+1^XX]}

LOAD.MV
;-- spool safs are limited to 80 characters per line
;-- lines might need to be combined to recreate the correct output.
;-- this is done by combining lines until one is found that ends with a carriage return
;-- the report will add its own CR/LF at the end of every line
;-- so remove the CR/CL before storing LINE in the MV array
""^XX^QQ,
DO{+/MSG[XX]^XX LINE_IF{L(/MSG[XX],D(13))<L(/MSG[XX]) /MSG[XX];
/MSG[XX]_/MSG[XX+1^XX]}^LINE,
IF{L(LINE,D(13))<L(LINE) LINE$(L(LINE,D(13)))^/MV["D",QQ+1^QQ,1],
""^LINE}}

Download a sample report (new format for late 4.9 and higher releases)
Download a sample report (old format for 4.9 and lower releases)


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
Attributes
NPR tips
NPR reports
Magic and C/S Products
ITNurse.net
Hosted by Daniel Davis
Resources for the IT Nurse
Articles and Discussion Forum
Debbie Kelly web site
Attributes
Meditech tips
Nursing Informatics
Debbie Bate-Travis web site
Attributes
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).