Adding New Roles to MediDash
person_add_alt_1 Adding a New Role to MediDash
MediDash is designed for extensibility, allowing you to easily add new roles beyond the built-in Admin, Doctor, and Patient roles. This guide provides a comprehensive walkthrough of the process, with best practices and code examples to help you along the way.
integration_instructions Implementation Steps
Follow these six essential steps to successfully integrate a new role into your MediDash application:
looks_one Step 1: Define the New Role
The first step is to define the new role in the Role
enum, which is located in the core models directory.
File Location
Example
export enum Role {
Admin = 'ADMIN',
Doctor = 'DOCTOR',
Patient = 'PATIENT',
// Add your new role here
Pharmacist = 'PHARMACIST'
}
Best Practices
- Use uppercase for consistency.
- Choose a descriptive and meaningful name.
- Keep the list in alphabetical order.
looks_two Step 2: Add Sample User Data
For testing and development purposes, create a sample user entry
in the users.json file.
File Location
Example
{
"id": 4,
"username": "pharmacist@example.com",
"password": "pharmacist123",
"firstName": "John",
"lastName": "Doe",
"token": "fake-pharmacist-token",
"role": "PHARMACIST",
"img": "assets/images/users/pharmacist.png"
}
Security Note
- This is for development purposes only.
- In a production environment, use a secure database.
- Always hash passwords in production.