Difference between revisions of "Setting up a VISTA Printer"

From VistApedia
Jump to: navigation, search
m
(Moved newer method to top of page)
Line 2: Line 2:
  
  
== 1.) VistA output to a temporary linux file: ==
+
=== GT.M pipe for print DEVICE: ===
 +
 
 +
With the introduction of the pipe device to GT.M (version V5.3-003) this simple, secure, and elegant method can be used:
 +
 
 +
                  NAME: HP-PHOTOSMART                   
 +
                    $I: <pipe>
 +
      PRE-OPEN EXECUTE: X "o ""p"":(command=""lpr"")::""pipe"" s IO=""p"""
 +
    POST-CLOSE EXECUTE: X "c ""p"""                 
 +
                SUBTYPE: P-OTHER80
 +
                  TYPE: OTHER
 +
 
 +
Note: We use TYPE:Other rather than Host File Server. No host file needed; output will be "piped" to the default CUPS printer. Also the fancy stuff is in the PRE-OPEN EXECUTE. Thus one could do:
 +
 
 +
      PRE-OPEN EXECUTE: X "o ""p"":(command=""lpr -P Photosmart_@192.168.5.103 -o cpi=12 -o lpi=8 -o page-left=72"")::""pipe"" s IO=""p"""
 +
 
 +
In human (ok in geekspeak), this last PRE-OPEN EXECUTE says, "Open a pipe device named "p" with the command to print to the CUPS printer named "Photosmart_@192.168.5.103" with the previously mentioned details set, and then set IO to that device." FileMan will then send his output to IO. Finally the POST-CLOSE just closes the pipe. No Linux /tmp/print.txt file to clean up. No fuss, no muss. '''What's not to love?!?!'''
 +
 
 +
