Fix: Encounter notes loading and saving issue#383
Conversation
Reviewer's GuideThis PR fixes encounter notes loading and saving by initializing the note object in session, exposing and binding the dynamic encounter selector, refactoring JSPs to use JSTL/EL instead of scriptlets, and cleaning up obsolete inputs. Sequence diagram for loading and saving encounter notessequenceDiagram
actor User
participant JSP as noteIssueList.jsp
participant Action as CaseManagementEntry2Action
participant Session
participant DB as Database
User->>JSP: Load encounter notes page
JSP->>Action: Request to load notes
Action->>Session: restoreFromSession()
alt caseNote is null
Action->>Action: Initialize new CaseManagementNote
end
Action->>DB: Fetch existing notes
DB-->>Action: Return notes
Action-->>JSP: Return notes data
JSP-->>User: Display notes
User->>JSP: Save new note
JSP->>Action: Submit new note
Action->>DB: Save note
DB-->>Action: Confirm save
Action-->>JSP: Return success
JSP-->>User: Show updated notes
Class diagram for CaseManagementEntry2Action and CaseManagementNote changesclassDiagram
class CaseManagementEntry2Action {
- Map<String, Object> mySessionMap
- CaseManagementNote caseNote
+ void restoreFromSession()
}
class CaseManagementNote {
+ String encounter_type
+ String id
...
}
CaseManagementEntry2Action --> CaseManagementNote : uses
CaseManagementEntry2Action --> mySessionMap : session access
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Pull Request Overview
This PR fixes an issue where encounter notes were not loading properly and new notes could not be saved. The changes address null pointer issues during session restoration and modernize JSP code by replacing scriptlet concatenations with JSTL/EL expressions.
Key changes include:
- Initializing the caseNote object in the Java action class to prevent null pointer exceptions
- Refactoring JSP code to use JSTL/EL instead of scriptlets for better maintainability
- Removing obsolete hidden input fields from the chart notes interface
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| CaseManagementEntry2Action.java | Added null check and initialization for caseNote object in restoreFromSession method |
| noteIssueList.jsp | Replaced scriptlet code with JSTL/EL expressions and removed redundant script tags |
| ChartNotes.jsp | Removed obsolete hidden filter input fields |
|
@sourcery-ai review |
There was a problem hiding this comment.
Hey @D3V41 - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `src/main/webapp/casemgmt/noteIssueList.jsp:492` </location>
<code_context>
+ </c:if>
- var c = "bgColour" + "<%=noteIndex%>";
+ var c = "bgColour" + "${noteIndex}";
var txtStyles = $F(c).split(";");
var txtColour = txtStyles[0].substr(txtStyles[0].indexOf("#"));
</code_context>
<issue_to_address>
Switching from scriptlet to EL for noteIndex in JavaScript may introduce type issues.
If noteIndex is undefined or not a string in the EL context, this could result in issues like 'bgColourundefined'. Consider casting or providing a default value in the EL expression.
Suggested implementation:
```
var c = "bgColour" + "${empty noteIndex ? 0 : noteIndex}";
```
```
var summary = "sumary" + "${empty noteIndex ? 0 : noteIndex}";
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
This PR fixes an issue where encounter notes were not loading properly and new notes could not be saved.
The update ensures that:
Summary by Sourcery
Fix encounter notes loading and persistence by correcting JSP element IDs, initializing form beans, and cleaning up redundant form fields
Bug Fixes:
Enhancements: