Cubex Billing Sync
Purpose
Cubex Billing Sync (CBS) gets billing charges out of CUBEX and adds them into VMIS updating inventory, creating medical records, and adding invoice charges.
How it Works
CBS polls CUBEX every minute for the three CUBEX servers. It is designed as a multi-step process to ensure transactions are not missed. Below list out the steps taken.
Contact CUBEX for new charges. System_error CBS uses CUBEX’s API to request new charges. CUBEX only sends back charges that we have not received in the past.
Save new charges to the local file system. System_error CBS takes the new charges from CUBEX and immediately save them to the file system under
/unprocessed-logs/{{DATABASE NAME}}/
.Process each charge file. System_error file_error CBS scans the
/unprocessed-logs/
folder for files. It takes these files and logs them into the VMIS database withincubex_billing_log
. It then pulls out each transaction and adds an additional log in the VMIS database withincubex_billing_log_transaction
. Once fully processed CBS moves the file into/processed-logs/{{DATABASE NAME}}/
.Process each transaction. SYSTEM_ERROR CBS then queries the
cubex_billing_log_transaction
for any unprocessed transactions processing them. while it processes the transaction CBS will log, link, and track all records created by CBS for a given transaction.
Handling System Errors system_error
A system error happens when CBS did not properly predict the situation causing CBS to fail. These typically relate to:
Inproper Setup - CBS internal folder structure is not properly setup.
File Storage - If the local drive runs out of memory.
Parsing Data - If data comes in from CUBEX that was in an unexpected format.
Database Access - CBS cannot communicate with the database.
In all cases CBS will immediately send an email to help desk with the error(s) thrown and when / where in the code it happened. If it deals with processing files it will include the billing charges.
Handling File Errors File_error
A file error happens when CBS has already created the CUBEX charges file but fails at processing the file.
These typically relate to:
Network Issues - When CBS cannot access the network to connect to the database.
Permission Issues - When CBS loses its access to the resources it needs.
SQL Query Issues - When CBS fails to setup the SQL queries properly.
These errors are typically due to something outside of the control of CBS. With that in mind, CBS will create a new file under /retry-logs/.
CBS will then attempt to retry the same action 10 times. After 10 failures, CBS will create a helpdesk ticket as well as email the hospital of the issue. The email will include the file in issue as well as all 10 exceptions thrown. CBS will move the log from /retry-log/
to /resolved-retry-logs/
or /failed-logs/
when it is successful or fails 10 attempts.
Resolving Issues
Technical Notes
The code is built around settings stored My.Settings
and is written in VB.Net 4.8. The program runs on the server eadu.cvm.tamu.edu as a scheduled task with the name Cubex Billing Sync. All files and code are stored in the C drive under C:/Cubex_Billing_Sync/
.
The program supports command line arguments as commands. The Cubex Billing Sync task uses the following command line arguments:
retry sa-download la-download tomo-download sa-process la-process tomo-process process-transactions
Command | Purpose |
---|---|
| Calls |
| Finds all unprocessed logs within the correct sub folder of |
| Finds all |
| Retries any failed log found in |
| [Untested] Clears log files that are one year or older. |
CUBEX is partitioned into three different catalogs. Each catalog is assigned a database number.
Database Number | Name |
---|---|
1 | Smal Animal |
2 | Large Animal |
3 | TOMO |
CBS stores CUBEX transactions in:
eadu.cvm.tamu.edu Server
C:/CUBEX_SYNC_LOG/unprocessed-logs/{{database-name}}/
- Each file is a separate call toCUBEX.GetBilling
. The file name includes[database_number]--[sequence_number]--[cubex-date].xml
. Each of these files store the raw data that comes fromCUBEX.GetBilling
.C:/CUBEX_SYNC_LOG/processed-logs/{{database-name}}
- Once a file is processed it is moved from unprocessed to here.NOTE: Logs that fail are still moved and an additional log is created under
./retry-logs/
housing the payload and all exceptions related to the file.
VMIS Database -
production
|devtest
cubex_billing_log
- Stores the raw data sent form CUBEX along with several other fields to help determine which CUBEX database it relates to.cubex_billing_log_transaction
- Stores each transaction within the file along with common fields from the file for ease of use. This links to the log and any other record it may create via foreign keys.NOTE: Fields are prefixed with either
cubex_
orvmis_
to state the originator of the data.
CBS communicates with:
VMIS Database
cubex_billing_log
: INSERT | UPDATE | SELECTcubex_billing_log_transaction
: INSERT | UPDATE | SELECTsp_cubex_transaction
: EXECUTE - Creates the records and updates the log.