### Firebase Configuration and Database Operations Source: https://context7.com/harshit-1104/doctor_patient_web/llms.txt Initializes and configures the Firebase connection for database and storage operations using the `pyrebase` library. Includes examples for pushing, retrieving, updating, and deleting data from the Firebase database, as well as uploading files and getting download URLs from Firebase Storage. ```python import pyrebase # Firebase configuration config = { "apiKey": "your_api_key", "authDomain": "your-project.firebaseapp.com", "databaseURL": "https://your-project.firebaseio.com", "projectId": "your-project-id", "storageBucket": "your-project.appspot.com", "messagingSenderId": "your_sender_id", "appId": "your_app_id", "measurementId": "your_measurement_id" } # Initialize Firebase irebase = pyrebase.initialize_app(config) db = firebase.database() storage = firebase.storage() # Database operations # Create/Push data db.child("Users/Patients").push({ "name": "John Doe", "email": "john@example.com" }) # Read data patient_data = db.child("Users/Patients/patient_id").get().val() # Update data db.child("Users/Doctors/doc_id/address").update({ "city": "New York", "state": "NY" }) # Delete data db.child("Users/Patients/patient_id/Reminder/reminder_id").remove() # Storage operations # Upload file storage.child("path/to/file.jpg").put("local_file.jpg") # Get download URL url = storage.child("path/to/file.jpg").get_url(None) ``` -------------------------------- ### JavaScript OTP Handling with AJAX Source: https://github.com/harshit-1104/doctor_patient_web/blob/main/templates/layout.html JavaScript code that retrieves an OTP from a dummy text element, checks its length, and sends an AJAX GET request to a server endpoint '/Delete_OTP' if the OTP is 6 digits long. The response from the server is then written to the document. ```javascript var dummy_text=document.querySelector('#dummy_text'); OTP = dummy_text.innerHTML; if(OTP.length == 6) { $.ajax({ type:'GET', url: "{{ url_for( 'Delete_OTP' ) }}", //'/Delete_OTP', data: JSON, contentType: "application/json", success:function(response){ document.write(response); } }).done(); } ``` -------------------------------- ### JavaScript OTP Handling and AJAX Request Source: https://github.com/harshit-1104/doctor_patient_web/blob/main/templates/layout1.html This JavaScript code snippet retrieves an OTP from a dummy text element, checks its length, and then makes an AJAX GET request to a Flask endpoint ('Delete_OTP') to delete the OTP. It handles the server response by writing it to the document. Dependencies include jQuery ('$'). ```javascript var dummy_text=document.querySelector('#dummy_text'); OTP = dummy_text.innerHTML; if(OTP.length == 6) { $.ajax({ type:'GET', url: "{{ url_for( 'Delete_OTP' ) }}", //'/Delete_OTP', data: JSON, //.stringify({'myId':bunchOfIds}), contentType: "application/json", success:function(response){ document.write(response); } }).done }; ``` -------------------------------- ### View Doctor's Given Reports History via API Source: https://context7.com/harshit-1104/doctor_patient_web/llms.txt Enables a doctor to view a history of all reports they have uploaded to patients. This GET request retrieves report details, including storage URLs, patient emails, and upload timestamps from Firebase. It requires the user to be logged in as a doctor. ```python import requests url = "http://localhost:5000/my_given_oldreport" # Must be logged in as doctor response = requests.get(url) # Expected behavior: # - Requires @is_logged_in decorator # - Retrieves: Users/Doctors/{doc_ses_id}/g_Reports # - Returns all reports with: # - Storage URL of uploaded document # - Patient email (Pushed to) # - Date and Time of upload # - Allows doctor to track all prescriptions given # - Template: my_given_oldreport.html with g_reports context ``` -------------------------------- ### Firebase Configuration and Initialization Source: https://context7.com/harshit-1104/doctor_patient_web/llms.txt Demonstrates how to configure and initialize the Pyrebase SDK for interacting with Firebase services, including database and storage operations. ```APIDOC ## Firebase Initialization and Operations ### Description Initializes the Pyrebase SDK with provided configuration and demonstrates basic database and storage operations. ### Initialization ```python import pyrebase config = { "apiKey": "your_api_key", "authDomain": "your-project.firebaseapp.com", "databaseURL": "https://your-project.firebaseio.com", "projectId": "your-project-id", "storageBucket": "your-project.appspot.com", "messagingSenderId": "your_sender_id", "appId": "your_app_id", "measurementId": "your_measurement_id" } firebase = pyrebase.initialize_app(config) db = firebase.database() storage = firebase.storage() ``` ### Database Operations #### Push (Create) ```python db.child("Users/Patients").push({ "name": "John Doe", "email": "john@example.com" }) ``` #### Get (Read) ```python patient_data = db.child("Users/Patients/patient_id").get().val() ``` #### Update ```python db.child("Users/Doctors/doc_id/address").update({ "city": "New York", "state": "NY" }) ``` #### Remove (Delete) ```python db.child("Users/Patients/patient_id/Reminder/reminder_id").remove() ``` ### Storage Operations #### Upload File ```python storage.child("path/to/file.jpg").put("local_file.jpg") ``` #### Get Download URL ```python url = storage.child("path/to/file.jpg").get_url(None) ``` ``` -------------------------------- ### Map Customer Domain to Proto with Nil Safety in Go Source: https://context7.com/harshit-1104/doctor_patient_web/llms.txt Safely maps a Customer domain object to a CustomerProto, returning nil if the input Customer is nil or considered empty. Handles cases with valid, empty, and nil customer inputs. ```go package main // Customer domain model type Customer struct { ID int } func (c *Customer) isEmpty() bool { return c == nil || c.ID == 0 } // Customer protocol buffer model type CustomerProto struct { ID int } // Safe mapping with nil check func toProtoFromCustomer(cust *Customer) *CustomerProto { if cust.isEmpty() { return nil } return &CustomerProto{ ID: cust.ID, } } // Usage example func main() { // Valid customer customer := &Customer{ID: 12345} proto := toProtoFromCustomer(customer) // proto.ID = 12345 // Empty customer emptyCustomer := &Customer{ID: 0} nilProto := toProtoFromCustomer(emptyCustomer) // nilProto = nil // Nil customer var nilCustomer *Customer result := toProtoFromCustomer(nilCustomer) // result = nil } ``` -------------------------------- ### Map Bank Domain to Proto with Nested Nil Safety in Go Source: https://context7.com/harshit-1104/doctor_patient_web/llms.txt Safely maps a Bank domain object, including its nested SubBank, to a BankProto. Returns nil if the input Bank is nil. Handles nested object mapping with explicit nil checks. ```go package main // Nested object mapping example type SubBank struct { ID int stat string } type Bank struct { ID int stat string SubBank *SubBank } func (b *Bank) isEmpty() bool { return b == nil || (b.ID == 0 && b.stat == "") } type BankProto struct { ID int stat string SubBank *SubBankProto } type SubBankProto struct { ID int stat string } func toProtoFromBank(bank *Bank) *BankProto { if bank == nil { return nil } // Map nested SubBank subBankProto := &SubBankProto{ ID: bank.SubBank.ID, stat: bank.SubBank.stat, } return &BankProto{ ID: bank.ID, stat: bank.stat, SubBank: subBankProto, } } // Usage with nested objects func exampleNestedMapping() { bank := &Bank{ ID: 1001, stat: "active", SubBank: &SubBank{ ID: 2001, stat: "verified", }, } bankProto := toProtoFromBank(bank) // bankProto.ID = 1001 // bankProto.stat = "active" // bankProto.SubBank.ID = 2001 // bankProto.SubBank.stat = "verified" } ``` -------------------------------- ### Doctor Registration with OTP Verification API Source: https://context7.com/harshit-1104/doctor_patient_web/llms.txt Manages doctor account registration with a two-step verification process. The first step submits doctor details, generates a 6-digit OTP, and sends it via email. The second step verifies this OTP within 30 seconds to create the doctor's record in Firebase under 'Users/Doctors'. Incomplete profile fields are initialized. ```python import requests # Step 1: Submit doctor registration form url_verify = "http://localhost:5000/docVerify" data = { 'docId': 'DOC12345', 'name': 'Dr. Jane Smith', 'email': 'drsmith@example.com', 'password': 'secureDocPassword', 'confirmed': 'secureDocPassword' } response = requests.post(url_verify, data=data) # System generates 6-digit OTP (100000-1000000) # Sends email via SMTP: smtp.gmail.com:465 # Stores OTP in Firebase: OTPs2/{id} with email and OTP # Redirects to /otpVerify page # Step 2: Verify OTP within 30 seconds url_otp = "http://localhost:5000/otpVerify" otp_data = { 'otp': '543219' # User receives via email } response = requests.post(url_otp, data=otp_data) # Expected behavior: # - Validates OTP matches stored value for email # - Creates doctor record in Firebase: Users/Doctors/{id} # - Default profile image included (base64 encoded) # - Address fields initialized empty (city, state, country, pincode) # - Specialist field initialized empty # - Returns redirect to login with success message # - OTP expires after 30 seconds via /Delete_verify_OTP endpoint ``` -------------------------------- ### Jinja Template Includes Source: https://github.com/harshit-1104/doctor_patient_web/blob/main/templates/layout1.html Demonstrates the inclusion of reusable template partials within a Jinja2 environment. This facilitates modularity in web page construction. It relies on the Jinja templating engine. ```jinja {% include 'includes/_navbar1.html' %} {% include 'includes/_messages.html' %} {% block body %}{% endblock %} ``` -------------------------------- ### Login Form State Management with JavaScript Source: https://github.com/harshit-1104/doctor_patient_web/blob/main/templates/login.html This JavaScript code manages the visual state of the login and registration forms. It uses local storage to remember the last selected login option and applies CSS classes to animate the form wrapper and change the background color accordingly. It also handles click events for the login and register buttons. ```javascript $(document).ready(function(){ var def = ".login-btn button"; if (!localStorage.getItem("log")) { localStorage.setItem("log", ".login-btn button") } else { def = localStorage.getItem("log") } if (def === ".login-btn button") { $('.veen .wrapper').addClass('move'); $('.body').css('background','#e0b722'); $(".veen .login-btn button").removeClass('active'); $(this).addClass('active'); } else if (def === ".rgstr-btn button") { $('.veen .wrapper').removeClass('move'); $('.body').css('background','#ff4931'); $(".veen .rgstr-btn button").removeClass('active'); $(this).addClass('active'); } $(".veen .rgstr-btn button").click(function(){ $('.veen .wrapper').addClass('move'); $('.body').css('background','#e0b722'); $(".veen .login-btn button").removeClass('active'); $(this).addClass('active'); localStorage.setItem("log", ".login-btn button") }); $(".veen .login-btn button").click(function(){ $('.veen .wrapper').removeClass('move'); $('.body').css('background','#ff4931'); $(".veen .rgstr-btn button").removeClass('active'); $(this).addClass('active'); localStorage.setItem("log", ".rgstr-btn button") }); }); ``` -------------------------------- ### Jinja2 Template Includes Source: https://github.com/harshit-1104/doctor_patient_web/blob/main/templates/layout.html Includes for Jinja2 templating engine, incorporating reusable components for the navigation bar and user messages. It also defines a block for the main page content. ```html {% include 'includes/_navbar.html' %} {% include 'includes/_messages.html' %} {% block body %}{% endblock %} ``` -------------------------------- ### Patient Login API Source: https://context7.com/harshit-1104/doctor_patient_web/llms.txt Authenticates patients using their email and password, establishing a session for access to the patient dashboard. ```APIDOC ## POST /patLogin ### Description Authenticates a patient with email and password, creating a session for dashboard access. ### Method POST ### Endpoint `/patLogin` ### Parameters #### Request Body - **email** (string) - Required - The patient's email address. - **password** (string) - Required - The patient's password. ### Request Example ```json { "email": "johndoe@example.com", "password": "securePassword123" } ``` ### Response #### Success Response (200) - Creates session variables: `session['logged_in'] = True`, `session['username']`, `session['email']`, `session['patient_id']`. - Redirects to `/pat_dashboard`. #### Error Response (401) - Flash error message: "Please check your credentials" - Returns an error response. ``` -------------------------------- ### Patient Registration API Source: https://context7.com/harshit-1104/doctor_patient_web/llms.txt Allows new patients to register for an account. The system validates the email, hashes the password using SHA-256, and creates a new patient record in the Firebase database. ```APIDOC ## POST /patRegister ### Description Registers a new patient account with email validation and password hashing using SHA-256 encryption. ### Method POST ### Endpoint `/patRegister` ### Parameters #### Request Body - **name** (string) - Required - The name of the patient. - **email** (string) - Required - The email address of the patient. - **password** (string) - Required - The password for the patient account. - **confirmed** (string) - Required - Confirmation of the password. ### Request Example ```json { "name": "John Doe", "email": "johndoe@example.com", "password": "securePassword123", "confirmed": "securePassword123" } ``` ### Response #### Success Response (200) - **redirect** (string) - Redirects to the login page with a success message. #### Response Example (Redirects to /login with flash message: "Patient, you are now registered and can log in") ### Database Structure Created ```json { "name": "John Doe", "email": "johndoe@example.com", "password": "hashed_password_string", "Reports": "", "Reminder": "" } ``` ``` -------------------------------- ### Doctor Registration and OTP Verification API Source: https://context7.com/harshit-1104/doctor_patient_web/llms.txt Handles doctor account registration with a two-step verification process involving email OTP for enhanced security. ```APIDOC ## POST /docVerify and POST /otpVerify ### Description Registers a doctor account with a two-step verification process via email OTP for enhanced security. ### Method POST ### Endpoint `/docVerify` (for initial registration) `/otpVerify` (for OTP verification) ### Parameters #### Request Body (`/docVerify`) - **docId** (string) - Required - The doctor's unique ID. - **name** (string) - Required - The name of the doctor. - **email** (string) - Required - The email address of the doctor. - **password** (string) - Required - The password for the doctor account. - **confirmed** (string) - Required - Confirmation of the password. #### Request Body (`/otpVerify`) - **otp** (string) - Required - The 6-digit OTP received via email. ### Request Example (`/docVerify`) ```json { "docId": "DOC12345", "name": "Dr. Jane Smith", "email": "drsmith@example.com", "password": "secureDocPassword", "confirmed": "secureDocPassword" } ``` ### Request Example (`/otpVerify`) ```json { "otp": "543219" } ``` ### Response #### Success Response (200) (`/docVerify`) - The system generates a 6-digit OTP and sends it via email. - Redirects to the `/otpVerify` page. #### Success Response (200) (`/otpVerify`) - Validates the OTP matches the stored value. - Creates a doctor record in Firebase: `Users/Doctors/{id}`. - Initializes address fields and specialist field as empty. - Returns redirect to the login page with a success message. - The OTP expires after 30 seconds (handled by `/Delete_verify_OTP` endpoint). ### Notes - OTP is valid for 30 seconds. - Email is sent via SMTP: `smtp.gmail.com:465`. ``` -------------------------------- ### Manage login/registration view state with jQuery and LocalStorage Source: https://github.com/harshit-1104/doctor_patient_web/blob/main/templates/register.html This JavaScript snippet uses jQuery to manage the visual state of login and registration forms. It leverages LocalStorage to remember the user's last selected view (login or registration) and applies CSS classes and background colors accordingly. It handles click events for buttons to switch between views and updates LocalStorage. ```javascript $(document).ready(function(){ var def = ".login-btn button"; if (!localStorage.getItem("reg")) { localStorage.setItem("reg", ".login-btn button") } else { def = localStorage.getItem("reg") } if (def === ".login-btn button") { $('.veen .wrapper').addClass('move'); $('.body').css('background','#e0b722'); $(".login-btn button").removeClass('active'); $(this).addClass('active'); } else if (def === ".rgstr-btn button") { $('.veen .wrapper').removeClass('move'); $('.body').css('background','#ff4931'); $(".rgstr-btn button").removeClass('active'); $(this).addClass('active'); } $(".veen .rgstr-btn button").click(function(){ $('.veen .wrapper').addClass('move'); $('.body').css('background','#e0b722'); $(".login-btn button").removeClass('active'); $(this).addClass('active'); localStorage.setItem("reg", ".login-btn button") }); $(".veen .login-btn button").click(function(){ $('.veen .wrapper').removeClass('move'); $('.body').css('background','#ff4931'); $(".rgstr-btn button").removeClass('active'); $(this).addClass('active'); localStorage.setItem("reg", ".rgstr-btn button") }); }); ``` -------------------------------- ### Patient Dashboard Template (HTML/Jinja2) Source: https://github.com/harshit-1104/doctor_patient_web/blob/main/templates/doc_upload.html This Jinja2 template renders the patient's dashboard. It displays a section for uploading new reports and a list of the patient's old reports. Each report entry includes details such as who posted it, date, time, a note, and a link to view the report. The template iterates through the 'Reports' dictionary in the 'pinfo' object to display each report. ```html {% extends 'doc_layout.html' %} {% block body %} Patient's Dashboard =================== * * * Select report to upload: Submit Patient's Old Reports --------------------- {% for report in pinfo['Reports'] %} {% endfor %} Posted By Date Time Note Reports {{ pinfo['Reports'][report]['Pushed by'] }} {{ pinfo['Reports'][report]['Date'] }} {{ pinfo['Reports'][report]['Time'] }} {{ pinfo['Reports'][report]['Note'] }} [View]({{ pinfo['Reports'][report]['Url'] }}) {% endblock %} ``` -------------------------------- ### Patient Registration API Source: https://context7.com/harshit-1104/doctor_patient_web/llms.txt Handles new patient account creation. It validates email uniqueness, hashes passwords using SHA-256, stores user data in Firebase under 'Users/Patients', and redirects to the login page upon successful registration. The database structure includes fields for name, email, password, reports, and reminders. ```python import requests import hashlib # Patient registration endpoint url = "http://localhost:5000/patRegister" # Registration data data = { 'name': 'John Doe', 'email': 'johndoe@example.com', 'password': 'securePassword123', 'confirmed': 'securePassword123' } # Send POST request response = requests.post(url, data=data) # Expected behavior: # - Validates email doesn't already exist in database # - Hashes password using SHA-256 # - Creates patient record in Firebase: Users/Patients/{id} # - Returns redirect to login page with success message # - Flash message: "Patient, you are now registered and can log in" # Database structure created: # { # "name": "John Doe", # "email": "johndoe@example.com", # "password": "hashed_password_string", # "Reports": "", # "Reminder": "" # } ``` -------------------------------- ### CSS Styling for DocPat Source: https://github.com/harshit-1104/doctor_patient_web/blob/main/templates/layout1.html Provides CSS rules for the 'DocPat' component, specifically hiding elements with the 'dont_display' class and setting a default font family for the body. No external dependencies are required. ```css .dont_display{ display: none; } body{ font-family: 'Noto Sans JP', sans-serif; } ``` -------------------------------- ### Doctor Login API Source: https://context7.com/harshit-1104/doctor_patient_web/llms.txt Authenticates doctors using their email and password, with an additional check for profile completion before granting dashboard access. ```APIDOC ## POST /docLogin ### Description Authenticates a doctor with email and password, including a check for profile completeness. ### Method POST ### Endpoint `/docLogin` ### Parameters #### Request Body - **email** (string) - Required - The doctor's email address. - **password** (string) - Required - The doctor's password. ### Request Example ```json { "email": "drsmith@example.com", "password": "secureDocPassword" } ``` ### Response #### Success Response (200) - Creates session variables: `session['logged_in'] = True`, `session['username']`, `session['email']`, `session['doc_ses_id']`. - Checks if profile fields (address, specialist) are complete. - Redirects to `/doc_dashboard`. #### Warning Response - If profile is incomplete, a "Complete Your Profile" warning is flashed. #### Error Response (401) - Returns an error response if credentials are invalid. ``` -------------------------------- ### Doctor Access Patient Records via OTP (Python) Source: https://context7.com/harshit-1104/doctor_patient_web/llms.txt Enables doctors to verify a patient-provided OTP to gain temporary access to the patient's medical records. Upon successful verification, the doctor's session is updated with the patient's ID, and patient information is displayed, including historical reports and an upload form. ```python import requests url = "http://localhost:5000/DocAccPatOTPVerify" # Doctor enters OTP provided by patient data = { 'OTP': '543219' } response = requests.post(url, data=data) # Expected behavior: # - Requires active doctor session # - Queries Firebase: OTPs for matching OTP value # - Retrieves complete patient information: # patient_data = db.child("Users/Patients/{patient_id}").get().val() # - Stores patient_id in session for upload functionality # - Renders doc_upload.html with patient info displayed: # - Patient name, email # - All historical reports with timestamps # - Upload form for new prescriptions # - Flash error "No Patient Found, try Again" if OTP invalid # - OTP valid for 10 seconds only ``` -------------------------------- ### Doctor Login API Source: https://context7.com/harshit-1104/doctor_patient_web/llms.txt Authenticates doctors using email and password against the 'Users/Doctors' collection in Firebase. It creates a session with doctor information upon successful login. Additionally, it checks for profile completeness (address and specialist fields) and provides a warning if the profile is incomplete before redirecting to the doctor dashboard. ```python import requests url = "http://localhost:5000/docLogin" credentials = { 'email': 'drsmith@example.com', 'password': 'secureDocPassword' } response = requests.post(url, data=credentials) # Expected behavior: # - Validates credentials against Firebase: Users/Doctors # - Creates session with doctor information: # session['logged_in'] = True # session['username'] = doctor['name'] # session['email'] = doctor['email'] # session['doc_ses_id'] = firebase_doctor_id # - Checks profile completeness (address, specialist fields) # - Flash warning "Complete Your Profile" if incomplete # - Redirects to /doc_dashboard ``` -------------------------------- ### Session Management and Logout Source: https://context7.com/harshit-1104/doctor_patient_web/llms.txt Handles user sessions, including logging out users by clearing all session data and redirecting them to the login page. Also details the usage of session decorators for protected routes. ```APIDOC ## GET /logout ### Description Logs out the current user by clearing all session data and redirecting to the login page. ### Method GET ### Endpoint /logout ### Parameters None ### Response #### Success Response (302 Found) - Clears session variables (`logged_in`, `username`, `email`, `patient_id` or `doc_ses_id`). - Redirects to `/login` page. ### Protected Routes - Routes can be protected using the `@is_logged_in` decorator to ensure only authenticated users can access them. Unauthorized access attempts are redirected to the login page with an "Unauthorized, Please login" message. ``` -------------------------------- ### Session Management and Logout via API Source: https://context7.com/harshit-1104/doctor_patient_web/llms.txt Handles user session management, including a logout function that clears all session data. The logout endpoint clears variables like 'logged_in', 'username', 'email', and user IDs, then redirects to the login page. It also demonstrates the usage of an `@is_logged_in` decorator for protecting routes. ```python import requests # Logout endpoint url = "http://localhost:5000/logout" response = requests.get(url) # Expected behavior: # - Calls session.clear() # - Removes all session variables: # - logged_in, username, email # - patient_id or doc_ses_id # - Flash message: "Successfully logged out" # - Redirects to /login page # Session decorator usage in protected routes: @app.route('/pat_dashboard') @is_logged_in def pat_dashboard(): # Only accessible if 'logged_in' in session # Otherwise redirects to login with "Unauthorized, Please login" pass ``` -------------------------------- ### Patient Login API Source: https://context7.com/harshit-1104/doctor_patient_web/llms.txt Authenticates patients using email and password. It hashes the provided password with SHA-256 for comparison against stored credentials in Firebase ('Users/Patients'). Upon successful authentication, it establishes a session with user details and redirects to the patient dashboard. ```python import requests import hashlib url = "http://localhost:5000/patLogin" # Login credentials credentials = { 'email': 'johndoe@example.com', 'password': 'securePassword123' } response = requests.post(url, data=credentials) # Expected behavior: # - Hashes password with SHA-256 for comparison # - Queries Firebase: Users/Patients for matching email and password # - Creates session variables on success: # session['logged_in'] = True # session['username'] = user['name'] # session['email'] = user['email'] # session['patient_id'] = unique_firebase_key # - Redirects to /pat_dashboard # - Flash error "Please check your credentials" on failure ``` -------------------------------- ### Render Form Fields in Jinja2 Source: https://github.com/harshit-1104/doctor_patient_web/blob/main/templates/login.html This snippet demonstrates how to render form fields using a macro in Jinja2 templating. It assumes the existence of a `render_field` macro defined in `includes/_formhelpers.html`. It is used for both patient and doctor login forms. ```html {% from "includes/_formhelpers.html" import render_field %} ### Patient {{render_field(form1.email, class_="form-control")}} {{render_field(form1.password, class_="form-control")}} ### Doctor {{render_field(form2.email, class_="form-control")}} {{render_field(form2.password, class_="form-control")}} ``` -------------------------------- ### HTML Template for Doctor Information Source: https://github.com/harshit-1104/doctor_patient_web/blob/main/templates/search_doc.html This Jinja2 HTML template defines the structure for displaying doctor search filters and a table of doctor information. It iterates through a list of doctors to populate the table rows. Basic form elements are used for user input. ```jinja2 {% extends 'pat\_layout.html' %} {% block body %} Enter your location: Specialist you need: Name of the Doctor: {% for doc in docs %} {% endfor %} Name Place Specialist View Profile {{ docs\[doc\]\["name"] }} {{ docs\[doc\]\["address"]\["city"]}}, {{docs\[doc\]\["address"]\["state"] }} {{ docs\[doc\]\["specialist"] }} View Profile {% endblock %} ``` -------------------------------- ### Search for Doctors (Python) Source: https://context7.com/harshit-1104/doctor_patient_web/llms.txt Allows users to search and browse registered doctors. The system retrieves a list of all doctors from Firebase, including their name, specialty, address, and profile image URL, enabling frontend filtering by specialty. ```python import requests url = "http://localhost:5000/search_doc" response = requests.get(url) # Expected behavior: # - Retrieves all doctors: Users/Doctors # - Returns list of doctors with: # - Name, DocId # - Specialist (e.g., "Cardiologist", "Dermatologist") # - Address (city, state, country, pincode) # - Profile image URL # - Frontend allows filtering by: # - Specialty ``` -------------------------------- ### Add Patient Reminder Source: https://context7.com/harshit-1104/doctor_patient_web/llms.txt Allows a patient to create reminders for appointments, medication refills, or follow-up visits. The reminder is stored in Firebase and displayed on the reminder page. ```APIDOC ## POST /add_reminder ### Description Creates reminders for appointments, medication refills, or follow-up visits for a patient. Requires an active patient session. ### Method POST ### Endpoint /add_reminder ### Parameters #### Request Body - **Reminder** (string) - Required - The text of the reminder. ### Request Example ```json { "Reminder": "Take blood pressure medication at 9 AM daily" } ``` ### Response #### Success Response (302 Found) - Redirects to `/reminder` page after the reminder is added. #### Details - Stores reminder in Firebase: `Users/Patients/{patient_id}/Reminder/{reminder_id}`. - Displays all active reminders on the `/reminder` page. ``` -------------------------------- ### Generate Patient OTP for Doctor Access (Python) Source: https://context7.com/harshit-1104/doctor_patient_web/llms.txt Generates a time-limited, 6-digit OTP for patients to grant doctors temporary access to their medical records. The OTP is stored in Firebase and is valid for 10 seconds before being deleted. ```python import requests url = "http://localhost:5000/PatAccessDocOTP" # Must be logged in as patient response = requests.post(url) # Expected behavior: # - Generates random 6-digit OTP (100000-1000000) # - Stores in Firebase: OTPs/{id} # { # "patient_id": session['patient_id'], # "OTP": 543219 # } # - Returns rendered template with OTP displayed to patient # - OTP expires after 10 seconds via /Delete_OTP endpoint # - Patient shares this OTP with their doctor for record access # Example response displays OTP: 543219 # Patient communicates this code to doctor verbally or digitally ``` -------------------------------- ### Doctor Upload Patient Prescription (Python) Source: https://context7.com/harshit-1104/doctor_patient_web/llms.txt Allows doctors to upload prescriptions or medical reports to a patient's record after successful OTP verification. The uploaded file is converted to JPEG, stored in Firebase Storage, and its metadata is added to both the patient's and doctor's records. ```python import requests url = "http://localhost:5000/doc_upload" # Must have verified patient OTP first file = ('file', ('prescription.jpg', open('prescription.jpg', 'rb'), 'image/jpeg')) response = requests.post(url, files=[file]) # Expected behavior: # - Requires active doctor session and patient_id in session # - Converts image to JPEG using PIL # - Uploads to Firebase Storage: {doctor_username}/{timestamp}.jpeg # - Adds to patient's reports: Users/Patients/{patient_id}/Reports # { # "Url": "storage_url", # "Pushed by": "Dr. Jane Smith", # "Date": "26/10/2025", # "Time": "15:45:30", # "Note": "" # } # - Adds to doctor's given reports history: Users/Doctors/{doc_id}/g_Reports # { # "Url": "storage_url", # "Pushed to": "johndoe@example.com", # "Date": "26/10/2025", # "Time": "15:45:30" # } # - Clears patient_id from session # - Flash message: "Uploaded patient's report" # - Redirects to /doc_dashboard ``` -------------------------------- ### CSS Styling for Doctor Patient Web Source: https://github.com/harshit-1104/doctor_patient_web/blob/main/templates/layout.html Basic CSS rules for the application. It includes a rule to hide an element with the class 'dont_display' and sets a default font family for the body. ```css .dont_display { display: none; } body { font-family: 'Noto Sans JP', sans-serif; } ``` -------------------------------- ### Doctor Profile Management Source: https://context7.com/harshit-1104/doctor_patient_web/llms.txt Updates a doctor's profile information, including their specialty, address, and profile picture. This endpoint requires the user to be logged in. ```APIDOC ## POST /update_my_profile ### Description Updates a doctor's profile including specialty, address, and profile picture. Requires the user to be logged in. ### Method POST ### Endpoint /update_my_profile ### Parameters #### Form Data - **specialist** (string) - Required - The doctor's medical specialty. - **city** (string) - Required - The city of the doctor's address. - **state** (string) - Required - The state of the doctor's address. - **country** (string) - Required - The country of the doctor's address. - **city_pin** (string) - Required - The postal code of the doctor's address. #### Files - **files** (file) - Required - The doctor's profile picture. ### Request Example ```json { "specialist": "Cardiologist", "city": "New York", "state": "New York", "country": "USA", "city_pin": "10001" } ``` ### Response #### Success Response (302 Found) - Redirects to `/my_profile` upon successful update. #### Error Response - Returns an appropriate error if the update fails or if the user is not logged in. ``` -------------------------------- ### Add Patient Reminder via API Source: https://context7.com/harshit-1104/doctor_patient_web/llms.txt Allows adding reminders for patients, such as for appointments or medication. This function sends a POST request with the reminder details. The reminders are stored in Firebase under the patient's record. The API also supports viewing all active reminders. ```python import requests url = "http://localhost:5000/add_reminder" data = { 'Reminder': 'Take blood pressure medication at 9 AM daily' } response = requests.post(url, data=data) # Expected behavior: # - Requires patient session # - Stores in Firebase: Users/Patients/{patient_id}/Reminder/{reminder_id} # { # "rem": "Take blood pressure medication at 9 AM daily" # } # - Redirects to /reminder page # - Displays all active reminders # View all reminders url_view = "http://localhost:5000/reminder" response = requests.get(url_view) # Returns template with all patient reminders # Each reminder has delete button ``` -------------------------------- ### Patient Report Upload (Python) Source: https://context7.com/harshit-1104/doctor_patient_web/llms.txt Allows patients to upload medical reports as images with associated metadata to their Firebase storage. The system converts images to JPEG, uploads them to Firebase Storage, and stores metadata in Firebase DB. Temporary local files are deleted after upload. ```python import requests url = "http://localhost:5000/pat_upload" # Upload multiple files with note files = [ ('files', ('xray_report.jpg', open('xray_report.jpg', 'rb'), 'image/jpeg')), ('files', ('blood_test.jpg', open('blood_test.jpg', 'rb'), 'image/jpeg')) ] data = { 'Note': 'Annual checkup reports - February 2025' } response = requests.post(url, files=files, data=data) # Expected behavior: # - Requires active session (patient must be logged in) # - Converts all images to JPEG format using PIL # - Uploads to Firebase Storage: {username}/{index}{timestamp}.jpeg # - Stores metadata in Firebase DB: Users/Patients/{patient_id}/Reports/{report_id} # - Metadata structure: # { # "Url": "https://firebasestorage.googleapis.com/...", # "Pushed by": "User", # "Date": "26/10/2025", # "Time": "14:30:45", # "Note": "Annual checkup reports - February 2025" # } # - Deletes temporary local files # - Flash message: "Uploaded 2 files!" # - Redirects to /pat_dashboard ``` -------------------------------- ### View Patient Medical History (Python) Source: https://context7.com/harshit-1104/doctor_patient_web/llms.txt Enables patients to view their complete chronological medical history, including all uploaded reports. The system retrieves patient data from Firebase and displays reports with details such as URL, date, time, note, and the uploader. ```python import requests url = "http://localhost:5000/my_old_report" # Must be logged in as patient response = requests.get(url) # Expected behavior: # - Requires @is_logged_in decorator (session check) # - Retrieves all patient data: Users/Patients/{patient_id} # - Returns rendered template with: # - All reports from Reports/{report_id} # - Each report shows: URL, Date, Time, Note, Pushed by # - Chronological display of medical history # - Image previews with full-size view option # - Template: my_old_report.html with pinfo context variable ``` -------------------------------- ### Render form fields in Jinja2 templates Source: https://github.com/harshit-1104/doctor_patient_web/blob/main/templates/register.html This snippet demonstrates how to render form fields within Jinja2 HTML templates. It utilizes a macro 'render_field' to abstract the rendering process and allows for CSS class application. No specific inputs or outputs are defined beyond what the form field itself dictates. ```html {% include 'includes/\_messages.html' %} {% from "includes/\_formhelpers.html" import render_field %} ``` ```html {{render_field(form1.name, class_="form-control")}} ``` ```html {{render_field(form1.email, class_="form-control")}} ``` ```html {{render_field(form1.password, class_="form-control")}} ``` ```html {{render_field(form1.confirmed, class_="form-control")}} ``` ```html {{render_field(form2.docId, class_="form-control")}} ``` ```html {{render_field(form2.name, class_="form-control")}} ``` ```html {{render_field(form2.email, class_="form-control")}} ``` ```html {{render_field(form2.password, class_="form-control")}} ``` ```html {{render_field(form2.confirmed, class_="form-control")}} ``` -------------------------------- ### View Doctor's Given Reports History Source: https://context7.com/harshit-1104/doctor_patient_web/llms.txt Allows a doctor to view the complete history of all reports they have uploaded to patients. This endpoint requires the doctor to be logged in. ```APIDOC ## GET /my_given_oldreport ### Description Retrieves the complete history of all reports uploaded by the doctor to patients. Requires the doctor to be logged in. ### Method GET ### Endpoint /my_given_oldreport ### Parameters None ### Response #### Success Response (200 OK) - **g_reports** (array) - A list of reports, where each report contains: - **storage_url** (string) - The URL of the uploaded document. - **patient_email** (string) - The email of the patient the report was sent to. - **upload_datetime** (string) - The date and time of the upload. ``` -------------------------------- ### JavaScript for Filtering Doctor Table Source: https://github.com/harshit-1104/doctor_patient_web/blob/main/templates/search_doc.html This JavaScript function filters the doctor table based on user input for location, specialist, and doctor name. It dynamically hides or shows table rows () that do not match the filter criteria. It assumes the presence of elements with IDs 'filterInput', 'filterInput1', 'filterInput2', and a table with ID 'docTable'. ```javascript const searchinfo = () => { let filter=document.getElementById('filterInput').value.toUpperCase(); let filter1=document.getElementById('filterInput1').value.toUpperCase(); let filter2=document.getElementById('filterInput2').value.toUpperCase(); let t\_body = document.getElementById('docTable'); let d\_info=t\_body.getElementsByTagName('tr'); for (var i=0 ; i -1){ if (t\_spec.toLocaleUpperCase().indexOf(filter1) > -1) { if (t\_name.toLocaleUpperCase().indexOf(filter2) > -1) { d\_info[i].style.display = '' } else { d\_info[i].style.display = 'none' } } else { d\_info[i].style.display = 'none' } }else{ d\_info[i].style.display='none'; } } } ``` -------------------------------- ### Update Doctor Profile via API Source: https://context7.com/harshit-1104/doctor_patient_web/llms.txt Updates a doctor's profile information, including specialty, address, and profile picture. This function uses multipart form data for file uploads and standard form data for other profile fields. It requires the user to be logged in and uploads the profile image to Firebase Storage. ```python import requests url = "http://localhost:5000/update_my_profile" # Multipart form data files = { 'files': ('profile_pic.jpg', open('profile_pic.jpg', 'rb'), 'image/jpeg') } data = { 'specialist': 'Cardiologist', 'city': 'New York', 'state': 'New York', 'country': 'USA', 'city_pin': '10001' } response = requests.post(url, files=files, data=data) # Expected behavior: # - Requires @is_logged_in decorator # - Uploads profile image to Firebase Storage: doctor_profile/{username}/{timestamp}.jpeg # - Updates doctor record: Users/Doctors/{doc_ses_id} # - address: {city, state, country, pincode} # - specialist: "Cardiologist" # - profile_img: storage_url # - Converts image to JPEG, uploads, deletes temp file # - Profile completion triggers dashboard notifications # - Flash message: "Profile had Been Update" # - Redirects to /my_profile ``` -------------------------------- ### Filter Report Information (JavaScript) Source: https://github.com/harshit-1104/doctor_patient_web/blob/main/templates/pds.html This JavaScript function filters the report information displayed in a table. It takes user input from an input field and hides table rows that do not match the filter criteria. It relies on the presence of an element with id 'filterInput' and a table body with id 'total_report_info'. ```javascript const searchinfo = () => { let filter=document.getElementById('filterInput').value.toUpperCase(); let t_body = document.getElementById('total_report_info'); let d_info=t_body.getElementsByTagName('tr'); for (var i=0 ; i -1){ d_info[i].style.display=''; }else{ d_info[i].style.display='none' } } } ``` -------------------------------- ### Delete Patient Reminder Source: https://context7.com/harshit-1104/doctor_patient_web/llms.txt Removes a specific reminder from a patient's list. This action requires an active patient session and the reminder's unique ID. ```APIDOC ## POST /delete_reminder/{reminder_id} ### Description Removes completed or obsolete reminders from a patient's list. Requires an active patient session. ### Method POST ### Endpoint /delete_reminder/{reminder_id} ### Parameters #### Path Parameters - **reminder_id** (string) - Required - The unique identifier of the reminder to be deleted. ### Response #### Success Response (302 Found) - Redirects to `/reminder` page after the reminder is deleted. #### Details - Deletes the reminder from Firebase: `Users/Patients/{patient_id}/Reminder/{reminder_id}`. - Displays an updated list of active reminders. ``` -------------------------------- ### Delete Patient Reminder via API Source: https://context7.com/harshit-1104/doctor_patient_web/llms.txt Removes a specific patient reminder using its unique ID. This function sends a POST request to the delete endpoint with the reminder ID. The reminder is then deleted from Firebase, and the user is redirected to the reminder page with an updated list. ```python import requests # Reminder ID from Firebase reminder_id = "-MdKJF3j5nO2P8qR7sT9" url = f"http://localhost:5000/delete_reminder/{reminder_id}" response = requests.post(url) # Expected behavior: # - Requires patient session # - Deletes from Firebase: Users/Patients/{patient_id}/Reminder/{reminder_id} # - Flash message: "Reminder Deleted" # - Redirects to /reminder page # - Updated list displayed without deleted reminder ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.