Skip to content

Commit d0cea20

Browse files
committed
Revert change
1 parent d9fcfce commit d0cea20

3 files changed

Lines changed: 17 additions & 48 deletions

File tree

SAMtemplates/functions/main.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ Parameters:
3434
Default: none
3535

3636
EnabledSiteODSCodesParam:
37-
Type: String
37+
Type: AWS::SSM::Parameter::Value<String>
3838

3939
EnabledSystemsParam:
40-
Type: String
40+
Type: AWS::SSM::Parameter::Value<String>
4141

4242
BlockedSiteODSCodesParam:
43-
Type: String
43+
Type: AWS::SSM::Parameter::Value<String>
4444

4545
LogLevel:
4646
Type: String

SAMtemplates/parameters/main.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Resources:
1818
Properties:
1919
Name: !Sub ${StackName}-PSUNotifyEnabledSiteODSCodes
2020
Description: "List of site ODS codes for which notifications are enabled"
21-
Type: StringList
21+
Type: String
2222
Value: !If
2323
- IsProd
2424
- > # Prod notification enabled
@@ -31,7 +31,7 @@ Resources:
3131
Properties:
3232
Name: !Sub ${StackName}-PSUNotifyEnabledSystems
3333
Description: "List of application names for which notifications are enabled"
34-
Type: StringList
34+
Type: String
3535
Value: !If
3636
- IsProd
3737
- > # Prod notification enabled
@@ -51,7 +51,7 @@ Resources:
5151
Properties:
5252
Name: !Sub ${StackName}-PSUNotifyBlockedSiteODSCodes
5353
Description: "List of site ODS codes for which notifications are blocked"
54-
Type: StringList
54+
Type: String
5555
Value: !If
5656
- IsProd
5757
- > # Prod notification disabled

packages/updatePrescriptionStatus/src/validation/notificationSiteAndSystemFilters.ts

Lines changed: 11 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,17 @@
11
import {PSUDataItem} from "@PrescriptionStatusUpdate_common/commonTypes"
2-
import AWS from "aws-sdk"
32

4-
const ssm = new AWS.SSM()
5-
6-
/**
7-
* Fetches the comma-delimited StringList from SSM, normalizes & returns a Set<string>.
8-
*/
9-
async function fetchListFromSSM(paramNameEnvVar: string): Promise<Set<string>> {
10-
const paramName = process.env[paramNameEnvVar]
11-
if (!paramName) {
12-
throw new Error(`Missing required env-var ${paramNameEnvVar}`)
13-
}
14-
const resp = await ssm
15-
.getParameter({Name: paramName, WithDecryption: false})
16-
.promise()
17-
18-
const raw = resp.Parameter?.Value ?? ""
19-
return new Set(
20-
raw
21-
.split(",")
22-
.map((s) => s.trim().toLowerCase())
23-
.filter(Boolean)
3+
function getEnvList(name: string): Set<string> {
4+
const raw = process.env[name] ?? ""
5+
return new Set(raw
6+
.split(",")
7+
.map((s) => s.trim().toLowerCase())
8+
.filter(Boolean) // Remove empty entries
249
)
2510
}
2611

27-
const listsReady: Promise<{
28-
enabledSiteODSCodes: Set<string>;
29-
enabledSystems: Set<string>;
30-
blockedSiteODSCodes: Set<string>;
31-
}> = (async () => {
32-
const [enabledSiteODSCodes, enabledSystems, blockedSiteODSCodes] =
33-
await Promise.all([
34-
fetchListFromSSM("ENABLED_SITE_ODS_CODES"),
35-
fetchListFromSSM("ENABLED_SYSTEMS"),
36-
fetchListFromSSM("BLOCKED_SITE_ODS_CODES")
37-
])
38-
return {enabledSiteODSCodes, enabledSystems, blockedSiteODSCodes}
39-
})()
12+
const enabledSiteODSCodes = getEnvList("ENABLED_SITE_ODS_CODES")
13+
const enabledSystems = getEnvList("ENABLED_SYSTEMS")
14+
const blockedSiteODSCodes = getEnvList("BLOCKED_SITE_ODS_CODES")
4015

4116
/**
4217
* Given an array of PSUDataItem, only returns those which:
@@ -46,15 +21,9 @@ const listsReady: Promise<{
4621
* @param data - Array of PSUDataItem to be processed
4722
* @returns - the filtered array
4823
*/
49-
export async function checkSiteOrSystemIsNotifyEnabled(
24+
export function checkSiteOrSystemIsNotifyEnabled(
5025
data: Array<PSUDataItem>
51-
): Promise<Array<PSUDataItem>> {
52-
const {
53-
enabledSiteODSCodes,
54-
enabledSystems,
55-
blockedSiteODSCodes
56-
} = await listsReady
57-
26+
): Array<PSUDataItem> {
5827
return data.filter((item) => {
5928
const appName = item.ApplicationName.toLowerCase()
6029
const odsCode = item.PharmacyODSCode.toLowerCase()

0 commit comments

Comments
 (0)