Skip to content

Commit b204d64

Browse files
[PRMT-155] Group by NHS number and ODS code on Bulk Upload SQS message (#661)
* [PRMT-155] updated bulk upload metadata service to group by nhs number and ods code * [PRMT-155] remove adding ods code to the sqs message explicitly and update tests * [PRMT-155] updated function and created duplicate patients with different ods codes for testing purposes * [PRMT-155] update initial stubbed patient responses for testing purposes * [PRMT-155] rename metadata test file * [PRMT-155] update stubbed patient data to valid modulus 11 numbers * [PRMT-155] removed unused imports in test_pdf_stitching_service * remove unused placeholder * [PRMT-155] updated reference to stubbed patient NHS number * [PRMT-155] fix smoke test data --------- Co-authored-by: “samFallowfieldNHSgit config user.email “[email protected] <[email protected]> Co-authored-by: bethany-kish-nhs <[email protected]>
1 parent e13a93e commit b204d64

23 files changed

+144
-50
lines changed

app/cypress/e2e/1-ndr-smoke-tests/gp_user_workflows/patient_search_and_verify_unhappy_workflow.cy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ describe('GP Workflow: GP Role rejected from accessing a non mating ODS patient
77
const gpRoles = [Roles.SMOKE_GP_ADMIN_H85686, Roles.SMOKE_GP_CLINICAL_H85686];
88

99
const workspace = Cypress.env('WORKSPACE');
10-
const activePatient = workspace === 'ndr-dev' ? '9730153817' : '9000000002';
10+
const activePatient = workspace === 'ndr-dev' ? '9730153817' : '9000000017';
1111

1212
gpRoles.forEach((role) => {
1313
it(

app/cypress/support/patients.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ export const pdsPatients = {
44
};
55
export const stubPatients = {
66
activeUpload: 9730153817,
7-
activeNoUpload: 9000000004,
7+
activeNoUpload: 9000000068,
88
};

lambdas/models/staging_metadata.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
METADATA_FILENAME = "metadata.csv"
77
NHS_NUMBER_FIELD_NAME = "NHS-NO"
8+
ODS_CODE = "GP-PRACTICE-CODE"
89
NHS_NUMBER_PLACEHOLDER = "0000000000"
910

1011

lambdas/services/bulk_upload_metadata_service.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@
88

99
import pydantic
1010
from botocore.exceptions import ClientError
11-
from models.staging_metadata import NHS_NUMBER_FIELD_NAME, MetadataFile, StagingMetadata
11+
from models.staging_metadata import (
12+
NHS_NUMBER_FIELD_NAME,
13+
ODS_CODE,
14+
MetadataFile,
15+
StagingMetadata,
16+
)
1217
from services.base.s3_service import S3Service
1318
from services.base.sqs_service import SQSService
1419
from utils.audit_logging_setup import LoggingService
@@ -81,14 +86,19 @@ def csv_to_staging_metadata(csv_file_path: str) -> list[StagingMetadata]:
8186
for row in csv_reader:
8287
file_metadata = MetadataFile.model_validate(row)
8388
nhs_number = row[NHS_NUMBER_FIELD_NAME]
84-
if nhs_number not in patients:
85-
patients[nhs_number] = [file_metadata]
89+
ods_code = row[ODS_CODE]
90+
key = (nhs_number, ods_code)
91+
if key not in patients:
92+
patients[key] = [file_metadata]
8693
else:
87-
patients[nhs_number] += [file_metadata]
94+
patients[key].append(file_metadata)
8895

8996
return [
90-
StagingMetadata(nhs_number=nhs_number, files=patients[nhs_number])
91-
for nhs_number in patients
97+
StagingMetadata(
98+
nhs_number=nhs_number,
99+
files=patients[nhs_number, ods_code],
100+
)
101+
for (nhs_number, ods_code) in patients
92102
]
93103

94104
def send_metadata_to_fifo_sqs(

lambdas/services/mock_data/pds_patient_9000000001_X4S4L_pcse.json renamed to lambdas/services/mock_data/pds_patient_9000000009_X4S4L_pcse.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"resourceType": "Patient",
3-
"id": "9000000001",
3+
"id": "9000000009",
44
"identifier": [
55
{
66
"system": "https://fhir.nhs.uk/Id/nhs-number",
7-
"value": "9000000001",
7+
"value": "9000000009",
88
"extension": [
99
{
1010
"url": "https://fhir.hl7.org.uk/StructureDefinition/Extension-UKCore-NHSNumberVerificationStatus",

lambdas/services/mock_data/pds_patient_9000000002_H81109_gp.json renamed to lambdas/services/mock_data/pds_patient_9000000017_H81109_gp.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"resourceType": "Patient",
3-
"id": "9000000002",
3+
"id": "9000000017",
44
"identifier": [
55
{
66
"system": "https://fhir.nhs.uk/Id/nhs-number",
7-
"value": "9000000002",
7+
"value": "9000000017",
88
"extension": [
99
{
1010
"url": "https://fhir.hl7.org.uk/StructureDefinition/Extension-UKCore-NHSNumberVerificationStatus",

lambdas/services/mock_data/pds_patient_9000000005_not_active.json renamed to lambdas/services/mock_data/pds_patient_9000000033_not_active.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"resourceType": "Patient",
3-
"id": "9000000005",
3+
"id": "9000000033",
44
"identifier": [
55
{
66
"system": "https://fhir.nhs.uk/Id/nhs-number",
7-
"value": "9000000005",
7+
"value": "9000000033",
88
"extension": [
99
{
1010
"url": "https://fhir.hl7.org.uk/StructureDefinition/Extension-UKCore-NHSNumberVerificationStatus",

lambdas/services/mock_data/pds_patient_9000000100_H81109_gp_no_period_fields_in_name.json renamed to lambdas/services/mock_data/pds_patient_9000000041_H81109_gp_no_period_fields_in_name.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"resourceType": "Patient",
3-
"id": "9000000100",
3+
"id": "9000000041",
44
"identifier": [
55
{
66
"system": "https://fhir.nhs.uk/Id/nhs-number",
7-
"value": "9000000100",
7+
"value": "9000000041",
88
"extension": [
99
{
1010
"url": "https://fhir.hl7.org.uk/StructureDefinition/Extension-UKCore-NHSNumberVerificationStatus",

lambdas/services/mock_data/pds_patient_9000000004_M85143_gp.json renamed to lambdas/services/mock_data/pds_patient_9000000068_M85143_gp.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"resourceType": "Patient",
3-
"id": "9000000004",
3+
"id": "9000000068",
44
"identifier": [
55
{
66
"system": "https://fhir.nhs.uk/Id/nhs-number",
7-
"value": "9000000004",
7+
"value": "9000000068",
88
"extension": [
99
{
1010
"url": "https://fhir.hl7.org.uk/StructureDefinition/Extension-UKCore-NHSNumberVerificationStatus",

lambdas/services/mock_data/pds_patient_9000000105_M85143_gp_given_name_with_two_separate_strings.json renamed to lambdas/services/mock_data/pds_patient_9000000076_M85143_gp_given_name_with_two_separate_strings.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"resourceType": "Patient",
3-
"id": "9000000105",
3+
"id": "9000000076",
44
"identifier": [
55
{
66
"system": "https://fhir.nhs.uk/Id/nhs-number",
7-
"value": "9000000105",
7+
"value": "9000000076",
88
"extension": [
99
{
1010
"url": "https://fhir.hl7.org.uk/StructureDefinition/Extension-UKCore-NHSNumberVerificationStatus",

0 commit comments

Comments
 (0)