Bug 30719 - ILL should provide the ability to create batch requests
Summary: ILL should provide the ability to create batch requests
Status: Needs Signoff
Alias: None
Product: Koha
Classification: Unclassified
Component: ILL (show other bugs)
Version: master
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Pedro Amorim
QA Contact:
URL:
Keywords:
Depends on: 32768
Blocks:
  Show dependency treegraph
 
Reported: 2022-05-09 11:04 UTC by Andrew Isherwood
Modified: 2023-02-03 15:09 UTC (History)
5 users (show)

See Also:
Change sponsored?: Sponsored
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments
Bug 30719: Batch requests minor misc improvements (4.26 KB, patch)
2022-11-28 12:54 UTC, Pedro Amorim
Details | Diff | Splinter Review
Bug 30719: DB, API & tests (42.93 KB, patch)
2022-11-28 15:50 UTC, Pedro Amorim
Details | Diff | Splinter Review
Bug 30719: Batch ILL requests (89.40 KB, patch)
2022-11-28 15:51 UTC, Pedro Amorim
Details | Diff | Splinter Review
Bug 30719: Logging of batch operations (3.33 KB, patch)
2022-11-28 15:51 UTC, Pedro Amorim
Details | Diff | Splinter Review
Bug 30719: Batch statuses (72.10 KB, patch)
2022-11-28 15:52 UTC, Pedro Amorim
Details | Diff | Splinter Review
Bug 30719: DB, API & tests (42.93 KB, patch)
2022-11-28 15:53 UTC, Pedro Amorim
Details | Diff | Splinter Review
Bug 30719: Batch requests minor misc improvements (4.27 KB, patch)
2022-11-28 16:06 UTC, Pedro Amorim
Details | Diff | Splinter Review
Bug 30719: DB, API & tests (42.93 KB, patch)
2022-11-28 16:26 UTC, Pedro Amorim
Details | Diff | Splinter Review
Bug 30719: Batch ILL requests (89.40 KB, patch)
2022-11-28 16:27 UTC, Pedro Amorim
Details | Diff | Splinter Review
Bug 30719: Logging of batch operations (3.33 KB, patch)
2022-11-28 16:27 UTC, Pedro Amorim
Details | Diff | Splinter Review
Bug 30719: Batch statuses (72.10 KB, patch)
2022-11-28 16:27 UTC, Pedro Amorim
Details | Diff | Splinter Review
Bug 30719: Batch requests minor misc improvements (4.27 KB, patch)
2022-11-28 16:28 UTC, Pedro Amorim
Details | Diff | Splinter Review
Koha 22.11.00 Rosalie is here! (1.35 KB, patch)
2022-11-28 16:49 UTC, Pedro Amorim
Details | Diff | Splinter Review
Koha 22.11.00 Rosalie is here! (1.35 KB, patch)
2022-11-28 16:59 UTC, Pedro Amorim
Details | Diff | Splinter Review
Bug 30719: DB, API & tests (42.98 KB, patch)
2022-11-28 17:42 UTC, Pedro Amorim
Details | Diff | Splinter Review
Bug 30719: Batch ILL requests (89.46 KB, patch)
2022-11-28 17:42 UTC, Pedro Amorim
Details | Diff | Splinter Review
Bug 30719: Logging of batch operations (3.39 KB, patch)
2022-11-28 17:42 UTC, Pedro Amorim
Details | Diff | Splinter Review
Bug 30719: Batch statuses (72.16 KB, patch)
2022-11-28 17:42 UTC, Pedro Amorim
Details | Diff | Splinter Review
Bug 30719: Batch requests minor misc improvements (4.32 KB, patch)
2022-11-28 17:42 UTC, Pedro Amorim
Details | Diff | Splinter Review
Bug 30719: (QA Follow-up): (5.68 KB, patch)
2023-01-27 16:54 UTC, Pedro Amorim
Details | Diff | Splinter Review
Bug 30719: (QA Follow-up): (8.81 KB, patch)
2023-01-31 13:52 UTC, Pedro Amorim
Details | Diff | Splinter Review
Bug 30719: (QA Follow-up): (8.83 KB, patch)
2023-01-31 13:54 UTC, Pedro Amorim
Details | Diff | Splinter Review
Bug 30719: (QA Follow-up): (10.02 KB, patch)
2023-01-31 14:30 UTC, Pedro Amorim
Details | Diff | Splinter Review
Bug 30719: (QA Follow-up): (17.63 KB, patch)
2023-02-01 12:14 UTC, Pedro Amorim
Details | Diff | Splinter Review
Bug 30719: (QA Follow-up): (19.43 KB, patch)
2023-02-03 15:09 UTC, Pedro Amorim
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Isherwood 2022-05-09 11:04:36 UTC
Some interlibrary loan providers, for example Reprints Desk, allow for ILL requests to be submitted in batches.

