Skip to content
Open
Show file tree
Hide file tree
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 Apr 20, 2026
4f7a19f
update main
lauren5656 Apr 20, 2026
9c7549d
run precommit
lauren5656 Apr 20, 2026
97e7e5d
Merge branch 'main' into feature/hote-1099/hiv-result-processor
lauren5656 Apr 20, 2026
056793b
refactor: extract out a lambda http client
lewisbirks Apr 20, 2026
a545e5f
docs: refine lambda instructions
lewisbirks Apr 20, 2026
ea6ee37
feat: update business status from CONFIRMED to ORDER_ACCEPTED in orde…
cptiv2020 Apr 23, 2026
c3c78b4
feat: hiv-result-processor - extract correlation ID from headers
BenKainos-43 Apr 23, 2026
75e6ca7
refactor: add types and simplify error handling
BenKainos-43 Apr 23, 2026
9d1aee3
Fixed pre-commit issues, mostly order of imports and http changed to …
BenKainos-43 Apr 23, 2026
1a38470
refactor: complete hiv-result-processor todos and fix tests
BenKainos-43 Apr 23, 2026
fe4e32d
Fix: prettier formatter
BenKainos-43 Apr 23, 2026
f22eeba
Refactor: SonarQube code duplication fixes
BenKainos-43 Apr 23, 2026
f5e9329
Refactor: Removed duplicate code copied from order-result-lambda
BenKainos-43 Apr 23, 2026
819fbac
Refactor: Extract FHIR observation extractors to shared module
BenKainos-43 Apr 23, 2026
34813c0
Merge branch 'main' into feature/hote-1210/order-confirmed
cptiv2020 Apr 24, 2026
9012007
introduced flow for new status
cptiv2020 Apr 24, 2026
b386eae
refactoring
cptiv2020 Apr 24, 2026
b7a4061
remove unused method
cptiv2020 Apr 24, 2026
1baece3
refactor: Github comments resolved, fixed after review
BenKainos-43 Apr 24, 2026
7107d61
Extra changes from review
BenKainos-43 Apr 24, 2026
f3d913a
Merge remote-tracking branch 'origin/main' into feature/hote-1099/hiv…
BenKainos-43 Apr 24, 2026
cb3217d
pnpm commit fix
BenKainos-43 Apr 24, 2026
ac59343
refactoring
cptiv2020 Apr 27, 2026
0f125ca
added the output variable
cptiv2020 Apr 27, 2026
cc23a61
fix after review
cptiv2020 Apr 27, 2026
ddbf0ca
added test to improve code coverage
cptiv2020 Apr 27, 2026
ac7a489
fix the task builder to create valid payload
cptiv2020 Apr 27, 2026
bc52511
added the role to invoke lambdas
cptiv2020 Apr 27, 2026
15bd28a
Merge branch 'main' into feature/hote-1099/hiv-result-processor
cptiv2020 Apr 27, 2026
e48729f
Merge remote-tracking branch 'origin/main' into feature/hote-1099/hiv…
cptiv2020 Apr 27, 2026
03eb358
Merge branch 'feature/hote-1099/hiv-result-processor' into feature/ho…
cptiv2020 Apr 28, 2026
0cc5c36
refactoring
cptiv2020 Apr 28, 2026
bec807e
improve tests
cptiv2020 Apr 28, 2026
aca53e8
add error to log
cptiv2020 Apr 28, 2026
4e76680
Merge branch 'main' into feature/hote-1099/hiv-result-processor
cptiv2020 Apr 28, 2026
2441a20
Merge branch 'feature/hote-1099/hiv-result-processor' into feature/ho…
cptiv2020 Apr 28, 2026
846a296
Merge branch 'main' into feature/hote-1209/test-processed-status
cptiv2020 Apr 28, 2026
8a29ba4
Add test for order processed status
Masha-kainos Apr 28, 2026
59dd320
Merge branch 'feature/hote-1209/test-processed-status' of https://git…
Masha-kainos Apr 28, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Comment thread
cptiv2020 marked this conversation as resolved.
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';
1 change: 1 addition & 0 deletions lambdas/src/lib/types/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ export enum OrderStatus {
export enum ResultStatus {
Result_Available = "RESULT_AVAILABLE",
Result_Withheld = "RESULT_WITHHELD",
Result_Processed = "RESULT_PROCESSED",
}
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);
});
});
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,
]);
}
}
Loading
Loading