Skip to content

Commit dff011f

Browse files
committed
u[date MNS method to handle duplicate NHS numbers
1 parent a161017 commit dff011f

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

tests/e2e_automation/features/batchTests/Steps/batch_common_steps.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,10 @@ def mns_event_will_be_triggered_for_batch_record(context, action, valid_rows):
553553
null_nhs_rows = [row for row in valid_rows if _is_null_nhs_row(row)]
554554
positive_rows = [row for row in valid_rows if not _is_null_nhs_row(row)]
555555

556-
row_lookup = {str(row.NHS_NUMBER): row for row in positive_rows}
556+
row_lookup = {}
557+
for row in positive_rows:
558+
nhs = str(row.NHS_NUMBER)
559+
row_lookup.setdefault(nhs, []).append(row)
557560

558561
messages = read_messages_for_batch(
559562
context,
@@ -568,10 +571,15 @@ def mns_event_will_be_triggered_for_batch_record(context, action, valid_rows):
568571

569572
for msg in messages:
570573
nhs = msg.subject
574+
imms_id = msg.dataref.split("/")[-1]
571575

572576
assert nhs in row_lookup, f"Received message for NHS {nhs} but it does not exist in valid_rows"
573577

574-
row = row_lookup[nhs]
578+
matching_rows = [r for r in row_lookup[nhs] if r.IMMS_ID_CLEAN == imms_id]
579+
580+
assert matching_rows, f"Message NHS {nhs} with IMMS_ID {imms_id} does not match any row"
581+
582+
row = matching_rows[0]
575583

576584
context.nhs_number = row.NHS_NUMBER
577585
context.gp_code = get_gp_code_by_nhs_number(row.NHS_NUMBER)

0 commit comments

Comments
 (0)