- 판매 관리 기능 추가 - 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>
102 lines
3.1 KiB
Python
102 lines
3.1 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
조제 데이터 상세 확인 - formula_id가 NULL인 케이스 분석
|
|
"""
|
|
|
|
import sqlite3
|
|
|
|
def check_compound_details():
|
|
conn = sqlite3.connect('database/kdrug.db')
|
|
cursor = conn.cursor()
|
|
|
|
print("=" * 80)
|
|
print("조제 데이터 상세 분석")
|
|
print("=" * 80)
|
|
|
|
# formula_id가 NULL인 조제건 확인
|
|
print("\n1. Formula ID가 NULL인 조제건:")
|
|
print("-" * 80)
|
|
cursor.execute("""
|
|
SELECT compound_id, patient_id, formula_id, is_custom, custom_type,
|
|
custom_summary, compound_date, status
|
|
FROM compounds
|
|
WHERE formula_id IS NULL
|
|
ORDER BY compound_id DESC
|
|
""")
|
|
|
|
null_formulas = cursor.fetchall()
|
|
for comp in null_formulas:
|
|
print(f" ID: {comp[0]}")
|
|
print(f" 환자ID: {comp[1]}, is_custom: {comp[3]}, custom_type: {comp[4]}")
|
|
print(f" custom_summary: {comp[5]}")
|
|
print(f" 조제일: {comp[6]}, 상태: {comp[7]}")
|
|
print()
|
|
|
|
# 전체 조제 데이터 요약
|
|
print("\n2. 전체 조제 데이터 요약:")
|
|
print("-" * 80)
|
|
cursor.execute("""
|
|
SELECT
|
|
COUNT(*) as total,
|
|
COUNT(formula_id) as with_formula,
|
|
COUNT(*) - COUNT(formula_id) as without_formula,
|
|
SUM(CASE WHEN is_custom = 1 THEN 1 ELSE 0 END) as custom_count
|
|
FROM compounds
|
|
""")
|
|
|
|
summary = cursor.fetchone()
|
|
print(f" 총 조제건수: {summary[0]}")
|
|
print(f" 처방 있음: {summary[1]}")
|
|
print(f" 처방 없음(직접조제): {summary[2]}")
|
|
print(f" 커스텀 플래그: {summary[3]}")
|
|
|
|
# compound_items 테이블 확인
|
|
print("\n3. Compound_items 테이블 구조 및 데이터:")
|
|
print("-" * 80)
|
|
|
|
# 테이블 구조 확인
|
|
cursor.execute("PRAGMA table_info(compound_items)")
|
|
columns = cursor.fetchall()
|
|
if columns:
|
|
print(" 테이블 구조:")
|
|
for col in columns:
|
|
print(f" {col[1]:20s} {col[2]:15s}")
|
|
|
|
# 샘플 데이터
|
|
cursor.execute("""
|
|
SELECT * FROM compound_items
|
|
LIMIT 5
|
|
""")
|
|
items = cursor.fetchall()
|
|
if items:
|
|
print("\n 샘플 데이터:")
|
|
for item in items:
|
|
print(f" {item}")
|
|
else:
|
|
print(" compound_items 테이블이 비어있거나 없습니다.")
|
|
|
|
# 직접조제의 약재 구성 확인 (compound_items와 연결)
|
|
print("\n4. 직접조제(formula_id=NULL) 약재 구성:")
|
|
print("-" * 80)
|
|
|
|
for comp_id in [10, 8, 7]: # NULL인 compound_id들
|
|
cursor.execute("""
|
|
SELECT ci.*, h.herb_name
|
|
FROM compound_items ci
|
|
LEFT JOIN herb_items h ON ci.herb_item_id = h.herb_item_id
|
|
WHERE ci.compound_id = ?
|
|
LIMIT 5
|
|
""", (comp_id,))
|
|
|
|
items = cursor.fetchall()
|
|
if items:
|
|
print(f" Compound ID {comp_id}의 약재:")
|
|
for item in items:
|
|
print(f" {item}")
|
|
else:
|
|
print(f" Compound ID {comp_id}: 약재 데이터 없음")
|
|
|
|
conn.close()
|
|
|
|
if __name__ == "__main__":
|
|
check_compound_details() |