BLOGS
EASY SUBSCRIBE


Report Writing

Interoperability and EHR Optimization

Privacy and Security

Migration: Export MOX Using NPR

Written by Joe Cocuzzo, Senior VP of Report Writing Services - iatricSystems

Migration: Export MOX Using NPR

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:

With 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,
IF{O(&,%files);
   O(&,$MAC[$MAC]_D(0,0,1),&,&.TREE,&,&.LIMBS,&,&["OA"],&,&files)}, O(?,&.raf),
IF{A O(*,&U[0]C[4]F[3])};

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:

RWS-Blog-08-2016-Image-8.png

c) The layout of the screen is in /F:

RWS-Blog-08-2016-Image-9.png

So, assuming we want to export this database, we can do it with an NPR report that does this in the start macro:

1^/R.FOUND^/R.PAGE.NUM,
"OA"^MIS.APPL.database,
$["SEGS"](@MIS.APPL.database.segment,@MIS.APPL.database.directory),
O[""](*S,%["files"]),
;/[R.NO.BN.FF] = B
"B"^/R.NO.BN.FF,
C(%U,$U)


Then in a detail macro called as a program (with user and file.urn passed in as A and B)...

A^user,
B^file.urn,
:OAU[user,file.urn,"DOLT"]^{USER,PLATFORM,URN},
*U[USER]C[PLATFORM]F[URN]^POINTER,
O[""](?S,POINTER),
@SEND.HEADER,
@SEND.RECORDS,
C(?U),
EXIT;

SEND.HEADER
-?Q[""]^LAST,
"Rec #"_D(9)^!,
""^FLD,
DO{+(?Q[FLD],DATA)^FLD 1,
DATA|1_IF{FLD<LAST D(9)}^!},
D(13,10)^!

SEND.RECORDS
DO{+?D[REC]^REC 1,
REC_D(9)^!,
""^FLD,
DO{+(?D[REC,FLD],REG)^FLD 1,
IF{?D[REC,FLD,1] @SEND.MULTIPLE;
@SEND.REGULAR}},D(13,10)^!},
@.line

SEND.MULTIPLE
""^MUL,
-?D[REC,FLD,""]^LASTM,
DO{+(?D[REC,FLD,MUL],DATA)^MUL 1,
DO{L(DATA,"^")^p<L(DATA) DATA'#p^DATA},
DATA_IF{MUL<LASTM "^"}^!},
D(9)^!

SEND.REGULAR
REG_IF{FLD<LAST D(9)}^!

If we run the report to download, we see that we get tab delimited records with a ^ between the multiple fields.

RWS-Blog-08-2016-Image-10.png 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 (karen.roemer@iatric.com) to discuss how we can help support your team!

Topics: Report Writing Services, MEDITECH, NPR Tip, Report Writing Tips and Tricks

Subscribe to the Report Writing blog.

Receive the latest articles directly in your inbox.
Enter your email address and click SUBSCRIBE:

Comments

0 COMMENTS