--[[User:JohnLeoZ|gra'pa Z]] 22:30, 12 Aug 2009 (CDT)
  
(But see here [[GT.M pipe for print DEVICE:]] for the better way to print, neat and clean without the temporary file kludge.) JL.Z
 
 
----
 
----
'''A.) Calls to Routine ^TMGPRNTR'''
+
 
 +
=== VistA output to a temporary linux file: ===
 +
 
 +
Below is an older way of setting up a linux printer.
 +
'''Calls to Routine ^TMGPRNTR'''
 
   
 
   
Here is my DEVICE file entry:
+
Here is the DEVICE file entry:
 
   
 
   
 
                         NAME: S121-LAUGHLIN-LASER
 
                         NAME: S121-LAUGHLIN-LASER
Line 19: Line 39:
 
                       SUBTYPE: P-OTHER80           
 
                       SUBTYPE: P-OTHER80           
 
                         TYPE: HOST FILE SERVER
 
                         TYPE: HOST FILE SERVER
 
 
------------------------------------------
 
  
 
Here are the supporting calls to routine ^TMGPRNTR that create a file for writing, and then send the output file to the Linux lpr system
 
Here are the supporting calls to routine ^TMGPRNTR that create a file for writing, and then send the output file to the Linux lpr system
 
  
 
  GETJOBNM()
 
  GETJOBNM()
Line 77: Line 93:
 
         quit
 
         quit
 
    
 
    
 
+
----
---------------------------------------------------------------------------
+
=== '''Bare bones print via a Linux /tmp/file''' ===
---------------------------------------------------------------------------
 
 
 
'''B.) Bare bones print via a Linux /tmp/file'''
 
  
 
On a Linux system with CUPS.
 
On a Linux system with CUPS.
 
  
 
                   NAME: PRINTSERVER                       
 
                   NAME: PRINTSERVER                       
Line 94: Line 106:
 
                   TYPE: HOST FILE SERVER
 
                   TYPE: HOST FILE SERVER
  
 
----
 
 
And for an elaboration of this method  
 
And for an elaboration of this method  
  
Line 110: Line 120:
  
 
----
 
----
----
 
 
== 2.) [[GT.M pipe for print DEVICE:]] ==
 
 
With the introduction of the pipe device to GT.M (version V5.3-003) this simpler, more secure, even elegant method can be used:
 
 
                  NAME: HP-PHOTOSMART                   
 
                    $I: <pipe>
 
      PRE-OPEN EXECUTE: X "o ""p"":(command=""lpr"")::""pipe"" s IO=""p"""
 
    POST-CLOSE EXECUTE: X "c ""p"""                 
 
                SUBTYPE: P-OTHER80
 
                  TYPE: OTHER
 
 
 
Note: We use TYPE:Other rather than Host File Server. No host file needed; output will be "piped" to the default CUPS printer. Also the fancy stuff is in the PRE-OPEN EXECUTE. Thus one could do:
 
 
      PRE-OPEN EXECUTE: X "o ""p"":(command=""lpr -P Photosmart_@192.168.5.103 -o cpi=12 -o lpi=8 -o page-left=72"")::""pipe"" s IO=""p"""
 
 
In human (ok in geekspeak), this last PRE-OPEN EXECUTE says, "Open a pipe device named "p" with the command to print to the CUPS printer named "Photosmart_@192.168.5.103" with the previously mentioned details set, and then set IO to that device." FileMan will then send his output to IO. Finally the POST-CLOSE just closes the pipe. No Linux /tmp/print.txt file to clean up. No fuss, no muss. '''What's not to love?!?!'''
 
 
     
 
 
--[[User:JohnLeoZ|gra'pa Z]] 22:30, 12 Aug 2009 (CDT)
 

Revision as of 14:06, 13 August 2009

Back to Programming VistA Issues


GT.M pipe for print DEVICE:

With the introduction of the pipe device to GT.M (version V5.3-003) this simple, secure, and elegant method can be used:

                  NAME: HP-PHOTOSMART                     
                    $I: <pipe>
      PRE-OPEN EXECUTE: X "o ""p"":(command=""lpr"")::""pipe"" s IO=""p"""
    POST-CLOSE EXECUTE: X "c ""p"""                  
               SUBTYPE: P-OTHER80
                  TYPE: OTHER
 

Note: We use TYPE:Other rather than Host File Server. No host file needed; output will be "piped" to the default CUPS printer. Also the fancy stuff is in the PRE-OPEN EXECUTE. Thus one could do:

      PRE-OPEN EXECUTE: X "o ""p"":(command=""lpr -P Photosmart_@192.168.5.103 -o cpi=12 -o lpi=8 -o page-left=72"")::""pipe"" s IO=""p"""

In human (ok in geekspeak), this last PRE-OPEN EXECUTE says, "Open a pipe device named "p" with the command to print to the CUPS printer named "Photosmart_@192.168.5.103" with the previously mentioned details set, and then set IO to that device." FileMan will then send his output to IO. Finally the POST-CLOSE just closes the pipe. No Linux /tmp/print.txt file to clean up. No fuss, no muss. What's not to love?!?!

--gra'pa Z 22:30, 12 Aug 2009 (CDT)


VistA output to a temporary linux file:

Below is an older way of setting up a linux printer. Calls to Routine ^TMGPRNTR

Here is the DEVICE file entry:

                        NAME: S121-LAUGHLIN-LASER
                          $I: <TO BE SET IN PRE-OPEN EX.>    
        LOCATION OF TERMINAL: Laughlin_Office
 SUPPRESS FORM FEED AT CLOSE: YES   
                 PAGE LENGTH: 70                   
            PRE-OPEN EXECUTE: SET IO=$$GETJOBNM^TMGPRNTR()
          POST-CLOSE EXECUTE: DO FINISH^TMGPRNTR("laughlin_laser")
                     SUBTYPE: P-OTHER80          
                        TYPE: HOST FILE SERVER

Here are the supporting calls to routine ^TMGPRNTR that create a file for writing, and then send the output file to the Linux lpr system

GETJOBNM()
       ;"Purpose: To create a unique printer job name.  
       ;"        This will be used during a printing process
       ;"        that writes the printer file to the host file system, 
       ;"        then passes file to Linux
       ;"        printing system.
       ;"Output: Returns name of file to put output into
       
       ;"UNIQUE will generate a filename based on time and job number
       ;"    i.e. 'Print-Job-628233034.tmp
       
       ;"write !,"here in GETJOBNM^TMGPRNTR",!
       new cJobs set cJobs="PRINT JOBS"
       new Filename set Filename=$$UNIQUE^%ZISUTL("/tmp/Print-Job.tmp")
       
       ;"Now store Filename for later transfer to Linux lpr
       new index set index=$order(^TMP("TMG",cJobs,$J,""))
       if index="" set index=1
       set ^TMP("TMG",cJobs,$J,index)=Filename
       
       ;"write !,"Print job name will be:",Filename,!
       quit Filename   ;"result returned by altering Filename


FINISH(Printer)
       ;"Purpose: to complete the printing process by sending the now-created file
       ;"        to Linux CUPS (the printing system).
       ;"Note: The lpr system itself will delete this print file when 
       ;"      done (option -r)
       ;"Input: Printer OPTIONAL -- the name of the linux printer to send the job to.
       
       new cJobs set cJobs="PRINT JOBS"
       new index set index=$order(^TMP("TMG",cJobs,$J,""))
       new Filename set Filename=$get(^TMP("TMG",cJobs,$J,index))
       
       close IO
       kill IO(1,IO)
        
       kill ^TMP("TMG",cJobs,$J,index)
       if Filename'="" do
       . new CmdStr
       . set CmdStr="lpr "
       . if $get(Printer)'="" set CmdStr=CmdStr_"-P "_Printer
       . ;"option -r --> lpr deletes file after printing done.
       . set CmdStr=CmdStr_" -r "_Filename_" &"
       . ;"write !,"Here is where I call:",!,"ZSYSTEM "_CmdStr,!
       . zsystem CmdStr
       . ;"write "Back from zsystem.  Returning to Fileman.",!
       
       quit
 

Bare bones print via a Linux /tmp/file

On a Linux system with CUPS.

                  NAME: PRINTSERVER                      
                    $I: /tmp/vistaprint.txt
  LOCATION OF TERMINAL: lpr           
            OPEN COUNT: 1
    POST-CLOSE EXECUTE: X "ZSYSTEM ""lpr -r /tmp/vistaprint.txt"""
               SUBTYPE: P-OTHER80                 
                  TYPE: HOST FILE SERVER

And for an elaboration of this method

                  NAME: HP-PHOTOSMART                     
                    $I: <TO BE SET IN PRE-OPEN EXECUTE>
      PRE-OPEN EXECUTE: S IO="/tmp/"_$J_"print.txt"
    POST-CLOSE EXECUTE: X "ZSYSTEM ""lpr -P Photosmart_@192.168.5.103 -r /tmp/""_$J_""print.txt"""
               SUBTYPE: P-OTHER80
                  TYPE: HOST FILE SERVER

Note: This DEVICE does not require the calls to ^TMGPRNTR. And, by exposing the lpr call in the POST-CLOSE EXECUTE, it allows more flexibility. For example, this relatively simple change will direct output to the default CUPS printer with 12 characters/inch, 8 lines/inch and a 1 inch left margin. :

     POST-CLOSE EXECUTE: X "ZSYSTEM ""lpr -o cpi=12 -o lpi=8 -o page-left=72 -r /tmp/""_$J_""print.txt"""