fix: 기존 처방 약재 및 효능 정보 수정

- 쌍화탕: 당귀 → 일당귀로 수정
- 월비탕: 진피초 → 진피(陳皮)로 수정
- 십전대보탕: 각 약재별 효능 설명 추가
  - 보음보혈, 보혈지통, 대보원기 등 11개 약재 효능 추가

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
시골약사 2026-02-18 04:37:16 +00:00
parent f1034c197f
commit 95df32c14d
5 changed files with 515 additions and 0 deletions

119
check_sipjeondaebotang.py Normal file
View File

@ -0,0 +1,119 @@
#!/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()

81
check_ssanghwatang.py Normal file
View File

@ -0,0 +1,81 @@
#!/usr/bin/env python3
"""
쌍화탕 처방 당귀 약재 확인
"""
import sqlite3
def check_ssanghwatang():
conn = sqlite3.connect('database/kdrug.db')
cursor = conn.cursor()
# 쌍화탕 처방 찾기
print("🔍 쌍화탕 처방 검색...")
print("="*60)
cursor.execute("""
SELECT formula_id, formula_code, formula_name
FROM formulas
WHERE formula_name LIKE '%쌍화%'
""")
formulas = cursor.fetchall()
if not formulas:
print("❌ 쌍화탕 처방을 찾을 수 없습니다.")
else:
for formula_id, code, name in formulas:
print(f"\n📋 {name} ({code})")
# 처방 구성 약재 확인
cursor.execute("""
SELECT hm.herb_name, hm.ingredient_code, fi.grams_per_cheop
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(" 구성 약재:")
for herb_name, code, amount in ingredients:
if '당귀' in herb_name:
print(f" ⚠️ {herb_name} ({code}): {amount}g <-- 당귀 발견!")
else:
print(f" - {herb_name} ({code}): {amount}g")
# 당귀 관련 약재 검색
print("\n\n🌿 당귀 관련 약재 검색...")
print("="*60)
cursor.execute("""
SELECT ingredient_code, herb_name, herb_name_hanja
FROM herb_masters
WHERE herb_name LIKE '%당귀%'
ORDER BY herb_name
""")
danggui_herbs = cursor.fetchall()
for code, name, hanja in danggui_herbs:
print(f"{code}: {name} ({hanja})")
# 일당귀 확인
print("\n✅ 일당귀 검색:")
cursor.execute("""
SELECT ingredient_code, herb_name, herb_name_hanja
FROM herb_masters
WHERE herb_name = '일당귀'
OR herb_name LIKE '%일당귀%'
""")
result = cursor.fetchall()
if result:
for code, name, hanja in result:
print(f" {code}: {name} ({hanja})")
else:
print(" ❌ 일당귀를 찾을 수 없음")
conn.close()
if __name__ == "__main__":
check_ssanghwatang()

112
update_sipjeondaebotang.py Normal file
View File

@ -0,0 +1,112 @@
#!/usr/bin/env python3
"""
십전대보탕 약재별 효능 설명 추가
"""
import sqlite3
def update_sipjeondaebotang():
"""십전대보탕 약재별 효능 설명 업데이트"""
conn = sqlite3.connect('database/kdrug.db')
cursor = conn.cursor()
try:
# 십전대보탕 ID 확인
cursor.execute("""
SELECT formula_id, formula_name
FROM formulas
WHERE formula_code = 'SJDB01'
""")
result = cursor.fetchone()
if not result:
print("❌ 십전대보탕을 찾을 수 없습니다.")
return False
formula_id, formula_name = result
print(f"📋 {formula_name} (ID: {formula_id}) 효능 설명 추가")
print("="*60)
# 각 약재별 효능 설명 업데이트
herb_notes = {
"숙지황": "보음보혈",
"작약": "보혈지통",
"인삼": "대보원기",
"백출": "보기건비",
"황기": "보기승양",
"대추": "보중익기",
"일당귀": "보혈활혈",
"복령": "건비이수",
"감초": "조화제약",
"천궁": "활혈행기",
"반하생강백반제": "화담지구"
}
print("\n약재별 효능 설명 추가:")
print("-"*60)
for herb_name, notes in herb_notes.items():
# 약재 코드 찾기
cursor.execute("""
SELECT fi.ingredient_id, hm.herb_name, fi.notes
FROM formula_ingredients fi
JOIN herb_masters hm ON fi.ingredient_code = hm.ingredient_code
WHERE fi.formula_id = ? AND hm.herb_name = ?
""", (formula_id, herb_name))
result = cursor.fetchone()
if result:
ingredient_id, actual_name, current_notes = result
# 효능 설명 업데이트
cursor.execute("""
UPDATE formula_ingredients
SET notes = ?
WHERE ingredient_id = ?
""", (notes, ingredient_id))
if current_notes:
print(f" {actual_name}: '{current_notes}''{notes}'")
else:
print(f" {actual_name}: 효능 설명 추가 → '{notes}'")
else:
print(f" ⚠️ {herb_name}: 약재를 찾을 수 없음")
conn.commit()
print(f"\n✅ 효능 설명 추가 완료!")
# 업데이트 후 확인
print(f"\n📊 업데이트된 십전대보탕 구성:")
print("-"*60)
cursor.execute("""
SELECT hm.herb_name, 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,))
results = cursor.fetchall()
for herb, amount, notes in results:
check = "" if notes else ""
print(f" {check} {herb:15s}: {amount:5.1f}g - {notes if notes else '효능 설명 없음'}")
except sqlite3.Error as e:
print(f"❌ 데이터베이스 오류: {e}")
conn.rollback()
return False
finally:
conn.close()
return True
if __name__ == "__main__":
print("🌿 십전대보탕 효능 설명 추가 프로그램")
print("="*60)
if update_sipjeondaebotang():
print("\n✅ 업데이트 작업이 완료되었습니다.")
else:
print("\n❌ 업데이트 중 오류가 발생했습니다.")

