""" Management command to initialize onboarding acknowledgement data """ from django.core.management.base import BaseCommand from django.utils import timezone from apps.accounts.models import ( AcknowledgementContent, AcknowledgementChecklistItem, Role ) class Command(BaseCommand): help = 'Initialize default acknowledgement content and checklist items' def handle(self, *args, **options): self.stdout.write('Initializing onboarding acknowledgement data...') # Create generic content (applies to all users) self._create_generic_content() # Create role-specific content self._create_px_admin_content() self._create_hospital_admin_content() self._create_department_manager_content() self._create_physician_content() self._create_staff_content() self.stdout.write(self.style.SUCCESS('Onboarding data initialized successfully!')) def _create_generic_content(self): """Create generic acknowledgement content for all users""" self.stdout.write('Creating generic content...') role = None # Generic content # Create generic content items contents = [ { 'code': 'INTRO_PX360', 'order': 1, 'title_en': 'Welcome to PX360', 'title_ar': 'مرحبًا بك في PX360', 'description_en': 'Overview of the PX360 Patient Experience Management System', 'description_ar': 'نظرة عامة على نظام إدارة تجربة المريض PX360', 'content_en': """

Welcome to PX360

PX360 is a comprehensive Patient Experience Management System designed to help healthcare organizations improve patient satisfaction and quality of care.

Key Features:

Getting Started:

This wizard will guide you through the essential features and policies of the system. Please review each section carefully and acknowledge the checklist items to complete your onboarding.

""", 'content_ar': """

مرحبًا بك في PX360

PX360 هو نظام شامل لإدارة تجربة المرضى مصمم لمساعدة المؤسسات الصحية على تحسين رضا المرضى وجودة الرعاية.

الميزات الرئيسية:

البدء:

سيقوم هذا المعالج بإرشادك عبر الميزات والسياسات الأساسية للنظام. يرجى مراجعة كل قسم بعناية والاعتراف بالبنود المدرجة في القائمة لإكمال التسجيل.

""" }, { 'code': 'DATA_PRIVACY', 'order': 2, 'title_en': 'Data Privacy & Security', 'title_ar': 'خصوصية البيانات والأمان', 'description_en': 'Understanding data protection and security policies', 'description_ar': 'فهم سياسات حماية البيانات والأمان', 'content_en': """

Data Privacy & Security

Data Protection Principles:

User Responsibilities:

""", 'content_ar': """

خصوصية البيانات والأمان

مبادئ حماية البيانات:

مسؤوليات المستخدم:

""" }, { 'code': 'SYSTEM_USAGE', 'order': 3, 'title_en': 'System Usage Guidelines', 'title_ar': 'إرشادات استخدام النظام', 'description_en': 'Best practices for using PX360 effectively', 'description_ar': 'أفضل الممارسات لاستخدام PX360 بشكل فعال', 'content_en': """

System Usage Guidelines

Best Practices:

Support:

If you need assistance:

""", 'content_ar': """

إرشادات استخدام النظام

أفضل الممارسات:

الدعم:

إذا كنت بحاجة إلى المساعدة:

""" } ] for content_data in contents: AcknowledgementContent.objects.update_or_create( code=content_data['code'], role=role, defaults=content_data ) # Create checklist items for generic content intro_content = AcknowledgementContent.objects.get(code='INTRO_PX360') privacy_content = AcknowledgementContent.objects.get(code='DATA_PRIVACY') usage_content = AcknowledgementContent.objects.get(code='SYSTEM_USAGE') checklist_items = [ { 'content': intro_content, 'code': 'INTRO_ACK', 'order': 1, 'text_en': 'I have reviewed the PX360 system overview', 'text_ar': 'لقد راجعت نظرة عامة على نظام PX360', 'description_en': 'Confirm that you understand the system purpose and key features', 'description_ar': 'أكد أنك تفهم الغرض من النظام والميزات الرئيسية', 'is_required': True }, { 'content': privacy_content, 'code': 'PRIVACY_ACK', 'order': 1, 'text_en': 'I acknowledge and agree to the data privacy and security policies', 'text_ar': 'أعترف وأوافق على سياسات خصوصية البيانات والأمان', 'description_en': 'Confirm that you understand your responsibilities regarding data protection', 'description_ar': 'أكد أنك تفهم مسؤولياتك فيما يتعلق بحماية البيانات', 'is_required': True }, { 'content': privacy_content, 'code': 'PRIVACY_PASSWORD', 'order': 2, 'text_en': 'I will keep my password secure and report any security incidents', 'text_ar': 'سأحتفظ بكلمة المرور آمنة وسأبلغ عن أي حوادث أمنية', 'description_en': 'Commit to password security and incident reporting', 'description_ar': 'الالتزام بأمان كلمة المرور والإبلاغ عن الحوادث', 'is_required': True }, { 'content': usage_content, 'code': 'USAGE_ACK', 'order': 1, 'text_en': 'I will follow system usage guidelines and best practices', 'text_ar': 'سأتبع إرشادات استخدام النظام وأفضل الممارسات', 'description_en': 'Commit to using the system effectively and responsibly', 'description_ar': 'الالتزام باستخدام النظام بفعالية ومسؤولية', 'is_required': True } ] for item_data in checklist_items: AcknowledgementChecklistItem.objects.update_or_create( code=item_data['code'], defaults=item_data ) def _create_px_admin_content(self): """Create PX Admin specific content""" try: role = Role.objects.get(name='PX_ADMIN') except Role.DoesNotExist: self.stdout.write(self.style.WARNING('PX Admin role not found, skipping PX Admin content')) return self.stdout.write('Creating PX Admin content...') content_data = { 'code': 'PX_ADMIN_RESP', 'role': role, 'order': 4, 'title_en': 'PX Admin Responsibilities', 'title_ar': 'مسؤوليات مسؤول PX', 'description_en': 'Understanding PX Admin role and permissions', 'description_ar': 'فهم دور وصلاحيات مسؤول PX', 'content_en': """

PX Admin Responsibilities

As a PX Admin, you have full access to all system features and are responsible for:

Note: With great power comes great responsibility. All your actions are logged and audited.

""", 'content_ar': """

مسؤوليات مسؤول PX

بصفتك مسؤول PX، لديك حق الوصول الكامل إلى جميع ميزات النظام ومسؤول عن:

ملاحظة: مع السلطة العالية تأتي المسؤولية الكبيرة. جميع إجراءاتك مسجلة وقابلة للتدقيق.

""" } content, _ = AcknowledgementContent.objects.update_or_create( code=content_data['code'], role=role, defaults=content_data ) checklist_items = [ { 'content': content, 'code': 'PX_ADMIN_OVERSIGHT', 'order': 1, 'text_en': 'I understand my role as PX Admin and will use permissions responsibly', 'text_ar': 'أفهم دوري كمسؤول PX وسأستخدم الصلاحيات بمسؤولية', 'description_en': 'Accept responsibility for PX Admin role', 'description_ar': 'قبول المسؤولية لدور مسؤول PX', 'is_required': True } ] for item_data in checklist_items: AcknowledgementChecklistItem.objects.update_or_create( code=item_data['code'], defaults=item_data ) def _create_hospital_admin_content(self): """Create Hospital Admin specific content""" try: role = Role.objects.get(name='HOSPITAL_ADMIN') except Role.DoesNotExist: return self.stdout.write('Creating Hospital Admin content...') content_data = { 'code': 'HOSPITAL_ADMIN_RESP', 'role': role, 'order': 4, 'title_en': 'Hospital Admin Responsibilities', 'title_ar': 'مسؤوليات مدير المستشفى', 'description_en': 'Understanding Hospital Admin role and scope', 'description_ar': 'فهم دور ونطاق مدير المستشفى', 'content_en': """

Hospital Admin Responsibilities

As a Hospital Admin, you can manage users, view reports, and oversee operations within your hospital.

""", 'content_ar': """

مسؤوليات مدير المستشفى

بصفتك مدير المستشفى، يمكنك إدارة المستخدمين وعرض التقارير والإشراف على العمليات داخل مستشفاك.

