pat2vec.pat2vec_get_methods.get_method_bloods
Functions
|
Retrieves and engineers features from blood test data for a patient. |
|
Searches for bloods data for patients within a date range. |
- pat2vec.pat2vec_get_methods.get_method_bloods.search_bloods_data(cohort_searcher_with_terms_and_search=None, client_id_codes=None, client_idcode_name='client_idcode.keyword', bloods_time_field='basicobs_entered', start_year=1995, start_month=1, start_day=1, end_year=2025, end_month=12, end_day=12, additional_custom_search_string=None)[source]
Searches for bloods data for patients within a date range.
Uses a cohort searcher to find basic observation data that has a numeric value, within a specified time window.
- Parameters:
cohort_searcher_with_terms_and_search (Optional[Callable]) – The function for cohort searching. Defaults to None.
client_id_codes (Optional[Union[str, List[str]]]) – The client ID code(s) of the patient(s). Defaults to None.
client_idcode_name (str) – The name of the client ID code field in the index. Defaults to “client_idcode.keyword”.
bloods_time_field (str) – The timestamp field for filtering bloods data. Defaults to ‘basicobs_entered’.
start_year (Union[int, str]) – Start year for the search. Defaults to 1995.
start_month (Union[int, str]) – Start month for the search. Defaults to 1.
start_day (Union[int, str]) – Start day for the search. Defaults to 1.
end_year (Union[int, str]) – End year for the search. Defaults to 2025.
end_month (Union[int, str]) – End month for the search. Defaults to 12.
end_day (Union[int, str]) – End day for the search. Defaults to 12.
additional_custom_search_string (Optional[str]) – An additional string to append to the search query. Defaults to None.
- Returns:
A DataFrame containing the raw bloods data.
- Return type:
pd.DataFrame
- Raises:
ValueError – If cohort_searcher_with_terms_and_search or client_id_codes is None.
- pat2vec.pat2vec_get_methods.get_method_bloods.get_current_pat_bloods(current_pat_client_id_code, target_date_range, pat_batch, batch_mode=False, cohort_searcher_with_terms_and_search=None, config_obj=None)[source]
Retrieves and engineers features from blood test data for a patient.
This function fetches blood test data for a patient within a specified date range, either from a pre-loaded batch or by searching. It then calculates a wide range of statistical features for each type of blood test found, such as mean, median, standard deviation, counts, and time-based features.
- Parameters:
current_pat_client_id_code (str) – The client ID code of the patient.
target_date_range (Tuple) – A tuple representing the target date range.
pat_batch (pd.DataFrame) – The DataFrame containing patient data for batch mode.
batch_mode (bool) – Indicates if batch mode is enabled. This is controlled by config_obj.batch_mode. Defaults to False.
cohort_searcher_with_terms_and_search (Optional[Callable]) – The function for cohort searching. Defaults to None.
config_obj (Optional[object]) – Configuration object with settings like batch_mode and bloods_time_field. Defaults to None.
- Returns:
- A DataFrame containing the calculated blood test features
for the specified patient.
- Return type:
pd.DataFrame