File tree Expand file tree Collapse file tree
updatePrescriptionStatus/src/utils Expand file tree Collapse file tree Original file line number Diff line number Diff 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 ,
Original file line number Diff line number Diff 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 )
You can’t perform that action at this time.
0 commit comments