🤖 AI Features

Using the AI Treatment Plan Generator and AI Chat Assistant.

Overview

HealthCIP integrates AI at two key points to reduce doctors' administrative burden while maintaining clinical accuracy:

  1. AI Treatment Plan Generator — Automatically generates treatment plans from diagnosis and symptoms, grounded in your actual pharmacy inventory
  2. AI Chat Assistant — A conversational interface for clinical queries with contextual memory

Note: AI features are available in the Professional and Enterprise plans. You'll need an OpenAI or Deepseek API key configured by your system administrator.

AI Treatment Plan Generator

How It Works

The AI Treatment Plan Generator uses a two-stage pipeline that's both powerful and cost-efficient:

Stage 1: LLM Suggestion (Cheap)

The AI receives only the patient's diagnosis and symptoms — no master data lists, no large context. It returns a conceptual treatment plan using generic medicine names (e.g., "Paracetamol 500mg tablet"). This prompt is tiny (~100 tokens), keeping API costs near zero.

Stage 2: BM25 Grounding (Zero Tokens)

The generic suggestions from Stage 1 are matched against your actual master data using BM25 text search — the same algorithm used in search engines. This maps generic medicine names to real products in your pharmacy, complete with their actual database IDs. This stage uses zero LLM tokens.

How to Use

  1. Start a consultation from the Doctor's appointment list
  2. Record symptoms from the symptom master list
  3. Enter the diagnosis/inference in the clinical notes
  4. Click the AI Treatment Plan button
  5. Optionally add Doctor's Notes/Preferences — the AI will prioritize these (e.g., "Prefer generic brands" or "Avoid NSAIDs")
  6. The AI returns a complete treatment plan with medicines, dosages, intervals, and durations
  7. Review the plan — each item is already linked to your master data
  8. Edit, add, or remove items as needed
  9. Save the treatment plan to the patient's record

Pro tip: The AI respects your doctor's notes. If you write "Patient has a history of gastric issues — avoid aspirin," the treatment plan will reflect this preference.

Sample AI Treatment Plan Output

After entering "Acute sinusitis with fever and headache" as the diagnosis, the AI might return:

MedicineDosageIntervalDurationTiming
Amoxicillin 500mg capsule500mg1-0-17 DaysAFTER_MEAL
Paracetamol 500mg tablet500mg1-1-13 DaysAFTER_MEAL
Cetirizine 10mg tablet10mg0-0-17 DaysBEFORE_MEAL

Each medicine is already matched to your actual inventory — the doctor just reviews and approves.

Technical Details

The AI service is powered by Spring AI and supports multiple LLM providers:

AI Chat Assistant

How to Use

  1. Log in as a Doctor
  2. Navigate to Doctor > Chat
  3. Type your clinical question in the chat input
  4. The AI responds with contextual information
  5. The conversation maintains context — you can ask follow-up questions

Chat Features

Important clinical disclaimer: AI-generated treatment plans and chat responses are suggestions only. All clinical decisions must be reviewed and approved by a qualified medical professional. HealthCIP and LogicSoft Computers are not responsible for clinical outcomes resulting from AI-generated suggestions.

Configuration

To enable AI features, your administrator needs to configure the following in application.properties:

# LLM Provider Configuration
llm.api-key=your-api-key-here
llm.api-url=https://api.deepseek.com/v1/chat/completions
llm.model=deepseek-v4-flash

# OpenAI alternative (uses Spring AI auto-configuration)
# spring.ai.openai.api-key=your-openai-key
# spring.ai.openai.chat.model=gpt-4

The AI also uses Spring AI's ChatClient with MessageChatMemoryAdvisor for chat memory management.

Files Reference

FilePurpose
AiService.javaInterface for AI chat service
OpenAiServiceImpl.javaOpenAI/Spring AI chat implementation
AiTreatmentPlanService.javaTwo-stage treatment plan generator (LLM + BM25)
AiInferenceService.javaAI inference for diagnosis support
AiInvestigationService.javaAI-assisted investigation suggestions
Bm25Matcher.javaBM25 text search algorithm for master data grounding