-
Notifications
You must be signed in to change notification settings - Fork 1
[PRMP-588] document review patch endpoint #870
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
50ec48a
[PRMP-588] Implement document review update functionality with valida…
NogaNHS 45a2d9b
[PRMP-588] Add mock feature flag for document upload iteration and up…
NogaNHS 02478fe
[PRMP-588] Add tests for document update functionality with custom ke…
NogaNHS 4595a26
[PRMP-588] Add tests for document_upload_review_service.py
NogaNHS 65d1683
[PRMP-588] Add tests for test_dynamo_utils.py.py
NogaNHS 8228030
[PRMP-588] Add error handling for invalid document review requests an…
NogaNHS fa12809
[PRMP-588] Add unit tests for document review update functionality an…
NogaNHS 5d8bb88
[PRMP-588] format
NogaNHS d59fb37
Merge branch 'main' into PRMP-588
NogaNHS 6044acc
Merge branch 'main' into PRMP-588
NogaNHS 47bd422
Merge branch 'main' into PRMP-588
NogaNHS 28a14f5
[PRMP-588] Update document review handler to include document version…
NogaNHS 63e274c
[PRMP-588] Add document version to retrieval in get_document_review_s…
NogaNHS f36a5bc
[PRMP-588] Addressing PR comments
NogaNHS f574ddb
Merge branch 'main' into PRMP-588
NogaNHS 94b43ab
[PRMP-588] fix unit tests
NogaNHS 5756e54
Merge branch 'main' into PRMP-588
NogaNHS 46eb012
Merge branch 'main' into PRMP-588
NogaNHS f9835f7
Remove redundant import of DocumentReviewException in document_upload…
NogaNHS 7929b29
Improve error messages in DocumentReviewException raises
NogaNHS 8151df1
[PRMP-588] Add version field to document response and update related …
NogaNHS b74c5a6
[PRMP-588] addressing PR comments
NogaNHS e9a9789
Refactor document review status updates for improved clarity and main…
NogaNHS f6d794c
format
NogaNHS e535b42
Merge branch 'main' into PRMP-588
NogaNHS bb57188
Refactor document review update logic to improve error handling and c…
NogaNHS fe2a6f4
Fix error handling in document review service for missing reviews
NogaNHS 8dee06c
Refactor document review service to improve status transition validat…
NogaNHS def9193
Merge branch 'main' into PRMP-588
NogaNHS 6f966aa
Refactor document update logic to replace 'key_pair' with 'update_key…
NogaNHS 796dcbc
Merge branch 'main' into PRMP-588
NogaNHS 9646ccf
Refactor document review service tests to use 'version' consistently …
NogaNHS File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| from enums.feature_flags import FeatureFlags | ||
| from enums.lambda_error import LambdaError | ||
| from enums.logging_app_interaction import LoggingAppInteraction | ||
| from models.document_review import PatchDocumentReviewRequest | ||
| from pydantic import ValidationError | ||
| from services.feature_flags_service import FeatureFlagService | ||
| from services.update_document_review_service import UpdateDocumentReviewService | ||
| from utils.audit_logging_setup import LoggingService | ||
| from utils.decorators.ensure_env_var import ensure_environment_variables | ||
| from utils.decorators.handle_lambda_exceptions import handle_lambda_exceptions | ||
| from utils.decorators.override_error_check import override_error_check | ||
| from utils.decorators.set_audit_arg import set_request_context_for_logging | ||
| from utils.decorators.validate_patient_id import validate_patient_id | ||
| from utils.lambda_exceptions import UpdateDocumentReviewException | ||
| from utils.lambda_handler_utils import validate_review_path_parameters | ||
| from utils.lambda_response import ApiGatewayResponse | ||
| from utils.request_context import request_context | ||
|
|
||
| logger = LoggingService(__name__) | ||
|
|
||
|
|
||
| @set_request_context_for_logging | ||
| @validate_patient_id | ||
| @ensure_environment_variables( | ||
| names=[ | ||
| "DOCUMENT_REVIEW_DYNAMODB_NAME", | ||
| ] | ||
| ) | ||
| @override_error_check | ||
| @handle_lambda_exceptions | ||
| def lambda_handler(event, context): | ||
| request_context.app_interaction = LoggingAppInteraction.UPDATE_REVIEW.value | ||
|
|
||
| logger.info("Patch Document Review handler has been triggered") | ||
| feature_flag_service = FeatureFlagService() | ||
| feature_flag_service.validate_feature_flag( | ||
| FeatureFlags.UPLOAD_DOCUMENT_ITERATION_3_ENABLED | ||
| ) | ||
|
|
||
| query_params = event.get("queryStringParameters", {}) | ||
| patient_id = query_params.get("patientId") | ||
|
|
||
| if not patient_id: | ||
| logger.error("Missing patient_id in query string parameters") | ||
| raise UpdateDocumentReviewException(400, LambdaError.PatientIdNoKey) | ||
|
|
||
| document_id, document_version = validate_review_path_parameters(event) | ||
|
|
||
| reviewer_ods_code = request_context.authorization.get( | ||
| "selected_organisation", {} | ||
| ).get("org_ods_code") | ||
|
|
||
| if not reviewer_ods_code: | ||
| logger.error("Missing ODS code in authorization token") | ||
| raise UpdateDocumentReviewException( | ||
| 401, LambdaError.DocumentReferenceUnauthorised | ||
| ) | ||
steph-torres-nhs marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| body = event.get("body") | ||
| try: | ||
| review_request = PatchDocumentReviewRequest.model_validate_json(body) | ||
| except ValidationError as e: | ||
| logger.error(f"Invalid request body: {str(e)}") | ||
| raise UpdateDocumentReviewException(400, LambdaError.DocumentReviewInvalidBody) | ||
|
|
||
| document_review_service = UpdateDocumentReviewService() | ||
| document_review_service.update_document_review( | ||
| patient_id=patient_id, | ||
| document_id=document_id, | ||
| document_version=document_version, | ||
| update_data=review_request, | ||
| reviewer_ods_code=reviewer_ods_code, | ||
| ) | ||
|
|
||
| logger.info( | ||
| "Document review updated successfully", | ||
| {"Result": "Successful document review update"}, | ||
| ) | ||
| return ApiGatewayResponse(200, "", "PATCH").create_api_gateway_response() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.