Skip to content

VED-835 Refactor create immunisation endpoint#926

Merged
dlzhry2nhs merged 7 commits intomasterfrom
feature/VED-835-refactor-create-endpoint
Oct 24, 2025
Merged

VED-835 Refactor create immunisation endpoint#926
dlzhry2nhs merged 7 commits intomasterfrom
feature/VED-835-refactor-create-endpoint

Conversation

@dlzhry2nhs
Copy link
Collaborator

@dlzhry2nhs dlzhry2nhs commented Oct 21, 2025

Summary

Routine Change

  • No functional changes; purely refactoring into controller -> service -> repository

  • Added error scenarios for the Create Imms journey into the FHIR API exception decorator

  • Moved the duplicate checking into the service layer.

  • Simplified each layer, improved readability and return types.

  • Additionally added some extra terraform constraints which I think will help with the fresh environment deployment flakiness

  • FOR DISCUSSION: I have modified the code so that the service passes around the actual FHIR Immunization entity rather than dicts. Dicts are mutable and do not help to document the code. If we do not want to do this, I can remove the commit (number 4 I think). One other thing to consider is that it will change the ordering of the JSON that is dumped to the DB. E.g. previously "id" would be the last key as it was added last, but now it will be at the top, just after resource, because we are using the .json method of the FHIR entity. Hopefully that is okay - as the Get endpoint also uses the FHIR resource to dump so it will not affect anything the client sees when retrieving. As long as we don't care about the particular ordering of what is actually stored to Dynamo then should be fine.

Reviews Required

  • Dev

Review Checklist

ℹ️ This section is to be filled in by the reviewer.

  • I have reviewed the changes in this PR and they fill all or part of the acceptance criteria of the ticket, and the code is in a mergeable state.
  • If there were infrastructure, operational, or build changes, I have made sure there is sufficient evidence that the changes will work.
  • I have ensured the changelog has been updated by the submitter, if necessary.

@github-actions
Copy link
Contributor

This branch is working on a ticket in the NHS England VED JIRA Project. Here's a handy link to the ticket:

VED-835

@dlzhry2nhs dlzhry2nhs temporarily deployed to internal-dev-sandbox October 21, 2025 16:27 — with GitHub Actions Inactive
@dlzhry2nhs dlzhry2nhs temporarily deployed to internal-dev-sandbox October 21, 2025 16:28 — with GitHub Actions Inactive
@dlzhry2nhs dlzhry2nhs temporarily deployed to internal-dev-sandbox October 22, 2025 10:07 — with GitHub Actions Inactive
@dlzhry2nhs dlzhry2nhs temporarily deployed to internal-dev-sandbox October 22, 2025 10:10 — with GitHub Actions Inactive
@dlzhry2nhs dlzhry2nhs temporarily deployed to internal-dev-sandbox October 22, 2025 10:29 — with GitHub Actions Inactive
"""it should return 400 if json has superseded nhs number."""
# Given
create_result = {
"diagnostics": "Validation errors: contained[?(@.resourceType=='Patient')].identifier[0].value does not exists"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No longer a valid scenario. See 2aea793#diff-3ea35476d2424353d5982240bd60f7d32bda82e49830191d5bf200ca7f21c2ecL367 and ticket for further context.

@dlzhry2nhs dlzhry2nhs temporarily deployed to internal-dev-sandbox October 22, 2025 10:34 — with GitHub Actions Inactive
}
)

def test_add_patient(self):
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

All these tests are obsolete - basically repeated scenarios with weak assertions that are already covered by the first.

def test_decimal_on_create(self):
"""it should create Immunization, and preserve decimal value"""
imms = create_covid_19_immunization_dict(imms_id="an-id")
imms["doseQuantity"] = 0.7477
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This was invalid FHIR.

JamesW1-NHS
JamesW1-NHS previously approved these changes Oct 22, 2025
@sonarqubecloud
Copy link

@dlzhry2nhs dlzhry2nhs merged commit 0c2652a into master Oct 24, 2025
17 checks passed
@dlzhry2nhs dlzhry2nhs deleted the feature/VED-835-refactor-create-endpoint branch October 24, 2025 15:44
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.

3 participants