-
Notifications
You must be signed in to change notification settings - Fork 1
[HOTE-1209] feat: Reactive Results: Set TEST_PROCESSED status #408
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
cptiv2020
wants to merge
40
commits into
main
Choose a base branch
from
feature/hote-1209/test-processed-status
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
fe073a4
[HOTE-1099] feat: Results processor
lauren5656 4f7a19f
update main
lauren5656 9c7549d
run precommit
lauren5656 97e7e5d
Merge branch 'main' into feature/hote-1099/hiv-result-processor
lauren5656 056793b
refactor: extract out a lambda http client
lewisbirks a545e5f
docs: refine lambda instructions
lewisbirks ea6ee37
feat: update business status from CONFIRMED to ORDER_ACCEPTED in orde…
cptiv2020 c3c78b4
feat: hiv-result-processor - extract correlation ID from headers
BenKainos-43 75e6ca7
refactor: add types and simplify error handling
BenKainos-43 9d1aee3
Fixed pre-commit issues, mostly order of imports and http changed to …
BenKainos-43 1a38470
refactor: complete hiv-result-processor todos and fix tests
BenKainos-43 fe4e32d
Fix: prettier formatter
BenKainos-43 f22eeba
Refactor: SonarQube code duplication fixes
BenKainos-43 f5e9329
Refactor: Removed duplicate code copied from order-result-lambda
BenKainos-43 819fbac
Refactor: Extract FHIR observation extractors to shared module
BenKainos-43 34813c0
Merge branch 'main' into feature/hote-1210/order-confirmed
cptiv2020 9012007
introduced flow for new status
cptiv2020 b386eae
refactoring
cptiv2020 b7a4061
remove unused method
cptiv2020 1baece3
refactor: Github comments resolved, fixed after review
BenKainos-43 7107d61
Extra changes from review
BenKainos-43 f3d913a
Merge remote-tracking branch 'origin/main' into feature/hote-1099/hiv…
BenKainos-43 cb3217d
pnpm commit fix
BenKainos-43 ac59343
refactoring
cptiv2020 0f125ca
added the output variable
cptiv2020 cc23a61
fix after review
cptiv2020 ddbf0ca
added test to improve code coverage
cptiv2020 ac7a489
fix the task builder to create valid payload
cptiv2020 bc52511
added the role to invoke lambdas
cptiv2020 15bd28a
Merge branch 'main' into feature/hote-1099/hiv-result-processor
cptiv2020 e48729f
Merge remote-tracking branch 'origin/main' into feature/hote-1099/hiv…
cptiv2020 03eb358
Merge branch 'feature/hote-1099/hiv-result-processor' into feature/ho…
cptiv2020 0cc5c36
refactoring
cptiv2020 bec807e
improve tests
cptiv2020 aca53e8
add error to log
cptiv2020 4e76680
Merge branch 'main' into feature/hote-1099/hiv-result-processor
cptiv2020 2441a20
Merge branch 'feature/hote-1099/hiv-result-processor' into feature/ho…
cptiv2020 846a296
Merge branch 'main' into feature/hote-1209/test-processed-status
cptiv2020 8a29ba4
Add test for order processed status
Masha-kainos 59dd320
Merge branch 'feature/hote-1209/test-processed-status' of https://git…
Masha-kainos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
lambdas/goose-migrator-lambda/migrations/000018_add_result_processed_status.sql
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| -- +goose Up | ||
| INSERT INTO result_type (result_code, description) | ||
| VALUES ('RESULT_PROCESSED', 'Test has been processed at the lab but results are not yet available') | ||
| ON CONFLICT DO NOTHING; | ||
|
|
||
| -- +goose Down | ||
| DELETE FROM result_type | ||
| WHERE result_code = 'RESULT_PROCESSED'; |
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
60 changes: 60 additions & 0 deletions
60
lambdas/src/order-status-lambda/db/commands/insert-result-status.test.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| import { type DBClient } from "../../../lib/db/db-client"; | ||
| import { ResultStatus } from "../../../lib/types/status"; | ||
| import { InsertResultStatusCommand } from "./insert-result-status"; | ||
|
|
||
| const normalizeWhitespace = (sql: string): string => sql.replace(/\s+/g, " ").trim(); | ||
|
|
||
| describe("InsertResultStatusCommand", () => { | ||
| let dbClient: jest.Mocked<Pick<DBClient, "query" | "withTransaction" | "close">>; | ||
| let command: InsertResultStatusCommand; | ||
|
|
||
| beforeEach(() => { | ||
| jest.clearAllMocks(); | ||
|
|
||
| dbClient = { | ||
| query: jest.fn(), | ||
| withTransaction: jest.fn(), | ||
| close: jest.fn().mockResolvedValue(undefined), | ||
| }; | ||
|
|
||
| command = new InsertResultStatusCommand(dbClient as DBClient); | ||
| }); | ||
|
|
||
| const expectedQuery = ` | ||
| INSERT INTO result_status (order_uid, status, correlation_id) | ||
| VALUES ($1::uuid, $2, $3::uuid) | ||
| ON CONFLICT (correlation_id) DO NOTHING; | ||
| `; | ||
|
|
||
| it("executes the correct SQL with all parameters", async () => { | ||
| dbClient.query.mockResolvedValue({ rows: [], rowCount: 1 }); | ||
|
|
||
| await command.execute( | ||
| "9f44d6e9-7829-49f1-a327-8eca95f5db32", | ||
| ResultStatus.Result_Processed, | ||
| "c1a2b3c4-d5e6-7890-abcd-ef1234567890", | ||
| ); | ||
|
|
||
| expect(dbClient.query).toHaveBeenCalledTimes(1); | ||
| expect(normalizeWhitespace(dbClient.query.mock.calls[0][0])).toBe( | ||
| normalizeWhitespace(expectedQuery), | ||
| ); | ||
| expect(dbClient.query.mock.calls[0][1]).toEqual([ | ||
| "9f44d6e9-7829-49f1-a327-8eca95f5db32", | ||
| ResultStatus.Result_Processed, | ||
| "c1a2b3c4-d5e6-7890-abcd-ef1234567890", | ||
| ]); | ||
| }); | ||
|
|
||
| it("inserts with ON CONFLICT DO NOTHING for duplicate correlation IDs", async () => { | ||
| dbClient.query.mockResolvedValue({ rows: [], rowCount: 0 }); | ||
|
|
||
| await command.execute( | ||
| "9f44d6e9-7829-49f1-a327-8eca95f5db32", | ||
| ResultStatus.Result_Processed, | ||
| "c1a2b3c4-d5e6-7890-abcd-ef1234567890", | ||
| ); | ||
|
|
||
| expect(dbClient.query).toHaveBeenCalledTimes(1); | ||
| }); | ||
| }); |
20 changes: 20 additions & 0 deletions
20
lambdas/src/order-status-lambda/db/commands/insert-result-status.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| import { type DBClient } from "../../../lib/db/db-client"; | ||
| import { ResultStatus } from "../../../lib/types/status"; | ||
|
|
||
| export class InsertResultStatusCommand { | ||
| constructor(private readonly dbClient: DBClient) {} | ||
|
|
||
| async execute(orderId: string, status: ResultStatus, correlationId: string): Promise<void> { | ||
| const query = ` | ||
| INSERT INTO result_status (order_uid, status, correlation_id) | ||
| VALUES ($1::uuid, $2, $3::uuid) | ||
| ON CONFLICT (correlation_id) DO NOTHING; | ||
| `; | ||
|
|
||
| await this.dbClient.query<void, [string, ResultStatus, string]>(query, [ | ||
| orderId, | ||
| status, | ||
| correlationId, | ||
| ]); | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.