RA Import & Billing Upload Utility

Internal Documentation

This document describes how the RA Import and Billing Upload utility works, how data flows through the system, and the design decisions behind it.

1. Purpose

This utility is designed to safely ingest financial data into MySQL so it can later be used for reconciliation, reporting, and invoice generation.

Current scope:

Out of scope (by design):

2. Technology Stack

3. Folder Structure

/ra-import/
├── index.php              (RA text import UI)
├── parse.php              (RA parser)
├── csv_index.php          (Billing upload UI)
├── billing_preview.php    (Preview before commit)
├── billing_commit.php     (Final DB insert)
├── db.php                 (Database connection)
├── vendor/                (Composer dependencies)
└── docs/
    └── index.html         (This documentation)

4. Database Tables

4.1 Doctors

Stores individuals (doctors) used to tag RA transactions.

ColumnDescription
doctor_idPrimary key
doctor_nameDoctor’s name
emailEmail address
oh_percentOverhead percentage
is_activeActive flag
created_atCreation timestamp

4.2 RA Transactions

Stores raw RA data, tagged to a single doctor per import.

ColumnDescription
transaction_typeAdvance / Reduction
transaction_dateRA posting date
amountNormalized amount
messageRA description
doctor_idForeign key to doctors

4.3 Billing CSV Extracts

Stores billing data uploaded from CSV or Excel. Patient names are masked before storage.

Full patient names are never stored in the database.

5. RA Text Import Flow

  1. User selects a doctor
  2. User pastes RA text
  3. System parses each line
  4. Dates and amounts are normalized
  5. All rows are saved with the selected doctor
One doctor per import is an intentional design choice to avoid ambiguity.

6. Billing Upload Flow (CSV / Excel)

  1. User uploads CSV or Excel file
  2. File is parsed but not saved
  3. Patient names are masked
  4. Preview table is shown
  5. User confirms import
  6. Data is inserted into the database
Nothing is written to the database until the user confirms.

7. Patient Name Masking

Patient names are converted to initials to reduce PHI exposure.

OriginalStored
TAM, IRENE CHI WAIT, I.C.W.
JAVIER, FILIPINAJ, F.

Masking happens:

8. Excel Support

Excel (.xlsx) is preferred over CSV because it preserves:

Excel support is provided using PhpSpreadsheet.

9. Preview → Commit Safety Model

10. Known Limitations

11. Recommended Future Enhancements

12. Design Philosophy

Ingestion should be boring, predictable, and auditable.
Intelligence belongs on top of clean data — not inside ingestion.