Skip to content

Naresh-x86/CliniSim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CliniSim

A Python-based clinical simulation environment engineered using the customtkinter framework for the UI and the tkVideoPlayer module 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 via ollama and asyncio routines to generate real-time patient dialog and symptom progressions.


Data Structures and Content Loading

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
Loading

  • Medical Schemas
    drugs.json, tests.json, and imaging.json are 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 the dll_expected sequences to determine simulation success or failure based on the diagnostic pathway chosen.

UI Engine and Theming

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.

LLM Integration

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.


Setup & Run Instructions

Warning

Ensure the Ollama daemon is active in the background and the necessary models are pulled locally before initiating the simulation.

  1. Clone & Install Dependencies Initialize your environment and install the required packages:

    pip install customtkinter tkinter tkvideoplayer Pillow ollama colorama termcolor
  2. Launch the Application Execute the main simulation script:

    python main.py

    (Note: The debug boolean 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.

About

A Python-based clinical simulation environment. Operational loop initializes a stochastic patient state and requires the user to apply diagnostic protocols. It utilizes a local LLM via ollama & asyncio routines to generate real-time patient dialog & symptom progression.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages