Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
a0d8d56
AEA-6045 Common validator code and dependencies.
originalphil Feb 6, 2026
4cd9193
Merge branch 'main' into aea-6045-extract-interaction-worker-logic
originalphil Feb 6, 2026
1f89dde
AEA-6045 Moving create-specific validations into create validator.
originalphil Feb 11, 2026
f5c99a4
AEA-6045 Move check_signed_time into CreatePrescriptionValidator and …
originalphil Feb 12, 2026
96c90c0
AEA-6045 Temporarily add agents.md to .gitignore.
originalphil Feb 12, 2026
7ae053e
AEA-6045 Move check_days_supply into CreatePrescriptionValidator and …
originalphil Feb 12, 2026
a6fa77e
AEA-6045 Move check_repeat_dispense_window into CreatePrescriptionVal…
originalphil Feb 12, 2026
8d4188e
AEA-6045 Move check_patient_name into CreatePrescriptionValidator and…
originalphil Feb 12, 2026
061e0b9
AEA-6045 Move check_prescription_treatment_type into CreatePrescripti…
originalphil Feb 12, 2026
a21c647
AEA-6045 Move check_prescription_type into CreatePrescriptionValidato…
originalphil Feb 12, 2026
41e3911
AEA-6045 Move check_repeat_dispense_instances into CreatePrescription…
originalphil Feb 12, 2026
3c86734
AEA-6045 Move check_birth_date into CreatePrescriptionValidator and a…
originalphil Feb 12, 2026
4ace0f5
AEA-6045 Move validate_line_items into CreatePrescriptionValidator an…
originalphil Feb 13, 2026
320688e
AEA-6045 Add run_validations method.
originalphil Feb 17, 2026
f3c4878
AEA-6045 Move validations out of classes and adjust tests.
originalphil Feb 18, 2026
f683ee1
AEA-6045 Remove validation context class.
originalphil Feb 18, 2026
9724c8d
AEA-6045 Back to camelCase for context attributes.
originalphil Feb 19, 2026
a821fd9
AEA-6045 Unit tests for common validations.
originalphil Feb 19, 2026
b7db928
AEA-6045 Interaction worker code WIP.
originalphil Feb 23, 2026
74a54fd
AEA-6045 Remove interaction worker context and schematron.
originalphil Feb 23, 2026
ccaa8d4
AEA-6045 Moved create_initial_record.
originalphil Feb 23, 2026
095ea4f
AEA-6045 Remove subsequent cancellation response generation.
originalphil Feb 23, 2026
fb2fa06
AEA-6045 Whitespace.
originalphil Feb 23, 2026
1baaa1a
AEA-6045 Add prepare_record_for_store to interaction worker code.
originalphil Feb 24, 2026
aa6a669
AEA-6045 Add apply_updates. Remove unused functions. Consistent param…
originalphil Feb 24, 2026
c07f574
Merge branch 'main' into aea-6045-extract-interaction-worker-logic
originalphil Feb 24, 2026
7cd1c43
AEA-6045 Simplify validation errors. Remove unused code.
originalphil Feb 25, 2026
d55ae14
AEA-6045 Remove a bit more unused code. Pre-review tidy.
originalphil Feb 25, 2026
dc90624
AEA-6045 Sonar fixes I.
originalphil Feb 25, 2026
87d456a
AEA-6045 Sonar fixes II.
originalphil Feb 25, 2026
69cf281
AEA-6045 Sonar fixes III.
originalphil Feb 25, 2026
b2d2904
AEA-6045 Sonar fixes IV.
originalphil Feb 25, 2026
516a75d
AEA-6045 Add base utilities unit tests.
originalphil Feb 25, 2026
7a5632b
AEA-6045 Additional unit tests.
originalphil Feb 25, 2026
2049b27
AEA-6045 Little test fix.
originalphil Feb 25, 2026
9aaf790
AEA-6045 Remove temp function.
originalphil Feb 25, 2026
ba46e8c
AEA-6045 Happy path test for validations.
originalphil Feb 25, 2026
23fd1f4
AEA-6045 Add tests for updates.
originalphil Feb 26, 2026
5321c53
AEA-6045 Sonar things.
originalphil Feb 26, 2026
b9c04fd
Merge branch 'main' into aea-6045-extract-interaction-worker-logic
originalphil Feb 26, 2026
a7330ad
AEA-6075 Test coverage.
originalphil Feb 26, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@ cover/
# Build
dist/
__pycache__/

# Temp
agents.md
78 changes: 77 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,15 @@ authors = [
]
readme = "README.md"
requires-python = "==3.10.12"
dependencies = ["boto3 (>=1.26.159,<2.0.0)", "botocore (>=1.29.159,<1.30.0)", "simplejson (>=3.17.2,<4.0.0)", "python-dateutil (>=2.7.0.post0,<3.0.0)", "six (>=1.5,<2.0.0)"]
dependencies = [
"boto3 (>=1.26.159,<2.0.0)",
"botocore (>=1.29.159,<1.30.0)",
"lxml (==4.6.3)",
"python-dateutil (>=2.7.0.post0,<3.0.0)",
"pytz (==2020.4)",
"simplejson (>=3.17.2,<4.0.0)",
"six (>=1.5,<2.0.0)"
]

