[NDR-423] CORE DB to use ID, all endpoints ignore SNOMED code#1151
[NDR-423] CORE DB to use ID, all endpoints ignore SNOMED code#1151jameslinnell wants to merge 19 commits intomainfrom
Conversation
Code security issues foundView full details here. |
|
|
|
||
| if not document_id or not snomed_code: | ||
| if not document_id: | ||
| logger.error("Missing document id or snomed code in request path parameters.") |
There was a problem hiding this comment.
Remove reference to snomed code here
| return SnomedCodes.LLOYD_GEORGE.value | ||
|
|
||
| if common_name not in MtlsCommonNames: | ||
| logger.error(f"mTLS common name {common_name} - is not supported") |
There was a problem hiding this comment.
This isn't really to do with this PR, more a note to what Fraser was saying about updating the ssm param - I would expect there to be a fhir lambda error if an mtls request is used, with an invalid common name, but it seemed like access and store were alerted to an error on their stuff, implying it went down the LG route?
There was a problem hiding this comment.
I think there's a ticket to look into Mtls errors
|
|
||
| document = model_class.model_validate(response["Item"]) | ||
| return document | ||
| if not return_deleted: |
There was a problem hiding this comment.
Might need a run through of this - would it be simpler to reverse this and if return_deleted exit earlier?
| def get_item_agnostic( | ||
| self, | ||
| partion_key: dict, | ||
| partition_key: dict, |
There was a problem hiding this comment.
Ooh surprised this wasn't causing issues before!
| document_id: str, | ||
| table, | ||
| ) -> DocumentReference | None: | ||
| documentreference = self.document_service.get_item( |
There was a problem hiding this comment.
Should this be document_reference to keep with existing syntax patterns
| object_parts = object_key.split("/") | ||
| document_key = object_parts[-1] | ||
| nhs_number = None | ||
| if len(object_parts) > 1: |
There was a problem hiding this comment.
Is this not a shared service used by access & store too? Would they still need this as their ID's are made up of snomed?
There was a problem hiding this comment.
I added this in, now I'm removing it. It's not needed anymore.
| if not documents: | ||
| logger.error( | ||
| f"Failed to process object key with ID: {document_key}", | ||
| f"No document with the following key found in {self.table_name} table: {document_key}", |
There was a problem hiding this comment.
What is document_key in this scenario?
There was a problem hiding this comment.
document reference ID
| assert len(body["issue"]) > 0 | ||
| issue = body["issue"][0] | ||
| assert issue["severity"] == "error" | ||
| # Commented this out for now as this will no longer retunr a 500 but now a 400 |
There was a problem hiding this comment.
Do we have a ticket for this to be fixed in? And should we remove the test or change it to assert a 400 for now, to keep the coverage?
There was a problem hiding this comment.
I have added 400 invalid tests, so this is covered. Yeah Matt added this test in his PR to fix 500 FHIR response. but now it doesn't return a 500. Could be worth talking it through
| (f"{pdm_data_helper.snomed_code}+{str(uuid.uuid4())}", 400, "invalid"), | ||
| (f"{pdm_data_helper.snomed_code}&{str(uuid.uuid4())}", 400, "invalid"), | ||
| (f"{pdm_data_helper.snomed_code}{str(uuid.uuid4())}", 400, "invalid"), | ||
| (f"{str(uuid.uuid4())}~{pdm_data_helper.snomed_code}", 400, "invalid"), |
There was a problem hiding this comment.
Can you add empty string here?
There was a problem hiding this comment.
Ah can see this is on line 113 - can it be combined into this test?
There was a problem hiding this comment.
TBH, that test works in a different way. It's easier to leave as separate tests.
| _assert_operation_outcome(body=body, code="MISSING_VALUE") | ||
|
|
||
|
|
||
| def test_no_snomed_or_document_id_in_path_param_id(): |
There was a problem hiding this comment.
Is this one redundant now?
There was a problem hiding this comment.
no, there is a still a function to look for path params. IT's not used but may be used in the future. I think as it doesn''t affect the current code it can be left in
| "pdm_record", | ||
| ) | ||
|
|
||
| def retrieve_document_reference(self, record): |
There was a problem hiding this comment.
Don't know if I'm missing something here but don't we need these? We reference data_helper.retrieve_document_reference a lot
There was a problem hiding this comment.
They are no longer required to be different compared to the same methods on the base class so, we don't need them on the pdm_helper class anymore.
| mock_document_service.handle_get_document_reference_request.assert_not_called() | ||
|
|
||
|
|
||
| def test_lambda_handler_id_malformed( |
There was a problem hiding this comment.
Why is this one not needed anymore?
There was a problem hiding this comment.
Because
MOCK_INVALID_EVENT_ID_MALFORMED["pathParameters"]["id"] = f"~{TEST_UUID}"
This is now a valid ID. the function that gets the ID will split by ~ and take the last item.
Invalid IDs would be non-uuids and a test for that has been added by
def test_get_id_from_path_parameters_raises_error(path_parameter):
| patched_service.document_service.get_item.return_value = None | ||
|
|
||
| with pytest.raises(GetFhirDocumentReferenceException) as exc_info: | ||
| with pytest.raises(GetFhirDocumentReferenceException) as excinfo: |
There was a problem hiding this comment.
Isn't exc_info the standard everywhere else?



Overview
Jira ticket: NDR-423
Description
Changes CORE db calls to use the updated DB design. All FHIR endpoints now longer require snomed code as part of their request
Context
SNOMED is a redundant parameter, IDs were previously not FHIR compliant.
Checklist
Tasks for all changes:
Deploy - SandboxSANDBOX Full- Deploy feature branch to sandbox