diff --git a/backend/pmr_api.py b/backend/pmr_api.py index ad6b9ca..21f5fc3 100644 --- a/backend/pmr_api.py +++ b/backend/pmr_api.py @@ -640,6 +640,9 @@ def print_label(): - printer: 프린터 선택 (선택, 기본값 '168') - '121': QL-710W (192.168.0.121) - '168': QL-810W (192.168.0.168) + - orientation: 출력 방향 (선택, 기본값 'portrait') + - 'portrait': 세로 모드 (QR 라벨과 동일, 회전 없음) + - 'landscape': 가로 모드 (90도 회전) """ try: from brother_ql.raster import BrotherQLRaster @@ -657,6 +660,7 @@ def print_label(): unit = data.get('unit', '정') sung_code = data.get('sung_code', '') printer = data.get('printer', '168') # 기본값: QL-810W + orientation = data.get('orientation', 'portrait') # 기본값: 세로 모드 # 프린터 설정 if printer == '121': @@ -688,14 +692,19 @@ def print_label(): conversion_factor=conversion_factor ) - # 2. 이미지 90도 회전 (Brother QL이 세로 방향 기준이므로) - label_rotated = label_image.rotate(90, expand=True) + # 2. 방향 설정 (portrait: 회전 없음, landscape: 90도 회전) + if orientation == 'landscape': + # 가로 모드: 90도 회전 (기존 방식) + label_final = label_image.rotate(90, expand=True) + else: + # 세로 모드: 회전 없음 (QR 라벨과 동일) + label_final = label_image # 3. Brother QL 프린터로 전송 qlr = BrotherQLRaster(printer_model) instructions = convert( qlr=qlr, - images=[label_rotated], + images=[label_final], label='29', rotate='0', threshold=70.0, @@ -708,11 +717,12 @@ def print_label(): ) send(instructions, printer_identifier=f"tcp://{printer_ip}:9100") - logging.info(f"[SUCCESS] PMR 라벨 인쇄 성공: {med_name} → {printer_model}") + logging.info(f"[SUCCESS] PMR 라벨 인쇄 성공: {med_name} → {printer_model} ({orientation})") return jsonify({ 'success': True, 'message': f'{med_name} 라벨 인쇄 완료 ({printer_model})', - 'printer': printer_model + 'printer': printer_model, + 'orientation': orientation }) except ImportError as e: diff --git a/backend/templates/pmr.html b/backend/templates/pmr.html index 20bbd46..4071c15 100644 --- a/backend/templates/pmr.html +++ b/backend/templates/pmr.html @@ -2993,7 +2993,7 @@ return; } - const patientName = document.querySelector('.patient-info h2')?.textContent?.trim() || ''; + const patientName = document.getElementById('detailName')?.textContent?.trim() || ''; let printedCount = 0; let failedCount = 0;