""" 간호 인수인계 교육 플랫폼 - Gradio 멀티페이지 애플리케이션 (채팅 기반) """ import os import gradio as gr from services.gemini_service import GeminiEvaluator from services.supabase_service import SupabaseService from config.database import supabase_client # 데이터베이스 초기화 try: print("🔗 데이터베이스 연결 시도 중...") # Supabase 서비스 초기화 if supabase_client: try: supabase_service = SupabaseService() print("✅ Supabase 클라이언트 초기화 완료") # 시나리오 데이터 로드 (테이블이 없는 경우 무시) try: print("📥 시나리오 데이터 로드 중...") supabase_service.load_scenarios_from_json("data/scenarios.json") print("✅ 시나리오 데이터 로드 완료") except Exception as load_error: print(f"⚠️ 시나리오 데이터 로드 실패: {load_error}") print(" (이미 데이터가 있거나 테이블이 없을 수 있습니다)") except Exception as service_error: print(f"⚠️ Supabase 서비스 초기화 실패: {service_error}") supabase_service = None else: print("⚠️ Supabase 클라이언트가 초기화되지 않았습니다.") print(" 환경 변수 SUPABASE_URL과 SUPABASE_ANON_KEY를 확인하세요.") supabase_service = None except Exception as e: print(f"⚠️ 데이터베이스 초기화 중 오류: {e}") import traceback traceback.print_exc() supabase_service = None # Gemini 평가기 초기화 evaluator = GeminiEvaluator() # 초기 학생 ID 생성 (TSID 기반) from tsidpy import TSID tsid = TSID.create() initial_student_id = f"student_{tsid.to_string()}" # ===== EMR HTML 생성 함수들 (기존 로직 재사용) ===== def create_emr_html(patient, scenario): """실제 병원 EMR과 유사한 HTML 생성""" vitals = scenario.vitals or {} labs = scenario.labs or {} orders = scenario.orders or [] nursing_notes = scenario.nursing_notes or [] # EMR 헤더 emr_html = f"""
| 검사항목 | ' html += '결과 | ' html += '참고범위 | ' html += '상태 | ' html += "
|---|