""" } content, _ = AcknowledgementContent.objects.update_or_create( code=content_data['code'], role=role, defaults=content_data ) checklist_items = [ { 'content': content, 'code': 'HOSPITAL_ADMIN_SCOPE', 'order': 1, 'text_en': 'I understand my Hospital Admin role and hospital-level responsibilities', 'text_ar': 'أفهم دوري كمدير مستشفى ومسؤولياتي على مستوى المستشفى', 'description_en': 'Accept responsibility for Hospital Admin role', 'description_ar': 'قبول المسؤولية لدور مدير المستشفى', 'is_required': True } ] for item_data in checklist_items: AcknowledgementChecklistItem.objects.update_or_create( code=item_data['code'], defaults=item_data ) def _create_department_manager_content(self): """Create Department Manager specific content""" try: role = Role.objects.get(name='DEPARTMENT_MANAGER') except Role.DoesNotExist: return self.stdout.write('Creating Department Manager content...') content_data = { 'code': 'DEPT_MGR_RESP', 'role': role, 'order': 4, 'title_en': 'Department Manager Responsibilities', 'title_ar': 'مسؤوليات مدير القسم', 'description_en': 'Understanding Department Manager role and operations', 'description_ar': 'فهم دور وعمليات مدير القسم', 'content_en': """

Department Manager Responsibilities

As a Department Manager, you oversee your department's operations and staff performance.

""", 'content_ar': """

مسؤوليات مدير القسم

بصفتك مدير القسم، تشرف على عمليات قسمك وأداء الموظفين.

""" } content, _ = AcknowledgementContent.objects.update_or_create( code=content_data['code'], role=role, defaults=content_data ) checklist_items = [ { 'content': content, 'code': 'DEPT_MGR_SCOPE', 'order': 1, 'text_en': 'I understand my Department Manager role and responsibilities', 'text_ar': 'أفهم دوري ومسؤولياتي كمدير قسم', 'description_en': 'Accept responsibility for Department Manager role', 'description_ar': 'قبول المسؤولية لدور مدير القسم', 'is_required': True } ] for item_data in checklist_items: AcknowledgementChecklistItem.objects.update_or_create( code=item_data['code'], defaults=item_data ) def _create_physician_content(self): """Create Physician specific content""" try: role = Role.objects.get(name='PHYSICIAN') except Role.DoesNotExist: return self.stdout.write('Creating Physician content...') content_data = { 'code': 'PHYSICIAN_RESP', 'role': role, 'order': 4, 'title_en': 'Physician Responsibilities', 'title_ar': 'مسؤوليات الطبيب', 'description_en': 'Understanding Physician role in PX360', 'description_ar': 'فهم دور الطبيب في PX360', 'content_en': """

Physician Responsibilities

As a Physician, you play a key role in patient experience and quality of care.

""", 'content_ar': """

مسؤوليات الطبيب

بصفتك طبيبًا، تلعب دورًا رئيسيًا في تجربة المريض وجودة الرعاية.

""" } content, _ = AcknowledgementContent.objects.update_or_create( code=content_data['code'], role=role, defaults=content_data ) checklist_items = [ { 'content': content, 'code': 'PHYSICIAN_SCOPE', 'order': 1, 'text_en': 'I understand my Physician role and commitment to patient care', 'text_ar': 'أفهم دوري كطبيب والالتزام برعاية المرضى', 'description_en': 'Accept responsibility for Physician role', 'description_ar': 'قبول المسؤولية لدور الطبيب', 'is_required': True } ] for item_data in checklist_items: AcknowledgementChecklistItem.objects.update_or_create( code=item_data['code'], defaults=item_data ) def _create_staff_content(self): """Create Staff specific content""" try: role = Role.objects.get(name='STAFF') except Role.DoesNotExist: return self.stdout.write('Creating Staff content...') content_data = { 'code': 'STAFF_RESP', 'role': role, 'order': 4, 'title_en': 'Staff Responsibilities', 'title_ar': 'مسؤوليات الموظف', 'description_en': 'Understanding Staff role and daily operations', 'description_ar': 'فهم دور الموظف والعمليات اليومية', 'content_en': """

Staff Responsibilities

As a Staff member, you contribute to daily operations and patient experience.

""", 'content_ar': """

مسؤوليات الموظف

بصفتك موظفًا، تساهم في العمليات اليومية وتجربة المريض.

""" } content, _ = AcknowledgementContent.objects.update_or_create( code=content_data['code'], role=role, defaults=content_data ) checklist_items = [ { 'content': content, 'code': 'STAFF_SCOPE', 'order': 1, 'text_en': 'I understand my Staff role and commitment to quality service', 'text_ar': 'أفهم دوري كموظف والالتزام بخدمة عالية الجودة', 'description_en': 'Accept responsibility for Staff role', 'description_ar': 'قبول المسؤولية لدور الموظف', 'is_required': True } ] for item_data in checklist_items: AcknowledgementChecklistItem.objects.update_or_create( code=item_data['code'], defaults=item_data )