Skip to content

NPA-6546: Update post authorise responses#120

Merged
ehallam merged 9 commits intomainfrom
task/NPA-6546/update-post-authorise-responses
Apr 15, 2026
Merged

NPA-6546: Update post authorise responses#120
ehallam merged 9 commits intomainfrom
task/NPA-6546/update-post-authorise-responses

Conversation

@tomknapp
Copy link
Copy Markdown
Contributor

@tomknapp tomknapp commented Apr 13, 2026

Pull Request

🧾 Ticket Link

https://nhsd-jira.digital.nhs.uk/browse/NPA-6546


📄 Description/Summary of Changes

  • Rename Proxy -> User
  • Add permissions to the response
  • Add DOB to user and patient demographics
  • Add identifiers for the user and patients and onlineUserId for TPP
  • Include the ODS Code in the response

🧪 Developer Testing Carried Out

  • unit tests
  • sandbox build
  • sandbox unit tests
  • end to end tests against deployed im1 application

📋 PR Principles

  • Keep PRs Small and Focused: Ensure the PR addresses a single task or feature to make it easier to review.
  • Multiple PRs for one Ticket: When splitting work into multiple PRs, clearly describe what this PR addresses and outline the remaining work to complete the ticket.
  • Ensure Tests Are Included: Add or update unit, integration, or end-to-end tests to cover the changes made.
  • Follow Coding Standards: Ensure the code adheres to the team's coding guidelines and best practices.
  • Resolve Comments Promptly: If you raise a comment, ensure you follow up and resolve it before approving the PR to maintain clarity and ensure comments are addressed.
  • Foster Learning: PR reviews are an opportunity to share knowledge, provide constructive feedback, and encourage a collaborative environment.

🏷️ Naming Conventions Reminder

Please ensure the following naming conventions are followed:

  • PR title follows the format: NPA-XXXX: <short-description>
  • Branch name follows the convention: <type>/NPA-XXXX/<short-description>
  • Commit messages follow the template: NPA-XXXX: <short-description>

Copilot AI review requested due to automatic review settings April 13, 2026 08:55
@tomknapp tomknapp temporarily deployed to internal-dev-sandbox April 13, 2026 08:57 — with GitHub Actions Inactive
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the /authenticate 201 response contract and internal transformation models to replace proxy with user and enrich returned demographic/permission data across EMIS and TPP integrations.

Changes:

  • Updated domain ForwardResponse/Demographics models to include odsCode, user, dateOfBirth, and permissions.
  • Updated EMIS/TPP client transformers and infrastructure models to populate user vs patients, plus identifiers and (TPP) onlineUserId.
  • Updated OpenAPI spec and automated tests to reflect the new response shape (plus Makefile pytest arg passthrough).

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
tests/end_to_end/authenticate/POST/test_201.py Updates E2E expected 201 payloads for EMIS/TPP.
specification/im1-pfs-auth-api.yaml Updates OpenAPI schemas for new user-centric response payload and added fields.
Makefile Allows passing additional pytest args via PYTEST_ARGS.
app/api/infrastructure/tpp/tests/test_client.py Updates TPP client unit test expectations for new response structure.
app/api/infrastructure/tpp/models.py Extends TPP response models to include user, identifiers, permissions, and onlineUserId.
app/api/infrastructure/tpp/data/mocked_response.xml Adds mocked effective service access data for TPP user.
app/api/infrastructure/tpp/client.py Populates new fields and adds parsing for identifiers/permissions in TPP responses.
app/api/infrastructure/emis/tests/test_client.py Updates EMIS client unit test expectations and error parametrization.
app/api/infrastructure/emis/models.py Updates EMIS models for user + identifiers + permissions.
app/api/infrastructure/emis/client.py Updates EMIS response transformation to construct user and filtered patients.
app/api/domain/tests/test_forward_response_model.py Updates domain model test to new required fields.
app/api/domain/forward_response_model.py Introduces Permissions, enriches Demographics, and replaces proxy with odsCode + user.
Comments suppressed due to low confidence (1)

