User Interface Backend
User Interface Backend - FastAPI interface |
FastAPI app
User Interface Backend - FastAPI interface
- class Token(**data)[source]
Bases:
BaseModelToken for accessing the UI backend service after user authentication.
-
access_token:
str
-
token_type:
str
-
access_token:
- class TokenData(**data)[source]
Bases:
BaseModelAdditional data for user access token
-
username:
Optional[str]
-
username:
- class User(**data)[source]
Bases:
BaseModelWebsite user for authentication
-
disabled:
Optional[bool]
-
email:
Optional[str]
-
full_name:
Optional[str]
-
username:
str
-
disabled:
- authenticate_user(db, username, password)[source]
Retrieve a user from the user database using username and password.
- Parameters:
db (
Dict) – User databaseusername (
str) – Usernamepassword (
str) – Plaintext password
- Return type:
Union[bool,User]
Returns: User object if username exists and password is correct, false otherwise
- create_access_token(data, expires_delta=None)[source]
Create an access token for user authentication-
- Parameters:
data (
dict) – Data encoded by the tokenexpires_delta (
Optional[timedelta]) – timedelta object specifying the expiration time (default: 15 minutes)
- Return type:
str
Returns: Access token
- async get_current_active_user(current_user=Depends(get_current_user))[source]
Ensure current user is active (non-disabled)
Returns: current_user if user is not disabled
- async get_current_user(token=Depends(OAuth2PasswordBearer))[source]
Retrieve user from database by access token.
- Parameters:
token (
str) – Access token provided by user- Return type:
Returns: User if access token is valid.
- get_password_hash(password)[source]
Hash plaintext password.
- Parameters:
password (
str) – Plaintext password- Return type:
str
Returns: Hashed password
- async get_patient_info(patient_id, recommendation_id, current_user=Depends(get_current_active_user))[source]
Get patient data of a specific patient
- Parameters:
patient_id (
str) – Patient identifierrecommendation_id (
str) – Guideline recommendation identifier.current_user (
User) – Authenticated user
- Return type:
Dict
Returns: Patient data of a specific patient.
- get_patients_from_recommendation(recommendation_id)[source]
Retrieve list of patients that were evaluated for a specific guideline recommendation.
- Parameters:
recommendation_id (
str) – Guideline recommendation identifier.- Return type:
List
Returns: List of patients
- get_recommendation_ids()[source]
Retrieve all available guideline recommendation identifier from the guideline interface.
Returns: List of available guideline recommendation identifier
- Return type:
Dict
- async get_recommendation_list(current_user=Depends(get_current_active_user))[source]
Lists identifiers of available guideline recommendations.
- Parameters:
current_user (
User) – Authenticated user- Return type:
Dict
Returns: List of available guideline recommendation identifier
- async get_recommendation_results(recommendation_id, current_user=Depends(get_current_active_user))[source]
Get results (summary + detailed) of the guideline recommendation evaluation on clinical data.
- Parameters:
recommendation_id (
str) – Guideline recommendation identifier.current_user (
User) – Authenticated user
- Return type:
Dict
Returns: Results (summary + detailed) of the guideline recommendation evaluation
- get_recommendation_results_details(recommendation_id)[source]
Retrieves the details of the guideline recommendation adherence evaluation.
The detailed results include all clinical data that was used to evaluated the guideline recommendation adherence.
- Parameters:
recommendation_id (
str) – Guideline recommendation identifier.- Return type:
DataFrame
Returns: Details of the guideline recommendation adherence evaluation.
- get_recommendation_results_summary(recommendation_id)[source]
Retrieves the summary of the guideline recommendation adherence evaluation.
The summary includes patient identifier, ward, birth date, time on ICU and whether the guideline recommendation is applicable and implemented.
- Parameters:
recommendation_id (
str) – Guideline recommendation identifier.- Return type:
DataFrame
Returns: Summary of the guideline recommendation adherence evaluation
- async get_recommendation_variable_names(recommendation_id, current_user=Depends(get_current_active_user))[source]
Lists clinical variable names required to evaluate a specific guideline recommendation.
- Parameters:
recommendation_id (
str) – Guideline recommendation identifier.current_user (
User) – Authenticated user
- Return type:
Dict
Returns: Clinical variable names
- get_recommendation_variables(recommendation_id)[source]
Retrieve the clinical variables names that are required to evaluate guideline recommendation adherence of the given recommendation.
- Parameters:
recommendation_id (
str) – Guideline recommendation identifier.- Return type:
DataFrame
Returns: List of clinical variables names
- get_user(db, username)[source]
Retrieve a user from the user database
- Parameters:
db (
Dict) – User databaseusername (
str) – Username
- Return type:
Optional[User]
Returns: User entry from user database
- async list_patient_by_recommendation(recommendation_id, current_user=Depends(get_current_active_user))[source]
List current patients for a specific guideline recommendation.
- Parameters:
recommendation_id (
str) – Guideline recommendation identifier.current_user (
User) – Authenticated user
- Return type:
List
Returns: Current patients for specific guideline recommendation.
- async list_patients(current_user=Depends(get_current_active_user))[source]
List current patients
- Parameters:
current_user (
User) – Authenticated user- Return type:
Dict
Returns: Current patients
- load_user_db()[source]
Read the user database from yaml file
Returns: User database as dictionary
- Return type:
Dict
- async login_for_access_token(form_data=Depends(OAuth2PasswordRequestForm))[source]
Login form to retrieve access token.
- Parameters:
form_data (
OAuth2PasswordRequestForm) – Formulat data with “username” and “password” fields.- Return type:
Dict
Returns: Access token if the provided username and password are valid.
- request_patient_data(patient_id, variable_name)[source]
Get clinical data for a specific patient.
- Parameters:
patient_id (
str) – Patient identifiervariable_name (
List[str]) – List of clinical variable names to return for the patients.
- Return type:
DataFrame
Returns: List of all available values for the requested variables for the specified patient.
- verify_password(plain_password, hashed_password)[source]
Verify user provided password against hashed database password.
- Parameters:
plain_password (
str) – User provided plaintext passwordhashed_password (
str) – Hashed password from user database.
- Return type:
bool
Returns: True if passwords match, False otherwise