Skip to content

Commit 97a7f24

Browse files
committed
Gate the post-dated lambda behind a feature flag in updatePrescriptionStatus. Enable in in dev, qa, and int, but leave it off in ref and prod
1 parent a5e03b7 commit 97a7f24

7 files changed

Lines changed: 38 additions & 7 deletions

File tree

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ jobs:
8686
ENABLE_BACKUP: "True"
8787
ENABLE_NOTIFICATIONS_INTERNAL: true
8888
ENABLE_NOTIFICATIONS_EXTERNAL: false
89+
ENABLE_POST_DATED_NOTIFICATIONS: true
8990
ENABLED_SYSTEMS: "Internal Test System"
9091
BLOCKED_SITE_ODS_CODES: "B3J1Z"
9192
NOTIFY_ROUTING_PLAN_ID: "e57fe5cc-0567-4854-abe2-b7dd9014a50c"
@@ -126,6 +127,7 @@ jobs:
126127
ENABLE_BACKUP: "False"
127128
ENABLE_NOTIFICATIONS_INTERNAL: false
128129
ENABLE_NOTIFICATIONS_EXTERNAL: false
130+
ENABLE_POST_DATED_NOTIFICATIONS: true
129131
ENABLED_SYSTEMS: "Internal Test System"
130132
BLOCKED_SITE_ODS_CODES: "B3J1Z"
131133
NOTIFY_ROUTING_PLAN_ID: "e57fe5cc-0567-4854-abe2-b7dd9014a50c"
@@ -163,6 +165,7 @@ jobs:
163165
ENABLE_BACKUP: "False"
164166
ENABLE_NOTIFICATIONS_INTERNAL: false
165167
ENABLE_NOTIFICATIONS_EXTERNAL: false
168+
ENABLE_POST_DATED_NOTIFICATIONS: true
166169
ENABLED_SYSTEMS: "Internal Test System"
167170
BLOCKED_SITE_ODS_CODES: "B3J1Z"
168171
NOTIFY_ROUTING_PLAN_ID: "e57fe5cc-0567-4854-abe2-b7dd9014a50c"

.github/workflows/pull_request.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ jobs:
119119
ENABLE_BACKUP: "False"
120120
ENABLE_NOTIFICATIONS_INTERNAL: true
121121
ENABLE_NOTIFICATIONS_EXTERNAL: false
122+
ENABLE_POST_DATED_NOTIFICATIONS: true
122123
ENABLED_SYSTEMS: "Internal Test System"
123124
BLOCKED_SITE_ODS_CODES: "XXXXX" # Workaround empty string handling
124125
NOTIFY_ROUTING_PLAN_ID: "e57fe5cc-0567-4854-abe2-b7dd9014a50c"

.github/workflows/release.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ jobs:
8484
ENABLE_BACKUP: "True"
8585
ENABLE_NOTIFICATIONS_INTERNAL: false
8686
ENABLE_NOTIFICATIONS_EXTERNAL: false
87+
ENABLE_POST_DATED_NOTIFICATIONS: true
8788
ENABLED_SYSTEMS: "Internal Test System"
8889
BLOCKED_SITE_ODS_CODES: "XXXXX" # Workaround empty string handling
8990
NOTIFY_ROUTING_PLAN_ID: "e57fe5cc-0567-4854-abe2-b7dd9014a50c"
@@ -223,6 +224,7 @@ jobs:
223224
ENABLE_BACKUP: "False"
224225
ENABLE_NOTIFICATIONS_INTERNAL: false
225226
ENABLE_NOTIFICATIONS_EXTERNAL: false
227+
ENABLE_POST_DATED_NOTIFICATIONS: true
226228
ENABLED_SYSTEMS: "Internal Test System, Apotec Ltd - Apotec CRM - Production, CrxPatientApp, nhsPrescriptionApp, Titan PSU Prod"
227229
BLOCKED_SITE_ODS_CODES: "B3J1Z"
228230
NOTIFY_ROUTING_PLAN_ID: "e57fe5cc-0567-4854-abe2-b7dd9014a50c"
@@ -266,6 +268,7 @@ jobs:
266268
ENABLE_BACKUP: "True"
267269
ENABLE_NOTIFICATIONS_INTERNAL: true
268270
ENABLE_NOTIFICATIONS_EXTERNAL: true
271+
ENABLE_POST_DATED_NOTIFICATIONS: true
269272
ENABLED_SYSTEMS: "Internal Test System" # Workaround empty string handling
270273
BLOCKED_SITE_ODS_CODES: "XXXXX" # Workaround empty string handling
271274
NOTIFY_ROUTING_PLAN_ID: "e57fe5cc-0567-4854-abe2-b7dd9014a50c"

.github/workflows/run_release_code_and_api.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ on:
8484
required: false
8585
type: boolean
8686
default: false
87+
ENABLE_POST_DATED_NOTIFICATIONS:
88+
required: false
89+
type: boolean
90+
default: false
8791
ENABLED_SYSTEMS:
8892
required: true
8993
type: string

SAMtemplates/functions/main.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ Parameters:
6161
EnableNotificationsInternalParam:
6262
Type: AWS::SSM::Parameter::Name<String>
6363

