BLOGS
EASY SUBSCRIBE


Report Writing

Interoperability and EHR Optimization

Privacy and Security

Writing files from NPR report to a shared folder from a scheduled or submerged report (MAGIC Only)

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

The only "officially supported" mechanism to write a file to a non-MEDITECH machine is to use FTP. This means you need to set up an FTP as a service on the destination machine, which typically involves installing additional software.

It would be much more convenient if you could write files to any Windows PC in the network using a regular windows user ID and password.

It turns out you can. Microsoft has a protocol called "Server Message Block" that allows you to read and write files, created folders, and read directories and MEDITECH has a set of Z programs and OS utilities that support this protocol.

This month I will show you how to use Z.smb.put.raf to write a file from an NPR report to a share using a regular windows user ID and password.

First we need to have a place to keep our Windows user ID and password information. The FTP remote host dictionary is a good place, and at most sites this will hide the password information a bit better than just putting it into our NPR report source code.

NPR Tip

Next, we write an NPR report where we do all output in a macro, which builds lines of data in a memory based RAF. This is similar to the way you can build a MOX message in a temporary RAF and then use MIS.OA.MSG.auto to send a MOX message.

Set up Page 1 as you would a report with no picture and put a program call to a macro in the title:

NPR Tip

The program call in the title is so you can set a flag to suppress the PRINT ON prompt and any report messages. The code in the "setup" macro looks like this:

NPR Tip

(It probably would be okay to set the /Z.SCHED.LOG and /R.NO.RPT.MSGS flag multiple times, but just in case we set the report up to just do it 1x. The title program is executed when the report first displays a selection screen and then as it prints each new page.)

The report has NO PICTURE, just a footnote to call a macro ("detail") for each record. Our demo report just has one selection, where you identify the MIS.FTP remote host where the password and host information is kept:

NPR Tip

NPR Tip

 

In the "detail" macro we send data to a random access structure in memory:

/STUFF[n] = data (including CR/LF)

Note that this technique of writing the data to slash (memory based temp file) should not be used for extremely large records. In our case, each file is only two lines long. If you need to send very large files this way, you would write to an RAF as a disk file in your own directory.

The arguments to the Z.smb.put.raf program are:
A = HOST (ip or server name of the host to send to)
B = USER (windows user id of user with rights to the share)
C = PW (windows password of user in argument B)
D = Share name
E = Path and file name
F = "name of" the raf structure with the data to put in the file
(^/STUFF^F would put the "name of" the RAF into F)

Here is the "detail" macro showing how the lines of data are put into /STUFF[line number] and how the file is transferred to the shared folder.

NPR Tip

IMPORTANT NOTE: Make sure you enable the SHARE for your user on the server. Otherwise you will get an error when MEDITECH attempts to write the file to the share.

The report makes files very fast, far faster than FTP, especially if you have a lot of small files to create:

NPR Tip

A sample MAGIC report has been uploaded to our report library ADM.PAT.zcus.is.smb.transfer

Topics: Server Message Block, Magic, Iatric Systems NPR Report, MEDITECH, scheduled report, Report Writing Tips and Tricks

Subscribe to the Report Writing blog.

Receive the latest articles directly in your inbox.
Enter your email address and click SUBSCRIBE:

Comments

0 COMMENTS