#!/usr/bin/env python3 """ 십전대보탕 데이터 조회 및 분석 """ import sqlite3 def check_sipjeondaebotang(): """십전대보탕 처방 상세 조회""" conn = sqlite3.connect('database/kdrug.db') cursor = conn.cursor() print("🔍 십전대보탕 처방 조회") print("="*70) # 십전대보탕 처방 찾기 cursor.execute(""" SELECT formula_id, formula_code, formula_name, formula_type, base_cheop, base_pouches, description, is_active FROM formulas WHERE formula_name LIKE '%십전대보%' OR formula_name LIKE '%십전대보탕%' OR formula_code LIKE '%SJDB%' """) formulas = cursor.fetchall() if not formulas: print("❌ 십전대보탕 처방을 찾을 수 없습니다.") else: for formula_id, code, name, f_type, cheop, pouches, desc, active in formulas: print(f"\n📋 {name} ({code})") print(f" ID: {formula_id}") print(f" 타입: {f_type if f_type else '❌ 없음'}") print(f" 기본 첩수: {cheop if cheop else '❌ 없음'}") print(f" 기본 포수: {pouches if pouches else '❌ 없음'}") print(f" 설명: {desc if desc else '❌ 없음'}") print(f" 활성 상태: {'활성' if active else '비활성'}") # 처방 구성 약재 확인 cursor.execute(""" SELECT hm.herb_name, hm.ingredient_code, fi.grams_per_cheop, fi.notes FROM formula_ingredients fi JOIN herb_masters hm ON fi.ingredient_code = hm.ingredient_code WHERE fi.formula_id = ? ORDER BY fi.sort_order """, (formula_id,)) ingredients = cursor.fetchall() print(f"\n 구성 약재 ({len(ingredients)}개):") print(" " + "-"*60) print(f" {'약재명':15s} | {'용량(g)':>8s} | {'효능 설명'}") print(" " + "-"*60) total_amount = 0 for herb_name, code, amount, notes in ingredients: total_amount += amount notes_str = notes if notes else "❌ 효능 설명 없음" print(f" {herb_name:15s} | {amount:8.1f} | {notes_str}") print(" " + "-"*60) print(f" {'총 용량':15s} | {total_amount:8.1f} |") # 빠진 정보 체크 print(f"\n ⚠️ 빠진 정보 체크:") missing = [] if not desc: missing.append("처방 설명") if not f_type: missing.append("처방 타입") if not cheop: missing.append("기본 첩수") if not pouches: missing.append("기본 포수") # 약재별 효능 설명 체크 missing_notes = [] for herb_name, code, amount, notes in ingredients: if not notes: missing_notes.append(herb_name) if missing: print(f" - 처방 기본 정보: {', '.join(missing)}") if missing_notes: print(f" - 약재 효능 설명 없음: {', '.join(missing_notes)}") if not missing and not missing_notes: print(" ✅ 모든 정보가 완비되어 있습니다.") # 십전대보탕 표준 구성 확인 print(f"\n\n📚 십전대보탕 표준 구성 (참고용):") print("="*70) print(""" 십전대보탕은 사군자탕(인삼, 백출, 복령, 감초)과 사물탕(당귀, 천궁, 백작약, 숙지황)을 합방한 처방으로, 황기와 육계를 추가하여 총 10개 약재로 구성됩니다. 주요 효능: 기혈양허(氣血兩虛)를 치료하는 대표 처방 - 대보기혈(大補氣血): 기와 혈을 크게 보함 - 병후 회복, 수술 후 회복, 만성 피로에 사용 표준 구성 (1첩 기준): - 인삼 4g (대보원기) - 황기 4g (보기승양) - 백출 4g (보기건비) - 복령 4g (건비이수) - 감초 2g (조화제약) - 당귀(일당귀) 4g (보혈) - 천궁 4g (활혈) - 백작약 4g (보혈) - 숙지황 4g (보음보혈) - 육계 2g (온양보화) """) conn.close() if __name__ == "__main__": check_sipjeondaebotang()