diff --git a/backend/pmr_api.py b/backend/pmr_api.py index 3dea33e..084ec43 100644 --- a/backend/pmr_api.py +++ b/backend/pmr_api.py @@ -11,6 +11,7 @@ from PIL import Image, ImageDraw, ImageFont import io import base64 import os +from utils.drug_unit import get_drug_unit pmr_bp = Blueprint('pmr', __name__, url_prefix='/pmr') @@ -363,6 +364,7 @@ def get_prescription_detail(prescription_id): 'total_qty': float(row.INV_QUAN) if row.INV_QUAN else 0, 'type': '급여' if row.PS_Type in ['0', '4'] else '비급여' if row.PS_Type == '1' else row.PS_Type, 'sung_code': row.SUNG_CODE or '', + 'unit': get_drug_unit(row.GoodsName or '', row.SUNG_CODE or ''), 'ps_type': row.PS_Type or '0', 'unit_code': unit_code, 'is_substituted': is_substituted, diff --git a/backend/templates/pmr.html b/backend/templates/pmr.html index 7ab118b..abd6ade 100644 --- a/backend/templates/pmr.html +++ b/backend/templates/pmr.html @@ -1555,7 +1555,6 @@ 약품명 - 제형 용량 횟수 일수 @@ -1563,7 +1562,7 @@ ${data.medications.map((m, i) => ` - +
@@ -1581,8 +1580,7 @@ ` : ''} - ${m.formulation ? `${m.formulation}` : '-'} - ${m.dosage || '-'} + ${m.dosage || '-'}${m.unit || '정'} ${m.frequency || '-'}회 ${m.duration || '-'}일 @@ -1821,7 +1819,7 @@ const disabled = m.status === 'removed' ? 'disabled' : ''; return ` - +
${i+1}${m.med_name || m.medication_code}
@@ -1859,7 +1857,7 @@ ${currentMedications.map((m, i) => ` - +
${i+1}${m.med_name || m.medication_code}
@@ -2605,17 +2603,20 @@ // 약품명: 두 번째 셀의 .med-name const medName = tr.querySelector('.med-name')?.textContent?.trim() || ''; const addInfo = tr.dataset.addInfo || ''; - // 용량: 네 번째 셀 (index 3) - const dosageText = cells[3]?.textContent?.replace(/[^0-9.]/g, '') || '0'; + // 용량: 세 번째 셀 (index 2) - 제형 컬럼 제거됨 + const dosageText = cells[2]?.textContent?.replace(/[^0-9.]/g, '') || '0'; const dosage = parseFloat(dosageText) || 0; - // 횟수: 다섯 번째 셀 (index 4) - const freqText = cells[4]?.textContent?.replace(/[^0-9]/g, '') || '0'; + // 횟수: 네 번째 셀 (index 3) + const freqText = cells[3]?.textContent?.replace(/[^0-9]/g, '') || '0'; const frequency = parseInt(freqText) || 0; - // 일수: 여섯 번째 셀 (index 5) - const durText = cells[5]?.textContent?.replace(/[^0-9]/g, '') || '0'; + // 일수: 다섯 번째 셀 (index 4) + const durText = cells[4]?.textContent?.replace(/[^0-9]/g, '') || '0'; const duration = parseInt(durText) || 0; - console.log('Preview data:', { patientName, medName, addInfo, dosage, frequency, duration }); + // 단위: data-unit 속성에서 가져오기 (SUNG_CODE 기반 자동 판별) + const unit = tr.dataset.unit || '정'; + + console.log('Preview data:', { patientName, medName, addInfo, dosage, frequency, duration, unit }); try { const res = await fetch('/pmr/api/label/preview', { @@ -2628,7 +2629,7 @@ dosage: dosage, frequency: frequency, duration: duration, - unit: '정' + unit: unit }) }); const data = await res.json();