Skip to content

19802-missing-validation-when-saving-without-adding-diagnosis#19912

Open
denuwanhendalage wants to merge 3 commits intodevelopmentfrom
19802-missing-validation-when-saving-without-adding-diagnosis
Open

19802-missing-validation-when-saving-without-adding-diagnosis#19912
denuwanhendalage wants to merge 3 commits intodevelopmentfrom
19802-missing-validation-when-saving-without-adding-diagnosis

Conversation

@denuwanhendalage
Copy link
Copy Markdown
Collaborator

@denuwanhendalage denuwanhendalage commented Apr 10, 2026

changes

  1. diagnoses.xhtml -> improve button UI, add warning message to save button
  2. DiagnosisController.java -> created field-specific validation messages, swapped the save message and update message to give a correct response.

Summary by CodeRabbit

  • Bug Fixes

    • Prevented saving diagnoses with blank or empty name or code fields.
  • New Features

    • Clarified success messages to distinguish creating vs updating diagnoses.
    • Save now refreshes status messages and the diagnosis detail view immediately.
  • Style

    • Updated diagnosis management UI with revised layout, button styling and icons, and improved message display.

Signed-off-by: denuwanhendalage <shashankadenuwanb@gmail.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 10, 2026

Walkthrough

Added input validation to diagnosis saving—checking that both current.name and current.code are non-null and non-blank (trimmed), emitting JsfUtil.addErrorMessage(...) and returning early on failure. Success message text was swapped for create vs edit. UI: growl given an ID, buttons restyled with icons, and save now updates growl and detail panel.

Changes

Cohort / File(s) Summary
Diagnosis Validation Logic
src/main/java/com/divudi/bean/clinical/DiagnosisController.java
Added null/blank (trimmed) checks for getCurrent().getName() and getCurrent().getCode() with JsfUtil.addErrorMessage(...) and early return on validation failure; preserved persistence flow and swapped success message wording between create and edit paths.
Diagnosis Management UI
src/main/webapp/emr/admin/diagnoses.xhtml
Added id="growlMsg" to <p:growl/>, restyled action buttons with FontAwesome icons and adjusted panel grid width (w-100w-80), and expanded the save command's update targets to include growlMsg and the detail panel (gpDetail).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding missing validation when saving a diagnosis without explicit creation.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 19802-missing-validation-when-saving-without-adding-diagnosis

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


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.

Signed-off-by: denuwanhendalage <shashankadenuwanb@gmail.com>
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/main/java/com/divudi/bean/clinical/DiagnosisController.java`:
- Around line 164-171: In DiagnosisController, the second validation block
incorrectly re-checks getCurrent().getName(); change it to validate
getCurrent().getCode() instead and keep the JsfUtil.addErrorMessage("Please
enter a Diagnosis Code before saving."); so the code field is actually
validated; update the condition referencing getCurrent().getCode() (and
trim()/isEmpty() as in the name check) to mirror the first validation block.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 17989bdc-3600-4608-845a-d83499c3a495

📥 Commits

Reviewing files that changed from the base of the PR and between b3a402f and e45f78a.

📒 Files selected for processing (2)
  • src/main/java/com/divudi/bean/clinical/DiagnosisController.java
  • src/main/webapp/emr/admin/diagnoses.xhtml

Comment thread src/main/java/com/divudi/bean/clinical/DiagnosisController.java
Signed-off-by: denuwanhendalage <shashankadenuwanb@gmail.com>
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/main/java/com/divudi/bean/clinical/DiagnosisController.java`:
- Around line 164-170: The growl component in clinical_diagnosis.xhtml needs an
id and the save button must update it so validation FacesMessages are shown: add
id="growlMsg" to the existing <p:growl/> (same element referenced in the review)
and include growlMsg in the save button's update attribute (alongside lstSelect
and selectFocus, e.g., update="growlMsg lstSelect selectFocus") to mirror the
working pattern used in emr/admin/diagnoses.xhtml; this ensures the
JsfUtil.addErrorMessage messages from the save logic in DiagnosisController (the
validation at getCurrent().getName()/getCode()) are rendered to users.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0448f262-936b-44b1-a892-bac786a5d48b

📥 Commits

Reviewing files that changed from the base of the PR and between e45f78a and ce57690.

📒 Files selected for processing (1)
  • src/main/java/com/divudi/bean/clinical/DiagnosisController.java

Comment thread src/main/java/com/divudi/bean/clinical/DiagnosisController.java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant