Skip to content

Commit ddc1c0b

Browse files
committed
tidy
1 parent 4c4c508 commit ddc1c0b

File tree

11 files changed

+11
-103
lines changed

11 files changed

+11
-103
lines changed

.github/workflows/sonarcloud.yml

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -24,45 +24,6 @@ jobs:
2424
- name: Install poetry
2525
run: pip install poetry==2.1.4
2626

27-
- name: Debug PR Info
28-
if: github.event_name == 'pull_request'
29-
run: |
30-
echo "PR Number: ${{ github.event.pull_request.number }}"
31-
echo "PR Head SHA: ${{ github.event.pull_request.head.sha }}"
32-
echo "PR Base SHA: ${{ github.event.pull_request.base.sha }}"
33-
echo "Current SHA: ${{ github.sha }}"
34-
35-
36-
- name: Debug Trigger Info
37-
run: |
38-
echo "=== WORKFLOW TRIGGER DEBUG ==="
39-
echo "Event Name: ${{ github.event_name }}"
40-
echo "Current SHA: ${{ github.sha }}"
41-
42-
if [ "${{ github.event_name }}" = "pull_request" ]; then
43-
echo "=== PULL REQUEST DETAILS ==="
44-
echo "PR Number: ${{ github.event.pull_request.number }}"
45-
echo "PR Head SHA: ${{ github.event.pull_request.head.sha }}"
46-
echo "PR Base SHA: ${{ github.event.pull_request.base.sha }}"
47-
echo "PR Head Ref: ${{ github.event.pull_request.head.ref }}"
48-
echo "PR Base Ref: ${{ github.event.pull_request.base.ref }}"
49-
echo "✅ Using PR HEAD commit for analysis"
50-
elif [ "${{ github.event_name }}" = "push" ]; then
51-
echo "=== PUSH DETAILS ==="
52-
echo "Branch: ${{ github.ref_name }}"
53-
echo "Pushed SHA: ${{ github.sha }}"
54-
echo "Before SHA: ${{ github.event.before }}"
55-
echo "After SHA: ${{ github.event.after }}"
56-
echo "✅ Using pushed commit for analysis"
57-
else
58-
echo "=== OTHER EVENT ==="
59-
echo "Unknown event type: ${{ github.event_name }}"
60-
fi
61-
62-
63-
- name: Install poetry
64-
run: pip install poetry==2.1.2
65-
6627
- uses: actions/setup-python@v5
6728
with:
6829
python-version: 3.11

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,3 @@ openapi.json
3030

3131
devtools/volume/
3232
**/.coverage
33-
backend/src/1.json

.tool-versions

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
poetry 2.1.2
32
nodejs 23.11.0
43
python 3.11.12

backend/src/fhir_controller.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
from parameter_parser import process_params, process_search_params, create_query_string
3737
import urllib.parse
3838

39-
4039
sqs_client = boto3_client("sqs", region_name="eu-west-2")
4140
queue_url = os.getenv("SQS_QUEUE_URL", "Queue_url")
4241

@@ -392,10 +391,10 @@ def delete_immunization(self, aws_event):
392391
except UnauthorizedVaxError as unauthorized:
393392
return self.create_response(403, unauthorized.to_operation_outcome())
394393

395-
def search_immunizations(self, aws_event: APIGatewayProxyEventV1) -> dict:
396-
394+
def search_immunizations(self, aws_event: APIGatewayProxyEventV1) -> dict:
397395
if response := self.authorize_request(aws_event):
398396
return response
397+
399398
try:
400399
search_params = process_search_params(process_params(aws_event))
401400
except ParameterException as e:
@@ -429,6 +428,7 @@ def search_immunizations(self, aws_event: APIGatewayProxyEventV1) -> dict:
429428
except UnauthorizedVaxError as unauthorized:
430429
return self.create_response(403, unauthorized.to_operation_outcome())
431430
# Check vaxx type permissions on the existing record - end
431+
432432
result = self.fhir_service.search_immunizations(
433433
search_params.patient_identifier,
434434
vax_type_perm,
@@ -657,8 +657,7 @@ def create_response(status_code, body=None, headers=None):
657657

658658
@staticmethod
659659
def _identify_supplier_system(aws_event):
660-
headers = aws_event.get("headers", {})
661-
supplier_system = headers.get("SupplierSystem")
660+
supplier_system = aws_event["headers"]["SupplierSystem"]
662661
if not supplier_system:
663662
raise UnauthorizedError("SupplierSystem header is missing")
664663
return supplier_system

backend/src/fhir_repository.py

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
from models.utils.validation_utils import get_vaccine_type, check_identifier_system_value
2424

25+
2526
def create_table(table_name=None, endpoint_url=None, region_name="eu-west-2"):
2627
if not table_name:
2728
table_name = os.environ["DYNAMODB_TABLE_NAME"]
@@ -395,34 +396,12 @@ def delete_immunization(
395396

396397
def find_immunizations(self, patient_identifier: str, vaccine_types: list):
397398
"""it should find all of the specified patient's Immunization events for all of the specified vaccine_types"""
398-
399-
# ✅ Add debug logging
400-
import logging
401-
logger = logging.getLogger(__name__)
402-
403-
# Create the patient PK and log it
404-
patient_pk = _make_patient_pk(patient_identifier)
405-
406-
condition = Key("PatientPK").eq(patient_pk)
399+
condition = Key("PatientPK").eq(_make_patient_pk(patient_identifier))
407400
is_not_deleted = Attr("DeletedAt").not_exists() | Attr("DeletedAt").eq("reinstated")
408401

409-
# # check response without filter
410-
# response = self.table.query(
411-
# IndexName="PatientGSI",
412-
# KeyConditionExpression=condition
413-
# )
414-
# if 'LastEvaluatedKey' in response:
415-
# print("More rows are available. Use LastEvaluatedKey to paginate.")
416-
# else:
417-
# print("No more rows.")
418-
419-
raw_items = self.get_all_items(condition,is_not_deleted)
420-
421-
# ✅ Log the raw DynamoDB response
402+
raw_items = self.get_all_items(condition, is_not_deleted)
422403

423404
if raw_items:
424-
# Log first few items for debugging
425-
426405
# Filter the response to contain only the requested vaccine types
427406
items = [x for x in raw_items if x["PatientSK"].split("#")[0] in vaccine_types]
428407

backend/src/fhir_service.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,6 @@ def search_immunizations(
290290
"""
291291
# TODO: is disease type a mandatory field? (I assumed it is)
292292
# i.e. Should we provide a search option for getting Patient's entire imms history?
293-
294293
if not nhs_number_mod11_check(nhs_number):
295294
return create_diagnostics()
296295

@@ -300,6 +299,7 @@ def search_immunizations(
300299
for r in self.immunization_repo.find_immunizations(nhs_number, vaccine_types)
301300
if self.is_valid_date_from(r, date_from) and self.is_valid_date_to(r, date_to)
302301
]
302+
303303
# Create the patient URN for the fullUrl field.
304304
# NOTE: This UUID is assigned when a SEARCH request is received and used only for referencing the patient
305305
# resource from immunisation resources within the bundle. The fullUrl value we are using is a urn (hence the
@@ -311,14 +311,14 @@ def search_immunizations(
311311

312312
# Filter and amend the immunization resources for the SEARCH response
313313
resources_filtered_for_search = [Filter.search(imms, patient_full_url) for imms in resources]
314+
314315
# Add bundle entries for each of the immunization resources
315316
entries = [
316317
BundleEntry(
317318
resource=Immunization.parse_obj(imms),
318319
search=BundleEntrySearch(mode="match"),
319320
fullUrl=f"https://api.service.nhs.uk/immunisation-fhir-api/Immunization/{imms['id']}",
320321
)
321-
# get imms and log for debug
322322
for imms in resources_filtered_for_search
323323
]
324324

backend/src/get_imms_handler.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,10 @@
88
from models.errors import Severity, Code, create_operation_outcome
99
from log_structure import function_info
1010
from constants import GENERIC_SERVER_ERROR_DIAGNOSTICS_MESSAGE
11-
from clients import logger
1211

1312
logging.basicConfig(level="INFO")
1413
logger = logging.getLogger()
1514

16-
1715
@function_info
1816
def get_imms_handler(event, _context):
1917
return get_immunization_by_id(event, make_controller())

backend/src/models/utils/a.json

Lines changed: 0 additions & 24 deletions
This file was deleted.

backend/src/parameter_parser.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ def process_search_params(params: ParamContainer) -> SearchParams:
8585
8686
:raises ParameterException:
8787
"""
88+
8889
# patient.identifier
8990
patient_identifiers = params.get(patient_identifier_key, [])
9091
patient_identifier = patient_identifiers[0] if len(patient_identifiers) == 1 else None
@@ -124,6 +125,7 @@ def process_search_params(params: ParamContainer) -> SearchParams:
124125
if len(date_froms) == 1 else date_from_default
125126
except ValueError:
126127
raise ParameterException(f"Search parameter {date_from_key} must be in format: YYYY-MM-DD")
128+
127129
# date.to
128130
date_tos = params.get(date_to_key, [])
129131

backend/src/search_imms_handler.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ def search_imms_handler(event: events.APIGatewayProxyEventV1, _context: context_
2424

2525
def search_imms(event: events.APIGatewayProxyEventV1, controller: FhirController):
2626
try:
27-
logger.info(json.dumps(event, indent=2))
2827
query_params = event.get("queryStringParameters", {})
2928
body = event.get("body")
3029
body_has_immunization_identifier = False
@@ -46,7 +45,6 @@ def search_imms(event: events.APIGatewayProxyEventV1, controller: FhirController
4645
# Check for 'immunization.identifier' in body
4746
body_has_immunization_identifier = "immunization.identifier" in parsed_body
4847
body_has_immunization_element = "_element" in parsed_body
49-
5048
if (
5149
query_string_has_immunization_identifier
5250
or body_has_immunization_identifier

0 commit comments

Comments
 (0)