...
No new dependencies are required in mod-circulation for Approach 1.
Module | Endpoint | New module dependency | Purpose |
---|---|---|---|
mod-circulation → mod-users | /patron-block-condition /patron-block-limits?query=(patronGroupId=={patronGroupId}) | No | Get conditions and limits to be checked. |
mod-circulation → mod-feesfines | /accounts?query=(userId=={patronId} AND status=="Open") | No | Check outstanding fee/fine balance and number of open fees/fines for lost items. |
mod-circulation → mod-calendar | /calendar/periods | No | Calculate the overdue period (already implemented in CIRC-548). |
Approach 2 (new module; pub-sub)
New module (mod-automated-blocks) will be created. It will receive info about circulation events and fees/fines from event subscriptions.
Publishing/subscriptions configuration
Module | Publish/subscribe | Event type | Payload |
---|---|---|---|
mod-feesfines | publish | PATRON_FEE_FINE_BALANCE_CHANGE_EVENT | { |
mod-circulation | publish | ITEM_CHECK_OUT_EVENT | { |
mod-circulation | publish | ITEM_CHECK_IN_EVENT | { |
mod-circulation | publish | ITEM_DECLARED_LOST_EVENT | { |
mod-circulation | publish | LOAN_DUE_DATE_UPDATE_EVENT | { |
mod-automatedblocks | subscribe | PATRON_FEE_FINE_BALANCE_CHANGE_EVENT |
...
Using the info from events mod-automated-blocks is subscribed to, we need to maintain one object per patron in the DB:
Code Block | ||
---|---|---|
| ||
{ "patronId": string, "outstandingFeeFineBalance": numeric, "numberOfOpenFeesFinesForLostItems": numeric, "numberOfLostItems": numeric, "openLoans": [ { "loanId": string, "dueDate": string, "returnedDate": string, "recall": boolean } ] } |
This object allows to check each of the required block conditions for a patron:
Condition | Check against |
---|---|
Maximum outstanding fee/fine balance | .outstandingFeeFineBalance |
Maximum number of items charged out | number of .openLoans objects |
Maximum number of lost items | .numberOfOpenFeesFinesForLostItems |
Maximum number of overdue items | number of .openLoans[dueDate < returnedDate] |
Maximum number of overdue recalled items | number of .openLoans[dueDate < returnedDate AND recall == true] |
Maximum number of overdue days for recalled item | max of .openLoans[dueDate < returnedDate AND recall == true].(returnedDate - dueDate) |
API
mod-automated-blocks will provide one endpoint that other modules will use to determine if patron should be blocked from borrowing, renewing and/or requesting items and why:
Code Block | ||
---|---|---|
| ||
GET /automated-patron-blocks/{patronId} |
Response example:
Code Block | ||
---|---|---|
| ||
{
"automatedPatronBlocks": [
{
"blockBorrowing": true,
"blockRenewal": false,
"blockRequest": false,
"message": "Patron has reached maximum allowed number of items charged out"
},
{
"blockBorrowing": false,
"blockRenewal": false,
"blockRequest": true,
"message": "Patron has reached maximum allowed outstanding fee/fine balance for his/her patron group"
}
]
} |
Dependencies
Module | Endpoint | Purpose |
---|---|---|
mod-automated-blocks → mod-users | GET /patron-block-condition | Get conditions and limits to be checked. |
mod-circulation → mod-automated-blocks | GET /automated-patron-blocks/{patronId} | Check if action is allowed before borrowing, renewing and/or requesting items. |