ai_cdss.DataLoader#

class ai_cdss.DataLoader(rgs_mode='plus')[source]#

Loads data from database and CSV files for the Clinical Decision Support System.

Args:

rgs_mode (str, optional): Mode for fetching RGS data. Default is “plus”.

Methods

fetch_and_validate_patients(study_ids)

Fetch patient data for the given study IDs and validate that patients exist.

load_patient_data(patient_list)

Load all data specific to a patient clinical trial.

load_patient_subscales(patient_list)

Load and decode patient clinical scale data for the given patient list.

load_ppf_data(patient_list)

Load PPF (precomputed patient-protocol fit) data from internal storage.

load_protocol_attributes([file_path])

Load protocol attributes from internal storage or a specified file path.

load_protocol_similarity()

Load protocol similarity data from internal storage.

load_session_data(patient_list)

Load session data from the RGS interface.

load_timeseries_data(patient_list)

Load timeseries data for the given patient list.

load_patient_data(patient_list)[source]#

Load all data specific to a patient clinical trial.

Return type:

Union[DataFrame, DataUnit]

Args:

patient_list (List[int]): List of patient IDs.

Returns:

Union[pd.DataFrame, DataUnit]: Patient data as a DataFrame or DataUnit.

load_session_data(patient_list)[source]#

Load session data from the RGS interface.

Return type:

Union[DataFrame, DataUnit]

Args:

patient_list (List[int]): List of patient IDs.

Returns:

Union[pd.DataFrame, DataUnit]: Session data as a DataFrame or DataUnit.

load_timeseries_data(patient_list)[source]#

Load timeseries data for the given patient list.

Return type:

Union[DataFrame, DataUnit]

Args:

patient_list (List[int]): List of patient IDs.

Returns:

Union[pd.DataFrame, DataUnit]: Timeseries data as a DataFrame or DataUnit.

load_ppf_data(patient_list)[source]#

Load PPF (precomputed patient-protocol fit) data from internal storage.

Return type:

Union[DataFrame, DataUnit]

Args:

patient_list (List[int]): List of patient IDs.

Returns:

Union[pd.DataFrame, DataUnit]: PPF data as a DataFrame or DataUnit.

load_patient_subscales(patient_list)[source]#

Load and decode patient clinical scale data for the given patient list.

Return type:

Union[DataFrame, DataUnit]

Args:

patient_list (List[int]): List of patient IDs.

Returns:

Union[pd.DataFrame, DataUnit]: Decoded patient scale data indexed by PATIENT_ID.

load_protocol_attributes(file_path=None)[source]#

Load protocol attributes from internal storage or a specified file path.

Args:

file_path (str, optional): Path to the protocol attributes file.

Returns:

pd.DataFrame: Protocol attributes data.

load_protocol_similarity()[source]#

Load protocol similarity data from internal storage.

Returns:

pd.DataFrame: Protocol similarity data with columns: PROTOCOL_ID_1, PROTOCOL_ID_2, SIMILARITY_SCORE.

fetch_and_validate_patients(study_ids)[source]#

Fetch patient data for the given study IDs and validate that patients exist.

Return type:

List[int]

Args:

study_ids (List[int]): List of study cohort identifiers to fetch patients for.

Returns:

List[int]: List of patient IDs associated with the provided study IDs.

Raises:

ValueError: If no patients are found for the given study IDs.