Custom Web-Based Pharmacy Management System

Job ID: 39252256

Budget: £1,500 – £2,500 GBP

Overview
This document outlines a phased development plan and cost estimate for a modern web-based Pharmacy Management System (PMR) tailored to UK pharmacy operations. The system will be scalable, secure.

Goals: Establish the foundational PMR system with secure backend, core dispensing workflows, and patient records.
Features:

● Secure login with role-based access
● Patient record system (history, allergies, manual entry)
● Dispensing workflow (medication search, dose entry, label generation)
● Audit log for dispense history
● Manual logging for fridge/room temperature and pharmacist logs
● Data backup and restore features
● Prescription sorting and filtering
● Backend infrastructure (CI/CD, DB schema, deployment, logging)
● Error handling, input validation, edge case coverage

Clinical Records & Inventory Management
Goals: Expand into structured clinical data capture and basic inventory workflows.

Features:

● Private controlled drug register (auto log)
● Manual stock control
● Patient prescription filtering
● Follow-up action tracking

● Structured clinical messaging
● Patient information leaflets (PILs)
● Admin panel with audit & monitoring too

Tech Stack Overview
• Backend: Node.js with Express.js
• Database: MongoDB (NoSQL)
• Deployment: AWS EC2 with PM2 and NGINX for load balancing and reverse proxy
• CI/CD: GitHub Actions
• Authentication: JWT-based authentication with Role-Based Access Control (RBAC)
• File Storage: AWS S3 (for labels, prescriptions, and backup)
• Error Logging & Monitoring: Winston/Loggly/Sentry
• Data Backup & Restore: MongoDB Atlas backups or custom script with mongodump/mongorestore
• Testing: Jest or Mocha with Chai (for unit and integration testing)
• Validation: Joi or express-validator

Please check System Flow and Architecture, I have tried to explain it more detailed but needed your views on.



Backend Infrastructure Flow
1. Authentication & Authorization Flow
• Login: Verify user credentials (email, password) → Generate JWT → Return token with role info.
• RBAC Middleware: Validate token → Extract role → Check permissions → Grant/deny access.
• Secure Routes: Protect sensitive endpoints (e.g., medication dispense) by verifying pharmacist/doctor roles.



2. Patient Record System Flow
• CRUD Operations:
• Create and manage patient details (name, DOB, allergies, history).
• Manual entry of records by pharmacists.
• Data Storage: Store in MongoDB with appropriate indexing for faster querying.
• Security: Encrypt sensitive patient information using libraries like crypto or bcrypt.



3. Dispensing Workflow Flow
• Search for Medication: Filter by name, type, dose, and availability.
• Dose Entry: Pharmacist enters dose, frequency, and duration.
• Label Generation:
• Use a PDF library (e.g., pdfkit) to generate printable labels.
• Store generated labels on AWS S3 for future reference.
• Dispense Confirmation: Save the medication details in dispense history.



4. Audit Log Flow
• Every action (create, update, delete) triggers an audit log entry.
• Audit logs include:
• User ID, Role, Action, Timestamp, and IP address.
• Store in a separate MongoDB collection for easy querying and filtering.



5. Temperature and Pharmacist Logs
• Temperature Logging: Manual entry of fridge/room temperature.
• Pharmacist Logs: Track login/logout, dispense history, and notes.
• Log Retention: Store logs in MongoDB and enable automated purging after a defined retention period.



6. Prescription Sorting & Filtering
• Sorting: By date, patient name, doctor, or medication type.
• Filtering: Search by patient ID, medication, or pharmacist name.
• Pagination: Use MongoDB's .skip() and .limit() for efficient pagination.



7. Data Backup & Restore
Backup:
• Use mongodump to create backups.
• Store backups in AWS S3 or MongoDB Atlas backups.
Restore:
• Use mongorestore to restore data from backups.
• Create a separate admin-only endpoint to trigger the restore process.



8. Database Schema
• Users Collection
• Patients Collection
• Dispense History Collection
• Audit Logs Collection



9. Authentication with RBAC
• Use JWT tokens for authentication.
• Store user roles in MongoDB.
• Create middleware for role-based access control (RBAC).



10. Deployment on AWS EC2 and S3



11. CI/CD Pipeline
• GitHub Actions Workflow



12. Error Handling & Edge Cases
• Input Validation: Use Joi to validate patient and medication data.
• Error Logs: Use Winston for logging errors.
• Edge Cases:
o Handle expired JWT tokens.
o Manage large data queries with pagination.
o Backup restore fails gracefully.