Skip to content

PatientInvestigation Approval Audit Event Log#18501

Draft
OsaVS wants to merge 3 commits intodevelopmentfrom
17232-audit-event-recording-for-patientinvestigation-approve-operations
Draft

PatientInvestigation Approval Audit Event Log#18501
OsaVS wants to merge 3 commits intodevelopmentfrom
17232-audit-event-recording-for-patientinvestigation-approve-operations

Conversation

@OsaVS
Copy link
Collaborator

@OsaVS OsaVS commented Feb 9, 2026

Not Ready for Merge

Issue: #17232

Files Changed:

  • PatientReportController
  • PatientReportUploadController
  • LabrotaryManagementController
  • search_for_reporting_ondemand

New Method to map the PatientReport values.

UpdateInvestigation and initialInvestigation, two new variables to hold the before and after states.

Navigation methods are modified to set initialInvestigation.

Approval and ReverseApproval methods are modified to set updateInvestigation and initialInvestigation.

patientReportController.navigateToViewPatientRepoort() method should be modified to set currentPatientReport when reportType is Upload.
Same case with the laboratoryManagementController.navigateToEditReport().

search_for_reporting_ondemand.xhtml file modified to set initialInvestigation when navigating to patient_report page.

After:

{"ApproveStatus":true,
"investigationID":1851806,
"ReportId":1851821,
"DataEntered":true,
"ApprovedAt":"Feb 6, 2026, 9:49:48 AM",
"patient_ID":1822103,
"ApprovingUser":1816040,
"Investigation":"ESR N",
"patient_name":"Wimal Arampath",
"CollectedAt":"Feb 6, 2026, 9:49:21 AM"}

Before:

{"ApproveStatus":false,
"investigationID":1851806,
"ReportId":1851821,
"DataEntered":false,
"patient_ID":1822103,
"Investigation":"ESR N",
"patient_name":"Wimal Arampath",
"CollectedAt":"Feb 6, 2026, 9:49:21 AM"}|


<hr/>

#### Investigation: FBC (PCV/Platelet/WBC/DC/Hb)

