Recently a MEDITECH hospital wanted to export a handful of MOX databases, since they were migrating away from MOX. I have done a few of these in the past on rare occasions (on a “per database” basis), and most of the programming time was spent on mapping and cleanup — not on the actual extraction of the data itself.
In this blog post, I’ll discuss how I figured out how to write a generic export in an NPR report, so savvy NPR programmers can do this for themselves in the future.
All I remembered from my past work is that MEDITECH keeps MOX databases in the old “$T OA” directory in a single random access file per each database. So, I knew that the way to get to the data was to open a prefix to this structure in an NPR report — and then I could export the data.
Unfortunately, MOX NPR reports do not keep a prefix open to the OA data, so it takes some poking around to figure out how to get over to the database file. I thought it might be interesting to Report Writers to see how I figured out where everything lives and how to write a generic export inside an NPR report.
Step 1 was to write a quick export for a range of users of all databases and the file urn of the database. That is just like this:
Then I made a small database and included some “multiple” type fields — if you put a question mark below a field prompt, that field becomes a multiple:
I created a couple of records in the database with boring but descriptive data in the records and fields.
Running the database/file urn report showed me that my new database was file.urn = 30.
Where does that data go??
Over in MOX, files are kept in a structure :OAU[user,urn]:
If we go to the “Front End” using a report that called %FEC or %Z.fec, and then go to the MOX segment and directory, and type “OPEN MOX”, we can do a “G” (get) and look at :OAU where we see this for “IATRIC” and file.urn = 30.
The interesting info is in the “DOLT” (dollar T) node that isn’t shown in the data definition, but looks like it gets us over to the database file on the “DOLT” directory:
But where are those files?
Going over to the $T directory (MIS.APPL.database = “OA”), I took a look at the “O” program to see that there is a structure &files that looked like the place where the data is kept.
"OA %O Open Prefixes",97.01.07.2000,
Using the $T editor, I looked at a few of the "DB" programs and figured out that the database pointers are in this structure:
The three subscripts in the structure “IATRIC”, “NPR”, and the 3 correspond to what we see in the “DOLT” node in MOX so it looks like we can use the OAU data to open a prefix to the pointer and get to the database raf.
If we open the RAF, we see:
a) The data is in the D node.
b) The field names are in the Q node:
c) The layout of the screen is in /F:
So, assuming we want to export this database, we can do it with an NPR report that does this in the start macro:
;/[R.NO.BN.FF] = B
Then in a detail macro called as a program (with user and file.urn passed in as A and B)...
If we run the report to download, we see that we get tab delimited records with a ^ between the multiple fields.
If you need more help…
Our Report Writing team can help you fix reports, create new ones, and make old ones faster. Simply reach out to your Iatric Systems Account Executive or Karen Roemer (firstname.lastname@example.org) to discuss how we can help support your team!