[tool.poetry]
packages = [{include = "eps_spine_shared", from = "src"}]
Expand Down
64 changes: 64 additions & 0 deletions src/eps_spine_shared/common/checksum_util.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
from string import ascii_uppercase

LONGIDLENGTH_WITH_CHECKDIGIT = 37
SHORTIDLENGTH_WITH_CHECKDIGIT = 20


def calculate_checksum(prescription_id):
"""
Generate a checksum for either R1 or R2 prescription
"""
prsc_id = prescription_id.replace("-", "")
prsc_id_length = len(prsc_id)

running_total = 0
for string_position in range(prsc_id_length - 1):
char_mod36 = int(prsc_id[string_position], 36)
running_total += char_mod36 * (2 ** (prsc_id_length - string_position - 1))

check_value = (38 - running_total % 37) % 37
if check_value == 36:
check_value = "+"
elif check_value > 9:
check_value = ascii_uppercase[check_value - 10]
else:
check_value = str(check_value)

return check_value


def check_checksum(prescription_id, internal_id, log_object):
"""
Check the checksum of a Prescription ID
:prescription_id the prescription to check
:log_object invalid checksums will be logged
"""
check_character = prescription_id[-1:]
check_value = calculate_checksum(prescription_id)

if check_value == check_character:
return True

log_object.write_log(
"MWS0042",
None,
{
"internalID": internal_id,
"prescriptionID": prescription_id,
"checkValue": check_value,
},
)

return False


def remove_check_digit(prescription_id):
"""
Takes the passed in id and determines, by its length, if it contains a checkdigit,
returns an id without the check digit
"""
prescription_key = prescription_id
id_length = len(prescription_id)
if id_length in [LONGIDLENGTH_WITH_CHECKDIGIT, SHORTIDLENGTH_WITH_CHECKDIGIT]:
prescription_key = prescription_id[:-1]
return prescription_key
2 changes: 1 addition & 1 deletion src/eps_spine_shared/common/dynamodb_datastore.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
)
from eps_spine_shared.common.dynamodb_index import EpsDynamoDbIndex, PrescriptionStatus
from eps_spine_shared.logger import EpsLogger
from eps_spine_shared.nhsfundamentals.timeutilities import (
from eps_spine_shared.nhsfundamentals.time_utilities import (
TimeFormats,
convert_spine_date,
time_now_as_string,
Expand Down
2 changes: 1 addition & 1 deletion src/eps_spine_shared/common/dynamodb_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
)
from eps_spine_shared.common.prescription.record import PrescriptionStatus
from eps_spine_shared.logger import EpsLogger
from eps_spine_shared.nhsfundamentals.timeutilities import TimeFormats
from eps_spine_shared.nhsfundamentals.time_utilities import TimeFormats


class EpsDynamoDbIndex:
Expand Down
2 changes: 1 addition & 1 deletion src/eps_spine_shared/common/indexes.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from eps_spine_shared.errors import EpsSystemError
from eps_spine_shared.logger import EpsLogger
from eps_spine_shared.nhsfundamentals.timeutilities import time_now_as_string
from eps_spine_shared.nhsfundamentals.time_utilities import time_now_as_string

INDEX_NHSNUMBER_DATE = "nhsNumberDate_bin"
INDEX_NHSNUMBER_PRDATE = "nhsNumberPrescriberDate_bin"
Expand Down
3 changes: 1 addition & 2 deletions src/eps_spine_shared/common/prescription/issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from eps_spine_shared.common.prescription.claim import PrescriptionClaim
from eps_spine_shared.common.prescription.line_item import PrescriptionLineItem
from eps_spine_shared.common.prescription.statuses import PrescriptionStatus
from eps_spine_shared.nhsfundamentals.timeutilities import TimeFormats
from eps_spine_shared.nhsfundamentals.time_utilities import TimeFormats


class PrescriptionIssue(object):
Expand Down Expand Up @@ -73,7 +73,6 @@ def expire(self, expired_at_time, parent_prescription):
:type expired_at_time: datetime.datetime
:type parent_prescription: PrescriptionRecord
"""

currentStatus = self.status

# update the issue status, if appropriate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from eps_spine_shared.common.prescription import fields
from eps_spine_shared.common.prescription.statuses import PrescriptionStatus
from eps_spine_shared.logger import EpsLogger
from eps_spine_shared.nhsfundamentals.timeutilities import TimeFormats
from eps_spine_shared.nhsfundamentals.time_utilities import TimeFormats


class NextActivityGenerator(object):
Expand Down
Loading