pat2vec.pat2vec_get_methods.get_method_appointments
Functions
|
Retrieves pims_apps features for a given patient within a date range. |
|
Searches for appointment data for a specific patient within a date range. |
- pat2vec.pat2vec_get_methods.get_method_appointments.search_appointments(cohort_searcher_with_terms_and_search=None, client_id_codes=None, appointments_time_field='AppointmentDateTime', 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='pims_apps*', term_name='HospitalID.keyword', output_filename='appointments_search_results.csv', overwrite=False, config_obj=None)[source]
Searches for appointment data for a specific patient within a date range.
Uses a cohort searcher to find appointment data. If output_filename is provided, the function will attempt to load existing data from disk or save the search results to disk.
- 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.
appointments_time_field (str) – The timestamp field for filtering appointments. Defaults to ‘AppointmentDateTime’.
fields_override (Optional[List[str]]) – A list of fields to override the default APPOINTMENT_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.
index_name (str) – The name of the Elasticsearch index to search. Defaults to “pims_apps*”.
term_name (str) – The field to filter on for the client_id_codes. Defaults to “HospitalID.keyword”.
output_filename (Optional[str]) – The filename or path to a CSV file to load from or save to. Defaults to “appointments_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 appointment data.
- Return type:
pd.DataFrame
- pat2vec.pat2vec_get_methods.get_method_appointments.get_appointments(current_pat_client_id_code, target_date_range, pat_batch, config_obj=None, cohort_searcher_with_terms_and_search=None)[source]
Retrieves pims_apps features for a given patient within a date range.
This function retrieves appointment data, either from a pre-loaded batch DataFrame or by searching, and then processes it to create one-hot encoded features for consultant, clinic, and appointment type.
- 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 pims_apps features for the
specified patient. If no data is found, a DataFrame with only the ‘client_idcode’ is returned.
- Return type:
pd.DataFrame