pat2vec.pat2vec_get_methods.get_method_news

Functions

compute_feature_stats(data, column, ...)

Computes summary statistics for a feature column in the NEWS dataset.

get_news(current_pat_client_id_code, ...[, ...])

Retrieves NEWS/NEWS2 features for a patient within a date range.

search_news_observations([...])

Searches for NEWS/NEWS2 observation data within a date range.

pat2vec.pat2vec_get_methods.get_method_news.compute_feature_stats(data, column, feature_name, config_obj)[source]

Computes summary statistics for a feature column in the NEWS dataset.

Parameters:
  • data (pd.DataFrame) – Subset of patient data for the feature.

  • column (str) – Column to compute stats from (e.g., ‘observation_valuetext_analysed’).

  • feature_name (str) – Base name for the output feature columns.

  • config_obj (object) – Configuration object with negate_biochem attribute.

Returns:

A dictionary of calculated feature statistics (mean, median, std,

max, min, n).

Return type:

Dict

pat2vec.pat2vec_get_methods.get_method_news.search_news_observations(cohort_searcher_with_terms_and_search=None, client_id_codes=None, observations_time_field='observationdocument_recordeddtm', fields_override=None, start_year='1995', start_month='01', start_day='01', end_year='2025', end_month='12', end_day='12', additional_custom_search_string=None, index_name='observations', output_filename='news_search_results.csv', overwrite=False, config_obj=None)[source]

Searches for NEWS/NEWS2 observation data within a date range.

Parameters:
  • output_filename (Optional[str]) – The filename or path to a CSV file to load from or save to. Defaults to “news_search_results.csv”.

  • overwrite (bool) – If True, perform the search even if output_filename exists. Defaults to False.

  • config_obj (Optional[object]) – Configuration object containing root_path. Defaults to None.

  • fields_override (List[str] | None)

  • index_name (str)

pat2vec.pat2vec_get_methods.get_method_news.get_news(current_pat_client_id_code, target_date_range, pat_batch, config_obj=None, cohort_searcher_with_terms_and_search=None, fields_override=None)[source]

Retrieves NEWS/NEWS2 features for a patient within a date range.

This function fetches NEWS (National Early Warning Score) observation data, either from a pre-loaded batch or by searching. It then calculates summary statistics (mean, median, std, etc.) for each component of the NEWS score.

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 with settings like batch_mode and client_idcode_term_name. Defaults to None.

  • cohort_searcher_with_terms_and_search (Optional[Callable]) – The function for cohort searching. Defaults to None.

  • fields_override (Optional[List[str]]) – A list of fields to override the default search fields. Defaults to None.

Returns:

A DataFrame containing NEWS features for the specified patient.

Return type:

pd.DataFrame