pat2vec.pat2vec_get_methods.get_method_covid
Functions
|
Generates a binary feature for COVID-19 test results. |
|
Retrieves COVID-19 test features for a patient within a date range. |
|
Searches for COVID-19 test observations. |
- pat2vec.pat2vec_get_methods.get_method_covid.search_covid(cohort_searcher_with_terms_and_search=None, client_id_codes=None, observations_time_field='basicobs_entered', 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='basic_observations', output_filename='covid_search_results.csv', overwrite=False, config_obj=None)[source]
Searches for COVID-19 test observations.
- 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 ‘basicobs_entered’.
fields_override (Optional[List[str]]) – A list of fields to override the default COVID_FIELDS. Defaults to None.
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.
client_idcode_term_name (str) – The name of the client ID code field in the index. Defaults to “client_idcode.keyword”.
index_name (str) – The name of the Elasticsearch index to search. Defaults to “basic_observations”.
output_filename (Optional[str]) – The filename or path to a CSV file to load from or save to. Defaults to “covid_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.
- Returns:
A DataFrame containing the raw COVID-19 test observation 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_covid.calculate_covid_features(features_data, current_pat_client_id_code, negate_biochem=False)[source]
Generates a binary feature for COVID-19 test results.
Creates a binary flag covid_positive which is 1 if any ‘positive’ result is found, 0 if only ‘negative’ results are found, and NaN if no results are found (or 0 if negate_biochem is True).
- Parameters:
features_data (pd.DataFrame) – The prepared COVID-19 test data.
current_pat_client_id_code (str) – The patient’s client ID.
negate_biochem (bool) – If True, returns 0 when no data is available. Defaults to False.
- Returns:
A single-row DataFrame with the covid_positive feature.
- Return type:
pd.DataFrame
- pat2vec.pat2vec_get_methods.get_method_covid.get_covid(current_pat_client_id_code, target_date_range, pat_batch, config_obj=None, cohort_searcher_with_terms_and_search=None)[source]
Retrieves COVID-19 test features for a patient within a date range.
- 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. Defaults to None.
cohort_searcher_with_terms_and_search (Optional[Callable]) – The function for cohort searching. Defaults to None.
- Returns:
A DataFrame containing the COVID-19 test feature for the patient.
- Return type:
pd.DataFrame