Skip to content

Fix indexes used when generating Patient Spreadsheet#2430

Open
sebastian-j-ibanez wants to merge 2 commits into
maintenancefrom
fix/issue-2119-generate-spreadsheet-list
Open

Fix indexes used when generating Patient Spreadsheet#2430
sebastian-j-ibanez wants to merge 2 commits into
maintenancefrom
fix/issue-2119-generate-spreadsheet-list

Conversation

@sebastian-j-ibanez

@sebastian-j-ibanez sebastian-j-ibanez commented May 16, 2026

Copy link
Copy Markdown
Collaborator

Changes made

  • Fix indexes used when initializing spreadsheet.
  • Update formatting.
  • Fix file name date/time.

Summary by Sourcery

Correct patient list spreadsheet generation and tidy response header formatting.

Bug Fixes:

  • Use distinct column indexes for province and postal code cells in the generated patient list spreadsheet.

Enhancements:

  • Reformat the HTTP Content-Disposition header string for improved readability.

Summary by cubic

Fix incorrect column indexes in GeneratePatientSpreadSheetList2Action so province and postal code populate their own columns instead of overwriting the city column in the exported patient list. Also cleans up minor download header formatting.

Written for commit abe089a. Summary will update on new commits. Review in cubic

@sebastian-j-ibanez sebastian-j-ibanez self-assigned this May 16, 2026
@sourcery-ai

sourcery-ai Bot commented May 16, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adjusts spreadsheet generation to use correct column indexes for province and postal code cells and applies minor formatting clean-up in the patient list export action.

Flow diagram for corrected spreadsheet cell indexes in GeneratePatientSpreadSheetList2Action

flowchart LR
    A[Loop demographics array] --> B[Create HSSFRow with sheet.createRow]
    B --> C[Set cell 0 to d.getFirstName]
    C --> D[Set cell 1 to d.getLastName]
    D --> E[Set cell 2 to d.getAddress]
    E --> F[Set cell 3 to d.getCity]
    F --> G[Set cell 4 to d.getProvince]
    G --> H[Set cell 5 to d.getPostal]
Loading

File-Level Changes

Change Details Files
Correct spreadsheet cell indexes for demographic province and postal code columns when generating the patient list workbook.
  • Update the province cell to be written to the next column after city instead of reusing the city column index.
  • Update the postal code cell to be written to the subsequent column instead of reusing the city column index.
  • Preserve existing column order: first name, last name, address, city, province, postal.
src/main/java/ca/openosp/openo/report/pageUtil/GeneratePatientSpreadSheetList2Action.java
Tidy up HTTP response header and surrounding code formatting in the patient list spreadsheet action.
  • Reformat the Content-Disposition header string literal onto multiple lines for readability.
  • Remove superfluous blank lines around field declarations and inside the main loop body.
src/main/java/ca/openosp/openo/report/pageUtil/GeneratePatientSpreadSheetList2Action.java

Possibly linked issues

  • #(not specified): PR updates province and postal cells to indexes 4 and 5, fixing the export overwrite bug described

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai

coderabbitai Bot commented May 16, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3b731c94-9407-441f-b61f-9a99f15c65d2

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/issue-2119-generate-spreadsheet-list

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 and usage tips.

@qodo-code-review

Copy link
Copy Markdown

Review Summary by Qodo

Fix cell indexes in patient spreadsheet generation

🐞 Bug fix

Grey Divider

Walkthroughs

Description
• Fix incorrect cell indexes in spreadsheet generation
  - Changed duplicate index 3 to correct indexes 4 and 5
  - Ensures Province and Postal data written to correct columns
• Clean up formatting and whitespace
  - Remove extra blank lines
  - Reformat long header line for readability
Diagram
flowchart LR
  A["Spreadsheet Generation"] --> B["Cell Index Mapping"]
  B --> C["Column 0: First Name"]
  B --> D["Column 1: Last Name"]
  B --> E["Column 2: Address"]
  B --> F["Column 3: City"]
  B --> G["Column 4: Province (Fixed)"]
  B --> H["Column 5: Postal (Fixed)"]
Loading

Grey Divider

File Changes

