Skip to content

Conversation

@damithdeshan98
Copy link
Collaborator

@damithdeshan98 damithdeshan98 commented Jan 5, 2026

Signed-off-by: damithdeshan98 [email protected]

Summary by CodeRabbit

Release Notes

  • New Features
    • Added Ward Admission Diagnosis Card feature with print and close functionality
    • Added Local Surgery Diagnosis Card feature with print and close functionality
    • Introduced new dialogs to view and interact with both diagnosis card types across clinical data and admission profile sections
    • Labeled existing diagnosis card as "Diagnosis Card (Legacy)" for clarity

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 5, 2026

Walkthrough

The changes introduce diagnosis card template support to the inpatient clinical data workflow. A new dependency injection of ConfigOptionApplicationController was added to InpatientClinicalDataController, along with methods to load Ward Admission and Local Surgery diagnosis card templates, perform HTML variable substitution, and expose the rendered HTML. Corresponding UI updates add buttons and dialogs in two view files to trigger and display these new diagnosis card types.

Changes

Cohort / File(s) Summary
Backend Controller - Diagnosis Card Support
src/main/java/com/divudi/bean/inward/InpatientClinicalDataController.java
Added ConfigOptionApplicationController dependency injection; introduced three new private String fields (wardAdmissionDiagnosisCardHtml, localSurgeryDiagnosisCardHtml, selectedDiagnosisCardTypeHtml); added loadWardAdmissionDiagnosisCard() and loadLocalSurgeryDiagnosisCard() methods to load templates via controller and build variable replacements from encounter data; added replaceVariablesInHtml() utility method; added getters/setters for all three new fields.
Frontend UI - Diagnosis Card Dialogs & Buttons
src/main/webapp/inward/admission_profile.xhtml, src/main/webapp/inward/clinical_data.xhtml
Added two new AJAX buttons (Ward Admission Card and Local Surgery Card) triggering the new controller actions; added two new dialogs (wardDiagnosisDlgDashboard/wardDiagnosisDlg and surgeryDiagnosisDlgDashboard/surgeryDiagnosisDlg) that render the HTML from the controller properties; each dialog includes Print and Close buttons; clinical_data.xhtml also added a new "Diagnosis Card Types Section" with additional button options; renamed existing diagnosis button to "(Legacy)".

Sequence Diagram(s)

sequenceDiagram
    participant UI as UI / View
    participant Controller as InpatientClinicalDataController
    participant ConfigCtrl as ConfigOptionApplicationController
    participant UI2 as Dialog / Renderer

    UI->>Controller: loadWardAdmissionDiagnosisCard()
    activate Controller
    Controller->>ConfigCtrl: retrieve template (Ward Admission)
    activate ConfigCtrl
    ConfigCtrl-->>Controller: HTML template
    deactivate ConfigCtrl
    
    Note over Controller: Build replacements map<br/>from current encounter
    Controller->>Controller: replaceVariablesInHtml(template, replacements)
    activate Controller
    Controller-->>Controller: rendered HTML
    deactivate Controller
    
    Controller->>Controller: set wardAdmissionDiagnosisCardHtml
    Controller-->>UI: response (AJAX complete)
    deactivate Controller
    
    UI->>UI2: show wardDiagnosisDlg
    Note over UI2: Render wardAdmissionDiagnosisCardHtml
    UI2->>UI2: Print or Close action
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 21.43% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title check ❓ Inconclusive The title is incomplete and truncated, ending with 'Surge' instead of the full intended name, making it vague and unclear about the complete scope of the changes. Complete the title to fully describe the functionality being added, e.g., 'Add Ward Admission and Local Surgery Diagnosis Card functionality' for clarity.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings

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.

Copy link
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: 3

Fix all issues with AI Agents 🤖
In @src/main/java/com/divudi/bean/inward/InpatientClinicalDataController.java:
- Around line 493-527: Reset the diagnosis card HTML state at the start of each
loader and ensure encounter/patient lists are populated before building
replacements: in loadWardAdmissionDiagnosisCard() and
loadLocalSurgeryDiagnosisCard() clear wardAdmissionDiagnosisCardHtml /
localSurgeryDiagnosisCardHtml and selectedDiagnosisCardTypeHtml immediately,
then if current != null call fillCurrentPatientLists(current.getPatient()) and
fillCurrentEncounterLists(current) before invoking
createReplacementsMap(current) and replaceVariablesInHtml(...); this prevents
stale HTML on early returns and avoids NPEs inside createReplacementsMap when
encounter/patient lists are null.

In @src/main/webapp/inward/admission_profile.xhtml:
- Around line 348-373: The Ward and Local Surgery buttons call
inpatientClinicalDataController.loadWardAdmissionDiagnosisCard and
loadLocalSurgeryDiagnosisCard but never set
inpatientClinicalDataController.current from admissionController.current,
causing a null-current early return; fix by adding a pre-action sync such as an
<f:setPropertyActionListener> (value="#{admissionController.current}"
target="#{inpatientClinicalDataController.current}") or an actionListener that
sets inpatientClinicalDataController.current before invoking the
loadWardAdmissionDiagnosisCard / loadLocalSurgeryDiagnosisCard actions so the
controller has the selected encounter (alternatively mirror how
navigateToInpatientClinicalData() assigns current).

