Skip to content

[CDAPI-152]: Unhappy path integration tests#121

Open
MohammadPatelNHS wants to merge 4 commits intomainfrom
feature/CDAPI-152
Open

[CDAPI-152]: Unhappy path integration tests#121
MohammadPatelNHS wants to merge 4 commits intomainfrom
feature/CDAPI-152

Conversation

@MohammadPatelNHS
Copy link
Copy Markdown
Contributor

Description

Context

Type of changes

  • Refactoring (non-breaking change)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would change existing functionality)
  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • I have followed the code style of the project
  • I have added tests to cover my changes
  • I have updated the documentation accordingly
  • This PR is a result of pair or mob programming
  • Exceptions/Exclusions to coding standards (e.g. #noqa or #NOSONAR) are included within this Pull Request.

Sensitive Information Declaration

To ensure the utmost confidentiality and protect your and others privacy, we kindly ask you to NOT including PII (Personal Identifiable Information) / PID (Personal Identifiable Data) or any other sensitive data in this PR (Pull Request) and the codebase changes. We will remove any PR that do contain any sensitive information. We really appreciate your cooperation in this matter.

  • I confirm that neither PII/PID nor sensitive data are included in this PR and the codebase changes.

@MohammadPatelNHS MohammadPatelNHS marked this pull request as ready for review April 23, 2026 15:05
@MohammadPatelNHS MohammadPatelNHS requested a review from a team as a code owner April 23, 2026 15:05
@sonarqubecloud
Copy link
Copy Markdown

@github-actions
Copy link
Copy Markdown

Deployment Complete

Copy link
Copy Markdown
Collaborator

@nhsd-jack-wainwright nhsd-jack-wainwright left a comment

Choose a reason for hiding this comment

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

LGTM, just a few minor comments 👍


patient = (
resource["identifier"][0].get("value")
if type(resource["identifier"]) is list
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Would we ever expect the patient resource's identifier value to not be a list here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure what the exact structure of the document we get from middleware will be but I've seen an example where a patient identifier could be supplied in both a patient resource and as part of the subject in the composition resource. when supplied as part of the composition subject, identifier is not a list.

return None

if len(patient_values) > 1:
if len(set(patient_values)) > 1:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Are you create a set from patient_values here to account for the same value being provided multiple times?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

adding onto the above point, if a patient identifier is supplied as part of both composition subject and patient resource then its fine if they are the same value, pdm allows for that.
it does still return an error if the nhs numbers supplied in each resource is different.

{
"resource": {
"resourceType": "Patient",
"identifier": [{"value": "PDM_SERVER_ERROR"}],
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Are there some other scenarios here covered by CDAPI-72 that need to be included here? I think the BAD_GATEWAY and GATEWAY_TIMEOUT scenarios should be included for example as well as perhaps the authentication errors.


assert operation_outcome.issue == [issue]

def test_pdm_returns_internal_server_error(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Similar to above, is it worth including some scenarios here for if a BAD_GATEWAY or GATEWAY_TIMEOUT response is returned by PDM?

request_method="POST", path="FHIR/R4/Bundle"
request_method="POST",
path="FHIR/R4/Bundle",
headers={"X-Correlation-ID": "bb038f9a-dc45-49e1-bcfd-3ab3c3de5e16"},
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why do these test cases now need to include a correlation ID?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I was running the integration tests locally, which doesn't supply a base correlation id like it does on remote because its not using proxygen. I could update the the api gateway mock server.py file to include a correlation id always instead

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.

2 participants