June 13, 2022

Understanding MEDITECH MV Arrays

MV (Multi-Value) Arrays allow for the creation of our own "multiples".  Often the MV array itself is created in an NPR Report  Writer macro which is integrated into the report via the AL Footnote.  User-defined (xx) fields are placed on report lines as though they were any other multiple.  The Line Attribute MV is added to the top line containing the first of the "xx" multiples. 

Here is an example of the steps necessary for creating an MV Array to print the positive integers 1 through 10:

  1.  Set up two Detail lines.
  2.  Create a user-defined field (xx) with the following attributes:

    DAT=FREE
    LEN=5
    VAL=""
    It doesn’t matter what you value you use with your VAL attribute.  You could use VAL=1.  That would make no difference because the MV Line Attribute will overwrite whatever VAL you enter.
  3. Put the xx field on your Detail lines, one on top of the other like you would any other multiple:
    D          xx.field
    D          xx.field
  4. Enter the following Line Attribute on the upper of the two Detail lines:      MV=D
    Make note of what value you use.  In this case, I used D.  You can use whatever value you like, you just have to make note of it.  Tradition has been to use the current Region as your value for this Line Attribute.  Since these lines are in the D Region, I used D as the value.
  5. Use the AL Footnote to integrate a macro into your report.  It would appear as follows:  AL D d
    You can name your macro whatever you like.  In this case, the AL Footnote will integrate a macro called d before the D Region prints.
  6. File and translate your report.
  7. Go back into your report and find the field number for your xx field.  You can find the field number in the lower left-hand portion of the Report Picture screen.  You will need this number later.
  8. Create a macro called ‘d’ with the following code:
    0^NUM,
    DO{@Add(1,NUM)’>10 “Number “_NUM^/MV[“D”,NUM,1]}
    “D” is used here as the primary subscript since that was the value used in the MV Line Attribute.
    1 is used as the third subscript here but it will be whatever field number is used on the Report Picture screen for your xx field.
    NUM is the second subscript which is a unique value to make sure none of your MV array entries is overwritten by another entry.
    Please note that in C/S, MV Arrays are created as /R.MV while in MAGIC they simply use /MV. 
  9. File and translate your macro and then file and translate your report again (you have to retranslate your report after you translate a macro that is integrated via the AL Footnote).

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

You Might Also Enjoy

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

@Translation.message is an NPR Programming Macro that can be used in NPR Report Writer ...

BFI stands for Before Input. BFI attributes can come in pairs, just like FCL attributes. ...

SUB is a Field Attribute not documented on Meditech's website. It allows you to define ...

Create an NPR Report to produce a downloaded file and add the following Footnote: AL ...