Skip to content

Commit

Permalink
PRMT-4747 (#93)
Browse files Browse the repository at this point in the history
* [PRMT-4747] Set `includeDeletedRecord` flags to `true`.

* [PRMT-4747] Removed unnecessary test.
  • Loading branch information
martin-nhs authored Apr 30, 2024
1 parent ec12bbf commit 1934de0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 22 deletions.
4 changes: 2 additions & 2 deletions src/__tests__/app.integration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ describe('app', () => {
});

const getPatientResponseAfterDeletion = await callGetPatient(nhsNumber);
expect(getPatientResponseAfterDeletion.status).toBe(404);
expect(getPatientResponseAfterDeletion.status).toBe(200);

const softDeletedRecords = await db.queryTableByConversationId(
inboundConversationId,
Expand Down Expand Up @@ -700,7 +700,7 @@ describe('app', () => {
});

const getPatientResponseAfterDeletion = await callGetPatient(nhsNumber);
expect(getPatientResponseAfterDeletion.status).toBe(404);
expect(getPatientResponseAfterDeletion.status).toBe(200);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ import { createCore } from '../ehr-core-repository';
import { EhrTransferTracker } from '../dynamo-ehr-transfer-tracker';
import { markFragmentAsReceivedAndCreateItsParts } from '../ehr-fragment-repository';
import { HealthRecordNotFoundError, MessageNotFoundError } from '../../../errors/errors';
import { buildCore } from '../../../models/core';
import { getEpochTimeInSecond } from '../../time';
import moment from 'moment-timezone';

jest.mock('../../../middleware/logging');
Expand Down Expand Up @@ -251,20 +249,6 @@ describe('ehr-conversation-repository', () => {
.rejects.toThrowError(MessageNotFoundError);
});

it('should throw an error if the only existing messages were deleted', async () => {
// given
const conversationId = uuid().toUpperCase();
const messageId = uuid().toUpperCase();
const item = { ...buildCore(conversationId, messageId), DeletedAt: getEpochTimeInSecond() };

await db.writeItemsInTransaction([item]);

// when
await expect(() => getMessageIdsForConversation(conversationId))
// then
.rejects.toThrowError(MessageNotFoundError);
});

it('should return health record extract message id given a conversation id for a small health record', async () => {
// given
const messageId = uuid().toUpperCase();
Expand Down Expand Up @@ -366,7 +350,6 @@ describe('ehr-conversation-repository', () => {
const messageId = uuid().toUpperCase();
const conversationId = makeConversationIdForTest();
const fragmentIds = [uuid().toUpperCase(), uuid().toUpperCase(), uuid().toUpperCase()];

await createCompleteRecordForTest(nhsNumber, conversationId, messageId, fragmentIds);

// when
Expand All @@ -375,7 +358,7 @@ describe('ehr-conversation-repository', () => {
// then
const healthRecordStatusAfterwards = await getConversationStatus(conversationId);
expect(result).toEqual([conversationId]);
expect(healthRecordStatusAfterwards).toEqual(HealthRecordStatus.NOT_FOUND);
expect(healthRecordStatusAfterwards).toEqual(HealthRecordStatus.COMPLETE);

const deletedRecords = await db.queryTableByConversationId(
conversationId,
Expand Down
4 changes: 2 additions & 2 deletions src/services/database/dynamo-ehr-transfer-tracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export class EhrTransferTracker {
}
}

async queryTableByNhsNumber(nhsNumber, includeDeletedRecord = false) {
async queryTableByNhsNumber(nhsNumber, includeDeletedRecord = true) {
const params = {
TableName: this.tableName,
IndexName: 'NhsNumberSecondaryIndex',
Expand Down Expand Up @@ -124,7 +124,7 @@ export class EhrTransferTracker {
async queryTableByConversationId(
inboundConversationId,
recordType = RecordType.ALL,
includeDeletedRecord = false
includeDeletedRecord = true
) {
const params = {
TableName: this.tableName,
Expand Down

0 comments on commit 1934de0

Please sign in to comment.