tests/end_to_end/authenticate/POST/test_201.py:100

  • The expected EMIS 201 response body is out of sync with the new response models/spec: the API now returns odsCode at the top level, and user is an EMISPatientModel (so it should include dateOfBirth, userPatientLinkToken, patientIdentifiers, and permissions within user, not as a separate top-level permissions). Update this expected payload to match the actual response contract.
                "patients": [
                    {
                        "firstName": "Jane",
                        "surname": "Doe",
                        "title": "Mrs",
                        "permissions": {
                            "appointmentsEnabled": False,
                            "demographicsUpdateEnabled": True,
                            "epsEnabled": False,
                            "medicalRecordEnabled": True,
                            "onlineTriageEnabled": True,
                            "practicePatientCommunicationEnabled": True,
                            "prescribingEnabled": True,
                            "recordSharingEnabled": False,
                            "recordViewAuditEnabled": True,
                            "medicalRecord": {
                                "recordAccessScheme": "CoreSummaryCareRecord",
                                "allergiesEnabled": True,
                                "consultationsEnabled": True,
                                "immunisationsEnabled": True,
                                "documentsEnabled": True,
                                "medicationEnabled": True,
                                "problemsEnabled": True,
                                "testResultsEnabled": True,
                            },
                        },
                    },
                    {
                        "firstName": "Ella",
                        "surname": "Taylor",
                        "title": "Ms",
                        "permissions": {
                            "appointmentsEnabled": True,
                            "demographicsUpdateEnabled": True,
                            "epsEnabled": False,
                            "medicalRecordEnabled": True,
                            "onlineTriageEnabled": False,
                            "practicePatientCommunicationEnabled": True,
                            "prescribingEnabled": False,
                            "recordSharingEnabled": False,
                            "recordViewAuditEnabled": True,
                            "medicalRecord": {
                                "recordAccessScheme": "DetailedCodedCareRecord",
                                "allergiesEnabled": True,
                                "consultationsEnabled": True,
                                "immunisationsEnabled": True,
                                "documentsEnabled": True,
                                "medicationEnabled": True,
                                "problemsEnabled": True,
                                "testResultsEnabled": True,
                            },
                        },
                    },
                ],
                "user": {"firstName": "Alex", "surname": "Taylor", "title": "Mr"},
                "permissions": {
                    "appointmentsEnabled": True,
                    "demographicsUpdateEnabled": True,
                    "epsEnabled": True,
                    "medicalRecordEnabled": True,
                    "onlineTriageEnabled": False,
                    "practicePatientCommunicationEnabled": False,
                    "prescribingEnabled": True,
                    "recordSharingEnabled": False,
                    "recordViewAuditEnabled": True,
                    "medicalRecord": {
                        "recordAccessScheme": "DetailedCodedCareRecord",
                        "allergiesEnabled": True,
                        "consultationsEnabled": True,
                        "immunisationsEnabled": True,
                        "documentsEnabled": True,
                        "medicationEnabled": True,
                        "problemsEnabled": True,
                        "testResultsEnabled": True,
                    },
                },
                "sessionId": "SID_2qZ9yJpVxHq4N3b",
                "endUserSessionId": "SESS_mDq6nE2b8R7KQ0v",
                "supplier": "EMIS",
            },

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread specification/im1-pfs-auth-api.yaml Outdated
Comment thread specification/im1-pfs-auth-api.yaml Outdated
Comment thread specification/im1-pfs-auth-api.yaml Outdated
Comment thread tests/end_to_end/authenticate/POST/test_201.py
Comment thread app/api/infrastructure/emis/client.py
Comment thread app/api/infrastructure/tpp/client.py Outdated
Comment thread app/api/infrastructure/tpp/client.py Outdated
@tomknapp tomknapp temporarily deployed to internal-dev-sandbox April 13, 2026 10:12 — with GitHub Actions Inactive
@tomknapp tomknapp temporarily deployed to internal-dev-sandbox April 13, 2026 10:16 — with GitHub Actions Inactive
@tomknapp tomknapp temporarily deployed to internal-dev-sandbox April 13, 2026 10:22 — with GitHub Actions Inactive
@tomknapp tomknapp temporarily deployed to internal-dev-sandbox April 13, 2026 10:57 — with GitHub Actions Inactive
@tomknapp tomknapp force-pushed the task/NPA-6546/update-post-authorise-responses branch from bd92a28 to b5688a9 Compare April 13, 2026 10:58
@tomknapp tomknapp temporarily deployed to internal-dev-sandbox April 13, 2026 11:00 — with GitHub Actions Inactive
@tomknapp tomknapp force-pushed the task/NPA-6546/update-post-authorise-responses branch from b5688a9 to 8ec8016 Compare April 13, 2026 11:01
@tomknapp tomknapp temporarily deployed to internal-dev-sandbox April 13, 2026 11:03 — with GitHub Actions Inactive
Copy link
Copy Markdown

@ehallam ehallam left a comment

Choose a reason for hiding this comment

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

just a few comments on naming but other than that looks great!
obviously happy for you to push back

Comment thread app/api/infrastructure/tpp/client.py Outdated
Comment thread app/api/infrastructure/tpp/models.py Outdated
Comment thread app/api/infrastructure/emis/client.py Outdated
@tomknapp tomknapp temporarily deployed to internal-dev-sandbox April 13, 2026 15:54 — with GitHub Actions Inactive
ehallam
ehallam previously approved these changes Apr 13, 2026
Copy link
Copy Markdown

@ehallam ehallam left a comment

Choose a reason for hiding this comment

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

nice one!

@tomknapp tomknapp force-pushed the task/NPA-6546/update-post-authorise-responses branch from 828312b to d4fc225 Compare April 13, 2026 15:59
@tomknapp tomknapp temporarily deployed to internal-dev-sandbox April 13, 2026 16:03 — with GitHub Actions Inactive
@ehallam ehallam merged commit e1540f6 into main Apr 15, 2026
26 checks passed
@ehallam ehallam deleted the task/NPA-6546/update-post-authorise-responses branch April 15, 2026 13:48
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.

4 participants