Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
08df684
Enhance document review functionality with new validation and status …
NogaNHS Dec 4, 2025
c237239
Update document review custodian handling with new status and timesta…
NogaNHS Dec 4, 2025
b32c424
Remove unnecessary assertion from document service tests
NogaNHS Dec 5, 2025
9374c2c
Rename 'update_key' to 'key_pair' in document update methods for cons…
NogaNHS Dec 5, 2025
22e9c6c
Refactor document review custodian update logic with improved handlin…
NogaNHS Dec 5, 2025
64ad5fb
Merge branch 'main' into PRMP-908
NogaNHS Dec 8, 2025
e4443b5
[PRMP-908] Refactor error handling in the document upload review serv…
NogaNHS Dec 8, 2025
4b2d6e1
Merge branch 'main' into PRMP-908
NogaNHS Dec 9, 2025
a3d612f
[PRMP-908] Update document review tests to include reviewer field and…
NogaNHS Dec 9, 2025
0bd835a
[PRMP-908] format
NogaNHS Dec 9, 2025
b962607
[PRMP-908] Update document service test to pass key pair as a keyword…
NogaNHS Dec 9, 2025
0a03305
Merge branch 'main' into PRMP-908
NogaNHS Dec 9, 2025
6437529
Refactor imports in dynamo_service.py
NogaNHS Dec 9, 2025
c167c4a
Simplify key_pair assignment in document service
NogaNHS Dec 10, 2025
f703849
Update type hints for sort_key and key_pair parameters in document se…
NogaNHS Dec 10, 2025
fc6b550
Add MNS end-to-end tests and update workflow for AWS region
NogaNHS Dec 12, 2025
c512b6f
Add MNS end-to-end tests and helper functions for death notifications
NogaNHS Dec 15, 2025
46e73c1
Add MNS end-to-end test service configuration to sandbox workflow
NogaNHS Dec 15, 2025
f37d1d1
Add MNS end-to-end test step to sandbox deployment workflow
NogaNHS Dec 15, 2025
d9e6299
Update MNS end-to-end test workflow reference in sandbox deployment
NogaNHS Dec 15, 2025
7007499
Remove MNS test steps from end-to-end workflow configurations
NogaNHS Dec 15, 2025
73b6cc0
Refactor MNS helper functions and update death notification tests for…
NogaNHS Dec 16, 2025
1f17b02
Refactor MNS test files for improved readability and consistency
NogaNHS Dec 16, 2025
7d32d7d
Refactor MNS helper functions and update informal death notification …
NogaNHS Dec 16, 2025
780df9c
Merge branch 'main' into PRMP-908
NogaNHS Dec 16, 2025
885394f
Merge branch 'main' into PRMP-908
NogaNHS Dec 17, 2025
b7d08e6
Merge branch 'main' into PRMP-908
NogaNHS Dec 18, 2025
2217dc3
Merge branch 'main' into PRMP-908
NogaNHS Dec 19, 2025
2407c1c
Merge branch 'main' into PRMP-908
NogaNHS Dec 19, 2025
68b7ef4
[PRMP-908]clean up test assertions
NogaNHS Dec 19, 2025
a3e6fc1
[PRMP-908] simplify key_pair assignment in document update logic
NogaNHS Dec 19, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/base-e2e-backendtest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ jobs:
run: |
AWS_WORKSPACE="${SANDBOX}"
API_URL="api-${SANDBOX}.access-request-fulfilment.patient-deductions.nhs.uk"
AWS_DEFAULT_REGION=${{ vars.AWS_REGION }}
echo "NDR_API_ENDPOINT=$API_URL" >> $GITHUB_ENV
echo "AWS_WORKSPACE=$AWS_WORKSPACE" >> $GITHUB_ENV
env:
Expand Down
78 changes: 78 additions & 0 deletions .github/workflows/base-e2e-mns.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: "Z-BASE E2e Test: MNS E2E Tests"

on:
workflow_call:
inputs:
build_branch:
description: "Branch with e2e tests."
required: true
type: "string"
environment:
description: "Which Environment type are we using"
required: true
type: "string"
sandbox:
description: "Sandbox to run the smoke tests on."
required: true
type: "string"
secrets:
AWS_ASSUME_ROLE:
required: true

permissions:
pull-requests: write
id-token: write
contents: read

jobs:
mns-e2e-test:
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
strategy:
matrix:
test-file:
- test_mns_process.py
- test_mns_death.py
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v6
with:
repository: "NHSDigital/national-document-repository"
ref: ${{ inputs.build_branch }}

- name: AWS Role
uses: aws-actions/configure-aws-credentials@v5
with:
role-to-assume: ${{ secrets.AWS_ASSUME_ROLE }}
role-skip-session-tagging: true
mask-aws-account-id: true
aws-region: ${{ vars.AWS_REGION }}

- name: Set up Python 3.11
uses: actions/setup-python@v6
with:
python-version: 3.11

- name: Make virtual environment
run: |
make env

- name: Start virtual environment
run: |
source ./lambdas/venv/bin/activate
echo PATH=$PATH >> $GITHUB_ENV


- name: Set E2e Test Variables
run: |
AWS_WORKSPACE="${SANDBOX}"
AWS_DEFAULT_REGION=${{ vars.AWS_REGION }}
echo "AWS_WORKSPACE=$AWS_WORKSPACE" >> $GITHUB_ENV
echo "AWS_DEFAULT_REGION=$AWS_DEFAULT_REGION" >> $GITHUB_ENV
env:
SANDBOX: ${{ inputs.sandbox }}

- name: Run MNS E2E Test - ${{ matrix.test-file }}
run: |
cd ./lambdas && ./venv/bin/python3 -m pytest tests/e2e/mns/${{ matrix.test-file }} -vv
10 changes: 10 additions & 0 deletions .github/workflows/lambdas-deploy-feature-to-sandbox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,13 @@ jobs:
sandbox: ${{ inputs.sandbox }}
secrets:
AWS_ASSUME_ROLE: ${{ secrets.AWS_ASSUME_ROLE }}

run_mns_e2etest:
uses: ./.github/workflows/base-e2e-mns.yml
needs: ["deploy_all_lambdas", "disable_fhir_stub"]
with:
build_branch: ${{ inputs.build_branch }}
environment: development
sandbox: ${{ inputs.sandbox }}
secrets:
AWS_ASSUME_ROLE: ${{ secrets.AWS_ASSUME_ROLE }}
11 changes: 10 additions & 1 deletion .github/workflows/ndr-e2e-test-sandbox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,13 @@ jobs:
environment: ${{ inputs.environment }}
sandbox: ${{ inputs.sandbox }}
secrets:
AWS_ASSUME_ROLE: ${{ secrets.AWS_ASSUME_ROLE }}
AWS_ASSUME_ROLE: ${{ secrets.AWS_ASSUME_ROLE }}

services-mns-e2etest:
uses: ./.github/workflows/base-e2e-mns.yml
with:
build_branch: ${{ inputs.build_branch }}
environment: ${{ inputs.environment }}
sandbox: ${{ inputs.sandbox }}
secrets:
AWS_ASSUME_ROLE: ${{ secrets.AWS_ASSUME_ROLE }}
29 changes: 17 additions & 12 deletions lambdas/enums/lambda_error.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
from enum import Enum
from enum import Enum, StrEnum
from typing import Optional

from enums.fhir.fhir_issue_type import FhirIssueCoding, UKCoreSpineError
from utils.error_response import ErrorResponse
from utils.request_context import request_context


class LambdaError(Enum):
class ErrorMessage(StrEnum):
MISSING_POST = "Missing POST request body"
MISSING_KEY = "An error occurred due to missing key"
RETRIEVE_DOCUMENTS = "Unable to retrieve documents for patient"
FAILED_TO_QUERY_DYNAMO = "Failed to query DynamoDB"
FAILED_TO_VALIDATE = "Failed to validate data"
FAILED_TO_UPDATE_DYNAMO = "Failed to update DynamoDB"
FAILED_TO_CREATE_TRANSACTION = "Failed to create transaction"

class LambdaError(Enum):

