pat2vec.pat2vec_get_methods.get_method_bmi

Functions

calculate_bmi_features(bmi_sample[, ...])

Calculate statistical features from BMI, weight, or height observations.

get_bmi_features(current_pat_client_id_code, ...)

Retrieves BMI-related features for a patient within a specified date range.

search_bmi_observations([...])

Searches for BMI-related observation data within a date range.

pat2vec.pat2vec_get_methods.get_method_bmi.search_bmi_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', additional_custom_search_string=None)[source]

Searches for BMI-related observation data within a date range.

Uses a cohort searcher to find observations related to BMI, weight, and height.

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’.

  • additional_custom_search_string (Optional[str]) – An additional string to append to the search query. Defaults to None.

Returns:

A DataFrame containing the raw BMI observation data.

Return type:

pd.DataFrame

Raises:

ValueError – If essential arguments are None.

pat2vec.pat2vec_get_methods.get_method_bmi.calculate_bmi_features(bmi_sample, term_prefix='bmi', negate_biochem=False)[source]

Calculate statistical features from BMI, weight, or height observations.

Computes mean, median, standard deviation, and other specific features based on the term prefix.

Parameters:
  • bmi_sample (pd.DataFrame) – DataFrame containing the observation data.

  • term_prefix (str) – Prefix for feature column names (e.g., ‘bmi’, ‘weight’, ‘height’). Defaults to “bmi”.

  • negate_biochem (bool) – If True, returns features with NaN values when no data is available. Defaults to False.

Returns:

A dictionary of calculated features.

Return type:

Dict[str, Union[float, int]]

pat2vec.pat2vec_get_methods.get_method_bmi.get_bmi_features(current_pat_client_id_code, target_date_range, pat_batch, config_obj=None, cohort_searcher_with_terms_and_search=None)[source]

Retrieves BMI-related features for a patient within a specified date range.

This function fetches BMI, weight, and height data, either from a pre-loaded batch or by searching, and then calculates statistical features for each.

Parameters:
  • current_pat_client_id_code (str) – The client ID code of the patient.

  • target_date_range (Tuple[int, int, int, int, int, int]) – 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 BMI-related features for the

specified patient.

Return type:

pd.DataFrame