kdrug-inventory-system/check_samsoeun_ingredients.py
시골약사 f1034c197f feat: 월비탕 및 삼소음 처방 추가
- 월비탕 1차~4차 단계별 처방 추가 (WBT001-1 ~ WBT001-4)
- 삼소음 처방 추가 (SSE001)
- 처방 추가 가이드 문서 작성
- 약재 성분 코드 확인 및 검증 스크립트 추가

월비탕: 단계별 비만치료 처방 (1차~4차)
삼소음: 리기화담, 해표산한 효능의 기침/가래 치료 처방

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

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

109 lines
3.1 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("="*60)
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:
# 특수 케이스 처리
if herb == "소엽":
search_term = "자소엽"
elif herb == "대조":
search_term = "대추"
elif herb == "적복령":
search_term = "적복령"
else:
search_term = herb
cursor.execute("""
SELECT ingredient_code, herb_name, herb_name_hanja
FROM herb_masters
WHERE herb_name LIKE ? OR herb_name = ?
ORDER BY
CASE WHEN herb_name = ? THEN 0 ELSE 1 END,
LENGTH(herb_name)
LIMIT 1
""", (f'%{search_term}%', search_term, search_term))
result = cursor.fetchone()
if result:
herb_codes[herb] = result[0]
print(f"{herb}: {result[0]} ({result[1]})")
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])}")
# 복령 관련 추가 확인
if "적복령" not in herb_codes or not herb_codes.get("적복령"):
print("\n📌 복령 관련 약재 추가 검색:")
cursor.execute("""
SELECT ingredient_code, herb_name
FROM herb_masters
WHERE herb_name LIKE '%복령%'
ORDER BY herb_name
""")
bokryung_list = cursor.fetchall()
for code, name in bokryung_list:
print(f" - {code}: {name}")
conn.close()
return herb_codes
if __name__ == "__main__":
herb_codes = check_herb_codes()
print("\n📊 약재 코드 매핑 결과:")
print("-"*60)
for herb, code in herb_codes.items():
if code:
print(f'"{herb}": "{code}",')