After:
```text
|{
	"ApproveStatus":true,
	"DataEntered":true,
	"ApprovedAt":"Jan 9, 2026, 9:34:32 AM",
	"investigationID":1835856,
	"patient_ID":1822103,
	"ApprovingUser":1816040,
	"Investigation":"FBC Report Format",
	"patient_name":"Wimal Arampath",
	"CollectedAt":"Jan 8, 2026, 11:54:42 AM",
	"Result":{
			"RBC Absolute Value":"0.0",
			"himoglobin Reference Range Label":"13 - 17",
			"MCH Reference Range Label":"27 - 34",
			"WBC Reference Range Label":"4 - 10",
			"Eosinophils# Absolute Value":"9.00",
			"Lymphocytes# Absolute Value":"14.00",
			"Monocytes# Reference Range Label":"3 - 12",
			"PCV(HCT) Reference Range Label":"36 - 46",
			"Platelet Count Reference Range Label":"150 - 400",
			"Immature cells Label":"",
			"RDW-CV Absolute Value":"0",
			"Basophils# % Value":"0.00",
			"Haemoglobin Absolute Value":"0.0",
			"RDW-SD Absolute Value":"0",
			"MCHC Absolute Value":"0",
			"Immature Cells Value":"",
			"Immature Cells 10^9/L":"",
			"MCH Absolute Value":"0.0",
			"Immature Cells Absolute Value":"",
			"RBC Reference Range Label":"3.8 - 4.8",
			"P-LCC New Value":"0",
			"Lymphocytes#  % Value":"15.0",
			"Neutrophils# % Value":"13.0",
			"Monocytes# Absolute Value":"16.00",
			"MPV Absolute Value":"0",
			"Lymphocytes# Reference Range Label":"20 - 40",
			"PCV(HCT) Absolute Value":"0.0","P-LCR New Value":"0",
			"Neutrophils# Reference Range Label":"50 - 70",
			"MCV Reference Range Label":"80 - 100",
			"WBC Absolute Value":"11.00",
			"Basophils# Reference Range Label":"0 - 1",
			"Platelet Count Absolute Value":"0",
			"Basophils# Absolute Value":"7.00",
			"Eosinophils# % Value":"8.0",
			"comment New Value":"",
			"Neutrophils# Absolute Value":"12.00",
			"MCV Absolute Value":"0",
			"PCT New Value":"0.000",
			"Eosinophils# Reference Range Label":"0.5 - 5",
			"PDW New Value":"0",
			" MCHC Reference Range Label":"32 - 36",
			"Immature Cells Flag":"",
			"Immature Cells Reference Range":"",
			"Monocytes# % Value":"10.0"
		}
}|

Signed-off-by: OsaVS <41975253+OsaVS@users.noreply.github.com>
@OsaVS OsaVS self-assigned this Feb 9, 2026
@OsaVS OsaVS linked an issue Feb 9, 2026 that may be closed by this pull request
8 tasks
@OsaVS OsaVS added the Lab label Feb 9, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 9, 2026

Important

Review skipped

Draft detected.

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.

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
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 17232-audit-event-recording-for-patientinvestigation-approve-operations

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


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
Member

@buddhika75 buddhika75 left a comment

Choose a reason for hiding this comment

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

PR #18501 Review - PatientInvestigation Approval Audit Event Log

PR: #18501
Issue: #17232
Files Changed: 4


1. btnNewReport Change (Critical - Functionality Lost)

Before (current code):

<p:commandLink id="btnNewReport" ajax="false"
    disabled="#{!pi.received}"
    action="/lab/patient_report?faces-redirect=true"
    actionListener="#{patientReportController.createNewReport(pi)}" >
    <f:setPropertyActionListener value="#{pi}" target="#{patientReportController.currentPtIx}"/>

After (PR):

<p:commandLink id="btnNewReport" ajax="false"
    disabled="#{!pi.received}"
    action="#{patientReportController.navigateToCreatedPatientReport(pi)}" >
<!--  <f:setPropertyActionListener ... commented out -->

Functionality difference

The old code used createNewReport(pi) as an actionListener, which handles 3 report types:

  • Microbiology -> calls createNewMicrobiologyReport()
  • HtmlTemplate -> calls createNewPatientTemplateReport()
  • Normal -> calls createNewPatientReport()

The new code calls navigateToCreatedPatientReport(pi) which routes through navigateToNewlyCreatedPatientReport(pi), which only handles 2 report types:

  • Microbiology -> calls createNewMicrobiologyReport()
  • Everything else -> calls createNewPatientReport()

HtmlTemplate report type is lost. Any investigation configured with InvestigationReportType.HtmlTemplate will no longer call createNewPatientTemplateReport() - it will incorrectly fall into the normal createNewPatientReport() path.

Also, the new path adds extra validation (checkAlreadyGeneratedPatientReportsExists, alternative report checking) that the old path didn't have. This could be seen as an improvement, but it's a behavioral change that may prevent users from creating reports in some edge cases where they previously could.


2. enterNewReportFormat Link (Minor - OK)

Before: action="/lab/patient_report?faces-redirect=true" with actionListener="#{patientReportController.enterNewReportFormat(pi, ifi)}"

After: action="#{patientReportController.navigateToPatientReportPage}" with actionListener="#{patientReportController.enterNewReportFormat(pi, ifi)}"

The enterNewReportFormat method already returns "/lab/patient_report" (without ?faces-redirect=true). Since actionListener runs before action, the action used to be the hardcoded navigation. Now the action calls a new method navigateToPatientReportPage() that just sets initialInvestigation and returns the same path. This change is functionally okay.


3. cmdOldReport and cmdOldReportEdit Links (OK)

Before: action="/lab/patient_report?faces-redirect=true" with f:setPropertyActionListener setting currentPatientReport

After: action="#{patientReportController.navigateToPatientReportPage}" with the same f:setPropertyActionListener

The navigateToPatientReportPage() adds audit initialInvestigation capture. Since f:setPropertyActionListener runs before the action method in JSF lifecycle, currentPatientReport will be set before navigateToPatientReportPage() reads it. This is functionally OK.


4. Java Changes - Other Observations

Bug in navigateToViewPatientReport

In PatientReportController.navigateToViewPatientReport(), the audit map is populated using currentPatientReport:

patientInvestigationToAuditMap(initialInvestigation, currentPatientReport);

But at that point, currentPatientReport hasn't been set yet - it's set on the next line via setCurrentPatientReport(patientReport). It should be using the patientReport parameter instead. This means the audit "before" snapshot will capture stale/wrong data.

Commented-out code in PatientReportUploadController

The uploadReport() method contains commented-out code that should be removed before merge:

//  patientReportController.setInitialInvestigation(new HashMap<>(20));
//  patientReportController.patientInvestigationToAuditMap(...)

Summary Table

Change Impact Verdict
btnNewReport action change HtmlTemplate reports broken Functionality lost
btnNewReport removes setPropertyActionListener currentPtIx now set inside navigateToCreatedPatientReport OK
enterNewReportFormat link Adds audit capture, navigation same OK
cmdOldReport / cmdOldReportEdit links Adds audit capture, navigation same OK
navigateToViewPatientReport audit uses wrong variable Audit "before" state will be wrong Bug
Commented-out code in upload controller Dead code in PR Cleanup needed

Recommendation

The PR should not be merged as-is because:

  1. btnNewReport loses HtmlTemplate report type handling - investigations configured as HtmlTemplate will be created incorrectly
  2. Bug in navigateToViewPatientReport - audit "before" state captures stale currentPatientReport instead of the patientReport parameter
  3. Commented-out code in PatientReportUploadController should be removed

@OsaVS OsaVS requested a review from buddhika75 February 11, 2026 12:21
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.

Implement Audit Event Recording for PatientInvestigation Approve Operations

2 participants