Skip to content

Commit

Permalink
[PRMP-760] - format
Browse files Browse the repository at this point in the history
  • Loading branch information
NogaNHS committed Sep 2, 2024
1 parent 2e8e6fb commit 8767dcb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
20 changes: 10 additions & 10 deletions lambda/bulk-ods-update/bulk_ods_update.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import calendar
import csv
import logging
import os
import tempfile
from datetime import date, timedelta, datetime
import calendar
import csv

import boto3

from utils.enums.trud import OdsDownloadType, TrudItem
from utils.models.ods_models import PracticeOds, IcbOds
from utils.services.ssm_service import SsmSecretManager
from utils.services.trud_api_service import TrudApiService

import logging

from utils.trud_files import (
GP_FILE_HEADERS,
ICB_FILE_HEADERS,
Expand Down Expand Up @@ -151,10 +149,10 @@ def extract_and_process_ods_icb_data(trud_service: TrudApiService):
logger.info("Extracting and processing ODS ICB data")

if icb_zip_file := trud_service.unzipping_files(
download_file, icb_zip_file_path, TEMP_DIR, True
download_file, icb_zip_file_path, TEMP_DIR, True
):
if icb_csv_file := trud_service.unzipping_files(
icb_zip_file, icb_csv_file_name, TEMP_DIR
icb_zip_file, icb_csv_file_name, TEMP_DIR
):
icb_ods_data = trud_csv_to_dict(icb_csv_file, ICB_FILE_HEADERS)
icb_ods_data_amended_data = get_amended_records(icb_ods_data)
Expand Down Expand Up @@ -201,7 +199,8 @@ def compare_and_overwrite(download_type: OdsDownloadType, data: list[dict]):
PracticeOds.icb_ods_code.set(amended_record.get("IcbOdsCode")),
]
)
logger.info(f'Overwriting for ODS: {amended_record.get("PracticeOdsCode")} - Name: {amended_record.get("PracticeName")} | ICB: {amended_record.get("IcbOdsCode")}')
logger.info(
f'Overwriting for ODS: {amended_record.get("PracticeOdsCode")} - Name: {amended_record.get("PracticeName")} | ICB: {amended_record.get("IcbOdsCode")}')
except Exception as e:
logger.info(
f"Failed to create/update record by Practice ODS code: {str(e)}"
Expand All @@ -213,10 +212,11 @@ def compare_and_overwrite(download_type: OdsDownloadType, data: list[dict]):
try:
icb = IcbOds(amended_record.get("IcbOdsCode"))
icb.update(actions=[IcbOds.icb_name.set(amended_record.get("IcbName"))])
logger.info(f'Overwriting for ODS: {amended_record.get("IcbOdsCode")} - Name: {amended_record.get("IcbName")}')
logger.info(
f'Overwriting for ODS: {amended_record.get("IcbOdsCode")} - Name: {amended_record.get("IcbName")}')
except Exception as e:
logger.info(f"Failed to create/update record by ICB ODS code: {str(e)}")


class UnableToGetReleaseDate(Exception):
pass
pass
7 changes: 3 additions & 4 deletions lambda/event-enrichment/event_enrichment_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,6 @@ def _publish_enriched_events_to_sns_topic(enriched_events: list):


def _fetch_supplier_details(practice_ods_code: str) -> dict:

if not practice_ods_code or practice_ods_code.isspace():
return EMPTY_ORGANISATION

Expand Down Expand Up @@ -315,9 +314,9 @@ def _fetch_supplier_details(practice_ods_code: str) -> dict:

def _has_supplier_ods_code(extension: dict) -> bool:
return (
"SDS-ManufacturingOrganisation" in extension["url"]
and "ods-organization-code"
in extension["valueReference"]["identifier"]["system"]
"SDS-ManufacturingOrganisation" in extension["url"]
and "ods-organization-code"
in extension["valueReference"]["identifier"]["system"]
)


Expand Down

0 comments on commit 8767dcb

Please sign in to comment.