Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

No new dependencies are required in mod-circulation for Approach 1.

ModuleEndpointNew module dependencyPurpose

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

{
  "patronId": string,
  "balance": numeric,
"status": string
}

Example:

{
  "patronId": "1785d668-831e-11ea-bc55-0242ac130003",
  "balance": -15,
"status": "Aged to lost"
}
mod-circulationpublish

ITEM_CHECK_OUT_EVENT

{
  "patronId": string,
  "loanId": string,
  "dueDate": string
}
mod-circulationpublishITEM_CHECK_IN_EVENT
{
  "patronId": string,
"loanId": string,
"returnedDate": string
}
mod-circulationpublishITEM_DECLARED_LOST_EVENT
{
  "patronId": string,
"loanId": string
}
mod-circulationpublishLOAN_DUE_DATE_UPDATE_EVENT
{
  "patronId": string,
  "loanId": string,
  "dueDate": string,
"recall": boolean
}
mod-automatedblockssubscribe

PATRON_FEE_FINE_BALANCE_CHANGE_EVENT
ITEM_CHECK_OUT_EVENT
ITEM_CHECK_IN_EVENT
ITEM_DECLARED_LOST_EVENT
LOAN_DUE_DATE_UPDATE_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
languagetext
{
  "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:

ConditionCheck 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
languagetext
GET /automated-patron-blocks/{patronId}

Response example:

Code Block
languagetext
{
  "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

ModuleEndpointPurpose

mod-automated-blocks → mod-users

GET /patron-block-condition
GET /patron-block-limits?query=(patronGroupId=={patronGroupId})

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.