64+
EnablePostDatedNotifications:
65+
Type: AWS::SSM::Parameter::Name<String>
66+
Default: "false"
67+
6468
RequireApplicationName:
6569
Type: String
6670
Default: false
@@ -126,6 +130,7 @@ Resources:
126130
TABLE_NAME: !Ref PrescriptionStatusUpdatesTableName
127131
NHS_NOTIFY_PRESCRIPTIONS_SQS_QUEUE_URL: !Ref NHSNotifyPrescriptionsSQSQueueUrl
128132
POST_DATED_PRESCRIPTIONS_SQS_QUEUE_URL: !Ref PostDatedNotificationsSQSQueueUrl
133+
ENABLE_POST_DATED_NOTIFICATIONS: !Ref EnablePostDatedNotifications
129134
SQS_SALT: !Ref SQSSaltSecret
130135
ENABLED_SITE_ODS_CODES_PARAM: !Ref EnabledSiteODSCodesParam
131136
ENABLED_SYSTEMS_PARAM: !Ref EnabledSystemsParam

SAMtemplates/main_template.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ Parameters:
122122
Type: String
123123
Default: " "
124124

125+
EnablePostDatedNotifications:
126+
Type: String
127+
Default: "false"
128+
125129
NotifyRoutingPlanIDValue:
126130
Type: String
127131
Default: " "
@@ -232,6 +236,7 @@ Resources:
232236
PrescriptionNotificationStatesTableName: !GetAtt Tables.Outputs.PrescriptionNotificationStatesTableName
233237
NHSNotifyPrescriptionsSQSQueueUrl: !GetAtt Messaging.Outputs.NHSNotifyPrescriptionsSQSQueueUrl
234238
PostDatedNotificationsSQSQueueUrl: !GetAtt Messaging.Outputs.PostDatedNotificationsSQSQueueUrl
239+
EnablePostDatedNotifications: !Ref EnablePostDatedNotifications
235240
SQSSaltSecret: !GetAtt Secrets.Outputs.SQSSaltSecret
236241
EnabledSiteODSCodesParam: !GetAtt Parameters.Outputs.EnabledSiteODSCodesParameterName
237242
EnabledSystemsParam: !GetAtt Parameters.Outputs.EnabledSystemsParameterName

packages/updatePrescriptionStatus/src/utils/sqsClient.ts

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ import {
1414

1515
import {checkSiteOrSystemIsNotifyEnabled} from "../validation/notificationSiteAndSystemFilters"
1616

17+
// eslint-disable-next-line max-len
18+
const ENABLE_POST_DATED_NOTIFICATIONS = (process.env.ENABLE_POST_DATED_NOTIFICATIONS || "false").toLowerCase() === "true"
19+
1720
const sqsUrl: string | undefined = process.env.NHS_NOTIFY_PRESCRIPTIONS_SQS_QUEUE_URL
1821
const postDatedSqsUrl: string | undefined = process.env.POST_DATED_PRESCRIPTIONS_SQS_QUEUE_URL
1922

@@ -255,20 +258,27 @@ export async function pushPrescriptionToNotificationSQS(
255258
})
256259
.map(({current}) => current)
257260

258-
// Build two arrays, one of all post dated, and one of all non-post-dated
259-
const postDatedItems = changedStatus.filter(item => item.PostDatedLastModifiedSetAt)
260-
const nonPostDatedItems = changedStatus.filter(item => !item.PostDatedLastModifiedSetAt)
261+
let sqsPromises: Promise<Array<string>>
262+
if (ENABLE_POST_DATED_NOTIFICATIONS) {
263+
logger.info("Post-dated notifications are enabled, separating post-dated and non-post-dated items")
264+
// Build two arrays, one of all post dated, and one of all non-post-dated
265+
const postDatedItems = changedStatus.filter(item => item.PostDatedLastModifiedSetAt)
266+
const nonPostDatedItems = changedStatus.filter(item => !item.PostDatedLastModifiedSetAt)
261267

262-
const postDatedMessageIds = sendItemsToSQS(postDatedItems, postDatedSqsUrl, requestId, logger)
263-
const nonPostDatedMessageIds = sendItemsToSQS(nonPostDatedItems, sqsUrl, requestId, logger)
268+
const postDatedMessageIds = sendItemsToSQS(postDatedItems, postDatedSqsUrl, requestId, logger)
269+
const nonPostDatedMessageIds = sendItemsToSQS(nonPostDatedItems, sqsUrl, requestId, logger)
270+
sqsPromises = Promise.all([postDatedMessageIds, nonPostDatedMessageIds]).then(results => results.flat())
271+
} else {
272+
logger.info("Post-dated notifications are disabled, sending all items to the standard notifications queue")
273+
sqsPromises = sendItemsToSQS(changedStatus, sqsUrl, requestId, logger)
274+
}
264275

265276
logger.info(
266277
"The following patients will have prescription update app notifications requested",
267278
{nhsNumbers: changedStatus.map(e => e.PatientNHSNumber)}
268279
)
269280

270-
return Promise.all([postDatedMessageIds, nonPostDatedMessageIds])
271-
.then(results => results.flat())
281+
return sqsPromises
272282
}
273283

274284
/**

0 commit comments

Comments
 (0)