feat: OTC 용법 라벨 시스템 구현
DB: - otc_label_presets 테이블 추가 (SQLite) - 바코드 기준 오버라이드 데이터 저장 Backend: - utils/otc_label_printer.py: 라벨 이미지 생성 + Brother QL-810W 출력 - API: CRUD + 미리보기 렌더링 + MSSQL 약품 검색 Frontend: - /admin/otc-labels: 관리 페이지 - 실시간 미리보기 - 저장된 프리셋 목록 - 바코드/이름 검색 → 프리셋 편집 → 인쇄
This commit is contained in:
@@ -397,6 +397,30 @@ class DatabaseManager:
|
||||
self.sqlite_conn.commit()
|
||||
print("[DB Manager] SQLite 마이그레이션: pets 테이블 생성")
|
||||
|
||||
# otc_label_presets 테이블 생성 (OTC 용법 라벨)
|
||||
cursor.execute("SELECT name FROM sqlite_master WHERE type='table' AND name='otc_label_presets'")
|
||||
if not cursor.fetchone():
|
||||
cursor.executescript("""
|
||||
CREATE TABLE IF NOT EXISTS otc_label_presets (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
barcode VARCHAR(20) NOT NULL UNIQUE,
|
||||
drug_code VARCHAR(20),
|
||||
display_name VARCHAR(100),
|
||||
effect VARCHAR(100),
|
||||
dosage_instruction TEXT,
|
||||
usage_tip TEXT,
|
||||
use_wide_format BOOLEAN DEFAULT TRUE,
|
||||
print_count INTEGER DEFAULT 0,
|
||||
last_printed_at DATETIME,
|
||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS idx_otc_label_barcode ON otc_label_presets(barcode);
|
||||
CREATE INDEX IF NOT EXISTS idx_otc_label_drug_code ON otc_label_presets(drug_code);
|
||||
""")
|
||||
self.sqlite_conn.commit()
|
||||
print("[DB Manager] SQLite 마이그레이션: otc_label_presets 테이블 생성")
|
||||
|
||||
def test_connection(self, database='PM_BASE'):
|
||||
"""연결 테스트"""
|
||||
try:
|
||||
|
||||
@@ -145,3 +145,22 @@ CREATE TABLE IF NOT EXISTS pets (
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_pets_user ON pets(user_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_pets_species ON pets(species);
|
||||
|
||||
-- 9. OTC 용법 라벨 테이블 (바코드 기준 오버라이드 데이터)
|
||||
CREATE TABLE IF NOT EXISTS otc_label_presets (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
barcode VARCHAR(20) NOT NULL UNIQUE, -- 바코드 (PK 역할)
|
||||
drug_code VARCHAR(20), -- MSSQL DrugCode (참조용)
|
||||
display_name VARCHAR(100), -- 표시 이름 (오버라이드, NULL이면 MSSQL 이름 사용)
|
||||
effect VARCHAR(100), -- 효능 (예: "치통, 두통")
|
||||
dosage_instruction TEXT, -- 용법 (예: "1일 3회, 1회 1정, 식후 30분")
|
||||
usage_tip TEXT, -- 부가 설명 (예: "[통증 시에만 복용]")
|
||||
use_wide_format BOOLEAN DEFAULT TRUE, -- 와이드 포맷 사용 여부
|
||||
print_count INTEGER DEFAULT 0, -- 인쇄 횟수 (통계용)
|
||||
last_printed_at DATETIME, -- 마지막 인쇄 시간
|
||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_otc_label_barcode ON otc_label_presets(barcode);
|
||||
CREATE INDEX IF NOT EXISTS idx_otc_label_drug_code ON otc_label_presets(drug_code);
|
||||
|
||||
Reference in New Issue
Block a user