Skip to content

Commit 8fd25f4

Browse files
committed
Merge branch 'master' into VED-738-refactor
2 parents 67972c3 + c7856fe commit 8fd25f4

File tree

14 files changed

+159
-52
lines changed

14 files changed

+159
-52
lines changed

backend/src/models/fhir_immunization_pre_validators.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,15 +310,18 @@ def pre_validate_patient_name_given(self, values: dict) -> dict:
310310
except (KeyError, IndexError, AttributeError):
311311
pass
312312

313+
PERSON_SURNAME_MAX_LENGTH = 35
314+
313315
def pre_validate_patient_name_family(self, values: dict) -> dict:
314316
"""
315317
Pre-validate that, if a contained[?(@.resourceType=='Patient')].name[{index}].family (legacy CSV field name:
316-
PERSON_SURNAME) exists, index dynamically determined then it is a an array containing a single non-empty string
318+
PERSON_SURNAME) exists, index dynamically determined then it is a non-empty string of maximum length
319+
35 characters
317320
"""
318321
field_location = patient_name_family_field_location(values)
319322
try:
320323
field_value, _ = patient_and_practitioner_value_and_index(values, "family", "Patient")
321-
PreValidation.for_string(field_value, field_location)
324+
PreValidation.for_string(field_value, field_location, max_length=self.PERSON_SURNAME_MAX_LENGTH)
322325
except (KeyError, IndexError, AttributeError):
323326
pass
324327

backend/src/models/utils/pre_validator_utils.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ def for_string(
2323
if not isinstance(field_value, str):
2424
raise TypeError(f"{field_location} must be a string")
2525

26+
if field_value.isspace():
27+
raise ValueError(f"{field_location} must be a non-empty string")
28+
2629
if defined_length:
2730
if len(field_value) != defined_length:
2831
raise ValueError(f"{field_location} must be {defined_length} characters")

backend/tests/test_immunization_pre_validator.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,9 @@ def test_pre_validate_patient_name_family(self):
506506
ValidatorModelTests.test_string_value(
507507
self,
508508
field_location=patient_name_family_field_location(valid_json_data),
509-
valid_strings_to_test=["test"],
509+
valid_strings_to_test=["test", "Quitelongsurname", "Surnamewithjustthirtyfivecharacters"],
510+
max_length=PreValidators.PERSON_SURNAME_MAX_LENGTH,
511+
invalid_length_strings_to_test=["Surnamethathasgotthirtysixcharacters"],
510512
)
511513

512514
def test_pre_validate_patient_birth_date(self):

backend/tests/testing_utils/pre_validation_test_utils.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,16 @@ def test_string_value(
7676
expected_error_message=f"{field_location} must be a string",
7777
)
7878

79+
# Test whitespace
80+
for invalid_whitespace_string in InvalidValues.for_whitespace_strings:
81+
test_invalid_values_rejected(
82+
test_instance,
83+
valid_json_data,
84+
field_location=field_location,
85+
invalid_value=invalid_whitespace_string,
86+
expected_error_message=f"{field_location} must be a non-empty string",
87+
)
88+
7989
# If there is a predefined string length, then test invalid string lengths,
8090
# otherwise check the empty string only
8191
if defined_length:

backend/tests/testing_utils/values_for_tests.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,12 @@ class Invalid:
319319
class InvalidValues:
320320
"""Store lists of invalid values for tests"""
321321

322+
for_whitespace_strings = [
323+
" ", # All spaces
324+
" \n ", # Spaces and newlines
325+
"\r\n\t", # CR, LF and tabs
326+
]
327+
322328
for_postal_codes = [
323329
"SW1 1AA", # Too many spaces in divider
324330
"SW 1 1A", # Too many space dividers

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/grafana/non-prod/terraform/.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: 16 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

infrastructure/instance/dynamodb.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ resource "aws_dynamodb_table" "delta-dynamodb-table" {
6868
type = "S"
6969
}
7070

71+
attribute {
72+
name = "ImmsID"
73+
type = "S"
74+
}
75+
7176
attribute {
7277
name = "Operation"
7378
type = "S"
@@ -102,6 +107,12 @@ resource "aws_dynamodb_table" "delta-dynamodb-table" {
102107
projection_type = "ALL"
103108
}
104109

110+
global_secondary_index {
111+
name = "ImmunisationIdIndex"
112+
hash_key = "ImmsID"
113+
projection_type = "ALL"
114+
}
115+
105116
point_in_time_recovery {
106117
enabled = var.environment == "prod"
107118
}

infrastructure/instance/ecs_batch_processor_config.tf

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,14 @@ resource "aws_iam_policy" "ecs_task_exec_policy" {
157157
"firehose:PutRecordBatch"
158158
],
159159
"Resource" : "arn:aws:firehose:*:*:deliverystream/${module.splunk.firehose_stream_name}"
160-
}
160+
},
161+
{
162+
Effect = "Allow",
163+
Action = [
164+
"s3:PutObject",
165+
],
166+
Resource = "${aws_s3_bucket.data_quality_reports_bucket.arn}/*"
167+
},
161168
]
162169
})
163170
}

0 commit comments

Comments
 (0)