import React, { useState, useRef } from 'react'; import { ClipboardList, PlusCircle, MessageCircle, Info, Mail, Award, Stethoscope, Search, X, Send, Upload, User, Clock, Phone, AlertCircle } from 'lucide-react'; export default function App() { const [activeTab, setActiveTab] = useState('dashboard'); const [patients, setPatients] = useState([ { id: 'P-001', name: 'John Doe', age: 32, symptoms: 'Fever', status: 'Infected', note: 'High parasitemia detected in peripheral blood smear.' }, ]); const [showModal, setShowModal] = useState(false); const [isAnalyzing, setIsAnalyzing] = useState(false); const [patientInfo, setPatientInfo] = useState({ name: '', age: '', symptoms: '' }); const [selectedFile, setSelectedFile] = useState(null); const [scanResult, setScanResult] = useState(null); const [messages, setMessages] = useState([ { sender: 'doctor', text: 'Hello! I am your AI clinical assistant. How can I assist you with your screening or research questions today?' } ]); const [inputValue, setInputValue] = useState(''); const [isTyping, setIsTyping] = useState(false); const fileInputRef = useRef(null); const handleScan = () => { setIsAnalyzing(true); // Simulate clinical reasoning setTimeout(() => { const isPositive = Math.random() > 0.4; const result = { status: isPositive ? 'Infected' : 'Uninfected', note: isPositive ? 'Analysis detected distinct ring-stage trophozoites and elevated parasitemia levels in the 40x magnified sample.' : 'Negative for Plasmodium species. Normal hematological morphology observed.' }; setScanResult(result); setPatients(prev => [{ id: `P-${Math.floor(Math.random()*900)}`, ...patientInfo, ...result }, ...prev]); setIsAnalyzing(false); }, 2500); }; const handleSendMessage = async () => { if (!inputValue.trim()) return; const userMessage = inputValue; setMessages(prev => [...prev, { sender: 'user', text: userMessage }]); setInputValue(''); setIsTyping(true); try { const systemPrompt = "You are a highly professional virtual clinical assistant for a Malaria Clinic. Provide accurate, evidence-based, and concise medical information."; const apiUrl = `https://generativelanguage.googleapis.com/v1beta/models/gemini-3-flash-preview:generateContent`; const payload = { contents: [{ parts: [{ text: userMessage }] }], tools: [{ "google_search": {} }], systemInstruction: { parts: [{ text: systemPrompt }] } }; const response = await fetch(apiUrl, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(payload) }); const result = await response.json(); const candidate = result.candidates?.[0]; let assistantText = "I'm sorry, I couldn't process that query right now."; let sources = []; if (candidate && candidate.content?.parts?.[0]?.text) { assistantText = candidate.content.parts[0].text; if (candidate.groundingMetadata?.groundingAttributions) { sources = candidate.groundingMetadata.groundingAttributions .map(attr => ({ uri: attr.web?.uri, title: attr.web?.title })) .filter(s => s.uri && s.title); } } setMessages(prev => [...prev, { sender: 'doctor', text: assistantText, sources }]); } catch (error) { setMessages(prev => [...prev, { sender: 'doctor', text: "I encountered an error while searching for that information. Please try again." }]); } finally { setIsTyping(false); } }; const NavItem = ({ id, icon: Icon, label }) => ( ); return (
{activeTab !== 'chat' && ( )} {activeTab === 'dashboard' && ( <>

Diagnostic Dashboard

Automated Malaria Screening System

Recent History

{patients.map(p => (

{p.name} ({p.age}y)

{p.symptoms}

{p.status}

{p.note &&

{p.note}

}
))}
)} {} {activeTab === 'achievements' && (

Our Achievements

{[ { title: "Accuracy Rate", val: "98.99%", desc: "Proven diagnostic precision in clinical trials." }, { title: "Processing Speed", val: "< 2s", desc: "Automated analysis reduces waiting times significantly." }, { title: "Clinical Reach", val: "10,000+", desc: "Patients screened across endemic regions." } ].map((item, i) => (

{item.val}

{item.title}

{item.desc}

))}
)} {activeTab === 'about' && (

About Clinic Sentinel

Clinic Sentinel is an advanced diagnostic initiative dedicated to eradicating the diagnostic bottleneck in malaria detection. Our core model is a custom-engineered Convolutional Neural Network (CNN) that achieves 98.99% accuracy.

Our Clinical Specialists

Dr. A. Sharma (Chief Pathologist)

Over 15 years of experience in tropical medicine and automated diagnostic imaging.

Dr. R. Kulkarni (Clinical AI Lead)

Specializes in Deep Learning for medical vision, bridging the gap between AI and patient care.

)} {activeTab === 'chat' && (

Dr. AI Assistant

{messages.map((m, i) => (
{m.text} {m.sources && m.sources.length > 0 && (

Sources:

{m.sources.map((s, idx) => ( {s.title} ))}
)}
))} {isTyping &&
Researching...
}
setInputValue(e.target.value)} onKeyPress={(e) => e.key === 'Enter' && handleSendMessage()} placeholder="Ask a medical question..." className="flex-1 bg-transparent p-2 outline-none text-white" />
)}
{showModal && (

New Diagnostic Entry

{!scanResult ? (
setPatientInfo({...patientInfo, name: e.target.value})} /> setPatientInfo({...patientInfo, age: e.target.value})} /> setPatientInfo({...patientInfo, symptoms: e.target.value})} />
fileInputRef.current.click()}>

{selectedFile ? selectedFile.name : 'Upload Blood Smear Image'}

setSelectedFile(e.target.files[0])} />
) : (

{scanResult.status}

{scanResult.note}

)}
)}
); }