Setting up a VISTA Printer

From VistApedia
Revision as of 22:49, 24 October 2016 by Lindamry (talk | contribs) (Avoiding the Staircase effect when printing from GT.M/Cache on *Nix with Laser Printers)
Jump to: navigation, search

Back to Programming VistA Issues

This is an updated page. See this page for old content.

Setting Up a Printer in VISTA

In order to set-up a printer in VISTA, there are three steps:

  • Add printer to CUPS or to Windows Printer list. The printers may be on remote servers, as long as the VISTA machine can access them.
  • In VISTA, you need to create an entry that represents the printer formatting characteristics in the terminal type file (#3.2)
  • Then you need to create an entry in the device file (#3.5) that corresponds to the printer

In practice, you don't need to do the second step because there are only about 5 commonly used subtypes in VISTA which you reuse.

A Subtype is a file entry that contains the code to send to the printer, to open the printer, reset the printer, select the page size, adjust the margins, select the font etc.

Subtypes

Information about subtypes, including the most common subtypes, is listed here.

Cache/Windows printing

When you specify a printer name in $I, Cache/Windows sends raw input directly to the printer, bypassing the driver. This makes setting up a printer on Windows easy:

NAME: BROTHER                           $I: |PRN|\\VXQA\HL2270DW
  LOCATION OF TERMINAL: QA              SUBTYPE: P-HP-LASER
  TYPE: TERMINAL

As you can see, all you have to do is put the printer name after |PRN| in $I. You can specify local printers; or you can specify shared printers using a UNC path (as shown above).

Cache/Linux printing

You can use Pipes in Cache to print on Linux/Unix. Here's an operative example. Based on my experience, this is the best way to do it.

NAME: SAM'S PHARMACY PRINTER            $I: /usr/bin/lpr -PSAN_FL6 -l
  OPEN PARAMETERS: "QW"                 SUBTYPE: P-HPLJ4SI-P12
  TYPE: TERMINAL

Please note that there is a bug in DEVOK^%ZOSV (ZOSVONT) that prevents it from checking the device properly. This will show up if you misconfigure a device and then use it in Taskman. Short of fixing this, here is how to remove the bad prints from Taskman:

S (DEV,ZTIME,ZTSK)="" F  S DEV=$O(^%ZTSCH("IO",DEV)) Q:DEV=""  F  S ZTIME=$O(^%ZTSCH("IO",DEV,ZTIME)) Q:'ZTIME  F  S ZTSK=$O(^%ZTSCH("IO",DEV,ZTIME,ZTSK)) Q:'ZTSK  D DQ^%ZTLOAD

You can also use the method developed but not adopted by the VA in patch XU*8.0*585. After attempting to use this method in production, I would recommend against it, because a. CPRS and BCMA code is not configured to pick up PQ devices and b. %ZISC has issues with PQ devices. I have fixed both of these issues; but the code for this is not in VISTA yet.

Here's a sample device that uses the XU*8.0*585 method:

NAME: PRINTER_NAME                          $I: PRINTER_NAME
  PURGE OLD PRINT QUEUE FILES: YES      LOCATION OF TERMINAL: Cups Device
  SUBTYPE: P-HP-LTR-POR-C17L7-W128-NOFF TYPE: PRINT QUEUE

GT.M/Linux printing

Pipes again; just like Cache.

NAME: PHAR-IP-DM                        $I: PHAR-IP-DM
  LOCATION OF TERMINAL: Inpatient Pharmacy Dot-Matrix
  OPEN PARAMETERS: (shell="/bin/sh":comm="lpr -l -P PHAR-IP-DM 2>/dev/null":WRITEONLY)::"pipe"
  SUBTYPE: P-EPSON-DM-P15-5L
  TYPE: TERMINAL


NAME: PHAR-IP-LS                        $I: PHAR-IP
  LOCATION OF TERMINAL: Inpatient Pharmacy Landscape
  OPEN PARAMETERS: (shell="/bin/sh":comm="lpr -P PHAR-IP -l":WRITEONLY)::"pipe"
  SUBTYPE: P-HPLJ4SI-P13-LS
  TYPE: TERMINAL


NAME: PHAR-IP-POR-P12                   $I: PHAR-IP
  LOCATION OF TERMINAL: Inpatient Pharmacy Portrait (PL)
  OPEN PARAMETERS: (shell="/bin/sh":comm="lpr -P PHAR-IP -l":WRITEONLY)::"pipe"
MNEMONIC: PL
  SUBTYPE: P-HPLJ4SI-P12                TYPE: TERMINAL


NAME: PHAR-IP-POR-P16                   $I: PHAR-IP
  LOCATION OF TERMINAL: Inpatient Pharmacy Portrait (MAR)
  OPEN PARAMETERS: (shell="/bin/sh":comm="lpr -P PHAR-IP -l":WRITEONLY)::"pipe"
MNEMONIC: MAR
  SUBTYPE: P-HPLJ2-P16                  TYPE: TERMINAL

How does printing from VISTA work?

How does this work? The way this works is that $I becomes the IO variable. The open parameters tells VISTA how to open the device.

Vista does this:

S IO=[$I]
S param=[OPEN PARAMETERS]
O IO:param
U IO
Send Open Execute from Subtype
U IO(0)
Interact with user; open another job, etc...
U IO
write write write
Send Close Execute from Subtype
C IO
etc.

No need to do pre-open and post-close executes on the device which dynamically changes IOs.

Avoiding the Staircase effect when printing from GT.M/Cache on *Nix with Laser Printers

For an explanation of the Staircase effect, see this: http://www.digitalissues.co.uk/html/os/unix/stair.html

Basically, the new line doesn't include a carriage return, so our output just flows off the page. So when you print a 10 line document, you may only see one line, as the rest was printed outside of the margin.

If you are sending raw output (lpr with the -l option) from VISTA to any PCL compatible printer (and VISTA by and large uses PCL for formatting plain text output), you need to add this to your open execute:

W $C(27),"&k2G"

This tells the PCL compatible printer to append a CR to each LF or FF.

On the other hand, if you are asking CUPS to handle the formatting (lpr without the -l option), CUPS properly formats the line returns through a CUPS filter, so you don't have to do anything.

Advanced printing topics

Advanced printing topics