Skip to content

fix: documents do not follow display document preferences#344

Merged
yingbull merged 3 commits intodevelop/coyotefrom
325-documents-do-not-follow-display-document-preferences
Jul 3, 2025
Merged

fix: documents do not follow display document preferences#344
yingbull merged 3 commits intodevelop/coyotefrom
325-documents-do-not-follow-display-document-preferences

Conversation

@LiamStanziani
Copy link
Copy Markdown
Collaborator

@LiamStanziani LiamStanziani commented Jul 2, 2025

Added a fix to ensure that the document property uses the correct field in the database. Fixed issue where image file types were not being set in document manager

Summary by Sourcery

Fix retrieval and storage of display document preferences using the correct property constant and ensure document content types are set correctly based on file extension

Bug Fixes:

  • Retrieve and save displayDocumentAs preference using UserProperty.DISPLAY_DOCUMENT_AS constant
  • Derive and set contentType for non-PDF files from their extension while preserving existing PDF handling and page count

@LiamStanziani LiamStanziani linked an issue Jul 2, 2025 that may be closed by this pull request
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai bot commented Jul 2, 2025

Reviewer's Guide

This PR corrects the retrieval and persistence of the display document preference by replacing the hardcoded property name with the UserProperty.DISPLAY_DOCUMENT_AS constant, and restores contentType assignment in the document manager by inferring and setting the MIME type for non-PDF files based on their file extension.

Class diagram for UserProperty display document preference fix

classDiagram
    class ProviderProperty2Action {
        +String viewDisplayDocumentAs()
        +String saveDisplayDocumentAs()
    }
    class UserProperty {
        +String DISPLAY_DOCUMENT_AS
        +String getName()
        +void setName(String)
        +String getValue()
        +void setValue(String)
    }
    ProviderProperty2Action --> UserProperty : uses
    note for ProviderProperty2Action "Now uses UserProperty.DISPLAY_DOCUMENT_AS instead of hardcoded string for property name"
Loading

Class diagram for AddEditDocument2Action contentType assignment

classDiagram
    class AddEditDocument2Action {
        -boolean addDocument(HttpServletRequest request)
    }
    class Document {
        +void setContentType(String)
        +void setNumberOfPages(int)
    }
    AddEditDocument2Action --> Document : sets contentType
    note for AddEditDocument2Action "Now infers contentType for non-PDF files from file extension"
Loading

File-Level Changes

Change Details Files
Replaced hardcoded preference key with constant for display document preferences
  • Use UserProperty.DISPLAY_DOCUMENT_AS instead of literal string in getProp calls
  • Replace hardcoded name with constant in setName when saving preference
src/main/java/org/oscarehr/provider/web/ProviderProperty2Action.java
Restore contentType assignment for non-PDF documents
  • Add else branch to infer contentType from file extension
  • Ensure contentType is always set for both PDF and non-PDF files
src/main/java/org/oscarehr/documentManager/actions/AddEditDocument2Action.java

Possibly linked issues

  • #0: The PR fixes the display document preference setting which caused documents to always display as images, directly addressing the issue.

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

@LiamStanziani LiamStanziani requested a review from yingbull July 2, 2025 18:40
@LiamStanziani LiamStanziani self-assigned this Jul 2, 2025
@yingbull yingbull merged commit 7054579 into develop/coyote Jul 3, 2025
10 of 11 checks passed
@yingbull yingbull deleted the 325-documents-do-not-follow-display-document-preferences branch July 3, 2025 18:23
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.

Documents do not follow display document preferences

2 participants