guideexamples.pathway.simple_cli
This Example demonstrates interaction with the Pathway, Patient, Care Team, and Worklist APIs.
The CLI utilizes the requests library to make HTTP requests to the Carium API.
The CLI is organized into classes for each API, with a main class to run the CLI.
Main functionality demonstrated includes:
Functionality |
Description |
---|---|
Login to the Carium API |
Authenticates the user to the Carium API. |
Get organization ID |
Retrieves and displays the organization ID. |
Show pathways |
Displays information about available pathways. |
Enroll patient |
Enrolls a patient in a pathway. |
Show patients |
Displays information about patients. |
Show care team |
Displays information about the care team. |
Show worklist |
Displays information about the worklist. |
Complete worklist |
Marks the worklist item as completed. |
Update worklist |
Updates worklist details (due date, assignment to care team, completion). |
To run the CLI, execute the following command:
# run the CLI
python guideexamples/pathway/simple_cli.py
Functions
|
Main function to run the Simple CLI |
Classes
|
A class to wrap python requests method to include Carium API headers. |
|
A class to interact with the Care Team API |
|
A class to interact with the Organization API |
|
A class to interact with the Pathway API |
|
A class to interact with the Patient API |
A simple CLI to interact with the Carium API |
|
|
A class to interact with the Worklist API |
- class Api(cli: SimpleCli)[source]
A class to wrap python requests method to include Carium API headers. It also includes a method to login to the API
- Parameters:
cli (SimpleCli) –
- get(url: str, params: dict) Response [source]
Make a GET request to the API
- Parameters:
url (str) – str: http url for the GET API
params (dict) – dict: query parameters for the GET API
- Returns:
The response from the GET request
- Return type:
Response
- list_with_paging(url: str, params: dict, limit: int | None = None) Generator[list[dict], None, None] [source]
Get data from the API with paging, prompt the user to page more data if available
- Parameters:
url (str) – str: http url for the GET API
params (dict) – dict: query parameters for the GET API
limit (int | None) – Optional[int]: maxium number of records to return in a single request
- Returns:
A generator of list of dict results from the GET API
- Return type:
Generator[list[dict], None, None]
- class CareTeam(cli: SimpleCli)[source]
A class to interact with the Care Team API
- Parameters:
cli (SimpleCli) –
Print the care team menu and return the user’s choice
- Returns:
The user’s choice
- Return type:
str
- class Organization(cli: SimpleCli)[source]
A class to interact with the Organization API
- Parameters:
cli (SimpleCli) –
- class Pathway(cli: SimpleCli)[source]
A class to interact with the Pathway API
- Parameters:
cli (SimpleCli) –
- enroll_patient()[source]
Enroll a patient in a pathway
- Steps:
Prompt the user for the pathway version ID.
Get the stages for the pathway version.
Prompt the user to choose a stage to enroll the patient.
Enroll the patient in the chosen stage
Print the pathway menu and return the user’s choice
- Returns:
The user’s choice
- Return type:
str
- class Patient(cli: SimpleCli)[source]
A class to interact with the Patient API
- Parameters:
cli (SimpleCli) –
Print the patient menu and return the user’s choice
- Returns:
The user’s choice
- Return type:
str
- class SimpleCli[source]
A simple CLI to interact with the Carium API
- classmethod create_table(fields: list[str]) PrettyTable [source]
Create a table with the given fields, will append an ‘Index’ to column field headers
- Parameters:
fields (list[str]) – list[str]: List of column names for the table
- Returns:
An instance of the PrettyTable class.
- Return type:
PrettyTable
Print the main menu and return the user’s choice
- Return type:
str
- classmethod print_table(table: PrettyTable, data: Generator[list[dict], None, None], data_fields: list[str], mapper: Callable)[source]
Print the table with the data, using the mapper to map the data to the fields
- Parameters:
table (PrettyTable) – PrettyTable: table with the column headers
data (Generator[list[dict], None, None]) – Generator[list[dict], None, None]: List of dict results from the GET API
data_fields (list[str]) – list[str]: response attribute names in the same order as the create_table fields
mapper (Callable) – Callable: function to map the API response data to the fields
- class Worklist(cli: SimpleCli)[source]
A class to interact with the Worklist API
- Parameters:
cli (SimpleCli) –
- assign_to_care_team(worklist_id: str)[source]
Assign a worklist entry to a care team
- Steps:
Prompt the user for the care team ID
Assign the worklist entry to the care team
- Parameters:
worklist_id (str) – str: worklist ID to update
- complete_worklist()[source]
Complete a worklist entry
- Steps:
Prompt the user for the worklist ID to complete
Mark the worklist as completed
Print the worklist menu and return the user’s choice
- Return type:
str
- show_worklist()[source]
Show the worklist in the organization
Displays the worklist ID, text, created-at, done, care-team, care-team-id, assigned-at, and due-time.
- update_due_time(worklist_id: str)[source]
Update the due date of a worklist entry
- Steps:
Prompt the user for the due date
Update the due date of the worklist entry
- Parameters:
worklist_id (str) – str: worklist ID to update