Skip to content

feat: Export Health Reports (PDF) (#217) - #291

Open
Dev1822 wants to merge 4 commits into
vallabhatech:mainfrom
Dev1822:feature/export-health-reports
Open

feat: Export Health Reports (PDF) (#217)#291
Dev1822 wants to merge 4 commits into
vallabhatech:mainfrom
Dev1822:feature/export-health-reports

Conversation

@Dev1822

@Dev1822 Dev1822 commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

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 pdfkit that aggregates the user's patient information, tracked health metrics, current medications, and recent symptom history. The frontend has been updated with a new /export-report preview page, which is accessible directly from a new card on the user Dashboard.

Fixes #217

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes.

  • Manually verified the HealthReportExport preview page correctly fetches and displays the count of the user's health metrics, medicines, and symptom checks.
  • Manually triggered the PDF generation and verified that the downloaded file successfully renders the Patient Information, Health Metrics history, Medicine Schedule, and Symptom History correctly without formatting issues.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works

Summary by CodeRabbit

  • New Features
    • Added a Health Report Export page accessible from the dashboard.
    • Users can preview and download PDF health reports containing metrics, medicines, and up to 100 symptom checks.
    • Symptom history includes dates, reported symptoms, probable conditions, risk levels, and probabilities.
    • Added clear handling for reports without symptom history and improved multi-page report formatting.

@vercel

vercel Bot commented Jul 20, 2026

Copy link
Copy Markdown

@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.

@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@Dev1822, you've reached your PR review limit, so we couldn't start this review.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: b8b539c6-026d-42c4-804b-9712fea509e8

📥 Commits

Reviewing files that changed from the base of the PR and between 3028e17 and c0232b7.

📒 Files selected for processing (5)
  • server/routes/symptomChecks.js
  • server/utils/pdfGenerator.js
  • src/i18n/locales/en.json
  • src/pages/Dashboard.jsx
  • src/pages/HealthReportExport.jsx
📝 Walkthrough

Walkthrough

The 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.

Changes

Health report export

Layer / File(s) Summary
Export route and dashboard entry
src/App.jsx, src/pages/Dashboard.jsx
The application adds the /export-report route and the dashboard adds an Export Health Report feature card.
Symptom data loading and preview
src/pages/HealthReportExport.jsx
The export page loads symptom checks with metrics and medicines. It displays symptom-history information and updates the report description.
PDF symptom rendering
server/routes/reports.js, server/utils/pdfGenerator.js
The report route loads recent symptom checks. The PDF generator renders symptom details, probable conditions, probabilities, risk levels, empty states, and pagination.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested labels: backend, testing

Suggested reviewers: kiranhk-code

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning Removing ToastProvider and ToastContainer is unrelated to the health report export requirements in [#217]. Move the toast provider removal to a separate pull request or document its direct requirement for this feature.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: adding PDF health report export functionality.
Linked Issues check ✅ Passed The changes add report access, data fetching, PDF generation, and sections for metrics, medicines, and symptom history required by issue [#217].
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request frontend ui/ux labels Jul 27, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 74ce1e9 and 3028e17.

📒 Files selected for processing (5)
  • server/routes/reports.js
  • server/utils/pdfGenerator.js
  • src/App.jsx
  • src/pages/Dashboard.jsx
  • src/pages/HealthReportExport.jsx

Comment thread server/utils/pdfGenerator.js Outdated
Comment thread server/utils/pdfGenerator.js
Comment thread src/App.jsx
Comment on lines +342 to +360
<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 />

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 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*\()' src

Repository: 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.jsx

Repository: 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.

Comment thread src/pages/Dashboard.jsx
Comment on lines +30 to +37
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);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀 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.

@sonarqubecloud

sonarqubecloud Bot commented Aug 4, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request frontend ui/ux

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Export Health Reports (PDF)

1 participant