View File

@ -0,0 +1,118 @@
#!/usr/bin/env python3
"""
쌍화탕 처방의 당귀를 일당귀로 수정
"""
import sqlite3
def update_danggui():
"""쌍화탕의 당귀를 일당귀로 수정"""
conn = sqlite3.connect('database/kdrug.db')
cursor = conn.cursor()
try:
# 현재 쌍화탕에 등록된 당귀 확인
print("🔍 현재 쌍화탕 처방의 당귀 확인...")
cursor.execute("""
SELECT f.formula_name, fi.ingredient_code, hm.herb_name, fi.grams_per_cheop
FROM formulas f
JOIN formula_ingredients fi ON f.formula_id = fi.formula_id
JOIN herb_masters hm ON fi.ingredient_code = hm.ingredient_code
WHERE f.formula_name LIKE '%쌍화%'
AND hm.herb_name LIKE '%당귀%'
""")
current = cursor.fetchall()
print(f"현재 상태:")
for name, code, herb, amount in current:
print(f" - {name}: {herb} ({code}) - {amount}g")
# 당귀(3105H1AHM)를 일당귀(3403H1AHM)로 변경
print(f"\n✏️ 당귀(3105H1AHM) → 일당귀(3403H1AHM)로 변경 중...")
# 쌍화탕 처방 ID 확인
cursor.execute("""
SELECT formula_id
FROM formulas
WHERE formula_name LIKE '%쌍화%'
""")
formula_ids = [row[0] for row in cursor.fetchall()]
if formula_ids:
# 당귀를 일당귀로 수정
cursor.execute("""
UPDATE formula_ingredients
SET ingredient_code = '3403H1AHM'
WHERE ingredient_code = '3105H1AHM'
AND formula_id IN ({})
""".format(','.join('?' * len(formula_ids))), formula_ids)
updated_count = cursor.rowcount
print(f"{updated_count}개 항목 수정됨")
# 변경 후 확인
print(f"\n🔍 수정 후 확인...")
cursor.execute("""
SELECT f.formula_name, fi.ingredient_code, hm.herb_name, fi.grams_per_cheop
FROM formulas f
JOIN formula_ingredients fi ON f.formula_id = fi.formula_id
JOIN herb_masters hm ON fi.ingredient_code = hm.ingredient_code
WHERE f.formula_name LIKE '%쌍화%'
AND hm.herb_name LIKE '%당귀%'
""")
updated = cursor.fetchall()
print(f"수정된 상태:")
for name, code, herb, amount in updated:
print(f" - {name}: {herb} ({code}) - {amount}g")
conn.commit()
print(f"\n✅ 쌍화탕 당귀 수정 완료!")
# 전체 처방 구성 확인
print(f"\n📋 수정된 쌍화탕 전체 구성:")
print("-"*60)
for formula_id in formula_ids:
cursor.execute("""
SELECT f.formula_name
FROM formulas f
WHERE f.formula_id = ?
""", (formula_id,))
formula_name = cursor.fetchone()[0]
print(f"\n{formula_name}:")
cursor.execute("""
SELECT hm.herb_name, 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,))
for herb, amount, notes in cursor.fetchall():
marker = "" if herb == "일당귀" else " "
print(f" {marker} {herb}: {amount}g ({notes if notes else ''})")
else:
print("❌ 쌍화탕 처방을 찾을 수 없습니다.")
except sqlite3.Error as e:
print(f"❌ 데이터베이스 오류: {e}")
conn.rollback()
return False
finally:
conn.close()
return True
if __name__ == "__main__":
print("🌿 쌍화탕 당귀 수정 프로그램")
print("="*60)
if update_danggui():
print("\n✅ 수정 작업이 완료되었습니다.")
else:
print("\n❌ 수정 중 오류가 발생했습니다.")

85
update_wolbitang_jinpi.py Normal file
View File

@ -0,0 +1,85 @@
#!/usr/bin/env python3
"""
월비탕 처방의 진피초를 진피(陳皮) 수정
"""
import sqlite3
def update_jinpi():
"""진피초를 진피로 수정"""
conn = sqlite3.connect('database/kdrug.db')
cursor = conn.cursor()
try:
# 현재 진피초로 등록된 월비탕 처방 확인
print("🔍 현재 월비탕 처방에 등록된 진피 확인...")
cursor.execute("""
SELECT f.formula_name, fi.ingredient_code, hm.herb_name
FROM formulas f
JOIN formula_ingredients fi ON f.formula_id = fi.formula_id
JOIN herb_masters hm ON fi.ingredient_code = hm.ingredient_code
WHERE f.formula_code LIKE 'WBT%'
AND hm.herb_name LIKE '%진피%'
ORDER BY f.formula_code
""")
current = cursor.fetchall()
print(f"현재 상태:")
for name, code, herb in current:
print(f" - {name}: {herb} ({code})")
# 진피초(3632H1AHM)를 진피(陳皮)(3466H1AHM)로 변경
print(f"\n✏️ 진피초(3632H1AHM) → 진피(陳皮)(3466H1AHM)로 변경 중...")
cursor.execute("""
UPDATE formula_ingredients
SET ingredient_code = '3466H1AHM'
WHERE ingredient_code = '3632H1AHM'
AND formula_id IN (
SELECT formula_id
FROM formulas
WHERE formula_code LIKE 'WBT%'
)
""")
updated_count = cursor.rowcount
print(f"{updated_count}개 항목 수정됨")
# 변경 후 확인
print(f"\n🔍 수정 후 확인...")
cursor.execute("""
SELECT f.formula_name, fi.ingredient_code, hm.herb_name
FROM formulas f
JOIN formula_ingredients fi ON f.formula_id = fi.formula_id
JOIN herb_masters hm ON fi.ingredient_code = hm.ingredient_code
WHERE f.formula_code LIKE 'WBT%'
AND hm.herb_name LIKE '%진피%'
ORDER BY f.formula_code
""")
updated = cursor.fetchall()
print(f"수정된 상태:")
for name, code, herb in updated:
print(f" - {name}: {herb} ({code})")
conn.commit()
print(f"\n✅ 진피 수정 완료!")
except sqlite3.Error as e:
print(f"❌ 데이터베이스 오류: {e}")
conn.rollback()
return False
finally:
conn.close()
return True
if __name__ == "__main__":
print("🌿 월비탕 진피 수정 프로그램")
print("="*60)
if update_jinpi():
print("\n✅ 수정 작업이 완료되었습니다.")
else:
print("\n❌ 수정 중 오류가 발생했습니다.")