[HOTE-1138] feat: simplify results lambda#404
[HOTE-1138] feat: simplify results lambda#404TSeelig wants to merge 8 commits intofeature/hote-1209/test-processed-statusfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors order-result-lambda so that, after request validation and DB/idempotency checks, the validated FHIR Observation is handed off to a downstream “result processor” Lambda (removing HIV-specific processing from this lambda to support other test types later).
Changes:
- Add a lambda-invocation client (
AWSLambdaClient) and aResultProcessingHandoffServiceto invoke the downstream processor lambda. - Update
order-result-lambdato delegate validated results to the handoff service and adjust unit tests accordingly. - Update local Terraform to grant invoke permissions and pass the processor function name via environment variable.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| local-environment/infra/main.tf | Adds an IAM inline policy for lambda invoke and updates env vars for order_result_lambda |
| lambdas/src/order-result-lambda/result-processing-service.ts | New service that invokes the processor lambda with the validated observation |
| lambdas/src/order-result-lambda/result-processing-service.test.ts | Unit tests for the new handoff service |
| lambdas/src/order-result-lambda/models.ts | Adds a handoff message type and updates Observation schema constraints |
| lambdas/src/order-result-lambda/init.ts | Wires in AWSLambdaClient + ResultProcessingHandoffService and reads RESULT_PROCESSING_FUNCTION_NAME |
| lambdas/src/order-result-lambda/init.test.ts | Extends init tests to cover the new dependency/env var |
| lambdas/src/order-result-lambda/index.ts | Delegates validated observations to resultProcessingService and adds middy wrapper export pattern |
| lambdas/src/order-result-lambda/index.test.ts | Updates handler tests to assert delegation to the new service |
| lambdas/src/order-result-lambda/cors-configuration.ts | Adds lambda-specific CORS options composition |
| lambdas/src/lib/lambda/lambda-client.ts | New reusable AWS Lambda invoke client wrapper |
| lambdas/src/lib/lambda/lambda-client.test.ts | Unit tests for the new lambda client wrapper |
0144d58 to
2fd31c4
Compare
There was a problem hiding this comment.
Pull request overview
Refactors order-result-lambda to validate incoming FHIR Observations and hand off downstream test-specific processing to a separate “result processor” Lambda, introducing a shared Lambda invocation client to support this new flow.
Changes:
- Added
ResultProcessingHandoffServiceinorder-result-lambdaand wired it viainit.tsusing a newRESULT_PROCESSING_FUNCTION_NAMEenv var. - Introduced a shared
AWSLambdaClient(src/lib/lambda/lambda-client.ts) for synchronous Lambda-to-Lambda invocation and response parsing. - Updated local Terraform to grant invoke permissions and set the result-processing function name for the local environment.
Reviewed changes
Copilot reviewed 12 out of 13 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| local-environment/infra/main.tf | Adds IAM policy for Lambda invocation and updates env vars for order_result_lambda. |
| lambdas/src/order-result-lambda/result-processing-service.ts | New service to invoke the downstream result processor Lambda. |
| lambdas/src/order-result-lambda/result-processing-service.test.ts | Unit tests for the new result processing handoff service. |
| lambdas/src/order-result-lambda/models.ts | Adds handoff message model and adjusts Observation schema. |
| lambdas/src/order-result-lambda/init.ts | Wires Lambda client + handoff service and reads new env var. |
| lambdas/src/order-result-lambda/init.test.ts | Updates init wiring tests for new dependencies/env var. |
| lambdas/src/order-result-lambda/index.ts | Replaces in-lambda HIV processing with delegation + adds Middy wrapper. |
| lambdas/src/order-result-lambda/index.test.ts | Updates handler tests to validate delegation to the processing service. |
| lambdas/src/order-result-lambda/cors-configuration.ts | Adds CORS options module for the lambda. |
| lambdas/src/lib/lambda/lambda-client.ts | New shared AWS Lambda invoke client wrapper with payload decoding/validation. |
| lambdas/src/lib/lambda/lambda-client.test.ts | Unit tests for the new Lambda client wrapper. |
| lambdas/package.json | Adds @aws-sdk/client-lambda dependency. |
| lambdas/package-lock.json | Locks the new dependency tree for @aws-sdk/client-lambda. |
Files not reviewed (1)
- lambdas/package-lock.json: Language not supported
2fd31c4 to
5684f46
Compare
5684f46 to
f4afc08
Compare
f4afc08 to
6b2434f
Compare
There was a problem hiding this comment.
Pull request overview
This PR refactors order-result-lambda to stop performing HIV-specific result processing and instead hand off validated FHIR Observations to a downstream “result processor” Lambda, supporting a more extensible multi-test flow.
Changes:
- Added a Lambda invocation client (
AWSLambdaClient) and aResultProcessingHandoffServiceto invoke the downstream processor function. - Updated
order-result-lambdahandler to delegate validated results to the processor lambda and adjusted unit tests accordingly. - Updated local Terraform to allow Lambda→Lambda invocation and configured the processor function name via env var.
Reviewed changes
Copilot reviewed 12 out of 13 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| local-environment/infra/main.tf | Adds IAM policy for InvokeFunction and sets processor function name env var for order-result in local infra. |
| lambdas/src/order-result-lambda/result-processing-service.ts | New service to hand off validated observations to the processor Lambda. |
| lambdas/src/order-result-lambda/result-processing-service.test.ts | Unit tests for the new handoff service behavior. |
| lambdas/src/order-result-lambda/models.ts | Adds a handoff message shape and formatting/quoting normalization. |
| lambdas/src/order-result-lambda/init.ts | Wires AWSLambdaClient + ResultProcessingHandoffService into the lambda environment. |
| lambdas/src/order-result-lambda/init.test.ts | Updates init tests for new dependencies + mandatory env var. |
| lambdas/src/order-result-lambda/index.ts | Switches to lambdaHandler + middy wrapper; delegates processing to downstream lambda; retains notification dispatch logic. |
| lambdas/src/order-result-lambda/index.test.ts | Updates handler unit tests to mock the new processing service and new error path. |
| lambdas/src/order-result-lambda/cors-configuration.ts | Adds per-lambda CORS options merged from shared defaults. |
| lambdas/src/lib/lambda/lambda-client.ts | New AWS SDK v3 Lambda invoke wrapper that decodes and validates proxy-style responses. |
| lambdas/src/lib/lambda/lambda-client.test.ts | Unit tests for AWSLambdaClient success and error cases. |
| lambdas/package.json | Adds @aws-sdk/client-lambda dependency. |
| lambdas/package-lock.json | Locks transitive deps for @aws-sdk/client-lambda. |
Files not reviewed (1)
- lambdas/package-lock.json: Language not supported
6b2434f to
cadb769
Compare
cadb769 to
7ac209b
Compare
There was a problem hiding this comment.
Pull request overview
This PR refactors order-result-lambda to validate incoming FHIR Observations and then hand off the validated payload to a dedicated “result processor” Lambda (supporting the new multi-lambda results flow described in HOTE-1138/HOTE-1099).
Changes:
- Added a
ResultProcessingHandoffServiceand wiring inorder-result-lambdato invoke a downstream Lambda after validation. - Introduced a shared
AWSLambdaClientwrapper (AWS SDK v3) for Lambda-to-Lambda invocation, with unit tests. - Updated local Terraform to grant invoke permissions and pass the downstream function name via env var.
Reviewed changes
Copilot reviewed 12 out of 13 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| local-environment/infra/main.tf | Adds IAM policy for lambda:InvokeFunction and injects RESULT_PROCESSING_FUNCTION_NAME into order_result_lambda (currently broken due to missing/incorrect module references and missing env vars). |
| lambdas/src/order-result-lambda/index.ts | Switches handler to Middy pattern and delegates validated results to resultProcessingService. |
| lambdas/src/order-result-lambda/init.ts | Wires AWSLambdaClient + ResultProcessingHandoffService into the lambda environment. |
| lambdas/src/order-result-lambda/models.ts | Formatting updates + adds ResultProcessingHandoffMessage type used for inter-lambda payloads. |
| lambdas/src/order-result-lambda/result-processing-service.ts | New service that invokes the downstream processor Lambda with { headers, body } payload. |
| lambdas/src/order-result-lambda/cors-configuration.ts | Adds lambda-specific CORS options built on shared defaults. |
| lambdas/src/order-result-lambda/*.test.ts | Updates/introduces unit tests for the new handoff service, init wiring, and handler behavior. |
| lambdas/src/lib/lambda/lambda-client.ts | New Lambda client wrapper around @aws-sdk/client-lambda with response decoding/validation. |
| lambdas/src/lib/lambda/lambda-client.test.ts | Unit tests for the Lambda client wrapper. |
| lambdas/package.json | Adds @aws-sdk/client-lambda dependency. |
| lambdas/package-lock.json | Lockfile update for the new dependency and transitive packages. |
Files not reviewed (1)
- lambdas/package-lock.json: Language not supported
7ac209b to
35159a0
Compare
35159a0 to
e225ef1
Compare
There was a problem hiding this comment.
Pull request overview
This PR refactors order-result-lambda to stop performing HIV-specific result processing itself and instead hand off validated FHIR Observations to a downstream “result processor” Lambda, adding a small shared Lambda invocation client and wiring/config updates.
Changes:
- Add
ResultProcessingHandoffServiceand inject it viaorder-result-lambda/init.tsto invoke a downstream processor Lambda. - Refactor
order-result-lambda/index.tsto delegate processing and adopt the repo’slambdaHandler+ Middy-wrappedhandlerstructure. - Add local-environment Terraform wiring for invocation permissions and a new
RESULT_PROCESSING_FUNCTION_NAMEenv var.
Reviewed changes
Copilot reviewed 12 out of 13 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| local-environment/infra/main.tf | Adds IAM policy + env var to allow order-result to invoke a processor lambda in local env |
| lambdas/src/order-result-lambda/result-processing-service.ts | New service that invokes the downstream processor lambda |
| lambdas/src/order-result-lambda/result-processing-service.test.ts | Unit tests for the new handoff service |
| lambdas/src/order-result-lambda/models.ts | Adds a typed handoff message model and formatting cleanup |
| lambdas/src/order-result-lambda/init.ts | Wires in AWSLambdaClient + ResultProcessingHandoffService via env var |
| lambdas/src/order-result-lambda/init.test.ts | Extends init wiring tests to cover new dependencies/env var |
| lambdas/src/order-result-lambda/index.ts | Delegates processing to the handoff service; wraps handler with Middy |
| lambdas/src/order-result-lambda/index.test.ts | Updates handler tests to assert delegation to processing service |
| lambdas/src/order-result-lambda/cors-configuration.ts | Adds local CORS options module for this lambda (matching other lambdas) |
| lambdas/src/lib/lambda/lambda-client.ts | Introduces a shared AWS Lambda invoke client wrapper |
| lambdas/src/lib/lambda/lambda-client.test.ts | Unit tests for the new invoke client wrapper |
| lambdas/package.json | Adds @aws-sdk/client-lambda dependency |
| lambdas/package-lock.json | Lockfile updates for the new dependency |
Files not reviewed (1)
- lambdas/package-lock.json: Language not supported
|
Playwright E2E tests currently failing due to undeclared terraform module: This terraform module is for a lambda being implemented in #386 |
e225ef1 to
c1f5108
Compare
…te-1138/simplify-results-lambda # Conflicts: # lambdas/pnpm-lock.yaml # lambdas/src/order-result-lambda/index.ts # local-environment/infra/main.tf
|



Description
HOTE-1138
Remove HIV processing logic from order-result lambda as this is now being done by processor lambda being implemented in HOTE-1099.
Context
We are aiming to detangle HIV logic from order-results lambda to enable support for other types of testing in the future. The new flow is that Order-results lambda receives and validates -> processor lambda carrys out bussiness logic/checks specific to different types of tests -> 3rd lambda HOTE-1100 posts result to database.
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.