Skip to content

Commit eb44d7b

Browse files
buddhika75claude
andcommitted
fix(theater): refresh Surgery Workbench Timed Services and Professional Fees tabs
SurgeryBillController's proEncounterComponents/timedEncounterComponents lists were only ever initialized to an empty ArrayList and never queried from the DB, so the Surgery Workbench summary tabs never showed data added via the separate InwardTimedItemController/InwardProfessionalBillController beans. Getters now lazily fetch from the DB, and the add/update/remove actions in those beans invalidate the cache so the workbench re-fetches on return. Verified end-to-end with Playwright + DB checks against local Payara. Fixes #20890 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 9d58c89 commit eb44d7b

4 files changed

Lines changed: 73 additions & 2 deletions

File tree

developer_docs/testing/playwright-e2e-workflow.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1480,6 +1480,33 @@ field alone is not enough. Fix: search and select a Speciality (e.g. type
14801480
statement reaches the server at all; with it filled, the insert fires
14811481
immediately. Verified while testing issue #22665.
14821482

1483+
## 56. `p:datePicker timeInput="true"` — typing into the input does not commit; use the PrimeFaces widget API for non-AJAX forms
1484+
1485+
On `theater/inward_timed_service_consume_surgery.xhtml`'s Start/End Time
1486+
fields (`p:datePicker showTime="true" timeInput="true"`, no `readonlyInput`
1487+
set — `input.readOnly` is `false`), the documented "click → Ctrl+A →
1488+
pressSequentially → Escape" pattern (§ "p:datePicker / p:calendar") left the
1489+
input **empty** every time: `document.getElementById(...).value` read `""`
1490+
both before and after `Escape`, with no visible error. Root cause wasn't
1491+
narrowed further, but the fix that reliably works is to skip DOM typing
1492+
entirely and drive the PrimeFaces widget directly — safe here because the
1493+
submit button (`+ Add Service`) is `ajax="false"`, so (per §29) only the
1494+
final submitted `_input` value matters:
1495+
```js
1496+
Object.keys(PrimeFaces.widgets).filter(k => /starttime|endtime/i.test(k))
1497+
// -> ["widget_form_startTime", "widget_form_endTime"]
1498+
PrimeFaces.widgets.widget_form_startTime.setDate(new Date(2026, 7, 5, 19, 0, 0));
1499+
```
1500+
`setDate()` both sets the widget's internal date **and** re-serializes the
1501+
visible `_input` text using the field's configured pattern, so a DOM read
1502+
right after confirms the committed value. Verified end-to-end for issue
1503+
#20890: the typed-looking string round-tripped correctly through the
1504+
non-AJAX submit and the saved `PATIENTITEM.FROMTIME`/`TOTIME` matched. Only
1505+
use this shortcut for non-AJAX (full-postback) submits — for an AJAX
1506+
`p:datePicker` where the *change* event itself must fire a listener, this
1507+
bypasses that and the real key-event pattern would still be required (untested
1508+
here).
1509+
14831510
## Quick checklist
14841511

14851512
- [ ] Confirmed environment + URL with the developer; credentials kept out of the repo.

src/main/java/com/divudi/bean/inward/InwardProfessionalBillController.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,7 @@ public void saveProfessionalFeeBill() {
460460
makeNullList();
461461
current = null;
462462
settlePreview = true;
463+
surgeryBillController.refreshProEncounterComponents();
463464
JsfUtil.addSuccessMessage("Professional fee bill saved.");
464465
}
465466

src/main/java/com/divudi/bean/inward/InwardTimedItemController.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,7 @@ public void updateTimedService(BillFee bf) {
345345
bf.setFeeValue(value);
346346
bf.setFeeGrossValue(value);
347347
updateBillFee(bf);
348+
surgeryBillController.refreshTimedEncounterComponents();
348349
}
349350

350351
public void removeTimedEncFromList(EncounterComponent encounterComponent) {
@@ -366,6 +367,7 @@ public void removeTimedEncFromDbase(EncounterComponent encounterComponent) {
366367
updateBillItem(encounterComponent.getBillItem());
367368
updateBill(encounterComponent.getBillItem().getBill());
368369
getBillBean().updateBatchBill(getBatchBill());
370+
surgeryBillController.refreshTimedEncounterComponents();
369371
}
370372

371373
private void retiredEncounterComponent(EncounterComponent encounterComponent) {
@@ -569,6 +571,7 @@ public void saveSurgeryTimedService() {
569571
}
570572

571573
getBillBean().updateBatchBill(getBatchBill());
574+
surgeryBillController.refreshTimedEncounterComponents();
572575

573576
JsfUtil.addSuccessMessage("Surgery Detail Successfull Updated");
574577

src/main/java/com/divudi/bean/inward/SurgeryBillController.java

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,7 @@ public void removeTimeService(PatientItem patientItem) {
395395
patientItem.setRetiredAt(new Date());
396396
patientItem.setRetired(true);
397397
getPatientItemFacade().edit(patientItem);
398+
refreshTimedEncounterComponents();
398399
}
399400
}
400401

@@ -1292,7 +1293,7 @@ public void addProfessionalFee() {
12921293

12931294
public List<EncounterComponent> getProEncounterComponents() {
12941295
if (proEncounterComponents == null) {
1295-
proEncounterComponents = new ArrayList<>();
1296+
fetchProEncounterComponents();
12961297
}
12971298
return proEncounterComponents;
12981299
}
@@ -1301,6 +1302,29 @@ public void setProEncounterComponents(List<EncounterComponent> proEncounterCompo
13011302
this.proEncounterComponents = proEncounterComponents;
13021303
}
13031304

1305+
public void refreshProEncounterComponents() {
1306+
proEncounterComponents = null;
1307+
}
1308+
1309+
private void fetchProEncounterComponents() {
1310+
proEncounterComponents = new ArrayList<>();
1311+
if (surgeryBill == null || surgeryBill.getProcedure() == null
1312+
|| surgeryBill.getProcedure().getId() == null) {
1313+
return;
1314+
}
1315+
String jpql = "SELECT ec FROM EncounterComponent ec"
1316+
+ " WHERE ec.patientEncounter = :proc"
1317+
+ " AND ec.billItem.bill.surgeryBillType = :sbt"
1318+
+ " ORDER BY ec.orderNo";
1319+
HashMap<String, Object> params = new HashMap<>();
1320+
params.put("proc", surgeryBill.getProcedure());
1321+
params.put("sbt", SurgeryBillType.ProfessionalFee);
1322+
proEncounterComponents = getEncounterComponentFacade().findByJpql(jpql, params);
1323+
if (proEncounterComponents == null) {
1324+
proEncounterComponents = new ArrayList<>();
1325+
}
1326+
}
1327+
13041328
public PatientEncounterFacade getPatientEncounterFacade() {
13051329
return patientEncounterFacade;
13061330
}
@@ -1359,7 +1383,7 @@ public void setBillNumberBean(BillNumberGenerator billNumberBean) {
13591383

13601384
public List<EncounterComponent> getTimedEncounterComponents() {
13611385
if (timedEncounterComponents == null) {
1362-
timedEncounterComponents = new ArrayList<>();
1386+
fetchTimedEncounterComponents();
13631387
}
13641388
return timedEncounterComponents;
13651389
}
@@ -1368,6 +1392,22 @@ public void setTimedEncounterComponents(List<EncounterComponent> timedEncounterC
13681392
this.timedEncounterComponents = timedEncounterComponents;
13691393
}
13701394

1395+
public void refreshTimedEncounterComponents() {
1396+
timedEncounterComponents = null;
1397+
}
1398+
1399+
private void fetchTimedEncounterComponents() {
1400+
Bill timedBill = getSurgeryTimedServiceBill();
1401+
if (timedBill == null) {
1402+
timedEncounterComponents = new ArrayList<>();
1403+
return;
1404+
}
1405+
timedEncounterComponents = getBillBean().getEncounterComponents(timedBill);
1406+
if (timedEncounterComponents == null) {
1407+
timedEncounterComponents = new ArrayList<>();
1408+
}
1409+
}
1410+
13711411
public PatientItemFacade getPatientItemFacade() {
13721412
return patientItemFacade;
13731413
}

0 commit comments

Comments
 (0)