Command-Line Management Tool
The SecureHealth Command-Line Management Tool provides comprehensive system administration capabilities for managing patients, encryption operations, audit logs, and system configuration. This tool is essential for system administrators and developers working with the SecureHealth platform.
Overviewβ
The CLI tool is built using Symfony Console and provides a comprehensive interface for managing all aspects of the SecureHealth system. It includes commands for patient management, encryption operations, audit logging, and system administration.
Key Features
- Patient Management: Create, update, and manage patient records
- Encryption Operations: Manage encryption keys and operations
- Audit Logging: View and manage audit logs
- System Administration: Complete system management capabilities
- Database Operations: Direct database management and maintenance
- Security Management: User and role management
Installation and Setupβ
Prerequisites
- PHP 8.2 or higher
- Symfony Console
- MongoDB 8.2 with Queryable Encryption
- SecureHealth application installed
Installationβ
Installation Commands
# Navigate to SecureHealth directory
cd /path/to/securehealth
# Install dependencies
composer install
# Make CLI executable
chmod +x bin/console
Configurationβ
The CLI tool uses the same configuration as the main application:
Environment Configuration
# Environment variables
MONGODB_URI=mongodb://localhost:27017/securehealth
MONGODB_DB=securehealth
APP_SECRET=your-app-secret
JWT_SECRET_KEY=your-jwt-secret
ENCRYPTION_KEY_PATH=/path/to/encryption.key
Available Commandsβ
Patient Managementβ
Create Patientβ
# Create a new patient
php bin/console app:create-patient \
--firstName="John" \
--lastName="Doe" \
--email="john.doe@email.com" \
--phone="555-123-4567" \
--dateOfBirth="1990-01-01" \
--ssn="123-45-6789"
Update Patientβ
# Update patient information
php bin/console app:update-patient \
--id="patient_123" \
--firstName="John" \
--lastName="Smith" \
--email="john.smith@email.com"
List Patientsβ
# List all patients
php bin/console app:list-patients
# List patients with filters
php bin/console app:list-patients \
--role="doctor" \
--limit=10 \
--search="John"
Delete Patientβ
# Delete a patient
php bin/console app:delete-patient --id="patient_123"
Encryption Operationsβ
Generate Encryption Keyβ
# Generate new encryption key
php bin/console app:generate-encryption-key
# Generate key with specific parameters
php bin/console app:generate-encryption-key \
--key-id="key_123" \
--algorithm="AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic"
Initialize MongoDBβ
# Initialize MongoDB with encryption configuration
php bin/console app:init-mongodb
# Initialize with specific database
php bin/console app:init-mongodb --database="securehealth_prod"
Encrypt Dataβ
# Encrypt specific data
php bin/console app:encrypt-data \
--field="lastName" \
--value="Smith" \
--algorithm="deterministic"
Decrypt Dataβ
# Decrypt specific data
php bin/console app:decrypt-data \
--field="lastName" \
--encrypted-value="encrypted_value_here"
Audit Loggingβ
View Audit Logsβ
# View recent audit logs
php bin/console app:view-audit-logs
# View logs with filters
php bin/console app:view-audit-logs \
--user="doctor_123" \
--action="patient_view" \
--start-date="2024-01-01" \
--end-date="2024-01-31"
Export Audit Logsβ
# Export audit logs to CSV
php bin/console app:export-audit-logs \
--format="csv" \
--output="audit_logs_2024.csv" \
--start-date="2024-01-01" \
--end-date="2024-01-31"
Clear Audit Logsβ
# Clear old audit logs
php bin/console app:clear-audit-logs \
--older-than="2023-01-01" \
--confirm
User Managementβ
Create Userβ
# Create a new user
php bin/console app:create-user \
--email="doctor@securehealth.dev" \
--firstName="Dr. Jane" \
--lastName="Smith" \
--roles="ROLE_DOCTOR" \
--password="securepassword123"
Update Userβ
# Update user information
php bin/console app:update-user \
--id="user_123" \
--firstName="Dr. Jane" \
--lastName="Johnson" \
--roles="ROLE_DOCTOR,ROLE_ADMIN"
List Usersβ
# List all users
php bin/console app:list-users
# List users by role
php bin/console app:list-users --role="ROLE_DOCTOR"
Reset Passwordβ
# Reset user password
php bin/console app:reset-password \
--email="doctor@securehealth.dev" \
--new-password="newpassword123"
System Administrationβ
System Statusβ
# Check system status
php bin/console app:system-status
# Check specific components
php bin/console app:system-status --component="mongodb"
php bin/console app:system-status --component="encryption"
Database Maintenanceβ
# Optimize database
php bin/console app:optimize-database
# Rebuild indexes
php bin/console app:rebuild-indexes
# Check database integrity
php bin/console app:check-database-integrity
Cache Managementβ
# Clear application cache
php bin/console app:clear-cache
# Warm up cache
php bin/console app:warm-cache
# Clear specific cache
php bin/console app:clear-cache --type="doctrine"
Backup and Restoreβ
# Create database backup
php bin/console app:backup-database \
--output="/backups/securehealth_2024-01-15.bak"
# Restore database
php bin/console app:restore-database \
--input="/backups/securehealth_2024-01-15.bak"
Advanced Usageβ
Batch Operationsβ
Batch Patient Importβ
# Import patients from CSV
php bin/console app:import-patients \
--file="/data/patients.csv" \
--format="csv" \
--batch-size=100
Batch User Creationβ
# Create multiple users
php bin/console app:create-users \
--file="/data/users.json" \
--format="json"
Monitoring and Alertsβ
Health Checkβ
# Run comprehensive health check
php bin/console app:health-check
# Check specific services
php bin/console app:health-check --service="mongodb"
php bin/console app:health-check --service="encryption"
Performance Monitoringβ
# Monitor system performance
php bin/console app:monitor-performance
# Generate performance report
php bin/console app:performance-report \
--output="/reports/performance_2024-01-15.pdf"
Security Operationsβ
Security Auditβ
# Run security audit
php bin/console app:security-audit
# Audit specific components
php bin/console app:security-audit --component="encryption"
php bin/console app:security-audit --component="users"
Key Rotationβ
# Rotate encryption keys
php bin/console app:rotate-encryption-keys \
--old-key-id="key_123" \
--new-key-id="key_456"
Configuration Optionsβ
Command Line Optionsβ
Most commands support common options:
--verboseor-v: Verbose output--quietor-q: Quiet mode--no-interactionor-n: Non-interactive mode--env=prod: Environment specification--helpor-h: Command help
Environment-Specific Commandsβ
# Development environment
php bin/console app:create-patient --env=dev
# Production environment
php bin/console app:create-patient --env=prod
# Test environment
php bin/console app:create-patient --env=test
Error Handlingβ
Common Errorsβ
Database Connection Issuesβ
# Check MongoDB connection
php bin/console app:check-mongodb-connection
# Test encryption configuration
php bin/console app:test-encryption-config
Permission Issuesβ
# Check file permissions
php bin/console app:check-permissions
# Fix permission issues
php bin/console app:fix-permissions
Encryption Errorsβ
# Validate encryption keys
php bin/console app:validate-encryption-keys
# Test encryption operations
php bin/console app:test-encryption
Logging and Debuggingβ
Enable Debug Modeβ
# Run commands with debug output
php bin/console app:create-patient --verbose --debug
View Command Logsβ
# View command execution logs
tail -f var/log/console.log
# View specific command logs
grep "create-patient" var/log/console.log
Integration with CI/CDβ
Automated Deploymentβ
# Deploy application
php bin/console app:deploy --environment=production
# Run post-deployment tasks
php bin/console app:post-deploy --environment=production
Health Checksβ
# Run health checks for monitoring
php bin/console app:health-check --format=json > health_status.json
Next Stepsβ
- API Reference - Complete API documentation
- Security Implementation - Security patterns
- Troubleshooting - Common issues and solutions
- Live Demo - Try the system