pat2vec.pat2vec_get_methods.get_method_hosp_site๏ƒ

Functions

calculate_hospital_site_features(...[,ย ...])

Generate binary hospital site features from observation values.

get_hosp_site(current_pat_client_id_code,ย ...)

Retrieves CORE_HospitalSite features for a patient within a date range.

prepare_hospital_site_data(raw_data)

Filter to valid CORE_HospitalSite records and drop NAs.

search_hospital_site([...])

Search hospital site observations via cohort search API.

pat2vec.pat2vec_get_methods.get_method_hosp_site.search_hospital_site(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, client_idcode_term_name='client_idcode.keyword', index_name='observations', output_filename='hosp_site_search_results.csv', overwrite=False, config_obj=None)[source]๏ƒ

Search hospital site observations via cohort search API.

Parameters:
  • fields_override (Optional[List[str]]) โ€“ A list of fields to override the default HOSP_SITE_FIELDS. Defaults to None.

  • index_name (str) โ€“ The name of the Elasticsearch index to search. Defaults to โ€œobservationsโ€.

  • output_filename (Optional[str]) โ€“ The filename or path to a CSV file to load from or save to. Defaults to โ€œhosp_site_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.

pat2vec.pat2vec_get_methods.get_method_hosp_site.prepare_hospital_site_data(raw_data)[source]๏ƒ

Filter to valid CORE_HospitalSite records and drop NAs.

pat2vec.pat2vec_get_methods.get_method_hosp_site.calculate_hospital_site_features(features_data, current_pat_client_id_code, negate_biochem=False)[source]๏ƒ

Generate binary hospital site features from observation values.

pat2vec.pat2vec_get_methods.get_method_hosp_site.get_hosp_site(current_pat_client_id_code, target_date_range, pat_batch, config_obj=None, cohort_searcher_with_terms_and_search=None)[source]๏ƒ

Retrieves CORE_HospitalSite features for a patient within a date range.

This function fetches hospital site observation data, either from a pre-loaded batch or by searching, and then creates binary features indicating the presence of records from specific hospital sites.

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 negate_biochem. Defaults to None.

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

Returns:

A DataFrame containing hospital site features for the patient.

Return type:

pd.DataFrame