In the Reprints Desk case, a batch is created with the supplier, then requests are then submitted including the batch ID. Obviously, this workflow may differ according to supplier and these differences should be abstracted away into the supplier backend.

For core Koha, we should provide the ability for it to recognise if a given backend can process batch requests. If so, we should provide an interface for creating and manipulating batches within Koha, then submitting a batch to the supplier. It should also be possible to view all batches and the contents of a given batch.

The funding institution has defined the following workflow for creating and populating batches:

- A encapsulating "batch" is created with a name and a requesting borrower
- Requests are added to a batch via two methods:
    - In bulk:
        - A form which allows the user to paste in a collection of identifiers, such as DOI / PMID etc.
        - For each of these identifiers:
          - The request metadata should be populated via API queries to metadata suppliers, for example, PubMed API or LibKey/Browzine. This behaviour is governed by the presence of appropriate plugins.
          - (Optional) Once the metadata is populated for an item, we check for item availability via any installed ILL availability plugins
    - Individually:
        - A regular ILL request form, requests are added to the batch
Comment 1 Pedro Amorim 2022-11-28 12:54:31 UTC Comment hidden (obsolete)
Comment 2 Pedro Amorim 2022-11-28 15:50:34 UTC Comment hidden (obsolete)
Comment 3 Pedro Amorim 2022-11-28 15:51:30 UTC Comment hidden (obsolete)
Comment 4 Pedro Amorim 2022-11-28 15:51:59 UTC Comment hidden (obsolete)
Comment 5 Pedro Amorim 2022-11-28 15:52:31 UTC Comment hidden (obsolete)
Comment 6 Pedro Amorim 2022-11-28 15:53:13 UTC Comment hidden (obsolete)
Comment 7 Pedro Amorim 2022-11-28 15:54:20 UTC Comment hidden (obsolete)
Comment 8 Pedro Amorim 2022-11-28 16:06:46 UTC Comment hidden (obsolete)
Comment 9 Pedro Amorim 2022-11-28 16:26:28 UTC Comment hidden (obsolete)
Comment 10 Pedro Amorim 2022-11-28 16:27:01 UTC Comment hidden (obsolete)
Comment 11 Pedro Amorim 2022-11-28 16:27:29 UTC Comment hidden (obsolete)
Comment 12 Pedro Amorim 2022-11-28 16:27:58 UTC Comment hidden (obsolete)
Comment 13 Pedro Amorim 2022-11-28 16:28:23 UTC Comment hidden (obsolete)
Comment 14 Pedro Amorim 2022-11-28 16:39:29 UTC Comment hidden (obsolete)
Comment 15 Pedro Amorim 2022-11-28 16:49:59 UTC Comment hidden (obsolete)
Comment 16 Pedro Amorim 2022-11-28 16:59:22 UTC Comment hidden (obsolete)
Comment 17 Pedro Amorim 2022-11-28 17:42:01 UTC
Created attachment 144298 [details] [review]
Bug 30719: DB, API & tests

This commit adds the following:

- A database update that adds an "illbatches" table, a
"illrequest.batch_id" foreign key and an "illbatches.borrowernumber"
foreign key
- Illbatch and Illbatches Koha objects
- Adds 'batch' accessor to Illrequest object
- CRUD API endpoints for working with ILL batches
- Unit tests of the Koha objects and API endpoints
- Adds 'batch_id' filter to /illrequests endpoint

Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com>
Comment 18 Pedro Amorim 2022-11-28 17:42:06 UTC
Created attachment 144299 [details] [review]
Bug 30719: Batch ILL requests

- Add API endpoint for ILL request creation
- UI for creation of ILL batches, including:
  - Ability to paste in list of identifier
  - Auto metadata enrichment for each identifier, using installed third party service API plugins
  - Auto retrieval of identifier availability, using installed third party service API plugins
  - Auto creation of local requests within batch
- UI for management of existing ILL batches, including adding requests to, and removing requests from, batches
- Additional UI to allow users to navigate from requests to their enclosing batches and vice-versa

Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com>
Comment 19 Pedro Amorim 2022-11-28 17:42:11 UTC
Created attachment 144300 [details] [review]
Bug 30719: Logging of batch operations

This commit adds logging of the following batch operations:

- Batch creation
- Batch update (Updating of the batch itself, not its contents)
- Batch delete

Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com>
Comment 20 Pedro Amorim 2022-11-28 17:42:17 UTC
Created attachment 144301 [details] [review]
Bug 30719: Batch statuses

This commits adds the following provision for batch statuses:

