forked from nhs-england-tools/playwright-python-blueprint
-
Notifications
You must be signed in to change notification settings - Fork 2
Feature/bcss 20438 fit kit logged docstrings and md #57
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
Merged
Andyg79
merged 9 commits into
main
from
feature/BCSS-20438-fit-kit-logged-docstrings-and-md
May 9, 2025
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
061ebd9
wip - updated docstrings and added markdown
Andyg79 bc4cbcd
Addressing sonaqube errors
Andyg79 4b3a4bf
addressed sonarqube errors
Andyg79 8024d4e
addressed sonaqube errors
Andyg79 0ad7550
addressing sonarqube errors
Andyg79 2b2b2c6
Added logic to check and correct for duplicate records. (#55)
adrianoaru-nhs 4833bf5
Compartment 6 codegen code (#56)
adrianoaru-nhs 4ab0d83
Addressed PR comments
Andyg79 7e260f4
Merge branch 'main' of github.com:NHSDigital/bcss-playwright into fea…
adrianoaru-nhs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,71 @@ | ||
| # Utility Guide: Fit Kit Logged Utility | ||
|
|
||
| The Fit Kit Logged Utility provides methods to retrieve test data (fit kit test results) used by the compartment 3 tests, and splits them into two dataframes (one 'normal', one 'abnormal'). | ||
|
|
||
| ## Table of Contents | ||
|
|
||
| - [Utility Guide: Fit Kit Logged Utility](#utility-guide-fit-kit-logged-utility) | ||
| - [Table of Contents](#table-of-contents) | ||
| - [Using the Fit Kit Logged Utility](#using-the-fit-kit-logged-utility) | ||
| - [Required Arguments](#required-arguments) | ||
| - [Fit Kit Logged Specific Functions](#fit-kit-logged-specific-functions) | ||
| - [Example Usage](#example-usage) | ||
|
|
||
| ## Using the Fit Kit Logged Utility | ||
|
|
||
| To use the Fit Kit Logged Utility, import the `fit_kit_logged.py` module, from the `utils` directory, into your test file and call the `process_kit_data` method as required. | ||
|
|
||
| ## Required Arguments | ||
|
|
||
| The methods in this utility require specific arguments. Below is a summary of the required arguments for key methods: | ||
|
|
||
| - `process_kit_data`: Requires `smokescreen_properties`(dict) | ||
| - `split_fit_kits`: Requires `kit_id_df`(pd.DataFrame), `smokescreen_properties`(dict) | ||
|
|
||
| ## Fit Kit Logged Specific Functions | ||
|
|
||
| The `fit_kit_logged` Utility includes methods for retrieving FIT test kits from the DB and splitting them into 'Normal' and 'Abnormal' results. Below are their key functions: | ||
|
|
||
| 1. **`process_kit_data(smokescreen_properties: dict) -> list`** | ||
| Retrieves the test data needed for compartment 3 and then splits it into two data frames, using the `split_fit_kits` method. | ||
|
|
||
| - **Arguments**: | ||
| - `smokescreen_properties` (dict): A dictionary containing properties required to retrieve and process kit data. | ||
|
|
||
| - **Returns**: | ||
| A list of tuples where each tuple contains a device ID (str) and a `boolean` flag (True for normal, False for abnormal). | ||
|
|
||
| 1. **`split_fit_kits(kit_id_df: pd.DataFrame, smokescreen_properties: dict) -> tuple`** | ||
| This method splits the `dataframe` into two dataframes, one normal and one abnormal. It determines the number of normal and abnormal kits by using the `c3_eng_number_of_normal_fit_kits` parameter from `smokescreen_properties` for the number of normal, and then the rest are marked as abnormal. | ||
|
|
||
| - **Arguments**: | ||
| - `kit_id_df` (pd.DataFrame): A `dataframe` containing fit kit IDs. | ||
| - `smokescreen_properties` (dict): A dictionary containing the number of normal and abnormal fit kits to split. | ||
|
|
||
| - **Returns**: | ||
| A tuple containing two dataframes: | ||
| - `normal_fit_kit_df` (pd.DataFrame): `dataframe` containing normal fit kits. | ||
| - `abnormal_fit_kit_df` (pd.DataFrame): `dataframe` containing abnormal fit kits. | ||
|
|
||
| ## Example Usage | ||
|
|
||
| ```python | ||
| from utils.fit_kit_logged import process_kit_data | ||
|
|
||
| def test_example_usage(smokescreen_properties: dict) -> None: | ||
| # Find data, separate it into normal and abnormal, add results to the test records in the KIT_QUEUE table (i.e. mimic receiving results from the middleware) and get device IDs and their flags. | ||
| device_ids = process_kit_data(smokescreen_properties) | ||
| # Note: In this example, all of the code below this line is for context only and uses functions from other utilities. | ||
| # Retrieve NHS numbers for each device_id and determine normal/abnormal status | ||
| nhs_numbers = [] | ||
| normal_flags = [] | ||
|
|
||
| for device_id, is_normal in device_ids: | ||
| nhs_number = update_kit_service_management_entity( | ||
| device_id, is_normal, smokescreen_properties | ||
| ) | ||
| nhs_numbers.append(nhs_number) | ||
| normal_flags.append(is_normal) # Store the flag (True for normal, False for abnormal). | ||
Andyg79 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| test_example_usage() | ||
| ``` | ||
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.