feat: Export Health Reports (PDF) (#217) - #291
Conversation
|
@Dev1822 is attempting to deploy a commit to the vallabhatech's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
Warning Review limit reached
Next review available in: 49 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughThe health report export flow now retrieves up to 100 symptom checks, displays symptom history in the export preview, and includes symptom details in generated PDFs. The dashboard links to the export page, and the application registers the new route. ChangesHealth report export
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 5
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@server/utils/pdfGenerator.js`:
- Around line 237-248: The symptom rendering loop currently limits output to 20
checks despite the route and user-facing PDF description supporting up to 100.
Update the slice in the symptom rendering block to render up to 100 checks while
preserving the existing page-break and formatting logic.
- Around line 243-245: Update the symptom-history rendering block to select the
highest-probability result rather than assuming check.results[0] is ordered.
Sort check.results by probability descending, then use the first sorted result
for the “Probable Condition” text while preserving the existing output format.
In `@src/App.jsx`:
- Around line 342-360: The App component’s render tree must restore the
ToastProvider wrapper around the routes and include ToastContainer so existing
useToast consumers function correctly. Update the JSX around Navbar, Routes,
ScrollToTopButton, and Footer to place these elements within the provider while
preserving the current routing structure.
In `@src/pages/Dashboard.jsx`:
- Around line 146-153: Localize the export-report card in the dashboard data
definition by adding appropriate dashboard translation keys and replacing its
literal title, description, and button label with useTranslation’s t(...) calls.
Preserve the existing link and icon while ensuring all visible text uses the
established translation namespace.
In `@src/pages/HealthReportExport.jsx`:
- Around line 30-37: Update the symptom data request in the Promise.all block of
HealthReportExport to use a bounded report-summary endpoint or capped query
instead of fetching the complete /api/symptom-checks history. Return only the
symptom count and latest-100-record status required by the preview, and adjust
setSymptoms to consume that summary without loading unnecessary sensitive
records.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 5ab1339e-7550-46b2-9bb4-3b2ccc08c9e9
📒 Files selected for processing (5)
server/routes/reports.jsserver/utils/pdfGenerator.jssrc/App.jsxsrc/pages/Dashboard.jsxsrc/pages/HealthReportExport.jsx
| <Navbar /> | ||
| <div style={{ paddingTop: 80, minHeight: '100vh' }}> | ||
| <Routes> | ||
| <Route path="/" element={<Dashboard />} /> | ||
| <Route path="/dashboard" element={<Dashboard />} /> | ||
| <Route path="/medicine-tracker" element={<MedicineTracker />} /> | ||
| <Route path="/symptom-checker" element={<SymptomChecker />} /> | ||
| <Route path="/clinics-nearby" element={<ClinicsNearby />} /> | ||
| <Route path="/dosage-calculator" element={<DosageCalculator />} /> | ||
| <Route path="/health-metrics" element={<HealthMetrics />} /> | ||
| <Route path="/settings" element={<Settings />} /> | ||
| <Route path="/login" element={<Login />} /> | ||
| <Route path="/profile" element={<Profile />} /> | ||
| <Route path="/export-report" element={<HealthReportExport />} /> | ||
| <Route path="*" element={<NotFound />} /> | ||
| </Routes> | ||
| </div> | ||
| <ScrollToTopButton /> | ||
| <Footer /> |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Find toast providers, containers, hooks, and direct toast calls.
rg -n -C 3 --glob '*.{js,jsx,ts,tsx}' \
'(ToastProvider|ToastContainer|useToast\b|\btoast\s*\()' srcRepository: vallabhatech/CareSync
Length of output: 1903
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "Files with toast-related symbols:"
rg -n --glob '*.{js,jsx,ts,tsx}' '(ToastProvider|ToastContainer|useToast\b|\btoast\s*\()' src
echo
echo "App.jsx imports and top-level elements:"
sed -n '1,80p' src/App.jsx
sed -n '320,365p' src/App.jsx
echo
echo "Context implementation:"
cat -n src/context/ToastContext.jsx
echo
echo "Component implementation:"
cat -n src/components/Toast.jsxRepository: vallabhatech/CareSync
Length of output: 8929
Restore the toast wrapping or remove toast usage.
App.jsx imports useToast, and ToastContainer also calls useToast, but App.jsx no longer wraps the app in ToastProvider. Existing toast consumers will throw instead of showing notifications; keep both ToastProvider and ToastContainer in the render tree unless all toast usage is removed/migrated.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/App.jsx` around lines 342 - 360, The App component’s render tree must
restore the ToastProvider wrapper around the routes and include ToastContainer
so existing useToast consumers function correctly. Update the JSX around Navbar,
Routes, ScrollToTopButton, and Footer to place these elements within the
provider while preserving the current routing structure.
| const [metricsRes, medRes, symptomRes] = await Promise.all([ | ||
| API.get('/api/health-metrics'), | ||
| API.get('/api/medicines'), | ||
| API.get('/api/symptom-checks'), | ||
| ]); | ||
| setMetrics(metricsRes.data); | ||
| setMedicines(medRes.data); | ||
| setSymptoms(symptomRes.data); |
There was a problem hiding this comment.
🚀 Performance & Scalability | 🟠 Major | ⚡ Quick win
Do not fetch the complete symptom history for this preview.
The /api/symptom-checks endpoint returns all matching records, but this page only uses symptoms.length. A long history increases response size and client memory without improving the preview. It also transfers more sensitive health data than this screen needs.
Add a bounded report-summary endpoint or a capped query that returns only the required count and the latest 100-record status.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/pages/HealthReportExport.jsx` around lines 30 - 37, Update the symptom
data request in the Promise.all block of HealthReportExport to use a bounded
report-summary endpoint or capped query instead of fetching the complete
/api/symptom-checks history. Return only the symptom count and latest-100-record
status required by the preview, and adjust setSymptoms to consume that summary
without loading unnecessary sensitive records.
|



Description
This PR implements the "Export Health Reports" feature, allowing users to generate and download a comprehensive PDF summary of their health data to share with their healthcare providers.
The implementation integrates a backend PDF generation utility using
pdfkitthat aggregates the user's patient information, tracked health metrics, current medications, and recent symptom history. The frontend has been updated with a new/export-reportpreview page, which is accessible directly from a new card on the user Dashboard.Fixes #217
Type of change
How Has This Been Tested?
Please describe the tests that you ran to verify your changes.
HealthReportExportpreview page correctly fetches and displays the count of the user's health metrics, medicines, and symptom checks.Checklist:
Summary by CodeRabbit