1. src/main/java/ca/openosp/openo/report/pageUtil/GeneratePatientSpreadSheetList2Action.java 🐞 Bug fix +4/-7

Fix spreadsheet cell indexes and formatting

• Fixed cell index bug where Province and Postal were both assigned to column 3
• Changed Province cell index from 3 to 4
• Changed Postal cell index from 3 to 5
• Removed extra blank lines for code cleanup
• Reformatted long Content-Disposition header line for better readability

src/main/java/ca/openosp/openo/report/pageUtil/GeneratePatientSpreadSheetList2Action.java


Grey Divider

ⓘ You are approaching your monthly quota for Qodo. Upgrade your plan

Qodo Logo

@qodo-code-review

qodo-code-review Bot commented May 16, 2026

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider


Remediation recommended

1. Wrong filename date format ✓ Resolved 🐞 Bug ≡ Correctness
Description
GeneratePatientSpreadSheetList2Action builds the download filename using the pattern
yyyy-mm-dd.hh.mm.ss, which uses mm (minutes) where month formatting in this codebase uses MM,
producing incorrect/misleading filenames. This can also increase the chance of confusing or
colliding filenames when users sort or compare exports by date.
Code

src/main/java/ca/openosp/openo/report/pageUtil/GeneratePatientSpreadSheetList2Action.java[R68-69]

+        response.setHeader("Content-Disposition", "attachment; filename=\"patientlist_spreadsheet-"
+                + UtilDateUtilities.getToday("yyyy-mm-dd.hh.mm.ss") + ".xls\"");
Evidence
The action constructs the attachment filename using
UtilDateUtilities.getToday("yyyy-mm-dd.hh.mm.ss"). UtilDateUtilities.getToday passes the pattern
to SimpleDateFormat, and the same utility class uses "MM" for months in justMonth(),
demonstrating that mm is not the intended token for months in this codebase.

src/main/java/ca/openosp/openo/report/pageUtil/GeneratePatientSpreadSheetList2Action.java[64-70]
src/main/java/ca/openosp/openo/util/UtilDateUtilities.java[203-210]
src/main/java/ca/openosp/openo/util/UtilDateUtilities.java[87-96]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The spreadsheet download filename uses `UtilDateUtilities.getToday("yyyy-mm-dd.hh.mm.ss")`. In this codebase, month formatting uses `MM`, so using `mm` in the date portion results in minutes being placed where the month should be.
### Issue Context
`UtilDateUtilities.getToday` delegates directly to `SimpleDateFormat`, so the provided pattern is interpreted literally by Java date formatting.
### Fix Focus Areas
- src/main/java/ca/openosp/openo/report/pageUtil/GeneratePatientSpreadSheetList2Action.java[64-70]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Qodo Logo

@cubic-dev-ai cubic-dev-ai 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.

No issues found across 1 file

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

@sebastian-j-ibanez sebastian-j-ibanez changed the title fix: use correct cell indexes in GeneratePatientSpreadSheetList2Actio… Fix indexes used when generating Patient Spreadsheet May 16, 2026

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request cleans up whitespace and fixes a bug in the patient spreadsheet generation where multiple data fields were being written to the same column index. A review comment correctly identifies a logic error in the date format string used for the filename, where minutes were used instead of months, and provides a suggestion to fix it.

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

Hey - I've left some high level feedback:

  • Consider extracting the spreadsheet column indices (0–5) into named constants or an enum to make the column layout clearer and less error-prone to modify in the future.
  • The workbook/response stream handling could be improved by using try-with-resources around the HSSFWorkbook and output stream to ensure resources are closed reliably even if an exception occurs.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider extracting the spreadsheet column indices (0–5) into named constants or an enum to make the column layout clearer and less error-prone to modify in the future.
- The workbook/response stream handling could be improved by using try-with-resources around the `HSSFWorkbook` and output stream to ensure resources are closed reliably even if an exception occurs.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

…SpreadSheetList2Action.java

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Signed-off-by: Sebastian Ibanez <91081658+sebastian-j-ibanez@users.noreply.github.com>

@LiamStanziani LiamStanziani left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good to me

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: Patient list export overwrites city/province with postal code (column 3 bug)

2 participants