-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bump up versions Begin adding quality checker values and updating variables Bump up requirements Improve variable names and use terraform jsonencode Update more terraform Add serverless cron Add more dos searching Add base level reporting functions Reduce code duplication and log on z code incorrectly profiled Start unit tests Increase unit test coverage Add schedule and deployment changes Add job complete and incomplete alarms Fix incorrect alarm threshold
- Loading branch information
Jack Plowman
committed
Sep 18, 2023
1 parent
a710a94
commit f43a09f
Showing
58 changed files
with
1,634 additions
and
805 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,5 @@ omit = | |
tests/* | ||
**/tests/* | ||
application/dos_db_handler/*.py | ||
**/conftest.py | ||
branch = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
aws-embedded-metrics | ||
aws-lambda-powertools[tracer] ~= 2.2.0 | ||
aws-lambda-powertools[tracer] ~= 2.24.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
aws-embedded-metrics | ||
aws-lambda-powertools[tracer] ~= 2.2.0 | ||
aws-lambda-powertools[tracer] ~= 2.24.0 | ||
psycopg[binary] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
aws-embedded-metrics | ||
aws-lambda-powertools[tracer] ~= 2.2.0 | ||
aws-lambda-powertools[tracer] ~= 2.24.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
aws-embedded-metrics | ||
aws-lambda-powertools[tracer] ~= 2.2.0 | ||
aws-lambda-powertools[tracer] ~= 2.24.0 | ||
simplejson |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
aws-embedded-metrics | ||
aws-lambda-powertools[tracer, validation] ~= 2.2.0 | ||
aws-lambda-powertools[tracer, validation] ~= 2.24.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
from aws_lambda_powertools.logging import Logger | ||
from psycopg import Connection | ||
|
||
from .reporting import log_to_quality_check_report | ||
from .search_dos import ( | ||
search_for_incorrectly_profiled_z_code, | ||
search_for_matching_services, | ||
search_for_pharmacy_ods_codes, | ||
) | ||
from common.dos import DoSService | ||
from common.service_type import BLOOD_PRESSURE, CONTRACEPTION, ServiceType | ||
|
||
logger = Logger(child=True) | ||
|
||
|
||
def check_pharmacy_profiling(connection: Connection) -> None: | ||
"""Check the pharmacy profiling data quality of the dos database. | ||
Args: | ||
connection (Connection): Connection to the DoS DB. | ||
""" | ||
odscodes = search_for_pharmacy_ods_codes(connection) | ||
for odscode in odscodes: | ||
matched_services = search_for_matching_services(connection, odscode) | ||
check_for_multiple_of_service_type(matched_services, BLOOD_PRESSURE) | ||
check_for_multiple_of_service_type(matched_services, CONTRACEPTION) | ||
|
||
|
||
def check_incorrect_zcode_profiling(connection: Connection, service_type: ServiceType) -> None: | ||
"""Check the palliative care profiling data quality of the dos database. | ||
Args: | ||
connection (Connection): Connection to the DoS DB. | ||
service_type (ServiceType): Service type to check for. | ||
""" | ||
if incorrectly_profiled_services := search_for_incorrectly_profiled_z_code(connection, service_type): | ||
logger.info( | ||
f"Found {len(incorrectly_profiled_services)} incorrectly " | ||
f"profiled {service_type.TYPE_NAME.lower()} services.", | ||
services=incorrectly_profiled_services, | ||
) | ||
log_to_quality_check_report( | ||
incorrectly_profiled_services, | ||
f"{service_type.TYPE_NAME} ZCode is on invalid service type", | ||
service_type.DOS_SG_SD_ID, | ||
) | ||
|
||
|
||
def check_for_multiple_of_service_type(matched_services: list[DoSService], service_type: ServiceType) -> None: | ||
"""Check for multiple of service type. | ||
Args: | ||
matched_services (list[DoSService]): List of matched services. | ||
service_type (ServiceType): Service type to check for. | ||
""" | ||
matched_service_types = [service for service in matched_services if service.typeid == service_type.DOS_TYPE_ID] | ||
if len(matched_service_types) > 1: | ||
log_to_quality_check_report( | ||
matched_service_types, | ||
f"Multiple 'Pharmacy' type services found (type {service_type.DOS_TYPE_ID})", | ||
) |
Oops, something went wrong.