Blogs Home
Monday, September 14, 2020 12:00 PM

T-SQL- Constructing a GL Account string from a BAR payment or adjustment (MT 6.15+)

Written by Thomas Harlan, Reporting Services Team - iatricSystems

RWS Blog- T-SQL-Constructing-a-GL-Account-string-from-BAR-payment-or-adjustment - Blog header July 2020As you work with Meditech BAR 6.15, you may find yourself needing to identify the GL Account that a payment or adjustment posts to. And then… you find that the appropriate field in the non-charge procedure dictionary has a dynamic string definition stored in it, instead of a specific GL Account number.

What you will see is something like this:

("01.5000.",AT,"21")

You might also see a specific account, like:

("01.5000.5017")

In each case this directs Meditech to construct the string by Q-ing (concatenating) the three components together. The AT, notice it is not quoted, is a placeholder that is replaced by the BAR Account Type when the string is processed.

For the single component example, we get: 01.5000.5017 as the output.

For the three component example, however, we get a dynamically generated string like: 01.5000.0121

This tells us that the last part of the account string (0121) is composed of the AT placeholder (component 2) and the third component.

If we are working in the DR, we have to identify what the value in AT needs to be, on a payment/adjustment transaction level. As it happens, this is stored at the facility level in the BAR Account Type dictionary:

BarAcctType_Facilities.FacilityGlRevenue

If we pull in that dictionary, based on the BAR account type, then we can get our missing piece, and then – if we break up the dynamic string appropriately – we can reassemble it all into the proper output:

9-14-20 image 1

9-14-20 image 2

Note that we have to check for overrides at the facility level of the BAR non-charge procedure dictionary, and then we break out the dynamic string into its pieces using IatricPieceFn() [ Source code attached! ]

Also note that you need to search/replace the fdb. references with the name of your M/AT database in the DR before you try out this code.

Extra Credit

Got Magic or C/S? You will find roughly the same data elements in the NPR-based BAR dictionaries.

You could also take this logic and make a scalar function of it, to package it all up and take parameters for: the dynamic string and the BAR account type. Just remember that calling this logic via a function will incur overhead in your query!

And…

As ever, if you need help with MEDITECH DR optimization, reporting, extracting, index creation or analysis please feel free to give your iatricSystems Account Executive a call or email info@iatric.com to discuss how we can help support your team!

RW-HELP-Button-Blue.png