March 21, 2022

Using the ID Screen Field Attribute for MEDITECH CS NPR Report Screen lookups

The Process Reports routine has an option for enter/editing Attributes to Screen Field Elements.  It is option # 9.

The ID attribute allows us to specify which program should be used for the "lookup" function of a field.

We can create our own "lookup" programs within NPR Report Macros. 

Here is an example of the steps that can be used for a "lookup" program that uses the Meditech MIS Location Dictionary:

  1. One of your Select Fields should point to the MIS Location Dictionary (MIS.LOCN)
  2. Create a macro called 'lookup' with the following code:

    @SETUP.SPECIAL.FUNCTION,
    @SETUP.LOOKUP.RESTRICTION,
    @SETUP.WINDOW.BUTTONS,
    @SETUP.WINDOW.HEADER,
    @SETUP.WINDOW.TRAILER,
    @SETUP.LOOKUP.DETAILS,
    %Z.id(FILE,A,HEADER,DISPLAY,"AR",TITLE,{"","","","",2,1})^A;

    SETUP.SPECIAL.FUNCTION
    "%(Z)debug(0)"^/ID.SPFN[1]

    SETUP.LOOKUP.RESTRICTION
    "&(G)GGN[CD]|2="_@Z.quote_"D"_@Z.quote^/ID.SEL,
    "Only Department-type Locations are acceptable."^/ID.SEL.MSG

    SETUP.WINDOW.BUTTONS
    {10,"&Top","&Bottom","Pg &Up","Pg &Down","&Exit","&Ok","Debu&g"}^/ID.BUT,
    194^/ID.BUT[1],
    193^/ID.BUT[2],
    132^/ID.BUT[3],
    131^/ID.BUT[4],
    27^/ID.BUT[5],
    148^/ID.BUT,
    1^/ID.BUT[7]

    SETUP.WINDOW.HEADER
    1^/ID.HDR,
    "This lookup provides a list of Department type locations only. "^/ID.HDR[1]

    SETUP.WINDOW.TRAILER
    "1"^/ID.MULT,
    "Please contact John Shipman at Interface People with questions."^/ID.MULT[1],
    "          972-345-4464   John.Shipman@ipeople.com           "^/ID.MULT[2]

    SETUP.LOOKUP.DETAILS
    ^@Root(@MIS.LOCN.main)^FILE,
    "Location":12L_("Description":32L)_("Phone Number":40L)^HEADER,
    "CD:12L_([A,CD]|1:32L)_([A,CD]|16:40L)"^DISPLAY,
    "Department Locations"^TITLE
  3. File and translate your macro.
  4. Add the following ID attribute to your Select Field (using option # 9):
    ID=%DPM.zcus.report.M.lookup(A)
  5. File and translate your screen.

Here is an explanation of most of the code involved in this macro:

Here is the main body of the macro:

@SETUP.SPECIAL.FUNCTION,
@SETUP.LOOKUP.RESTRICTION,
@SETUP.WINDOW.BUTTONS,
@SETUP.WINDOW.HEADER,
@SETUP.WINDOW.TRAILER,
@SETUP.LOOKUP.DETAILS,
%Z.id(FILE,A,HEADER,DISPLAY,"AR",TITLE,{"","","","",2,1})^A;

This macro is called in the standard format for running a program: %DPM.program(ARGUMENTS)

Since the macro is called in this way, the main body of the macro ends with a semi-colon.  Also, the value that the macro
returns is the last value on the last line of the main body of the macro.

SETUP.SPECIAL.FUNCTION, SETUP.LOOKUP.RESTRICTION, SETUP.WINDOW.BUTTONS, SETUP.WINDOW.HEADER, SETUP.WINDOW.TRAILER, and SETUP.LOOKUP.DETAILS are called Local Macros.  Local Macros are small sections of code that are grouped together below the main body of the macro and are used to perform some task.  Local Macros being with their title (the title line does not have a comma at the end of it).  Local Macros are called from the main body of the macro with the @ symbol followed by the Local Macro title and then a comma.

SETUP.SPECIAL.FUNCTION sets up a global variable array called /ID.SPFN is subscripted by the ASCII code for a keystroke.  In this case, if the end-user presses the keystroke for an ASCII code of 1, then the Debugger program is called.  For the purpose of this Lookup program, the ASCII code of 1 is linked to the Debug command button.

SETUP.LOOKUP.RESTRICTION sets up a global variable called /ID.SEL.  In order for an entry to be available in the lookup, it must pass the criteria set up in /ID.SEL.  In this case, the field MIS.LOCN.type must equal "D" (as in Department).  The physical address for the field MIS.LOCN.type is &(G)GGN[ggn]|2.  The Subscript which is within the brackets is replaced with CD. 

/ID.SEL.MSG is also set up and has a message that will appear if the end-user enters an entry that does not pass the criteria in /ID.SEL.

SETUP.WINDOW.BUTTONS sets up a global variable called /ID.BUT which is a queued string.  The first piece is the length of the buttons.  Each subsequent piece is the text to appear on the command button.  The letter of the text that will be underlined and be used to invoke the keyboard shortcut is preceded by an ampersand.

/ID.BUT is also an array that links an ASCII code to the command buttons.  In this case, &Top is the first command button and the ASCII code 194 is linked to it.  194 is the value of the keystroke for <Ctrl><Home>.  The "T" in Top will be underlined and end-users can invoke the command by pressing <Alt><T>.

SETUP.WINDOW.HEADER sets up a global variable called /ID.HDR.  The ID program Z.id will set aside lines at the top of the window to display the contents of the /ID.HDR array.  This is simply free text.

SETUP.WINDOW.TRAILER sets up a global variable called /ID.MULT.  The ID program Z.id will set aside lines at the bottom of the window to display the contents of the /ID.MULT array.  Again, this is simply free text.

SETUP.LOOKUP.DETAILS sets up some general information for the lookup to work correctly.  FILE is a local variable that contains the physical address of the Meditech table to look into.  HEADER contains the string that will appear at the top of the lookup.  DISPLAY contains the data string to display for each entry in the lookup table.  CD represents the entry in each record of the lookup table.  A represents whatever table is used as FILE.  In this case, [A,CD]|1 represents the field MIS.LOCN.name, and [A,CD]|16 represents the field MIS.LOCN.phone.number.  TITLE contains the title to appear at the top of the lookup window.

Z.id is the standard lookup program.  The 7th argument is a queued string.  The 2 sets up two lines at the bottom of the screen for the /ID.MULT array.  The 1 sets up the line at the top of the screen for the /ID.HDR array.

Topics: MEDITECH, Report Writing, NPR Report, CS System

You Might Also Enjoy

Select the Report DPM NPR.PROC Enter a report name (any name you like) Page 1 will need a ...

Select the Report DPM NPR.DOLT Enter a report name (any name you like) Page 1 will just ...

Steps: Select the Report DPM NPR.DOLT Enter a report name (any name you like) Page 1 will ...

NPR.SEG.id.editor is a very useful routine in MEDITECH's C/S software that provides handy ...

@Pgm.name is an NPR Programming Macro that can come in handy, especially when using the ...