|
1 | | -batch-processor-filter-lambda |
| 1 | +# batch-processor-filter-lambda |
2 | 2 |
|
3 | | -TODO |
| 3 | +## Contributing to this project |
| 4 | +You will first need to have the required setup as specified in the root README. |
| 5 | + |
| 6 | +Then, getting set up to contribute to this Lambda is the same for any others. Refer to |
| 7 | +the `Setting up a virtual environment with poetry` section in the root README. Assuming 1 and 2 have already been done, |
| 8 | +then you will just need to follow steps 3-5 for this specific directory. |
| 9 | + |
| 10 | +Then run: |
| 11 | +``` |
| 12 | +make test |
| 13 | +``` |
| 14 | +to verify your setup. |
| 15 | + |
| 16 | +## Overview |
| 17 | +The context of this Lambda function should be understood within the following architecture diagram: |
| 18 | +https://nhsd-confluence.digital.nhs.uk/spaces/Vacc/pages/1161762503/Immunisation+FHIR+API+-+Batch+Ingestion+Improvements |
| 19 | + |
| 20 | +The purpose of the batch-processor-filter Lambda function is to ensure that there is only ever one batch file event |
| 21 | +processing at any given time for a given combination of `supplier` + `vaccination type`. This is because the order in |
| 22 | +which updates are applied is vital; for the same supplier/vacc type combination, there may be changes to the same |
| 23 | +patient's vaccination record across 2 different files. Therefore, the order in which they arrive must be preserved. |
| 24 | + |
| 25 | +The Lambda function consumes one event at a time on a per `message group id` (composed of the supplier name + vacc type) |
| 26 | +basis from an SQS FIFO queue. At a high-level, the pseudocode is as follows: |
| 27 | + |
| 28 | +- check the Audit Table for any duplicate named files and process accordingly if that is the case |
| 29 | +- check the Audit Table if there is already an event processing for the given supplier + vacc type |
| 30 | +- if there is not, then update the event's status in the Audit Table and forward to SQS for processing by ECS |
| 31 | +- if there is, then throw an error so that the event is returned to the queue and will be tried again later |
0 commit comments