July 4, 2022

Sending Downloaded Files via FTP in MEDITECH CS NPR Report Writer

  1. Create an NPR Report to produce a downloaded file and add the following Footnote:    AL CLOSE.UP close.up
  2. File and Translate your report.
  3. Create a Report Macro called close.up with the following code:

    IF{@Not(@Z.rpt.found);
       /R.HALTED;
       @.on.device'="DOWNLOAD";
       @Not(@Z.rpt.download.path);
       %Z.rw.close.up(0),
       "USER"^USR,
       "PASSWORD"^PWD,
       @Z.rpt.download.path^LFN,
       "IP ADDRESS"^RMH,
       "/FOLDERS/FILENAME"^RFN,
       {LFN,"FTP://"_USR_":"_PWD_"@"_RMH_RFN}@Internet.put.file @W.return(LFN_" SENT!");
       @W.return(LFN_" FAILED TO SEND!")},
    @Translation.message("***** PLEASE RETRANSLATE YOUR REPORT *****")
  4. Replace "USER" with the user for accessing the FTP server.

    Replace "PASSWORD" with the password for accessing the FTP server.

    Replace "IP ADDRESS" with the IP Address of the FTP server.

    Replace "/FOLDERS/FILENAME" with the name of the Remote Filename.

    File and Translate your Report Macro and then Retranslate your Report.

    When running your report, the close.up Macro will try to send your Downloaded file via FTP.  This occurs after the End of Report message appears.  You will receive a pop-up window message informing you if the file was sent or failed to be sent.

    AL is a Footnote used to integrate a Report Macro into your Report.  In this case, the Report Macro close.up will be integrated into your Report at the end of the Report.  CLOSE.UP occurs at the end of the Report.

    The Report Macro close.up makes use of an IF Statement to determine whether or not the downloaded file should be sent via FTP.

    Condition:    @Not(@Z.rpt.found)

    If no records are found, then there is no need to send the file.  @Z.rpt.found is a Global Variable (also represented by /R.FOUND) which is set up if at least one record is found.  @Not is an NPR Programming Macro that returns a non-nil value if the Argument has a nil value.  So if there is NOT a value for Z.rpt.found, then the IF Statement ends at that point.

    Condition:    /R.HALTED

    If there is a value for the Global Variable /R.HALTED, then the IF Statement ends at that point.  /R.HALTED is set up if the end-user chooses to halt the normal operation of the Report.

    Condition:    @.on.device'="DOWNLOAD"

    If the Print Destination chosen is NOT EQUAL to "DOWNLOAD", then the IF Statement ends at that point.  The Not Equal Operator is '=.  @.on.device is a Global Variable (also represented by /.PRT) used to store the response to the Print Destination.

    Condition:    @Not(@Z.rpt.download.path)

    The path chosen for a downloaded file is stored in the Global Variable @Z.rpt.download.path.  So the IF Statement ends at this point if there is no value for @Z.rpt.download.path.

    Code:        %Z.rw.close.up(0)

    Z.rw.close.up is an NPR Procedure used at the end of every Report.  It is designed to finish the printing process.  In this case, it completes the download of the report data from the Meditech server to the client.

    Code:        {LFN,"FTP://"_USR_":"_PWD_"@"_RMH_RFN}@Internet.put.file

    @Internet.put.file is an NPR Programming Macro used to copy the contents of a Local File to a Remote File.  Most NPR Programming Macros use this syntax:    @NPR.Macro(ARGUMENTS)

    @Internet.put.file uses this syntax:    {ARGUMENTS}@Internet.put.file

Topics: MEDITECH, NPR Report, CS System

You Might Also Enjoy

You can modify your report so that everything that prints is sent to your Windows ...

You can use the following steps to write data to your Windows clipboard from an NPR ...

You can send emails from a CDS in CS but you must have the Meditech Parameters set up to ...

The Footnote FD (Field Delimiter) requires you to enter the ASCII code for a keystroke. ...

Command-Line Arguments can be passed in with your call to the Meditech Remote ...