BioEcko Docs
Functional Consultant Training

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:

  1. Data Migration -- Mapping legacy data to Bio Ecko tables requires knowing column names, types, and relationships
  2. Report Interpretation -- BI dashboards query these tables; understanding them helps you validate report accuracy
  3. Troubleshooting -- When a bill shows the wrong amount, knowing that bill_items links to services and tariffs helps you trace the root cause
  4. Configuration -- Master data setup (departments, services, formulary) means populating specific tables correctly
  5. 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:

LevelEntityTableDescription
1OrganizationorganizationsThe hospital/chain. Top-level tenant.
2BranchbranchesPhysical locations within an organization
3DepartmentdepartmentsFunctional units (Cardiology, Lab, Pharmacy)
4UserprofilesStaff members with roles and permissions
5PatientpatientsThe central clinical entity
6Encounterappointments / admissionsOPD visit or IPD stay
7Transactionbills, lab_orders, prescriptionsClinical and financial events

Key Relationships:

  • Every patient belongs to an organization
  • Every appointment links to a patient and a profiles (doctor)
  • Every bill links to a patient and an appointment or admission
  • Every lab_order links to an appointment or admission and a lab_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:

TablePurposeKey Columns
patientsDemographicsmrn, first_name, last_name, dob, gender, phone, abha_number
patient_addressesMultiple addressesaddress_line, city, state, pincode, type (home/work)
patient_contactsEmergency contactsname, relationship, phone
patient_insuranceInsurance coveragetpa_id, policy_number, plan_name, valid_from, valid_to
patient_allergiesAllergy recordsallergen, severity, reaction, reported_by
patient_documentsUploaded filesdocument_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-00001 or BEK/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:

TablePurposeLinks To
appointmentsOPD visit recordspatients, profiles (doctor), departments
admissionsIPD stay recordspatients, beds, profiles (attending doctor)
visit_diagnosesDiagnosis entries (ICD-10)appointments or admissions
prescriptionsMedication ordersappointments or admissions, patients
prescription_itemsIndividual drugs in a prescriptionprescriptions, drug_formulary
vitalsVital signs (BP, pulse, temp, SpO2)patients, appointments or admissions
clinical_notesDoctor's notes (SOAP format)appointments or admissions
proceduresPerformed proceduresadmissions, ot_schedules
discharge_summariesIPD discharge documentationadmissions

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:

TablePurposeKey Columns
billsBill headerbill_number, patient_id, total_amount, discount, net_amount, status
bill_itemsLine itemsservice_id, quantity, rate, amount, tax
paymentsPayment receiptsbill_id, amount, payment_mode, reference_number
servicesService mastername, code, category, department_id
tariffsService pricingservice_id, rate, effective_from, branch_id
insurance_claimsTPA claimsbill_id, tpa_id, claim_amount, approved_amount, status
refundsRefund recordsbill_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:

TablePurposeKey Columns
drug_formularyMedicine mastergeneric_name, brand_name, dosage_form, strength, route
inventory_itemsStock items (meds + consumables)item_name, category, unit, reorder_level
stock_entriesStock in/out transactionsitem_id, batch_number, expiry_date, quantity, type (GRN/issue/return)
purchase_ordersProcurement orderssupplier_id, items, total_value, status
grn (Goods Received Note)Goods receiptpo_id, received_quantity, batch, expiry, verified_by
dispensing_recordsPharmacy dispensingprescription_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

  1. patients.id → referenced by appointments.patient_id
  2. appointments.id → referenced by prescriptions.appointment_id
  3. prescriptions.id → referenced by prescription_items.prescription_id
  4. prescription_items.id → referenced by dispensing_records.prescription_item_id
  5. dispensing_records.id → billing creates a bill_items entry 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 created
  • updated_at -- When last modified
  • created_by -- Which user created it
  • updated_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.

On this page