Skip to content

[HOTE-1138] feat: simplify results lambda#404

Merged
rgolipally1 merged 54 commits intomainfrom
feature/hote-1138/simplify-results-lambda
Apr 29, 2026
Merged

[HOTE-1138] feat: simplify results lambda#404
rgolipally1 merged 54 commits intomainfrom
feature/hote-1138/simplify-results-lambda

Conversation

@TSeelig
Copy link
Copy Markdown
Contributor

@TSeelig TSeelig commented Apr 23, 2026

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

  • Refactoring (non-breaking change)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would change existing functionality)
  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • I am familiar with the contributing guidelines
  • I have followed the code style of the project
  • I have added tests to cover my changes
  • I have updated the documentation accordingly
  • This PR is a result of pair or mob programming

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.

  • I confirm that neither PII/PID nor sensitive data are included in this PR and the codebase changes.

Copilot AI review requested due to automatic review settings April 23, 2026 13:55
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 a ResultProcessingHandoffService to invoke the downstream processor lambda.
  • Update order-result-lambda to 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

Comment thread lambdas/src/order-result-lambda/index.ts Outdated
Comment thread lambdas/src/order-result-lambda/index.ts Outdated
Comment thread lambdas/src/order-result-lambda/index.test.ts Outdated
Comment thread local-environment/infra/main.tf Outdated
Comment thread local-environment/infra/main.tf Outdated
Comment thread lambdas/src/order-result-lambda/models.ts
Comment thread lambdas/src/order-result-lambda/index.ts Outdated
Copilot AI review requested due to automatic review settings April 23, 2026 14:14
@TSeelig TSeelig force-pushed the feature/hote-1138/simplify-results-lambda branch from 0144d58 to 2fd31c4 Compare April 23, 2026 14:14
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ResultProcessingHandoffService in order-result-lambda and wired it via init.ts using a new RESULT_PROCESSING_FUNCTION_NAME env 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

Comment thread lambdas/src/order-result-lambda/models.ts Outdated
Comment thread lambdas/src/order-result-lambda/index.ts Outdated
Comment thread lambdas/src/order-result-lambda/index.ts Outdated
Comment thread local-environment/infra/main.tf Outdated
Comment thread local-environment/infra/main.tf Outdated
Comment thread local-environment/infra/main.tf Outdated
@TSeelig TSeelig force-pushed the feature/hote-1138/simplify-results-lambda branch from 2fd31c4 to 5684f46 Compare April 23, 2026 14:40
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 23, 2026

Lambdas Coverage Report

Lines Statements Branches Functions
Coverage: 98%
98.14% (2219/2261) 91.59% (610/666) 96.59% (369/382)

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 23, 2026

UI Coverage Report

Lines Statements Branches Functions
Coverage: 96%
96.32% (5927/6153) 88.4% (724/819) 88.44% (222/251)

Copilot AI review requested due to automatic review settings April 23, 2026 15:08
@TSeelig TSeelig force-pushed the feature/hote-1138/simplify-results-lambda branch from 5684f46 to f4afc08 Compare April 23, 2026 15:08
@TSeelig TSeelig force-pushed the feature/hote-1138/simplify-results-lambda branch from f4afc08 to 6b2434f Compare April 23, 2026 15:18
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 a ResultProcessingHandoffService to invoke the downstream processor function.
  • Updated order-result-lambda handler 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

Comment thread local-environment/infra/main.tf Outdated
Comment thread local-environment/infra/main.tf Outdated
Comment thread lambdas/src/order-result-lambda/index.ts Outdated
Comment thread lambdas/src/order-result-lambda/index.ts Outdated
@TSeelig TSeelig force-pushed the feature/hote-1138/simplify-results-lambda branch from 6b2434f to cadb769 Compare April 23, 2026 15:23
@TSeelig TSeelig force-pushed the feature/hote-1138/simplify-results-lambda branch from e225ef1 to c1f5108 Compare April 27, 2026 13:34
…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
…te-1138/simplify-results-lambda

# Conflicts:
#	lambdas/pnpm-lock.yaml
#	lambdas/src/order-result-lambda/index.ts
#	local-environment/infra/main.tf
Copilot AI review requested due to automatic review settings April 28, 2026 09:37
@cptiv2020 cptiv2020 changed the base branch from main to feature/hote-1099/hiv-result-processor April 28, 2026 09:38
@cptiv2020 cptiv2020 changed the base branch from feature/hote-1099/hiv-result-processor to feature/hote-1209/test-processed-status April 28, 2026 12:05
Base automatically changed from feature/hote-1209/test-processed-status to main April 29, 2026 09:12
@sonarqubecloud
Copy link
Copy Markdown

@rgolipally1 rgolipally1 merged commit 5a615b7 into main Apr 29, 2026
15 checks passed
@rgolipally1 rgolipally1 deleted the feature/hote-1138/simplify-results-lambda branch April 29, 2026 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants