- 판매 관리 기능 추가 - compounds 테이블에 판매 관련 컬럼 추가 (payment_method, discount_rate, delivery_method 등) - 판매 상태 관리 (조제완료→결제대기→결제완료→배송대기→배송완료) - 판매 처리 모달 UI 구현 - 9가지 상태별 뱃지 표시 - 마일리지 시스템 구축 - patients 테이블에 마일리지 컬럼 추가 (balance, earned, used) - mileage_transactions 테이블 생성 (거래 이력 관리) - 마일리지 사용/적립 기능 구현 - 복합 결제 기능 - 할인율(%) / 할인액(원) 직접 입력 선택 가능 - 마일리지 + 현금 + 카드 + 계좌이체 복합 결제 - 결제 금액 자동 검증 - 결제 방법 자동 분류 (복합결제 지원) - API 엔드포인트 추가 - POST /api/compounds/<id>/status (상태 업데이트) - PUT /api/compounds/<id>/price (가격 조정) - GET /api/sales/statistics (판매 통계) - 데이터베이스 설정 통합 - config.py 생성하여 DB 경로 중앙화 TODO: 처방별 기본가격 정책 시스템 (price_policies 테이블 활용) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
103 lines
3.4 KiB
Python
103 lines
3.4 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
compound_ingredients 테이블 확인 - 직접조제 데이터 분석
|
|
"""
|
|
|
|
import sqlite3
|
|
|
|
def analyze_compound_ingredients():
|
|
conn = sqlite3.connect('database/kdrug.db')
|
|
cursor = conn.cursor()
|
|
|
|
print("=" * 80)
|
|
print("Compound_ingredients 테이블 분석")
|
|
print("=" * 80)
|
|
|
|
# 테이블 구조
|
|
print("\n1. 테이블 구조:")
|
|
print("-" * 80)
|
|
cursor.execute("PRAGMA table_info(compound_ingredients)")
|
|
for col in cursor.fetchall():
|
|
print(f" {col[1]:25s} {col[2]:15s} {'NOT NULL' if col[3] else 'NULL':10s}")
|
|
|
|
# formula_id가 NULL인 compound의 약재 구성
|
|
print("\n2. Formula_id가 NULL인 조제건의 약재 구성:")
|
|
print("-" * 80)
|
|
|
|
cursor.execute("""
|
|
SELECT
|
|
c.compound_id,
|
|
c.formula_id,
|
|
c.is_custom,
|
|
c.custom_type,
|
|
COUNT(ci.compound_ingredient_id) as ingredient_count,
|
|
GROUP_CONCAT(h.herb_name || ':' || ci.grams_per_cheop || 'g', ', ') as ingredients
|
|
FROM compounds c
|
|
LEFT JOIN compound_ingredients ci ON c.compound_id = ci.compound_id
|
|
LEFT JOIN herb_items h ON ci.herb_item_id = h.herb_item_id
|
|
WHERE c.formula_id IS NULL
|
|
GROUP BY c.compound_id
|
|
ORDER BY c.compound_id DESC
|
|
""")
|
|
|
|
results = cursor.fetchall()
|
|
for row in results:
|
|
print(f"\n Compound ID: {row[0]}")
|
|
print(f" Formula ID: {row[1]}, is_custom: {row[2]}, custom_type: {row[3]}")
|
|
print(f" 약재 수: {row[4]}개")
|
|
print(f" 구성: {row[5]}")
|
|
|
|
# 전체 통계
|
|
print("\n3. 전체 조제 통계:")
|
|
print("-" * 80)
|
|
|
|
cursor.execute("""
|
|
SELECT
|
|
c.formula_id IS NOT NULL as has_formula,
|
|
c.is_custom,
|
|
COUNT(DISTINCT c.compound_id) as compound_count,
|
|
COUNT(ci.compound_ingredient_id) as total_ingredients
|
|
FROM compounds c
|
|
LEFT JOIN compound_ingredients ci ON c.compound_id = ci.compound_id
|
|
GROUP BY has_formula, is_custom
|
|
""")
|
|
|
|
print(f" {'처방있음':10s} {'커스텀':8s} {'조제수':8s} {'총약재수':10s}")
|
|
print(" " + "-" * 40)
|
|
for row in cursor.fetchall():
|
|
has_formula = "예" if row[0] else "아니오"
|
|
is_custom = "예" if row[1] else "아니오"
|
|
print(f" {has_formula:10s} {is_custom:8s} {row[2]:8d} {row[3]:10d}")
|
|
|
|
# 특정 조제건 상세
|
|
print("\n4. Compound ID 10번 상세 (formula_id=NULL):")
|
|
print("-" * 80)
|
|
|
|
cursor.execute("""
|
|
SELECT
|
|
ci.herb_item_id,
|
|
h.herb_name,
|
|
ci.grams_per_cheop,
|
|
c.cheop_total,
|
|
ci.total_grams,
|
|
ci.notes
|
|
FROM compound_ingredients ci
|
|
LEFT JOIN herb_items h ON ci.herb_item_id = h.herb_item_id
|
|
LEFT JOIN compounds c ON ci.compound_id = c.compound_id
|
|
WHERE ci.compound_id = 10
|
|
ORDER BY ci.compound_ingredient_id
|
|
""")
|
|
|
|
ingredients = cursor.fetchall()
|
|
if ingredients:
|
|
print(f" {'약재코드':15s} {'약재명':15s} {'1첩용량':10s} {'첩수':8s} {'총용량':10s}")
|
|
print(" " + "-" * 60)
|
|
for ing in ingredients:
|
|
print(f" {ing[0]:15s} {ing[1] or 'Unknown':15s} {ing[2]:10.1f}g {ing[3]:8.0f} {ing[4]:10.1f}g")
|
|
else:
|
|
print(" 약재 데이터 없음")
|
|
|
|
conn.close()
|
|
|
|
if __name__ == "__main__":
|
|
analyze_compound_ingredients() |