- Database updates
- Object definitions
- CRUD REST API
- Unit tests
- UI adding support for batch statuses in batch UI
- Admin UI for managing batch statuses

Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com>
Comment 21 Pedro Amorim 2022-11-28 17:42:22 UTC Comment hidden (obsolete)
Comment 22 Marcel de Rooy 2023-01-27 09:22:31 UTC
Looking at bug history, I am asking for another signoff please.
Comment 23 Martin Renvoize 2023-01-27 11:25:18 UTC
I'm asking the customer whose sponsored this work to SO. We got a bit ahead of ourselves here.
Comment 24 Pedro Amorim 2023-01-27 16:54:39 UTC Comment hidden (obsolete)
Comment 25 Pedro Amorim 2023-01-31 13:52:09 UTC Comment hidden (obsolete)
Comment 26 Pedro Amorim 2023-01-31 13:54:16 UTC Comment hidden (obsolete)
Comment 27 Pedro Amorim 2023-01-31 14:30:11 UTC Comment hidden (obsolete)
Comment 28 Pedro Amorim 2023-02-01 12:14:24 UTC Comment hidden (obsolete)
Comment 29 Pedro Amorim 2023-02-01 12:19:10 UTC
Apply patches, on ktd, preparation:
- Run dbic
- Run reset_all
- Enable ILLModule sys pref
- At least one ILL batch status needs to exist, admin -> (bottom right) Interlibrary Loan batch statuses, add that (name:NEW status:NEW)
- At least one ILL Backend with "provide_batch_requests" capability needs to exist, add ReprintsDesk backend from https://github.com/PTFS-Europe/koha-ill-reprintsdesk to kohadevbox/koha/Koha/Illbackends with name 'ReprintsDesk'
- Update backend_directory in koha-conf.xml to <backend_directory>/kohadevbox/koha/Koha/Illbackends</backend_directory>
- At least one metadata enrichment plugin needs to exist, admin -> Manage plugins add that (https://github.com/PTFS-Europe/koha-plugin-api-pubmed/releases/tag/1.1.0)
- restart_all
- Run yarn build to update CSS

Test plan:
- Go to ILL Requests admin area, click "New ILL batch request" and select ReprintsDesk
- Create new batch (insert name, cardnumber and library) and press "continue"
- Add PubMed ID, one per line (example: 23668524\n29710265) and press "Process identifiers"
- After processing is complete, click "add items to batch" and then "finish and view batch"

Verify that:
- The items requested in the batch are now illrequests in Koha, and are part of the batch that was just created
- Clicking on "Batch requests" lists all existing batches
- From the previous step, clicking on a batch name lists only the requests from that batch
- If a batch is deleted, whatever requests that were previously on that batch are not deleted (their batch_id is now NULL)
- When editing a request that is part of a batch, it's possible to change which batch the request is part of, or none.

(Optional) Test logging:
- Before doing the above, enable illlog sys pref
- Do some CRUD actions on batch requests
- Check log viewer -> module "Interlibrary loans"
- Verify that the actions performed have been logged

(Optional) Test error messaging:
- Try creating a batch with an already existing batch name, verify it doesn't create and error message shows appropriately
- Try creating a batch with a non-existent borrower cardnumber, verifiy it doesn't create the batch and error message shows appropriately

Run tests and ensure all are passing:
prove -v t/db_dependent/Illbatches.t
prove -v t/db_dependent/api/v1/illbatches.t
prove -v t/db_dependent/IllbatchStatuses.t
prove -v t/db_dependent/api/v1/illbatchstatuses.t
Comment 30 Pedro Amorim 2023-02-03 15:09:32 UTC
Created attachment 146152 [details] [review]
Bug 30719: (QA Follow-up):

- Fix wrong link 'Create a new batch status message' in case there are no existing batch statuses
- Detail of batch update - View status of any request within a batch
- Fix typo to correctly display status code on batch statuses list page
- Fixed an issue with illrequest api definition that prevented the listing of any ILL requests if any request had a status_alias
- Updated "Add items to batch" css class to match new 22.11 style
- Fixed conflict issue where it prevented the creation of a single request in a backend that is using JS field validation utilizing the #cardnumber selector
- Added a check for metadata enrichment plugins and bail batches JS code if none are found, this prevents a console error
- Remove ysearch from patron auto complete in batch creation and use patron_autocomplete instead
- 'New batch' and 'list batches' buttons no longer show if no metadata plugin is installed
- Fixed tests, all passing now
- Improved error messaging for non-existent cardnumber input in patron in ill batch creation
- Improved error messaging for duplicate batch name creation error
- Fix sidemenu filters and search not working after new batch_id column

Sponsored-by: UKHSA