Skip to content

[PRMP-1465] Post User Restriction#1131

Open
SWhyteAnswer wants to merge 69 commits intomainfrom
PRMP-1465
Open

[PRMP-1465] Post User Restriction#1131
SWhyteAnswer wants to merge 69 commits intomainfrom
PRMP-1465

Conversation

@SWhyteAnswer
Copy link
Contributor

@SWhyteAnswer SWhyteAnswer commented Feb 25, 2026

Overview

Jira ticket: PRMP-1465

Description

Context

Checklist

Tasks for all changes:

  • 1. I have linked this PR to its Jira ticket.
  • 2. I have run git pre-commits. (WIP)
  • 3. I have added and/or updated relevant tests.
  • 4. I have updated relevant documentation.
  • 5. I have considered the cross-team impact (and have PR approval from both Core & Demographics if necessary).
  • 6. I have successfully deployed this change to a sandbox and witnessed unit and e2e tests passing:
  • 7. I have run the UI Smoke Tests against the deployed sandbox and witnessed it passing:

@github-actions
Copy link

Code security issues found

View full details here.

@github-actions
Copy link

Code security issues found

View full details here.

@sonarqubecloud
Copy link

@github-actions
Copy link

Code security issues found

View full details here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove change?

logger.error("Missing user context")
raise LambdaException(
400,
LambdaError.SearchPatientMissing,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this error?

Comment on lines +79 to +100
if patient_id != nhs_number:
logger.error("patientId query param does not match nhs_number in request body")
raise LambdaException(
400,
LambdaError.PatientIdMismatch,
)

try:
creator, ods_code = extract_creator_and_ods_code_from_request_context()
except OdsErrorException:
logger.error("Missing user context")
raise LambdaException(
400,
LambdaError.SearchPatientMissing,
)

if restricted_smartcard_id == creator:
logger.error("You cannot create a restriction for yourself")
raise LambdaException(
400,
LambdaError.CreateRestrictionSelfRestriction,
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be in the service? as this is business logic?

Comment on lines +102 to +117
pds_service = get_pds_service()
patient = pds_service.fetch_patient_details(nhs_number)
if not patient:
logger.error("Patient not found in PDS")
raise LambdaException(
404,
LambdaError.SearchPatientNoPDS,
)
if patient.general_practice_ods != ods_code:
logger.error(
"Patient's general practice ODS does not match request context ODS",
)
raise LambdaException(
403,
LambdaError.SearchPatientNoAuth,
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be in the service

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants