Skip to content

Commit 061ebd9

Browse files
committed
wip - updated docstrings and added markdown
1 parent 8044806 commit 061ebd9

File tree

2 files changed

+86
-3
lines changed

2 files changed

+86
-3
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
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+
```

utils/fit_kit_logged.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from oracle.oracle import OracleDB
21
from oracle.oracle_specific_functions import get_kit_id_logged_from_db
32
import pandas as pd
43
import logging
@@ -7,11 +6,17 @@
76

87
def process_kit_data(smokescreen_properties: dict) -> list:
98
"""
10-
This method retrieved the test data needed for compartment 3 and then splits it into two data frames:
9+
This method retrieves the test data needed for compartment 3 and then splits it into two data frames:
1110
- 1 normal
1211
- 1 abnormal
12+
1313
Once the dataframe is split in two it then creates two lists, one for normal and one for abnormal
1414
Each list will either have true or false appended depending on if it is normal or abnormal
15+
Args:
16+
smokescreen_properties (dict): A dictionary containing properties required to retrieve and process kit data.
17+
18+
Returns:
19+
list: A list of tuples where each tuple contains a device ID (str) and a boolean flag (True for normal, False for abnormal).
1520
"""
1621
# Get test data for compartment 3
1722
kit_id_df = get_kit_id_logged_from_db(smokescreen_properties)
@@ -48,9 +53,22 @@ def process_kit_data(smokescreen_properties: dict) -> list:
4853
return device_ids
4954

5055

51-
def split_fit_kits(kit_id_df: pd.DataFrame, smokescreen_properties: dict) -> pd.DataFrame:
56+
def split_fit_kits(
57+
kit_id_df: pd.DataFrame, smokescreen_properties: dict
58+
) -> pd.DataFrame:
5259
"""
5360
This method splits the dataframe into two, 1 normal and 1 abnormal
61+
Args:
62+
kit_id_df (pd.DataFrame): A dataframe containing fit kit IDs.
63+
smokescreen_properties (dict): A dictionary containing the number of normal and
64+
abnormal fit kits to split. It should include the keys:
65+
- "c3_eng_number_of_normal_fit_kits" (str): Number of normal fit kits.
66+
- "c3_eng_number_of_abnormal_fit_kits" (str): Number of abnormal fit kits.
67+
68+
Returns:
69+
tuple: A tuple containing two dataframes:
70+
- normal_fit_kit_df (pd.DataFrame): Dataframe containing normal fit kits.
71+
- abnormal_fit_kit_df (pd.DataFrame): Dataframe containing abnormal fit kits.
5472
"""
5573
number_of_normal = int(smokescreen_properties["c3_eng_number_of_normal_fit_kits"])
5674
number_of_abnormal = int(

0 commit comments

Comments
 (0)