Skip to content

Commit 45941d0

Browse files
committed
When the flag is off, don't require the post dated sqs url. Also, add a comment
1 parent 97a7f24 commit 45941d0

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

packages/postDatedLambda/src/databaseClient.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ export async function enrichMessagesWithExistingRecords(
179179
const postDatedItems = messages.map((m) => m.prescriptionData)
180180

181181
const prescriptionsWithRecords = await fetchExistingRecordsForPrescriptions(postDatedItems, logger)
182+
// prescription IDs are unique, even across pharmacies. so we can build a map keyed by prescription ID just fine.
182183
const recordsMap = new Map(prescriptionsWithRecords.map((p) => [p.postDatedData.PrescriptionID, p.existingRecords]))
183184
const enrichedMessages: Array<PostDatedSQSMessageWithExistingRecords> = messages.map((message) => ({
184185
...message,

packages/updatePrescriptionStatus/src/utils/sqsClient.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -230,11 +230,6 @@ export async function pushPrescriptionToNotificationSQS(
230230
throw new Error("Notifications SQS URL not configured")
231231
}
232232

233-
if (!postDatedSqsUrl) {
234-
logger.warn("Post-dated Notifications SQS URL not found in environment variables")
235-
throw new Error("Post-dated Notifications SQS URL not configured")
236-
}
237-
238233
// Only allow through sites and systems that are allowedSitesAndSystems
239234
const allowedSitesAndSystemsData = await checkSiteOrSystemIsNotifyEnabled(data)
240235

@@ -261,6 +256,12 @@ export async function pushPrescriptionToNotificationSQS(
261256
let sqsPromises: Promise<Array<string>>
262257
if (ENABLE_POST_DATED_NOTIFICATIONS) {
263258
logger.info("Post-dated notifications are enabled, separating post-dated and non-post-dated items")
259+
260+
if (!postDatedSqsUrl) {
261+
logger.warn("Post-dated Notifications SQS URL not found in environment variables")
262+
throw new Error("Post-dated Notifications SQS URL not configured")
263+
}
264+
264265
// Build two arrays, one of all post dated, and one of all non-post-dated
265266
const postDatedItems = changedStatus.filter(item => item.PostDatedLastModifiedSetAt)
266267
const nonPostDatedItems = changedStatus.filter(item => !item.PostDatedLastModifiedSetAt)

0 commit comments

Comments
 (0)