diff --git a/backend/app.py b/backend/app.py index 7c4d486..c43e9cd 100644 --- a/backend/app.py +++ b/backend/app.py @@ -5105,7 +5105,7 @@ def api_rx_usage(): ISNULL(G.GoodsName, '알 수 없음') as product_name, ISNULL(G.SplName, '') as supplier, SUM(ISNULL(P.QUAN, 1)) as total_qty, - SUM(ISNULL(P.QUAN, 1) * ISNULL(P.Days, 1)) as total_dose, + SUM(ISNULL(P.INV_QUAN, 0)) as total_dose, -- 총 투약량 (1회복용량 x 복용횟수 x 일수) SUM(ISNULL(P.DRUPRICE, 0)) as total_amount, -- DRUPRICE 합계 COUNT(DISTINCT P.PreSerial) as prescription_count, COALESCE(NULLIF(G.BARCODE, ''), '') as barcode, diff --git a/backend/pmr_api.py b/backend/pmr_api.py index f9f121c..a250edb 100644 --- a/backend/pmr_api.py +++ b/backend/pmr_api.py @@ -1008,11 +1008,15 @@ def create_label_image(patient_name, med_name, add_info='', dosage=0, frequency= draw_centered(dosage_text, start_y, info_font) draw_centered(time_text, start_y + fixed_line_height + line_spacing, info_font) - y = box_bottom + 10 + # 조제일 (시그니처 위쪽에 배치) - 먼저 위치 계산 + today = datetime.now().strftime('%Y-%m-%d') + print_date_text = f"조제일 : {today}" + bbox = draw.textbbox((0, 0), print_date_text, font=small_font) + date_w, date_h = bbox[2] - bbox[0], bbox[3] - bbox[1] + print_date_y = label_height - date_h - 70 # 시그니처 위쪽 - # 보관조건 표시 (용법 박스와 조제일 사이 여백) + # 보관조건 표시 (조제일 바로 위에 고정 배치) if storage_conditions: - # 모든 보관조건 표시 (실온보관, 냉장보관 등) storage_text = f"* {storage_conditions}" try: storage_font = ImageFont.truetype(font_path, 28) @@ -1020,15 +1024,11 @@ def create_label_image(patient_name, med_name, add_info='', dosage=0, frequency= storage_font = ImageFont.load_default() bbox_storage = draw.textbbox((0, 0), storage_text, font=storage_font) storage_w = bbox_storage[2] - bbox_storage[0] - draw.text(((label_width - storage_w) / 2, y), storage_text, font=storage_font, fill="black") - y += 25 + storage_h = bbox_storage[3] - bbox_storage[1] + storage_y = print_date_y - storage_h - 8 # 조제일 위 8px 간격 + draw.text(((label_width - storage_w) / 2, storage_y), storage_text, font=storage_font, fill="black") - # 조제일 (시그니처 위쪽에 배치) - today = datetime.now().strftime('%Y-%m-%d') - print_date_text = f"조제일 : {today}" - bbox = draw.textbbox((0, 0), print_date_text, font=small_font) - date_w, date_h = bbox[2] - bbox[0], bbox[3] - bbox[1] - print_date_y = label_height - date_h - 70 # 시그니처 위쪽 + # 조제일 그리기 draw.text(((label_width - date_w) / 2, print_date_y), print_date_text, font=small_font, fill="black") # 시그니처 박스 (하단 - 약국명)