pat2vec.pat2vec_get_methods.get_method_core02
Functions
|
Calculates O2 saturation features from CORE_SpO2 observations. |
|
Cleans an observation value to be used as a feature name. |
|
Retrieves CORE_SpO2 features for a patient within a date range. |
|
Searches for CORE_SpO2 observation data within a date range. |
- pat2vec.pat2vec_get_methods.get_method_core02.search_core_o2_observations(cohort_searcher_with_terms_and_search=None, client_id_codes=None, observations_time_field='observationdocument_recordeddtm', start_year='1995', start_month='01', start_day='01', end_year='2025', end_month='12', end_day='12', search_term='CORE_SpO2', additional_custom_search_string=None)[source]
Searches for CORE_SpO2 observation data within a date range.
Uses a cohort searcher to find CORE_SpO2 observation data for specified patients within a given date range.
- 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.
observations_time_field (str) – The timestamp field for filtering observations. Defaults to ‘observationdocument_recordeddtm’.
start_year (str) – Start year for the search. Defaults to ‘1995’.
start_month (str) – Start month for the search. Defaults to ‘01’.
start_day (str) – Start day for the search. Defaults to ‘01’.
end_year (str) – End year for the search. Defaults to ‘2025’.
end_month (str) – End month for the search. Defaults to ‘12’.
end_day (str) – End day for the search. Defaults to ‘12’.
search_term (str) – The observation type to search for. Defaults to “CORE_SpO2”.
additional_custom_search_string (Optional[str]) – An additional string to append to the search query. Defaults to None.
- Returns:
A DataFrame containing the raw CORE_SpO2 observation data.
- Return type:
pd.DataFrame
- Raises:
ValueError – If essential arguments are None.
- pat2vec.pat2vec_get_methods.get_method_core02.clean_observation_value(value)[source]
Cleans an observation value to be used as a feature name.
Replaces characters that are invalid in column names.
- Parameters:
value (str) – The original observation value.
- Returns:
- The cleaned value suitable for use as a column name,
or None if the input is NaN.
- Return type:
Optional[str]
- pat2vec.pat2vec_get_methods.get_method_core02.calculate_core_o2_features(features_data, search_term='CORE_SpO2')[source]
Calculates O2 saturation features from CORE_SpO2 observations.
Creates binary features for each unique observation value found in the data.
- Parameters:
features_data (pd.DataFrame) – DataFrame containing CORE_SpO2 observations.
search_term (str) – The observation type being processed. Defaults to “CORE_SpO2”.
- Returns:
A dictionary of calculated binary features.
- Return type:
Dict[str, int]
- pat2vec.pat2vec_get_methods.get_method_core02.get_core_02(current_pat_client_id_code, target_date_range, pat_batch, config_obj=None, cohort_searcher_with_terms_and_search=None)[source]
Retrieves CORE_SpO2 features for a patient within a date range.
This function fetches CORE_SpO2 (oxygen saturation) data, either from a pre-loaded batch or by searching, and then creates binary features for each unique observation value.
- 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.
config_obj (Optional[object]) – Configuration object containing batch_mode and other settings. Defaults to None.
cohort_searcher_with_terms_and_search (Optional[Callable]) – The function for cohort searching. Defaults to None.
- Returns:
- A DataFrame containing CORE_SpO2 features for the
specified patient. If no data is found, a DataFrame with only the ‘client_idcode’ is returned.
- Return type:
pd.DataFrame
- Raises:
ValueError – If config_obj is None, or if cohort_searcher_with_terms_and_search is None when not in batch mode.