Skip to content

Commit 8640252

Browse files
authored
Merge branch 'main' into bugfix/eja-fixing-tagging-permissions
2 parents baeca45 + 77b124a commit 8640252

File tree

12 files changed

+194
-56
lines changed

12 files changed

+194
-56
lines changed

.github/workflows/cicd-2-publish.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ on:
99
branches:
1010
- main
1111
- hotfix/*
12+
workflow_dispatch: {}
1213

1314
concurrency:
1415
group: terraform-dev

infrastructure/stacks/_shared/locals.tf

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,32 @@ locals {
88

99
# tflint-ignore: terraform_unused_declarations
1010
tags = {
11-
TagVersion = "1"
12-
Programme = "Vaccinations"
13-
Project = "EligibilitySignpostingAPI"
14-
Environment = var.environment
15-
ServiceCategory = var.environment == "prod" ? "Bronze" : "N/A"
16-
Tool = "Terraform"
17-
workspace = lower(terraform.workspace)
11+
# Billing and Identification (FinOps)
12+
FinOpsTagVersion = "1"
13+
Programme = "Vaccinations"
14+
Product = "EligibilitySignpostingAPI"
15+
Owner = "[email protected]" # REQUIRED - distribution list recommended
16+
CostCentre = "129117" # REQUIRED - your cost centre code
17+
Customer = "NHS England" # Optional but recommended
18+
19+
# Environment Information (SecOps)
20+
data_classification = "5" # REQUIRED - 1-5 based on Cloud Risk Model
21+
DataType = "PII" # REQUIRED - adjust based on your data
22+
Environment = var.environment # REQUIRED - Development/Testing/Preproduction/Production
23+
ProjectType = "Production" # REQUIRED - PoC/Pilot/Production
24+
PublicFacing = "Y" # REQUIRED - Y/N for internet-facing
25+
26+
# Technical Operations (TechOps)
27+
ServiceCategory = "Silver" # REQUIRED - Bronze/Silver/Gold/Platinum
28+
OnOffPattern = "AlwaysOn" # REQUIRED - AlwaysOn/OfficeHours/MF86/MF95/MF77
29+
30+
# Application Information (DevOps)
31+
ApplicationRole = "API" # REQUIRED - Web/App/DB/WebServer/Firewall/LoadBalancer
32+
Tool = "Terraform" # Optional - None/Terraform/Packer/CloudFormation/ARM
33+
34+
# Custom/Internal
35+
workspace = lower(terraform.workspace)
36+
Stack = local.stack_name
1837
}
1938

2039
terraform_state_bucket_name = "eligibility-signposting-api-${var.environment}-tfstate"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
provider "aws" {
22
region = "eu-west-2"
3+
4+
default_tags {
5+
tags = local.tags
6+
}
37
}
48

59
# Used by ACM
610
provider "aws" {
711
alias = "eu-west-2"
812
region = "eu-west-2"
13+
14+
default_tags {
15+
tags = local.tags
16+
}
917
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
provider "aws" {
22
region = "eu-west-2"
3+
4+
default_tags {
5+
tags = local.tags
6+
}
37
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
provider "aws" {
22
region = "eu-west-2"
3+
4+
default_tags {
5+
tags = local.tags
6+
}
37
}

poetry.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ localstack = "^4.8.1"
5757
pytest-docker = "^3.2.3"
5858
stamina = "^25.1.0"
5959
pytest-freezer = "^0.4.9"
60-
moto = "^5.1.9"
60+
moto = "^5.1.13"
6161
requests = "^2.32.5"
6262
jsonschema = "^4.25.1"
6363
behave = "^1.2.6"

src/eligibility_signposting_api/services/processors/rule_processor.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,13 @@ class RuleProcessor:
3939

4040
def is_base_eligible(self, person: Person, cohort: IterationCohort) -> bool:
4141
if cohort.is_virtual_cohort:
42-
for row in person.data:
43-
if row.get("ATTRIBUTE_TYPE", "") == "COHORTS":
44-
row["COHORT_MEMBERSHIPS"].append({"COHORT_LABEL": cohort.cohort_label})
42+
cohorts_data = next((row for row in person.data if row.get("ATTRIBUTE_TYPE") == "COHORTS"), None)
43+
44+
if cohorts_data is None:
45+
cohorts_data = {"ATTRIBUTE_TYPE": "COHORTS", "COHORT_MEMBERSHIPS": []}
46+
person.data.append(cohorts_data)
47+
48+
cohorts_data.setdefault("COHORT_MEMBERSHIPS", []).append({"COHORT_LABEL": cohort.cohort_label})
4549

4650
person_cohorts = self.person_data_reader.get_person_cohorts(person)
4751

tests/fixtures/builders/repos/person.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def person_rows_builder( # noqa:PLR0913
1818
gender: Gender | None = ...,
1919
postcode: str | None = ...,
2020
cohorts: Sequence[str] | None = ...,
21-
vaccines: Sequence[tuple[str, date]] | None = ...,
21+
vaccines: dict[str, dict[str, str | None]] | None = ...,
2222
icb: str | None = ...,
2323
gp_practice: str | None = ...,
2424
pcn: str | None = ...,
@@ -36,8 +36,6 @@ def person_rows_builder( # noqa:PLR0913
3636
date_of_birth = date_of_birth if date_of_birth is not ... else faker.date_of_birth(minimum_age=18, maximum_age=99)
3737
gender = gender if gender is not ... else choice(get_args(Gender))
3838
postcode = postcode if postcode is not ... else faker.postcode()
39-
cohorts = cohorts if cohorts is not ... else ["cohort-a", "cohort-b"]
40-
vaccines = vaccines if vaccines is not ... else [("RSV", faker.past_date("-5y")), ("COVID", faker.past_date("-5y"))]
4139
icb = icb if icb is not ... else faker.icb()
4240
gp_practice = gp_practice if gp_practice is not ... else faker.gp_practice()
4341
pcn = pcn if pcn is not ... else faker.pcn()
@@ -64,26 +62,28 @@ def person_rows_builder( # noqa:PLR0913
6462
"MSOA": msoa,
6563
"LSOA": lsoa,
6664
},
67-
{
68-
"NHS_NUMBER": key,
69-
"ATTRIBUTE_TYPE": "COHORTS",
70-
"COHORT_MEMBERSHIPS": [
71-
{"COHORT_LABEL": cohort, "DATE_JOINED": faker.past_date().strftime("%Y%m%d")} for cohort in cohorts
72-
],
73-
},
7465
]
75-
rows.extend(
76-
{
77-
"NHS_NUMBER": key,
78-
"ATTRIBUTE_TYPE": vaccine,
79-
"LAST_SUCCESSFUL_DATE": (
80-
last_successful_date.strftime("%Y%m%d") if last_successful_date else last_successful_date
81-
),
82-
"OPTOUT": choice(["Y", "N"]),
83-
"LAST_INVITE_DATE": faker.past_date("-5y").strftime("%Y%m%d"),
84-
}
85-
for vaccine, last_successful_date in vaccines
86-
)
66+
67+
if cohorts is not ... and cohorts:
68+
rows.append(
69+
{
70+
"NHS_NUMBER": key,
71+
"ATTRIBUTE_TYPE": "COHORTS",
72+
"COHORT_MEMBERSHIPS": [
73+
{"COHORT_LABEL": cohort, "DATE_JOINED": faker.past_date().strftime("%Y%m%d")} for cohort in cohorts
74+
],
75+
}
76+
)
77+
78+
if vaccines is not ... and vaccines:
79+
rows.extend(
80+
{
81+
"NHS_NUMBER": key,
82+
"ATTRIBUTE_TYPE": vaccine_name,
83+
**details,
84+
}
85+
for vaccine_name, details in vaccines.items()
86+
)
8787

8888
shuffle(rows)
8989

tests/integration/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ def person_with_all_data(person_table: Any, faker: Faker) -> Generator[eligibili
409409
gender="0",
410410
postcode="SW18",
411411
cohorts=["cohort_label1", "cohort_label2"],
412-
vaccines=[("RSV", None)],
412+
vaccines={"RSV": {"LAST_SUCCESSFUL_DATE": None}},
413413
icb="QE1",
414414
gp_practice="C81002",
415415
pcn="U78207",

0 commit comments

Comments
 (0)