[HOTE-1209] feat: Reactive Results: Set TEST_PROCESSED status#408
Merged
[HOTE-1209] feat: Reactive Results: Set TEST_PROCESSED status#408
Conversation
Signed-off-by: lewisbirks <lewis.birks1@nhs.net>
Signed-off-by: lewisbirks <lewis.birks1@nhs.net>
…r status handling
- Import extraction functions from validation-service instead of duplicating - Type buildTaskFromObservation() return as FHIRTask - Type sendResult() parameter as FHIRTask and remove error handling (let caller handle it)
…-result-processor
…-result-processor # Conflicts: # lambdas/package.json # lambdas/pnpm-lock.yaml
…te-1209/test-processed-status # Conflicts: # lambdas/src/lib/utils/validation-result.ts # lambdas/src/lib/validation/index.ts # lambdas/src/order-result-lambda/validation-service.ts # lambdas/src/order-result-lambda/validation.ts # lambdas/src/order-status-lambda/index.test.ts # lambdas/src/order-status-lambda/types.ts # lambdas/src/order-status-lambda/utils.ts
Contributor
There was a problem hiding this comment.
Pull request overview
Adds support for a new intermediate result state (TEST_PROCESSED → RESULT_PROCESSED) and introduces a new HIV result processor lambda plus supporting shared utilities/infra for invoking lambdas internally.
Changes:
- Extend
order-status-lambdato resolve incomingtest-processedbusiness status into a newRESULT_PROCESSEDresult status write. - Add
hiv-result-processor-lambdaand aLambdaHttpClientimplementation to invoke another lambda via the AWS Lambda API. - Update local Terraform, migrations, and repo tooling/docs to support the new lambda and status.
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| scripts/config/gitleaks.toml | Ignore pnpm store directories for secret scanning noise reduction. |
| local-environment/infra/outputs.tf | Expose HIV results processor lambda name as a Terraform output. |
| local-environment/infra/main.tf | Add invoke permissions + define HIV results processor lambda and env vars. |
| lambdas/src/result-status-lambda/index.ts | Add extra success log after DB updates. |
| lambdas/src/order-status-lambda/validation/task-validation.ts | New request body parsing + Zod validation helper. |
| lambdas/src/order-status-lambda/validation/task-validation.test.ts | Unit tests for task validation helper. |
| lambdas/src/order-status-lambda/validation/patient-validation.ts | New patient ownership validation helper. |
| lambdas/src/order-status-lambda/validation/patient-validation.test.ts | Unit tests for patient ownership validation. |
| lambdas/src/order-status-lambda/validation/correlation-id-validation.ts | New correlation-id extraction/validation helper. |
| lambdas/src/order-status-lambda/validation/correlation-id-validation.test.ts | Unit tests for correlation-id validation helper. |
| lambdas/src/order-status-lambda/utils.ts | Remove local utility/mapping in favour of shared/more structured modules. |
| lambdas/src/order-status-lambda/models/types.ts | Add TEST_PROCESSED business status + introduce StatusKind. |
| lambdas/src/order-status-lambda/models/schemas.ts | Move order-status task schema into a dedicated module. |
| lambdas/src/order-status-lambda/models/mappings.ts | Add mapping to resolve incoming business status into order vs result status updates. |
| lambdas/src/order-status-lambda/init.ts | Wire in new DB command for inserting result statuses. |
| lambdas/src/order-status-lambda/init.test.ts | Update init wiring assertions/mocks for new dependency. |
| lambdas/src/order-status-lambda/index.ts | Refactor handler to use validation helpers + support result status updates. |
| lambdas/src/order-status-lambda/index.test.ts | Remove previous handler-level tests. |
| lambdas/src/order-status-lambda/db/commands/insert-result-status.ts | Add DB command to insert result_status rows idempotently. |
| lambdas/src/order-status-lambda/db/commands/insert-result-status.test.ts | Unit tests for insert-result-status command SQL/params. |
| lambdas/src/order-result-lambda/validation-service.ts | Move FHIR observation field extraction into shared lib module; reuse shared validation types. |
| lambdas/src/order-result-lambda/index.ts | Update interpretation extraction call site to use shared extractor. |
| lambdas/src/lib/validation/index.ts | Fix import path and formatting in shared validation module. |
| lambdas/src/lib/utils/fhir-utils.ts | Introduce shared extractIdFromReference helper. |
| lambdas/src/lib/types/status.ts | Add Result_Processed to the shared ResultStatus enum. |
| lambdas/src/lib/http/lambda-http-client.ts | New HttpClient implementation that invokes another lambda via InvokeCommand. |
| lambdas/src/lib/http/lambda-http-client.test.ts | Unit tests for LambdaHttpClient request/response/error behaviour. |
| lambdas/src/lib/fhir-observation-extractors/index.ts | New shared observation field extractors (moved from order-result-lambda). |
| lambdas/src/lib/fhir-observation-extractors/index.test.ts | Unit tests for shared observation extractors. |
| lambdas/src/lib/db/test-result-db-client.ts | Formatting-only refactor of query invocation. |
| lambdas/src/hiv-result-processor-lambda/services/result-status-lambda-service.ts | Service wrapper to call result-status lambda via HttpClient. |
| lambdas/src/hiv-result-processor-lambda/services/result-status-lambda-service.test.ts | Unit tests for the service wrapper. |
| lambdas/src/hiv-result-processor-lambda/models/interpretation.ts | Add InterpretationCode enum for HIV processor decisioning. |
| lambdas/src/hiv-result-processor-lambda/init.ts | New init wiring for LambdaClient + LambdaHttpClient + service. |
| lambdas/src/hiv-result-processor-lambda/init.test.ts | Unit tests for init wiring and singleton behaviour. |
| lambdas/src/hiv-result-processor-lambda/index.ts | New lambda handler to process HIV observation and invoke status lambda. |
| lambdas/src/hiv-result-processor-lambda/index.test.ts | Unit tests for HIV processor handler branches and error handling. |
| lambdas/src/hiv-result-processor-lambda/builders/task-builder.ts | Build a FHIR Task payload from an Observation for downstream status update. |
| lambdas/src/hiv-result-processor-lambda/builders/task-builder.test.ts | Unit tests for task builder output and failure modes. |
| lambdas/pnpm-lock.yaml | Lockfile updates for new AWS SDK Lambda client dependency. |
| lambdas/package.json | Add @aws-sdk/client-lambda dependency. |
| lambdas/README.md | Document local invocation of lambdas via AWS CLI (LocalStack). |
| database/migrations/000011_add_result_processed_status.sql | Seed new RESULT_PROCESSED into result_type. |
| .pre-commit-config.yaml | Exclude pnpm artifacts from formatting/lint hooks. |
| .gitignore | Ignore pnpm store/artifacts and pnpm error/debug logs. |
| .github/instructions/lambdas.instructions.md | Update internal lambda docs (invocation modes, HttpClient guidance, middleware notes). |
TSeelig
approved these changes
Apr 28, 2026
iichr
reviewed
Apr 28, 2026
…te-1209/test-processed-status # Conflicts: # lambdas/goose-migrator-lambda/migrations/000011_add_result_processed_status.sql
ravikumarqa28
approved these changes
Apr 28, 2026
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Description
https://nhsd-jira.digital.nhs.uk/browse/HOTE-1209
Context
Type of changes
Checklist
Sensitive Information Declaration
To ensure the utmost confidentiality and protect your and others privacy, we kindly ask you to NOT including PII (Personal Identifiable Information) / PID (Personal Identifiable Data) or any other sensitive data in this PR (Pull Request) and the codebase changes. We will remove any PR that do contain any sensitive information. We really appreciate your cooperation in this matter.