O3-5692: Build a dedicated REST endpoint for queue entries#114
O3-5692: Build a dedicated REST endpoint for queue entries#114UjjawalPrabhat wants to merge 3 commits into
Conversation
jwnasambu
left a comment
There was a problem hiding this comment.
@UjjawalPrabhat this is a good progress . Kindly make the following updates here:
- Update SUMMARY_REPRESENTATION to include patientIdentifier.
- Add logic to rename patientIdentifier to identifier and flatten the patient object.
jwnasambu
left a comment
There was a problem hiding this comment.
Also create this file to include test cases for
getQueueEntrySummaries_shouldReturnPaginatedSummariesWithIdentifier,
shouldHandleTotalCountRequest, and shouldReturnEmptyListWhenNoResults. I know the PR originally focuses on DAO tests but without Controller tests there is
no verification that the final JSON keys like identifier or visitUuid are correctly
transformed for the frontend.
| * {@code queueComingFrom}. Entries without a resolvable predecessor are absent from the result. | ||
| */ | ||
| @Authorized({ PrivilegeConstants.GET_QUEUE_ENTRIES }) | ||
| Map<QueueEntry, String> getPreviousQueueEntryUuids(Collection<QueueEntry> entries); |
There was a problem hiding this comment.
Kindly to follow the 3-layer architectural pattern (Controller -> Service -> DAO) mentioned in the PR description, please expose
this method getPreviousQueueEntryUuids in the Service interface to ensures that the logic is available to the REST
controller while maintaining proper security and transaction boundaries. please don't forget to add the @Authorized annotation for
PrivilegeConstants.GET_QUEUE_ENTRIES."
There was a problem hiding this comment.
This is already in place, the method is declared on QueueEntryService at line 146 with @Authorized({ PrivilegeConstants.GET_QUEUE_ENTRIES }) on line 145. Let me know if you're seeing something different.
| public Map<QueueEntry, String> getPreviousQueueEntryUuids(Collection<QueueEntry> entries) { | ||
| return dao.getPreviousQueueEntryUuids(entries); | ||
| } |
There was a problem hiding this comment.
Kindly provide the implementation for getPreviousQueueEntryUuids by delegating the call to the DAO layer. This maintains
consistency with the patterns used in emrapi and ensures the service layer remains the primary entry point for business logic.
There was a problem hiding this comment.
The implementation at lines 228-230 delegates to the DAO - return dao.getPreviousQueueEntryUuids(entries); with @Override + @Transactional(readOnly = true) on the lines above. Happy to adjust if you'd like a different pattern.
|
|
||
| QueueEntryService queueEntryService = services.getQueueEntryService(); | ||
| List<QueueEntry> entries = queueEntryService.getQueueEntries(criteria, context.getStartIndex(), context.getLimit()); | ||
| Map<QueueEntry, String> previousUuids = queueEntryService.getPreviousQueueEntryUuids(entries); |
There was a problem hiding this comment.
In the controller, please ensure you are calling queueEntryService.getPreviousQueueEntryUuids() rather than trying to
access the DAO directly. This preserves the architectural integrity of the module.
There was a problem hiding this comment.
The controller calls the service, not the DAO — queueEntryService.getPreviousQueueEntryUuids(entries) on line 71, where queueEntryService is obtained from services.getQueueEntryService() on line 69. There's no DAO reference anywhere in the controller.
|
|
Hi @UjjawalPrabhat, some questions I have:
|



Summary
The Service Queues table currently loads via
QueueEntryResourcewith a deep customv=representation that pulls every encounter, obs, and diagnosis on each patient's visit. On a 50-entry queue this triggers hundreds of cascading Hibernate loads; ~95% of the bytes are never read by the table.Adds
GET /rest/v1/queue-entry-summary— flat, server-paginated, withpreviousQueueEntryUuidresolved via a single batch IN-clause query instead of the per-row N+1 path throughgetPreviousQueueEntry.Mirrors the three-layer batch pattern from openmrs-module-emrapi PR #250.
Response shape
Before (
/queue-entry?v=custom:(…)as requested by the frontend):{ "uuid": "...", "display": "...", "queue": { "uuid": "...", "display": "...", "name": "...", "description": "...", "service": {...}, "location": {...} }, "status": { "uuid": "...", "display": "...", "name": {...}, "datatype": {...}, "conceptClass": {...}, "set": false, "version": "...", "retired": false, "names": [...], "descriptions": [...], "mappings": [...], "answers": [...], "setMembers": [...], ... }, "priority": { /* same deep Concept shape */ }, "patient": { "uuid": "...", "display": "...", "identifiers": [ { "uuid": "...", "identifier": "...", "identifierType": {...}, "location": {...}, "preferred": true, ... } ], "person": { /* full person graph */ } }, "visit": { "uuid": "...", "startDatetime": "...", "encounters": [ { "uuid": "...", "display": "...", "encounterDatetime": "...", "encounterType": {...}, "diagnoses": [ { /* full diagnosis */ } ], "obs": [ { /* full obs, recursively */ } ], "encounterProviders": [ { /* full provider */ } ], "voided": false } /* …every encounter on the visit, each with its full obs/diagnoses/providers graph */ ], "attributes": [ { /* full visit attributes */ } ] }, "priorityComment": "...", "sortWeight": 0.0, "startedAt": "...", "endedAt": null, "locationWaitingFor": {...}, "providerWaitingFor": {...}, "queueComingFrom": {...}, "previousQueueEntry": { /* full QueueEntry, recursively */ } }After (
/queue-entry-summary):{ "uuid": "...", "patient": { "uuid": "...", "display": "100GEJ - John Doe" }, "queue": { "uuid": "...", "display": "Triage" }, "status": { "uuid": "...", "display": "Waiting" }, "priority": { "uuid": "...", "display": "Not urgent" }, "priorityComment": "...", "startedAt": "2026-05-25T09:00:00.000+0000", "visitUuid": "...", "visitStartDatetime": "2026-05-25T08:55:00.000+0000", "previousQueueEntryUuid": null }Relate Issue
O3-5692