Data Model Primer
Key database tables, relationships, and data patterns in Bio Ecko -- a non-developer guide for functional consultants to understand how data is structured...
February 2026 · 16 min
Manual area
FC Training Programme
Coverage
8 sections
Operator notes
3 implementation notes
Why an FC Needs to Know the Data Model
You will not write SQL queries. But understanding the data model is essential for:
- Data Migration -- Mapping legacy data to Bio Ecko tables requires knowing column names, types, and relationships
- Report Interpretation -- BI dashboards query these tables; understanding them helps you validate report accuracy
- Troubleshooting -- When a bill shows the wrong amount, knowing that
bill_itemslinks toservicesandtariffshelps you trace the root cause - Configuration -- Master data setup (departments, services, formulary) means populating specific tables correctly
- Integration -- HL7/FHIR mappings reference specific table columns
Think of the data model as the blueprint of the building you are furnishing. You don't build the walls, but you need to know where the rooms are.
Core Entity Hierarchy
Bio Ecko's data model follows a clear hierarchy:
| Level | Entity | Table | Description |
|---|---|---|---|
| 1 | Organization | organizations | The hospital/chain. Top-level tenant. |
| 2 | Branch | branches | Physical locations within an organization |
| 3 | Department | departments | Functional units (Cardiology, Lab, Pharmacy) |
| 4 | User | profiles | Staff members with roles and permissions |
| 5 | Patient | patients | The central clinical entity |
| 6 | Encounter | appointments / admissions | OPD visit or IPD stay |
| 7 | Transaction | bills, lab_orders, prescriptions | Clinical and financial events |
Key Relationships:
- Every
patientbelongs to anorganization - Every
appointmentlinks to apatientand aprofiles(doctor) - Every
billlinks to apatientand anappointmentoradmission - Every
lab_orderlinks to anappointmentoradmissionand alab_test(from the test catalogue)
Patient Data Tables
The patient is the centre of the entire data model. Here are the key patient-related tables:
| Table | Purpose | Key Columns |
|---|---|---|
patients | Demographics | mrn, first_name, last_name, dob, gender, phone, abha_number |
patient_addresses | Multiple addresses | address_line, city, state, pincode, type (home/work) |
patient_contacts | Emergency contacts | name, relationship, phone |
patient_insurance | Insurance coverage | tpa_id, policy_number, plan_name, valid_from, valid_to |
patient_allergies | Allergy records | allergen, severity, reaction, reported_by |
patient_documents | Uploaded files | document_type, file_url, uploaded_by |
MRN (Medical Record Number):
- Auto-generated unique ID for each patient within an organization
- Format is configurable (e.g.,
MRN-2026-00001orBEK/12345) - Once assigned, an MRN never changes -- it is the patient's permanent identifier
- Duplicate MRN detection is built-in to prevent the same patient from getting two records
Clinical Data Tables
Clinical data captures what happens during patient encounters:
| Table | Purpose | Links To |
|---|---|---|
appointments | OPD visit records | patients, profiles (doctor), departments |
admissions | IPD stay records | patients, beds, profiles (attending doctor) |
visit_diagnoses | Diagnosis entries (ICD-10) | appointments or admissions |
prescriptions | Medication orders | appointments or admissions, patients |
prescription_items | Individual drugs in a prescription | prescriptions, drug_formulary |
vitals | Vital signs (BP, pulse, temp, SpO2) | patients, appointments or admissions |
clinical_notes | Doctor's notes (SOAP format) | appointments or admissions |
procedures | Performed procedures | admissions, ot_schedules |
discharge_summaries | IPD discharge documentation | admissions |
FC Insight: The visit_diagnoses table is critical for ABDM compliance, insurance claims, and clinical analytics. Ensure ICD-10 coding is enforced (not free text) during configuration.
Financial Data Tables
Financial tables track the revenue cycle:
| Table | Purpose | Key Columns |
|---|---|---|
bills | Bill header | bill_number, patient_id, total_amount, discount, net_amount, status |
bill_items | Line items | service_id, quantity, rate, amount, tax |
payments | Payment receipts | bill_id, amount, payment_mode, reference_number |
services | Service master | name, code, category, department_id |
tariffs | Service pricing | service_id, rate, effective_from, branch_id |
insurance_claims | TPA claims | bill_id, tpa_id, claim_amount, approved_amount, status |
refunds | Refund records | bill_id, amount, reason, approved_by |
Tariff System: A service can have multiple tariffs -- one per branch, one per insurance plan, one for self-pay patients. The billing engine picks the correct tariff based on the patient's context. During configuration, you must set up tariffs carefully -- pricing errors are the #1 source of billing complaints.
Inventory & Pharmacy Tables
Pharmacy and inventory share a common stock management backbone:
| Table | Purpose | Key Columns |
|---|---|---|
drug_formulary | Medicine master | generic_name, brand_name, dosage_form, strength, route |
inventory_items | Stock items (meds + consumables) | item_name, category, unit, reorder_level |
stock_entries | Stock in/out transactions | item_id, batch_number, expiry_date, quantity, type (GRN/issue/return) |
purchase_orders | Procurement orders | supplier_id, items, total_value, status |
grn (Goods Received Note) | Goods receipt | po_id, received_quantity, batch, expiry, verified_by |
dispensing_records | Pharmacy dispensing | prescription_id, item_id, batch_used, quantity_dispensed |
FEFO (First Expiry First Out): Bio Ecko enforces FEFO for pharmacy dispensing -- the batch closest to expiry is dispensed first. This is critical for medication safety and waste reduction.
Relationships -- How Tables Connect
Understanding foreign keys (links between tables) is the most important data model concept for an FC:
Example Chain: Patient → Visit → Prescription → Dispensing → Billing
patients.id→ referenced byappointments.patient_idappointments.id→ referenced byprescriptions.appointment_idprescriptions.id→ referenced byprescription_items.prescription_idprescription_items.id→ referenced bydispensing_records.prescription_item_iddispensing_records.id→ billing creates abill_itemsentry linked to the dispensing
Why This Matters:
- If you delete a patient (rare, but possible), all their appointments, prescriptions, and bills are affected
- If a service tariff is wrong, every bill item using that tariff is wrong
- If a drug in the formulary has an incorrect generic name, every prescription referencing it inherits the error
FC Rule: Fix master data errors immediately when discovered. The longer wrong master data stays, the more transactions it corrupts.
Audit Trail and Soft Deletes
Bio Ecko uses two data integrity patterns:
Audit Columns (on every table):
created_at-- When the record was createdupdated_at-- When last modifiedcreated_by-- Which user created itupdated_by-- Which user last modified it
Soft Deletes (on critical tables):
Instead of physically deleting records, Bio Ecko sets a deleted_at timestamp. The record remains in the database but is hidden from the UI. This is essential for:
- Regulatory compliance (medical records must be retained)
- Audit trails (who deleted what and when)
- Recovery (accidentally deleted records can be restored)
FC Relevance: When a user says "I deleted a patient record by mistake," the data is not lost. A super-admin can restore soft-deleted records from the admin panel.
Notes
Info
You do not need to memorize all 319 tables. Focus on the 30-40 tables in the core chain: patients → encounters → clinical data → billing → payments. These cover 80% of your work.
Tip
During data migration, always start with the 'parent' tables (organizations, departments, users, patients) before loading 'child' tables (appointments, bills, lab orders). The database enforces this order via foreign key constraints.
Warning
Never directly modify database records using SQL tools in production. Always use the Bio Ecko admin interface. Direct SQL changes bypass audit trails, RLS policies, and business validations.
Related topics
FC Training Programme
This training programme is designed to take a complete fresher -- someone with no prior healthcare or ERP background -- and transform them into a confident...
Bio Ecko Platform Architecture
A non-technical guide to Bio Ecko's technology stack, module organization, real-time capabilities, and infrastructure -- everything an FC needs to confidently...
Role & Permission Model
How Bio Ecko's 14-role system works -- role hierarchy, permission matrices, Row Level Security, multi-branch access, and configuration guidelines for...
Insurance Claims
Bio-Ecko manages the complete insurance claims lifecycle -- from patient eligibility verification at registration through pre-authorization, claim submission...
Prescriptions
The Prescriptions module lets you write, manage, and print prescriptions. Prescriptions are typically created during an OPD visit but can also be managed...
Appointments
The Appointments module manages your clinic's schedule. You can book appointments for registered patients, view your daily/weekly calendar, manage time slots...
Bio Ecko Platform Architecture
A non-technical guide to Bio Ecko's technology stack, module organization, real-time capabilities, and infrastructure -- everything an FC needs to confidently...
Role & Permission Model
How Bio Ecko's 14-role system works -- role hierarchy, permission matrices, Row Level Security, multi-branch access, and configuration guidelines for...