Skip to content

Commit dbf4891

Browse files
authored
Merge branch 'master' into dependabot/pip/tests/e2e_automation/lxml-6.1.0
2 parents 573ebfc + 516dad0 commit dbf4891

21 files changed

Lines changed: 434 additions & 221 deletions

File tree

.github/workflows/dependabot-auto-approve.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
- name: Fetch Dependabot metadata
1515
id: metadata
1616
continue-on-error: true
17-
uses: dependabot/fetch-metadata@ffa630c65fa7e0ecfa0625b5ceda64399aea1b36
17+
uses: dependabot/fetch-metadata@25dd0e34f4fe68f24cc83900b1fe3fe149efef98
1818

1919
- name: Auto-approve minor and patch updates
2020
if: steps.metadata.outcome == 'success' && contains(fromJSON('["version-update:semver-minor", "version-update:semver-patch"]'), steps.metadata.outputs.update-type)

.github/workflows/deploy-lambda-artifact.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ jobs:
235235
- name: Login to Amazon ECR
236236
id: login-ecr
237237
if: ${{ steps.decide.outputs.deployment_mode == 'build' && !steps.build-check.outputs.existing_image_digest }}
238-
uses: aws-actions/amazon-ecr-login@376925c9d111252e87ae59691e5a442dd100ef6a
238+
uses: aws-actions/amazon-ecr-login@19d944daaa35f0fa1d3f7f8af1d3f2e5de25c5b7
239239

240240
- name: Set up Docker Buildx
241241
if: ${{ steps.decide.outputs.deployment_mode == 'build' && !steps.build-check.outputs.existing_image_digest }}

.github/workflows/quality-checks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
steps:
1919
- uses: actions/checkout@0c366fd6a839edf440554fa01a7085ccba70ac98
2020

21-
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f
21+
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e
2222
with:
2323
node-version: "23.11.0"
2424
cache: "npm"

config/dev/permissions_config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
"FLU.CRUDS",
4747
"HPV.CRUDS",
4848
"MENACWY.CRUDS",
49+
"MENB.CRUDS",
4950
"MMR.CRUDS",
5051
"MMRV.CRUDS",
5152
"PERTUSSIS.CRUDS",

config/preprod/permissions_config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
"FLU.CRUDS",
4444
"HPV.CRUDS",
4545
"MENACWY.CRUDS",
46+
"MENB.CRUDS",
4647
"MMR.CRUDS",
4748
"MMRV.CRUDS",
4849
"PERTUSSIS.CRUDS",

config/prod/permissions_config.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@
2525
},
2626
{
2727
"supplier": "RAVS",
28-
"permissions": ["MMR.CRUDS", "RSV.CRUDS", "PNEUMOCOCCAL.CRUDS"],
28+
"permissions": [
29+
"MENB.CRUDS",
30+
"MMR.CRUDS",
31+
"RSV.CRUDS",
32+
"PNEUMOCOCCAL.CRUDS"
33+
],
2934
"ods_codes": ["X26", "X8E5B"]
3035
},
3136
{

infrastructure/account/.terraform.lock.hcl

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

infrastructure/instance/.terraform.lock.hcl

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

infrastructure/mesh/.terraform.lock.hcl

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

lambdas/backend/src/service/fhir_service.py

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from authorisation.api_operation_code import ApiOperationCode
2323
from authorisation.authoriser import Authoriser
2424
from common.get_service_url import get_service_url
25-
from common.models.constants import Constants
25+
from common.models.constants import Constants, Urls
2626
from common.models.errors import (
2727
Code,
2828
CustomValidationError,
@@ -62,6 +62,7 @@ class FhirService:
6262
_DATA_MISSING_DATE_TIME_ERROR_MSG = (
6363
"Data quality issue - immunisation with ID %s was found containing no occurrenceDateTime"
6464
)
65+
_SINGLE_SNOMED_CODEABLE_CONCEPT_FIELDS = ("site", "route")
6566

6667
def __init__(
6768
self,
@@ -73,6 +74,36 @@ def __init__(
7374
self.immunization_repo = imms_repo
7475
self.validator = validator
7576

77+
@staticmethod
78+
def _keep_first_snomed_coding(coding: list) -> list:
79+
snomed_seen = False
80+
filtered_coding = []
81+
for coding_entry in coding:
82+
is_snomed_coding = isinstance(coding_entry, dict) and coding_entry.get("system") == Urls.SNOMED
83+
if is_snomed_coding and snomed_seen:
84+
continue
85+
86+
snomed_seen = snomed_seen or is_snomed_coding
87+
filtered_coding.append(coding_entry)
88+
89+
return filtered_coding
90+
91+
@classmethod
92+
def _normalize_single_snomed_codeable_concepts(cls, immunization: dict) -> None:
93+
for field_name in cls._SINGLE_SNOMED_CODEABLE_CONCEPT_FIELDS:
94+
field = immunization.get(field_name)
95+
coding = field.get("coding") if isinstance(field, dict) else None
96+
if isinstance(coding, list):
97+
field["coding"] = cls._keep_first_snomed_coding(coding)
98+
99+
def _validate_immunization(self, immunization: dict) -> None:
100+
self._normalize_single_snomed_codeable_concepts(immunization)
101+
102+
try:
103+
self.validator.validate(immunization)
104+
except (ValueError, MandatoryError) as error:
105+
raise CustomValidationError(message=str(error)) from error
106+
76107
def get_immunization_by_identifier(
77108
self, identifier: Identifier, supplier_name: str, elements: set[str] | None
78109
) -> FhirBundle:
@@ -117,10 +148,7 @@ def create_immunization(self, immunization: dict, supplier_system: str) -> Id:
117148
if immunization.get("id") is not None:
118149
raise CustomValidationError("id field must not be present for CREATE operation")
119150

120-
try:
121-
self.validator.validate(immunization)
122-
except (ValueError, MandatoryError) as error:
123-
raise CustomValidationError(message=str(error)) from error
151+
self._validate_immunization(immunization)
124152

125153
vaccination_type = get_vaccine_type(immunization)
126154

@@ -139,10 +167,7 @@ def create_immunization(self, immunization: dict, supplier_system: str) -> Id:
139167
return self.immunization_repo.create_immunization(immunization_fhir_entity, supplier_system)
140168

141169
def update_immunization(self, imms_id: str, immunization: dict, supplier_system: str, resource_version: int) -> int:
142-
try:
143-
self.validator.validate(immunization)
144-
except (ValueError, MandatoryError) as error:
145-
raise CustomValidationError(message=str(error)) from error
170+
self._validate_immunization(immunization)
146171

147172
immunization_to_update = Immunization.parse_obj(immunization)
148173

0 commit comments

Comments
 (0)