In @src/main/webapp/inward/clinical_data.xhtml:
- Around line 59-80: The button labels are inconsistent and duplicate concepts
across header and tab sections, causing confusion; update the value attributes
so wording is consistent across both places (use either "Ward Admission
Diagnosis Card" and "Local Surgery Diagnosis Card" everywhere) and/or remove
duplicate buttons if redundant; specifically harmonize the values for the
p:commandButton elements that call
inpatientClinicalDataController.loadWardAdmissionDiagnosisCard /
loadLocalSurgeryDiagnosisCard and ensure the oncomplete targets
PF('wardDiagnosisDialog') and PF('surgeryDiagnosisDialog') match the chosen
labels so header shortcuts and tab labels consistently refer to the same dialog
and controller actions.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/main/webapp/inward/admission_profile.xhtml (1)

602-615: Duplicate </h:form>, </ui:define>, </ui:composition> – invalid view structure

There are two consecutive sets of closing tags for h:form, ui:define, and ui:composition (Lines 602–604 and again 613–615). This will produce invalid XHTML/Facelets and can break view compilation.

Remove one of the duplicate sets so that each of these elements is closed exactly once.

🧹 Nitpick comments (3)
src/main/webapp/inward/admission_profile.xhtml (1)

548-600: Ward/Local Surgery dashboard dialogs look structurally correct

The new dashboard dialogs (widgetVars wardDiagnosisDialogDashboard and surgeryDiagnosisDialogDashboard) are inside the JSF form, use h:panelGroup as the AJAX/print target, and render the HTML via h:outputText escape="false" as expected for pre-rendered HTML fragments. The Print and Close buttons are wired correctly to p:printer and PF(...).hide().

If you want to avoid an unnecessary server round-trip for Print/Close (they don’t rely on server-side state changes), you could set ajax="false" and/or use type="button" with pure client-side handlers, but the current implementation is functionally fine.

src/main/webapp/inward/clinical_data.xhtml (1)

666-718: Diagnosis card dialogs are wired correctly; consider small UX optimization

The new wardDiagnosisDlg / surgeryDiagnosisDlg dialogs correctly:

  • Use h:panelGroup as the AJAX/print target (wardDiagnosisPanel, surgeryDiagnosisPanel).
  • Render the HTML fragments from inpatientClinicalDataController with escape="false".
  • Provide Print buttons targeting the respective panels and Close buttons that hide the dialog via PF(...).hide().

Functionally this is sound. If you want to reduce server round-trips, you could switch the Print/Close buttons to ajax="false" (or type="button" with purely client-side handlers), since they don’t need to hit the server.

src/main/java/com/divudi/bean/inward/InpatientClinicalDataController.java (1)

532-540: replaceVariablesInHtml is correct but tightly coupled to {...} key format

The implementation:

for (Map.Entry<String, String> replacement : replacements.entrySet()) {
    if (replacement.getValue() != null) {
        result = result.replace(
            "{{" + replacement.getKey().substring(1, replacement.getKey().length() - 1) + "}}",
            replacement.getValue()
        );
    }
}

assumes all replacement keys are of the form "{name}" and converts them to {{name}} for HTML templates. That matches the current createReplacementsMap keys and works as long as templates consistently use {{...}} placeholders.

If you want this utility to be more generally reusable and less brittle against future changes in key format, you could:

  • Store plain keys without braces in the map (e.g., "name") and let this method decide whether to look for {name} or {{name}}, or
  • Store the exact placeholder string (e.g., "{{name}}") as the key and just call result.replace(key, value).

Not a blocker, but it will make template evolution safer.

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0bc8dd7 and 3fc3fa0.

📒 Files selected for processing (3)
  • src/main/java/com/divudi/bean/inward/InpatientClinicalDataController.java
  • src/main/webapp/inward/admission_profile.xhtml
  • src/main/webapp/inward/clinical_data.xhtml
🧰 Additional context used
📓 Path-based instructions (6)
**/*.{xhtml,java}

📄 CodeRabbit inference engine (AGENTS.md)

Implement accessibility with proper tooltips and labeling

Files:

  • src/main/webapp/inward/admission_profile.xhtml
  • src/main/webapp/inward/clinical_data.xhtml
  • src/main/java/com/divudi/bean/inward/InpatientClinicalDataController.java
**/*.{java,xhtml}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{java,xhtml}: Use webUserController.hasPrivilege() for UI privilege integration
Use configOptionApplicationController for dynamic configuration values

Files:

  • src/main/webapp/inward/admission_profile.xhtml
  • src/main/webapp/inward/clinical_data.xhtml
  • src/main/java/com/divudi/bean/inward/InpatientClinicalDataController.java
**/*.{xhtml,css}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{xhtml,css}: For UI improvements, limit work to XHTML/CSS/PrimeFaces unless backend changes are explicitly requested
Prefer PrimeFaces button classes (e.g., ui-button-success, ui-button-warning) over Bootstrap button classes

Files:

  • src/main/webapp/inward/admission_profile.xhtml
  • src/main/webapp/inward/clinical_data.xhtml
**/*.xhtml

📄 CodeRabbit inference engine (AGENTS.md)

**/*.xhtml: Escape & as &amp; in XML/XHTML attribute values; maintain standard HTML DOCTYPE with ui:composition templating
Use h:outputText for headings/labels rather than raw HTML heading tags in XHTML

**/*.xhtml: Never use plain HTML elements (div, span, etc.) with id attributes for AJAX updates; use JSF components (h:panelGroup, p:outputPanel, etc.) instead
Never use rendered attribute on plain HTML elements; JSF ignores it; use JSF components like h:panelGroup with layout="block" instead
Use selectionMode="multiple" on dataTable and selectionBox="true" on column for PrimeFaces DataTable selection (NOT selectionMode on column)
Use PrimeFaces p:resolveFirstComponentWithId function for component updates in AJAX operations instead of CSS/jQuery selectors
Never use PrimeFaces CSS/jQuery selectors like @(.class), @(#id), @parent, etc. in update or process attributes; use @this, @form, explicit component IDs, or p:resolveFirstComponentWithId
Use h:outputText instead of HTML headings (h1-h6) in ERP UI
Use PrimeFaces button classes instead of Bootstrap in UI development
Always escape ampersands as &amp; in XHTML attributes

Files:

  • src/main/webapp/inward/admission_profile.xhtml
  • src/main/webapp/inward/clinical_data.xhtml
**/*Controller.java

📄 CodeRabbit inference engine (AGENTS.md)

Reuse existing controller properties and methods; avoid introducing new filtered values, global filters, or backend logic for UI-only tasks

Files:

  • src/main/java/com/divudi/bean/inward/InpatientClinicalDataController.java
**/*.java

📄 CodeRabbit inference engine (AGENTS.md)

Do not 'fix' intentional typos in model/controller property names used for database compatibility

Files:

  • src/main/java/com/divudi/bean/inward/InpatientClinicalDataController.java
🧠 Learnings (29)
📓 Common learnings
Learnt from: buddhika75
Repo: hmislk/hmis PR: 0
File: :0-0
Timestamp: 2025-09-01T22:35:24.496Z
Learning: buddhika75 in PR #15249 implemented comprehensive privilege security fixes for pharmacy stock adjustment functionality, including dual privilege requirements (PharmacyAdjustmentDepartmentStockBySingleItemQTY AND PharmacyStockAdjustmentSingleItem), UI access control with unauthorized messages, and proper privilege tree structure in UserPrivilageController.java. Demonstrates systematic security implementation and thorough cross-validation.
Learnt from: buddhika75
Repo: hmislk/hmis PR: 0
File: :0-0
Timestamp: 2025-09-01T22:35:24.496Z
Learning: buddhika75 successfully implemented comprehensive dual-privilege security for pharmacy stock adjustment functionality in PR #15249. The implementation includes proper privilege tree structure, dual privilege requirements (PharmacyAdjustmentDepartmentStockBySingleItemQTY AND PharmacyStockAdjustmentSingleItem), unauthorized access prevention with clear messages, complete UI gating, and deep-link protection across all affected XHTML files.
Learnt from: buddhika75
Repo: hmislk/hmis PR: 14791
File: pr_description_substitute_functionality.md:69-74
Timestamp: 2025-08-08T13:42:59.349Z
Learning: In PR hmislk/hmis#14791, buddhika75 decided to defer adding a transactional boundary for replaceSelectedSubstitute() (and related flows) to a future change. If a follow-up issue is created, assign it to buddhika75 and keep this PR focused on substitute UX/validation improvements.
Learnt from: buddhika75
Repo: hmislk/hmis PR: 15798
File: src/main/java/com/divudi/bean/clinic/ClinicController.java:5583-5584
Timestamp: 2025-10-10T14:10:03.618Z
Learning: For hmislk/hmis, when a fix is deferred, buddhika75 prefers a separate GitHub issue to track it and to be assigned to themselves; e.g., create an issue for ClinicController single-payment Staff_Welfare handling gap and link back to the PR/comment.
Learnt from: RaveeshaPeiris
Repo: hmislk/hmis PR: 16704
File: src/main/webapp/reports/inpatientReports/ip_unsettled_invoices.xhtml:0-0
Timestamp: 2025-12-05T07:27:55.890Z
Learning: In PR #16704, RaveeshaPeiris confirmed that src/main/webapp/reports/inpatientReports/ip_unsettled_invoices.xhtml contains intentional placeholder dropdowns for wireframe work (Sponsor, Patient Category, Admission Types, Payment Mode, Room Category) with empty value="" bindings. Backend bindings and data integration will be added in a later PR. This is wireframe-only work.
Learnt from: RaveeshaPeiris
Repo: hmislk/hmis PR: 16704
File: src/main/webapp/reports/inpatientReports/ip_unsettled_invoices.xhtml:0-0
Timestamp: 2025-12-05T07:29:50.729Z
Learning: In PR #16704, RaveeshaPeiris confirmed that the Branch, Department, Consultant, Service Center, and Discharge Type dropdowns in src/main/webapp/reports/inpatientReports/ip_unsettled_invoices.xhtml are intentional placeholder wireframe work with empty value="" bindings. Backend bindings and data integration will be added in a later PR.
Learnt from: DhaneshKaushan
Repo: hmislk/hmis PR: 16790
File: src/main/webapp/reports/managementReports/surgery_count_type.xhtml:20-30
Timestamp: 2025-11-24T07:14:42.869Z
Learning: In src/main/webapp/reports/managementReports/surgery_count_type.xhtml for PR #16790, DhaneshKaushan confirmed this is wireframe-only work for Surgery Count (Type) report, intentionally deferring value bindings and backend integration to a later PR.
📚 Learning: 2025-11-24T07:14:42.869Z
Learnt from: DhaneshKaushan
Repo: hmislk/hmis PR: 16790
File: src/main/webapp/reports/managementReports/surgery_count_type.xhtml:20-30
Timestamp: 2025-11-24T07:14:42.869Z
Learning: In src/main/webapp/reports/managementReports/surgery_count_type.xhtml for PR #16790, DhaneshKaushan confirmed this is wireframe-only work for Surgery Count (Type) report, intentionally deferring value bindings and backend integration to a later PR.

Applied to files:

  • src/main/webapp/inward/admission_profile.xhtml
  • src/main/webapp/inward/clinical_data.xhtml
📚 Learning: 2025-12-05T07:27:55.890Z
Learnt from: RaveeshaPeiris
Repo: hmislk/hmis PR: 16704
File: src/main/webapp/reports/inpatientReports/ip_unsettled_invoices.xhtml:0-0
Timestamp: 2025-12-05T07:27:55.890Z
Learning: In PR #16704, RaveeshaPeiris confirmed that src/main/webapp/reports/inpatientReports/ip_unsettled_invoices.xhtml contains intentional placeholder dropdowns for wireframe work (Sponsor, Patient Category, Admission Types, Payment Mode, Room Category) with empty value="" bindings. Backend bindings and data integration will be added in a later PR. This is wireframe-only work.

Applied to files:

  • src/main/webapp/inward/admission_profile.xhtml
  • src/main/webapp/inward/clinical_data.xhtml
  • src/main/java/com/divudi/bean/inward/InpatientClinicalDataController.java
📚 Learning: 2025-05-28T20:22:14.251Z
Learnt from: damithdeshan98
Repo: hmislk/hmis PR: 12594
File: src/main/webapp/resources/ezcomp/lab/dashboard/patient_sample.xhtml:246-409
Timestamp: 2025-05-28T20:22:14.251Z
Learning: In src/main/webapp/resources/ezcomp/lab/dashboard/patient_sample.xhtml, the duplicate "Status Details" column (alongside "Current Status" column) is intentionally kept for future use and should not be removed despite appearing redundant.

Applied to files:

  • src/main/webapp/inward/admission_profile.xhtml
  • src/main/webapp/inward/clinical_data.xhtml
📚 Learning: 2025-07-13T18:49:02.315Z
Learnt from: damithdeshan98
Repo: hmislk/hmis PR: 13897
File: src/main/webapp/lab/patient_report_without_sample_sending_process.xhtml:15-15
Timestamp: 2025-07-13T18:49:02.315Z
Learning: In src/main/webapp/lab/patient_report_without_sample_sending_process.xhtml, damithdeshan98 wants to keep the current privilege check pattern using OR condition (LabDataentry OR LabPrinting) rather than requiring dual privileges like other dashboard components. This page should not follow the standard dual-privilege requirement pattern used in other HMIS dashboard components.

Applied to files:

  • src/main/webapp/inward/admission_profile.xhtml
  • src/main/webapp/inward/clinical_data.xhtml
📚 Learning: 2025-07-13T18:41:53.231Z
Learnt from: damithdeshan98
Repo: hmislk/hmis PR: 13897
File: src/main/webapp/lab/patient_report_without_sample_sending_process.xhtml:247-249
Timestamp: 2025-07-13T18:41:53.231Z
Learning: In src/main/webapp/lab/patient_report_without_sample_sending_process.xhtml, damithdeshan98 prefers using explicit Save buttons rather than adding AJAX listeners for immediate auto-saving on flag select menus, even though other similar fields in the form have auto-save functionality.

Applied to files:

  • src/main/webapp/inward/admission_profile.xhtml
  • src/main/webapp/inward/clinical_data.xhtml
📚 Learning: 2025-12-05T07:29:50.729Z
Learnt from: RaveeshaPeiris
Repo: hmislk/hmis PR: 16704
File: src/main/webapp/reports/inpatientReports/ip_unsettled_invoices.xhtml:0-0
Timestamp: 2025-12-05T07:29:50.729Z
Learning: In PR #16704, RaveeshaPeiris confirmed that the Branch, Department, Consultant, Service Center, and Discharge Type dropdowns in src/main/webapp/reports/inpatientReports/ip_unsettled_invoices.xhtml are intentional placeholder wireframe work with empty value="" bindings. Backend bindings and data integration will be added in a later PR.

Applied to files:

  • src/main/webapp/inward/admission_profile.xhtml
  • src/main/webapp/inward/clinical_data.xhtml
  • src/main/java/com/divudi/bean/inward/InpatientClinicalDataController.java
📚 Learning: 2025-11-06T06:42:14.188Z
Learnt from: ChinthakaPrasad
Repo: hmislk/hmis PR: 16336
File: src/main/webapp/inward/inward_admission.xhtml:57-59
Timestamp: 2025-11-06T06:42:14.188Z
Learning: In src/main/webapp/inward/inward_admission.xhtml, ChinthakaPrasad confirmed that the p:messages component is intentionally commented out because the global p:growl component from template.xhtml handles message display for the admission page.

Applied to files:

  • src/main/webapp/inward/admission_profile.xhtml
  • src/main/webapp/inward/clinical_data.xhtml
📚 Learning: 2025-05-30T05:57:48.936Z
Learnt from: damithdeshan98
Repo: hmislk/hmis PR: 12622
File: src/main/webapp/resources/ezcomp/lab/dashboard/patient_sample.xhtml:19-23
Timestamp: 2025-05-30T05:57:48.936Z
Learning: In src/main/webapp/resources/ezcomp/lab/dashboard/patient_sample.xhtml, damithdeshan98 confirms that users must have both 'DashBoardMenu' and 'DashBoardSampleSearch' privileges to access the sample dashboard section, maintaining the dual-privilege requirement pattern used throughout the HMIS dashboard components.

Applied to files:

  • src/main/webapp/inward/admission_profile.xhtml
📚 Learning: 2025-06-28T00:58:21.722Z
Learnt from: buddhika75
Repo: hmislk/hmis PR: 13441
File: src/main/webapp/resources/pharmacy/history.xhtml:56-122
Timestamp: 2025-06-28T00:58:21.722Z
Learning: In src/main/webapp/resources/pharmacy/history.xhtml, the Stock data table is intentionally duplicated between the block layout and tab layout sections to support dynamic rendering based on user preferences. The conditional rendering allows users to choose between different UI layouts, so both versions need to exist and should not be refactored into a shared component.

Applied to files:

  • src/main/webapp/inward/admission_profile.xhtml
  • src/main/webapp/inward/clinical_data.xhtml
📚 Learning: 2025-07-26T13:29:32.079Z
Learnt from: DARKDRAGON-LK
Repo: hmislk/hmis PR: 14180
File: src/main/webapp/inward/inward_bill_final.xhtml:144-158
Timestamp: 2025-07-26T13:29:32.079Z
Learning: In src/main/webapp/inward/inward_bill_final.xhtml, the Credit Company Details panel with commented-out ui:repeat block for displaying credit company information is intentionally reserved for future development, as confirmed by DARKDRAGON-LK. The empty panel structure should be kept as is for future implementation.

Applied to files:

  • src/main/webapp/inward/admission_profile.xhtml
  • src/main/webapp/inward/clinical_data.xhtml
📚 Learning: 2025-05-18T06:37:28.921Z
Learnt from: damithdeshan98
Repo: hmislk/hmis PR: 12368
File: src/main/webapp/opd/opd_cancel_batch_bill_print.xhtml:39-39
Timestamp: 2025-05-18T06:37:28.921Z
Learning: In the JSF/PrimeFaces implementation for HMIS, a commandButton with ajax="false" and no explicit action attribute is intentionally used when the purpose is to simply reload the page after making a selection change (such as changing paper type), as the page reload will reflect the new selection.

Applied to files:

  • src/main/webapp/inward/admission_profile.xhtml
  • src/main/webapp/inward/clinical_data.xhtml
📚 Learning: 2025-11-07T14:17:19.975Z
Learnt from: DhaneshKaushan
Repo: hmislk/hmis PR: 16372
File: src/main/webapp/pharmacy/pharmacy_item_import_with_stock.xhtml:32-40
Timestamp: 2025-11-07T14:17:19.975Z
Learning: In src/main/webapp/pharmacy/pharmacy_item_import_with_stock.xhtml, DhaneshKaushan prefers to defer wiring the Download Template <p:fileDownload> to a backend implementation in a later PR; for UI-only changes, disable or hide the button temporarily to avoid broken UX and console errors.

Applied to files:

  • src/main/webapp/inward/admission_profile.xhtml
  • src/main/webapp/inward/clinical_data.xhtml
📚 Learning: 2025-11-08T06:14:25.951Z
Learnt from: damithdeshan98
Repo: hmislk/hmis PR: 16386
File: src/main/webapp/lab/laboratory_management_dashboard.xhtml:49-58
Timestamp: 2025-11-08T06:14:25.951Z
Learning: In src/main/webapp/lab/laboratory_management_dashboard.xhtml, the WorkSheet menu item should use DashBoardWorksheet privilege (alongside DashBoardMenu) for access control, not DashBoardInvestigationSearch. This controls access to the WorkSheet dashboard section itself, separate from the action buttons within that section.

Applied to files:

  • src/main/webapp/inward/admission_profile.xhtml
📚 Learning: 2025-05-25T09:21:31.563Z
Learnt from: damithdeshan98
Repo: hmislk/hmis PR: 12500
File: src/main/webapp/collecting_centre/index.xhtml:76-82
Timestamp: 2025-05-25T09:21:31.563Z
Learning: The "Collecting Centre Bill Search" button in src/main/webapp/collecting_centre/index.xhtml should not have privilege checking and should remain accessible to all users, even though other buttons in the same section have privilege controls.

Applied to files:

  • src/main/webapp/inward/admission_profile.xhtml
📚 Learning: 2025-09-07T20:04:10.743Z
Learnt from: buddhika75
Repo: hmislk/hmis PR: 15313
File: src/main/webapp/pharmacy/pharmacy_item_transactions_popup.xhtml:3-13
Timestamp: 2025-09-07T20:04:10.743Z
Learning: In src/main/webapp/pharmacy/pharmacy_item_transactions_popup.xhtml, buddhika75 confirmed that popup pages should be complete standalone pages without template inheritance, preferring lightweight independent popup windows over template-based architecture.

Applied to files:

  • src/main/webapp/inward/admission_profile.xhtml
  • src/main/webapp/inward/clinical_data.xhtml
📚 Learning: 2025-12-05T07:28:42.897Z
Learnt from: RaveeshaPeiris
Repo: hmislk/hmis PR: 16704
File: src/main/webapp/reports/inpatientReports/ip_unsettled_invoices.xhtml:0-0
Timestamp: 2025-12-05T07:28:42.897Z
Learning: In PR #16704, RaveeshaPeiris confirmed that the dataTable section (lines 294-361) in src/main/webapp/reports/inpatientReports/ip_unsettled_invoices.xhtml is intentional placeholder wireframe work with empty value="" bindings and empty column outputs. Backend bindings and data integration for the results table will be added in a later PR.

Applied to files:

  • src/main/webapp/inward/clinical_data.xhtml
📚 Learning: 2025-09-11T15:44:34.440Z
Learnt from: damithdeshan98
Repo: hmislk/hmis PR: 15364
File: src/main/webapp/resources/ezcomp/sample_management/sm_barCodes.xhtml:202-208
Timestamp: 2025-09-11T15:44:34.440Z
Learning: In src/main/webapp/resources/ezcomp/sample_management/sm_barCodes.xhtml, damithdeshan98 confirmed that the patient-info div containing Bill No placement outside the sticker div in the individual barcode layout is working properly and doesn't need structural changes, despite appearing to break conventional HTML nesting patterns.

Applied to files:

  • src/main/webapp/inward/clinical_data.xhtml
📚 Learning: 2025-07-26T13:31:04.605Z
Learnt from: DARKDRAGON-LK
Repo: hmislk/hmis PR: 14180
File: src/main/webapp/inward/inward_bill_final.xhtml:167-169
Timestamp: 2025-07-26T13:31:04.605Z
Learning: In src/main/webapp/inward/inward_bill_final.xhtml, the <credit:outputCredit> component within the Credit Company Details panel is intentionally commented out for future development, as confirmed by DARKDRAGON-LK. The component structure is kept in place for future implementation rather than being completely removed.

Applied to files:

  • src/main/webapp/inward/clinical_data.xhtml
📚 Learning: 2025-06-07T00:31:33.358Z
Learnt from: buddhika75
Repo: hmislk/hmis PR: 12749
File: src/main/java/com/divudi/bean/common/SearchController.java:17253-17254
Timestamp: 2025-06-07T00:31:33.358Z
Learning: In src/main/java/com/divudi/bean/common/SearchController.java, PHARMACY_GRN_RETURN should not be included in the pharmacyBillTypesAtomics list for generatePharmacyCollection(); its inclusion is not required for this context.

Applied to files:

  • src/main/java/com/divudi/bean/inward/InpatientClinicalDataController.java
📚 Learning: 2025-09-23T17:57:08.030Z
Learnt from: PasinduW99
Repo: hmislk/hmis PR: 15552
File: src/main/webapp/pharmacy/pharmacy_reprint_grn_with_costing.xhtml:84-91
Timestamp: 2025-09-23T17:57:08.030Z
Learning: In src/main/webapp/pharmacy/pharmacy_reprint_grn_with_costing.xhtml, PasinduW99 confirmed that GRN receipt paper format configuration options (A4, Custom 1, Custom 2) should use configOptionController instead of configOptionApplicationController because they want department-specific configuration rather than application-wide settings for receipt printing formats.

Applied to files:

  • src/main/java/com/divudi/bean/inward/InpatientClinicalDataController.java
📚 Learning: 2025-08-15T13:53:07.240Z
Learnt from: buddhika75
Repo: hmislk/hmis PR: 14865
File: src/main/java/com/divudi/bean/pharmacy/PharmacyRequestForBhtController.java:0-0
Timestamp: 2025-08-15T13:53:07.240Z
Learning: In src/main/java/com/divudi/bean/pharmacy/PharmacyRequestForBhtController.java, the addMedicine() method (currently a TODO) is intentionally not implemented as buddhika75 confirmed it's not necessary for the current pharmacy drug request functionality.

Applied to files:

  • src/main/java/com/divudi/bean/inward/InpatientClinicalDataController.java
📚 Learning: 2025-08-20T12:03:46.114Z
Learnt from: damithdeshan98
Repo: hmislk/hmis PR: 15055
File: src/main/java/com/divudi/bean/common/CollectingCentrePaymentController.java:299-301
Timestamp: 2025-08-20T12:03:46.114Z
Learning: In CollectingCentrePaymentController.java, damithdeshan98 confirmed that getHospitalTotal() and getCcTotal() values from BillLight objects in pandingCCpaymentBills are guaranteed to be non-null, so null checking is not needed when aggregating these values in the totalHospitalAmount and totalCCAmount calculations.

Applied to files:

  • src/main/java/com/divudi/bean/inward/InpatientClinicalDataController.java
📚 Learning: 2025-10-12T05:32:34.145Z
Learnt from: CR
Repo: hmislk/hmis PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-10-12T05:32:34.145Z
Learning: Applies to **/*.xhtml : Fetch dynamic configuration values via configOptionApplicationController in UI

Applied to files:

  • src/main/java/com/divudi/bean/inward/InpatientClinicalDataController.java
📚 Learning: 2025-11-24T21:54:09.952Z
Learnt from: CR
Repo: hmislk/hmis PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-24T21:54:09.952Z
Learning: Applies to **/*.{java,xhtml} : Use `configOptionApplicationController` for dynamic configuration values

Applied to files:

  • src/main/java/com/divudi/bean/inward/InpatientClinicalDataController.java
📚 Learning: 2025-11-24T21:54:09.952Z
Learnt from: CR
Repo: hmislk/hmis PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-24T21:54:09.952Z
Learning: Applies to **/*Controller.java : Reuse existing controller properties and methods; avoid introducing new filtered values, global filters, or backend logic for UI-only tasks

Applied to files:

  • src/main/java/com/divudi/bean/inward/InpatientClinicalDataController.java
📚 Learning: 2025-06-02T11:30:02.679Z
Learnt from: ImeshRanawellaSG
Repo: hmislk/hmis PR: 12668
File: src/main/java/com/divudi/bean/common/ReportsController.java:3586-3598
Timestamp: 2025-06-02T11:30:02.679Z
Learning: In `src/main/java/com/divudi/bean/common/ReportsController.java`, within the `removeNonDues()` method, the filtering logic for cancelled and refund bills in the OP visit section is intentionally different from the IP logic. For OP visits, removing rows when the balance is greater than or equal to zero is correct for this specific location, as per business requirements. This exception should be remembered for future reviews.

Applied to files:

  • src/main/java/com/divudi/bean/inward/InpatientClinicalDataController.java
📚 Learning: 2025-08-20T12:05:22.703Z
Learnt from: damithdeshan98
Repo: hmislk/hmis PR: 15055
File: src/main/java/com/divudi/bean/common/CollectingCentrePaymentController.java:291-295
Timestamp: 2025-08-20T12:05:22.703Z
Learning: In CollectingCentrePaymentController.java, when BillLight objects are created via JPQL queries using bill.totalCenterFee and bill.totalHospitalFee, these values are guaranteed to be non-null because they originate from primitive double fields in the Bill entity, so null checking is not needed when negating getCcTotal() and getHospitalTotal() values from these specific BillLight objects.

Applied to files:

  • src/main/java/com/divudi/bean/inward/InpatientClinicalDataController.java
📚 Learning: 2025-10-05T02:22:51.361Z
Learnt from: buddhika75
Repo: hmislk/hmis PR: 15729
File: src/main/java/com/divudi/bean/pharmacy/PharmacyController.java:2160-2170
Timestamp: 2025-10-05T02:22:51.361Z
Learning: In the HMIS Java codebase, com.divudi.core.entity.Bill implements lazy initialization in getBillFinanceDetails(), so this getter never returns null. Code reviews should not suggest adding null guards around b.getBillFinanceDetails() usages (e.g., in src/main/java/com/divudi/bean/pharmacy/PharmacyController.java and similar controllers).

Applied to files:

  • src/main/java/com/divudi/bean/inward/InpatientClinicalDataController.java
🔇 Additional comments (1)
src/main/java/com/divudi/bean/inward/InpatientClinicalDataController.java (1)

147-149: Config option injection and new HTML fields are consistent with existing patterns

  • Injecting ConfigOptionApplicationController here is appropriate for application‑wide template configuration and aligns with the “use configOptionApplicationController for dynamic configuration values” guideline.
  • New fields wardAdmissionDiagnosisCardHtml, localSurgeryDiagnosisCardHtml, and selectedDiagnosisCardTypeHtml plus their getters/setters integrate cleanly with the view layer and don’t interfere with existing diagnosis card mechanisms.

No functional issues spotted with these additions.

As per coding guidelines, using ConfigOptionApplicationController for these templates is the right choice.

Also applies to: 235-238, 3250-3272

Comment on lines +493 to +527
/**
* Load and display Ward Admission Diagnosis Card with variable replacement
*/
public void loadWardAdmissionDiagnosisCard() {
if (current == null) {
JsfUtil.addErrorMessage("No patient encounter selected");
return;
}
String templateHtml = configOptionApplicationController.getLongTextValueByKey("Ward Admission Diagnosis Card Template", "");
if (templateHtml == null || templateHtml.isEmpty()) {
JsfUtil.addErrorMessage("Ward Admission Diagnosis Card template not configured");
return;
}
Map<String, String> replacements = createReplacementsMap(current);
wardAdmissionDiagnosisCardHtml = replaceVariablesInHtml(templateHtml, replacements);
selectedDiagnosisCardTypeHtml = wardAdmissionDiagnosisCardHtml;
}

/**
* Load and display Local Surgery Diagnosis Card with variable replacement
*/
public void loadLocalSurgeryDiagnosisCard() {
if (current == null) {
JsfUtil.addErrorMessage("No patient encounter selected");
return;
}
String templateHtml = configOptionApplicationController.getLongTextValueByKey("Local Surgery Diagnosis Card Template", "");
if (templateHtml == null || templateHtml.isEmpty()) {
JsfUtil.addErrorMessage("Local Surgery Diagnosis Card template not configured");
return;
}
Map<String, String> replacements = createReplacementsMap(current);
localSurgeryDiagnosisCardHtml = replaceVariablesInHtml(templateHtml, replacements);
selectedDiagnosisCardTypeHtml = localSurgeryDiagnosisCardHtml;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Reset diagnosis card HTML on failure and ensure encounter context is fully prepared

In loadWardAdmissionDiagnosisCard() / loadLocalSurgeryDiagnosisCard():

if (current == null) {
    JsfUtil.addErrorMessage("No patient encounter selected");
    return;
}
String templateHtml = configOptionApplicationController.getLongTextValueByKey(...);
if (templateHtml == null || templateHtml.isEmpty()) {
    JsfUtil.addErrorMessage("... template not configured");
    return;
}
Map<String, String> replacements = createReplacementsMap(current);
wardAdmissionDiagnosisCardHtml = replaceVariablesInHtml(templateHtml, replacements);
selectedDiagnosisCardTypeHtml = wardAdmissionDiagnosisCardHtml;

Two points:

  1. Stale HTML when validation fails
  • On the early returns (no current, or missing template), wardAdmissionDiagnosisCardHtml / localSurgeryDiagnosisCardHtml and selectedDiagnosisCardTypeHtml are left unchanged.
  • Because the UI always opens the dialog in oncomplete, this can show a previous patient’s card (or previous encounter) when the current call fails, which is misleading and potentially sensitive.

Consider clearing state at the start of each method:

public void loadWardAdmissionDiagnosisCard() {
    wardAdmissionDiagnosisCardHtml = null;
    selectedDiagnosisCardTypeHtml = null;

    if (current == null) {
        JsfUtil.addErrorMessage("No patient encounter selected");
        return;
    }
    ...
}

(and similarly for localSurgeryDiagnosisCardHtml).

  1. Robustness of createReplacementsMap(current)
  • createReplacementsMap() iterates over lists like getEncounterInvestigations(), getEncounterProcedures(), getPatientAllergies(), etc. Some getters (e.g. getEncounterInvestigations()) can return null until fillCurrentEncounterLists(current) / fillCurrentPatientLists(current.getPatient()) have been called.
  • Today those fill methods are invoked in the navigation methods that lead to clinical_data.xhtml, but these new loaders are now also called from admission_profile.xhtml. If current is ever set without also populating the encounter lists, you could get NullPointerExceptions here.

A defensive pattern would be:

if (current != null) {
    fillCurrentPatientLists(current.getPatient());
    fillCurrentEncounterLists(current);
}
Map<String, String> replacements = createReplacementsMap(current);

before building the HTML, to ensure all lists are in a known good state.

🤖 Prompt for AI Agents
In @src/main/java/com/divudi/bean/inward/InpatientClinicalDataController.java
around lines 493-527, Reset the diagnosis card HTML state at the start of each
loader and ensure encounter/patient lists are populated before building
replacements: in loadWardAdmissionDiagnosisCard() and
loadLocalSurgeryDiagnosisCard() clear wardAdmissionDiagnosisCardHtml /
localSurgeryDiagnosisCardHtml and selectedDiagnosisCardTypeHtml immediately,
then if current != null call fillCurrentPatientLists(current.getPatient()) and
fillCurrentEncounterLists(current) before invoking
createReplacementsMap(current) and replaceVariablesInHtml(...); this prevents
stale HTML on early returns and avoids NPEs inside createReplacementsMap when
encounter/patient lists are null.

Comment on lines +348 to +373
value="Diagnosis Card (Legacy)"
ajax="false"
action="#{admissionController.navigateToInpatientDiagnosisCard()}"
icon="fa fa-diagnoses"
class="w-100">
</p:commandButton>
<p:commandButton
value="Ward Admission Card"
ajax="true"
icon="pi pi-document"
styleClass="ui-button-success w-100"
action="#{inpatientClinicalDataController.loadWardAdmissionDiagnosisCard}"
oncomplete="PF('wardDiagnosisDialogDashboard').show()"
process="@this"
update="wardDiagnosisPanelDashboard">
</p:commandButton>
<p:commandButton
value="Local Surgery Card"
ajax="true"
icon="pi pi-document"
styleClass="ui-button-info w-100"
action="#{inpatientClinicalDataController.loadLocalSurgeryDiagnosisCard}"
oncomplete="PF('surgeryDiagnosisDialogDashboard').show()"
process="@this"
update="surgeryDiagnosisPanelDashboard">
</p:commandButton>
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

find . -type f -name "*InpatientClinicalDataController*"

Repository: hmislk/hmis

Length of output: 130


🏁 Script executed:

find . -type f -name "admission_profile.xhtml"

Repository: hmislk/hmis

Length of output: 103


🏁 Script executed:

rg "loadWardAdmissionDiagnosisCard|loadLocalSurgeryDiagnosisCard" -A 10 -B 2

Repository: hmislk/hmis

Length of output: 11016


🏁 Script executed:

head -100 ./src/main/webapp/inward/admission_profile.xhtml

Repository: hmislk/hmis

Length of output: 5777


🏁 Script executed:

rg "inpatientClinicalDataController|admissionController" ./src/main/webapp/inward/admission_profile.xhtml | head -30

Repository: hmislk/hmis

Length of output: 3203


🏁 Script executed:

head -150 ./src/main/webapp/inward/clinical_data.xhtml

Repository: hmislk/hmis

Length of output: 9534


🏁 Script executed:

grep -n "current\|setCurrent\|fillCurrentEncounterLists" ./src/main/java/com/divudi/bean/inward/InpatientClinicalDataController.java | head -40

Repository: hmislk/hmis

Length of output: 2410


🏁 Script executed:

grep -n "setCurrent\|public.*current\|@PostConstruct\|preRender\|postLoad" ./src/main/java/com/divudi/bean/inward/InpatientClinicalDataController.java | head -20

Repository: hmislk/hmis

Length of output: 567


🏁 Script executed:

rg "inpatientClinicalDataController\.current\s*=" ./src/main/webapp/inward/admission_profile.xhtml

Repository: hmislk/hmis

Length of output: 37


🏁 Script executed:

rg "f:viewAction|p:ajax.*event=\"load\"|@PostConstruct" ./src/main/webapp/inward/admission_profile.xhtml

Repository: hmislk/hmis

Length of output: 37


🏁 Script executed:

rg "preRender\|viewAction\|PostConstruct" ./src/main/java/com/divudi/bean/inward/InpatientClinicalDataController.java -B 2 -A 5

Repository: hmislk/hmis

Length of output: 37


🏁 Script executed:

cat ./src/main/java/com/divudi/bean/inward/InpatientClinicalDataController.java | grep -A 5 "public void setCurrent"

Repository: hmislk/hmis

Length of output: 709


🏁 Script executed:

grep -n "navigateToAdmissionProfilePage" ./src/main/java/com/divudi/bean/inward/AdmissionController.java -A 10

Repository: hmislk/hmis

Length of output: 456


🏁 Script executed:

grep -n "f:setPropertyActionListener\|inpatientClinicalDataController" ./src/main/webapp/inward/admission_profile.xhtml

Repository: hmislk/hmis

Length of output: 3250


🏁 Script executed:

grep -n "p:ajax.*load\|p:poll" ./src/main/webapp/inward/admission_profile.xhtml

Repository: hmislk/hmis

Length of output: 37


🏁 Script executed:

wc -l ./src/main/webapp/inward/admission_profile.xhtml

Repository: hmislk/hmis

Length of output: 107


🏁 Script executed:

tail -200 ./src/main/webapp/inward/admission_profile.xhtml | head -100

Repository: hmislk/hmis

Length of output: 6598


🏁 Script executed:

sed -n '340,380p' ./src/main/webapp/inward/admission_profile.xhtml

Repository: hmislk/hmis

Length of output: 2470


🏁 Script executed:

grep -B 20 "loadWardAdmissionDiagnosisCard\|loadLocalSurgeryDiagnosisCard" ./src/main/webapp/inward/admission_profile.xhtml | head -50

Repository: hmislk/hmis

Length of output: 2018


🏁 Script executed:

grep -n "f:setPropertyActionListener.*inpatientClinicalDataController" ./src/main/webapp/inward/admission_profile.xhtml

Repository: hmislk/hmis

Length of output: 37


🏁 Script executed:

sed -n '1,100p' ./src/main/webapp/inward/admission_profile.xhtml | grep -i "ajax\|listener\|load\|init"

Repository: hmislk/hmis

Length of output: 654


🏁 Script executed:

grep -n "p:ajax.*event=\"load\"\|p:remoteCommand\|onload" ./src/main/webapp/inward/admission_profile.xhtml

Repository: hmislk/hmis

Length of output: 37


🏁 Script executed:

grep -n "private.*current\|public.*getCurrent\|patientEncounter" ./src/main/java/com/divudi/bean/inward/AdmissionController.java | head -20

Repository: hmislk/hmis

Length of output: 1222


🏁 Script executed:

grep -n "navigateToAdmissionProfilePage\|navigateToInpatientClinicalData\|clinical_data" ./src/main/java/com/divudi/bean/inward/AdmissionController.java -A 5 | head -40

Repository: hmislk/hmis

Length of output: 564


🏁 Script executed:

grep -rn "inpatientClinicalDataController.setCurrent\|inpatientClinicalDataController.*current\s*=" ./src/main/webapp/inward/ --include="*.xhtml"

Repository: hmislk/hmis

Length of output: 37


🏁 Script executed:

rg "navigateToClinical|clinical_data" ./src/main/java/com/divudi/bean/inward/AdmissionController.java -A 8

Repository: hmislk/hmis

Length of output: 37


🏁 Script executed:

grep -n "class Admission\|extends PatientEncounter" ./src/main/java/com/divudi/entity/Admission.java | head -5

Repository: hmislk/hmis

Length of output: 136


🏁 Script executed:

grep -n "class PatientEncounter\|private.*Admission\|getEncounter\|patientEncounter" ./src/main/java/com/divudi/entity/Admission.java | head -20

Repository: hmislk/hmis

Length of output: 136


🏁 Script executed:

rg "navigateToAdmissionProfilePage" ./src/main/webapp/inward/ --include="*.xhtml" -B 5 -A 5

Repository: hmislk/hmis

Length of output: 496


🏁 Script executed:

find . -type f -name "Admission.java"

Repository: hmislk/hmis

Length of output: 115


🏁 Script executed:

rg "navigateToAdmissionProfilePage" ./src/main/webapp/inward/ -B 5 -A 5

Repository: hmislk/hmis

Length of output: 9073


🏁 Script executed:

grep -n "class Admission" ./src/main/java/com/divudi/entity/inward/Admission.java | head -3

Repository: hmislk/hmis

Length of output: 143


🏁 Script executed:

grep -n "class Admission" ./src/main/java/com/divudi/core/entity/inward/Admission.java | head -3

Repository: hmislk/hmis

Length of output: 131


🏁 Script executed:

grep -n "extends PatientEncounter\|implements PatientEncounter" ./src/main/java/com/divudi/core/entity/inward/Admission.java

Repository: hmislk/hmis

Length of output: 131


🏁 Script executed:

head -50 ./src/main/java/com/divudi/core/entity/inward/Admission.java

Repository: hmislk/hmis

Length of output: 348


🏁 Script executed:

grep -n "inpatientClinicalDataController.current\|setCurrent" ./src/main/webapp/inward/admission_profile.xhtml

Repository: hmislk/hmis

Length of output: 37


🏁 Script executed:

sed -n '1,20p' ./src/main/webapp/inward/admission_profile.xhtml

Repository: hmislk/hmis

Length of output: 1120


Sync InpatientClinicalDataController.current before invoking Ward/Local Surgery Card buttons

These buttons call inpatientClinicalDataController.loadWardAdmissionDiagnosisCard and loadLocalSurgeryDiagnosisCard, which both guard against null current and return early with "No patient encounter selected" if not initialized. Since this page never propagates admissionController.current to inpatientClinicalDataController.current, clicking these buttons will fail with an error unless the user reached this page through navigateToInpatientClinicalData() (which explicitly sets the current).

Add <f:setPropertyActionListener value="#{admissionController.current}" target="#{inpatientClinicalDataController.current}" /> to at least one of the buttons, or use an actionListener to synchronize before the action fires.

🤖 Prompt for AI Agents
In @src/main/webapp/inward/admission_profile.xhtml around lines 348-373, The
Ward and Local Surgery buttons call
inpatientClinicalDataController.loadWardAdmissionDiagnosisCard and
loadLocalSurgeryDiagnosisCard but never set
inpatientClinicalDataController.current from admissionController.current,
causing a null-current early return; fix by adding a pre-action sync such as an
<f:setPropertyActionListener> (value="#{admissionController.current}"
target="#{inpatientClinicalDataController.current}") or an actionListener that
sets inpatientClinicalDataController.current before invoking the
loadWardAdmissionDiagnosisCard / loadLocalSurgeryDiagnosisCard actions so the
controller has the selected encounter (alternatively mirror how
navigateToInpatientClinicalData() assigns current).

Comment on lines +59 to +80
<!-- Diagnosis Card Type Buttons -->
<p:commandButton
ajax="true"
icon="pi pi-document"
value="Ward Admission Card"
class="m-1 p-0 ui-button-success"
action="#{inpatientClinicalDataController.loadWardAdmissionDiagnosisCard}"
oncomplete="PF('wardDiagnosisDialog').show()"
process="@this"
update="wardDiagnosisPanel">
</p:commandButton>

<p:commandButton
ajax="true"
icon="pi pi-document"
value="Surgery Card"
class="m-1 p-0 ui-button-info"
action="#{inpatientClinicalDataController.loadLocalSurgeryDiagnosisCard}"
oncomplete="PF('surgeryDiagnosisDialog').show()"
process="@this"
update="surgeryDiagnosisPanel">
</p:commandButton>
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Align naming and avoid confusing duplication for diagnosis card buttons

You now have four labels for essentially two concepts:

  • Header: Ward Admission Card / Surgery Card
  • Diagnosis tab section: Ward Admission Diagnosis Card / Local Surgery Diagnosis Card

All four trigger the same two controller methods and dialogs, so this inconsistency is likely to confuse users and makes the UI harder to document.

Consider:

  • Using consistent wording for each card type across header and tab sections (e.g., always “Ward Admission Diagnosis Card” and “Local Surgery Diagnosis Card”).
  • Optionally de‑duplicating the buttons (e.g., keep either header shortcuts or the section, not both) to simplify the UX, unless both placements are intentionally required.

Also applies to: 626-659

🤖 Prompt for AI Agents
In @src/main/webapp/inward/clinical_data.xhtml around lines 59-80, The button
labels are inconsistent and duplicate concepts across header and tab sections,
causing confusion; update the value attributes so wording is consistent across
both places (use either "Ward Admission Diagnosis Card" and "Local Surgery
Diagnosis Card" everywhere) and/or remove duplicate buttons if redundant;
specifically harmonize the values for the p:commandButton elements that call
inpatientClinicalDataController.loadWardAdmissionDiagnosisCard /
loadLocalSurgeryDiagnosisCard and ensure the oncomplete targets
PF('wardDiagnosisDialog') and PF('surgeryDiagnosisDialog') match the chosen
labels so header shortcuts and tab labels consistently refer to the same dialog
and controller actions.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants