
I built a web portal for a pharmacy network that combines online medication ordering, assortment and inventory management, intake/consultation scheduling (pharmacists/provisors/pick-up points), and supplier management. The solution is based on Yii2 with a focus on reliability, scalability, and a clear role-based access model.
Technologies: PHP 8+, Yii2, MySQL, HTML, CSS, Bootstrap, Yii2-queue (as needed), Redis/Cache (where applicable).
Business Requirements
- An online storefront with up-to-date stock levels, prices, and availability statuses (in stock/on order/low stock).
- Cart and fast checkout: pick-up or delivery (per customer scenario).
- Multiple roles: Network Administrator, Pharmacy Manager, Pharmacist/Provisor, Customer (patient), Supplier.
- Schedules / opening hours of pharmacies and pick-up points, slots for pick-ups/consultations.
- Supplier integration: price lists, minimum order quantities, supply statuses.
- Extensibility: new pharmacy locations, product categories, pricing rules, promo codes.
Architecture and Key Decisions (Yii2)
- Template: Yii2 Advanced (frontend/backend/api), clear separation of public UI, admin panel, and REST API.
- ActiveRecord + DataProvider: efficient queries, MySQL indexes, filtered search (category, manufacturer, dosage form).
- RBAC (Role-Based Access Control): access policies for all roles; granular permissions (create/update/approve orders, manage stock, manage suppliers).
- Behaviors: TimestampBehavior, BlameableBehavior; for products — SEO fields and friendly URLs (as needed).
- Validations/scenarios: separate scenarios for creating, editing, and confirming orders; prescription checks (if required).
- REST API (
yii\rest\Controller): mobile app/3rd-party integrations; JSON formats and consistent error codes. - Migrations: full control over the DB schema; dumps/seed data for staging.
- Caching: categories, filters, search suggestions; dictionaries invalidated on update.
Key Functionality
1) Roles and Access
- Network Administrator: global settings, creation of pharmacies, roles, business rules, supplier integrations.
- Pharmacy Manager: local pricing, stock, order confirmations, working hours, specific location storefront.
- Pharmacist/Provisor: order processing, consultations, product reservations, marking orders ready for pick-up.
- Supplier: price lists/minimum batches, shipment confirmations, ETA, substitutions with analogs (if agreed).
- Customer (patient): search medicines, check availability, place orders, choose pharmacy/time.
2) Catalog and Availability
- Categories, dosage forms, manufacturers, SKUs/barcodes, substitution rules (approved analogs).
- Warehouses/stock per pharmacy, reserve-on-order (to prevent overselling), low-stock alerts.
3) Ordering and Processing
- Classic flow: Add to cart → Checkout → Payment/Reservation → Pharmacy confirmation → Ready for pick-up/Delivery.
- Statuses: draft / pending / confirmed / ready / completed / cancelled; event log and staff comments.
- Prescription validation (if a prescription upload is required), age/restriction checks (configurable).
4) Opening Hours and Slots
- Pharmacy calendar: intake/pick-up hours, exceptions (holidays, inventory).
- Slot ranking at checkout (closest available time), limits on the number of pick-ups per slot.
5) Suppliers and Procurement
- Import of price lists (CSV/Excel/API), mapping to internal SKUs.
- Purchase requests to suppliers with MOQs and stock taken into account.
- Supply tracking: statuses, expected dates, automatic stock updates.
Security and Compliance
- RBAC + access policies for every CRUD operation.
- Form protection: CSRF, rate limiting (on API), server-side validation, input sanitization.
- User action audit log and change tracking for orders/stock.
- DB backups; distinct roles for sensitive operations.
- Optional: storage and verification of e-prescriptions according to local regulations (configurable).
Performance and UX
- Search with autocomplete (cached suggestions), filters without page reloads.
- SQL optimization (composite indexes, EXPLAIN analysis), pagination via ActiveDataProvider.
- Bootstrap for clean, accessible UI; mobile-first approach.
- Optional: queues (Yii2-queue) for heavy tasks — price imports, bulk updates, notifications.
Analytics and Admin Panel
- Dashboards: sales by pharmacy, top products, reserve rates, cancellations, pick-up SLA.
- Supplier reports: pricing, on-time performance, reliability of deliveries.
- CSV/Excel export; role-dependent views and filters.
Business Outcomes
- A single system for online sales and pharmacy network operations.
- Inventory transparency and reservation control — fewer customer refusals.
- Faster order processing and pick-up planning thanks to slots and roles.
- Ready to scale: add pharmacies, new categories, integrations with suppliers or payment services.
Need a similar Yii2 portal for your pharmacy network?
I will prepare the architecture, an implementation roadmap, and a budget considering regulatory requirements and integrations.