kdrug-inventory-system/dev_scripts/check_wolbitang_ingredients.py
시골약사 ad9ac396e2 chore: 개발 파일 정리 및 구조화
- 개발/테스트 스크립트를 dev_scripts/ 폴더로 이동
- 스크린샷을 screenshots/ 폴더로 이동
- 백업 파일 보존 (.backup)
- 처방 관련 추가 스크립트 포함

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

Co-Authored-By: Claude <noreply@anthropic.com>
2026-02-18 04:44:48 +00:00

78 lines
2.0 KiB
Python

#!/usr/bin/env python3
"""
월비탕에 사용되는 약재들의 성분 코드 확인
"""
import sqlite3
def check_herb_codes():
"""약재 성분 코드 확인"""
# 월비탕에 사용되는 약재들
herbs_to_check = [
"마황",
"석고",
"감초",
"진피",
"복령",
"갈근",
"건지황",
"창출"
]
conn = sqlite3.connect('database/kdrug.db')
cursor = conn.cursor()
herb_codes = {}
print("🌿 월비탕 약재 성분 코드 확인")
print("="*50)
for herb in herbs_to_check:
# 정확한 이름으로 먼저 검색
cursor.execute("""
SELECT ingredient_code, herb_name, herb_name_hanja
FROM herb_masters
WHERE herb_name = ?
""", (herb,))
result = cursor.fetchone()
# 정확한 이름이 없으면 포함된 이름으로 검색
if not result:
cursor.execute("""
SELECT ingredient_code, herb_name, herb_name_hanja
FROM herb_masters
WHERE herb_name LIKE ?
ORDER BY LENGTH(herb_name)
LIMIT 1
""", (f'%{herb}%',))
result = cursor.fetchone()
if result:
herb_codes[herb] = result[0]
print(f"{herb}: {result[0]} ({result[1]}, {result[2]})")
else:
print(f"{herb}: 찾을 수 없음")
# 비슷한 이름 찾기
cursor.execute("""
SELECT herb_name
FROM herb_masters
WHERE herb_name LIKE ?
LIMIT 5
""", (f'%{herb[:2]}%',))
similar = cursor.fetchall()
if similar:
print(f" 유사한 약재: {', '.join([s[0] for s in similar])}")
conn.close()
return herb_codes
if __name__ == "__main__":
herb_codes = check_herb_codes()
print("\n📊 약재 코드 매핑 결과:")
print("-"*50)
for herb, code in herb_codes.items():
print(f'"{herb}": "{code}",')