|
| 1 | +# Utility Guide: Fit Kit Logged Utility |
| 2 | + |
| 3 | +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'). |
| 4 | + |
| 5 | +## Table of Contents |
| 6 | + |
| 7 | +- [Utility Guide: Fit Kit Logged Utility](#utility-guide-fit-kit-logged-utility) |
| 8 | + - [Table of Contents](#table-of-contents) |
| 9 | + - [Using the Fit Kit Logged Utility](#using-the-fit-kit-logged-utility) |
| 10 | + - [Required Arguments](#required-arguments) |
| 11 | + - [Fit Kit Logged Specific Functions](#fit-kit-logged-specific-functions) |
| 12 | + - [Example Usage](#example-usage) |
| 13 | + |
| 14 | +## Using the Fit Kit Logged Utility |
| 15 | + |
| 16 | +To use the Fit Kit Logged Utility, import the `fit_kit_logged.py` module, from the `utils` directory, into your test file and call its methods as required. |
| 17 | + |
| 18 | +## Required Arguments |
| 19 | + |
| 20 | +The methods in this utility require specific arguments. Below is a summary of the required arguments for key methods: |
| 21 | + |
| 22 | +- `process_kit_data`: Requires `smokescreen_properties`(dict) |
| 23 | +- `split_fit_kits`: Requires `kit_id_df`(pd.DataFrame), `smokescreen_properties`(dict) |
| 24 | + |
| 25 | +## Fit Kit Logged Specific Functions |
| 26 | + |
| 27 | +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 the key functions: |
| 28 | + |
| 29 | +1. **`process_kit_data(smokescreen_properties: dict) -> list`** |
| 30 | + Retrieves the test data needed for compartment 3 and then splits it into two data frames, using the `split_fit_kits` method. |
| 31 | + - **Arguments**: |
| 32 | + - `smokescreen_properties` (dict): A dictionary containing properties required to retrieve and process kit data. |
| 33 | + - **Returns**: A list of tuples where each tuple contains a device ID (str) and a boolean flag (True for normal, False for abnormal). |
| 34 | + |
| 35 | +2. **`split_fit_kits(kit_id_df: pd.DataFrame, smokescreen_properties: dict) -> pd.DataFrame`** |
| 36 | + This method splits the dataframe into two dataframes, 1 normal and 1 abnormal. |
| 37 | + - **Arguments**: |
| 38 | + - `kit_id_df` (pd.DataFrame): A dataframe containing fit kit IDs. |
| 39 | + - `smokescreen_properties` (dict): A dictionary containing the number of normal and abnormal fit kits to split. |
| 40 | + - **Returns**: A tuple containing two dataframes: |
| 41 | + - normal_fit_kit_df (pd.DataFrame): Dataframe containing normal fit kits. |
| 42 | + - abnormal_fit_kit_df (pd.DataFrame): Dataframe containing abnormal fit kits. |
| 43 | + |
| 44 | +## Example Usage |
| 45 | + |
| 46 | +```python |
| 47 | +from utils.fit_kit_logged import process_kit_data |
| 48 | + |
| 49 | +def example_usage() -> None: |
| 50 | + # 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) |
| 51 | + # and get device IDs and their flags |
| 52 | + device_ids = process_kit_data(smokescreen_properties) |
| 53 | + # Retrieve NHS numbers for each device_id and determine normal/abnormal status |
| 54 | + nhs_numbers = [] |
| 55 | + normal_flags = [] |
| 56 | + |
| 57 | + for device_id, is_normal in device_ids: |
| 58 | + nhs_number = update_kit_service_management_entity( |
| 59 | + device_id, is_normal, smokescreen_properties |
| 60 | + ) |
| 61 | + nhs_numbers.append(nhs_number) |
| 62 | + normal_flags.append(is_normal) # Store the flag (True for normal, False for abnormal) |
| 63 | + |
| 64 | +example_usage() |
| 65 | +``` |
0 commit comments