diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..437496c --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,37 @@ +name: Django + Pytest CI + +on: + push: + branches: ['**'] + pull_request: + branches: ['**'] + +jobs: + test: + runs-on: windows-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Python 3.11 + uses: actions/setup-python@v4 + with: + python-version: '3.11' + + - name: Install ffmpeg + run: choco install ffmpeg -y + + - name: Install dependencies + run: | + pip install --upgrade pip + pip install -r requirements.txt + working-directory: Merilife/MediBot/chatbot-website + + - name: Run migrations + run: python manage.py migrate --noinput + working-directory: Merilife/MediBot/chatbot-website + + - name: Run tests + run: pytest --maxfail=1 --disable-warnings -q + working-directory: Merilife/MediBot/chatbot-website diff --git a/Merilife/MediBot/.gitignore b/Merilife/MediBot/.gitignore index 519dfde..be62080 100644 --- a/Merilife/MediBot/.gitignore +++ b/Merilife/MediBot/.gitignore @@ -3,4 +3,7 @@ !/media/test/.gitkeep .pytest_cache/ .coverage -htmlcov/ \ No newline at end of file +htmlcov/ +# Python byte‑code +__pycache__/ +*.py[cod] diff --git a/Merilife/MediBot/chatbot-website/chatbot/__pycache__/__init__.cpython-311.pyc b/Merilife/MediBot/chatbot-website/chatbot/__pycache__/__init__.cpython-311.pyc index ba6b416..12b0d3e 100644 Binary files a/Merilife/MediBot/chatbot-website/chatbot/__pycache__/__init__.cpython-311.pyc and b/Merilife/MediBot/chatbot-website/chatbot/__pycache__/__init__.cpython-311.pyc differ diff --git a/Merilife/MediBot/chatbot-website/chatbot/__pycache__/__init__.cpython-312.pyc b/Merilife/MediBot/chatbot-website/chatbot/__pycache__/__init__.cpython-312.pyc deleted file mode 100644 index 20c158c..0000000 Binary files a/Merilife/MediBot/chatbot-website/chatbot/__pycache__/__init__.cpython-312.pyc and /dev/null differ diff --git a/Merilife/MediBot/chatbot-website/chatbot/__pycache__/admin.cpython-311.pyc b/Merilife/MediBot/chatbot-website/chatbot/__pycache__/admin.cpython-311.pyc index a9e9f30..7027b78 100644 Binary files a/Merilife/MediBot/chatbot-website/chatbot/__pycache__/admin.cpython-311.pyc and b/Merilife/MediBot/chatbot-website/chatbot/__pycache__/admin.cpython-311.pyc differ diff --git a/Merilife/MediBot/chatbot-website/chatbot/__pycache__/admin.cpython-312.pyc b/Merilife/MediBot/chatbot-website/chatbot/__pycache__/admin.cpython-312.pyc deleted file mode 100644 index bb79de1..0000000 Binary files a/Merilife/MediBot/chatbot-website/chatbot/__pycache__/admin.cpython-312.pyc and /dev/null differ diff --git a/Merilife/MediBot/chatbot-website/chatbot/__pycache__/ai_wrapper.cpython-311.pyc b/Merilife/MediBot/chatbot-website/chatbot/__pycache__/ai_wrapper.cpython-311.pyc index 9cce2ec..0dc4ecd 100644 Binary files a/Merilife/MediBot/chatbot-website/chatbot/__pycache__/ai_wrapper.cpython-311.pyc and b/Merilife/MediBot/chatbot-website/chatbot/__pycache__/ai_wrapper.cpython-311.pyc differ diff --git a/Merilife/MediBot/chatbot-website/chatbot/__pycache__/ai_wrapper.cpython-312.pyc b/Merilife/MediBot/chatbot-website/chatbot/__pycache__/ai_wrapper.cpython-312.pyc deleted file mode 100644 index 6edbd80..0000000 Binary files a/Merilife/MediBot/chatbot-website/chatbot/__pycache__/ai_wrapper.cpython-312.pyc and /dev/null differ diff --git a/Merilife/MediBot/chatbot-website/chatbot/__pycache__/apps.cpython-311.pyc b/Merilife/MediBot/chatbot-website/chatbot/__pycache__/apps.cpython-311.pyc index 7085a3c..c019938 100644 Binary files a/Merilife/MediBot/chatbot-website/chatbot/__pycache__/apps.cpython-311.pyc and b/Merilife/MediBot/chatbot-website/chatbot/__pycache__/apps.cpython-311.pyc differ diff --git a/Merilife/MediBot/chatbot-website/chatbot/__pycache__/apps.cpython-312.pyc b/Merilife/MediBot/chatbot-website/chatbot/__pycache__/apps.cpython-312.pyc deleted file mode 100644 index 7c5f8e9..0000000 Binary files a/Merilife/MediBot/chatbot-website/chatbot/__pycache__/apps.cpython-312.pyc and /dev/null differ diff --git a/Merilife/MediBot/chatbot-website/chatbot/__pycache__/backends.cpython-311.pyc b/Merilife/MediBot/chatbot-website/chatbot/__pycache__/backends.cpython-311.pyc index b51f67c..146e8b7 100644 Binary files a/Merilife/MediBot/chatbot-website/chatbot/__pycache__/backends.cpython-311.pyc and b/Merilife/MediBot/chatbot-website/chatbot/__pycache__/backends.cpython-311.pyc differ diff --git a/Merilife/MediBot/chatbot-website/chatbot/__pycache__/backends.cpython-312.pyc b/Merilife/MediBot/chatbot-website/chatbot/__pycache__/backends.cpython-312.pyc deleted file mode 100644 index 77bd1c3..0000000 Binary files a/Merilife/MediBot/chatbot-website/chatbot/__pycache__/backends.cpython-312.pyc and /dev/null differ diff --git a/Merilife/MediBot/chatbot-website/chatbot/__pycache__/factories.cpython-312.pyc b/Merilife/MediBot/chatbot-website/chatbot/__pycache__/factories.cpython-312.pyc deleted file mode 100644 index 5d129dc..0000000 Binary files a/Merilife/MediBot/chatbot-website/chatbot/__pycache__/factories.cpython-312.pyc and /dev/null differ diff --git a/Merilife/MediBot/chatbot-website/chatbot/__pycache__/ignore_tests.cpython-312-pytest-8.3.5.pyc b/Merilife/MediBot/chatbot-website/chatbot/__pycache__/ignore_tests.cpython-312-pytest-8.3.5.pyc deleted file mode 100644 index 5d4a83e..0000000 Binary files a/Merilife/MediBot/chatbot-website/chatbot/__pycache__/ignore_tests.cpython-312-pytest-8.3.5.pyc and /dev/null differ diff --git a/Merilife/MediBot/chatbot-website/chatbot/__pycache__/load_utils.cpython-311.pyc b/Merilife/MediBot/chatbot-website/chatbot/__pycache__/load_utils.cpython-311.pyc index e14e04d..736b4b9 100644 Binary files a/Merilife/MediBot/chatbot-website/chatbot/__pycache__/load_utils.cpython-311.pyc and b/Merilife/MediBot/chatbot-website/chatbot/__pycache__/load_utils.cpython-311.pyc differ diff --git a/Merilife/MediBot/chatbot-website/chatbot/__pycache__/middleware.cpython-311.pyc b/Merilife/MediBot/chatbot-website/chatbot/__pycache__/middleware.cpython-311.pyc index 43add69..bf26170 100644 Binary files a/Merilife/MediBot/chatbot-website/chatbot/__pycache__/middleware.cpython-311.pyc and b/Merilife/MediBot/chatbot-website/chatbot/__pycache__/middleware.cpython-311.pyc differ diff --git a/Merilife/MediBot/chatbot-website/chatbot/__pycache__/middleware.cpython-312.pyc b/Merilife/MediBot/chatbot-website/chatbot/__pycache__/middleware.cpython-312.pyc deleted file mode 100644 index a6ccc93..0000000 Binary files a/Merilife/MediBot/chatbot-website/chatbot/__pycache__/middleware.cpython-312.pyc and /dev/null differ diff --git a/Merilife/MediBot/chatbot-website/chatbot/__pycache__/models.cpython-311.pyc b/Merilife/MediBot/chatbot-website/chatbot/__pycache__/models.cpython-311.pyc index 12da998..12b7e3c 100644 Binary files a/Merilife/MediBot/chatbot-website/chatbot/__pycache__/models.cpython-311.pyc and b/Merilife/MediBot/chatbot-website/chatbot/__pycache__/models.cpython-311.pyc differ diff --git a/Merilife/MediBot/chatbot-website/chatbot/__pycache__/models.cpython-312.pyc b/Merilife/MediBot/chatbot-website/chatbot/__pycache__/models.cpython-312.pyc deleted file mode 100644 index 77c0bdf..0000000 Binary files a/Merilife/MediBot/chatbot-website/chatbot/__pycache__/models.cpython-312.pyc and /dev/null differ diff --git a/Merilife/MediBot/chatbot-website/chatbot/__pycache__/speech_to_text.cpython-311.pyc b/Merilife/MediBot/chatbot-website/chatbot/__pycache__/speech_to_text.cpython-311.pyc index a9e387f..040bc01 100644 Binary files a/Merilife/MediBot/chatbot-website/chatbot/__pycache__/speech_to_text.cpython-311.pyc and b/Merilife/MediBot/chatbot-website/chatbot/__pycache__/speech_to_text.cpython-311.pyc differ diff --git a/Merilife/MediBot/chatbot-website/chatbot/__pycache__/speech_to_text.cpython-312.pyc b/Merilife/MediBot/chatbot-website/chatbot/__pycache__/speech_to_text.cpython-312.pyc deleted file mode 100644 index 3358997..0000000 Binary files a/Merilife/MediBot/chatbot-website/chatbot/__pycache__/speech_to_text.cpython-312.pyc and /dev/null differ diff --git a/Merilife/MediBot/chatbot-website/chatbot/__pycache__/urls.cpython-311.pyc b/Merilife/MediBot/chatbot-website/chatbot/__pycache__/urls.cpython-311.pyc index 5b6763a..93adc82 100644 Binary files a/Merilife/MediBot/chatbot-website/chatbot/__pycache__/urls.cpython-311.pyc and b/Merilife/MediBot/chatbot-website/chatbot/__pycache__/urls.cpython-311.pyc differ diff --git a/Merilife/MediBot/chatbot-website/chatbot/__pycache__/urls.cpython-312.pyc b/Merilife/MediBot/chatbot-website/chatbot/__pycache__/urls.cpython-312.pyc deleted file mode 100644 index 1258e5d..0000000 Binary files a/Merilife/MediBot/chatbot-website/chatbot/__pycache__/urls.cpython-312.pyc and /dev/null differ diff --git a/Merilife/MediBot/chatbot-website/chatbot/__pycache__/utils.cpython-311.pyc b/Merilife/MediBot/chatbot-website/chatbot/__pycache__/utils.cpython-311.pyc index 84e0c51..36e539b 100644 Binary files a/Merilife/MediBot/chatbot-website/chatbot/__pycache__/utils.cpython-311.pyc and b/Merilife/MediBot/chatbot-website/chatbot/__pycache__/utils.cpython-311.pyc differ diff --git a/Merilife/MediBot/chatbot-website/chatbot/__pycache__/utils.cpython-312.pyc b/Merilife/MediBot/chatbot-website/chatbot/__pycache__/utils.cpython-312.pyc deleted file mode 100644 index 12a1aa2..0000000 Binary files a/Merilife/MediBot/chatbot-website/chatbot/__pycache__/utils.cpython-312.pyc and /dev/null differ diff --git a/Merilife/MediBot/chatbot-website/chatbot/admin.py b/Merilife/MediBot/chatbot-website/chatbot/admin.py index 0a7e232..bf1c057 100644 --- a/Merilife/MediBot/chatbot-website/chatbot/admin.py +++ b/Merilife/MediBot/chatbot-website/chatbot/admin.py @@ -5,7 +5,16 @@ from chatbot.models import CustomUser, DoctorProfile, PatientProfile from django.http import HttpResponseRedirect +# Add inline for DoctorProfile +class DoctorProfileInline(admin.StackedInline): + model = DoctorProfile + can_delete = False + verbose_name_plural = 'Doctor Profile' + class CustomUserAdmin(UserAdmin): + # Include DoctorProfile inline + inlines = [DoctorProfileInline] + fieldsets = ( (None, {'fields': ('uid', 'password')}), ('Personal Information', {'fields': ('full_name', 'email', 'phone')}), @@ -22,11 +31,18 @@ class CustomUserAdmin(UserAdmin): 'fields': ('uid', 'password1', 'password2', 'full_name', 'is_staff'), }), ) - list_display = ('uid', 'full_name', 'is_staff', 'specialization', 'date_joined') - list_filter = ('is_staff', 'is_active', 'specialization') - search_fields = ('uid', 'full_name', 'email', 'specialization') + list_display = ('uid', 'full_name', 'is_staff', 'get_specialization', 'date_joined') + list_filter = ('is_staff', 'is_active', 'doctor_profile__specialization') + search_fields = ('uid', 'full_name', 'email', 'doctor_profile__specialization') ordering = ('uid',) + def get_specialization(self, obj): + # Display the specialization from the related DoctorProfile + if hasattr(obj, 'doctor_profile') and obj.doctor_profile: + return obj.doctor_profile.specialization + return '' + get_specialization.short_description = 'Specialization' + class CustomAdminSite(admin.AdminSite): site_header = 'Medico Administration' site_title = 'Medico Admin Portal' diff --git a/Merilife/MediBot/chatbot-website/chatbot/management/__pycache__/__init__.cpython-312.pyc b/Merilife/MediBot/chatbot-website/chatbot/management/__pycache__/__init__.cpython-312.pyc deleted file mode 100644 index 16ae3ae..0000000 Binary files a/Merilife/MediBot/chatbot-website/chatbot/management/__pycache__/__init__.cpython-312.pyc and /dev/null differ diff --git a/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0001_initial.cpython-311.pyc b/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0001_initial.cpython-311.pyc index 55b7e52..23d8f56 100644 Binary files a/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0001_initial.cpython-311.pyc and b/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0001_initial.cpython-311.pyc differ diff --git a/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0001_initial.cpython-312.pyc b/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0001_initial.cpython-312.pyc deleted file mode 100644 index 2b8c49a..0000000 Binary files a/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0001_initial.cpython-312.pyc and /dev/null differ diff --git a/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0002_customuser_groups_customuser_is_superuser_and_more.cpython-311.pyc b/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0002_customuser_groups_customuser_is_superuser_and_more.cpython-311.pyc index af42a1f..f4e4973 100644 Binary files a/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0002_customuser_groups_customuser_is_superuser_and_more.cpython-311.pyc and b/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0002_customuser_groups_customuser_is_superuser_and_more.cpython-311.pyc differ diff --git a/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0002_customuser_groups_customuser_is_superuser_and_more.cpython-312.pyc b/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0002_customuser_groups_customuser_is_superuser_and_more.cpython-312.pyc deleted file mode 100644 index bc43096..0000000 Binary files a/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0002_customuser_groups_customuser_is_superuser_and_more.cpython-312.pyc and /dev/null differ diff --git a/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0003_customuser_bio_customuser_email_customuser_full_name_and_more.cpython-311.pyc b/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0003_customuser_bio_customuser_email_customuser_full_name_and_more.cpython-311.pyc index dcc3289..d746694 100644 Binary files a/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0003_customuser_bio_customuser_email_customuser_full_name_and_more.cpython-311.pyc and b/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0003_customuser_bio_customuser_email_customuser_full_name_and_more.cpython-311.pyc differ diff --git a/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0003_customuser_bio_customuser_email_customuser_full_name_and_more.cpython-312.pyc b/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0003_customuser_bio_customuser_email_customuser_full_name_and_more.cpython-312.pyc deleted file mode 100644 index c4c0155..0000000 Binary files a/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0003_customuser_bio_customuser_email_customuser_full_name_and_more.cpython-312.pyc and /dev/null differ diff --git a/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0004_doctorprofile_patientprofile.cpython-311.pyc b/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0004_doctorprofile_patientprofile.cpython-311.pyc index 78819e2..78f3e71 100644 Binary files a/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0004_doctorprofile_patientprofile.cpython-311.pyc and b/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0004_doctorprofile_patientprofile.cpython-311.pyc differ diff --git a/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0004_doctorprofile_patientprofile.cpython-312.pyc b/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0004_doctorprofile_patientprofile.cpython-312.pyc deleted file mode 100644 index b7d3080..0000000 Binary files a/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0004_doctorprofile_patientprofile.cpython-312.pyc and /dev/null differ diff --git a/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0005_treatment.cpython-311.pyc b/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0005_treatment.cpython-311.pyc index 8e6f940..6c63ded 100644 Binary files a/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0005_treatment.cpython-311.pyc and b/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0005_treatment.cpython-311.pyc differ diff --git a/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0005_treatment.cpython-312.pyc b/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0005_treatment.cpython-312.pyc deleted file mode 100644 index 8aaf8de..0000000 Binary files a/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0005_treatment.cpython-312.pyc and /dev/null differ diff --git a/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0006_treatment_reqd.cpython-311.pyc b/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0006_treatment_reqd.cpython-311.pyc index c6c360a..91c5b9e 100644 Binary files a/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0006_treatment_reqd.cpython-311.pyc and b/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0006_treatment_reqd.cpython-311.pyc differ diff --git a/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0006_treatment_reqd.cpython-312.pyc b/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0006_treatment_reqd.cpython-312.pyc deleted file mode 100644 index 99ebcc2..0000000 Binary files a/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0006_treatment_reqd.cpython-312.pyc and /dev/null differ diff --git a/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0007_customuser_address_customuser_age_and_more.cpython-311.pyc b/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0007_customuser_address_customuser_age_and_more.cpython-311.pyc index f259d61..4342533 100644 Binary files a/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0007_customuser_address_customuser_age_and_more.cpython-311.pyc and b/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0007_customuser_address_customuser_age_and_more.cpython-311.pyc differ diff --git a/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0007_customuser_address_customuser_age_and_more.cpython-312.pyc b/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0007_customuser_address_customuser_age_and_more.cpython-312.pyc deleted file mode 100644 index dcd4c15..0000000 Binary files a/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0007_customuser_address_customuser_age_and_more.cpython-312.pyc and /dev/null differ diff --git a/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0008_alter_customuser_email.cpython-311.pyc b/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0008_alter_customuser_email.cpython-311.pyc index c36f8d6..54260b5 100644 Binary files a/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0008_alter_customuser_email.cpython-311.pyc and b/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0008_alter_customuser_email.cpython-311.pyc differ diff --git a/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0008_alter_customuser_email.cpython-312.pyc b/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0008_alter_customuser_email.cpython-312.pyc deleted file mode 100644 index ea4f743..0000000 Binary files a/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0008_alter_customuser_email.cpython-312.pyc and /dev/null differ diff --git a/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0009_fix_migration_conflicts.cpython-311.pyc b/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0009_fix_migration_conflicts.cpython-311.pyc index 3c7a4b8..b7eaf97 100644 Binary files a/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0009_fix_migration_conflicts.cpython-311.pyc and b/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0009_fix_migration_conflicts.cpython-311.pyc differ diff --git a/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0009_fix_migration_conflicts.cpython-312.pyc b/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0009_fix_migration_conflicts.cpython-312.pyc deleted file mode 100644 index a1bc562..0000000 Binary files a/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0009_fix_migration_conflicts.cpython-312.pyc and /dev/null differ diff --git a/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/__init__.cpython-311.pyc b/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/__init__.cpython-311.pyc index 778613f..d128292 100644 Binary files a/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/__init__.cpython-311.pyc and b/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/__init__.cpython-311.pyc differ diff --git a/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/__init__.cpython-312.pyc b/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/__init__.cpython-312.pyc deleted file mode 100644 index 48ed90e..0000000 Binary files a/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/__init__.cpython-312.pyc and /dev/null differ diff --git a/Merilife/MediBot/chatbot-website/chatbot/static/images b/Merilife/MediBot/chatbot-website/chatbot/static/images deleted file mode 100644 index 1421b4c..0000000 --- a/Merilife/MediBot/chatbot-website/chatbot/static/images +++ /dev/null @@ -1 +0,0 @@ -This directory is intentionally left blank. \ No newline at end of file diff --git a/Merilife/MediBot/chatbot-website/chatbot/static/images/adi.png b/Merilife/MediBot/chatbot-website/chatbot/static/images/adi.png new file mode 100644 index 0000000..e69de29 diff --git a/Merilife/MediBot/chatbot-website/chatbot/templates/admin/index.html b/Merilife/MediBot/chatbot-website/chatbot/templates/admin/index.html index e71e32d..c1aedef 100644 --- a/Merilife/MediBot/chatbot-website/chatbot/templates/admin/index.html +++ b/Merilife/MediBot/chatbot-website/chatbot/templates/admin/index.html @@ -13,11 +13,17 @@ {% block content %}
- +
- + Access Load Manager Dashboard + + {% if request.user.is_superuser %} + + Register New Doctor + + {% endif %}
{% if app_list %} diff --git a/Merilife/MediBot/chatbot-website/chatbot/templates/chatbot/about.html b/Merilife/MediBot/chatbot-website/chatbot/templates/chatbot/about.html new file mode 100644 index 0000000..4d9d167 --- /dev/null +++ b/Merilife/MediBot/chatbot-website/chatbot/templates/chatbot/about.html @@ -0,0 +1,37 @@ +{% load static %} + + + + + + About Me - Medico + + + + + + +
+

