Useful VistA Programs

From VistApedia
Jump to: navigation, search

The intent of this page is to list useful VistA Programs, some of which don't exist, and some of which could be created easily but have not been created to date.

Iterate through a File

Currently, iterating through a file, with no limitations or filtering on the entries is done by using the MUMPS $ORDER function on a variable just lower than the global root of the file. If there is any way to filter the entries you want, or put an order on the entries you want, such as by the NAME field of the file, this is probably not the best strategy. But it does work.

Note if you are iterating through the file, looking for a particular value for a field that has been cross-referenced, the MUMPS $DATA function is FAR superior to using the MUMPS $ORDER function.

Iterating through a File using a Sort Template

It would be nice to have a program that would take a Sort Template as input, and then each time the "NEXT/EACH" tag is called, would return the next entry in the file in the order that the Sort template would have produced it. This leverages the power of VA FileMan at the MUMPS coding level and allows the end-users to define the order since end-users can define a Sort Template.

There should probably be some checks for sanity, such as specifying the FileMan File that the Sort Template should be using, the name of the Sort Template, and possibly something that is paying attention to security.

Note this could be done (under the covers) by having the INIT/BEGIN tag verify all the input variables, set up a call to EN1^DIP, with a DHIT that would save the entries found in a temporary global in the order that they "print", and then each time the NEXT tag is called, it would look in the temporary global, make sure that INIT had been called to set it up, and then just return the next value in order. It could be an optimization to kill off the previous ordered entries in the list if we know that the caller won't try to back up, or even give them a call so they could back up.

Ultimately the FINAL/END tag would kill of the temporary data structure so we don't waste space.

There should also be some tag to TEST the current entry or retrieve it without advancing the "NEXT" pointer/cursor, so we can use this iteration subroutines as a high level mapping function.