{"id":131,"date":"2025-07-06T05:26:46","date_gmt":"2025-07-05T23:56:46","guid":{"rendered":"https:\/\/rehabilitationessentials.com\/?page_id=131"},"modified":"2025-07-06T08:28:45","modified_gmt":"2025-07-06T02:58:45","slug":"for-professionals","status":"publish","type":"page","link":"https:\/\/rehabilitationessentials.com\/index.php\/for-professionals\/","title":{"rendered":"For Professionals"},"content":{"rendered":"\n<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta charset=\"UTF-8\">\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n    <title>Physiotherapy Exercise Prescription Tool<\/title>\n    <!-- Tailwind CSS CDN -->\n    <script src=\"https:\/\/cdn.tailwindcss.com\"><\/script>\n    <link href=\"https:\/\/fonts.googleapis.com\/css2?family=Inter:wght@400;600;700&#038;display=swap\" rel=\"stylesheet\">\n    <style>\n        body {\n            font-family: 'Inter', sans-serif;\n            background-color: #f0f2f5;\n            color: #333;\n        }\n        \/* Custom scrollbar for better aesthetics *\/\n        ::-webkit-scrollbar {\n            width: 8px;\n        }\n        ::-webkit-scrollbar-track {\n            background: #f1f1f1;\n            border-radius: 10px;\n        }\n        ::-webkit-scrollbar-thumb {\n            background: #888;\n            border-radius: 10px;\n        }\n        ::-webkit-scrollbar-thumb:hover {\n            background: #555;\n            cursor: grab;\n        }\n        \/* Styles for the printable view *\/\n        \/* These styles are now primarily for the new print window *\/\n        @media print {\n            body {\n                margin: 0;\n                padding: 20px;\n                box-shadow: none;\n                border-radius: 0;\n                background-color: white;\n                color: #000; \/* Ensure black text for printing *\/\n                font-size: var(--print-base-font-size, 11pt); \/* Default or dynamic font size *\/\n            }\n            h1, h2, h3, p, li {\n                color: #000 !important;\n            }\n            img {\n                max-width: 100%;\n                height: auto;\n                display: block;\n                margin: 10px auto;\n            }\n            .exercise-item-print {\n                display: grid;\n                grid-template-columns: 120px 1fr; \/* Smaller image on left, text on right *\/\n                gap: 10px;\n                padding: 10px;\n                margin-bottom: 15px; \/* Reduced margin *\/\n                border-bottom: 1px dashed #ccc; \/* Keep separator *\/\n                page-break-inside: avoid; \/* Still try to keep exercise together if possible *\/\n            }\n            .exercise-item-print:last-child {\n                border-bottom: none;\n            }\n            .exercise-item-print img {\n                margin: 0; \/* Remove auto margin *\/\n                width: 100%;\n                height: auto;\n                max-width: 120px; \/* Enforce smaller image size *\/\n            }\n            .exercise-item-print .image-container {\n                display: flex;\n                flex-direction: column;\n                gap: 5px;\n            }\n            .exercise-item-print h4 {\n                font-size: 1.1em; \/* Slightly smaller heading *\/\n                margin-top: 0;\n                margin-bottom: 5px;\n            }\n            .exercise-item-print ul,\n            .exercise-item-print p {\n                font-size: 0.9em; \/* Smaller text *\/\n                margin-bottom: 5px;\n            }\n            .exercise-item-print h5 {\n                font-size: 1em; \/* Smaller subheadings *\/\n                margin-bottom: 5px;\n            }\n            .exercise-item-print ul.dosimetry-list {\n                list-style: none; \/* Remove bullet for dosimetry list *\/\n                padding-left: 0;\n                display: grid;\n                grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); \/* Responsive dosimetry *\/\n                gap: 5px;\n            }\n            .protocol-section {\n                border: 2px solid #a7f3d0; \/* Green border for protocols *\/\n                padding: 10px; \/* Reduced padding *\/\n                margin-bottom: 20px; \/* Reduced margin *\/\n                background-color: #ecfdf5; \/* Light green background *\/\n                border-radius: 8px;\n                page-break-before: always; \/* Start new page for each protocol *\/\n            }\n            .protocol-section:first-of-type {\n                page-break-before: auto; \/* Don't force new page for the very first protocol *\/\n            }\n            .protocol-phase {\n                border-left: 4px solid #34d399; \/* Darker green for phase *\/\n                padding-left: 8px; \/* Reduced padding *\/\n                margin-top: 10px; \/* Reduced margin *\/\n                margin-bottom: 10px; \/* Reduced margin *\/\n            }\n        }\n    <\/style>\n<\/head>\n<body class=\"p-4 md:p-8\">\n    <div class=\"max-w-7xl mx-auto bg-white p-6 md:p-10 rounded-xl shadow-lg\">\n        <h1 class=\"text-4xl font-bold text-center text-blue-700 mb-8\">Exercise Prescription Tool<\/h1>\n\n        <!-- Patient Profile \/ Session Details -->\n        <section class=\"mb-10 p-6 bg-blue-50 rounded-lg shadow-inner\">\n            <h2 class=\"text-2xl font-semibold text-blue-800 mb-4\">Patient &#038; Session Details<\/h2>\n            <div class=\"grid grid-cols-1 md:grid-cols-2 gap-6\">\n                <div>\n                    <label for=\"patientName\" class=\"block text-sm font-medium text-gray-700 mb-1\">Patient Name\/ID<\/label>\n                    <input type=\"text\" id=\"patientName\" class=\"w-full p-3 border border-gray-300 rounded-md focus:ring-blue-500 focus:border-blue-500 transition duration-150 ease-in-out\" placeholder=\"e.g., John Doe \/ P12345\">\n                <\/div>\n                <div>\n                    <label for=\"physioName\" class=\"block text-sm font-medium text-gray-700 mb-1\">Physiotherapist Name<\/label>\n                    <input type=\"text\" id=\"physioName\" class=\"w-full p-3 border border-gray-300 rounded-md focus:ring-blue-500 focus:border-blue-500 transition duration-150 ease-in-out\" placeholder=\"e.g., Sarah Smith\">\n                <\/div>\n                <div>\n                    <label for=\"serviceName\" class=\"block text-sm font-medium text-gray-700 mb-1\">Service Name<\/label>\n                    <input type=\"text\" id=\"serviceName\" class=\"w-full p-3 border border-gray-300 rounded-md focus:ring-blue-500 focus:border-blue-500 transition duration-150 ease-in-out\" placeholder=\"e.g., Community Physio Team\">\n                <\/div>\n                <div class=\"md:col-span-2\">\n                    <label for=\"clinicalGoals\" class=\"block text-sm font-medium text-gray-700 mb-1\">Clinical Goal(s)<\/label>\n                    <textarea id=\"clinicalGoals\" rows=\"3\" class=\"w-full p-3 border border-gray-300 rounded-md focus:ring-blue-500 focus:border-blue-500 transition duration-150 ease-in-out\" placeholder=\"e.g., Improve balance, Increase lower limb strength, Reduce falls risk\"><\/textarea>\n                <\/div>\n                <div class=\"md:col-span-2\">\n                    <label for=\"precautions\" class=\"block text-sm font-medium text-gray-700 mb-1\">Specific Instructions\/Precautions<\/label>\n                    <textarea id=\"precautions\" rows=\"3\" class=\"w-full p-3 border border-gray-300 rounded-md focus:ring-blue-500 focus:border-blue-500 transition duration-150 ease-in-out\" placeholder=\"e.g., Stop if dizziness occurs, Perform exercises seated if unstable\"><\/textarea>\n                <\/div>\n            <\/div>\n        <\/section>\n\n        <!-- Exercise Library -->\n        <section class=\"mb-10 p-6 bg-gray-50 rounded-lg shadow-inner\">\n            <h2 class=\"text-2xl font-semibold text-gray-800 mb-4\">Exercise Library<\/h2>\n            <div class=\"flex flex-col md:flex-row gap-4 mb-6\">\n                <input type=\"text\" id=\"exerciseSearch\" placeholder=\"Search exercises or protocols...\" class=\"flex-grow p-3 border border-gray-300 rounded-md focus:ring-blue-500 focus:border-blue-500 transition duration-150 ease-in-out\">\n                <select id=\"categoryFilter\" class=\"p-3 border border-gray-300 rounded-md focus:ring-blue-500 focus:border-blue-500 transition duration-150 ease-in-out\">\n                    <option value=\"\">All Categories<\/option>\n                    <option value=\"Strength\">Strength<\/option>\n                    <option value=\"Balance\">Balance<\/option>\n                    <option value=\"Flexibility\">Flexibility<\/option>\n                    <option value=\"Endurance\">Endurance<\/option>\n                    <option value=\"Functional\">Functional<\/option>\n                    <option value=\"Mobility\">Mobility<\/option>\n                    <option value=\"Chair-based\">Chair-based<\/option>\n                    <option value=\"Bed-based\">Bed-based<\/option>\n                    <option value=\"Upper Limb Coordination\">Upper Limb Coordination<\/option>\n                    <option value=\"Standing Balance\">Standing Balance<\/option>\n                    <option value=\"Post-Op\">Post-Op<\/option>\n                    <option value=\"Fracture Rehab\">Fracture Rehab<\/option>\n                    <option value=\"Shoulder\">Shoulder<\/option>\n                    <option value=\"Knee\">Knee<\/option>\n                    <option value=\"Ankle\">Ankle<\/option>\n                    <option value=\"Wrist\">Wrist<\/option>\n                    <option value=\"Hand\">Hand<\/option>\n                    <option value=\"Core\">Core<\/option>\n                    <option value=\"Glutes\">Glutes<\/option>\n                    <option value=\"Lower Back\">Lower Back<\/option>\n                    <option value=\"Posture\">Posture<\/option>\n                    <option value=\"Fall Prevention\">Fall Prevention<\/option>\n                    <option value=\"Warm-up\">Warm-up<\/option>\n                    <option value=\"Cool-down\">Cool-down<\/option>\n                <\/select>\n                <select id=\"difficultyFilter\" class=\"p-3 border border-gray-300 rounded-md focus:ring-blue-500 focus:border-blue-500 transition duration-150 ease-in-out\">\n                    <option value=\"\">All Difficulties<\/option>\n                    <option value=\"Very Easy\">Very Easy<\/option>\n                    <option value=\"Easy\">Easy<\/option>\n                    <option value=\"Moderate\">Moderate<\/option>\n                    <option value=\"Challenging\">Challenging<\/option>\n                <\/select>\n            <\/div>\n\n            <!-- Individual Exercises Section -->\n            <details open class=\"mb-6 border border-gray-200 rounded-lg shadow-sm\">\n                <summary class=\"p-4 bg-gray-200 rounded-t-lg cursor-pointer text-lg font-semibold text-gray-800 hover:bg-gray-300 transition duration-150 ease-in-out\">\n                    Individual Exercises\n                <\/summary>\n                <div id=\"individualExerciseList\" class=\"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6 p-4\">\n                    <!-- Individual Exercise cards will be loaded here by JavaScript -->\n                <\/div>\n            <\/details>\n\n            <!-- Protocols Section -->\n            <details open class=\"border border-gray-200 rounded-lg shadow-sm\">\n                <summary class=\"p-4 bg-gray-200 rounded-t-lg cursor-pointer text-lg font-semibold text-gray-800 hover:bg-gray-300 transition duration-150 ease-in-out\">\n                    Protocols\n                <\/summary>\n                <div id=\"protocolList\" class=\"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6 p-4\">\n                    <!-- Protocol cards will be loaded here by JavaScript -->\n                <\/div>\n            <\/details>\n\n            <!-- Otago Protocol Phase Selection Section (Hidden by default) -->\n            <div id=\"otagoPhaseSelection\" class=\"hidden mt-8 p-6 bg-yellow-50 rounded-lg shadow-md border border-yellow-300\">\n                <h3 class=\"text-xl font-semibold text-yellow-800 mb-4\">Configure Otago Protocol Phases<\/h3>\n                <p class=\"text-gray-700 mb-4\">Select the phases you wish to include in the prescription:<\/p>\n                <div id=\"otagoPhasesCheckboxes\" class=\"grid grid-cols-1 md:grid-cols-2 gap-4 mb-6\">\n                    <!-- Checkboxes will be dynamically loaded here -->\n                <\/div>\n                <div class=\"flex justify-end gap-4\">\n                    <button id=\"cancelOtagoSelectionBtn\" class=\"bg-gray-300 hover:bg-gray-400 text-gray-800 font-bold py-2 px-4 rounded-md transition duration-150 ease-in-out\">\n                        Cancel\n                    <\/button>\n                    <button id=\"confirmOtagoSelectionBtn\" class=\"bg-green-600 hover:bg-green-700 text-white font-bold py-2 px-4 rounded-md transition duration-150 ease-in-out\">\n                        Add Selected Phases to Prescription\n                    <\/button>\n                <\/div>\n            <\/div>\n        <\/section>\n\n        <!-- Prescription Builder -->\n        <section class=\"mb-10 p-6 bg-green-50 rounded-lg shadow-inner\">\n            <h2 class=\"text-2xl font-semibold text-green-800 mb-4\">Current Prescription<\/h2>\n\n            <!-- Global Dosimetry Settings -->\n            <div class=\"mb-8 p-4 bg-blue-100 rounded-lg shadow-sm border border-blue-300\">\n                <h3 class=\"text-xl font-semibold text-blue-800 mb-4\">Global Dosimetry Settings<\/h3>\n                <div class=\"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4 mb-4\">\n                    <div>\n                        <label for=\"globalSets\" class=\"block text-sm font-medium text-gray-700 mb-1\">Sets<\/label>\n                        <input type=\"number\" id=\"globalSets\" value=\"3\" min=\"0\" class=\"w-full p-2 border border-gray-300 rounded-md text-sm\">\n                    <\/div>\n                    <div>\n                        <label for=\"globalReps\" class=\"block text-sm font-medium text-gray-700 mb-1\">Reps<\/label>\n                        <input type=\"number\" id=\"globalReps\" value=\"10\" min=\"0\" class=\"w-full p-2 border border-gray-300 rounded-md text-sm\">\n                    <\/div>\n                    <div>\n                        <label for=\"globalHoldTime\" class=\"block text-sm font-medium text-gray-700 mb-1\">Hold Time (seconds)<\/label>\n                        <input type=\"number\" id=\"globalHoldTime\" value=\"0\" min=\"0\" class=\"w-full p-2 border border-gray-300 rounded-md text-sm\">\n                    <\/div>\n                    <div>\n                        <label for=\"globalDuration\" class=\"block text-sm font-medium text-gray-700 mb-1\">Duration (minutes)<\/label>\n                        <input type=\"number\" id=\"globalDuration\" value=\"0\" min=\"0\" class=\"w-full p-2 border border-gray-300 rounded-md text-sm\">\n                    <\/div>\n                    <div>\n                        <label for=\"globalFrequency\" class=\"block text-sm font-medium text-gray-700 mb-1\">Frequency<\/label>\n                        <select id=\"globalFrequency\" class=\"w-full p-2 border border-gray-300 rounded-md text-sm\">\n                            <option value=\"Daily\">Daily<\/option>\n                            <option value=\"Once a day\">Once a day<\/option>\n                            <option value=\"Twice a day\">Twice a day<\/option>\n                            <option value=\"3 times a week\">3 times a week<\/option>\n                            <option value=\"As tolerated\">As tolerated<\/option>\n                        <\/select>\n                    <\/div>\n                    <div>\n                        <label for=\"globalRestBetweenSets\" class=\"block text-sm font-medium text-gray-700 mb-1\">Rest (seconds)<\/label>\n                        <input type=\"number\" id=\"globalRestBetweenSets\" value=\"30\" min=\"0\" class=\"w-full p-2 border border-gray-300 rounded-md text-sm\">\n                    <\/div>\n                <\/div>\n                <button id=\"applyGlobalDosimetryBtn\" class=\"bg-blue-500 hover:bg-blue-600 text-white font-bold py-2 px-4 rounded-md w-full transition duration-150 ease-in-out\">\n                    Apply to All Exercises\n                <\/button>\n            <\/div>\n\n            <div id=\"prescriptionList\" class=\"space-y-6\">\n                <!-- Selected exercises with dosimetry controls will be loaded here -->\n                <p id=\"noExercisesMessage\" class=\"text-gray-500 text-center text-lg\">No exercises or protocols added yet. Select items from the library above.<\/p>\n            <\/div>\n            <div class=\"mt-8 text-center\">\n                <div class=\"flex flex-col md:flex-row justify-center items-center gap-4 mb-6 p-4 bg-gray-100 rounded-lg\">\n                    <div class=\"flex items-center\">\n                        <label for=\"printFontSize\" class=\"text-gray-700 text-sm md:text-base mr-2\">Print Font Size:<\/label>\n                        <select id=\"printFontSize\" class=\"p-2 border border-gray-300 rounded-md text-sm focus:ring-blue-500 focus:border-blue-500\">\n                            <option value=\"small\">Small<\/option>\n                            <option value=\"medium\" selected>Medium<\/option>\n                            <option value=\"large\">Large<\/option>\n                        <\/select>\n                    <\/div>\n                <\/div>\n                <button id=\"generatePrescriptionBtn\" class=\"bg-blue-600 hover:bg-blue-700 text-white font-bold py-4 px-8 rounded-full shadow-lg transition duration-300 ease-in-out transform hover:scale-105 focus:outline-none focus:ring-4 focus:ring-blue-300\">\n                    Generate Printable Prescription (PDF)\n                <\/button>\n                <button id=\"exportWordBtn\" class=\"bg-green-600 hover:bg-green-700 text-white font-bold py-4 px-8 rounded-full shadow-lg transition duration-300 ease-in-out transform hover:scale-105 focus:outline-none focus:ring-4 focus:ring-green-300 mt-4 md:mt-0 ml-0 md:ml-4\">\n                    Export as Editable Word File (.doc)\n                <\/button>\n            <\/div>\n        <\/section>\n    <\/div>\n\n    <!-- Printable Area (hidden by default, no longer used for direct printing) -->\n    <div id=\"printableArea\" class=\"printable-area hidden\">\n        <!-- Content for printing was dynamically generated here, but now it's written to a new window -->\n    <\/div>\n\n    <script>\n        \/\/ --- Exercise and Protocol Data ---\n        \/\/ This array holds all the predefined exercises and protocols.\n        \/\/ Each entry includes details like name, category, images, directions, or protocol phases.\n        const libraryItems = [\n            \/\/ --- Otago Specific Exercises (placed at top for visibility) ---\n            {\n                id: 'walk-on-spot',\n                type: 'exercise',\n                name: 'Walk on the Spot (Warm-up)',\n                tags: ['Warm-up', 'Mobility', 'Endurance', 'Functional', 'Fall Prevention'],\n                difficulty: 'Very Easy',\n                equipment: 'None',\n                imageStart: 'https:\/\/placehold.co\/400x250\/ADD8E6\/000?text=Otago+Walk+on+Spot+START',\n                imageEnd: 'https:\/\/placehold.co\/400x250\/87CEEB\/000?text=Otago+Walk+on+Spot+END',\n                directions: [\n                    '1. Stand tall with good posture, feet hip-width apart.',\n                    '2. Gently lift one knee towards your chest, then lower it.',\n                    '3. Alternate legs, as if marching in place, but keeping your feet close to the ground.',\n                    '4. Swing your arms gently with the movement.',\n                    '5. Maintain a steady, comfortable rhythm.'\n                ],\n                tips: 'Breathe naturally. Keep movements controlled. This is a gentle warm-up.',\n                contraindications: 'Stop if any pain or dizziness.'\n            },\n            {\n                id: 'standing-feet-together',\n                type: 'exercise',\n                name: 'Standing with Feet Together',\n                tags: ['Balance', 'Standing Balance', 'Fall Prevention'],\n                difficulty: 'Easy',\n                equipment: 'Wall or sturdy chair for support',\n                imageStart: 'https:\/\/placehold.co\/400x250\/ADD8E6\/000?text=Otago+Feet+Together+START',\n                imageEnd: 'https:\/\/placehold.co\/400x250\/87CEEB\/000?text=Otago+Feet+Together+END',\n                directions: [\n                    '1. Stand tall with your feet together, touching at the heels and toes.',\n                    '2. Hold onto a wall or sturdy chair for support if needed.',\n                    '3. Stand as still as possible, keeping your body upright.',\n                    '4. Look straight ahead at a fixed point.',\n                    '5. Hold for the prescribed time, then relax.'\n                ],\n                tips: 'Engage your core. Progress by reducing hand support or closing your eyes (with caution).',\n                contraindications: 'High fall risk, severe balance impairment.'\n            },\n            {\n                id: 'semi-tandem-stand',\n                type: 'exercise',\n                name: 'Semi-Tandem Stand',\n                tags: ['Balance', 'Standing Balance', 'Fall Prevention'],\n                difficulty: 'Moderate',\n                equipment: 'Wall or sturdy chair for support',\n                imageStart: 'https:\/\/placehold.co\/400x250\/ADD8E6\/000?text=Otago+Semi-Tandem+START',\n                imageEnd: 'https:\/\/placehold.co\/400x250\/87CEEB\/000?text=Otago+Semi-Tandem+END',\n                directions: [\n                    '1. Stand tall, holding onto a wall or sturdy chair for support if needed.',\n                    '2. Place the heel of one foot beside the instep (middle) of the other foot.',\n                    '3. Distribute your weight evenly and try to maintain your balance.',\n                    '4. Look straight ahead at a fixed point.',\n                    '5. Hold for the prescribed time, then switch legs and repeat.'\n                ],\n                tips: 'Keep your body upright. Progress by reducing hand support or closing your eyes (with caution).',\n                contraindications: 'High fall risk, severe balance impairment.'\n            },\n            {\n                id: 'walking-forwards',\n                type: 'exercise',\n                name: 'Walking Forwards',\n                tags: ['Balance', 'Functional', 'Fall Prevention'],\n                difficulty: 'Easy',\n                equipment: 'Clear, safe walking path',\n                imageStart: 'https:\/\/placehold.co\/400x250\/ADD8E6\/000?text=Otago+Walk+Forwards+START',\n                imageEnd: 'https:\/\/placehold.co\/400x250\/87CEEB\/000?text=Otago+Walk+Forwards+END',\n                directions: [\n                    '1. Walk at your normal pace for the prescribed distance or time.',\n                    '2. Focus on maintaining a steady, comfortable rhythm.',\n                    '3. Ensure your walking environment is clear of obstacles.',\n                    '4. If needed, use a walking aid or have someone nearby for support.'\n                ],\n                tips: 'Keep your head up and look forward. Swing your arms naturally.',\n                contraindications: 'Perform only in a safe environment if at risk of falls.'\n            },\n            {\n                id: 'walking-backwards',\n                type: 'exercise',\n                name: 'Walking Backwards',\n                tags: ['Balance', 'Functional', 'Fall Prevention'],\n                difficulty: 'Moderate',\n                equipment: 'Clear space, wall\/chair for support if needed',\n                imageStart: 'https:\/\/placehold.co\/400x250\/ADD8E6\/000?text=Otago+Walk+Backwards+START',\n                imageEnd: 'https:\/\/placehold.co\/400x250\/87CEEB\/000?text=Otago+Walk+Backwards+END',\n                directions: [\n                    '1. Stand in a clear, safe area, with a wall or sturdy furniture nearby for support if needed.',\n                    '2. Look over your shoulder or use peripheral vision to ensure your path is clear.',\n                    '3. Slowly take small, controlled steps backward, placing your toes down first, then your heel.',\n                    '4. Keep your body upright and avoid leaning too far forward or backward.',\n                    '5. Maintain a steady, deliberate pace.'\n                ],\n                tips: 'Start with short distances and increase as you feel more confident. Use hand support initially.',\n                contraindications: 'High fall risk, severe balance impairment.'\n            },\n            {\n                id: 'walking-sideways',\n                type: 'exercise',\n                name: 'Walking Sideways',\n                tags: ['Balance', 'Functional', 'Fall Prevention'],\n                difficulty: 'Moderate',\n                equipment: 'Clear space, wall\/chair for support if needed',\n                imageStart: 'https:\/\/placehold.co\/400x250\/ADD8E6\/000?text=Otago+Walk+Sideways+START',\n                imageEnd: 'https:\/\/placehold.co\/400x250\/87CEEB\/000?text=Otago+Walk+Sideways+END',\n                directions: [\n                    '1. Stand tall with your feet together, facing forward.',\n                    '2. Step one foot out to the side, then bring the other foot to meet it.',\n                    '3. Continue stepping sideways, keeping your body facing forward and avoiding crossing your feet.',\n                    '4. Maintain a steady rhythm and keep your movements controlled.',\n                    '5. Repeat in the other direction.'\n                ],\n                tips: 'Keep your steps small and controlled, especially when starting. Use hand support if needed.',\n                contraindications: 'High fall risk, severe balance impairment.'\n            },\n            {\n                id: 'walking-heel-to-toe',\n                type: 'exercise',\n                name: 'Walking Heel-to-Toe (Tandem Walking)',\n                tags: ['Balance', 'Functional', 'Fall Prevention'],\n                difficulty: 'Challenging',\n                equipment: 'Clear space, wall\/chair for support if needed',\n                imageStart: 'https:\/\/placehold.co\/400x250\/ADD8E6\/000?text=Otago+Heel-to-Toe+Walk+START',\n                imageEnd: 'https:\/\/placehold.co\/400x250\/87CEEB\/000?text=Otago+Heel-to-Toe+Walk+END',\n                directions: [\n                    '1. Stand tall, holding onto a wall or sturdy chair for balance if needed.',\n                    '2. Place the heel of one foot directly in front of the toes of the other foot, so they are touching or almost touching.',\n                    '3. Keep your gaze fixed on a point straight ahead.',\n                    '4. Slowly take a step forward, placing the heel of the leading foot directly in front of the toes of the trailing foot.',\n                    '5. Maintain your balance as you walk in a straight line.'\n                ],\n                tips: 'Start with very small steps. Focus on a fixed point. Progress by reducing hand support.',\n                contraindications: 'High fall risk, severe balance impairment.'\n            },\n            {\n                id: 'walking-with-head-turns',\n                type: 'exercise',\n                name: 'Walking with Head Turns',\n                tags: ['Balance', 'Functional', 'Fall Prevention'],\n                difficulty: 'Challenging',\n                equipment: 'Clear, safe walking path',\n                imageStart: 'https:\/\/placehold.co\/400x250\/ADD8E6\/000?text=Otago+Walk+Head+Turn+START',\n                imageEnd: 'https:\/\/placehold.co\/400x250\/87CEEB\/000?text=Otago+Walk+Head+Turn+END',\n                directions: [\n                    '1. Walk at your normal comfortable pace.',\n                    '2. As you walk, slowly turn your head from side to side, looking over each shoulder.',\n                    '3. Keep your walking path clear and safe.',\n                    '4. Do not rush the head turns; maintain your balance throughout the movement.'\n                ],\n                tips: 'Start with small head turns and gradually increase the range of motion. If you feel dizzy, stop.',\n                contraindications: 'Severe dizziness, acute neck pain, high fall risk without supervision.'\n            },\n            {\n                id: 'walking-with-obstacles',\n                type: 'exercise',\n                name: 'Walking with Obstacles',\n                tags: ['Balance', 'Functional', 'Fall Prevention'],\n                difficulty: 'Challenging',\n                equipment: 'Small, safe obstacles (e.g., towels, small cones)',\n                imageStart: 'https:\/\/placehold.co\/400x250\/ADD8E6\/000?text=Otago+Walk+Obstacle+START',\n                imageEnd: 'https:\/\/placehold.co\/400x250\/87CEEB\/000?text=Otago+Walk+Obstacle+END',\n                directions: [\n                    '1. Place small, safe obstacles (e.g., rolled towels, small cones) on the floor a comfortable distance apart.',\n                    '2. Walk along the path, carefully stepping over each obstacle.',\n                    '3. Ensure you lift your feet high enough to clear the obstacles safely.',\n                    '4. Maintain your balance and posture throughout the walk.'\n                ],\n                tips: 'Start with very low obstacles and increase height\/number as you gain confidence. Ensure the obstacles are soft and won\\'t cause injury if tripped over.',\n                contraindications: 'High fall risk, severe balance impairment without close supervision.'\n            },\n            {\n                id: 'walking-with-gait-changes',\n                type: 'exercise',\n                name: 'Walking with Gait Changes',\n                tags: ['Balance', 'Functional', 'Fall Prevention'],\n                difficulty: 'Challenging',\n                equipment: 'Clear, safe walking path',\n                imageStart: 'https:\/\/placehold.co\/400x250\/ADD8E6\/000?text=Otago+Walk+Gait+Change+START',\n                imageEnd: 'https:\/\/placehold.co\/400x250\/87CEEB\/000?text=Otago+Walk+Gait+Change+END',\n                directions: [\n                    '1. Walk at your normal pace.',\n                    '2. Periodically, change your walking pattern: e.g., walk faster for 10 steps, then slower for 10 steps; take longer strides, then shorter strides; walk on your toes for a few steps, then on your heels.',\n                    '3. Maintain control and balance with each change.',\n                    '4. Ensure your environment is clear and safe.'\n                ],\n                tips: 'Start with simple changes and gradually introduce more complex ones. Always prioritize safety over speed or complexity.',\n                contraindications: 'High fall risk, severe balance impairment without close supervision.'\n            },\n            {\n                id: 'standing-hip-extension',\n                type: 'exercise',\n                name: 'Standing Hip Extension',\n                tags: ['Strength', 'Lower Limb', 'Glutes', 'Fall Prevention'],\n                difficulty: 'Moderate',\n                equipment: 'Wall or Chair for support',\n                imageStart: 'https:\/\/placehold.co\/400x250\/ADD8E6\/000?text=Otago+Hip+Extension+START',\n                imageEnd: 'https:\/\/placehold.co\/400x250\/87CEEB\/000?text=Otago+Hip+Extension+END',\n                directions: [\n                    '1. Stand tall, holding onto a wall or sturdy chair for balance.',\n                    '2. Keeping your leg straight, slowly move one leg backward behind you.',\n                    '3. Avoid arching your lower back or leaning forward excessively.',\n                    '4. Only lift as high as comfortable, feeling a squeeze in your gluteal muscles.',\n                    '5. Slowly lower your leg back to the starting position with control.',\n                    '6. Repeat with the same leg, then switch to the other leg.'\n                ],\n                tips: 'Keep your core engaged to prevent back arching. Focus on the gluteal muscles.',\n                contraindications: 'Avoid if acute lower back or hip pain.'\n            },\n            {\n                id: 'step-ups',\n                type: 'exercise',\n                name: 'Step-Ups',\n                tags: ['Strength', 'Functional', 'Lower Limb', 'Fall Prevention'],\n                difficulty: 'Moderate',\n                equipment: 'Sturdy step or low stair',\n                imageStart: 'https:\/\/placehold.co\/400x250\/ADD8E6\/000?text=Otago+Step-Up+START',\n                imageEnd: 'https:\/\/placehold.co\/400x250\/87CEEB\/000?text=Otago+Step-Up+END',\n                directions: [\n                    '1. Stand in front of a sturdy step or a low stair, holding onto a wall or railing for balance if needed.',\n                    '2. Step up onto the step with one foot, pushing through your heel to lift your body up.',\n                    '3. Bring your other foot up to meet the first, standing tall on the step.',\n                    '4. Step back down with the first foot, then the second, returning to the starting position.',\n                    '5. Alternate leading legs or complete a set on one side before switching.'\n                ],\n                tips: 'Ensure the step is stable. Control the movement both up and down. Start with a low step.',\n                contraindications: 'Avoid if knee pain, hip pain, or significant balance impairment without adequate support.'\n            },\n            {\n                id: 'hamstring-stretch-seated',\n                type: 'exercise',\n                name: 'Hamstring Stretch (Seated)',\n                tags: ['Flexibility', 'Lower Limb', 'Cool-down', 'Fall Prevention'],\n                difficulty: 'Easy',\n                equipment: 'Chair',\n                imageStart: 'https:\/\/placehold.co\/400x250\/ADD8E6\/000?text=Otago+Hamstring+Stretch+START',\n                imageEnd: 'https:\/\/placehold.co\/400x250\/87CEEB\/000?text=Otago+Hamstring+Stretch+END',\n                directions: [\n                    '1. Sit on the edge of a sturdy chair with one leg extended straight out in front of you, heel on the floor.',\n                    '2. Keep your back straight and gently lean forward from your hips, reaching towards your toes.',\n                    '3. You should feel a stretch along the back of your extended thigh.',\n                    '4. Hold the stretch for 20-30 seconds, breathing deeply.',\n                    '5. Return to the start and repeat with the other leg.'\n                ],\n                tips: 'Avoid rounding your back. The stretch should be gentle, not painful.',\n                contraindications: 'Avoid if acute lower back or knee pain.'\n            },\n            {\n                id: 'quad-stretch-standing',\n                type: 'exercise',\n                name: 'Quad Stretch (Standing)',\n                tags: ['Flexibility', 'Lower Limb', 'Cool-down', 'Fall Prevention'],\n                difficulty: 'Moderate',\n                equipment: 'Wall or Chair for support',\n                imageStart: 'https:\/\/placehold.co\/400x250\/ADD8E6\/000?text=Otago+Quad+Stretch+START',\n                imageEnd: 'https:\/\/placehold.co\/400x250\/87CEEB\/000?text=Otago+Quad+Stretch+END',\n                directions: [\n                    '1. Stand tall, holding onto a wall or sturdy chair for balance.',\n                    '2. Bend one knee and grasp your ankle or foot with the hand on the same side.',\n                    '3. Gently pull your heel towards your bottom, keeping your knees close together and your back straight.',\n                    '4. You should feel a stretch along the front of your thigh.',\n                    '5. Hold for 20-30 seconds, breathing deeply.',\n                    '6. Return to the start and repeat with the other leg.'\n                ],\n                tips: 'Keep your core engaged to avoid arching your back. Do not force the stretch if it causes pain.',\n                contraindications: 'Avoid if acute knee pain or instability.'\n            },\n            \/\/ --- General Exercises (retained from previous version) ---\n            {\n                id: 'sit-to-stand',\n                type: 'exercise',\n                name: 'Sit-to-Stand',\n                tags: ['Strength', 'Functional', 'Chair-based', 'Frailty', 'Fall Prevention'], \/\/ Added Fall Prevention\n                difficulty: 'Easy',\n                equipment: 'Sturdy Chair',\n                imageStart: 'https:\/\/upload.wikimedia.org\/wikipedia\/commons\/thumb\/c\/c2\/Sit-to-stand_exercise_start.png\/640px-Sit-to-stand_exercise_start.png',\n                imageEnd: 'https:\/\/upload.wikimedia.org\/wikipedia\/commons\/thumb\/4\/4b\/Sit-to-stand_exercise_end.png\/640px-Sit-to-stand_exercise_end.png',\n                directions: [\n                    '1. Start seated in a sturdy chair with your feet flat on the floor, hip-width apart.',\n                    '2. Lean slightly forward over your knees, keeping your back straight.',\n                    '3. Push through your feet and stand up slowly and smoothly, without using your hands if possible.',\n                    '4. Stand tall, fully extending your hips and knees.',\n                    '5. Slowly and carefully sit back down, controlling the movement, until you are fully seated.'\n                ],\n                tips: 'Keep your chest up and avoid pushing off with your hands. Control the movement both up and down.',\n                contraindications: 'Avoid if severe knee or hip pain, or if very unstable.'\n            },\n            {\n                id: 'heel-raises',\n                type: 'exercise',\n                name: 'Heel Raises (Standing)',\n                tags: ['Strength', 'Balance', 'Standing Balance', 'Fall Prevention'], \/\/ Added Fall Prevention\n                difficulty: 'Easy',\n                equipment: 'Wall or Chair for support',\n                imageStart: 'https:\/\/upload.wikimedia.org\/wikipedia\/commons\/thumb\/c\/c2\/Calf_raise_start.png\/640px-Calf_raise_start.png',\n                imageEnd: 'https:\/\/upload.wikimedia.org\/wikipedia\/commons\/thumb\/a\/a2\/Calf_raise_end.png\/640px-Calf_raise_end.png',\n                directions: [\n                    '1. Stand tall, holding onto a wall or sturdy chair for balance.',\n                    '2. Keep your feet hip-width apart.',\n                    '3. Slowly lift both heels off the floor, rising onto the balls of your feet as high as comfortable.',\n                    '4. Hold briefly at the top.',\n                    '5. Slowly lower your heels back down to the floor in a controlled manner.'\n                ],\n                tips: 'Keep your body straight and avoid leaning forward. Focus on lifting straight up.',\n                contraindications: 'Avoid if severe ankle or foot pain.'\n            },\n            {\n                id: 'wall-push-ups',\n                type: 'exercise',\n                name: 'Wall Push-ups',\n                tags: ['Strength', 'Upper Limb'],\n                difficulty: 'Easy',\n                equipment: 'Wall',\n                imageStart: 'https:\/\/upload.wikimedia.org\/wikipedia\/commons\/thumb\/1\/14\/Wall_pushup_start.png\/640px-Wall_pushup_start.png',\n                imageEnd: 'https:\/\/upload.wikimedia.org\/wikipedia\/commons\/thumb\/e\/e0\/Wall_pushup_end.png\/640px-Wall_pushup_end.png',\n                directions: [\n                    '1. Stand facing a wall, about an arm\\'s length away.',\n                    '2. Place your hands flat on the wall, slightly wider than shoulder-width apart, at chest height.',\n                    '3. Slowly bend your elbows, leaning your body towards the wall, keeping your body straight from head to heels.',\n                    '4. Go as far as comfortable, feeling a stretch in your chest.',\n                    '5. Push back to the starting position, straightening your arms.'\n                ],\n                tips: 'Keep your core engaged and avoid arching your back. The further your feet are from the wall, the harder it is.',\n                contraindications: 'Avoid if shoulder pain or wrist pain.'\n            },\n            {\n                id: 'seated-marching',\n                type: 'exercise',\n                name: 'Seated Marching',\n                tags: ['Endurance', 'Mobility', 'Chair-based', 'Frailty'],\n                difficulty: 'Very Easy',\n                equipment: 'Sturdy Chair',\n                imageStart: 'https:\/\/placehold.co\/400x250\/ADD8E6\/000?text=Seated+March+START+-+Person+seated+chair',\n                imageEnd: 'https:\/\/placehold.co\/400x250\/87CEEB\/000?text=Seated+March+END+-+Person+lifting+knee',\n                directions: [\n                    '1. Sit tall in a sturdy chair with your feet flat on the floor.',\n                    '2. Gently lift one knee towards your chest, as if marching in place, keeping your back straight.',\n                    '3. Place your foot back down slowly and in a controlled manner.',\n                    '4. Repeat with the other leg, alternating legs.',\n                    '5. Maintain a steady rhythm and breathe normally.'\n                ],\n                tips: 'Only lift your knee as high as feels comfortable. Keep your movements controlled, not fast.',\n                contraindications: 'None specific, but stop if any pain or dizziness.'\n            },\n            {\n                id: 'chair-knee-extension',\n                type: 'exercise',\n                name: 'Chair Knee Extension',\n                tags: ['Strength', 'Lower Limb', 'Chair-based', 'Fall Prevention'], \/\/ Added Fall Prevention\n                difficulty: 'Easy',\n                equipment: 'Sturdy Chair',\n                imageStart: 'https:\/\/upload.wikimedia.org\/wikipedia\/commons\/thumb\/f\/f6\/Seated_knee_extension_start.png\/640px-Seated_knee_extension_start.png',\n                imageEnd: 'https:\/\/upload.wikimedia.org\/wikipedia\/commons\/thumb\/e\/e6\/Seated_knee_extension_end.png\/640px-Seated_knee_extension_end.png',\n                directions: [\n                    '1. Sit tall in a sturdy chair with your feet flat on the floor.',\n                    '2. Slowly straighten one leg out in front of you, lifting your foot off the floor until your knee is straight.',\n                    '3. Hold this position for 1-2 seconds, feeling the muscle on the front of your thigh work.',\n                    '4. Slowly lower your foot back to the floor in a controlled manner.',\n                    '5. Repeat with the same leg, then switch to the other leg.'\n                ],\n                tips: 'Keep your back straight and avoid leaning back. Focus on the muscle contraction.',\n                contraindications: 'Avoid if severe knee pain or recent knee surgery.'\n            },\n            {\n                id: 'standing-balance-support',\n                type: 'exercise',\n                name: 'Standing Balance (Support)',\n                tags: ['Balance', 'Standing Balance', 'Frailty', 'Fall Prevention'], \/\/ Added Fall Prevention\n                difficulty: 'Easy',\n                equipment: 'Sturdy surface (e.g., kitchen counter)',\n                imageStart: 'https:\/\/upload.wikimedia.org\/wikipedia\/commons\/thumb\/f\/f7\/Standing_balance_with_support_start.png\/640px-Standing_balance_with_support_start.png',\n                imageEnd: 'https:\/\/upload.wikimedia.org\/wikipedia\/commons\/thumb\/1\/18\/Standing_balance_with_support_end.png\/640px-Standing_balance_with_support_end.png',\n                directions: [\n                    '1. Stand tall with your feet hip-width apart, holding onto a sturdy surface like a kitchen counter for support.',\n                    '2. Distribute your weight evenly between both feet.',\n                    '3. Try to stand as still as possible, focusing on a point in front of you.',\n                    '4. Hold this position, maintaining good posture.',\n                    '5. If comfortable, try to lightly touch the support with only your fingertips, or let go briefly.'\n                ],\n                tips: 'Engage your core muscles. Do not hold your breath. Progress by reducing hand support.',\n                contraindications: 'Perform only with adequate support if at risk of falls.'\n            },\n            {\n                id: 'ankle-circles',\n                type: 'exercise',\n                name: 'Ankle Circles',\n                tags: ['Flexibility', 'Mobility', 'Bed-based', 'Chair-based'],\n                difficulty: 'Very Easy',\n                equipment: 'None (can be seated or lying)',\n                imageStart: 'https:\/\/placehold.co\/400x250\/ADD8E6\/000?text=Ankle+Circle+START+-+Foot+neutral',\n                imageEnd: 'https:\/\/placehold.co\/400x250\/87CEEB\/000?text=Ankle+Circle+END+-+Foot+rotating',\n                directions: [\n                    '1. Sit comfortably in a chair or lie down.',\n                    '2. Lift one foot slightly off the floor, or keep your heel on the floor.',\n                    '3. Slowly rotate your ankle in a circular motion, making the biggest circle you can with your foot.',\n                    '4. Perform circles in one direction, then reverse the direction.',\n                    '5. Repeat with the other ankle.'\n                ],\n                tips: 'Control the movement; avoid jerky motions. Only move within a pain-free range.',\n                contraindications: 'Avoid if acute ankle injury or severe pain.'\n            },\n            {\n                id: 'bed-ankle-pumps',\n                type: 'exercise',\n                name: 'Ankle Pumps (Bed-based)',\n                tags: ['Mobility', 'Circulation', 'Bed-based'],\n                difficulty: 'Very Easy',\n                equipment: 'Bed',\n                imageStart: 'https:\/\/placehold.co\/400x250\/ADD8E6\/000?text=Ankle+Pump+Bed+START+-+Toes+up',\n                imageEnd: 'https:\/\/placehold.co\/400x250\/87CEEB\/000?text=Ankle+Pump+Bed+END+-+Toes+down',\n                directions: [\n                    '1. Lie on your back in bed with your legs straight.',\n                    '2. Point your toes away from you as far as comfortable.',\n                    '3. Then pull your toes up towards your head as far as comfortable.',\n                    '4. Repeat this pumping motion slowly and rhythmically.',\n                    '5. Perform with both feet at the same time or alternate.'\n                ],\n                tips: 'This helps with circulation and prevents stiffness. Do not push into pain.',\n                contraindications: 'None specific, but stop if any pain.'\n            },\n            {\n                id: 'bed-knee-bends',\n                type: 'exercise',\n                name: 'Knee Bends (Bed-based)',\n                tags: ['Mobility', 'Lower Limb', 'Bed-based'],\n                difficulty: 'Easy',\n                equipment: 'Bed',\n                imageStart: 'https:\/\/placehold.co\/400x250\/ADD8E6\/000?text=Bed+Knee+Bend+START+-+Leg+straight',\n                imageEnd: 'https:\/\/placehold.co\/400x250\/87CEEB\/000?text=Bed+Knee+Bend+END+-+Knee+bent+heel+gliding',\n                directions: [\n                    '1. Lie on your back in bed with your legs straight.',\n                    '2. Slowly slide one heel up towards your bottom, bending your knee.',\n                    '3. Keep your heel in contact with the bed.',\n                    '4. Slide your leg back down to the starting position.',\n                    '5. Repeat with the other leg.'\n                ],\n                tips: 'Move slowly and smoothly. Only bend as far as comfortable without pain.',\n                contraindications: 'Avoid if recent knee surgery or severe hip\/knee pain.'\n            },\n            {\n                id: 'finger-taps',\n                type: 'exercise',\n                name: 'Finger Taps',\n                tags: ['Upper Limb Coordination', 'Fine Motor', 'Dexterity'],\n                difficulty: 'Easy',\n                equipment: 'None',\n                imageStart: 'https:\/\/placehold.co\/400x250\/ADD8E6\/000?text=Finger+Tap+START+-+Hand+open',\n                imageEnd: 'https:\/\/placehold.co\/400x250\/87CEEB\/000?text=Finger+Tap+END+-+Finger+to+thumb',\n                directions: [\n                    '1. Rest your hand on a table or your lap, palm down.',\n                    '2. One by one, tap each finger to your thumb, starting with your index finger.',\n                    '3. Go through all fingers (index, middle, ring, pinky) and then reverse the order.',\n                    '4. Try to make each tap clear and distinct.',\n                    '5. Repeat with the other hand.'\n                ],\n                tips: 'Focus on accuracy and control, not speed. Keep your wrist relaxed.',\n                contraindications: 'Avoid if acute hand\/finger injury or severe pain.'\n            },\n            {\n                id: 'alternating-forearm-pronation-supination',\n                type: 'exercise',\n                name: 'Alternating Forearm Pronation\/Supination',\n                tags: ['Upper Limb Coordination', 'Mobility'],\n                difficulty: 'Moderate',\n                equipment: 'None (can use a light stick\/pen)',\n                imageStart: 'https:\/\/placehold.co\/400x250\/ADD8E6\/000?text=Forearm+Rotation+START+-+Palm+up',\n                imageEnd: 'https:\/\/placehold.co\/400x250\/87CEEB\/000?text=Forearm+Rotation+END+-+Palm+down',\n                directions: [\n                    '1. Sit comfortably with your elbow bent to 90 degrees, forearm resting on your lap or a table, palm facing up.',\n                    '2. Slowly rotate your forearm so your palm faces down (pronation).',\n                    '3. Then slowly rotate your forearm back so your palm faces up (supination).',\n                    '4. Keep your elbow tucked into your side and avoid moving your shoulder.',\n                    '5. Repeat with the other arm.'\n                ],\n                tips: 'If you have a light stick or pen, hold it in your hand to help visualize the rotation.',\n                contraindications: 'Avoid if acute elbow\/wrist pain or instability.'\n            },\n            {\n                id: 'tandem-stand-support',\n                type: 'exercise',\n                name: 'Tandem Stand (Support)',\n                tags: ['Balance', 'Standing Balance', 'Fall Prevention'], \/\/ Added Fall Prevention\n                difficulty: 'Moderate',\n                equipment: 'Sturdy surface (e.g., kitchen counter)',\n                imageStart: 'https:\/\/upload.wikimedia.org\/wikipedia\/commons\/thumb\/b\/b3\/Tandem_stand_start.png\/640px-Tandem_stand_start.png',\n                imageEnd: 'https:\/\/upload.wikimedia.org\/wikipedia\/commons\/thumb\/2\/2f\/Tandem_stand_end.png\/640px-Tandem_stand_end.png',\n                directions: [\n                    '1. Stand tall, holding onto a sturdy surface for balance.',\n                    '2. Place one foot directly in front of the other, heel touching the toes of the back foot (like standing on a tightrope).',\n                    '3. Distribute your weight evenly and try to maintain your balance.',\n                    '4. Hold this position for as long as comfortable, up to 30 seconds.',\n                    '5. Switch which foot is in front and repeat.'\n                ],\n                tips: 'Look straight ahead at a fixed point. Progress by reducing hand support or closing your eyes (with caution).',\n                contraindications: 'High fall risk, severe balance impairment, acute lower limb injury.'\n            },\n            {\n                id: 'single-leg-stand-support',\n                type: 'exercise',\n                name: 'Single Leg Stand (Support)',\n                tags: ['Balance', 'Standing Balance', 'Fall Prevention'], \/\/ Added Fall Prevention\n                difficulty: 'Challenging',\n                equipment: 'Sturdy surface (e.g., wall, counter)',\n                imageStart: 'https:\/\/upload.wikimedia.org\/wikipedia\/commons\/thumb\/e\/e0\/Single_leg_balance_start.png\/640px-Single_leg_balance_start.png',\n                imageEnd: 'https:\/\/upload.wikimedia.org\/wikipedia\/commons\/thumb\/2\/22\/Single_leg_balance_end.png\/640px-Single_leg_balance_end.png',\n                directions: [\n                    '1. Stand tall, holding onto a sturdy surface for balance.',\n                    '2. Slowly lift one foot off the floor, bending your knee slightly.',\n                    '3. Try to maintain your balance on one leg, keeping your body upright.',\n                    '4. Hold for a few seconds, then slowly lower your foot.',\n                    '5. Repeat with the other leg.'\n                ],\n                tips: 'Keep your core engaged. Do not hold your breath. Progress by reducing hand support or increasing hold time.',\n                contraindications: 'High fall risk, severe balance impairment, acute lower limb injury.'\n            },\n            {\n                id: 'shoulder-blade-squeezes',\n                type: 'exercise',\n                name: 'Shoulder Blade Squeezes',\n                tags: ['Strength', 'Posture', 'Upper Limb'],\n                difficulty: 'Easy',\n                equipment: 'None',\n                imageStart: 'https:\/\/placehold.co\/400x250\/ADD8E6\/000?text=Shoulder+Squeeze+START+-+Shoulders+relaxed',\n                imageEnd: 'https:\/\/placehold.co\/400x250\/87CEEB\/000?text=Shoulder+Squeeze+END+-+Shoulder+blades+squeezed',\n                directions: [\n                    '1. Sit or stand tall with your arms relaxed at your sides.',\n                    '2. Gently squeeze your shoulder blades together, as if trying to hold a pencil between them.',\n                    '3. Keep your shoulders down and avoid shrugging your neck.',\n                    '4. Hold for 5 seconds, then slowly release.',\n                    '5. Repeat.'\n                ],\n                tips: 'Focus on squeezing the shoulder blades, not lifting the shoulders. Good for posture and upper back strength.',\n                contraindications: 'Avoid if acute shoulder or neck pain.'\n            },\n            {\n                id: 'bridging',\n                type: 'exercise',\n                name: 'Bridging',\n                tags: ['Strength', 'Core', 'Glutes', 'Lower Back'],\n                difficulty: 'Moderate',\n                equipment: 'Mat or floor',\n                imageStart: 'https:\/\/placehold.co\/400x250\/ADD8E6\/000?text=Bridging+START+-+Lying+knees+bent',\n                imageEnd: 'https:\/\/placehold.co\/400x250\/87CEEB\/000?text=Bridging+END+-+Hips+lifted',\n                directions: [\n                    '1. Lie on your back with your knees bent, feet flat on the floor, hip-width apart, and arms by your sides.',\n                    '2. Engage your core and gluteal muscles, then slowly lift your hips off the floor until your body forms a straight line from your shoulders to your knees.',\n                    '3. Hold briefly at the top, squeezing your glutes.',\n                    '4. Slowly lower your hips back down to the starting position with control.',\n                    '5. Repeat.'\n                ],\n                tips: 'Avoid arching your lower back. Focus on lifting with your glutes. Keep your neck relaxed.',\n                contraindications: 'Avoid if acute lower back pain or hip pain.'\n            },\n            {\n                id: 'calf-stretch',\n                type: 'exercise',\n                name: 'Calf Stretch (Wall)',\n                tags: ['Flexibility', 'Lower Limb', 'Cool-down'], \/\/ Added Cool-down\n                difficulty: 'Easy',\n                equipment: 'Wall',\n                imageStart: 'https:\/\/placehold.co\/400x250\/ADD8E6\/000?text=Calf+Stretch+START+-+Standing+facing+wall',\n                imageEnd: 'https:\/\/placehold.co\/400x250\/87CEEB\/000?text=Calf+Stretch+END+-+Leaning+into+stretch',\n                directions: [\n                    '1. Stand facing a wall, about an arm\\'s length away. Place your hands on the wall for support.',\n                    '2. Step one foot back, keeping your heel on the ground and your leg straight.',\n                    '3. Lean forward, bending your front knee, until you feel a stretch in the calf of your back leg.',\n                    '4. Hold the stretch for 20-30 seconds. Keep your back heel on the ground.',\n                    '5. Return to the start and repeat with the other leg.'\n                ],\n                tips: 'To target the deeper calf muscle, bend the back knee slightly while keeping the heel down. Do not bounce.',\n                contraindications: 'Avoid if acute ankle or Achilles tendon pain.'\n            },\n            {\n                id: 'standing-hip-abduction',\n                type: 'exercise',\n                name: 'Standing Hip Abduction',\n                tags: ['Strength', 'Lower Limb', 'Balance', 'Glutes', 'Fall Prevention'], \/\/ Added Fall Prevention\n                difficulty: 'Moderate',\n                equipment: 'Wall or Chair for support',\n                imageStart: 'https:\/\/placehold.co\/400x250\/ADD8E6\/000?text=Hip+Abduction+START+-+Standing+straight',\n                imageEnd: 'https:\/\/placehold.co\/400x250\/87CEEB\/000?text=Hip+Abduction+END+-+Leg+out+to+side',\n                directions: [\n                    '1. Stand tall, holding onto a wall or sturdy chair for balance.',\n                    '2. Slowly lift one leg directly out to the side, keeping your knee straight and toes pointing forward.',\n                    '3. Only lift as high as comfortable, avoiding tilting your body.',\n                    '4. Hold for 1-2 seconds, feeling the muscle on the side of your hip work.',\n                    '5. Slowly lower your leg back to the starting position with control.',\n                    '6. Repeat with the same leg, then switch to the other leg.'\n                ],\n                tips: 'Keep your body upright and avoid leaning away from the leg you are lifting. Control the movement both up and down.',\n                contraindications: 'Avoid if acute hip pain or instability.'\n            },\n            {\n                id: 'toe-raises',\n                type: 'exercise',\n                name: 'Toe Raises (Standing)',\n                tags: ['Strength', 'Balance', 'Lower Limb', 'Fall Prevention'], \/\/ Added Fall Prevention\n                difficulty: 'Easy',\n                equipment: 'None',\n                imageStart: 'https:\/\/placehold.co\/400x250\/ADD8E6\/000?text=Toe+Raise+START+-+Feet+flat',\n                imageEnd: 'https:\/\/placehold.co\/400x250\/87CEEB\/000?text=Toe+Raise+END+-+Toes+lifted',\n                directions: [\n                    '1. Stand tall with your feet flat on the floor, hip-width apart.',\n                    '2. Slowly lift your toes and the front of your feet off the floor, keeping your heels on the ground.',\n                    '3. Try to lift as high as comfortable, feeling the muscles on the front of your shins work.',\n                    '4. Hold briefly at the top.',\n                    '5. Slowly lower your toes back down to the floor in a controlled manner.'\n                ],\n                tips: 'This exercise helps strengthen the muscles that lift your foot, important for preventing trips. Maintain good posture.',\n                contraindications: 'Avoid if acute ankle or shin pain.'\n            },\n            \/\/ --- Protocols (Otago Protocol placed at top for visibility) ---\n            {\n                id: 'otago-exercise-protocol',\n                type: 'protocol',\n                name: 'Otago Exercise Protocol (Fall Prevention)',\n                tags: ['Balance', 'Strength', 'Functional', 'Frailty', 'Fall Prevention', 'Evidence-Based'],\n                description: 'An evidence-based, individualized home-based exercise program designed to prevent falls in older adults. It includes a set of leg muscle strengthening and balance retraining exercises, and a walking plan. This protocol strictly follows the structure and exercises from the Livestronger Otago Exercise Programme Manual.',\n                evidenceBase: 'The Otago Exercise Programme is highly effective in reducing falls in older adults living in the community. (Campbell et al., 1997; Thomas et al., 2010).',\n                phases: [\n                    {\n                        name: 'Warm-up',\n                        notes: 'Prepare your body for exercise with gentle movements for 5 minutes.',\n                        exerciseIds: ['walk-on-spot']\n                    },\n                    {\n                        name: 'Strengthening Exercises',\n                        notes: 'Perform these exercises 3 times per week, with at least one rest day between sessions. Aim for 3 sets of 10-15 repetitions for each exercise.',\n                        exerciseIds: [\n                            'chair-knee-extension',\n                            'sit-to-stand',\n                            'standing-hip-abduction',\n                            'standing-hip-extension',\n                            'heel-raises',\n                            'toe-raises',\n                            'step-ups'\n                        ]\n                    },\n                    {\n                        name: 'Balance Exercises',\n                        notes: 'Perform these exercises 3 times per week, with at least one rest day between sessions. Hold each balance position for 10-30 seconds, 3 repetitions.',\n                        exerciseIds: [\n                            'standing-feet-together',\n                            'semi-tandem-stand',\n                            'tandem-stand-support', \/\/ Renamed to match existing ID\n                            'single-leg-stand-support', \/\/ Renamed to match existing ID\n                            'walking-forwards',\n                            'walking-backwards',\n                            'walking-sideways',\n                            'walking-heel-to-toe',\n                            'walking-with-head-turns',\n                            'walking-with-obstacles',\n                            'walking-with-gait-changes',\n                            'sit-to-stand', \/\/ Included again as per PDF for functional balance\n                            'step-ups' \/\/ Included again as per PDF for functional balance\n                        ]\n                    },\n                    {\n                        name: 'Cool-down & Flexibility',\n                        notes: 'Perform these stretches after your strengthening and balance exercises. Hold each stretch for 20-30 seconds.',\n                        exerciseIds: [\n                            'calf-stretch',\n                            'hamstring-stretch-seated',\n                            'quad-stretch-standing'\n                        ]\n                    }\n                ]\n            },\n            \/\/ --- Other Protocols (retained from previous version) ---\n            {\n                id: 'post-thr-protocol',\n                type: 'protocol',\n                name: 'Post Total Hip Replacement (THR) Protocol',\n                tags: ['Post-Op', 'Lower Limb'],\n                description: 'A phased exercise protocol for rehabilitation after Total Hip Replacement surgery. Always follow surgeon\\'s specific precautions.',\n                evidenceBase: 'Based on common post-operative rehabilitation guidelines for THR.',\n                phases: [\n                    {\n                        name: 'Phase 1: Early Post-Op (Weeks 0-6)',\n                        notes: 'Focus on pain management, swelling reduction, early mobility, and adherence to hip precautions (e.g., no hip flexion > 90 degrees, no adduction past midline, no internal rotation for posterior approach).',\n                        exerciseIds: ['bed-ankle-pumps', 'bed-knee-bends', 'chair-knee-extension', 'seated-marching']\n                    },\n                    {\n                        name: 'Phase 2: Intermediate (Weeks 6-12)',\n                        notes: 'Progressing strength and balance, gradually reducing reliance on walking aids. Continue hip precautions as advised by surgeon.',\n                        exerciseIds: ['sit-to-stand', 'heel-raises', 'standing-balance-support']\n                    },\n                    {\n                        name: 'Phase 3: Advanced (Weeks 12+)',\n                        notes: 'Return to functional activities, advanced strengthening, and balance challenges. May include light impact activities if cleared by surgeon.',\n                        exerciseIds: ['tandem-stand-support', 'single-leg-stand-support'] \/\/ Example, would add more advanced exercises\n                    }\n                ]\n            },\n            {\n                id: 'post-tkr-protocol',\n                type: 'protocol',\n                name: 'Post Total Knee Replacement (TKR) Protocol',\n                tags: ['Post-Op', 'Lower Limb'],\n                description: 'A phased exercise protocol for rehabilitation after Total Knee Replacement surgery. Focus on regaining knee range of motion and strength.',\n                evidenceBase: 'Based on common post-operative rehabilitation guidelines for TKR.',\n                phases: [\n                    {\n                        name: 'Phase 1: Early Post-Op (Weeks 0-4)',\n                        notes: 'Focus on achieving full knee extension, improving knee flexion, pain and swelling control, and early weight-bearing as tolerated.',\n                        exerciseIds: ['bed-ankle-pumps', 'bed-knee-bends', 'chair-knee-extension', 'seated-marching']\n                    },\n                    {\n                        name: 'Phase 2: Intermediate (Weeks 4-12)',\n                        notes: 'Progressing knee range of motion and strength. Introduce functional exercises and balance training.',\n                        exerciseIds: ['sit-to-stand', 'heel-raises', 'standing-balance-support']\n                    },\n                    {\n                        name: 'Phase 3: Advanced (Weeks 12+)',\n                        notes: 'Return to higher-level activities, sport-specific training if applicable, and continued strengthening.',\n                        exerciseIds: ['tandem-stand-support', 'single-leg-stand-support'] \/\/ Example, would add more advanced exercises\n                    }\n                ]\n            },\n            {\n                id: 'ul-fracture-conservative-protocol-template',\n                type: 'protocol',\n                name: 'Upper Limb Fracture (Conservative) Protocol - Template',\n                tags: ['Fracture Rehab', 'Upper Limb'],\n                description: 'Template for conservative management of an upper limb fracture (e.g., distal radius fracture). Specific exercises and timings depend on fracture type, stability, and healing progress. Always follow orthopedic guidance.',\n                evidenceBase: 'General principles of fracture rehabilitation (e.g., early protected motion, gradual strengthening).',\n                phases: [\n                    {\n                        name: 'Phase 1: Immobilization (Weeks 0-4\/6)',\n                        notes: 'Focus on pain\/swelling control, maintaining mobility of unaffected joints, and gentle isometric exercises if permitted.',\n                        exerciseIds: ['finger-taps', 'ankle-circles'] \/\/ Example: keep fingers\/shoulder moving if wrist in cast\n                    },\n                    {\n                        name: 'Phase 2: Early Mobilization (Post-Immobilization)',\n                        notes: 'Gradual restoration of range of motion in the affected joint, gentle strengthening.',\n                        exerciseIds: ['alternating-forearm-pronation-supination', 'wall-push-ups'] \/\/ Example: gentle wrist\/elbow ROM, then light strengthening\n                    },\n                    {\n                        name: 'Phase 3: Strengthening & Functional Return',\n                        notes: 'Progressive strengthening, coordination, and return to daily activities and hobbies.',\n                        exerciseIds: ['wall-push-ups', 'finger-taps'] \/\/ Example, would add more specific strengthening\n                    }\n                ]\n            },\n            {\n                id: 'll-fracture-surgical-protocol-template',\n                type: 'protocol',\n                name: 'Lower Limb Fracture (Surgical) Protocol - Template',\n                tags: ['Fracture Rehab', 'Lower Limb'],\n                description: 'Template for surgical management of a lower limb fracture (e.g., tibia fracture). Specific exercises, weight-bearing status, and timings depend on surgical fixation, fracture type, and healing progress. Always follow orthopedic guidance.',\n                evidenceBase: 'General principles of fracture rehabilitation post-surgery.',\n                phases: [\n                    {\n                        name: 'Phase 1: Early Post-Op & Protected Weight Bearing',\n                        notes: 'Focus on pain\/swelling control, maintaining range of motion in adjacent joints, non-weight bearing or protected weight-bearing exercises.',\n                        exerciseIds: ['bed-ankle-pumps', 'bed-knee-bends', 'chair-knee-extension']\n                    },\n                    {\n                        name: 'Phase 2: Progressive Weight Bearing & Strengthening',\n                        notes: 'Gradual increase in weight-bearing, progressive strengthening of affected limb, balance training.',\n                        exerciseIds: ['seated-marching', 'sit-to-stand', 'heel-raises']\n                    },\n                    {\n                        name: 'Phase 3: Advanced (Weeks 12+)',\n                        notes: 'Higher-level strengthening, agility, balance, and return to full functional activities.',\n                        exerciseIds: ['standing-balance-support', 'tandem-stand-support', 'single-leg-stand-support']\n                    }\n                ]\n            },\n            {\n                id: 'clavicle-fracture-conservative-protocol',\n                type: 'protocol',\n                name: 'Clavicle Fracture Rehab (Conservative)',\n                tags: ['Fracture Rehab', 'Upper Limb', 'Shoulder'],\n                description: 'A phased protocol for conservatively managed clavicle (collarbone) fractures. Focus on pain management, protected range of motion, and gradual strengthening. Always follow orthopedic guidance on immobilization and weight-bearing.',\n                evidenceBase: 'Based on common conservative management guidelines for clavicle fractures.',\n                phases: [\n                    {\n                        name: 'Phase 1: Immobilization (Weeks 0-4)',\n                        notes: 'Arm in sling. Focus on pain control, swelling reduction. Maintain active range of motion of elbow, wrist, and hand. Gentle pendulum exercises if pain-free and cleared by surgeon.',\n                        exerciseIds: ['finger-taps', 'ankle-circles', 'bed-ankle-pumps'] \/\/ Using existing exercises for unaffected joints\n                    },\n                    {\n                        name: 'Phase 2: Early Mobilization (Weeks 4-8)',\n                        notes: 'Gradual discontinuation of sling. Begin gentle active-assisted and active range of motion for shoulder (flexion, abduction, rotation) within pain-free limits. Avoid heavy lifting or pushing.',\n                        exerciseIds: ['wall-push-ups', 'shoulder-blade-squeezes'] \/\/ Gentle weight bearing, can adapt for shoulder ROM\n                    },\n                    {\n                        name: 'Phase 3: Strengthening & Functional Return (Weeks 8+)',\n                        notes: 'Progressive strengthening of shoulder girdle and upper limb. Return to full activities as tolerated and cleared by surgeon.',\n                        exerciseIds: ['wall-push-ups', 'alternating-forearm-pronation-supination', 'bridging'] \/\/ Example, would add more specific shoulder exercises\n                    }\n                ]\n            },\n            {\n                id: 'proximal-humerus-fracture-protocol',\n                type: 'protocol',\n                name: 'Proximal Humerus Fracture Rehab (Conservative\/Post-Op)',\n                tags: ['Fracture Rehab', 'Upper Limb', 'Shoulder', 'Post-Op'],\n                description: 'Rehabilitation protocol for proximal humerus fractures (upper arm bone near shoulder). Specifics depend on fracture stability and surgical intervention. Prioritize protected motion and gradual progression.',\n                evidenceBase: 'Based on common rehabilitation guidelines for proximal humerus fractures.',\n                phases: [\n                    {\n                        name: 'Phase 1: Protected Motion (Weeks 0-6)',\n                        notes: 'Arm in sling (often for 3-6 weeks). Focus on pain management, swelling control. Maintain active range of motion of elbow, wrist, and hand. Gentle pendulum exercises (passive) if cleared.',\n                        exerciseIds: ['finger-taps', 'ankle-circles', 'bed-ankle-pumps'] \/\/ Using existing exercises for unaffected joints\n                    },\n                    {\n                        name: 'Phase 2: Early Active Motion (Weeks 6-12)',\n                        notes: 'Progress to active-assisted and active range of motion for shoulder (flexion, abduction, rotation) within pain-free limits. Begin light isometric strengthening if cleared.',\n                        exerciseIds: ['wall-push-ups', 'alternating-forearm-pronation-supination', 'shoulder-blade-squeezes'] \/\/ Adapt wall push-ups for shoulder focus\n                    },\n                    {\n                        name: 'Phase 3: Progressive Strengthening & Return to Function (Weeks 12+)',\n                        notes: 'Introduce progressive resistive exercises for shoulder and upper limb. Focus on functional movements and return to daily activities\/sports.',\n                        exerciseIds: ['wall-push-ups', 'bridging'] \/\/ Example, would add more specific shoulder strengthening\n                    }\n                ]\n            },\n            {\n                id: 'ankle-fracture-rehab-protocol',\n                type: 'protocol',\n                name: 'Ankle Fracture Rehab Protocol',\n                tags: ['Fracture Rehab', 'Lower Limb', 'Ankle', 'Post-Op'],\n                description: 'A phased rehabilitation protocol for ankle fractures (conservative or post-surgical). Progression depends heavily on stability, healing, and weight-bearing status as advised by orthopedic surgeon.',\n                evidenceBase: 'Based on common rehabilitation guidelines for ankle fractures.',\n                phases: [\n                    {\n                        name: 'Phase 1: Immobilization & Protected Weight Bearing (Weeks 0-6)',\n                        notes: 'Boot or cast. Non-weight bearing or partial weight-bearing. Focus on pain\/swelling control. Maintain hip\/knee mobility. Gentle ankle pumps and circles for circulation if permitted.',\n                        exerciseIds: ['bed-ankle-pumps', 'bed-knee-bends', 'chair-knee-extension', 'seated-marching']\n                    },\n                    {\n                        name: 'Phase 2: Early Mobilization & Progressive Weight Bearing (Weeks 6-12)',\n                        notes: 'Transition to walking boot\/brace. Gradual increase in weight-bearing. Begin active ankle range of motion (dorsiflexion, plantarflexion, inversion, eversion) and gentle strengthening.',\n                        exerciseIds: ['heel-raises', 'standing-balance-support', 'calf-stretch'] \/\/ Adapt for ankle focus, e.g., seated heel raises first\n                    },\n                    {\n                        name: 'Phase 3: Advanced Strengthening & Balance (Weeks 12+)',\n                        notes: 'Full weight-bearing. Progressive strengthening of ankle and lower limb. Advanced balance and proprioception exercises. Return to sport\/activity specific drills.',\n                        exerciseIds: ['tandem-stand-support', 'single-leg-stand-support', 'bridging'] \/\/ Incorporate into ankle rehab\n                    }\n                ]\n            },\n            {\n                id: 'femur-fracture-rehab-protocol',\n                type: 'protocol',\n                name: 'Femur Fracture Rehab Protocol (Post-Op)',\n                tags: ['Fracture Rehab', 'Lower Limb', 'Post-Op'],\n                description: 'Comprehensive rehabilitation protocol for femur (thigh bone) fractures, typically post-surgical fixation. Progression is slow and guided by orthopedic surgeon\\'s weight-bearing orders.',\n                evidenceBase: 'Based on common post-operative rehabilitation guidelines for femur fractures.',\n                phases: [\n                    {\n                        name: 'Phase 1: Early Post-Op & Protected Weight Bearing (Weeks 0-6\/12)',\n                        notes: 'Focus on pain\/swelling control, maintaining knee\/ankle mobility. Strict adherence to weight-bearing status (often non-weight bearing or touch-down weight bearing). Isometric exercises for hip\/knee if cleared.',\n                        exerciseIds: ['bed-ankle-pumps', 'bed-knee-bends', 'chair-knee-extension', 'seated-marching']\n                    },\n                    {\n                        name: 'Phase 2: Progressive Weight Bearing & Initial Strengthening (Weeks 6\/12 - 20)',\n                        notes: 'Gradual increase in weight-bearing as tolerated and cleared. Introduce light active strengthening for hip and knee. Progress from bed-based to seated to standing exercises with support.',\n                        exerciseIds: ['sit-to-stand', 'heel-raises', 'standing-balance-support', 'bridging']\n                    },\n                    {\n                        name: 'Phase 3: Advanced Strengthening & Functional Return (Weeks 20+)',\n                        notes: 'Full weight-bearing. High-level strengthening, balance, and functional training. Return to demanding activities and sports as cleared by surgeon and based on bone healing.',\n                        exerciseIds: ['tandem-stand-support', 'single-leg-stand-support', 'calf-stretch']\n                    }\n                ]\n            },\n            \/\/ NEW PROTOCOLS FOR EXPANDED FRACTURE TYPES\n            {\n                id: 'distal-radius-fracture-protocol',\n                type: 'protocol',\n                name: 'Distal Radius Fracture Rehab (Wrist)',\n                tags: ['Fracture Rehab', 'Upper Limb', 'Wrist', 'Hand'],\n                description: 'Rehabilitation protocol for distal radius (wrist) fractures, common after falls. Progression depends on stability (conservative vs. surgical) and bone healing.',\n                evidenceBase: 'Based on common rehabilitation guidelines for wrist fractures.',\n                phases: [\n                    {\n                        name: 'Phase 1: Immobilization (Weeks 0-6)',\n                        notes: 'Wrist in cast\/brace. Focus on pain\/swelling control. Maintain full, pain-free range of motion of shoulder, elbow, and fingers of affected arm. Gentle finger exercises.',\n                        exerciseIds: ['finger-taps', 'shoulder-blade-squeezes', 'bed-ankle-pumps'] \/\/ Using existing exercises for unaffected joints\/general mobility\n                    },\n                    {\n                        name: 'Phase 2: Early Mobilization (Weeks 6-12)',\n                        notes: 'After cast\/brace removal. Begin gentle active and active-assisted range of motion for wrist (flexion, extension, radial\/ulnar deviation) and forearm (pronation\/supination). Light grip strengthening.',\n                        exerciseIds: ['alternating-forearm-pronation-supination', 'finger-taps']\n                    },\n                    {\n                        name: 'Phase 3: Progressive Strengthening & Functional Return',\n                        notes: 'Progressive strengthening of wrist and hand. Fine motor control and dexterity exercises. Return to daily activities, work, and sport as tolerated.',\n                        exerciseIds: ['finger-taps', 'wall-push-ups'] \/\/ Wall push-ups can be progressed to wrist weight-bearing\n                    }\n                ]\n            },\n            {\n                id: 'scaphoid-fracture-protocol',\n                type: 'protocol',\n                name: 'Scaphoid Fracture Rehab (Wrist)',\n                tags: ['Fracture Rehab', 'Upper Limb', 'Wrist', 'Hand'],\n                description: 'Rehabilitation protocol for scaphoid fractures, which can be slow to heal. Strict adherence to immobilization and weight-bearing status is critical. Often prolonged immobilization.',\n                evidenceBase: 'Based on specific rehabilitation guidelines for scaphoid fractures.',\n                phases: [\n                    {\n                        name: 'Phase 1: Prolonged Immobilization (Weeks 0-12+)',\n                        notes: 'Wrist in cast (often for 8-12+ weeks). Focus on pain\/swelling. Maintain full, pain-free range of motion of shoulder, elbow, and fingers. Avoid any wrist movement or weight-bearing.',\n                        exerciseIds: ['finger-taps', 'shoulder-blade-squeezes', 'bed-ankle-pumps']\n                    },\n                    {\n                        name: 'Phase 2: Initial Mobilization (Post-Immobilization)',\n                        notes: 'After confirmed union (X-ray). Begin very gentle active and active-assisted range of motion for wrist and forearm. No heavy lifting or gripping initially.',\n                        exerciseIds: ['alternating-forearm-pronation-supination', 'finger-taps']\n                    },\n                    {\n                        name: 'Phase 3: Progressive Strengthening & Functional Return',\n                        notes: 'Gradual, progressive strengthening of wrist and hand. Focus on grip strength, fine motor skills, and return to specific activities. Long-term recovery is common.',\n                        exerciseIds: ['finger-taps'] \/\/ More specific hand\/wrist exercises would be added here\n                    }\n                ]\n            },\n            {\n                id: 'tibia-fibula-fracture-protocol',\n                type: 'protocol',\n                name: 'Tibia\/Fibula Fracture Rehab (Lower Leg)',\n                tags: ['Fracture Rehab', 'Lower Limb', 'Knee', 'Ankle'],\n                description: 'Rehabilitation protocol for tibia\/fibula (lower leg) fractures. Progression depends on fracture type, stability, and surgical fixation. Weight-bearing status is crucial.',\n                evidenceBase: 'Based on common rehabilitation guidelines for lower leg fractures.',\n                phases: [\n                    {\n                        name: 'Phase 1: Immobilization & Protected Weight Bearing (Weeks 0-8\/12)',\n                        notes: 'Cast\/boot. Non-weight bearing or touch-down weight bearing. Focus on pain\/swelling. Maintain hip\/knee ROM. Gentle ankle pumps\/circles if permitted for circulation.',\n                        exerciseIds: ['bed-ankle-pumps', 'bed-knee-bends', 'chair-knee-extension', 'seated-marching']\n                    },\n                    {\n                        name: 'Phase 2: Progressive Weight Bearing & Early Strengthening (Weeks 8\/12 - 20)',\n                        notes: 'Gradual increase in weight-bearing. Begin active ankle and knee range of motion. Light strengthening for hip, knee, and ankle (non-weight bearing initially).',\n                        exerciseIds: ['sit-to-stand', 'heel-raises', 'standing-balance-support', 'bridging']\n                    },\n                    {\n                        name: 'Phase 3: Advanced Strengthening & Functional Return (Weeks 20+)',\n                        notes: 'Full weight-bearing. Progressive strengthening, balance, and agility drills. Return to higher impact activities and sport as cleared by surgeon and based on bone healing.',\n                        exerciseIds: ['tandem-stand-support', 'single-leg-stand-support', 'calf-stretch']\n                    }\n                ]\n            },\n            {\n                id: 'patella-fracture-protocol',\n                type: 'protocol',\n                name: 'Patella Fracture Rehab (Kneecap)',\n                tags: ['Fracture Rehab', 'Lower Limb', 'Knee'],\n                description: 'Rehabilitation protocol for patella (kneecap) fractures. Focus on regaining knee extension and flexion, often with protected weight-bearing and motion initially.',\n                evidenceBase: 'Based on common rehabilitation guidelines for patella fractures.',\n                phases: [\n                    {\n                        name: 'Phase 1: Immobilization & Protected Motion (Weeks 0-6)',\n                        notes: 'Knee immobilized in extension (brace\/cast). Non-weight bearing or partial weight-bearing. Focus on pain\/swelling. Maintain hip\/ankle ROM. Gentle quad sets (isometric) if cleared.',\n                        exerciseIds: ['bed-ankle-pumps', 'bed-knee-bends', 'seated-marching'] \/\/ Bed knee bends might be limited initially\n                    },\n                    {\n                        name: 'Phase 2: Progressive Motion & Weight Bearing (Weeks 6-12)',\n                        notes: 'Gradual increase in knee flexion range of motion. Progressive weight-bearing. Begin light strengthening for quadriceps and hamstrings.',\n                        exerciseIds: ['chair-knee-extension', 'sit-to-stand', 'heel-raises']\n                    },\n                    {\n                        name: 'Phase 3: Advanced Strengthening & Functional Return (Weeks 12+)',\n                        notes: 'Full knee range of motion. High-level strengthening for entire lower limb. Balance and functional drills. Return to sport\/activity specific training.',\n                        exerciseIds: ['standing-balance-support', 'tandem-stand-support', 'single-leg-stand-support', 'bridging']\n                    }\n                ]\n            },\n            {\n                id: 'rotator-cuff-repair-protocol',\n                type: 'protocol',\n                name: 'Rotator Cuff Repair Protocol',\n                tags: ['Post-Op', 'Shoulder', 'Upper Limb'],\n                description: 'A phased rehabilitation protocol following rotator cuff repair surgery. Strict adherence to precautions and controlled progression is essential to protect the repair.',\n                evidenceBase: 'Based on common post-operative rehabilitation guidelines for rotator cuff repair.',\n                phases: [\n                    {\n                        name: 'Phase 1: Protection & Passive Motion (Weeks 0-6)',\n                        notes: 'Arm in sling (often 4-6 weeks). Focus on pain\/swelling control. ONLY passive range of motion (PROM) for shoulder, as directed by therapist. Maintain elbow, wrist, hand ROM.',\n                        exerciseIds: ['finger-taps', 'ankle-circles', 'bed-ankle-pumps'] \/\/ General mobility for unaffected joints\n                    },\n                    {\n                        name: 'Phase 2: Active-Assisted & Gentle Active Motion (Weeks 6-12)',\n                        notes: 'Gradual progression to active-assisted (AAROM) then active range of motion (AROM). Begin light isometric exercises for rotator cuff if cleared. NO lifting, pushing, or pulling.',\n                        exerciseIds: ['alternating-forearm-pronation-supination', 'shoulder-blade-squeezes']\n                    },\n                    {\n                        name: 'Phase 3: Strengthening & Return to Activity (Weeks 12-24+)',\n                        notes: 'Progressive strengthening of rotator cuff and scapular stabilizers. Introduce functional activities. Gradual return to light lifting, then more demanding activities\/sports as cleared.',\n                        exerciseIds: ['wall-push-ups', 'bridging'] \/\/ Wall push-ups can be adapted for shoulder stability\n                    }\n                ]\n            },\n            {\n                id: 'acl-reconstruction-protocol',\n                type: 'protocol',\n                name: 'ACL Reconstruction Protocol',\n                tags: ['Post-Op', 'Knee', 'Lower Limb'],\n                description: 'A comprehensive, phased rehabilitation protocol following Anterior Cruciate Ligament (ACL) reconstruction surgery. Focus on protecting the graft, regaining full extension, and progressive strengthening.',\n                evidenceBase: 'Based on common post-operative rehabilitation guidelines for ACL reconstruction.',\n                phases: [\n                    {\n                        name: 'Phase 1: Protection & Early Motion (Weeks 0-4)',\n                        notes: 'Knee brace, often locked in extension. Partial weight-bearing with crutches. Focus on achieving full knee extension (critical!), pain\/swelling control, and early quadriceps activation (quad sets).',\n                        exerciseIds: ['bed-ankle-pumps', 'bed-knee-bends', 'chair-knee-extension', 'seated-marching'] \/\/ Bed knee bends limited to specific range\n                    },\n                    {\n                        name: 'Phase 2: Progressive Strengthening & Neuromuscular Control (Weeks 4-12)',\n                        notes: 'Wean off crutches\/brace. Progress knee flexion. Introduce closed-chain strengthening (e.g., mini-squats, step-ups). Begin balance and proprioception exercises.',\n                        exerciseIds: ['sit-to-stand', 'heel-raises', 'standing-balance-support', 'bridging']\n                    },\n                    {\n                        name: 'Phase 3: Return to Sport Preparation (Weeks 12-24+)',\n                        notes: 'Advanced strengthening, plyometrics, agility drills, and sport-specific training. Focus on power, endurance, and dynamic stability. Return to sport typically 9-12+ months post-op, based on objective criteria.',\n                        exerciseIds: ['tandem-stand-support', 'single-leg-stand-support', 'calf-stretch'] \/\/ Would add more advanced sport-specific drills here\n                    }\n                ]\n            }\n        ];\n\n        \/\/ --- Global Variables ---\n        let currentPrescription = [];\n        let nextPrescriptionItemId = 0; \/\/ Unique ID for each item added to the prescription\n        let selectedOtagoProtocol = null; \/\/ To store the Otago protocol object when configuring phases\n\n        \/\/ --- DOM Elements ---\n        const exerciseSearch = document.getElementById('exerciseSearch');\n        const categoryFilter = document.getElementById('categoryFilter');\n        const difficultyFilter = document.getElementById('difficultyFilter');\n        const individualExerciseList = document.getElementById('individualExerciseList'); \/\/ Specific div for exercises\n        const protocolList = document.getElementById('protocolList'); \/\/ Specific div for protocols\n        const prescriptionList = document.getElementById('prescriptionList');\n        const noExercisesMessage = document.getElementById('noExercisesMessage');\n        const generatePrescriptionBtn = document.getElementById('generatePrescriptionBtn');\n        const exportWordBtn = document.getElementById('exportWordBtn'); \/\/ New export button\n        \/\/ const printableArea = document.getElementById('printableArea'); \/\/ No longer directly used for printing\n\n        const patientNameInput = document.getElementById('patientName');\n        const physioNameInput = document.getElementById('physioName');\n        const serviceNameInput = document.getElementById('serviceName'); \/\/ New: Service Name input\n        const clinicalGoalsInput = document.getElementById('clinicalGoals');\n        const precautionsInput = document.getElementById('precautions');\n\n        const printFontSizeSelect = document.getElementById('printFontSize');\n\n        \/\/ Otago Phase Selection Elements\n        const otagoPhaseSelection = document.getElementById('otagoPhaseSelection');\n        const otagoPhasesCheckboxes = document.getElementById('otagoPhasesCheckboxes');\n        const cancelOtagoSelectionBtn = document.getElementById('cancelOtagoSelectionBtn');\n        const confirmOtagoSelectionBtn = document.getElementById('confirmOtagoSelectionBtn');\n\n        \/\/ Global Dosimetry Elements\n        const globalSetsInput = document.getElementById('globalSets');\n        const globalRepsInput = document.getElementById('globalReps');\n        const globalHoldTimeInput = document.getElementById('globalHoldTime');\n        const globalDurationInput = document.getElementById('globalDuration');\n        const globalFrequencySelect = document.getElementById('globalFrequency');\n        const globalRestBetweenSetsInput = document.getElementById('globalRestBetweenSets');\n        const applyGlobalDosimetryBtn = document.getElementById('applyGlobalDosimetryBtn');\n\n\n        \/\/ --- Helper Function to get an exercise by its ID ---\n        function getExerciseById(id) {\n            return libraryItems.find(item => item.type === 'exercise' && item.id === id);\n        }\n\n        \/**\n         * Checks if a given library item (exercise or protocol) is already in the current prescription.\n         * @param {object} item - The item from libraryItems to check.\n         * @returns {boolean} True if the item is in the prescription, false otherwise.\n         *\/\n        function isItemInPrescription(item) {\n            if (item.type === 'exercise') {\n                \/\/ Check if this individual exercise is added directly\n                return currentPrescription.some(pItem => pItem.originalId === item.id && !pItem.protocolOrigin);\n            } else if (item.type === 'protocol') {\n                \/\/ Check if any exercise from this protocol is in the prescription\n                return currentPrescription.some(pItem => pItem.protocolOrigin === item.id);\n            }\n            return false;\n        }\n\n        \/**\n         * Helper to get current global dosimetry values.\n         * @returns {object} An object containing the current global dosimetry settings.\n         *\/\n        function getGlobalDosimetry() {\n            return {\n                sets: parseInt(globalSetsInput.value) || 0,\n                reps: parseInt(globalRepsInput.value) || 0,\n                holdTime: parseInt(globalHoldTimeInput.value) || 0,\n                duration: parseInt(globalDurationInput.value) || 0,\n                frequency: globalFrequencySelect.value,\n                restBetweenSets: parseInt(globalRestBetweenSetsInput.value) || 0,\n            };\n        }\n\n        \/**\n         * Applies the current global dosimetry settings to all exercises in the prescription.\n         *\/\n        function applyGlobalDosimetry() {\n            const globalDosimetry = getGlobalDosimetry();\n            currentPrescription.forEach(item => {\n                item.sets = globalDosimetry.sets;\n                item.reps = globalDosimetry.reps;\n                item.holdTime = globalDosimetry.holdTime;\n                item.duration = globalDosimetry.duration;\n                item.frequency = globalDosimetry.frequency;\n                item.restBetweenSets = globalDosimetry.restBetweenSets;\n            });\n            renderPrescriptionList(); \/\/ Re-render to show updated values\n        }\n\n        \/**\n         * Helper to add a single exercise to the prescription, with optional protocol context.\n         * @param {object} exercise - The exercise object from the library.\n         * @param {string} [protocolId] - The ID of the protocol if this exercise is part of one.\n         * @param {string} [protocolName] - The name of the protocol if this exercise is part of one.\n         * @param {string} [phaseName] - The name of the protocol phase if this exercise is part of one.\n         *\/\n        function addSingleExerciseToPrescription(exercise, protocolId = null, protocolName = null, phaseName = null) {\n            \/\/ Apply global dosimetry as default for new exercises\n            const globalDosimetry = getGlobalDosimetry();\n\n            const newPrescriptionItem = {\n                id: nextPrescriptionItemId++, \/\/ Unique ID for this specific instance in the prescription\n                originalId: exercise.id, \/\/ Reference to the original exercise data\n                name: exercise.name,\n                imageStart: exercise.imageStart,\n                imageEnd: exercise.imageEnd,\n                directions: exercise.directions,\n                tips: exercise.tips,\n                contraindications: exercise.contraindications,\n                protocolOrigin: protocolId, \/\/ ID of the protocol it came from\n                protocolName: protocolName, \/\/ Name of the protocol\n                phaseName: phaseName, \/\/ Name of the phase within the protocol\n                \/\/ Default dosimetry values from global settings\n                sets: globalDosimetry.sets,\n                reps: globalDosimetry.reps,\n                holdTime: globalDosimetry.holdTime,\n                duration: globalDosimetry.duration,\n                frequency: globalDosimetry.frequency,\n                restBetweenSets: globalDosimetry.restBetweenSets,\n                progressionAdvice: '',\n                patientSpecificNotes: ''\n            };\n            currentPrescription.push(newPrescriptionItem);\n        }\n\n        \/**\n         * Adds an individual exercise or initiates protocol phase selection.\n         * @param {string} itemId - The ID of the exercise or protocol to add.\n         * @param {string} itemType - 'exercise' or 'protocol'.\n         *\/\n        function addItemsToPrescription(itemId, itemType) {\n            if (itemType === 'exercise') {\n                const exercise = getExerciseById(itemId);\n                if (exercise) {\n                    \/\/ Prevent adding the same individual exercise multiple times directly\n                    if (currentPrescription.some(item => item.originalId === exercise.id && !item.protocolOrigin)) {\n                        console.log(`${exercise.name} is already in the prescription as an individual exercise.`);\n                        return;\n                    }\n                    addSingleExerciseToPrescription(exercise);\n                }\n            } else if (itemType === 'protocol') {\n                const protocol = libraryItems.find(item => item.type === 'protocol' && item.id === itemId);\n                if (protocol) {\n                    \/\/ If it's the Otago protocol, show phase selection\n                    if (protocol.id === 'otago-exercise-protocol') {\n                        selectedOtagoProtocol = protocol;\n                        displayOtagoPhaseSelection(protocol);\n                    } else {\n                        \/\/ For other protocols, add all exercises from all phases directly\n                        if (currentPrescription.some(item => item.protocolOrigin === protocol.id)) {\n                            console.log(`${protocol.name} is already in the prescription.`);\n                            return;\n                        }\n                        protocol.phases.forEach(phase => {\n                            phase.exerciseIds.forEach(exerciseId => {\n                                const exercise = getExerciseById(exerciseId);\n                                if (exercise) {\n                                    addSingleExerciseToPrescription(exercise, protocol.id, protocol.name, phase.name);\n                                }\n                            });\n                        });\n                    }\n                }\n            }\n            renderPrescriptionList();\n            renderExerciseList(); \/\/ Re-render library to update \"Added\" status\n        }\n\n        \/**\n         * Displays the phase selection interface for the Otago protocol.\n         * @param {object} protocol - The Otago protocol object.\n         *\/\n        function displayOtagoPhaseSelection(protocol) {\n            otagoPhasesCheckboxes.innerHTML = ''; \/\/ Clear previous checkboxes\n            protocol.phases.forEach(phase => {\n                const div = document.createElement('div');\n                div.className = 'flex items-center';\n                div.innerHTML = `\n                    <input type=\"checkbox\" id=\"otago-phase-${phase.name.replace(\/\\s\/g, '-')}\" name=\"otago-phase\" value=\"${phase.name}\" class=\"h-4 w-4 text-green-600 border-gray-300 rounded focus:ring-green-500\" checked>\n                    <label for=\"otago-phase-${phase.name.replace(\/\\s\/g, '-')}\" class=\"ml-2 text-sm font-medium text-gray-900\">${phase.name}<\/label>\n                `;\n                otagoPhasesCheckboxes.appendChild(div);\n            });\n            otagoPhaseSelection.classList.remove('hidden');\n        }\n\n        \/**\n         * Confirms the selected Otago phases and adds their exercises to the prescription.\n         *\/\n        function confirmOtagoPhaseSelection() {\n            if (!selectedOtagoProtocol) return;\n\n            const selectedPhases = Array.from(otagoPhasesCheckboxes.querySelectorAll('input[type=\"checkbox\"]:checked'))\n                                        .map(checkbox => checkbox.value);\n\n            \/\/ Check if any exercise from this protocol is already in the prescription.\n            \/\/ If the protocol was added before, clear its exercises first to allow re-selection.\n            currentPrescription = currentPrescription.filter(item => item.protocolOrigin !== selectedOtagoProtocol.id);\n\n            selectedOtagoProtocol.phases.forEach(phase => {\n                if (selectedPhases.includes(phase.name)) {\n                    phase.exerciseIds.forEach(exerciseId => {\n                        const exercise = getExerciseById(exerciseId);\n                        if (exercise) {\n                            addSingleExerciseToPrescription(exercise, selectedOtagoProtocol.id, selectedOtagoProtocol.name, phase.name);\n                        }\n                    });\n                }\n            });\n\n            otagoPhaseSelection.classList.add('hidden'); \/\/ Hide the selection UI\n            selectedOtagoProtocol = null; \/\/ Clear the selected protocol\n            renderPrescriptionList();\n            renderExerciseList(); \/\/ Update \"Added\" status\n        }\n\n        \/**\n         * Cancels Otago phase selection and hides the UI.\n         *\/\n        function cancelOtagoPhaseSelection() {\n            otagoPhaseSelection.classList.add('hidden');\n            selectedOtagoProtocol = null;\n            renderExerciseList(); \/\/ Re-render to reset button state if needed\n        }\n\n\n        \/**\n         * Removes an exercise from the current prescription list.\n         * @param {number} prescriptionItemId - The unique ID of the prescription item to remove.\n         *\/\n        function removeExerciseFromPrescription(prescriptionItemId) {\n            currentPrescription = currentPrescription.filter(item => item.id !== prescriptionItemId);\n            renderPrescriptionList();\n            renderExerciseList(); \/\/ Re-render library to update \"Added\" status\n        }\n\n        \/**\n         * Updates a dosimetry value for a specific exercise in the prescription.\n         * @param {number} prescriptionItemId - The unique ID of the prescription item.\n         * @param {string} field - The dosimetry field to update (e.g., 'sets', 'reps').\n         * @param {any} value - The new value for the field.\n         *\/\n        function updateDosimetry(prescriptionItemId, field, value) {\n            const itemIndex = currentPrescription.findIndex(item => item.id === prescriptionItemId);\n            if (itemIndex > -1) {\n                \/\/ Ensure number types are parsed correctly\n                if (['sets', 'reps', 'holdTime', 'duration', 'restBetweenSets'].includes(field)) {\n                    currentPrescription[itemIndex][field] = parseInt(value) || 0;\n                } else {\n                    currentPrescription[itemIndex][field] = value;\n                }\n            }\n        }\n\n        \/**\n         * Renders the list of exercises currently in the prescription builder.\n         *\/\n        function renderPrescriptionList() {\n            prescriptionList.innerHTML = ''; \/\/ Clear existing list\n            if (currentPrescription.length === 0) {\n                noExercisesMessage.style.display = 'block';\n                return;\n            } else {\n                noExercisesMessage.style.display = 'none';\n            }\n\n            \/\/ Group exercises by protocol for better display in the builder\n            const groupedPrescription = {};\n            currentPrescription.forEach(item => {\n                const key = item.protocolOrigin || 'individual';\n                if (!groupedPrescription[key]) {\n                    groupedPrescription[key] = {\n                        name: item.protocolName || 'Individual Exercises',\n                        items: [],\n                        isProtocol: !!item.protocolOrigin\n                    };\n                }\n                groupedPrescription[key].items.push(item);\n            });\n\n            for (const key in groupedPrescription) {\n                const group = groupedPrescription[key];\n                const groupContainer = document.createElement('div');\n                groupContainer.className = `mb-8 p-4 rounded-lg ${group.isProtocol ? 'bg-green-100 border border-green-300' : 'bg-gray-100 border border-gray-200'}`;\n                groupContainer.innerHTML = `<h3 class=\"text-xl font-bold ${group.isProtocol ? 'text-green-800' : 'text-gray-800'} mb-4\">${group.name}<\/h3>`;\n\n                \/\/ Sort items within the group to maintain a consistent order\n                group.items.sort((a, b) => a.id - b.id);\n\n                group.items.forEach((item, index) => {\n                    const listItem = document.createElement('div');\n                    listItem.className = 'bg-white p-6 rounded-lg shadow-md border border-green-200 flex flex-col md:flex-row gap-4 items-start mb-4';\n                    listItem.setAttribute('data-id', item.id);\n\n                    listItem.innerHTML = `\n                        <div class=\"md:w-1\/4 flex-shrink-0\">\n                            <h4 class=\"text-lg font-semibold text-green-700 mb-2\">${index + 1}. ${item.name}<\/h4>\n                            ${item.phaseName ? `<p class=\"text-sm text-gray-600 mb-2\">Phase: ${item.phaseName}<\/p>` : ''}\n                            <div class=\"grid grid-cols-2 gap-2 mb-3\">\n                                <img decoding=\"async\" src=\"${item.imageStart}\" alt=\"${item.name} Start\" class=\"w-full h-auto rounded-md object-cover border border-gray-300\" onerror=\"this.onerror=null;this.src='https:\/\/placehold.co\/400x250\/ccc\/000?text=Image+Not+Found';\">\n                                <img decoding=\"async\" src=\"${item.imageEnd}\" alt=\"${item.name} End\" class=\"w-full h-auto rounded-md object-cover border border-gray-300\" onerror=\"this.onerror=null;this.src='https:\/\/placehold.co\/400x250\/ccc\/000?text=Image+Not+Found';\">\n                            <\/div>\n                            <button data-id=\"${item.id}\" class=\"remove-from-prescription-btn bg-red-500 hover:bg-red-600 text-white text-sm font-bold py-2 px-4 rounded-md w-full transition duration-150 ease-in-out\">\n                                Remove\n                            <\/button>\n                        <\/div>\n                        <div class=\"md:w-3\/4 flex-grow\">\n                            <p class=\"text-gray-700 text-sm mb-3\"><strong>Directions:<\/strong><\/p>\n                            <ul class=\"list-disc list-inside text-gray-700 text-sm mb-4 space-y-1\">\n                                ${item.directions.map(dir => `<li>${dir}<\/li>`).join('')}\n                            <\/ul>\n\n                            <h5 class=\"text-md font-semibold text-green-700 mb-2\">Dosimetry:<\/h5>\n                            <div class=\"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-4 mb-4\">\n                                <div>\n                                    <label for=\"sets-${item.id}\" class=\"block text-xs font-medium text-gray-600 mb-1\">Sets<\/label>\n                                    <input type=\"number\" id=\"sets-${item.id}\" value=\"${item.sets}\" min=\"0\" class=\"w-full p-2 border border-gray-300 rounded-md text-sm\" data-field=\"sets\" data-id=\"${item.id}\">\n                                <\/div>\n                                <div>\n                                    <label for=\"reps-${item.id}\" class=\"block text-xs font-medium text-gray-600 mb-1\">Reps<\/label>\n                                    <input type=\"number\" id=\"reps-${item.id}\" value=\"${item.reps}\" min=\"0\" class=\"w-full p-2 border border-gray-300 rounded-md text-sm\" data-field=\"reps\" data-id=\"${item.id}\">\n                                <\/div>\n                                <div>\n                                    <label for=\"holdTime-${item.id}\" class=\"block text-xs font-medium text-gray-600 mb-1\">Hold Time (seconds)<\/label>\n                                    <input type=\"number\" id=\"holdTime-${item.id}\" value=\"${item.holdTime}\" min=\"0\" class=\"w-full p-2 border border-gray-300 rounded-md text-sm\" data-field=\"holdTime\" data-id=\"${item.id}\">\n                                <\/div>\n                                <div>\n                                    <label for=\"duration-${item.id}\" class=\"block text-xs font-medium text-gray-600 mb-1\">Duration (minutes)<\/label>\n                                    <input type=\"number\" id=\"duration-${item.id}\" value=\"${item.duration}\" min=\"0\" class=\"w-full p-2 border border-gray-300 rounded-md text-sm\" data-field=\"duration\" data-id=\"${item.id}\">\n                                <\/div>\n                                <div>\n                                    <label for=\"frequency-${item.id}\" class=\"block text-xs font-medium text-gray-600 mb-1\">Frequency<\/label>\n                                    <select id=\"frequency-${item.id}\" class=\"w-full p-2 border border-gray-300 rounded-md text-sm\" data-field=\"frequency\" data-id=\"${item.id}\">\n                                        <option value=\"Daily\" ${item.frequency === 'Daily' ? 'selected' : ''}>Daily<\/option>\n                                        <option value=\"Once a day\" ${item.frequency === 'Once a day' ? 'selected' : ''}>Once a day<\/option>\n                                        <option value=\"Twice a day\" ${item.frequency === 'Twice a day' ? 'selected' : ''}>Twice a day<\/option>\n                                        <option value=\"3 times a week\" ${item.frequency === '3 times a week' ? 'selected' : ''}>3 times a week<\/option>\n                                        <option value=\"As tolerated\" ${item.frequency === 'As tolerated' ? 'selected' : ''}>As tolerated<\/option>\n                                    <\/select>\n                                <\/div>\n                                <div>\n                                    <label for=\"restBetweenSets-${item.id}\" class=\"block text-xs font-medium text-gray-600 mb-1\">Rest (seconds)<\/label>\n                                    <input type=\"number\" id=\"restBetweenSets-${item.id}\" value=\"${item.restBetweenSets}\" min=\"0\" class=\"w-full p-2 border border-gray-300 rounded-md text-sm\" data-field=\"restBetweenSets\" data-id=\"${item.id}\">\n                                <\/div>\n                            <\/div>\n\n                            <div class=\"mb-4\">\n                                <label for=\"progressionAdvice-${item.id}\" class=\"block text-xs font-medium text-gray-600 mb-1\">Progression Advice<\/label>\n                                <textarea id=\"progressionAdvice-${item.id}\" rows=\"2\" class=\"w-full p-2 border border-gray-300 rounded-md text-sm\" data-field=\"progressionAdvice\" data-id=\"${item.id}\" placeholder=\"e.g., Increase reps by 2 when able\">${item.progressionAdvice}<\/textarea>\n                            <\/div>\n                            <div>\n                                <label for=\"patientSpecificNotes-${item.id}\" class=\"block text-xs font-medium text-gray-600 mb-1\">Patient-Specific Notes<\/label>\n                                <textarea id=\"patientSpecificNotes-${item.id}\" rows=\"2\" class=\"w-full p-2 border border-gray-300 rounded-md text-sm\" data-field=\"patientSpecificNotes\" data-id=\"${item.id}\" placeholder=\"e.g., Perform this exercise immediately after waking\">${item.patientSpecificNotes}<\/textarea>\n                            <\/div>\n                        <\/div>\n                    `;\n                    groupContainer.appendChild(listItem);\n                });\n                prescriptionList.appendChild(groupContainer);\n            }\n\n\n            \/\/ Add event listeners for dosimetry inputs\n            prescriptionList.querySelectorAll('input, select, textarea').forEach(input => {\n                input.addEventListener('change', (event) => {\n                    const id = parseInt(event.target.dataset.id);\n                    const field = event.target.dataset.field;\n                    const value = event.target.value;\n                    updateDosimetry(id, field, value);\n                });\n            });\n\n            \/\/ Add event listeners for remove buttons\n            prescriptionList.querySelectorAll('.remove-from-prescription-btn').forEach(button => {\n                button.addEventListener('click', (event) => {\n                    const id = parseInt(event.target.dataset.id);\n                    removeExerciseFromPrescription(id);\n                });\n            });\n        }\n\n        \/**\n         * Renders the list of individual exercises and protocols in the library section.\n         * This function applies search and filter criteria.\n         *\/\n        function renderExerciseList() {\n            const searchTerm = exerciseSearch.value.toLowerCase();\n            const selectedCategory = categoryFilter.value;\n            const selectedDifficulty = difficultyFilter.value;\n\n            individualExerciseList.innerHTML = '';\n            protocolList.innerHTML = '';\n\n            libraryItems.forEach(item => {\n                const matchesSearch = searchTerm === '' ||\n                                      item.name.toLowerCase().includes(searchTerm) ||\n                                      (item.tags && item.tags.some(tag => tag.toLowerCase().includes(searchTerm))) ||\n                                      (item.description && item.description.toLowerCase().includes(searchTerm));\n                const matchesCategory = selectedCategory === '' || (item.tags && item.tags.includes(selectedCategory));\n                const matchesDifficulty = selectedDifficulty === '' || item.difficulty === selectedDifficulty;\n\n                if (matchesSearch && matchesCategory && matchesDifficulty) {\n                    const card = document.createElement('div');\n                    card.className = 'bg-white p-4 rounded-lg shadow-md flex flex-col items-center text-center border border-gray-200';\n\n                    const isAdded = isItemInPrescription(item);\n                    const buttonText = isAdded ? 'Added' : `Add ${item.type === 'exercise' ? 'Exercise' : 'Protocol'}`;\n                    const buttonClass = isAdded ? 'bg-gray-400 cursor-not-allowed' : 'bg-blue-500 hover:bg-blue-600';\n\n                    card.innerHTML = `\n                        <h3 class=\"text-lg font-semibold text-gray-800 mb-2\">${item.name}<\/h3>\n                        ${item.type === 'exercise' ? `\n                            <div class=\"flex-grow w-full mb-3\">\n                                <img decoding=\"async\" src=\"${item.imageStart}\" alt=\"${item.name} Start\" class=\"w-full h-32 object-cover rounded-md mb-2 border border-gray-300\" onerror=\"this.onerror=null;this.src='https:\/\/placehold.co\/400x250\/ccc\/000?text=Image+Not+Found';\">\n                                <img decoding=\"async\" src=\"${item.imageEnd}\" alt=\"${item.name} End\" class=\"w-full h-32 object-cover rounded-md border border-gray-300\" onerror=\"this.onerror=null;this.src='https:\/\/placehold.co\/400x250\/ccc\/000?text=Image+Not+Found';\">\n                            <\/div>\n                            <p class=\"text-sm text-gray-600 mb-2\">Difficulty: ${item.difficulty}<\/p>\n                            <p class=\"text-sm text-gray-600 mb-2\">Equipment: ${item.equipment}<\/p>\n                        ` : `\n                            <p class=\"text-sm text-gray-600 mb-2\">${item.description}<\/p>\n                            <p class=\"text-sm text-gray-600 mb-2\">Tags: ${item.tags.join(', ')}<\/p>\n                        `}\n                        <button data-id=\"${item.id}\" data-type=\"${item.type}\" class=\"add-to-prescription-btn ${buttonClass} text-white font-bold py-2 px-4 rounded-md w-full transition duration-150 ease-in-out\" ${isAdded ? 'disabled' : ''}>\n                            ${buttonText}\n                        <\/button>\n                    `;\n\n                    if (item.type === 'exercise') {\n                        individualExerciseList.appendChild(card);\n                    } else {\n                        protocolList.appendChild(card);\n                    }\n                }\n            });\n\n            \/\/ Add event listeners for the \"Add\" buttons\n            document.querySelectorAll('.add-to-prescription-btn').forEach(button => {\n                button.addEventListener('click', (event) => {\n                    const itemId = event.target.dataset.id;\n                    const itemType = event.target.dataset.type;\n                    addItemsToPrescription(itemId, itemType);\n                });\n            });\n        }\n\n        \/**\n         * Generates the complete HTML content for the printable prescription.\n         * This function now returns a full HTML string, including head, body, and styles.\n         * @param {boolean} forWordExport - True if generating for Word export, false for PDF print.\n         * @returns {string} Complete HTML string for the prescription.\n         *\/\n        function generatePrescriptionContent(forWordExport = false) {\n            const patientName = patientNameInput.value.trim();\n            const physioName = physioNameInput.value.trim();\n            const serviceName = serviceNameInput.value.trim();\n            const clinicalGoals = clinicalGoalsInput.value.trim();\n            const precautions = precautionsInput.value.trim();\n            const currentDate = new Date().toLocaleDateString('en-GB', { year: 'numeric', month: 'long', day: 'numeric' });\n\n            const fontSize = printFontSizeSelect.value;\n            let baseFontSize = '11pt';\n            if (fontSize === 'small') {\n                baseFontSize = '9pt';\n            } else if (fontSize === 'large') {\n                baseFontSize = '13pt';\n            }\n\n            let contentBodyHtml = `\n                <div class=\"header-section\">\n                    <h1>Exercise Prescription<\/h1>\n                    <p><strong>Date:<\/strong> ${currentDate}<\/p>\n                <\/div>\n\n                <div class=\"patient-details-section\">\n                    <h2>Patient Details<\/h2>\n                    <p><strong>Patient Name\/ID:<\/strong> ${patientName || 'N\/A'}<\/p>\n                    <p><strong>Physiotherapist:<\/strong> ${physioName || 'N\/A'}<\/p>\n                    ${serviceName ? `<p><strong>Service:<\/strong> ${serviceName}<\/p>` : ''}\n                    ${clinicalGoals ? `<p><strong>Clinical Goal(s):<\/strong> ${clinicalGoals}<\/p>` : ''}\n                    ${precautions ? `<p><strong>Specific Instructions\/Precautions:<\/strong> ${precautions}<\/p>` : ''}\n                <\/div>\n\n                <h2 class=\"exercise-program-title\">Your Exercise Program<\/h2>\n            `;\n\n            if (currentPrescription.length === 0) {\n                contentBodyHtml += '<p style=\"text-align: center; color: #6b7280; font-size: 1.2em;\">No exercises have been prescribed for this patient.<\/p>';\n            } else {\n                const groupedForPrint = {};\n                currentPrescription.forEach(item => {\n                    const protocolKey = item.protocolOrigin || 'individual';\n                    if (!groupedForPrint[protocolKey]) {\n                        const protocol = libraryItems.find(p => p.id === item.protocolOrigin);\n                        groupedForPrint[protocolKey] = {\n                            name: item.protocolName || 'Individual Exercises',\n                            isProtocol: !!item.protocolOrigin,\n                            evidenceBase: protocol ? protocol.evidenceBase : '',\n                            phases: {}\n                        };\n                    }\n\n                    if (item.protocolOrigin) {\n                        const phaseKey = item.phaseName || 'unphased';\n                        if (!groupedForPrint[protocolKey].phases[phaseKey]) {\n                            groupedForPrint[protocolKey].phases[phaseKey] = {\n                                name: item.phaseName || 'Exercises',\n                                items: []\n                            };\n                        }\n                        groupedForPrint[protocolKey].phases[phaseKey].items.push(item);\n                    } else {\n                        if (!groupedForPrint[protocolKey].items) {\n                            groupedForPrint[protocolKey].items = [];\n                        }\n                        groupedForPrint[protocolKey].items.push(item);\n                    }\n                });\n\n                for (const protocolKey in groupedForPrint) {\n                    const group = groupedForPrint[protocolKey];\n                    if (group.isProtocol) {\n                        contentBodyHtml += `\n                            <div class=\"protocol-section\">\n                                <h3>${group.name}<\/h3>\n                                ${group.evidenceBase ? `<p><strong>Evidence Base:<\/strong> ${group.evidenceBase}<\/p>` : ''}\n                        `;\n                        for (const phaseKey in group.phases) {\n                            const phase = group.phases[phaseKey];\n                            contentBodyHtml += `\n                                <div class=\"protocol-phase\">\n                                    <h4>${phase.name}<\/h4>\n                            `;\n                            if (group.name === 'Otago Exercise Protocol (Fall Prevention)') {\n                                const otagoProtocol = libraryItems.find(p => p.id === 'otago-exercise-protocol');\n                                const orderedExerciseIds = otagoProtocol.phases.find(p => p.name === phase.name).exerciseIds;\n                                phase.items.sort((a, b) => orderedExerciseIds.indexOf(a.originalId) - orderedExerciseIds.indexOf(b.originalId));\n                            } else {\n                                phase.items.sort((a, b) => a.id - b.id);\n                            }\n\n                            phase.items.forEach((item, index) => {\n                                contentBodyHtml += generateExercisePrintHtml(item, index + 1);\n                            });\n                            contentBodyHtml += `<\/div>`;\n                        }\n                        contentBodyHtml += `<\/div>`;\n                    } else {\n                        contentBodyHtml += `<h3>Individual Exercises<\/h3>`;\n                        group.items.sort((a, b) => a.id - b.id);\n                        group.items.forEach((item, index) => {\n                            contentBodyHtml += generateExercisePrintHtml(item, index + 1);\n                        });\n                    }\n                }\n            }\n\n            contentBodyHtml += `\n                <div class=\"footer-section\">\n                    <p>For any questions, please contact your Physiotherapist.<\/p>\n                    ${serviceName ? `<p>${serviceName}<\/p>` : ''}\n                    <p class=\"important-note\"><strong>Important:<\/strong> Stop if you experience any pain, dizziness, or discomfort.<\/p>\n                    <p>Disclaimer: This exercise program is prescribed for your specific condition. Consult your Physiotherapist before making any changes.<\/p>\n                <\/div>\n            `;\n\n            \/\/ Wrap the body content with full HTML structure and styles for the new window\n            return `\n                <!DOCTYPE html>\n                <html lang=\"en\">\n                <head>\n                    <meta charset=\"UTF-8\">\n                    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n                    <title>Exercise Prescription - ${patientName || 'Patient'}<\/title>\n                    <link href=\"https:\/\/fonts.googleapis.com\/css2?family=Inter:wght@400;600;700&#038;display=swap\" rel=\"stylesheet\">\n                    <style>\n                        body { font-family: 'Inter', sans-serif; margin: 0; padding: 20px; color: #000; font-size: ${baseFontSize}; }\n                        h1 { font-size: 2em; font-weight: bold; text-align: center; color: #1e40af; margin-bottom: 15px; }\n                        h2 { font-size: 1.5em; font-weight: bold; color: #1d4ed8; margin-bottom: 10px; }\n                        h3 { font-size: 1.3em; font-weight: bold; color: #065f46; margin-bottom: 10px; }\n                        h4 { font-size: 1.1em; font-weight: bold; color: #1e40af; margin-bottom: 5px; }\n                        h5 { font-size: 1em; font-weight: bold; color: #065f46; margin-bottom: 5px; }\n                        p { margin-bottom: 5px; line-height: 1.4; }\n                        ul { list-style: disc; margin-left: 20px; margin-bottom: 10px; }\n                        ul.dosimetry-list { list-style: none; padding-left: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 5px; }\n                        strong { font-weight: bold; }\n                        .header-section { text-align: center; margin-bottom: 30px; }\n                        .patient-details-section { border: 1px solid #bfdbfe; padding: 15px; border-radius: 8px; background-color: #eff6ff; margin-bottom: 30px; }\n                        .exercise-program-title { text-align: center; margin-bottom: 20px; color: #065f46; }\n                        .protocol-section { border: 2px solid #a7f3d0; padding: 15px; margin-bottom: 25px; background-color: #ecfdf5; border-radius: 8px; page-break-inside: avoid; }\n                        .protocol-phase { border-left: 4px solid #34d399; padding-left: 10px; margin-top: 15px; margin-bottom: 15px; page-break-inside: avoid; }\n                        .exercise-item-print {\n                            display: grid;\n                            grid-template-columns: 120px 1fr;\n                            gap: 10px;\n                            padding: 10px;\n                            margin-bottom: 15px;\n                            border-bottom: 1px dashed #ccc;\n                            page-break-inside: avoid;\n                            background-color: #ffffff;\n                            border-radius: 8px;\n                            box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);\n                        }\n                        .exercise-item-print:last-child { border-bottom: none; }\n                        .exercise-item-print img {\n                            width: 100%;\n                            height: auto;\n                            max-width: 120px;\n                            border-radius: 4px;\n                            border: 1px solid #e5e7eb;\n                        }\n                        .exercise-item-print .image-container {\n                            display: flex;\n                            flex-direction: column;\n                            gap: 5px;\n                        }\n                        .footer-section { text-align: center; margin-top: 30px; padding-top: 15px; border-top: 1px solid #e5e7eb; color: #4b5563; font-size: 0.85em; }\n                        .important-note { color: #b91c1c; font-weight: bold; margin-top: 10px; }\n                    <\/style>\n                <\/head>\n                <body>\n                    ${contentBodyHtml}\n                <\/body>\n                <\/html>\n            `;\n        }\n\n        \/**\n         * Generates the HTML for a single exercise item in the printable\/exportable view.\n         * @param {object} item - The exercise item from currentPrescription.\n         * @param {number} displayIndex - The sequential number for display.\n         * @returns {string} HTML string for the exercise.\n         *\/\n        function generateExercisePrintHtml(item, displayIndex) {\n            return `\n                <div class=\"exercise-item-print\">\n                    <div class=\"image-container\">\n                        <img decoding=\"async\" src=\"${item.imageStart}\" alt=\"${item.name} Starting Position\" onerror=\"this.onerror=null;this.src='https:\/\/placehold.co\/120x80\/ccc\/000?text=Image+Not+Found';\">\n                        <img decoding=\"async\" src=\"${item.imageEnd}\" alt=\"${item.name} End Position\" onerror=\"this.onerror=null;this.src='https:\/\/placehold.co\/120x80\/ccc\/000?text=Image+Not+Found';\">\n                    <\/div>\n                    <div>\n                        <h4>${displayIndex}. ${item.name}<\/h4>\n                        <h5>Directions:<\/h5>\n                        <ul style=\"list-style: disc; margin-left: 15px; margin-bottom: 5px;\">\n                            ${item.directions.map(dir => `<li>${dir}<\/li>`).join('')}\n                        <\/ul>\n                        <h5>Dosimetry:<\/h5>\n                        <ul class=\"dosimetry-list\">\n                            ${item.sets > 0 ? `<li><strong>Sets:<\/strong> ${item.sets}<\/li>` : ''}\n                            ${item.reps > 0 ? `<li><strong>Reps:<\/strong> ${item.reps}<\/li>` : ''}\n                            ${item.holdTime > 0 ? `<li><strong>Hold Time:<\/strong> ${item.holdTime}s<\/li>` : ''}\n                            ${item.duration > 0 ? `<li><strong>Duration:<\/strong> ${item.duration}min<\/li>` : ''}\n                            <li><strong>Frequency:<\/strong> ${item.frequency}<\/li>\n                            ${item.restBetweenSets > 0 ? `<li><strong>Rest:<\/strong> ${item.restBetweenSets}s<\/li>` : ''}\n                        <\/ul>\n                        ${item.progressionAdvice ? `<p><strong>Progression:<\/strong> ${item.progressionAdvice}<\/p>` : ''}\n                        ${item.patientSpecificNotes ? `<p><strong>Notes:<\/strong> ${item.patientSpecificNotes}<\/p>` : ''}\n                    <\/div>\n                <\/div>\n            `;\n        }\n\n        \/\/ --- Renders the list of individual exercises and protocols in the library section.\n        \/\/ This function applies search and filter criteria.\n        function renderExerciseList() {\n            const searchTerm = exerciseSearch.value.toLowerCase();\n            const selectedCategory = categoryFilter.value;\n            const selectedDifficulty = difficultyFilter.value;\n\n            individualExerciseList.innerHTML = '';\n            protocolList.innerHTML = '';\n\n            libraryItems.forEach(item => {\n                const matchesSearch = searchTerm === '' ||\n                                      item.name.toLowerCase().includes(searchTerm) ||\n                                      (item.tags && item.tags.some(tag => tag.toLowerCase().includes(searchTerm))) ||\n                                      (item.description && item.description.toLowerCase().includes(searchTerm));\n                const matchesCategory = selectedCategory === '' || (item.tags && item.tags.includes(selectedCategory));\n                const matchesDifficulty = selectedDifficulty === '' || item.difficulty === selectedDifficulty;\n\n                if (matchesSearch && matchesCategory && matchesDifficulty) {\n                    const card = document.createElement('div');\n                    card.className = 'bg-white p-4 rounded-lg shadow-md flex flex-col items-center text-center border border-gray-200';\n\n                    const isAdded = isItemInPrescription(item);\n                    const buttonText = isAdded ? 'Added' : `Add ${item.type === 'exercise' ? 'Exercise' : 'Protocol'}`;\n                    const buttonClass = isAdded ? 'bg-gray-400 cursor-not-allowed' : 'bg-blue-500 hover:bg-blue-600';\n\n                    card.innerHTML = `\n                        <h3 class=\"text-lg font-semibold text-gray-800 mb-2\">${item.name}<\/h3>\n                        ${item.type === 'exercise' ? `\n                            <div class=\"flex-grow w-full mb-3\">\n                                <img decoding=\"async\" src=\"${item.imageStart}\" alt=\"${item.name} Start\" class=\"w-full h-32 object-cover rounded-md mb-2 border border-gray-300\" onerror=\"this.onerror=null;this.src='https:\/\/placehold.co\/400x250\/ccc\/000?text=Image+Not+Found';\">\n                                <img decoding=\"async\" src=\"${item.imageEnd}\" alt=\"${item.name} End\" class=\"w-full h-32 object-cover rounded-md border border-gray-300\" onerror=\"this.onerror=null;this.src='https:\/\/placehold.co\/400x250\/ccc\/000?text=Image+Not+Found';\">\n                            <\/div>\n                            <p class=\"text-sm text-gray-600 mb-2\">Difficulty: ${item.difficulty}<\/p>\n                            <p class=\"text-sm text-gray-600 mb-2\">Equipment: ${item.equipment}<\/p>\n                        ` : `\n                            <p class=\"text-sm text-gray-600 mb-2\">${item.description}<\/p>\n                            <p class=\"text-sm text-gray-600 mb-2\">Tags: ${item.tags.join(', ')}<\/p>\n                        `}\n                        <button data-id=\"${item.id}\" data-type=\"${item.type}\" class=\"add-to-prescription-btn ${buttonClass} text-white font-bold py-2 px-4 rounded-md w-full transition duration-150 ease-in-out\" ${isAdded ? 'disabled' : ''}>\n                            ${buttonText}\n                        <\/button>\n                    `;\n\n                    if (item.type === 'exercise') {\n                        individualExerciseList.appendChild(card);\n                    } else {\n                        protocolList.appendChild(card);\n                    }\n                }\n            });\n\n            \/\/ Add event listeners for the \"Add\" buttons\n            document.querySelectorAll('.add-to-prescription-btn').forEach(button => {\n                button.addEventListener('click', (event) => {\n                    const itemId = event.target.dataset.id;\n                    const itemType = event.target.dataset.type;\n                    addItemsToPrescription(itemId, itemType);\n                });\n            });\n        }\n\n\n        \/\/ --- Event Listeners ---\n        document.addEventListener('DOMContentLoaded', () => {\n            renderExerciseList(); \/\/ Initial render of the exercise library\n            renderPrescriptionList(); \/\/ Initial render of the prescription list (will show \"No exercises\" message)\n\n            exerciseSearch.addEventListener('input', renderExerciseList);\n            categoryFilter.addEventListener('change', renderExerciseList);\n            difficultyFilter.addEventListener('change', renderExerciseList);\n\n            generatePrescriptionBtn.addEventListener('click', () => {\n                const fullPrintHtml = generatePrescriptionContent(false);\n                const printWindow = window.open('', '_blank');\n                printWindow.document.write(fullPrintHtml);\n                printWindow.document.close(); \/\/ Important to close the document for rendering\n\n                \/\/ Add a small delay to ensure content is rendered before printing\n                printWindow.onload = function() {\n                    setTimeout(() => {\n                        printWindow.print();\n                        \/\/ printWindow.close(); \/\/ Optional: close the new window after printing\n                    }, 500); \/\/ 500ms delay\n                };\n            });\n\n            exportWordBtn.addEventListener('click', () => {\n                const content = generatePrescriptionContent(true);\n                const filename = `Exercise_Prescription_${patientNameInput.value.trim() || 'Patient'}_${new Date().toLocaleDateString('en-GB').replace(\/\\\/\/g, '-')}.doc`;\n\n                const blob = new Blob(['<html xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:w=\"urn:schemas-microsoft-com:office:word\" xmlns=\"http:\/\/www.w3.org\/TR\/REC-html40\"><head><meta charset=\"utf-8\"><title>Exercise Prescription<\/title><\/head><body>' + content + '<\/body><\/html>'], {\n                    type: 'application\/msword'\n                });\n\n                const link = document.createElement('a');\n                link.href = URL.createObjectURL(blob);\n                link.download = filename;\n                document.body.appendChild(link);\n                link.click();\n                document.body.removeChild(link);\n            });\n\n            printFontSizeSelect.addEventListener('change', (event) => {\n                const fontSize = event.target.value;\n                let baseFontSize = '11pt';\n                if (fontSize === 'small') {\n                    baseFontSize = '9pt';\n                } else if (fontSize === 'large') {\n                    baseFontSize = '13pt';\n                }\n                \/\/ This updates the CSS variable, which will be used when generatePrescriptionContent is called\n                document.documentElement.style.setProperty('--print-base-font-size', baseFontSize);\n            });\n\n            \/\/ Otago Phase Selection Event Listeners\n            confirmOtagoSelectionBtn.addEventListener('click', confirmOtagoPhaseSelection);\n            cancelOtagoSelectionBtn.addEventListener('click', cancelOtagoPhaseSelection);\n\n            \/\/ Global Dosimetry Event Listener\n            applyGlobalDosimetryBtn.addEventListener('click', applyGlobalDosimetry);\n        });\n    <\/script>\n<\/body>\n<\/html>\n\n","protected":false},"excerpt":{"rendered":"<p>Physiotherapy Exercise Prescription Tool Exercise Prescription Tool Patient &#038; Session Details Patient Name\/ID Physiotherapist Name Service Name Clinical Goal(s) Specific Instructions\/Precautions Exercise Library All CategoriesStrengthBalanceFlexibilityEnduranceFunctionalMobilityChair-basedBed-basedUpper Limb CoordinationStanding BalancePost-OpFracture RehabShoulderKneeAnkleWristHandCoreGlutesLower BackPostureFall PreventionWarm-upCool-down All DifficultiesVery EasyEasyModerateChallenging Individual Exercises Protocols Configure Otago Protocol Phases Select the phases you wish to include in the prescription: Cancel Add Selected Phases [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_mi_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"class_list":["post-131","page","type-page","status-publish","hentry"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/rehabilitationessentials.com\/index.php\/wp-json\/wp\/v2\/pages\/131","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/rehabilitationessentials.com\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/rehabilitationessentials.com\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/rehabilitationessentials.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/rehabilitationessentials.com\/index.php\/wp-json\/wp\/v2\/comments?post=131"}],"version-history":[{"count":2,"href":"https:\/\/rehabilitationessentials.com\/index.php\/wp-json\/wp\/v2\/pages\/131\/revisions"}],"predecessor-version":[{"id":218,"href":"https:\/\/rehabilitationessentials.com\/index.php\/wp-json\/wp\/v2\/pages\/131\/revisions\/218"}],"wp:attachment":[{"href":"https:\/\/rehabilitationessentials.com\/index.php\/wp-json\/wp\/v2\/media?parent=131"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}