From 66a282d5859b489cb61729d32c78eaec55f94dbc Mon Sep 17 00:00:00 2001 From: Elliot Hallam <20362314+ehallam@users.noreply.github.com> Date: Wed, 15 Apr 2026 15:57:49 +0100 Subject: [PATCH 1/5] NPA-6546: fix end to end tests --- app/api/domain/forward_response_model.py | 6 +++--- app/api/infrastructure/emis/client.py | 10 +++++----- app/api/infrastructure/emis/models.py | 6 +++--- app/api/infrastructure/emis/tests/test_client.py | 8 ++++---- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/app/api/domain/forward_response_model.py b/app/api/domain/forward_response_model.py index 0a82706..9e6f3b1 100644 --- a/app/api/domain/forward_response_model.py +++ b/app/api/domain/forward_response_model.py @@ -1,4 +1,4 @@ -from pydantic import BaseModel, ConfigDict, field_validator +from pydantic import BaseModel, ConfigDict, SerializeAsAny, field_validator from pydantic.alias_generators import to_camel @@ -26,8 +26,8 @@ class ForwardResponse(BaseModel): session_id: str supplier: str ods_code: str - user: Demographics - patients: list[Demographics] + user: SerializeAsAny[Demographics] + patients: list[SerializeAsAny[Demographics]] @field_validator("patients") def patients_must_not_be_empty(cls, v: list) -> list: # noqa: N805 diff --git a/app/api/infrastructure/emis/client.py b/app/api/infrastructure/emis/client.py index c4011e9..c133569 100644 --- a/app/api/infrastructure/emis/client.py +++ b/app/api/infrastructure/emis/client.py @@ -14,7 +14,7 @@ EffectiveServices, Identifier, MedicalRecordPermissions, - Patient, + Person, SessionRequestData, SessionRequestHeaders, SessionResponse, @@ -114,7 +114,7 @@ def transform_response(self, response: dict) -> SessionResponse: endUserSessionId=response.get("EndUserSessionId"), supplier=self.supplier, odsCode=self.request.patient_ods_code, - user=Patient( + user=Person( firstName=response.get("FirstName"), surname=response.get("Surname"), title=response.get("Title"), @@ -145,20 +145,20 @@ def _mock_response(self) -> dict: with Path((BASE_DIR) / "data" / "mocked_response.json").open("r") as f: return load(f) - def _parse_patients(self, patient_links: list) -> list[Patient]: + def _parse_patients(self, patient_links: list) -> list[Person]: """Parsing raw data from Client into structual model. Args: patient_links (dict): Raw data containing information about patients Returns: - list[Patient]: Parsed information about patients + list[Person]: Parsed information about patients """ parsed_patients = [] for patient in patient_links: raw_permissions = patient.get("EffectiveServices", {}) parsed_patients.append( - Patient( + Person( firstName=patient.get("FirstName"), surname=patient.get("Surname"), title=patient.get("Title"), diff --git a/app/api/infrastructure/emis/models.py b/app/api/infrastructure/emis/models.py index b2cc49c..e8a2339 100644 --- a/app/api/infrastructure/emis/models.py +++ b/app/api/infrastructure/emis/models.py @@ -83,7 +83,7 @@ class EffectiveServices(Permissions): medical_record: MedicalRecordPermissions -class Patient(Demographics): +class Person(Demographics): """Base Model for User and Patient.""" model_config = ConfigDict(alias_generator=to_camel) @@ -99,5 +99,5 @@ class SessionResponse(ForwardResponse): model_config = ConfigDict(alias_generator=to_camel) end_user_session_id: str - user: Patient - patients: list[Patient] + user: Person + patients: list[Person] diff --git a/app/api/infrastructure/emis/tests/test_client.py b/app/api/infrastructure/emis/tests/test_client.py index 8accad9..c4aedc9 100644 --- a/app/api/infrastructure/emis/tests/test_client.py +++ b/app/api/infrastructure/emis/tests/test_client.py @@ -18,7 +18,7 @@ EffectiveServices, Identifier, MedicalRecordPermissions, - Patient, + Person, SessionResponse, ) @@ -140,7 +140,7 @@ def test_emis_client_transform_response(client: EmisClient) -> None: endUserSessionId="SESS_mDq6nE2b8R7KQ0v", supplier="EMIS", odsCode="some patient ods code", - user=Patient( + user=Person( firstName="Alex", surname="Taylor", title="Mr", @@ -170,7 +170,7 @@ def test_emis_client_transform_response(client: EmisClient) -> None: ), ), patients=[ - Patient( + Person( firstName="Jane", surname="Doe", title="Mrs", @@ -201,7 +201,7 @@ def test_emis_client_transform_response(client: EmisClient) -> None: ), ), ), - Patient( + Person( firstName="Ella", surname="Taylor", title="Ms", From 1b61b4c63ff85451c1d0caff82344910139fe752 Mon Sep 17 00:00:00 2001 From: Elliot Hallam <20362314+ehallam@users.noreply.github.com> Date: Thu, 16 Apr 2026 09:22:02 +0100 Subject: [PATCH 2/5] NPA-6546: address copilot comments --- app/api/infrastructure/emis/client.py | 4 ++-- app/api/infrastructure/tpp/client.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/api/infrastructure/emis/client.py b/app/api/infrastructure/emis/client.py index c133569..e39048c 100644 --- a/app/api/infrastructure/emis/client.py +++ b/app/api/infrastructure/emis/client.py @@ -146,10 +146,10 @@ def _mock_response(self) -> dict: return load(f) def _parse_patients(self, patient_links: list) -> list[Person]: - """Parsing raw data from Client into structual model. + """Parsing raw data from Client into structural model. Args: - patient_links (dict): Raw data containing information about patients + patient_links (list[dict]): Raw data containing information about patients Returns: list[Person]: Parsed information about patients diff --git a/app/api/infrastructure/tpp/client.py b/app/api/infrastructure/tpp/client.py index 88f6760..66cb8d3 100644 --- a/app/api/infrastructure/tpp/client.py +++ b/app/api/infrastructure/tpp/client.py @@ -136,7 +136,7 @@ def _mock_response(self) -> dict: return xmltodict.parse(mocked_response) def _parse_patients(self, data: dict) -> list[Person]: - """Parsing raw data from Client into structual model. + """Parsing raw data from Client into structural model. Args: data (dict): Raw data containing information about multiple patients From bc6ad535a46e0cf46c5106ac968ffeb0f075e27d Mon Sep 17 00:00:00 2001 From: Elliot Hallam <20362314+ehallam@users.noreply.github.com> Date: Thu, 16 Apr 2026 11:16:47 +0100 Subject: [PATCH 3/5] NPA-6546: testing with new proxygen credentials --- .github/actions/setup-proxygen/action.yaml | 8 ++++---- proxygen/credentials.yaml | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/actions/setup-proxygen/action.yaml b/.github/actions/setup-proxygen/action.yaml index 831ade8..5ca674d 100644 --- a/.github/actions/setup-proxygen/action.yaml +++ b/.github/actions/setup-proxygen/action.yaml @@ -29,15 +29,15 @@ runs: - name: Create Proxygen private key file run: | - echo "${{ inputs.PROXYGEN_PRIVATE_KEY }}" > ~/.proxygen/private_key.pem + echo "${{ inputs.NEW_PROXYGEN_PRIVATE_KEY }}" > ~/.proxygen/private_key.pem chmod 600 ~/.proxygen/private_key.pem shell: bash - name: Update Proxygen Credentials run: | - sed -i "s|CLIENT_ID_TO_BE_REPLACED|${{ inputs.PROXYGEN_CLIENT_ID }}|" ~/.proxygen/credentials.yaml - sed -i "s|KEY_ID_TO_BE_REPLACED|${{ inputs.PROXYGEN_KEY_ID }}|" ~/.proxygen/credentials.yaml - sed -i "s|PRIVATE_KEY_PATH_TO_BE_REPLACED|private_key.pem|" ~/.proxygen/credentials.yaml + sed -i "s|NEW_CLIENT_ID_TO_BE_REPLACED|${{ inputs.NEW_PROXYGEN_CLIENT_ID }}|" ~/.proxygen/credentials.yaml + sed -i "s|NEW_KEY_ID_TO_BE_REPLACED|${{ inputs.NEW_PROXYGEN_KEY_ID }}|" ~/.proxygen/credentials.yaml + sed -i "s|NEW_PRIVATE_KEY_PATH_TO_BE_REPLACED|private_key.pem|" ~/.proxygen/credentials.yaml shell: bash - name: Copy Proxygen settings diff --git a/proxygen/credentials.yaml b/proxygen/credentials.yaml index 454a829..caba917 100644 --- a/proxygen/credentials.yaml +++ b/proxygen/credentials.yaml @@ -1,4 +1,4 @@ base_url: https://identity.prod.api.platform.nhs.uk/realms/api-producers -client_id: CLIENT_ID_TO_BE_REPLACED -key_id: KEY_ID_TO_BE_REPLACED -private_key_path: PRIVATE_KEY_PATH_TO_BE_REPLACED +client_id: NEW_CLIENT_ID_TO_BE_REPLACED +key_id: NEW_KEY_ID_TO_BE_REPLACED +private_key_path: NEW_PRIVATE_KEY_PATH_TO_BE_REPLACED From 58a861ce4671286134c8e97b60cfaa6884c0d9ee Mon Sep 17 00:00:00 2001 From: Elliot Hallam <20362314+ehallam@users.noreply.github.com> Date: Thu, 16 Apr 2026 11:23:00 +0100 Subject: [PATCH 4/5] NPA-6546: prepended inputs with NEW_ --- .github/workflows/pull-request-checks.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/pull-request-checks.yml b/.github/workflows/pull-request-checks.yml index ea705e2..05fd4c6 100644 --- a/.github/workflows/pull-request-checks.yml +++ b/.github/workflows/pull-request-checks.yml @@ -35,9 +35,9 @@ jobs: emis_base_url: https://nhs70apptest.emishealth.com tpp_base_url: https://systmonline2.tpp-uk.com secrets: - PROXYGEN_CLIENT_ID: ${{ secrets.PROXYGEN_CLIENT_ID }} - PROXYGEN_KEY_ID: ${{ secrets.PROXYGEN_KEY_ID }} - PROXYGEN_PRIVATE_KEY: ${{ secrets.PROXYGEN_PRIVATE_KEY }} + NEW_PROXYGEN_CLIENT_ID: ${{ secrets.NEW_PROXYGEN_CLIENT_ID }} + NEW_PROXYGEN_KEY_ID: ${{ secrets.NEW_PROXYGEN_KEY_ID }} + NEW_PROXYGEN_PRIVATE_KEY: ${{ secrets.NEW_PROXYGEN_PRIVATE_KEY }} run-end-to-end-tests: name: "Run End to End Tests" @@ -54,9 +54,9 @@ jobs: - name: Setup proxygen uses: ./.github/actions/setup-proxygen with: - PROXYGEN_CLIENT_ID: ${{ secrets.PROXYGEN_CLIENT_ID }} - PROXYGEN_KEY_ID: ${{ secrets.PROXYGEN_KEY_ID }} - PROXYGEN_PRIVATE_KEY: ${{ secrets.PROXYGEN_PRIVATE_KEY }} + NEW_PROXYGEN_CLIENT_ID: ${{ secrets.NEW_PROXYGEN_CLIENT_ID }} + NEW_PROXYGEN_KEY_ID: ${{ secrets.NEW_PROXYGEN_KEY_ID }} + NEW_PROXYGEN_PRIVATE_KEY: ${{ secrets.NEW_PROXYGEN_PRIVATE_KEY }} - name: Run End to End Tests uses: ./.github/actions/run-end-to-end-tests env: @@ -78,9 +78,9 @@ jobs: additional_path: "pr-${{ github.event.number }}" type_of_deployment: "sandbox" secrets: - PROXYGEN_CLIENT_ID: ${{ secrets.PROXYGEN_CLIENT_ID }} - PROXYGEN_KEY_ID: ${{ secrets.PROXYGEN_KEY_ID }} - PROXYGEN_PRIVATE_KEY: ${{ secrets.PROXYGEN_PRIVATE_KEY }} + NEW_PROXYGEN_CLIENT_ID: ${{ secrets.NEW_PROXYGEN_CLIENT_ID }} + NEW_PROXYGEN_KEY_ID: ${{ secrets.NEW_PROXYGEN_KEY_ID }} + NEW_PROXYGEN_PRIVATE_KEY: ${{ secrets.NEW_PROXYGEN_PRIVATE_KEY }} run-postman-collection: name: "Run Postman Collection" From 55df05612127dab73cd418ba2e4cfec00bf9f00b Mon Sep 17 00:00:00 2001 From: Elliot Hallam <20362314+ehallam@users.noreply.github.com> Date: Thu, 16 Apr 2026 11:43:34 +0100 Subject: [PATCH 5/5] empty commit to retrigger build