Skip to content

Commit d3fa4eb

Browse files
authored
Merge pull request #473 from NHSDigital/release/2025-01-17
Release/2025 01 17
2 parents c9e3fe7 + c05ceda commit d3fa4eb

File tree

17 files changed

+308
-35
lines changed

17 files changed

+308
-35
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 2025-01-17
4+
- [PI-730] Accredited System base model is outdated
5+
- [PI-704] Refactor searchSdsDevice to use new domain structure
6+
37
## 2025-01-15
48
- [PI-689] Changelog ETL - modify / add to an AS
59

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2025.01.15
1+
2025.01.17

changelog/2025-01-17.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- [PI-730] Accredited System base model is outdated
2+
- [PI-704] Refactor searchSdsDevice to use new domain structure

infrastructure/swagger/05_paths.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -463,8 +463,7 @@ paths:
463463
operationId: searchsdsdevice
464464
summary: Retrieve Device resources for SDS FHIR API (GET)
465465
parameters:
466-
- $ref: "#/components/parameters/NhsAsClient"
467-
- $ref: "#/components/parameters/NhsAsClientInteration"
466+
- $ref: "#/components/parameters/NhsIdCode"
468467
- $ref: "#/components/parameters/NhsMhsManOrg"
469468
- $ref: "#/components/parameters/NhsMhsPartyKey"
470469
- $ref: "#/components/parameters/HeaderVersion"

infrastructure/swagger/13_components--parameters--query.yaml

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,6 @@
11
---
22
components:
33
parameters:
4-
NhsAsClient:
5-
name: nhs_as_client
6-
in: query
7-
required: true
8-
description: "Accredited System Client"
9-
schema:
10-
type: string
11-
NhsAsClientInteration:
12-
name: nhs_as_svc_ia
13-
in: query
14-
required: true
15-
description: "Accredited System Client Interaction"
16-
schema:
17-
type: string
184
NhsMhsManOrg:
195
name: nhs_mhs_manufacturer_org
206
in: query

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "connecting-party-manager"
3-
version = "2025.01.15"
3+
version = "2025.01.17"
44
description = "Repository for the Connecting Party Manager API and related services"
55
authors = ["NHS England"]
66
license = "LICENSE.md"

src/api/searchSdsDevice/src/v1/steps.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,44 @@ def _parse_event_query(query_params: dict):
1616
def parse_event_query(data, cache):
1717
event = APIGatewayProxyEvent(data[StepChain.INIT])
1818
query_params = _parse_event_query(event.query_string_parameters or {})
19+
1920
return {
2021
"query_params": query_params,
2122
"host": event.multi_value_headers["Host"],
2223
}
2324

2425

25-
def query_devices(data, cache) -> dict:
26+
def remove_manufacturer_org(data, cache):
2627
event_data: dict = data[parse_event_query]
2728
query_params: dict = event_data.get("query_params")
29+
ods_code = query_params.pop("nhs_mhs_manufacturer_org", None)
30+
return {"query_params": query_params, "ods_code": ods_code}
31+
32+
33+
def query_devices(data, cache) -> dict:
34+
event_data: dict = data[remove_manufacturer_org]
35+
query_params: dict = event_data.get("query_params")
2836
device_repo = DeviceRepository(
2937
table_name=cache["DYNAMODB_TABLE"], dynamodb_client=cache["DYNAMODB_CLIENT"]
3038
)
3139
results = device_repo.query_by_tag(**query_params)
32-
return HTTPStatus.OK, [result.state() for result in results]
40+
return [result.state() for result in results]
41+
42+
43+
def filter_devices(data, cache):
44+
event_data: dict = data[remove_manufacturer_org]
45+
ods_code: dict = event_data.get("ods_code")
46+
results: dict = data[query_devices]
47+
filtered_results = []
48+
for result in results:
49+
if not ods_code or result["ods_code"] == ods_code:
50+
filtered_results.append(result)
51+
return HTTPStatus.OK, filtered_results
3352

3453

3554
steps = [
3655
parse_event_query,
56+
remove_manufacturer_org,
3757
query_devices,
58+
filter_devices,
3859
]
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
Feature: Search SDS Device - failure scenarios
2+
These scenarios demonstrate failure SDS Device searching
3+
4+
Background:
5+
Given "default" request headers:
6+
| name | value |
7+
| version | 1 |
8+
| Authorization | letmein |
9+
10+
Scenario: Unsuccessfully search an SDS Device without query params
11+
When I make a "GET" request with "default" headers to "searchSdsDevice"
12+
Then I receive a status code "400" with body
13+
| path | value |
14+
| errors.0.code | MISSING_VALUE |
15+
| errors.0.message | SearchSDSDeviceQueryParams.nhs_id_code: field required |
16+
| errors.1.code | MISSING_VALUE |
17+
| errors.1.message | SearchSDSDeviceQueryParams.nhs_as_svc_ia: field required |
18+
And the response headers contain:
19+
| name | value |
20+
| Content-Type | application/json |
21+
| Content-Length | 206 |
22+
23+
Scenario: Unsuccessfully search an SDS Device without nhs_id_code query param
24+
When I make a "GET" request with "default" headers to "searchSdsDevice?nhs_as_svc_ia=Foo"
25+
Then I receive a status code "400" with body
26+
| path | value |
27+
| errors.0.code | MISSING_VALUE |
28+
| errors.0.message | SearchSDSDeviceQueryParams.nhs_id_code: field required |
29+
And the response headers contain:
30+
| name | value |
31+
| Content-Type | application/json |
32+
| Content-Length | 108 |
33+
34+
Scenario: Unsuccessfully search an SDS Device without nhs_as_svc_ia query param
35+
When I make a "GET" request with "default" headers to "searchSdsDevice?nhs_id_code=Foo"
36+
Then I receive a status code "400" with body
37+
| path | value |
38+
| errors.0.code | MISSING_VALUE |
39+
| errors.0.message | SearchSDSDeviceQueryParams.nhs_as_svc_ia: field required |
40+
And the response headers contain:
41+
| name | value |
42+
| Content-Type | application/json |
43+
| Content-Length | 110 |
44+
45+
Scenario: Unsuccessfully search an SDS Device with unknown query param
46+
When I make a "GET" request with "default" headers to "searchSdsDevice?nhs_id_code=Foo&nhs_as_svc_ia=Bar&foo=bar"
47+
Then I receive a status code "400" with body
48+
| path | value |
49+
| errors.0.code | VALIDATION_ERROR |
50+
| errors.0.message | SearchSDSDeviceQueryParams.foo: extra fields not permitted |
51+
And the response headers contain:
52+
| name | value |
53+
| Content-Type | application/json |
54+
| Content-Length | 115 |

0 commit comments

Comments
 (0)