A Python-based clinical simulation environment engineered using the
customtkinterframework for the UI and thetkVideoPlayermodule for media rendering. The core operational loop initializes a stochastic patient state and requires the user to apply diagnostic protocols, maintaining an active state log of actions. It utilizes a local Large Language Model viaollamaandasyncioroutines to generate real-time patient dialog and symptom progressions.
The application dynamically injects content schemas stored in JSON format at runtime.
stateDiagram-v2
[*] --> Initialization
Initialization --> LoadJSON: Parse /content/
LoadJSON --> StochasticPatient: Instantiate Disease Vector
StochasticPatient --> UserInput: Await Action
UserInput --> ActionHistory: Update DLL
ActionHistory --> LLM: Generate Context
LLM --> StochasticPatient: Update Symptoms
StochasticPatient --> [*]: Terminal State Reached
-
Medical Schemas
drugs.json,tests.json, andimaging.jsonare loaded into memory lists during initialization. These dictionaries define the available actions, their biological identifiers, and expected impacts on the patient state variables. -
Disease Vectors
A patient profile is instantiated by reading a specific JSON file mapped to a disease ID (e.g.,content/diseases/<id>/<id>.json). This file provides the initial state variables (demographics, base symptoms) which dictate the simulation's starting parameters. -
Action History
The system writes to an action history array (shared.action_history.dll) capturing chronological interactions and evaluating them against thedll_expectedsequences to determine simulation success or failure based on the diagnostic pathway chosen.
The visual interface is rendered via customtkinter.CTk().
| Module | Purpose | Implementation Details |
|---|---|---|
| Theme Parsing | Styling | Dynamically parses custom JSON theme dictionaries (themes/<theme_name>.json), extracting primary foreground (fg_color) elements to apply structural styling. |
| Canvas Overlay | Graphics | PIL loads images, and an RGBTransform pipeline calculates pixel mixing factors to dynamically overlay colors on static assets. |
| Media Decoding | Animation | Animations corresponding to disease states are rendered via TkinterVideo. Frame timing relies on event bindings (<<Loaded>>, <<SecondChanged>>) for consistent framerates. |
The application executes asynchronous calls using the ollama.AsyncClient. Instead of static dialogue trees, the patient state variables and the recent action history are concatenated and formatted as context for a prompt pipeline. The local model computes a response reflecting the simulated physiological changes or subjective symptom reports, which is then parsed and printed to the terminal UI via colorama.
Warning
Ensure the Ollama daemon is active in the background and the necessary models are pulled locally before initiating the simulation.
-
Clone & Install Dependencies Initialize your environment and install the required packages:
pip install customtkinter tkinter tkvideoplayer Pillow ollama colorama termcolor
-
Launch the Application Execute the main simulation script:
python main.py
(Note: The
debugboolean flag inside the script can be toggled to disable the LLM initialization sequence during diagnostic testing.)
Note
No Artificial Intelligence or automated code generation tools were utilized in the programming of this project. The entire codebase, including logic, UI design, and API integration, was written manually by hand.