Skip to content

Seeders

The CPR backend uses 38 seeder classes to populate the database with initial data and test records.

Running Seeders

bash
# Run all seeders
php artisan db:seed

# Run a specific seeder
php artisan db:seed --class=RoleSeeder

# Fresh migrate and seed
php artisan migrate:fresh --seed

Seeding Order

The DatabaseSeeder runs seeders in this order to satisfy foreign key dependencies:

 1. BranchSeeder              # Clinic branches
 2. RoleSeeder                # Roles and permissions
 3. UserSeeder                # Staff users
 4. InsuranceSeeder           # Insurance plans
 5. MedicineSeeder            # Medicine reference data
 6. PharmacyItemFormSeeder    # Dosage forms
 7. PharmacyItemSeeder        # Pharmacy products
 8. StockAvailableUnitSeeder  # Stock units
 9. StockAvailableSeeder      # Initial stock levels
10. ProcedureSeeder           # Medical procedures
11. BillingItemSeeder         # Billable items
12. SupplierSeeder            # Suppliers
13. PurchaseOrderStatusSeeder # PO status types
14. PaymentMethodSeeder       # Payment options
15. PatientSeeder             # Test patients
16. DoctorRoleSeeder          # Doctor specializations
17. DoctorSeeder              # Doctor profiles
18. SurgeryLocationSeeder     # OR locations
19. SurgeryScheduleSeeder     # Surgery schedules
20. BranchServiceSeeder       # Services per branch
21. BranchServiceCounterSeeder # Queue counters
22. BranchServiceUserSeeder   # Staff-service assignments
23. PurchaseOrderSeeder       # Sample POs
24. DeliverySeeder            # Sample deliveries
25. TransactionSeeder         # Sample transactions
26. StockMovementSeeder       # Stock movement history

Key Seeders

BranchSeeder

Creates 3 clinic branches:

BranchCodeAddress
Main ClinicMAIN123 Healthcare Avenue
Downtown BranchDWTN456 Central Street
North Side ClinicNORTH789 Northern Road

Each branch has operating hours and service configuration stored in the settings JSON column.

RoleSeeder

Creates 7 roles with specific permissions:

RoleKey Permissions
adminFull system access including admin.access
doctorPatient care, consultations, medical records
nursePatient care, vitals, basic records
receptionistAppointments, registration, queue management
pharmacistPharmacy, medication dispensing
lab_technicianLaboratory, test processing
billing_staffBilling, accounts, transactions

Permissions follow the {module}.{action} pattern (e.g., patients.create, pharmacy.read) with 40+ permissions across modules: users, roles, branches, patients, appointments, medical-records, consultations, laboratory, pharmacy, billing, reports, settings, vitals, inventory, admin.

UserSeeder

Creates 11 test users with role and branch assignments:

UserRoleBranchUsername
Admin UseradminMAINadmin
Dr. Sarah ChendoctorMAINdr.chen
Dr. Michael TorresdoctorDWTNdr.torres
Dr. Emily WatsondoctorNORTHdr.watson
Maria SantosnurseMAINnurse.santos
Anna RiveranurseDWTNnurse.rivera
Juan CruzreceptionistMAINrecep.cruz
Lisa ReyesreceptionistDWTNrecep.reyes
Carlos GarciapharmacistMAINpharm.garcia
Mark Johnsonlab_technicianMAINlab.johnson
Grace Leebilling_staffMAINbilling.lee

Default Password

All test users have the password: password

Address Seeders

Philippine geographic data is loaded from CSV files in database/seeders/csv/:

  • Regions, Provinces, Municipalities, Barangays, Zipcodes
  • Used for patient address lookup and validation

Creating New Seeders

bash
php artisan make:seeder ExampleSeeder

Guidelines

  1. Add the new seeder to DatabaseSeeder.php in the correct dependency order
  2. Use model factories where possible for test data
  3. For reference/lookup data, use insertOrIgnore to be idempotent
  4. Always position the seeder call after its foreign key dependencies

CPR - Clinical Patient Records