IPeople Blog

Using Command-Line Arguments for Magic Systems

Written by Gary | Nov 3, 2021 5:00:00 AM

Command-Line Arguments can be passed in with your call to the Meditech Remote Workstation.  These Command-Line Arguments can
then be parsed out.

This example will demonstrate how to create your own sign-on Program using an NPR Report Macro.  This Macro will parse out the Command-Line Arguments.  If there are no Command-Line Arguments, then the usual Meditech sign-on Program will be used.  If there are Command-Line Arguments, then PCI will be launched for whichever patient is included in the Command-Line Arguments.  This sort of Sign-On Program can make it possible for another vendor to link automatically to Meditech's PCI from their own software.

The usual Command-Line executed when accessing the Meditech Remote Workstation is:

C:\Program Files\MEDITECH\Workstation3.x\Client.mtad

The Arguments we will be adding will change this Command-Line to appear like this:

C:\Program Files\MEDITECH\Workstation3.x\Client.mtad MIS|UNIT.NUM|USER|FACILITY

There are four Arguments added to the end of the Command-Line.  There is a blank space after the original Command-Line.  The four Arguments are separated by the "pipe" character.  Those Arguments are the mnemonic of the Meditech MIS (MIS), the Patient Unit Number (UNIT.NUM), the MIS User mnemonic (USER), and the MIS Facility mnemonic (FAC).


Here is how the Command-Line would appear with the following Arguments:

MIS                    ARL5.61
UNIT.NUM    M000000305
USER                 SHIJO
FAC                    ARL

C:\Program Files\MEDITECH\Workstation3.x\Client.mtad ARL5.61|M000000305|SHIJO|ARL

Here are the steps for creating an NPR Report Macro to parse out the Command-Line Arguments and launch PCI:

1) Create an NPR Report with Report DPM Z and Report Name zcus.ip.bms.signon.

2) Add any Report Title you like and set the Active Field to Y, and then File and Translate your Report.

3) Add a Report Macro called signon with the following code:

ZZ%O(/,"P"),
%Z.pc(0),
IF{IF{@NOT.A.PC;
      @NOT.A.WORKSTATION;
      @OLD.VERSION;
      @NOT.A.VALID.COMMAND.TAIL} @RUN.REGULAR.MEDITECH.SESSION;
   @CALL.COMMAND.TAIL},
END;

RUN.REGULAR.MEDITECH.SESSION
C(/),
%MIS.signon("")

NOT.A.PC
"Y"'=@.pc

NOT.A.WORKSTATION
DO{># #S},D(31,0,0,192)^#,E(#T[1])^V=2_.=.

OLD.VERSION
D(30)_"V"^#,DO{E(#T[1])^V'=4'=5},#T[V]^V,
V#0<3!(V#0=3&(V<3.21))!((V#0=4)&(V<4.11))

NOT.A.COMMAND.TAIL
D(30)_"CT"^#,E(#T[1])^L,IF{L>0 #T[L]^CMDTL},
IF{@Not(CMDTL);
   CMDTL#"0|"^MIS,
   CMDTL#"1|"^UN,
   CMDTL#"2|"^USER,
   CMDTL#"3|"^FAC,
   @Not(MIS)!@Not(UN)!@Not(USER)!@Not(FAC)}

CALL.COMMAND.TAIL
ZZ%O(\,%.MIS.dic[MIS,"MIS"]),
UN^/[""_"..LAST.UNIT.NUM"],
USER^/[""_".USR"],
FAC^/[""_".FAC"],
%Z.link.to.pci.one.patient(""),
C(\,/)


4) File and Translate the Report Macro.

5) Add your Report Macro as the Sign On Program in OPS for whichever device you like.  

          The Pgm? prompt will be answered with Z.zcus.ip.bms.signon.M.signon

So if the Command-Line Arguments are included, then the user will automatically be brought into PCI.  Otherwise, the regular MEDITEH sign-on Program will be used.