Skip to content
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

Prmt 4839 #95

Merged
merged 5 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 8 additions & 3 deletions src/api/messages/store-message-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ import {
} from '../../services/database/ehr-fragment-repository';
import {
getConversationStatus,
updateConversationCompleteness, updateConversationToCoreReceived
} from "../../services/database/ehr-conversation-repository";
updateConversationCompleteness,
updateConversationToCoreReceived
} from '../../services/database/ehr-conversation-repository';

export const storeMessageControllerValidation = [
body('data.type').equals('messages'),
Expand Down Expand Up @@ -80,7 +81,11 @@ export const storeMessageController = async (req, res) => {
logInfo('Health record status for fragments: ' + healthRecordStatus);
res.status(201).json({ healthRecordStatus });
} catch (e) {
logError(`Error encountered while storing message: ${e.message ? e.message : 'No error message present' }`);
logError(
`Error encountered while storing message: ${
e.message ? e.message : 'No error message present'
}`
);
res.sendStatus(503);
}
};
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { updateConversationToCoreReceived } from "../../ehr-conversation-repository";
import { EhrTransferTracker } from "../../dynamo-ehr-transfer-tracker";
import { logError } from "../../../../middleware/logging";
import { buildConversationUpdateParams } from "../../../../models/conversation";
import { ConversationStatus } from "../../../../models/enums";
import { updateConversationToCoreReceived } from '../../ehr-conversation-repository';
import { EhrTransferTracker } from '../../dynamo-ehr-transfer-tracker';
import { logError } from '../../../../middleware/logging';
import { buildConversationUpdateParams } from '../../../../models/conversation';
import { ConversationStatus } from '../../../../models/enums';
import { v4 as uuid } from 'uuid';

jest.mock('../../dynamo-ehr-transfer-tracker');
Expand All @@ -28,7 +28,8 @@ describe('ehr-conversation-repository', () => {
// then
expect(EhrTransferTracker.getInstance).toHaveBeenCalled();
expect(buildConversationUpdateParams).toHaveBeenCalledWith(conversationId, {
TransferStatus: ConversationStatus.CORE_RECEIVED });
TransferStatus: ConversationStatus.CORE_RECEIVED
});
expect(mockedDbInstance.updateItemsInTransaction).toHaveBeenCalledWith([mockedUpdateParam]);
});

Expand All @@ -48,4 +49,4 @@ describe('ehr-conversation-repository', () => {
expect(logError).toHaveBeenCalled();
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import {
getMessageIdsForConversation,
getConversationStatus,
markRecordAsSoftDeleteForPatient,
updateConversationCompleteness, updateConversationToCoreReceived
} from "../ehr-conversation-repository";
updateConversationCompleteness,
updateConversationToCoreReceived
} from '../ehr-conversation-repository';
import { ConversationStatus, HealthRecordStatus, RecordType } from '../../../models/enums';
import {
cleanupRecordsForTest,
Expand Down
6 changes: 5 additions & 1 deletion src/services/database/ehr-conversation-repository.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,11 @@ export const updateConversationToCoreReceived = async (conversationId) => {

await db.updateItemsInTransaction([updateParam]);
} catch (err) {
logError(`Failed to update Conversation status to ${ConversationStatus.CORE_RECEIVED}: ${err.message ? err.message : 'No error message present'}`);
logError(
`Failed to update Conversation status to ${ConversationStatus.CORE_RECEIVED}: ${
err.message ? err.message : 'No error message present'
}`
);
throw err;
}
};
Expand Down
Loading