def create_error_response(
self, params: Optional[dict] = None, **kwargs
Expand Down Expand Up @@ -235,15 +240,15 @@ def create_error_body(self, params: Optional[dict] = None, **kwargs) -> str:
}
ManifestMissingBody = {
"err_code": "DMS_4002",
"message": MISSING_POST,
"message": ErrorMessage.MISSING_POST,
}
ManifestFilterDocumentReferences = {
"err_code": "DMS_4003",
"message": "Selected document references do not match any documents stored for this patient",
}
ManifestMissingJobId = {
"err_code": "DMS_4004",
"message": MISSING_KEY,
"message": ErrorMessage.MISSING_KEY,
}
ManifestMissingJob = {
"err_code": "DMS_4005",
Expand All @@ -267,19 +272,19 @@ def create_error_body(self, params: Optional[dict] = None, **kwargs) -> str:
}
StitchNoService = {
"err_code": "LGS_5001",
"message": RETRIEVE_DOCUMENTS,
"message": ErrorMessage.RETRIEVE_DOCUMENTS,
}
StitchClient = {
"err_code": "LGS_5002",
"message": "Unable to return stitched pdf file due to internal error",
}
StitchDB = {
"err_code": "LGS_5003",
"message": RETRIEVE_DOCUMENTS,
"message": ErrorMessage.RETRIEVE_DOCUMENTS,
}
StitchValidation = {
"err_code": "LGS_5004",
"message": RETRIEVE_DOCUMENTS,
"message": ErrorMessage.RETRIEVE_DOCUMENTS,
}
StitchCloudFront = {
"err_code": "LGS_5005",
Expand Down Expand Up @@ -320,7 +325,7 @@ def create_error_body(self, params: Optional[dict] = None, **kwargs) -> str:
"""
FeedbackMissingBody = {
"err_code": "SFB_4001",
"message": MISSING_POST,
"message": ErrorMessage.MISSING_POST,
}

FeedbackInvalidBody = {
Expand Down Expand Up @@ -603,7 +608,7 @@ def create_error_body(self, params: Optional[dict] = None, **kwargs) -> str:
}
DocTypeKey = {
"err_code": "VDT_4003",
"message": MISSING_KEY,
"message": ErrorMessage.MISSING_KEY,
}
PatientIdInvalid = {
"err_code": "PN_4001",
Expand All @@ -612,7 +617,7 @@ def create_error_body(self, params: Optional[dict] = None, **kwargs) -> str:
}
PatientIdNoKey = {
"err_code": "PN_4002",
"message": MISSING_KEY,
"message": ErrorMessage.MISSING_KEY,
"fhir_coding": UKCoreSpineError.MISSING_VALUE,
}
PatientIdMismatch = {
Expand Down Expand Up @@ -662,7 +667,7 @@ def create_error_body(self, params: Optional[dict] = None, **kwargs) -> str:
"""
DocumentReviewDB = {
"err_code": "UDR_5001",
"message": RETRIEVE_DOCUMENTS,
"message": ErrorMessage.RETRIEVE_DOCUMENTS,
}

DocumentReviewValidation = {
Expand Down
12 changes: 4 additions & 8 deletions lambdas/services/document_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def fetch_documents_from_table(
def get_item(
self,
document_id: str,
sort_key: dict = None,
sort_key: dict | None = None,
table_name: str = None,
model_class: type[BaseModel] = None,
) -> Optional[BaseModel]:
Expand Down Expand Up @@ -218,7 +218,7 @@ def update_document(
update_fields_name: set[str] | None = None,
condition_expression: str | Attr | ConditionBase = None,
expression_attribute_values: dict = None,
key_pair: dict | None = None
key_pair: dict | None = None,
):
"""Update document in specified or configured table."""
table_name = table_name or self.table_name
Expand All @@ -228,13 +228,9 @@ def update_document(
"updated_fields": document.model_dump(
exclude_none=True, by_alias=True, include=update_fields_name
),
"key_pair": key_pair
or {DocumentReferenceMetadataFields.ID.value: document.id},
}
if key_pair:
update_kwargs["key_pair"] = key_pair
else:
update_kwargs["key_pair"] = {
DocumentReferenceMetadataFields.ID.value: document.id
}

if condition_expression:
update_kwargs["condition_expression"] = condition_expression
Expand Down
Loading
Loading