About Me

+ Aditya Upadhyay +

My name is Aditya Upadhyay, a passionate and dedicated student currently pursuing my degree from IIIT Delhi. I have a strong foundation in computer science and an avid interest in software development, algorithms, and data structures. My coding skills span across languages like C, C++, Python, and I am comfortable working with tools like Git, NumPy, pandas, and Matplotlib.

+

I have successfully contributed to various academic and personal projects involving image processing, data analysis, and machine learning. I actively participate in hackathons, coding competitions, and have consistently ranked among top performers in programming contests. My accomplishments include completing internships, volunteering for NGOs, and making meaningful contributions to open-source projects.

+

I strive to continuously learn and grow, seeking opportunities where I can apply my skills to solve real-world problems.

+
+ + \ No newline at end of file diff --git a/Merilife/MediBot/chatbot-website/chatbot/templates/chatbot/index.html b/Merilife/MediBot/chatbot-website/chatbot/templates/chatbot/index.html index 35a507d..7d9798f 100644 --- a/Merilife/MediBot/chatbot-website/chatbot/templates/chatbot/index.html +++ b/Merilife/MediBot/chatbot-website/chatbot/templates/chatbot/index.html @@ -161,12 +161,13 @@ @@ -154,16 +240,126 @@ // DOM refs const chatBody = $('#chat-body'), - input = $('#user-input'), - sendBtn = $('#send-btn'), - micBtn = $('#mic-btn'), - langSel = $('#lang-select'); + input = $('#user-input'), + sendBtn = $('#send-btn'), + micBtn = $('#mic-btn'), + langModal = $('.language-modal'), + langButtons = $('.lang-btn'), + langMicBtn = $('#lang-mic-btn'); + + let selectedLang = null; + let recognition; + let languageRecognition; - // Add message to UI (and speak bot ones) + // Add message to UI + // Update addMessage function function addMessage(text, cls) { - chatBody.append($('
').addClass('message '+cls).text(text)); + let message = $('
').addClass('message '+cls); + + if (cls === 'bot' && text.includes('specialization')) { + message.addClass('specialization'); + message.html(`${text}`); + } else { + message.text(text); + } + + chatBody.append(message); chatBody.scrollTop(chatBody[0].scrollHeight); - if (cls === 'bot') speak(text, langSel.val()); + if (cls === 'bot') speak(text, selectedLang); + } + + // Initialize speech recognition + function initSpeechRecognition() { + if ('SpeechRecognition' in window || 'webkitSpeechRecognition' in window) { + const SR = window.SpeechRecognition || window.webkitSpeechRecognition; + recognition = new SR(); + recognition.continuous = false; + recognition.interimResults = false; + recognition.lang = selectedLang; + + micBtn.on('click', () => { + recognition.lang = selectedLang; + micBtn.toggleClass('active'); + if (micBtn.hasClass('active')) recognition.start(); + else recognition.stop(); + }); + + recognition.onresult = event => { + const transcript = event.results[0][0].transcript; + input.val(transcript); + sendAnswer(); + }; + + recognition.onend = () => micBtn.removeClass('active'); + recognition.onerror = e => console.error('Speech error:', e); + } else { + micBtn.hide(); + } + } + + // Language detection setup + function initLanguageRecognition() { + if ('SpeechRecognition' in window || 'webkitSpeechRecognition' in window) { + const SR = window.SpeechRecognition || window.webkitSpeechRecognition; + languageRecognition = new SR(); + languageRecognition.continuous = false; + languageRecognition.interimResults = false; + languageRecognition.lang = 'en-US'; + + langMicBtn.click(() => { + langMicBtn.addClass('active'); + languageRecognition.start(); + }); + + languageRecognition.onresult = (event) => { + const spokenLang = event.results[0][0].transcript.toLowerCase(); + const langMap = { + 'english': 'en-US', + 'hindi': 'hi-IN', + 'bengali': 'bn-IN', + 'marathi': 'mr-IN', + 'tamil': 'ta-IN', + 'telugu': 'te-IN', + 'gujarati': 'gu-IN', + 'kannada': 'kn-IN', + 'malayalam': 'ml-IN', + 'punjabi': 'pa-IN', + 'spanish': 'es-ES', + 'french': 'fr-FR', + 'inglés': 'en-US', + 'हिंदी': 'hi-IN', + 'বাংলা': 'bn-IN', + 'मराठी': 'mr-IN', + 'தமிழ்': 'ta-IN', + 'తెలుగు': 'te-IN', + 'ગુજરાતી': 'gu-IN', + 'ಕನ್ನಡ': 'kn-IN', + 'മലയാളം': 'ml-IN', + 'ਪੰਜਾਬੀ': 'pa-IN', + 'español': 'es-ES', + 'francés': 'fr-FR' + }; + + for (const [key, value] of Object.entries(langMap)) { + if (spokenLang.includes(key)) { + setLanguage(value); + return; + } + } + alert('Language not supported. Please select manually.'); + }; + + languageRecognition.onend = () => langMicBtn.removeClass('active'); + } + } + + // Set selected language + function setLanguage(lang) { + selectedLang = lang; + langModal.hide(); + $('.chat-container').show(); + initSpeechRecognition(); + fetchQuestion(); } // Fetch first question @@ -171,8 +367,17 @@ $.ajax({ url: "{% url 'medical_chat' %}", method: 'GET', + data: { + language: selectedLang + }, success(resp) { - if (resp.status==='question') addMessage(resp.question,'bot'); + if (resp.status === 'question') { + addMessage(resp.question, 'bot'); + } + }, + error: function(xhr) { + console.error('Error:', xhr.responseText); + addMessage('Server error. Please try again.', 'bot'); } }); } @@ -181,20 +386,42 @@ function sendAnswer() { const text = input.val().trim(); if (!text) return; - addMessage(text,'user'); + addMessage(text, 'user'); input.val(''); + $.ajax({ url: "{% url 'medical_chat' %}", method: 'POST', - headers: {'X-CSRFToken': csrftoken}, - data: { user_input: text }, + headers: { 'X-CSRFToken': csrftoken }, + data: { + user_input: text, + language: selectedLang + }, success(resp) { - if (resp.status==='question') addMessage(resp.question,'bot'); - else if (resp.status==='complete') { - addMessage('--- Report ---','bot'); - addMessage(resp.report,'bot'); - addMessage('--- Diagnosis ---','bot'); - addMessage(resp.diagnosis,'bot'); + if (resp.status === 'question') { + addMessage(resp.question, 'bot'); + } else if (resp.status === 'complete') { + addMessage('--- Report ---', 'bot'); + addMessage(resp.report, 'bot'); + addMessage('--- Diagnosis ---', 'bot'); + addMessage(resp.diagnosis, 'bot'); + console.log(resp.specialization) + if(resp.specialization) { + addMessage('Recommended doctor specialization:', 'bot'); + addMessage(`You should consult a ${resp.specialization} specialist`, 'bot'); + } + $('#user-input').prop('disabled', true).attr('placeholder', 'Chat closed - Report generated'); + $('#send-btn, #mic-btn').prop('disabled', true); + // ====== ADD THIS BLOCK RIGHT HERE ====== + // Disable chat interface + $('.chat-footer').addClass('chat-disabled'); + $('#user-input').prop('disabled', true).attr('placeholder', 'Chat closed'); + $('#send-btn, #mic-btn').prop('disabled', true); + $('#chat-status').show().text('Report generated - chat closed'); + // ====== END OF ADDED CODE ====== + // Add final message + addMessage('Chat session closed. Report has been generated.', 'bot'); + // addMessage('You can download the report from your profile.', 'bot'); } } }); @@ -210,38 +437,21 @@ speechSynthesis.speak(utt); } - // Setup - $(function(){ - fetchQuestion(); - sendBtn.click(sendAnswer); - input.keypress(e => { if (e.which===13) sendAnswer(); }); - }); - - // SpeechRecognition setup - let recognition; - if ('SpeechRecognition' in window || 'webkitSpeechRecognition' in window) { - const SR = window.SpeechRecognition || window.webkitSpeechRecognition; - recognition = new SR(); - recognition.continuous = false; - recognition.interimResults = false; - - micBtn.on('click', () => { - recognition.lang = langSel.val(); - micBtn.toggleClass('active'); - if (micBtn.hasClass('active')) recognition.start(); - else recognition.stop(); + // Initialize + $(function() { + // Language selection + langButtons.click(function() { + setLanguage($(this).data('lang')); }); - recognition.onresult = event => { - const transcript = event.results[0][0].transcript; - input.val(transcript); - sendAnswer(); - }; - recognition.onend = () => micBtn.removeClass('active'); - recognition.onerror = e => alert('Speech error: '+e.error); - } else { - micBtn.hide(); - } + initLanguageRecognition(); + $('.chat-container').hide(); + langModal.show(); + + // Send message handlers + sendBtn.click(sendAnswer); + input.keypress(e => { if (e.which === 13) sendAnswer(); }); + }); - + \ No newline at end of file diff --git a/Merilife/MediBot/chatbot-website/chatbot/templates/chatbot/report_gen.html b/Merilife/MediBot/chatbot-website/chatbot/templates/chatbot/report_gen.html index 0278b6b..9a8758a 100644 --- a/Merilife/MediBot/chatbot-website/chatbot/templates/chatbot/report_gen.html +++ b/Merilife/MediBot/chatbot-website/chatbot/templates/chatbot/report_gen.html @@ -292,6 +292,16 @@

🩺 Medico Report Generator

// The report_gen view returns bot_response directly if (response.status === 'success') { addMessage(response.response, 'bot-message'); + // Check for report completion keywords + if ( + response.response.includes('Diagnosis') || + response.response.includes('Preliminary Diagnosis') + ) { + userInput.prop('disabled', true); + sendButton.prop('disabled', true); + micButton.prop('disabled', true); + typingIndicator.hide(); + } } else { addMessage(`⚠️ ${response.response || 'Error processing request'}`, 'bot-message'); } diff --git a/Merilife/MediBot/chatbot-website/chatbot/tests/__pycache__/__init__.cpython-312.pyc b/Merilife/MediBot/chatbot-website/chatbot/tests/__pycache__/__init__.cpython-312.pyc deleted file mode 100644 index d3b38cd..0000000 Binary files a/Merilife/MediBot/chatbot-website/chatbot/tests/__pycache__/__init__.cpython-312.pyc and /dev/null differ diff --git a/Merilife/MediBot/chatbot-website/chatbot/tests/__pycache__/conftest.cpython-312-pytest-8.3.5.pyc b/Merilife/MediBot/chatbot-website/chatbot/tests/__pycache__/conftest.cpython-312-pytest-8.3.5.pyc deleted file mode 100644 index f24e852..0000000 Binary files a/Merilife/MediBot/chatbot-website/chatbot/tests/__pycache__/conftest.cpython-312-pytest-8.3.5.pyc and /dev/null differ diff --git a/Merilife/MediBot/chatbot-website/chatbot/tests/__pycache__/test_ai.cpython-312-pytest-8.3.5.pyc b/Merilife/MediBot/chatbot-website/chatbot/tests/__pycache__/test_ai.cpython-312-pytest-8.3.5.pyc deleted file mode 100644 index 9ace712..0000000 Binary files a/Merilife/MediBot/chatbot-website/chatbot/tests/__pycache__/test_ai.cpython-312-pytest-8.3.5.pyc and /dev/null differ diff --git a/Merilife/MediBot/chatbot-website/chatbot/tests/__pycache__/test_ai.cpython-312.pyc b/Merilife/MediBot/chatbot-website/chatbot/tests/__pycache__/test_ai.cpython-312.pyc deleted file mode 100644 index 871bf32..0000000 Binary files a/Merilife/MediBot/chatbot-website/chatbot/tests/__pycache__/test_ai.cpython-312.pyc and /dev/null differ diff --git a/Merilife/MediBot/chatbot-website/chatbot/tests/__pycache__/test_auth.cpython-312-pytest-8.3.5.pyc b/Merilife/MediBot/chatbot-website/chatbot/tests/__pycache__/test_auth.cpython-312-pytest-8.3.5.pyc deleted file mode 100644 index b7db053..0000000 Binary files a/Merilife/MediBot/chatbot-website/chatbot/tests/__pycache__/test_auth.cpython-312-pytest-8.3.5.pyc and /dev/null differ diff --git a/Merilife/MediBot/chatbot-website/chatbot/tests/__pycache__/test_auth.cpython-312.pyc b/Merilife/MediBot/chatbot-website/chatbot/tests/__pycache__/test_auth.cpython-312.pyc deleted file mode 100644 index 3f5ecbb..0000000 Binary files a/Merilife/MediBot/chatbot-website/chatbot/tests/__pycache__/test_auth.cpython-312.pyc and /dev/null differ diff --git a/Merilife/MediBot/chatbot-website/chatbot/tests/__pycache__/test_e2e.cpython-312-pytest-8.3.5.pyc b/Merilife/MediBot/chatbot-website/chatbot/tests/__pycache__/test_e2e.cpython-312-pytest-8.3.5.pyc deleted file mode 100644 index 252a293..0000000 Binary files a/Merilife/MediBot/chatbot-website/chatbot/tests/__pycache__/test_e2e.cpython-312-pytest-8.3.5.pyc and /dev/null differ diff --git a/Merilife/MediBot/chatbot-website/chatbot/tests/__pycache__/test_e2e.cpython-312.pyc b/Merilife/MediBot/chatbot-website/chatbot/tests/__pycache__/test_e2e.cpython-312.pyc deleted file mode 100644 index 54a982b..0000000 Binary files a/Merilife/MediBot/chatbot-website/chatbot/tests/__pycache__/test_e2e.cpython-312.pyc and /dev/null differ diff --git a/Merilife/MediBot/chatbot-website/chatbot/tests/__pycache__/test_integration.cpython-312-pytest-8.3.5.pyc b/Merilife/MediBot/chatbot-website/chatbot/tests/__pycache__/test_integration.cpython-312-pytest-8.3.5.pyc deleted file mode 100644 index 8f81482..0000000 Binary files a/Merilife/MediBot/chatbot-website/chatbot/tests/__pycache__/test_integration.cpython-312-pytest-8.3.5.pyc and /dev/null differ diff --git a/Merilife/MediBot/chatbot-website/chatbot/tests/__pycache__/test_integration.cpython-312.pyc b/Merilife/MediBot/chatbot-website/chatbot/tests/__pycache__/test_integration.cpython-312.pyc deleted file mode 100644 index 1202921..0000000 Binary files a/Merilife/MediBot/chatbot-website/chatbot/tests/__pycache__/test_integration.cpython-312.pyc and /dev/null differ diff --git a/Merilife/MediBot/chatbot-website/chatbot/tests/__pycache__/test_models.cpython-312-pytest-8.3.5.pyc b/Merilife/MediBot/chatbot-website/chatbot/tests/__pycache__/test_models.cpython-312-pytest-8.3.5.pyc deleted file mode 100644 index bf0a56a..0000000 Binary files a/Merilife/MediBot/chatbot-website/chatbot/tests/__pycache__/test_models.cpython-312-pytest-8.3.5.pyc and /dev/null differ diff --git a/Merilife/MediBot/chatbot-website/chatbot/tests/__pycache__/test_models.cpython-312.pyc b/Merilife/MediBot/chatbot-website/chatbot/tests/__pycache__/test_models.cpython-312.pyc deleted file mode 100644 index 5dc1f93..0000000 Binary files a/Merilife/MediBot/chatbot-website/chatbot/tests/__pycache__/test_models.cpython-312.pyc and /dev/null differ diff --git a/Merilife/MediBot/chatbot-website/chatbot/tests/__pycache__/test_nlp.cpython-312-pytest-8.3.5.pyc b/Merilife/MediBot/chatbot-website/chatbot/tests/__pycache__/test_nlp.cpython-312-pytest-8.3.5.pyc deleted file mode 100644 index 7418b35..0000000 Binary files a/Merilife/MediBot/chatbot-website/chatbot/tests/__pycache__/test_nlp.cpython-312-pytest-8.3.5.pyc and /dev/null differ diff --git a/Merilife/MediBot/chatbot-website/chatbot/tests/__pycache__/test_nlp.cpython-312.pyc b/Merilife/MediBot/chatbot-website/chatbot/tests/__pycache__/test_nlp.cpython-312.pyc deleted file mode 100644 index 658d510..0000000 Binary files a/Merilife/MediBot/chatbot-website/chatbot/tests/__pycache__/test_nlp.cpython-312.pyc and /dev/null differ diff --git a/Merilife/MediBot/chatbot-website/chatbot/tests/__pycache__/test_pairwise.cpython-312-pytest-8.3.5.pyc b/Merilife/MediBot/chatbot-website/chatbot/tests/__pycache__/test_pairwise.cpython-312-pytest-8.3.5.pyc deleted file mode 100644 index 0c30849..0000000 Binary files a/Merilife/MediBot/chatbot-website/chatbot/tests/__pycache__/test_pairwise.cpython-312-pytest-8.3.5.pyc and /dev/null differ diff --git a/Merilife/MediBot/chatbot-website/chatbot/tests/__pycache__/test_pairwise.cpython-312.pyc b/Merilife/MediBot/chatbot-website/chatbot/tests/__pycache__/test_pairwise.cpython-312.pyc deleted file mode 100644 index d61582d..0000000 Binary files a/Merilife/MediBot/chatbot-website/chatbot/tests/__pycache__/test_pairwise.cpython-312.pyc and /dev/null differ diff --git a/Merilife/MediBot/chatbot-website/chatbot/tests/__pycache__/test_reports.cpython-312-pytest-8.3.5.pyc b/Merilife/MediBot/chatbot-website/chatbot/tests/__pycache__/test_reports.cpython-312-pytest-8.3.5.pyc deleted file mode 100644 index 7db56e5..0000000 Binary files a/Merilife/MediBot/chatbot-website/chatbot/tests/__pycache__/test_reports.cpython-312-pytest-8.3.5.pyc and /dev/null differ diff --git a/Merilife/MediBot/chatbot-website/chatbot/tests/__pycache__/test_reports.cpython-312.pyc b/Merilife/MediBot/chatbot-website/chatbot/tests/__pycache__/test_reports.cpython-312.pyc deleted file mode 100644 index 85825c5..0000000 Binary files a/Merilife/MediBot/chatbot-website/chatbot/tests/__pycache__/test_reports.cpython-312.pyc and /dev/null differ diff --git a/Merilife/MediBot/chatbot-website/chatbot/tests/__pycache__/test_security.cpython-312-pytest-8.3.5.pyc b/Merilife/MediBot/chatbot-website/chatbot/tests/__pycache__/test_security.cpython-312-pytest-8.3.5.pyc deleted file mode 100644 index d576ab5..0000000 Binary files a/Merilife/MediBot/chatbot-website/chatbot/tests/__pycache__/test_security.cpython-312-pytest-8.3.5.pyc and /dev/null differ diff --git a/Merilife/MediBot/chatbot-website/chatbot/tests/__pycache__/test_security.cpython-312.pyc b/Merilife/MediBot/chatbot-website/chatbot/tests/__pycache__/test_security.cpython-312.pyc deleted file mode 100644 index 2023b7f..0000000 Binary files a/Merilife/MediBot/chatbot-website/chatbot/tests/__pycache__/test_security.cpython-312.pyc and /dev/null differ diff --git a/Merilife/MediBot/chatbot-website/chatbot/tests/__pycache__/test_views.cpython-312-pytest-8.3.5.pyc b/Merilife/MediBot/chatbot-website/chatbot/tests/__pycache__/test_views.cpython-312-pytest-8.3.5.pyc deleted file mode 100644 index dff9c01..0000000 Binary files a/Merilife/MediBot/chatbot-website/chatbot/tests/__pycache__/test_views.cpython-312-pytest-8.3.5.pyc and /dev/null differ diff --git a/Merilife/MediBot/chatbot-website/chatbot/tests/__pycache__/test_views.cpython-312.pyc b/Merilife/MediBot/chatbot-website/chatbot/tests/__pycache__/test_views.cpython-312.pyc deleted file mode 100644 index 4e86c7e..0000000 Binary files a/Merilife/MediBot/chatbot-website/chatbot/tests/__pycache__/test_views.cpython-312.pyc and /dev/null differ diff --git a/Merilife/MediBot/chatbot-website/chatbot/tests/test_ai.py b/Merilife/MediBot/chatbot-website/chatbot/tests/test_ai.py index 9b3ce86..194767e 100644 --- a/Merilife/MediBot/chatbot-website/chatbot/tests/test_ai.py +++ b/Merilife/MediBot/chatbot-website/chatbot/tests/test_ai.py @@ -24,4 +24,14 @@ def test_genai_integration(self, mock_client): def test_medical_report_generation(self): with patch('chatbot.ai_wrapper.GENAI_CLIENT_WORKING', False): report = generate_medical_report('Patient has fever') - self.assertIn('MEDICAL REPORT', report) \ No newline at end of file + self.assertIn('MEDICAL REPORT', report) + + def test_google_genai_api_message(self): + try: + import google.generativeai as genai + genai.configure(api_key="AIzaSyB0R26JpwnrxR1iHP7SRdlXImYhG2NAYLQ") + model = genai.GenerativeModel('gemini-2.0-flash') + response = model.generate_content("Hello, are you working?") + assert hasattr(response, 'text') and response.text + except Exception as e: + assert False, f"Google GenAI API call failed: {e}" \ No newline at end of file diff --git a/Merilife/MediBot/chatbot-website/chatbot/tests/test_reports.py b/Merilife/MediBot/chatbot-website/chatbot/tests/test_reports.py index 5beab00..775089e 100644 --- a/Merilife/MediBot/chatbot-website/chatbot/tests/test_reports.py +++ b/Merilife/MediBot/chatbot-website/chatbot/tests/test_reports.py @@ -3,7 +3,8 @@ from django.urls import reverse from django.test import Client, TestCase from django.contrib.auth import get_user_model -from chatbot.views.views import _generate_report as generate_report, generate_pdf +from chatbot.utils import text_to_pdf +from django.test import RequestFactory import pytest @pytest.mark.django_db @@ -17,20 +18,37 @@ def test_report_content_generation(patient_user): @pytest.mark.django_db def test_pdf_generation(sample_report): - class DummyRequest: - user = type('User', (), {'is_authenticated': True, 'is_superuser': False, 'doctor_profile': False})() - pdf = generate_pdf(DummyRequest(), sample_report) - assert b'%PDF' in pdf[:4] + # Test PDF utility directly + pdf_filename = text_to_pdf("Sample PDF Content for Testing") + import os + from django.conf import settings + filepath = os.path.join(settings.MEDIA_ROOT, pdf_filename) + assert os.path.exists(filepath) + with open(filepath, 'rb') as f: + content = f.read() + assert content.startswith(b'%PDF') + os.remove(filepath) @pytest.mark.django_db def test_report_generation(patient_user): - report, _ = generate_report(patient_user) - assert 'URI' in report.content or 'report' in report.content.lower() - assert hasattr(report, 'patient') or hasattr(report, 'user') + # Test _generate_report with dummy request and history + from chatbot.views.views import _generate_report + factory = RequestFactory() + request = factory.get('/') + history = "Q1: What are your main symptoms?\nA1: cold" + report, diagnosis, specialization = _generate_report(history, request) + assert 'report' in report.lower() or 'cold' in report.lower() + assert isinstance(diagnosis, str) + assert isinstance(specialization, str) @pytest.mark.django_db -def test_pdf_creation(sample_report): - class DummyRequest: - user = type('User', (), {'is_authenticated': True, 'is_superuser': False, 'doctor_profile': False})() - pdf_content = generate_pdf(DummyRequest(), sample_report) - assert pdf_content.startswith(b'%PDF') \ No newline at end of file +def test_pdf_creation(): + # Test PDF creation utility for binary output + pdf_filename = text_to_pdf("PDF binary test content") + import os + from django.conf import settings + filepath = os.path.join(settings.MEDIA_ROOT, pdf_filename) + with open(filepath, 'rb') as f: + content = f.read() + assert content.startswith(b'%PDF') + os.remove(filepath) \ No newline at end of file diff --git a/Merilife/MediBot/chatbot-website/chatbot/urls.py b/Merilife/MediBot/chatbot-website/chatbot/urls.py index 7b10075..83e7044 100644 --- a/Merilife/MediBot/chatbot-website/chatbot/urls.py +++ b/Merilife/MediBot/chatbot-website/chatbot/urls.py @@ -1,5 +1,5 @@ from django.urls import path -from .views.views import index, user_login, register_user, chat, doctor_dashboard, register_doctor, user_logout, generate_pdf, pdf_preview, close_treatment, view_treatment_history +from .views.views import index, user_login, register_user, chat, doctor_dashboard, register_doctor, user_logout, generate_pdf, pdf_preview, close_treatment, view_treatment_history, about from django.conf.urls.static import static from django.conf import settings from .views.views import reportgen, medical_chat @@ -9,6 +9,7 @@ urlpatterns = [ # path('admin/register_doctor/', register_doctor, name='register_doctor'), # Admin-only doctor registration path('', index, name='index'), + path('about/', about, name='about'), # About page link path('login/', user_login, name='login'), path('logout/', user_logout, name='logout'), path('register/', register_user, name='register'), diff --git a/Merilife/MediBot/chatbot-website/chatbot/views/__pycache__/views.cpython-311.pyc b/Merilife/MediBot/chatbot-website/chatbot/views/__pycache__/views.cpython-311.pyc index 0b53d15..8f0b638 100644 Binary files a/Merilife/MediBot/chatbot-website/chatbot/views/__pycache__/views.cpython-311.pyc and b/Merilife/MediBot/chatbot-website/chatbot/views/__pycache__/views.cpython-311.pyc differ diff --git a/Merilife/MediBot/chatbot-website/chatbot/views/__pycache__/views.cpython-312.pyc b/Merilife/MediBot/chatbot-website/chatbot/views/__pycache__/views.cpython-312.pyc deleted file mode 100644 index a23f7ce..0000000 Binary files a/Merilife/MediBot/chatbot-website/chatbot/views/__pycache__/views.cpython-312.pyc and /dev/null differ diff --git a/Merilife/MediBot/chatbot-website/chatbot/views/views.py b/Merilife/MediBot/chatbot-website/chatbot/views/views.py index 7f2cadc..cfdd56f 100644 --- a/Merilife/MediBot/chatbot-website/chatbot/views/views.py +++ b/Merilife/MediBot/chatbot-website/chatbot/views/views.py @@ -92,7 +92,7 @@ def user_login(request): if user is not None: login(request, user) if user.is_superuser: - return redirect('admin:index') + return redirect('index') # send admins to site homepage where Register Doctor appears # doctors are users with a linked DoctorProfile if hasattr(user, 'doctor_profile'): return redirect('doctor_dashboard') @@ -153,6 +153,17 @@ def register_doctor(request): return render(request, 'chatbot/register_doctor.html') @login_required def doctor_dashboard(request): + doctor_profile = getattr(request.user, 'doctor_profile', None) + if not doctor_profile: + return redirect('login') + # Get doctor's actual specialization from their profile + doctor_specialization = doctor_profile.specialization + # Treatments must match both doctor AND reqd=their specialization + open_treatments = Treatment.objects.filter( + doctor=request.user, + is_closed=False, + reqd=doctor_specialization # Critical filter + ) # Ensure only doctors can access this view is_doctor = False try: @@ -165,34 +176,41 @@ def doctor_dashboard(request): messages.error(request, 'Access denied') return redirect('login') - # Fetch open and closed treatments assigned to the logged-in doctor + # Only show treatments with required specialization matching the doctor's specialization + doctor_specialization = request.user.doctor_profile.specialization open_treatments = Treatment.objects.filter( - doctor=request.user, - is_closed=False + doctor=request.user, + is_closed=False, + reqd=doctor_specialization ).select_related('patient').prefetch_related('treatment_reports') closed_treatments = Treatment.objects.filter( - doctor=request.user, - is_closed=True + doctor=request.user, + is_closed=True, + reqd=doctor_specialization ).select_related('patient').prefetch_related('treatment_reports') - + # Get statistics today_appointments = Treatment.objects.filter( doctor=request.user, - created_at__date=now().date() + created_at__date=now().date(), + reqd=doctor_specialization ).count() - + total_patients = Treatment.objects.filter( - doctor=request.user + doctor=request.user, + reqd=doctor_specialization ).values('patient').distinct().count() - + total_reports = Report.objects.filter( - treatment__doctor=request.user + treatment__doctor=request.user, + treatment__reqd=doctor_specialization ).count() - + pending_reviews = Treatment.objects.filter( doctor=request.user, - is_closed=False + is_closed=False, + reqd=doctor_specialization ).count() context = { @@ -203,7 +221,8 @@ def doctor_dashboard(request): 'total_reports': total_reports, 'pending_reviews': pending_reviews, 'recent_reports': Report.objects.filter( - treatment__doctor=request.user + treatment__doctor=request.user, + treatment__reqd=doctor_specialization ).select_related('user', 'treatment').order_by('-created_at')[:5] } return render(request, 'chatbot/doctor_dashboard.html', context) @@ -220,8 +239,10 @@ def close_treatment(request, treatment_id): @login_required def view_treatment_history(request, treatment_id): - # Only assigned doctor can view the history + # Only assigned doctor with matching specialization can view the history treatment = get_object_or_404(Treatment, id=treatment_id, doctor=request.user) + if treatment.reqd != request.user.doctor_profile.specialization: + return HttpResponse('Unauthorized: Specialization mismatch', status=403) # Build file path history_file = os.path.join(settings.MEDIA_ROOT, 'reports_text', f"{treatment.patient.uid}.txt") if not os.path.exists(history_file): @@ -366,28 +387,127 @@ def reportgen(request): genai.configure(api_key="AIzaSyB0R26JpwnrxR1iHP7SRdlXImYhG2NAYLQ") # Create client instances for different purposes -med_chat_model = genai.GenerativeModel('gemini-1.5-flash') -report_model = genai.GenerativeModel('gemini-1.5-flash') -system_instruction = ( - "You are a medical assistant chatbot. Follow this EXACT process:" - "\n1. Ask the patient: 'What are your main symptoms?'" - "\n2. Ask the patient: 'How long have you been experiencing these symptoms?'" - "\n3. Ask the patient: 'Do you have any previous medical conditions?'" - "\n4. Based on all previous answers, ask ONE relevant follow-up question." - "\n5. Based on all previous answers, ask ONE final relevant follow-up question." - "\nAfter collecting all answers, generate a medical report with sections for History of Present Illness, " - "Medications, and Allergies. Then include the delimiter '###1234###' on a new line, followed by your preliminary diagnosis." - "\nDo NOT ask multiple questions at once. Ask EXACTLY ONE question at a time and wait for the answer." - "First old prompt is giiven to u if user has that will be used to generate the report. in complete info explasin that too like earlier issues and then add full info of the user and then ask the question. " -) -fixed_questions = [ - "What are your main symptoms?", - "How long have you been experiencing these symptoms?", - "Do you have any previous medical conditions?" -]# Decorator to exempt CSRF for simplicity +med_chat_model = genai.GenerativeModel('gemini-2.0-flash') +report_model = genai.GenerativeModel('gemini-2.0-flash') +# system_instruction = ( +# "You are a medical assistant chatbot. Follow this EXACT process:" +# "\n1. Ask the patient: 'What are your main symptoms?'" +# "\n2. Ask the patient: 'How long have you been experiencing these symptoms?'" +# "\n3. Ask the patient: 'Do you have any previous medical conditions?'" +# "\n4. Based on all previous answers, ask ONE relevant follow-up question." +# "\n5. Based on all previous answers, ask ONE final relevant follow-up question." +# "\nAfter collecting all answers, generate a medical report with sections for History of Present Illness, " +# "Medications, and Allergies. Then include the delimiter '###1234###' on a new line, followed by your preliminary diagnosis." +# "\nDo NOT ask multiple questions at once. Ask EXACTLY ONE question at a time and wait for the answer." +# "First old prompt is giiven to u if user has that will be used to generate the report. in complete info explasin that too like earlier issues and then add full info of the user and then ask the question. " +# ) + +TRANSLATED_QUESTIONS = { + 'en-US': [ + "What are your main symptoms?", + "How long have you been experiencing these symptoms?", + "Do you have any previous medical conditions?" + ], + 'hi-IN': [ + "आपके मुख्य लक्षण क्या हैं?", + "आपको ये लक्षण कितने समय से हैं?", + "क्या आपको कोई पूर्व चिकित्सीय स्थितियां हैं?" + ], + 'bn-IN': [ + "আপনার প্রধান উপসর্গ কী?", + "আপনি কতদিন ধরে এই উপসর্গগুলি অনুভব করছেন?", + "আপনার কি কোনো পূর্ববর্তী চিকিৎসা অবস্থা আছে?" + ], + 'mr-IN': [ + "आपली मुख्य लक्षणे कोणती आहेत?", + "आपण ही लक्षणे किती दिवसांपासून अनुभवत आहात?", + "आपल्याला कोणतीही पूर्व वैद्यकीय स्थिती आहे का?" + ], + 'ta-IN': [ + "உங்கள் முக்கிய அறிகுறிகள் என்ன?", + "இந்த அறிகுறிகள் எவ்வளவு நாட்களாக உள்ளன?", + "உங்களுக்கு ஏதேனும் முன் மருத்துவ நிலைகள் உள்ளனவா?" + ], + 'te-IN': [ + "మీ ప్రధాన లక్షణాలు ఏమిటి?", + "ఈ లక్షణాలు ఎంతకాలంగా ఉన్నాయి?", + "మీకు ఎలాంటి గత వైద్య పరిస్థితులు ఉన్నాయా?" + ], + 'gu-IN': [ + "તમારા મુખ્ય લક્ષણો શું છે?", + "આ લક્ષણો કેટલા સમયથી છે?", + "શું તમને કોઈ અગાઉની તબીબી સ્થિતિ છે?" + ], + 'kn-IN': [ + "ನಿಮ್ಮ ಮುಖ್ಯ ಲಕ್ಷಣಗಳು ಯಾವುವು?", + "ಈ ಲಕ್ಷಣಗಳು ಎಷ್ಟು ದಿನಗಳಿಂದ ಇವೆ?", + "ನಿಮಗೆ ಯಾವುದೇ ಹಿಂದಿನ ವೈದ್ಯಕೀಯ ಸ್ಥಿತಿಗಳು ಇದೆಯೆ?" + ], + 'ml-IN': [ + "നിങ്ങളുടെ പ്രധാന ലക്ഷണങ്ങൾ എന്താണ്?", + "ഈ ലക്ഷണങ്ങൾ എത്ര ദിവസമായി ഉണ്ട്?", + "നിങ്ങൾക്ക് മുൻപ് ഏതെങ്കിലും മെഡിക്കൽ അവസ്ഥയുണ്ടോ?" + ], + 'pa-IN': [ + "ਤੁਹਾਡੇ ਮੁੱਖ ਲੱਛਣ ਕੀ ਹਨ?", + "ਤੁਸੀਂ ਇਹ ਲੱਛਣ ਕਿੰਨੇ ਸਮੇਂ ਤੋਂ ਮਹਿਸੂਸ ਕਰ ਰਹੇ ਹੋ?", + "ਕੀ ਤੁਹਾਨੂੰ ਕੋਈ ਪਿਛਲੀ ਮੈਡੀਕਲ ਹਾਲਤ ਹੈ?" + ], + 'es-ES': [ + "¿Cuáles son sus síntomas principales?", + "¿Cuánto tiempo ha estado experimentando estos síntomas?", + "¿Tiene alguna condición médica previa?" + ], + 'fr-FR': [ + "Quels sont vos principaux symptômes?", + "Depuis combien de temps avez-vous ces symptômes?", + "Avez-vous des antécédents médicaux?" + ] +} + +LANGUAGE_MAP = { + 'en-US': 'English', + 'hi-IN': 'Hindi', + 'bn-IN': 'Bengali', + 'mr-IN': 'Marathi', + 'ta-IN': 'Tamil', + 'te-IN': 'Telugu', + 'gu-IN': 'Gujarati', + 'kn-IN': 'Kannada', + 'ml-IN': 'Malayalam', + 'pa-IN': 'Punjabi', + 'es-ES': 'Spanish', + 'fr-FR': 'French' +} + +fixed_questions = TRANSLATED_QUESTIONS['en-US'] # Default to English + @csrf_exempt def medical_chat(request): - # Prepare per-user history file + # Get selected language + selected_lang = request.POST.get('language', request.GET.get('language', 'en-US')) + lang_name = LANGUAGE_MAP.get(selected_lang, 'English') + fixed_questions = TRANSLATED_QUESTIONS.get(selected_lang, TRANSLATED_QUESTIONS['en-US']) + + # Store language in session + request.session['selected_lang'] = selected_lang + + # System instruction with language context + system_instruction = ( + f"You are a {lang_name}-speaking medical assistant. Follow these rules:\n" + "1. Ask questions ONLY in {lang_name}\n" + "2. Never repeat questions\n" + "3. Understand inputs in ANY language\n" + "4. Progress through: symptoms -> duration -> history -> follow-ups\n" + "5. Make questions distinct and clinically relevant\n\n" + "Process:\n" + "1-3: Fixed questions\n4-7: Unique follow-ups\n" + "After 7 answers, generate report with diagnosis after ###1234###" + ).format(lang_name=lang_name) + med_chat_model = genai.GenerativeModel( + 'gemini-1.5-flash', + system_instruction=system_instruction # Add this line + ) history_dir = os.path.join(settings.MEDIA_ROOT, 'reports_text') os.makedirs(history_dir, exist_ok=True) history_file = os.path.join(history_dir, f"{request.user.uid}.txt") @@ -401,6 +521,7 @@ def medical_chat(request): session = request.session.get('chat_session', { 'answers': [], 'question_count': 0, + 'asked_questions': [], # Track all questions that have been asked 'initial_prompt': request.POST.get('initial_prompt', '').strip() if request.method == 'POST' else '' }) @@ -410,18 +531,39 @@ def medical_chat(request): q_idx = session['question_count'] if q_idx < len(fixed_questions): question = fixed_questions[q_idx] - elif q_idx < len(fixed_questions) + 2: - question = _generate_followup(session['answers']) + elif q_idx < len(fixed_questions) + 4: # Up to 4 follow-up questions + question = _generate_followup(session['answers'],request) + + # Check if this question is too similar to previously asked questions + if question in session.get('asked_questions', []): + # Try one more time with a stronger instruction + question = _generate_followup(session['answers'] + ["Please ask about something different"],request) else: question = "All questions answered. Please submit your answers to generate the report." + + # Track this question + if 'asked_questions' not in session: + session['asked_questions'] = [] + if question not in session['asked_questions']: + session['asked_questions'].append(question) + request.session['chat_session'] = session return JsonResponse({'status': 'question', 'question': question}) # Handle POST: user submitted an answer user_input = request.POST.get('user_input', '').strip() - # Append user answer to file history + + # Get the current question being answered + q_idx = session['question_count'] + current_question = "" + if q_idx < len(fixed_questions): + current_question = fixed_questions[q_idx] + elif q_idx < len(fixed_questions) + 4 and 'asked_questions' in session and len(session['asked_questions']) > q_idx: + current_question = session['asked_questions'][q_idx] + + # Append user answer to file history with the question it answers with open(history_file, 'a', encoding='utf-8') as f: - f.write(f"Q{session['question_count'] + 1}: {user_input}\n") + f.write(f"Q{session['question_count'] + 1}: {current_question}\nA{session['question_count'] + 1}: {user_input}\n\n") # Update session session['answers'].append(user_input) @@ -434,18 +576,67 @@ def medical_chat(request): if q_idx < len(fixed_questions): next_q = fixed_questions[q_idx] return JsonResponse({'status': 'question', 'question': next_q}) - # Two dynamic follow-ups - elif q_idx < len(fixed_questions) + 2: - next_q = _generate_followup(session['answers']) + # Four dynamic follow-ups + elif q_idx < len(fixed_questions) + 4: + next_q = _generate_followup(session['answers'],request) + + # Check if this question is too similar to previously asked questions + if next_q in session.get('asked_questions', []): + # Try one more time with a stronger instruction + next_q = _generate_followup(session['answers'] + ["Please ask about something different"],request) + + # Add to asked questions + if 'asked_questions' not in session: + session['asked_questions'] = [] + if next_q not in session['asked_questions']: + session['asked_questions'].append(next_q) + request.session['chat_session'] = session + return JsonResponse({'status': 'question', 'question': next_q}) - # All 5 questions done, generate report + # All 7 questions done, generate report else: - full_history = _compile_history(session['initial_prompt'], session['answers']) - report, diagnosis = _generate_report(full_history) + full_history = _compile_history(session['initial_prompt'], session['answers'], session.get('asked_questions', [])) + report, diagnosis, specialization = _generate_report(full_history, request) # Changed here # Write report & diagnosis to file + + # After generating report, diagnosis, specialization = _generate_report(...) + # Get doctors with the recommended specialization + doctors = CustomUser.objects.filter( + doctor_profile__specialization=specialization, + doctor_profile__isnull=False # Ensure they have a doctor profile + ) + + # Fallback logic if no specialists found + if not doctors.exists(): + doctors = CustomUser.objects.filter( + doctor_profile__specialization='General Medicine', + doctor_profile__isnull=False + ) + + # Final fallback (assign any available doctor) + if not doctors.exists(): + doctors = CustomUser.objects.filter(doctor_profile__isnull=False) + + # Assign random doctor from filtered list + assigned = random.choice(list(doctors)) if doctors.exists() else None + + if assigned: + Treatment.objects.create( + patient=request.user, + doctor=assigned, + reqd=specialization, # Set to AI-recommended specialization + is_closed=False + ) + else: + # Handle error (no doctors available) + pass + + + + timestamp = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") with open(history_file, 'a', encoding='utf-8') as f: - f.write(f"=== {timestamp} ===\nReport:\n{report}\nDiagnosis: {diagnosis}\n") + f.write(f"=== {timestamp} ===\nReport:\n{report}\nDiagnosis: {diagnosis}\nRecommended Specialization: {specialization}\n") # Changed here # Create treatment entry doctors = CustomUser.objects.filter(doctor_profile__isnull=False) if doctors: @@ -458,96 +649,140 @@ def medical_chat(request): ) # Clear session request.session.pop('chat_session', None) - return JsonResponse({'status': 'complete', 'report': report, 'diagnosis': diagnosis}) - - -# def _generate_followup(answers): -# """ -# Use GenAI to generate a single follow-up question based on previous answers. -# """ -# prompt = ( -# "Based on these patient answers, ask exactly one relevant follow-up question:\n" -# + "\n".join(f"- {a}" for a in answers) -# ) -# chat = client.chats.create( -# model="gemini-1.5-flash", -# config=types.GenerateContentConfig( -# system_instruction="You are a helpful medical assistant.", -# ) -# ) -# response = chat.send_message(types.Part(text=prompt)) -# return response.text.strip() - -def _generate_followup(answers): - """ - Use GenAI to generate a single follow-up question based on previous answers. - """ + return JsonResponse({'status': 'complete', 'report': report, 'diagnosis': diagnosis, 'specialization': specialization}) + +# Modified _generate_followup function +def _generate_followup(answers, request): + selected_lang = request.session.get('selected_lang', 'en-US') + lang_name = LANGUAGE_MAP.get(selected_lang, 'English') + session = request.session.get('chat_session', {}) + + # Get previous questions and answers + asked_questions = session.get('asked_questions', []) + previous_qa = list(zip(asked_questions, answers)) + + # Build avoidance context + avoid_words = { + 'en-US': ["already asked", "repeat", "same"], + 'hi-IN': ["पहले पूछा", "दोहराएं", "वही"], + 'es-ES': ["ya preguntado", "repetir", "mismo"], + 'fr-FR': ["déjà demandé", "répéter", "même"] + }.get(selected_lang, []) + + # Recent context for narrowing the next step + recent_answers = answers[-2:] + avoid_list = ", ".join(avoid_words + asked_questions[-2:]) + + # Prompt with SOAP structure prompt = ( - "Based on these patient answers, ask exactly one relevant follow-up question:\n" - + "\n".join(f"- {a}" for a in answers) + f"Generate a unique and clinically relevant follow-up question in {lang_name}.\n\n" + "Conversation History:\n" + + "\n".join([f"Q{i+1}: {q}\nA{i+1}: {a}" for i, (q, a) in enumerate(previous_qa)]) + "\n\n" + "Guidelines:\n" + "1. Ask ONE new question in {lang_name}\n" + "2. Avoid repeating topics or phrases like: {avoid_list}\n" + "3. Use SOAP framework:\n" + " - S (Subjective): Consider symptoms or patient descriptions\n" + " - O (Objective): Consider measurable facts or observed signs\n" + " - A (Assessment): Try to narrow down the diagnostic thinking\n" + " - P (Plan): Lead towards management or next step in evaluation\n" + "4. Progress diagnosis logically based on recent answers: {recent_context}\n\n" + "Suggested question:".format( + lang_name=lang_name, + avoid_list=avoid_list, + recent_context=", ".join(recent_answers) + ) ) - + + + # Generate with higher temperature for variety response = med_chat_model.generate_content( prompt, - generation_config={"temperature": 0.7} + generation_config={"temperature": 0.8, "top_p": 0.95} ) - return response.text.strip() -def _compile_history(initial_prompt, answers): + question = response.text.strip() + + # Add question tracking by topic + current_topics = _extract_topics(question, selected_lang) + session['topics'] = session.get('topics', []) + current_topics + request.session['chat_session'] = session + + return question + + +def _extract_topics(question, lang): + topic_map = { + 'en-US': {'fever': ['fever', 'temperature', 'thermometer'], + 'pain': ['pain', 'hurt', 'ache']}, + 'hi-IN': {'fever': ['बुखार', 'तापमान', 'थर्मामीटर'], + 'pain': ['दर्द', 'पीड़ा']}, + # Add other languages + } + lang_topics = topic_map.get(lang, topic_map['en-US']) + return [topic for topic, keywords in lang_topics.items() + if any(kw in question.lower() for kw in keywords)] +def _compile_history(initial_prompt, answers, asked_questions=None): """ Compile the initial prompt (if any) and patient answers into a single text blob. """ history = [] if initial_prompt: history.append(f"Old Prompt: {initial_prompt}") - for idx, ans in enumerate(answers, start=1): - q = fixed_questions[idx-1] if idx <= len(fixed_questions) else f"Follow-up {idx - len(fixed_questions)}" - history.append(f"{q} {ans}") + + # If we have a list of asked questions, use those + if asked_questions and len(asked_questions) >= len(answers): + for idx, (question, ans) in enumerate(zip(asked_questions, answers), start=1): + history.append(f"Q{idx}: {question}") + history.append(f"A{idx}: {ans}") + else: + # Fall back to original behavior + for idx, ans in enumerate(answers, start=1): + q = fixed_questions[idx-1] if idx <= len(fixed_questions) else f"Follow-up {idx - len(fixed_questions)}" + history.append(f"Q{idx}: {q}") + history.append(f"A{idx}: {ans}") + return "\n".join(history) - -# def _generate_report(history_text): -# """ -# Send the full history to GenAI to generate the medical report and diagnosis. -# """ -# system_instruction = ( -# "You are a medical assistant. Generate a medical report with sections for History of Present Illness, Medications, and Allergies, " -# "then on a new line put '###1234###' and your preliminary diagnosis." -# ) -# prompt = history_text -# chat = client.chats.create( -# model="gemini-1.5-flash", -# config=types.GenerateContentConfig( -# system_instruction=system_instruction -# ) -# ) -# response = chat.send_message(types.Part(text=prompt)) -# full = response.text.strip() -# report, _, diag = full.partition('###1234###') -# return report.strip(), diag.strip() - -def _generate_report(history_text): +def _generate_report(history_text, request): """ Send the full history to GenAI to generate the medical report and diagnosis. + Only allows specializations from the predefined list. """ - prompt = f""" - Generate a medical report with these sections: - 1. History of Present Illness - 2. Medications - 3. Allergies + # Define allowed specializations from the form + allowed_specializations = [ + "Cardiology", "Dermatology", "Neurology", "Orthopedics", + "Pediatrics", "Psychiatry", "General Medicine", "Other" + ] - Followed by the delimiter '###1234###' and your preliminary diagnosis. - - Patient history: - {history_text} - """ + prompt = ( + "Generate medical report in English with these sections:\n" + "1. History of Present Illness\n" + "2. Medications\n3. Allergies\n" + "Followed by '###1234###' and diagnosis in English.\n" + "Then add '###SPECIALIZATION###' followed by ONE recommended doctor specialization " + "from this exact list: {specializations}. If unsure, choose General Medicine.\n\n" + "Patient history (may contain multilingual input):\n{history_text}" + ).format( + specializations=", ".join(allowed_specializations), + history_text=history_text + ) response = report_model.generate_content( prompt, generation_config={"temperature": 0.3} ) full = response.text.strip() - report, _, diag = full.partition('###1234###') - return report.strip(), diag.strip() + + report, _, rest = full.partition('###1234###') + diagnosis, _, specialization = rest.partition('###SPECIALIZATION###') + + # Clean and validate specialization + specialization = specialization.strip() + if specialization not in allowed_specializations: + specialization = "General Medicine" # Default if invalid + + return report.strip(), diagnosis.strip(), specialization + @csrf_exempt def speech_to_text(request): @@ -611,4 +846,8 @@ def speech_to_text(request): except Exception as e: logger.error(f"Unexpected error in speech_to_text view: {e}", exc_info=True) - return JsonResponse({'error': 'An unexpected error occurred'}, status=500) \ No newline at end of file + return JsonResponse({'error': 'An unexpected error occurred'}, status=500) + +def about(request): + """Render the About Me page""" + return render(request, 'chatbot/about.html') \ No newline at end of file diff --git a/Merilife/MediBot/chatbot-website/chatbot_website/__pycache__/__init__.cpython-311.pyc b/Merilife/MediBot/chatbot-website/chatbot_website/__pycache__/__init__.cpython-311.pyc index 4b1e38c..066ddf5 100644 Binary files a/Merilife/MediBot/chatbot-website/chatbot_website/__pycache__/__init__.cpython-311.pyc and b/Merilife/MediBot/chatbot-website/chatbot_website/__pycache__/__init__.cpython-311.pyc differ diff --git a/Merilife/MediBot/chatbot-website/chatbot_website/__pycache__/__init__.cpython-312.pyc b/Merilife/MediBot/chatbot-website/chatbot_website/__pycache__/__init__.cpython-312.pyc deleted file mode 100644 index c0156a9..0000000 Binary files a/Merilife/MediBot/chatbot-website/chatbot_website/__pycache__/__init__.cpython-312.pyc and /dev/null differ diff --git a/Merilife/MediBot/chatbot-website/chatbot_website/__pycache__/admin.cpython-311.pyc b/Merilife/MediBot/chatbot-website/chatbot_website/__pycache__/admin.cpython-311.pyc index dd92730..0f9ce51 100644 Binary files a/Merilife/MediBot/chatbot-website/chatbot_website/__pycache__/admin.cpython-311.pyc and b/Merilife/MediBot/chatbot-website/chatbot_website/__pycache__/admin.cpython-311.pyc differ diff --git a/Merilife/MediBot/chatbot-website/chatbot_website/__pycache__/apps.cpython-311.pyc b/Merilife/MediBot/chatbot-website/chatbot_website/__pycache__/apps.cpython-311.pyc index 6240aaa..d6a33c1 100644 Binary files a/Merilife/MediBot/chatbot-website/chatbot_website/__pycache__/apps.cpython-311.pyc and b/Merilife/MediBot/chatbot-website/chatbot_website/__pycache__/apps.cpython-311.pyc differ diff --git a/Merilife/MediBot/chatbot-website/chatbot_website/__pycache__/load_manager.cpython-311.pyc b/Merilife/MediBot/chatbot-website/chatbot_website/__pycache__/load_manager.cpython-311.pyc index 34cabfb..f4f68ae 100644 Binary files a/Merilife/MediBot/chatbot-website/chatbot_website/__pycache__/load_manager.cpython-311.pyc and b/Merilife/MediBot/chatbot-website/chatbot_website/__pycache__/load_manager.cpython-311.pyc differ diff --git a/Merilife/MediBot/chatbot-website/chatbot_website/__pycache__/load_middleware.cpython-311.pyc b/Merilife/MediBot/chatbot-website/chatbot_website/__pycache__/load_middleware.cpython-311.pyc index 6b210b7..8cd2374 100644 Binary files a/Merilife/MediBot/chatbot-website/chatbot_website/__pycache__/load_middleware.cpython-311.pyc and b/Merilife/MediBot/chatbot-website/chatbot_website/__pycache__/load_middleware.cpython-311.pyc differ diff --git a/Merilife/MediBot/chatbot-website/chatbot_website/__pycache__/load_views.cpython-311.pyc b/Merilife/MediBot/chatbot-website/chatbot_website/__pycache__/load_views.cpython-311.pyc index c1632a4..383da84 100644 Binary files a/Merilife/MediBot/chatbot-website/chatbot_website/__pycache__/load_views.cpython-311.pyc and b/Merilife/MediBot/chatbot-website/chatbot_website/__pycache__/load_views.cpython-311.pyc differ diff --git a/Merilife/MediBot/chatbot-website/chatbot_website/__pycache__/models.cpython-311.pyc b/Merilife/MediBot/chatbot-website/chatbot_website/__pycache__/models.cpython-311.pyc index 2ea5cba..d37b283 100644 Binary files a/Merilife/MediBot/chatbot-website/chatbot_website/__pycache__/models.cpython-311.pyc and b/Merilife/MediBot/chatbot-website/chatbot_website/__pycache__/models.cpython-311.pyc differ diff --git a/Merilife/MediBot/chatbot-website/chatbot_website/__pycache__/settings.cpython-311.pyc b/Merilife/MediBot/chatbot-website/chatbot_website/__pycache__/settings.cpython-311.pyc index 84116c0..4710f3e 100644 Binary files a/Merilife/MediBot/chatbot-website/chatbot_website/__pycache__/settings.cpython-311.pyc and b/Merilife/MediBot/chatbot-website/chatbot_website/__pycache__/settings.cpython-311.pyc differ diff --git a/Merilife/MediBot/chatbot-website/chatbot_website/__pycache__/settings.cpython-312.pyc b/Merilife/MediBot/chatbot-website/chatbot_website/__pycache__/settings.cpython-312.pyc deleted file mode 100644 index ea335ed..0000000 Binary files a/Merilife/MediBot/chatbot-website/chatbot_website/__pycache__/settings.cpython-312.pyc and /dev/null differ diff --git a/Merilife/MediBot/chatbot-website/chatbot_website/__pycache__/urls.cpython-311.pyc b/Merilife/MediBot/chatbot-website/chatbot_website/__pycache__/urls.cpython-311.pyc index f3e13b7..bda0fcf 100644 Binary files a/Merilife/MediBot/chatbot-website/chatbot_website/__pycache__/urls.cpython-311.pyc and b/Merilife/MediBot/chatbot-website/chatbot_website/__pycache__/urls.cpython-311.pyc differ diff --git a/Merilife/MediBot/chatbot-website/chatbot_website/__pycache__/urls.cpython-312.pyc b/Merilife/MediBot/chatbot-website/chatbot_website/__pycache__/urls.cpython-312.pyc deleted file mode 100644 index b1b9b22..0000000 Binary files a/Merilife/MediBot/chatbot-website/chatbot_website/__pycache__/urls.cpython-312.pyc and /dev/null differ diff --git a/Merilife/MediBot/chatbot-website/chatbot_website/__pycache__/wsgi.cpython-311.pyc b/Merilife/MediBot/chatbot-website/chatbot_website/__pycache__/wsgi.cpython-311.pyc index 29c4f76..4f13458 100644 Binary files a/Merilife/MediBot/chatbot-website/chatbot_website/__pycache__/wsgi.cpython-311.pyc and b/Merilife/MediBot/chatbot-website/chatbot_website/__pycache__/wsgi.cpython-311.pyc differ diff --git a/Merilife/MediBot/chatbot-website/chatbot_website/__pycache__/wsgi.cpython-312.pyc b/Merilife/MediBot/chatbot-website/chatbot_website/__pycache__/wsgi.cpython-312.pyc deleted file mode 100644 index b7bc894..0000000 Binary files a/Merilife/MediBot/chatbot-website/chatbot_website/__pycache__/wsgi.cpython-312.pyc and /dev/null differ diff --git a/Merilife/MediBot/chatbot-website/chatbot_website/settings.py b/Merilife/MediBot/chatbot-website/chatbot_website/settings.py index 90c6774..0b10d69 100644 --- a/Merilife/MediBot/chatbot-website/chatbot_website/settings.py +++ b/Merilife/MediBot/chatbot-website/chatbot_website/settings.py @@ -13,7 +13,7 @@ 'ENGINE': 'django.db.backends.mysql', 'NAME': 'medico_db', # Change this to your actual database name 'USER': 'root', # MySQL username (usually 'root' for local development)this - 'PASSWORD': 'harsh0604', + 'PASSWORD': 'Aditya@1998', 'HOST': 'localhost', 'PORT': '3306', } diff --git a/Merilife/MediBot/chatbot-website/chatbot_website/templatetags/__pycache__/__init__.cpython-311.pyc b/Merilife/MediBot/chatbot-website/chatbot_website/templatetags/__pycache__/__init__.cpython-311.pyc index dd37a6b..6e7f97b 100644 Binary files a/Merilife/MediBot/chatbot-website/chatbot_website/templatetags/__pycache__/__init__.cpython-311.pyc and b/Merilife/MediBot/chatbot-website/chatbot_website/templatetags/__pycache__/__init__.cpython-311.pyc differ diff --git a/Merilife/MediBot/chatbot-website/chatbot_website/templatetags/__pycache__/load_tags.cpython-311.pyc b/Merilife/MediBot/chatbot-website/chatbot_website/templatetags/__pycache__/load_tags.cpython-311.pyc index b6c463e..5d900f1 100644 Binary files a/Merilife/MediBot/chatbot-website/chatbot_website/templatetags/__pycache__/load_tags.cpython-311.pyc and b/Merilife/MediBot/chatbot-website/chatbot_website/templatetags/__pycache__/load_tags.cpython-311.pyc differ diff --git a/Merilife/MediBot/chatbot-website/media/reports_text/adipaadipa.txt b/Merilife/MediBot/chatbot-website/media/reports_text/adipaadipa.txt index ab03e78..e69de29 100644 --- a/Merilife/MediBot/chatbot-website/media/reports_text/adipaadipa.txt +++ b/Merilife/MediBot/chatbot-website/media/reports_text/adipaadipa.txt @@ -1,226 +0,0 @@ -Q1: cold -Q2: 5 days -Q3: no -Q1: cold -Q2: 2 days -Q3: no -Q4: no -Q5: yes -Q1: cold -Q2: 2 days -Q3: no -Q1: cold -Q2: 2 days -Q3: no -Q4: fever -Q5: no -=== 2025-05-01 02:11:42 === -Report: -**Medical Report** - -**1. History of Present Illness:** - -The patient presented with a complaint of a cold, of two days duration. Initially, the primary symptom was a cold. A follow-up reported the development of a fever. No other significant symptoms were reported in subsequent follow-ups. - - -**2. Medications:** - -None reported. - - -**3. Allergies:** - -None reported. -Diagnosis: **Preliminary Diagnosis:** Upper Respiratory Infection (URI) - - -**Note:** This is a preliminary diagnosis based on limited information. Further evaluation, including physical examination and potentially laboratory testing, may be necessary to confirm the diagnosis and rule out other potential causes. -Q1: fever -Q2: 2 days -Q3: bo -Q4: no -Q5: no -=== 2025-05-01 02:27:28 === -Report: -**Medical Report** - -**1. History of Present Illness:** - -The patient presents with a two-day history of fever. No other specific symptoms were reported. - - -**2. Medications:** - -None reported. - - -**3. Allergies:** - -None reported. -Diagnosis: **Preliminary Diagnosis:** - -Febrile illness. Further investigation is required to determine the underlying cause. -Q1: thanks -Q1: Error processing audio. Please try again or type your response. -Q2: Error processing audio. Please try again or type your response. -Q1: cold -Q1: fever -Q2: 3 days -Q3: nope -Q4: vomit and urge to do sex -Q5: happy -=== 2025-05-01 15:56:40 === -Report: -**Medical Report** - -**1. History of Present Illness:** - -The patient presented with a three-day history of fever. Follow-up information revealed an episode of vomiting and an expressed urge to engage in sexual activity. A subsequent follow-up noted the patient reported feeling "happy." The significance of these latter two observations requires further investigation and clarification. - - -**2. Medications:** - -None reported. - - -**3. Allergies:** - -None reported. -Diagnosis: **Preliminary Diagnosis:** Viral infection (Influenza or other viral etiology) is suspected given the fever and vomiting. However, the reported urge to engage in sexual activity and subsequent report of happiness warrant further investigation to rule out other potential causes, including but not limited to hormonal imbalances, psychiatric conditions, or drug-induced effects. Further history, physical examination, and possibly laboratory testing are necessary to establish a definitive diagnosis. -Q1: gvbfb -Q1: fever -Q2: two days -Q3: a very strong asthma -Q4: I don't use inhaler but I use condom specialised dotted -Q5: Nahin main Kuchh use nahin kar raha bus so raha hun -=== 2025-05-01 18:56:07 === -Report: -**Medical Report** - -**1. History of Present Illness:** - -The patient presents with a fever of two days duration. The patient's description of their symptoms is limited. Further clarification is needed regarding the severity and characteristics of the fever (e.g., temperature, chills, sweats). - - -**2. Medications:** - -The patient denies current medication use. However, the patient initially reported using a "condom specialized dotted," which requires further clarification to determine if this is a misunderstanding or refers to a medication delivery method. The patient later denied using any medication. - - -**3. Allergies:** - -No known allergies are reported. -Diagnosis: **Preliminary Diagnosis:** - -Fever of unknown origin. Further investigation is required to determine the etiology of the fever. The patient's statement regarding asthma requires further exploration and clarification of their asthma management plan, including the reason for not using an inhaler as prescribed, if applicable. The statement about a "condom specialized dotted" needs clarification to rule out any potential medication misuse or misunderstanding. A complete physical examination and potentially laboratory tests (e.g., complete blood count, blood cultures) are indicated. -Q1: Telugu -Q2: mood rojulu -Q3: asthma Undi -Q4: Aqua -Q5: Aqua -=== 2025-05-01 18:57:10 === -Report: -**Medical Report** - -**1. History of Present Illness:** - -The patient reports experiencing symptoms described as "Telugu" (language barrier prevents precise symptom clarification). The duration of these symptoms is stated as "mood rojulu" which translates roughly to "several days" in Telugu. Further clarification regarding the nature and specifics of the symptoms is required. - -**2. Medications:** - -The patient is currently taking "Aqua" (the nature and dosage of this medication require further clarification). This was noted in two follow-up visits. - -**3. Allergies:** - -No known allergies were reported, however, a thorough allergy assessment is recommended given the lack of detailed information. -Diagnosis: **Preliminary Diagnosis:** Unable to provide a preliminary diagnosis due to insufficient information regarding the patient's symptoms. Further investigation and clarification of the patient's reported symptoms (Telugu), medication ("Aqua"), and a complete allergy assessment are necessary for accurate diagnosis and treatment planning. A translator may be required for effective communication. -Q1: mujhe bahut jyada khansi hai aur Mere Sar Mein Dard Hai -Q2: aaj jyada Kuchh Nahin bus 10-15 Din Hue Hain -Q3: Nahin Aisa Kuchh To Nahin Hai -Q4: han matlab thoda bahut Bukhar To Hai 104 degree ka -Q5: han matlab chest Mein pen to Hai covid Jaisa lag raha hai -=== 2025-05-01 19:00:16 === -Report: -**Medical Report** - -**1. History of Present Illness:** - -The patient reports experiencing a severe cough (mujhe bahut jyada khansi hai) and headache (Mere Sar Mein Dard Hai) for approximately 10-15 days. Initially, the patient denied any other symptoms. However, upon further questioning, the patient admitted to experiencing fever (Bukhar) of 104 degrees Fahrenheit. The patient also reports chest pain (chest Mein pen) and suspects it may be related to COVID-19 (covid Jaisa lag raha hai). - - -**2. Medications:** - -None reported. - - -**3. Allergies:** - -None reported. -Diagnosis: **Preliminary Diagnosis:** Suspected Influenza or COVID-19 infection. Further investigation including a physical examination, vital signs assessment, and diagnostic testing (e.g., rapid antigen test, PCR test, chest X-ray) are necessary to confirm the diagnosis and rule out other potential causes of the patient's symptoms. The high fever warrants immediate attention. -Q1: j'ai de la fièvre et de la toux -Q2: 2 jours -Q3: non -Q4: non -Q5: non -=== 2025-05-01 23:32:06 === -Report: -**Medical Report** - -**1. History of Present Illness:** - -The patient reports a two-day history of fever and cough. The patient's description of symptoms, translated from French, indicates "j'ai de la fièvre et de la toux," signifying fever and cough. No further details regarding the character of the cough (e.g., productive or non-productive, dry or wet) or the severity of the fever (e.g., temperature) were provided. - -**2. Medications:** - -None reported. - -**3. Allergies:** - -None reported. -Diagnosis: **Preliminary Diagnosis:** Acute respiratory infection. Further investigation is required to determine the specific etiology (e.g., viral, bacterial, or other). This diagnosis is preliminary and requires further clinical evaluation, including physical examination and potentially laboratory testing. -Q1: hi I am having fever -Q2: two weeks -Q3: no no -Q4: gold -Q5: I experienced cold -=== 2025-05-04 02:05:47 === -Report: -**Medical Report** - -**1. History of Present Illness:** - -The patient reports a two-week history of fever. The onset of symptoms began approximately two weeks prior to this visit. Follow-up information indicates a previous cold-like illness. Further details regarding the character of the fever (e.g., intermittent, continuous, spiking), associated symptoms (e.g., chills, sweats, myalgias, cough, sore throat, headache, gastrointestinal symptoms), and severity are needed for a complete assessment. - - -**2. Medications:** - -None reported. - - -**3. Allergies:** - -None reported. -Diagnosis: **Preliminary Diagnosis:** Further investigation is required to establish a definitive diagnosis. Possible diagnoses include, but are not limited to, viral infection (e.g., influenza, other viral syndromes), bacterial infection, or other underlying medical condition. Additional history, physical examination, and potentially laboratory testing (e.g., complete blood count, blood cultures, influenza testing) are necessary to determine the etiology of the fever. -Q1: cold -Q2: 2 days -Q3: no -Q4: no -Q5: no -=== 2025-05-04 03:16:27 === -Report: -**Medical Report** - -**1. History of Present Illness:** - -The patient presents with a two-day history of cold symptoms. No further specifics regarding symptom severity (e.g., cough, congestion, fever, sore throat) were provided. - - -**2. Medications:** - -None reported. - - -**3. Allergies:** - -None reported. -Diagnosis: **Preliminary Diagnosis:** Upper Respiratory Infection (URI) - This is a preliminary diagnosis based on limited information. Further evaluation is necessary to confirm the diagnosis and rule out other potential causes. A more detailed symptom assessment is required. diff --git a/Merilife/MediBot/chatbot-website/media/test/reports_text/adipaadipa.txt b/Merilife/MediBot/chatbot-website/media/test/reports_text/adipaadipa.txt deleted file mode 100644 index 3767630..0000000 --- a/Merilife/MediBot/chatbot-website/media/test/reports_text/adipaadipa.txt +++ /dev/null @@ -1,404 +0,0 @@ -Q1: cold and fever -Q2: 3 days -Q3: no -Q4: no -Q5: no -=== 2025-05-04 16:05:30 === -Report: -**Medical Report** - -**1. History of Present Illness:** - -The patient presents with a three-day history of cold symptoms and fever. The onset was three days prior to this visit. No other specific symptoms were elaborated upon. - -**2. Medications:** - -None reported. - -**3. Allergies:** - -None reported. -Diagnosis: **Preliminary Diagnosis:** Upper Respiratory Infection (URI) - - -**Note:** This is a preliminary diagnosis based on limited information. Further investigation, including a physical examination and potentially laboratory testing, may be necessary to confirm the diagnosis and rule out other potential causes. -<<<<<<< Updated upstream -======= -Q1: fever cold and cough -Q2: 4 5 days -Q3: yes,mild asthma -Q4: yes rotahaler -Q5: nope rarely use it -=== 2025-05-04 20:45:37 === -Report: -**Medical Report** - -**1. History of Present Illness:** - -The patient presents with a four-to-five-day history of fever, chills, and cough. The onset of symptoms was gradual. - -**2. Medications:** - -The patient reports using a Rotahaler, an inhaler for asthma management. Use is infrequent, reported as "rarely." - -**3. Allergies:** - -No known drug allergies are reported. -Diagnosis: **Preliminary Diagnosis:** - -Upper Respiratory Infection (URI) Further investigation may be needed to rule out other possibilities. Given the patient's history of mild asthma, monitoring for any respiratory compromise is warranted. -Q1: bukhar h mujhe -Q2: 4 5 din -Q3: asthma h mujhe -Q1: bukhar hai mujhe -Q2: 4 5 din -Q3: nhi -Q4: nope -Q1: bukhar h mujhe -Q2: 3 4 days -Q3: ashtma h mujhe -Q4: thioda bahut ho rha h , zyada nhi -Q1: bukhar h mujhe -Q2: 4 5 days -Q3: nhi -Q4: thoda sa sardi h bas -Q5: nope -=== 2025-05-04 21:11:33 === -Report: -**Medical Report** - -**1. History of Present Illness:** - -The patient presented complaining of "bukhar" (fever) for 4-5 days. Initial complaint was solely fever. Follow-up inquiries revealed mild rhinorrhea (runny nose) described as "thoda sa sardi" on day one, but this symptom resolved by the second follow-up. - - -**2. Medications:** - -None reported. - - -**3. Allergies:** - -None reported. -Diagnosis: **Preliminary Diagnosis:** Possible viral upper respiratory infection (URI). Further investigation may be warranted depending on the persistence or worsening of symptoms. -Q1: pihj -Q2: प्रेजेंटेड कंप्लेनिंग का बुक हार्ट फीवर का 4 तो 5 डेज -Q3: jgf -Q4: jkhjk -Q1: fever and cold -Q2: 2 days -Q3: nope -Q4: cough and some bioady aches -Q5: cough and bvodya ches -=== 2025-05-04 21:34:36 === -Report: -**Medical Report** - -**1. History of Present Illness:** - -The patient presented with a two-day history of fever and cold symptoms. Follow-up reports indicate the development of a cough and body aches. The description of body aches is inconsistent across reports ("bioady aches" and "bvodya ches" in the follow-ups suggest potential transcription errors). Further clarification is needed regarding the nature and severity of the body aches. - - -**2. Medications:** - -None reported. - - -**3. Allergies:** - -None reported. -Diagnosis: **Preliminary Diagnosis:** Upper Respiratory Infection (URI). Further investigation is required to confirm the diagnosis and rule out other potential causes of the patient's symptoms, particularly given the inconsistent reporting of body aches. A more detailed physical examination and possibly further laboratory testing (e.g., rapid influenza test, complete blood count) are recommended. -Q1: ihjkg[hiohhijpughouhoujopu90-[hiklnoP:"jou[hi -Q1: fever -Q2: 2 dayts -Q3: nope -Q4: bodya ches -Q5: nopew -=== 2025-05-04 21:37:44 === -Report: -**Medical Report** - -**1. History of Present Illness:** - -The patient presents with a fever of two days' duration. The patient reports no other significant symptoms at this time. Further investigation into the cause of the fever is warranted. - - -**2. Medications:** - -None reported. - - -**3. Allergies:** - -None reported. -Diagnosis: **Preliminary Diagnosis:** - -Fever of unknown origin (FUO). Further investigation, including a complete blood count (CBC) and possibly other diagnostic tests, is necessary to determine the underlying cause of the fever. -Q1: fever -Q2: 2 days -Q3: nope -Q4: fever seems to get worse when i exert myself -Q5: cough and runny nose -=== 2025-05-04 21:40:32 === -Report: -## Medical Report - -**1. History of Present Illness:** - -The patient presents with a chief complaint of fever for the past two days. The patient denies any previous medical conditions. The fever appears to be exacerbated by physical exertion. The patient also reports experiencing a cough and runny nose. - -**2. Medications:** - -The patient denies taking any medications. - -**3. Allergies:** - -The patient denies any known allergies. -Diagnosis: **Preliminary Diagnosis:** - -Acute Viral Upper Respiratory Infection (URI), likely the common cold or influenza. Further investigation may be warranted to rule out other potential causes of fever, especially given the exacerbation with exertion. -Q1: fever -Q2: 3 days -Q3: no -Q4: 100 degree fahrenheit -Q5: cold and runny nose -=== 2025-05-04 21:43:05 === -Report: -**Medical Report** - -**1. History of Present Illness:** - -The patient presents with a chief complaint of fever, which has been present for the past three days. The patient reports a temperature of 100 degrees Fahrenheit. Additionally, the patient reports symptoms of a cold and runny nose. The patient denies any previous medical conditions. - -**2. Medications:** - -The patient reports taking no current medications. - -**3. Allergies:** - -The patient reports no known allergies. -Diagnosis: **Preliminary Diagnosis:** - -Acute Viral Upper Respiratory Infection (URI), likely the common cold. -Q1: fever -Q2: 1 day -Q3: no -Q4: 100 degree fahrenheit -Q5: 100 degree fahrenheit -Q1: fever -Q2: 1 day -Q3: no -Q4: it fluctuates, sometimes it gets very high -Q5: no body aches -Q1: fever -Q2: 1 day -Q3: cold and fever -Q4: yes -Q5: yes -Q6: yes -Q7: yes -=== 2025-05-04 21:52:06 === -Report: -## Medical Report - -**1. History of Present Illness:** - -The patient presents today complaining of fever, which began approximately one day ago. The patient reports a history of previous cold and fever. The patient responded affirmatively to all follow-up questions (Follow-up 1, Follow-up 2, Follow-up 3, Follow-up 4). Further details regarding these follow-up questions are needed to fully understand the context of the patient's condition. - -**2. Medications:** - -No current medications were reported by the patient. - -**3. Allergies:** - -No allergies were reported by the patient. -Diagnosis: **Preliminary Diagnosis:** - -Acute Febrile Illness, etiology undetermined. Further investigation is needed to rule out common viral or bacterial infections, especially given the patient's history of cold and fever. The nature of the follow-up questions answered affirmatively needs to be clarified to guide further diagnostic and treatment strategies. -Q1: What are your main symptoms? -A1: fever - -Q2: How long have you been experiencing these symptoms? -A2: 1 day - -Q3: Do you have any previous medical conditions? -A3: cold and fever - -Q4: -A4: body aches - -Q1: What are your main symptoms? -A1: bukhar h mujhe - -Q2: How long have you been experiencing these symptoms? -A2: 1 din - -Q3: Do you have any previous medical conditions? -A3: nhi - -Q4: -A4: sardi bhi ho rhi h - -Q5: -A5: haa - -Q6: -A6: kamzorui ho rha h - -Q7: -A7: nope - -=== 2025-05-04 22:04:43 === -Report: -**Medical Report** - -**1. History of Present Illness:** - -The patient presents with a chief complaint of "bukhar h mujhe" (fever). The onset of symptoms is reported as "1 din" (1 day). The patient also reports experiencing "sardi bhi ho rhi h" (cold symptoms), "kamzorui ho rha h" (weakness). The patient denies any previous medical conditions. - -**2. Medications:** - -The patient reports taking no medications ("nope"). - -**3. Allergies:** - -No allergies were reported ("nhi"). -Diagnosis: **Preliminary Diagnosis:** - -Acute Viral Upper Respiratory Infection (URI), likely influenza or common cold. Differential diagnosis includes other viral infections causing fever, cold symptoms, and weakness. Further investigation is needed to rule out other potential causes. -Q1: What are your main symptoms? -A1: fever and cold - -Q2: How long have you been experiencing these symptoms? -A2: 2 days - -Q3: Do you have any previous medical conditions? -A3: nope - -Q4: -A4: not really - -Q5: -A5: not really - -Q6: -A6: not really - -Q1: What are your main symptoms? -A1: fever - -Q2: How long have you been experiencing these symptoms? -A2: 1 day - -Q3: Do you have any previous medical conditions? -A3: no - -Q4: -A4: slight body aches but no chills - -Q5: -A5: no the appetite is fine - -Q6: -A6: dry cough , yes - -Q7: -A7: runny nose - -=== 2025-05-04 22:48:49 === -Report: -## Medical Report - -**1. History of Present Illness:** - -The patient presents with a one-day history of fever. Associated symptoms include slight body aches, but no chills are reported. The patient denies any loss of appetite. They also report a dry cough and a runny nose. - -**2. Medications:** - -The patient reports taking no medications. - -**3. Allergies:** - -The patient reports no known allergies. -Diagnosis: **Preliminary Diagnosis:** - -Acute Upper Respiratory Infection (URI), likely viral. Differential diagnosis includes influenza and common cold. Further evaluation may be warranted if symptoms worsen or do not improve within a few days. Recommend symptomatic treatment including rest, hydration, and over-the-counter fever reducers/pain relievers. -Q1: What are your main symptoms? -A1: fever - -Q2: How long have you been experiencing these symptoms? -A2: 1 day - -Q3: Do you have any previous medical conditions? -A3: no - -Q4: -A4: chills and sweating - -Q5: -A5: no pains - -Q6: -A6: nope - -Q7: -A7: no the appetite is fine - -=== 2025-05-05 01:44:18 === -Report: -## Medical Report - -**1. History of Present Illness:** - -The patient presents with a chief complaint of fever, which began approximately one day ago. Associated symptoms include chills and sweating. The patient denies experiencing any pains. Appetite is reported as normal. The patient denies any other symptoms. - -**2. Medications:** - -The patient reports taking no medications. - -**3. Allergies:** - -The patient reports no known allergies. -Diagnosis: **Preliminary Diagnosis:** - -Acute febrile illness, etiology undetermined. Further investigation is needed to rule out common causes of fever such as viral or bacterial infections. Differential diagnoses include influenza, common cold, or other upper respiratory infections. -Q1: What are your main symptoms? -A1: fever - -Q2: How long have you been experiencing these symptoms? -A2: 1 day - -Q3: Do you have any previous medical conditions? -A3: nope - -Q4: -A4: chills sometimes, no excessive sweating - -Q5: -A5: no body aches - -Q6: -A6: have a runny nose - -Q7: -A7: it is clear - -=== 2025-05-05 02:15:04 === -Report: -**Medical Report** - -**1. History of Present Illness:** - -The patient presents with a chief complaint of fever, which began approximately one day ago. Associated symptoms include occasional chills and a clear, runny nose. The patient denies excessive sweating or body aches. The patient reports no previous medical conditions. - -**2. Medications:** - -The patient reports taking no current medications. - -**3. Allergies:** - -The patient reports no known allergies. -Diagnosis: **Preliminary Diagnosis:** - -Acute viral upper respiratory infection (URI), likely common cold or early influenza. Further evaluation may be warranted if symptoms worsen or persist beyond a week. Consider testing for influenza or COVID-19 if clinically indicated based on local prevalence and patient risk factors. ->>>>>>> Stashed changes diff --git a/Merilife/MediBot/chatbot-website/meditron/__pycache__/__init__.cpython-311.pyc b/Merilife/MediBot/chatbot-website/meditron/__pycache__/__init__.cpython-311.pyc index c521d74..e113170 100644 Binary files a/Merilife/MediBot/chatbot-website/meditron/__pycache__/__init__.cpython-311.pyc and b/Merilife/MediBot/chatbot-website/meditron/__pycache__/__init__.cpython-311.pyc differ diff --git a/Merilife/MediBot/chatbot-website/meditron/__pycache__/__init__.cpython-312.pyc b/Merilife/MediBot/chatbot-website/meditron/__pycache__/__init__.cpython-312.pyc deleted file mode 100644 index 40cb3c6..0000000 Binary files a/Merilife/MediBot/chatbot-website/meditron/__pycache__/__init__.cpython-312.pyc and /dev/null differ diff --git a/Merilife/MediBot/chatbot-website/meditron/__pycache__/utils.cpython-311.pyc b/Merilife/MediBot/chatbot-website/meditron/__pycache__/utils.cpython-311.pyc index f5e4d78..b54907f 100644 Binary files a/Merilife/MediBot/chatbot-website/meditron/__pycache__/utils.cpython-311.pyc and b/Merilife/MediBot/chatbot-website/meditron/__pycache__/utils.cpython-311.pyc differ diff --git a/Merilife/MediBot/chatbot-website/meditron/__pycache__/utils.cpython-312.pyc b/Merilife/MediBot/chatbot-website/meditron/__pycache__/utils.cpython-312.pyc deleted file mode 100644 index bfa710c..0000000 Binary files a/Merilife/MediBot/chatbot-website/meditron/__pycache__/utils.cpython-312.pyc and /dev/null differ diff --git a/Merilife/MediBot/chatbot-website/reports/__pycache__/__init__.cpython-311.pyc b/Merilife/MediBot/chatbot-website/reports/__pycache__/__init__.cpython-311.pyc index c1448e1..a3e4437 100644 Binary files a/Merilife/MediBot/chatbot-website/reports/__pycache__/__init__.cpython-311.pyc and b/Merilife/MediBot/chatbot-website/reports/__pycache__/__init__.cpython-311.pyc differ diff --git a/Merilife/MediBot/chatbot-website/reports/__pycache__/__init__.cpython-312.pyc b/Merilife/MediBot/chatbot-website/reports/__pycache__/__init__.cpython-312.pyc deleted file mode 100644 index d85d3e7..0000000 Binary files a/Merilife/MediBot/chatbot-website/reports/__pycache__/__init__.cpython-312.pyc and /dev/null differ diff --git a/Merilife/MediBot/chatbot-website/reports/__pycache__/admin.cpython-311.pyc b/Merilife/MediBot/chatbot-website/reports/__pycache__/admin.cpython-311.pyc index cfa7918..5a67a94 100644 Binary files a/Merilife/MediBot/chatbot-website/reports/__pycache__/admin.cpython-311.pyc and b/Merilife/MediBot/chatbot-website/reports/__pycache__/admin.cpython-311.pyc differ diff --git a/Merilife/MediBot/chatbot-website/reports/__pycache__/admin.cpython-312.pyc b/Merilife/MediBot/chatbot-website/reports/__pycache__/admin.cpython-312.pyc deleted file mode 100644 index 8fc2f05..0000000 Binary files a/Merilife/MediBot/chatbot-website/reports/__pycache__/admin.cpython-312.pyc and /dev/null differ diff --git a/Merilife/MediBot/chatbot-website/reports/__pycache__/apps.cpython-311.pyc b/Merilife/MediBot/chatbot-website/reports/__pycache__/apps.cpython-311.pyc index e5645b8..38d7a23 100644 Binary files a/Merilife/MediBot/chatbot-website/reports/__pycache__/apps.cpython-311.pyc and b/Merilife/MediBot/chatbot-website/reports/__pycache__/apps.cpython-311.pyc differ diff --git a/Merilife/MediBot/chatbot-website/reports/__pycache__/apps.cpython-312.pyc b/Merilife/MediBot/chatbot-website/reports/__pycache__/apps.cpython-312.pyc deleted file mode 100644 index a108746..0000000 Binary files a/Merilife/MediBot/chatbot-website/reports/__pycache__/apps.cpython-312.pyc and /dev/null differ diff --git a/Merilife/MediBot/chatbot-website/reports/__pycache__/models.cpython-311.pyc b/Merilife/MediBot/chatbot-website/reports/__pycache__/models.cpython-311.pyc index e1e340e..94ab73c 100644 Binary files a/Merilife/MediBot/chatbot-website/reports/__pycache__/models.cpython-311.pyc and b/Merilife/MediBot/chatbot-website/reports/__pycache__/models.cpython-311.pyc differ diff --git a/Merilife/MediBot/chatbot-website/reports/__pycache__/models.cpython-312.pyc b/Merilife/MediBot/chatbot-website/reports/__pycache__/models.cpython-312.pyc deleted file mode 100644 index 778fd45..0000000 Binary files a/Merilife/MediBot/chatbot-website/reports/__pycache__/models.cpython-312.pyc and /dev/null differ diff --git a/Merilife/MediBot/chatbot-website/reports/__pycache__/tests.cpython-312-pytest-8.3.5.pyc b/Merilife/MediBot/chatbot-website/reports/__pycache__/tests.cpython-312-pytest-8.3.5.pyc deleted file mode 100644 index eb6d073..0000000 Binary files a/Merilife/MediBot/chatbot-website/reports/__pycache__/tests.cpython-312-pytest-8.3.5.pyc and /dev/null differ diff --git a/Merilife/MediBot/chatbot-website/reports/__pycache__/urls.cpython-311.pyc b/Merilife/MediBot/chatbot-website/reports/__pycache__/urls.cpython-311.pyc index d0d9ca7..c7ca184 100644 Binary files a/Merilife/MediBot/chatbot-website/reports/__pycache__/urls.cpython-311.pyc and b/Merilife/MediBot/chatbot-website/reports/__pycache__/urls.cpython-311.pyc differ diff --git a/Merilife/MediBot/chatbot-website/reports/__pycache__/urls.cpython-312.pyc b/Merilife/MediBot/chatbot-website/reports/__pycache__/urls.cpython-312.pyc deleted file mode 100644 index 0ece578..0000000 Binary files a/Merilife/MediBot/chatbot-website/reports/__pycache__/urls.cpython-312.pyc and /dev/null differ diff --git a/Merilife/MediBot/chatbot-website/reports/__pycache__/views.cpython-311.pyc b/Merilife/MediBot/chatbot-website/reports/__pycache__/views.cpython-311.pyc index 3eee8a6..b94b861 100644 Binary files a/Merilife/MediBot/chatbot-website/reports/__pycache__/views.cpython-311.pyc and b/Merilife/MediBot/chatbot-website/reports/__pycache__/views.cpython-311.pyc differ diff --git a/Merilife/MediBot/chatbot-website/reports/__pycache__/views.cpython-312.pyc b/Merilife/MediBot/chatbot-website/reports/__pycache__/views.cpython-312.pyc deleted file mode 100644 index 7b1e18c..0000000 Binary files a/Merilife/MediBot/chatbot-website/reports/__pycache__/views.cpython-312.pyc and /dev/null differ diff --git a/Merilife/MediBot/chatbot-website/reports/migrations/__pycache__/0001_initial.cpython-311.pyc b/Merilife/MediBot/chatbot-website/reports/migrations/__pycache__/0001_initial.cpython-311.pyc index 35cb1e7..0acec83 100644 Binary files a/Merilife/MediBot/chatbot-website/reports/migrations/__pycache__/0001_initial.cpython-311.pyc and b/Merilife/MediBot/chatbot-website/reports/migrations/__pycache__/0001_initial.cpython-311.pyc differ diff --git a/Merilife/MediBot/chatbot-website/reports/migrations/__pycache__/0001_initial.cpython-312.pyc b/Merilife/MediBot/chatbot-website/reports/migrations/__pycache__/0001_initial.cpython-312.pyc deleted file mode 100644 index 1cdf642..0000000 Binary files a/Merilife/MediBot/chatbot-website/reports/migrations/__pycache__/0001_initial.cpython-312.pyc and /dev/null differ diff --git a/Merilife/MediBot/chatbot-website/reports/migrations/__pycache__/0002_report_assigned_doctor_report_user.cpython-311.pyc b/Merilife/MediBot/chatbot-website/reports/migrations/__pycache__/0002_report_assigned_doctor_report_user.cpython-311.pyc index ec7fbba..a42a4a4 100644 Binary files a/Merilife/MediBot/chatbot-website/reports/migrations/__pycache__/0002_report_assigned_doctor_report_user.cpython-311.pyc and b/Merilife/MediBot/chatbot-website/reports/migrations/__pycache__/0002_report_assigned_doctor_report_user.cpython-311.pyc differ diff --git a/Merilife/MediBot/chatbot-website/reports/migrations/__pycache__/0002_report_assigned_doctor_report_user.cpython-312.pyc b/Merilife/MediBot/chatbot-website/reports/migrations/__pycache__/0002_report_assigned_doctor_report_user.cpython-312.pyc deleted file mode 100644 index 9153f3f..0000000 Binary files a/Merilife/MediBot/chatbot-website/reports/migrations/__pycache__/0002_report_assigned_doctor_report_user.cpython-312.pyc and /dev/null differ diff --git a/Merilife/MediBot/chatbot-website/reports/migrations/__pycache__/0003_report_treatment.cpython-311.pyc b/Merilife/MediBot/chatbot-website/reports/migrations/__pycache__/0003_report_treatment.cpython-311.pyc index c8c09b7..27c44d0 100644 Binary files a/Merilife/MediBot/chatbot-website/reports/migrations/__pycache__/0003_report_treatment.cpython-311.pyc and b/Merilife/MediBot/chatbot-website/reports/migrations/__pycache__/0003_report_treatment.cpython-311.pyc differ diff --git a/Merilife/MediBot/chatbot-website/reports/migrations/__pycache__/0003_report_treatment.cpython-312.pyc b/Merilife/MediBot/chatbot-website/reports/migrations/__pycache__/0003_report_treatment.cpython-312.pyc deleted file mode 100644 index 1af3742..0000000 Binary files a/Merilife/MediBot/chatbot-website/reports/migrations/__pycache__/0003_report_treatment.cpython-312.pyc and /dev/null differ diff --git a/Merilife/MediBot/chatbot-website/reports/migrations/__pycache__/0004_report_pdf_blob.cpython-311.pyc b/Merilife/MediBot/chatbot-website/reports/migrations/__pycache__/0004_report_pdf_blob.cpython-311.pyc index 03627fc..1f4cc4e 100644 Binary files a/Merilife/MediBot/chatbot-website/reports/migrations/__pycache__/0004_report_pdf_blob.cpython-311.pyc and b/Merilife/MediBot/chatbot-website/reports/migrations/__pycache__/0004_report_pdf_blob.cpython-311.pyc differ diff --git a/Merilife/MediBot/chatbot-website/reports/migrations/__pycache__/0004_report_pdf_blob.cpython-312.pyc b/Merilife/MediBot/chatbot-website/reports/migrations/__pycache__/0004_report_pdf_blob.cpython-312.pyc deleted file mode 100644 index cb74b4d..0000000 Binary files a/Merilife/MediBot/chatbot-website/reports/migrations/__pycache__/0004_report_pdf_blob.cpython-312.pyc and /dev/null differ diff --git a/Merilife/MediBot/chatbot-website/reports/migrations/__pycache__/__init__.cpython-311.pyc b/Merilife/MediBot/chatbot-website/reports/migrations/__pycache__/__init__.cpython-311.pyc index 984ae30..5d58206 100644 Binary files a/Merilife/MediBot/chatbot-website/reports/migrations/__pycache__/__init__.cpython-311.pyc and b/Merilife/MediBot/chatbot-website/reports/migrations/__pycache__/__init__.cpython-311.pyc differ diff --git a/Merilife/MediBot/chatbot-website/reports/migrations/__pycache__/__init__.cpython-312.pyc b/Merilife/MediBot/chatbot-website/reports/migrations/__pycache__/__init__.cpython-312.pyc deleted file mode 100644 index 1c32da9..0000000 Binary files a/Merilife/MediBot/chatbot-website/reports/migrations/__pycache__/__init__.cpython-312.pyc and /dev/null differ diff --git a/Merilife/MediBot/chatbot-website/reports/templates/reports/report_detail.html b/Merilife/MediBot/chatbot-website/reports/templates/reports/report_detail.html index f0f03da..cbf3769 100644 --- a/Merilife/MediBot/chatbot-website/reports/templates/reports/report_detail.html +++ b/Merilife/MediBot/chatbot-website/reports/templates/reports/report_detail.html @@ -56,6 +56,11 @@

