-
Notifications
You must be signed in to change notification settings - Fork 2
Feature/eja eli 579 adding derivation for previous dose calculations #515
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Feature/eja eli 579 adding derivation for previous dose calculations #515
Conversation
…of making it compatible with the token parsing logic
… syntax has changed. Going to loop back round and check if we need to specifically re-enable what it was actually testing
…ys with date formatting work
…evious-dose-calculations
1e2c894 to
122b6dc
Compare
…evious-dose-calculations
…le instances a function
…evious-dose-calculations
…evious-dose-calculations
…evious-dose-calculations
| @@ -0,0 +1,28 @@ | |||
| from eligibility_signposting_api.services.processors.derived_values.add_days_handler import AddDaysHandler | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this initialises the set of derived value handlers in the registry on lambda startup
| @@ -0,0 +1,180 @@ | |||
| from datetime import UTC, datetime, timedelta | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the specific implementation of the 'add days' function
| @@ -0,0 +1,67 @@ | |||
| from abc import ABC, abstractmethod | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the base class 'template' for all derivation classes
| @@ -0,0 +1,164 @@ | |||
| from typing import ClassVar | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the 'registry' that allows token text to map to a specific handler and provides the 'calculate' method for that handler to the calling code
| Attributes | ||
| ---------- | ||
| attribute_level : str | ||
| Example: "PERSON" or "TARGET" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changes to token parser to parse function information
| from typing import Any, Never | ||
|
|
||
| from wireup import service | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added in ability to call the calculate method for a given function after parsing all the arguments etc
Description
https://nhsd-jira.digital.nhs.uk/browse/ELI-579
COVID-19 Too Close to Previous dose calculation (add days template function). Specifically, adding the ability to have an 'in config' function call to an ADD_DAYS function, which allows the return of relative dates. This functionality leverages the existing token parsing functionality, and extends it to allow function calls beyond date formatting.
Context
Allows us to derive values to return to the user.
I took inspiration from MCP type approaches for LLMs, in that we can set up a 'registry' of tools which we can then make available using the plain text 'function calls'. I've tried to make the approach extendable, so that additional functions for specific purposes can be added by simply creating a class which inherits the base class.
See https://nhsd-confluence.digital.nhs.uk/spaces/Vacc/pages/1254943977/Configuration+driven+derivations for a more in-depth explanation of the changes and how they fit into the existing flow.
Type of changes
Checklist
Sensitive Information Declaration
To ensure the utmost confidentiality and protect your and others privacy, we kindly ask you to NOT including PII (Personal Identifiable Information) / PID (Personal Identifiable Data) or any other sensitive data in this PR (Pull Request) and the codebase changes. We will remove any PR that do contain any sensitive information. We really appreciate your cooperation in this matter.