{{ report.title }}

Back to Dashboard + {% if request.user.doctor_profile and report.assigned_doctor == request.user %} + + Download PDF + + {% endif %} {% else %} Back to Chat diff --git a/Merilife/MediBot/chatbot-website/reports/urls.py b/Merilife/MediBot/chatbot-website/reports/urls.py index 2ffc5ea..5b1a8fa 100644 --- a/Merilife/MediBot/chatbot-website/reports/urls.py +++ b/Merilife/MediBot/chatbot-website/reports/urls.py @@ -4,4 +4,5 @@ urlpatterns = [ path('generate/', views.generate_report, name='generate_report'), path('view//', views.view_report, name='view_report'), + path('download//', views.download_report_pdf, name='download_report_pdf'), ] \ No newline at end of file diff --git a/Merilife/MediBot/chatbot-website/reports/views.py b/Merilife/MediBot/chatbot-website/reports/views.py index f6cd3e6..fec4ad0 100644 --- a/Merilife/MediBot/chatbot-website/reports/views.py +++ b/Merilife/MediBot/chatbot-website/reports/views.py @@ -6,6 +6,8 @@ from django.contrib.auth.decorators import login_required import random # add random import from io import BytesIO +from reportlab.lib.pagesizes import letter +from reportlab.pdfgen import canvas def report_view(request): if request.method == 'GET': @@ -58,13 +60,37 @@ def view_report(request, report_id): (hasattr(request.user, 'doctor_profile') and report.treatment and report.treatment.doctor == request.user)): return HttpResponse('Unauthorized', status=403) - # If there's a PDF blob, return it as a PDF response - if report.pdf_blob: - return FileResponse( - BytesIO(report.pdf_blob), - content_type='application/pdf', - filename=f'report_{report.id}.pdf' - ) - # Otherwise render the report content as HTML - return render(request, 'reports/report_detail.html', {'report': report}) \ No newline at end of file + return render(request, 'reports/report_detail.html', {'report': report}) + +@login_required +def download_report_pdf(request, report_id): + report = get_object_or_404(Report, id=report_id) + # Only allow assigned doctor to download + if not (hasattr(request.user, 'doctor_profile') and report.assigned_doctor == request.user): + return HttpResponse('Unauthorized', status=403) + + buffer = BytesIO() + c = canvas.Canvas(buffer, pagesize=letter) + width, height = letter + # Patient info header + c.setFont("Helvetica-Bold", 14) + c.drawString(50, height - 50, f"Patient Name: {report.user.full_name}") + c.drawString(50, height - 70, f"Age: {report.user.age}") + c.drawString(50, height - 90, f"Date: {report.created_at.strftime('%Y-%m-%d %H:%M')}") + # Report content body + c.setFont("Helvetica", 12) + text_object = c.beginText(50, height - 120) + for line in report.content.splitlines(): + text_object.textLine(line) + c.drawText(text_object) + c.showPage() + c.save() + + buffer.seek(0) + # Save PDF to blob + report.pdf_blob = buffer.getvalue() + report.save(update_fields=['pdf_blob']) + + # Return PDF file response + return FileResponse(buffer, as_attachment=True, filename=f'report_{report.id}.pdf', content_type='application/pdf') \ No newline at end of file diff --git a/Merilife/MediBot/requirements.txt b/Merilife/MediBot/requirements.txt index e49a275..89e23a7 100644 --- a/Merilife/MediBot/requirements.txt +++ b/Merilife/MediBot/requirements.txt @@ -1,350 +1,18 @@ -# Django==5.0.1 -# django-cors-headers==4.3.1 -# django-rest-framework==0.1.0 -# django-environ==0.11.2 -# python-dotenv==1.0.0 -# django-allauth==0.60.0 -# django-guardian==2.4.0 -# pymongo==4.6.1 -# sentence-transformers==2.2.2 -# torch==2.1.2 -# transformers==4.36.2 -# python-jose==3.3.0 -# passlib==1.7.4 -# python-multipart==0.0.6 -# PyJWT==2.8.0 -# Pillow==10.2.0 -# pandas==2.1.4 -# numpy==1.26.3 -# matplotlib==3.8.2 -# seaborn==0.13.1 -# python-docx==1.1.0 -# reportlab==4.0.9 -# flake8==7.0.0 -# black==23.12.1 -# pytest==7.4.4 -# pytest-django==4.7.0 -# pytest-cov==4.1.0 - -absl-py==2.1.0 -aider-chat==0.60.1 -aiohappyeyeballs==2.4.0 -aiohttp==3.10.5 -aiosignal==1.3.1 -annotated-types==0.7.0 -anyio==4.9.0 -arrow==1.3.0 -asgiref==3.8.1 -asttokens==2.4.1 -attrs==24.2.0 -backoff==2.2.1 -bcrypt==4.0.1 -beautifulsoup4==4.12.3 -binaryornot==0.4.4 -bitcoinlib==0.6.15 -bleach==6.2.0 -blinker==1.8.2 -blis==0.7.11 -boto3==1.34.127 -botocore==1.34.127 -branca==0.8.1 -Brotli==1.1.0 -cachetools==5.5.1 -catalogue==2.0.10 -certifi==2024.8.30 -cffi==1.17.1 -chardet==5.2.0 -charset-normalizer==3.3.2 -clean-text==0.6.0 -click==8.1.7 -cloudpathlib==0.20.0 -cmsisdsp==1.9.9 -colorama==0.4.6 -comm==0.2.2 -comtypes==1.4.8 -confection==0.1.5 -ConfigArgParse==1.7 -contourpy==1.3.0 -cookiecutter==2.6.0 -cryptography==43.0.3 -cycler==0.12.1 -cymem==2.0.8 -Cython==3.0.11 -debugpy==1.8.5 -decorator==4.4.2 -defang==0.5.3 -diff-match-patch==20230430 -dill==0.3.9 -diskcache==5.6.3 -distlib==0.3.9 -distro==1.9.0 Django==5.1 -django-environ==0.12.0 -dnspython==2.7.0 -docker==7.1.0 -docstring-parser==0.15 -duckdb==1.1.3 -easyocr==1.7.2 -ecdsa==0.19.0 -elevenlabs==1.3.0 -emoji==1.7.0 -et_xmlfile==2.0.0 -executing==2.1.0 -ffmpeg-python==0.2.0 -filelock==3.16.1 +pytest==8.3.3 +pytest-django==4.7.0 +pytest-cov==4.1.0 flake8==7.1.1 -Flask==3.0.3 -Flask-MySQLdb==1.0.1 -flatbuffers==24.12.23 -folium==0.19.5 -fonttools==4.53.1 -frozenlist==1.4.1 -fsspec==2024.9.0 -ftfy==6.3.1 -future==1.0.0 -geographiclib==2.0 -geopy==2.4.1 -gitdb==4.0.11 -GitPython==3.1.43 -google-ai-generativelanguage==0.6.15 -google-api-core==2.24.1 -google-api-python-client==2.160.0 -google-auth==2.38.0 -google-auth-httplib2==0.2.0 -google-genai==1.11.0 -google-generativeai==0.8.4 -googleapis-common-protos==1.66.0 -greenlet==3.0.3 -grep-ast==0.3.3 -grpcio==1.70.0 -grpcio-status==1.70.0 -gTTS==2.5.1 -gunicorn==23.0.0 -gurobipy==11.0.3 -h11==0.14.0 -h5py==3.12.1 -httpcore==1.0.5 -httplib2==0.22.0 -httpx==0.28.1 -huggingface-hub==0.25.0 -idna==3.10 -imageio==2.36.0 -imageio-ffmpeg==0.5.1 -importlib_metadata==7.2.1 -importlib_resources==6.4.5 -instructor==0.6.8 -intel-openmp==2021.4.0 -ipaddress==1.0.23 -ipykernel==6.29.5 -ipython==8.27.0 -itsdangerous==2.2.0 -jedi==0.19.1 -Jinja2==3.1.4 -jiter==0.5.0 -jmespath==1.0.1 -joblib==1.4.2 -json5==0.9.25 -jsonpatch==1.33 -jsonpointer==3.0.0 -jsonschema==4.23.0 -jsonschema-specifications==2023.12.1 -jupyter_client==8.6.2 -jupyter_core==5.7.2 -kaggle==1.6.17 -keras==3.6.0 -kiwisolver==1.4.7 -langchain==0.3.17 -langchain-core==0.3.33 -langchain-openai==0.3.3 -langchain-text-splitters==0.3.5 -langcodes==3.4.1 -langsmith==0.3.5 -language_data==1.2.0 -lazy_loader==0.4 -libclang==18.1.1 -litellm==1.47.0 -llvmlite==0.43.0 -lxml==5.3.0 -marisa-trie==1.2.1 -Markdown==3.7 -markdown-it-py==3.0.0 -MarkupSafe==2.1.5 -matplotlib==3.9.2 -matplotlib-inline==0.1.7 -mccabe==0.7.0 -mdurl==0.1.2 -mkl==2021.4.0 -ml-dtypes==0.4.1 -MouseInfo==0.1.3 -moviepy==1.0.3 -mpmath==1.3.0 -multidict==6.1.0 -multiprocess==0.70.17 -murmurhash==1.0.10 -mutagen==1.47.0 -mysql==0.0.3 -mysql-connector==2.2.9 -mysql-connector-python==9.0.0 -mysqlclient==2.2.4 -namex==0.0.8 -nest-asyncio==1.6.0 -networkx==3.2.1 -ninja==1.11.1.4 -numba==0.60.0 +black==23.12.1 +reportlab==4.4.0 +pillow==10.3.0 numpy==1.26.4 -openai==0.28.0 -opencv-python==4.10.0.84 -opencv-python-headless==4.10.0.84 -opendatasets==0.1.22 -openpyxl==3.1.5 -opt_einsum==3.4.0 -optree==0.13.0 -orjson==3.10.15 -packaging==24.1 pandas==2.2.2 -pandasql==0.7.3 -parso==0.8.4 -pathos==0.3.3 -pathspec==0.12.1 -patsy==1.0.1 -pexpect==4.9.0 -pillow==10.3.0 -platformdirs==4.2.2 -playwright==1.44.0 -pox==0.3.5 -ppft==1.7.6.9 -praw==7.7.1 -prawcore==2.3.0 -preshed==3.0.9 -proglog==0.1.10 -prompt_toolkit==3.0.47 -proto-plus==1.26.0 -protobuf==5.29.3 -psutil==6.0.0 -psycopg2==2.9.10 -psycopg2-binary==2.9.10 -ptyprocess==0.7.0 -PuLP==2.9.0 -pure_eval==0.2.3 -pyasn1==0.6.1 -pyasn1_modules==0.4.1 -PyAutoGUI==0.9.54 -pyclipper==1.3.0.post6 -pycodestyle==2.12.1 -pycparser==2.22 -pycryptodome==3.20.0 -pycryptodomex==3.21.0 -pydantic==2.9.2 -pydantic_core==2.23.4 -pydub==0.25.1 -pyee==11.1.0 -PyExecJS==1.5.1 -pyflakes==3.2.0 -PyGetWindow==0.0.9 -Pygments==2.18.0 -pymongo==4.11 -PyMsgBox==1.0.9 -pynndescent==0.5.13 -pypandoc==1.13 -pyparsing==3.1.2 -pyperclip==1.9.0 -pypiwin32==223 -pyreadline3==3.4.1 -PyRect==0.2.0 -PyScreeze==1.0.1 -pytesseract==0.3.13 -python-bidi==0.6.6 -python-bitcoinlib==0.12.2 -python-dateutil==2.9.0.post0 -python-dotenv==1.0.1 -python-slugify==8.0.4 -pyttsx3==2.90 -pytweening==1.2.0 -pytz==2024.1 -pywin32==306 -PyYAML==6.0.2 -pyzmq==26.2.0 -RapidFuzz==3.12.2 -referencing==0.35.1 -regex==2024.9.11 -reportlab==4.4.0 -requests==2.32.3 -requests-toolbelt==1.0.0 -rich==13.7.1 -rpds-py==0.20.0 -rsa==4.9 -s3transfer==0.10.3 -safetensors==0.4.5 -scikit-image==0.25.2 -scikit-learn==1.5.2 -scikit-posthocs==0.11.2 -scipy==1.13.1 +matplotlib==3.9.2 seaborn==0.13.2 -setuptools==75.8.0 -shapely==2.0.7 -shell_gpt==1.4.3 -six==1.16.0 -smart-open==7.0.5 -smmap==5.0.1 -sniffio==1.3.1 -sortedcontainers==2.4.0 -sounddevice==0.5.0 -soundfile==0.12.1 -soupsieve==2.6 -spacy==3.7.5 -spacy-legacy==3.0.12 -spacy-loggers==1.0.5 -SQLAlchemy==2.0.32 -sqlparse==0.5.1 -srsly==2.4.8 -stack-data==0.6.3 -statsmodels==0.14.4 -sympy==1.13.1 -tbb==2021.13.1 -tenacity==8.5.0 -tensorboard-data-server==0.7.2 -termcolor==2.5.0 -text-unidecode==1.3 -thinc==8.2.5 -threadpoolctl==3.5.0 -tifffile==2025.3.13 -tiktoken==0.7.0 -tokenizers==0.19.1 -toml==0.10.2 -tomlkit==0.12.5 -torch==2.6.0 -torchvision==0.21.0 -tornado==6.4.1 -tqdm==4.66.5 -traitlets==5.14.3 +requests==2.32.3 +# torch==2.6.0 transformers==4.41.2 -translators==5.9.2 -tree-sitter==0.21.3 -tree-sitter-languages==1.10.2 -typer==0.9.4 -types-python-dateutil==2.9.0.20241206 -typing_extensions==4.12.2 -tzdata==2024.1 -umap==0.1.1 -umap-learn==0.5.6 -Unidecode==1.3.8 -update-checker==0.18.0 -uritemplate==4.1.1 -urllib3==2.2.3 -virtualenv==20.27.1 -wasabi==1.1.3 -wcwidth==0.2.13 -weasel==0.4.1 -webencodings==0.5.1 -websocket-client==1.8.0 -websockets==14.1 -Werkzeug==3.0.3 -wheel==0.45.1 -whitenoise==6.8.2 -wrapt==1.16.0 -wsproto==1.2.0 -xyzservices==2025.1.0 -yarl==1.11.1 -yt-dlp==2024.5.27 -zipp==3.20.2 -zstandard==0.23.0 \ No newline at end of file +google-genai==1.11.0 +google-generativeai==0.8.3 +google-ai-generativelanguage==0.6.15 \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index e49a275..bca1201 100644 Binary files a/requirements.txt and b/requirements.txt differ diff --git a/taged b/taged new file mode 100644 index 0000000..df6eb80 --- /dev/null +++ b/taged @@ -0,0 +1,292 @@ +diff --git a/Merilife/MediBot/chatbot-website/chatbot/__pycache__/__init__.cpython-312.pyc b/Merilife/MediBot/chatbot-website/chatbot/__pycache__/__init__.cpython-312.pyc +index 20c158c..2fdd392 100644 +Binary files a/Merilife/MediBot/chatbot-website/chatbot/__pycache__/__init__.cpython-312.pyc and b/Merilife/MediBot/chatbot-website/chatbot/__pycache__/__init__.cpython-312.pyc differ +diff --git a/Merilife/MediBot/chatbot-website/chatbot/__pycache__/admin.cpython-312.pyc b/Merilife/MediBot/chatbot-website/chatbot/__pycache__/admin.cpython-312.pyc +index bb79de1..329c037 100644 +Binary files a/Merilife/MediBot/chatbot-website/chatbot/__pycache__/admin.cpython-312.pyc and b/Merilife/MediBot/chatbot-website/chatbot/__pycache__/admin.cpython-312.pyc differ +diff --git a/Merilife/MediBot/chatbot-website/chatbot/__pycache__/ai_wrapper.cpython-312.pyc b/Merilife/MediBot/chatbot-website/chatbot/__pycache__/ai_wrapper.cpython-312.pyc +index 6edbd80..ed6ef67 100644 +Binary files a/Merilife/MediBot/chatbot-website/chatbot/__pycache__/ai_wrapper.cpython-312.pyc and b/Merilife/MediBot/chatbot-website/chatbot/__pycache__/ai_wrapper.cpython-312.pyc differ +diff --git a/Merilife/MediBot/chatbot-website/chatbot/__pycache__/apps.cpython-312.pyc b/Merilife/MediBot/chatbot-website/chatbot/__pycache__/apps.cpython-312.pyc +index 7c5f8e9..085dcfc 100644 +Binary files a/Merilife/MediBot/chatbot-website/chatbot/__pycache__/apps.cpython-312.pyc and b/Merilife/MediBot/chatbot-website/chatbot/__pycache__/apps.cpython-312.pyc differ +diff --git a/Merilife/MediBot/chatbot-website/chatbot/__pycache__/backends.cpython-312.pyc b/Merilife/MediBot/chatbot-website/chatbot/__pycache__/backends.cpython-312.pyc +index 77bd1c3..60ff6fd 100644 +Binary files a/Merilife/MediBot/chatbot-website/chatbot/__pycache__/backends.cpython-312.pyc and b/Merilife/MediBot/chatbot-website/chatbot/__pycache__/backends.cpython-312.pyc differ +diff --git a/Merilife/MediBot/chatbot-website/chatbot/__pycache__/middleware.cpython-312.pyc b/Merilife/MediBot/chatbot-website/chatbot/__pycache__/middleware.cpython-312.pyc +index a6ccc93..59f4583 100644 +Binary files a/Merilife/MediBot/chatbot-website/chatbot/__pycache__/middleware.cpython-312.pyc and b/Merilife/MediBot/chatbot-website/chatbot/__pycache__/middleware.cpython-312.pyc differ +diff --git a/Merilife/MediBot/chatbot-website/chatbot/__pycache__/models.cpython-312.pyc b/Merilife/MediBot/chatbot-website/chatbot/__pycache__/models.cpython-312.pyc +index 77c0bdf..68a0a67 100644 +Binary files a/Merilife/MediBot/chatbot-website/chatbot/__pycache__/models.cpython-312.pyc and b/Merilife/MediBot/chatbot-website/chatbot/__pycache__/models.cpython-312.pyc differ +diff --git a/Merilife/MediBot/chatbot-website/chatbot/__pycache__/speech_to_text.cpython-312.pyc b/Merilife/MediBot/chatbot-website/chatbot/__pycache__/speech_to_text.cpython-312.pyc +index 3358997..e8e8cc8 100644 +Binary files a/Merilife/MediBot/chatbot-website/chatbot/__pycache__/speech_to_text.cpython-312.pyc and b/Merilife/MediBot/chatbot-website/chatbot/__pycache__/speech_to_text.cpython-312.pyc differ +diff --git a/Merilife/MediBot/chatbot-website/chatbot/__pycache__/urls.cpython-312.pyc b/Merilife/MediBot/chatbot-website/chatbot/__pycache__/urls.cpython-312.pyc +index 1258e5d..19eb67e 100644 +Binary files a/Merilife/MediBot/chatbot-website/chatbot/__pycache__/urls.cpython-312.pyc and b/Merilife/MediBot/chatbot-website/chatbot/__pycache__/urls.cpython-312.pyc differ +diff --git a/Merilife/MediBot/chatbot-website/chatbot/__pycache__/utils.cpython-312.pyc b/Merilife/MediBot/chatbot-website/chatbot/__pycache__/utils.cpython-312.pyc +index 12a1aa2..ec1b3c7 100644 +Binary files a/Merilife/MediBot/chatbot-website/chatbot/__pycache__/utils.cpython-312.pyc and b/Merilife/MediBot/chatbot-website/chatbot/__pycache__/utils.cpython-312.pyc differ +diff --git a/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0001_initial.cpython-312.pyc b/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0001_initial.cpython-312.pyc +index 2b8c49a..aca9fb8 100644 +Binary files a/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0001_initial.cpython-312.pyc and b/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0001_initial.cpython-312.pyc differ +diff --git a/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0002_customuser_groups_customuser_is_superuser_and_more.cpython-312.pyc b/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0002_customuser_groups_customuser_is_superuser_and_more.cpython-312.pyc +index bc43096..b7d07b2 100644 +Binary files a/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0002_customuser_groups_customuser_is_superuser_and_more.cpython-312.pyc and b/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0002_customuser_groups_customuser_is_superuser_and_more.cpython-312.pyc differ +diff --git a/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0003_customuser_bio_customuser_email_customuser_full_name_and_more.cpython-312.pyc b/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0003_customuser_bio_customuser_email_customuser_full_name_and_more.cpython-312.pyc +index c4c0155..9eb2b05 100644 +Binary files a/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0003_customuser_bio_customuser_email_customuser_full_name_and_more.cpython-312.pyc and b/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0003_customuser_bio_customuser_email_customuser_full_name_and_more.cpython-312.pyc differ +diff --git a/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0004_doctorprofile_patientprofile.cpython-312.pyc b/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0004_doctorprofile_patientprofile.cpython-312.pyc +index b7d3080..6b1308c 100644 +Binary files a/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0004_doctorprofile_patientprofile.cpython-312.pyc and b/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0004_doctorprofile_patientprofile.cpython-312.pyc differ +diff --git a/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0005_treatment.cpython-312.pyc b/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0005_treatment.cpython-312.pyc +index 8aaf8de..5f47394 100644 +Binary files a/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0005_treatment.cpython-312.pyc and b/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0005_treatment.cpython-312.pyc differ +diff --git a/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0006_treatment_reqd.cpython-312.pyc b/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0006_treatment_reqd.cpython-312.pyc +index 99ebcc2..c028306 100644 +Binary files a/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0006_treatment_reqd.cpython-312.pyc and b/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0006_treatment_reqd.cpython-312.pyc differ +diff --git a/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0007_customuser_address_customuser_age_and_more.cpython-312.pyc b/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0007_customuser_address_customuser_age_and_more.cpython-312.pyc +index dcd4c15..26e2be9 100644 +Binary files a/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0007_customuser_address_customuser_age_and_more.cpython-312.pyc and b/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0007_customuser_address_customuser_age_and_more.cpython-312.pyc differ +diff --git a/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0008_alter_customuser_email.cpython-312.pyc b/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0008_alter_customuser_email.cpython-312.pyc +index ea4f743..0bee401 100644 +Binary files a/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0008_alter_customuser_email.cpython-312.pyc and b/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0008_alter_customuser_email.cpython-312.pyc differ +diff --git a/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0009_fix_migration_conflicts.cpython-312.pyc b/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0009_fix_migration_conflicts.cpython-312.pyc +index a1bc562..e91f28c 100644 +Binary files a/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0009_fix_migration_conflicts.cpython-312.pyc and b/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/0009_fix_migration_conflicts.cpython-312.pyc differ +diff --git a/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/__init__.cpython-312.pyc b/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/__init__.cpython-312.pyc +index 48ed90e..da631f5 100644 +Binary files a/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/__init__.cpython-312.pyc and b/Merilife/MediBot/chatbot-website/chatbot/migrations/__pycache__/__init__.cpython-312.pyc differ +diff --git a/Merilife/MediBot/chatbot-website/chatbot/templates/chatbot/medical_chat.html b/Merilife/MediBot/chatbot-website/chatbot/templates/chatbot/medical_chat.html +index 5863afe..6cccaa8 100644 +--- a/Merilife/MediBot/chatbot-website/chatbot/templates/chatbot/medical_chat.html ++++ b/Merilife/MediBot/chatbot-website/chatbot/templates/chatbot/medical_chat.html +@@ -38,7 +38,11 @@ + .navbar-brand i { color: var(--primary); margin-right: 0.5rem; } + .nav-link { font-weight: 500; padding: 0.25rem 0.75rem !important; border-radius: 6px; transition: background .3s, transform .3s; } + .nav-link:hover { background: rgba(155,89,182,0.1); transform: translateY(-2px); } +- ++ /* Add to style section */ ++ .chat-disabled { ++ opacity: 0.6; ++ pointer-events: none; ++ } + .hero { + flex: 1; + display: flex; +@@ -47,6 +51,8 @@ + background: linear-gradient(135deg, var(--secondary), var(--primary), var(--secondary)); + background-size: 300% 300%; + animation: gradientBG 10s ease infinite; ++ min-height: calc(100vh - 80px); /* Account for header height */ ++ padding: 20px 0; + } + .chat-container { + background: var(--bg); +@@ -59,9 +65,22 @@ + box-shadow: 0 8px 20px rgba(0,0,0,0.15); + overflow: hidden; + animation: fadeInUp 1s ease; ++ display: none; /* Hidden initially */ ++ height: 100%; ++ max-height: 80vh; ++ display: flex; ++ flex-direction: column; + } + .chat-header { background: var(--primary); color: #fff; padding: 1rem; font-weight: 600; } +- .chat-body { flex: 1; padding: 1rem; overflow-y: auto; } ++ .chat-body {  ++ flex: 1;  ++ padding: 1rem;  ++ overflow-y: auto; ++ flex: 1; ++ min-height: 200px; ++ overflow-y: auto; ++ padding: 15px;  ++ } + .message { margin-bottom: 1rem; max-width: 80%; padding: 0.75rem 1rem; border-radius: 12px; } + .bot { background: #e0f2f1; align-self: flex-start; color: var(--text); } + .user { background: var(--primary); color: #fff; align-self: flex-end; } +@@ -71,23 +90,87 @@ + padding: 0.75rem; + border-top: 1px solid rgba(0,0,0,0.1); + background: rgba(255,255,255,0.85); ++ margin-top: auto; /* Pushes footer to bottom */ ++ padding: 15px; ++ background: #f8f9fa; ++ border-top: 1px solid #dee2e6; + } + .chat-footer input { flex: 1; padding: 0.5rem; border: 1px solid #ccc; border-radius: 4px; } +- .chat-footer select { margin: 0 0.5rem; } + #mic-btn.active i { color: red; animation: pulse 1s infinite; } ++ .specialization { ++ color: #9b59b6; ++ font-weight: 600; ++ padding: 8px; ++ border-left: 3px solid #9b59b6; ++ margin: 10px 0; ++ } ++ /* Language Modal Styles */ ++ .language-modal { ++ position: fixed; ++ top: 0; ++ left: 0; ++ width: 100%; ++ height: 100%; ++ background: rgba(0,0,0,0.8); ++ display: flex; ++ justify-content: center; ++ align-items: center; ++ z-index: 9999; ++ backdrop-filter: blur(5px); ++ } ++ .modal-content { ++ background: white; ++ padding: 2rem; ++ border-radius: 1rem; ++ text-align: center; ++ max-width: 500px; ++ } ++ .lang-btn { ++ width: 200px; ++ transition: transform 0.3s; ++ margin: 0.5rem; ++ } ++ .lang-btn:hover { ++ transform: scale(1.05); ++ } ++ #lang-mic-btn { ++ border-radius: 50%; ++ width: 60px; ++ height: 60px; ++ font-size: 1.5rem; ++ margin-top: 1rem; ++ } ++ + @keyframes fadeInDown { from { opacity:0; transform: translateY(-20px);} to{opacity:1;transform:translateY(0);} } + @keyframes fadeInUp { from{opacity:0;transform:translateY(20px);} to{opacity:1;transform:translateY(0);} } + @keyframes gradientBG { + 0% { background-position: 0% 50%; } +- 25% { background-position: 50% 100%; } + 50% { background-position: 100% 50%; } +- 75% { background-position: 50% 0%; } + 100% { background-position: 0% 50%; } + } + @keyframes pulse { 0%{transform:scale(1);}50%{transform:scale(1.1);}100%{transform:scale(1);} } +  +  +  ++  ++
 ++  ++
 ++ +
 +
 +@@ -154,16 +232,110 @@ +  + // DOM refs + const chatBody = $('#chat-body'), +- input = $('#user-input'), +- sendBtn = $('#send-btn'), +- micBtn = $('#mic-btn'), +- langSel = $('#lang-select'); ++ input = $('#user-input'), ++ sendBtn = $('#send-btn'), ++ micBtn = $('#mic-btn'), ++ langModal = $('.language-modal'), ++ langButtons = $('.lang-btn'), ++ langMicBtn = $('#lang-mic-btn'); ++ ++ let selectedLang = null; ++ let recognition; ++ let languageRecognition; +  +- // Add message to UI (and speak bot ones) ++ // Add message to UI ++ // Update addMessage function + function addMessage(text, cls) { +- chatBody.append($('
').addClass('message '+cls).text(text)); ++ let message = $('
').addClass('message '+cls); ++  ++ if (cls === 'bot' && text.includes('specialization')) { ++ message.addClass('specialization'); ++ message.html(`${text}`); ++ } else { ++ message.text(text); ++ } ++  ++ chatBody.append(message); + chatBody.scrollTop(chatBody[0].scrollHeight); +- if (cls === 'bot') speak(text, langSel.val()); ++ if (cls === 'bot') speak(text, selectedLang); ++ } ++ ++ // Initialize speech recognition ++ function initSpeechRecognition() { ++ if ('SpeechRecognition' in window || 'webkitSpeechRecognition' in window) { ++ const SR = window.SpeechRecognition || window.webkitSpeechRecognition; ++ recognition = new SR(); ++ recognition.continuous = false; ++ recognition.interimResults = false; ++ recognition.lang = selectedLang; ++ ++ micBtn.on('click', () => { ++ recognition.lang = selectedLang; ++ micBtn.toggleClass('active'); ++ if (micBtn.hasClass('active')) recognition.start(); ++ else recognition.stop(); ++ }); ++ ++ recognition.onresult = event => { ++ const transcript = event.results[0][0].transcript; ++ input.val(transcript); ++ sendAnswer(); ++ }; ++ ++ recognition.onend = () => micBtn.removeClass('active'); ++ recognition.onerror = e => console.error('Speech error:', e); ++ } else { ++ micBtn.hide(); ++ } ++ } ++ ++ // Language detection setup ++ function initLanguageRecognition() { ++ if ('SpeechRecognition' in window || 'webkitSpeechRecognition' in window) { ++ const SR = window.SpeechRecognition || window.webkitSpeechRecognition; +[ \ No newline at end of file