feat(pmr): 라벨 단위 정규화 + 제형 컬럼 제거

- SUNG_CODE 기반 단위 자동 판별 (정/캡슐/mL/포 등)
- 제형 컬럼 제거, 용량에 단위 직접 표시 (예: 1정, 0.5mL)
- previewLabels() 셀 인덱스 수정
This commit is contained in:
thug0bin 2026-03-11 22:00:45 +09:00
parent 80b3919ac9
commit 849ce4c3c0
2 changed files with 17 additions and 14 deletions

View File

@ -11,6 +11,7 @@ from PIL import Image, ImageDraw, ImageFont
import io import io
import base64 import base64
import os import os
from utils.drug_unit import get_drug_unit
pmr_bp = Blueprint('pmr', __name__, url_prefix='/pmr') 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, '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, 'type': '급여' if row.PS_Type in ['0', '4'] else '비급여' if row.PS_Type == '1' else row.PS_Type,
'sung_code': row.SUNG_CODE or '', 'sung_code': row.SUNG_CODE or '',
'unit': get_drug_unit(row.GoodsName or '', row.SUNG_CODE or ''),
'ps_type': row.PS_Type or '0', 'ps_type': row.PS_Type or '0',
'unit_code': unit_code, 'unit_code': unit_code,
'is_substituted': is_substituted, 'is_substituted': is_substituted,

View File

@ -1555,7 +1555,6 @@
<tr> <tr>
<th style="width:40px;"><input type="checkbox" id="checkAll" onchange="toggleAll(this)"></th> <th style="width:40px;"><input type="checkbox" id="checkAll" onchange="toggleAll(this)"></th>
<th>약품명</th> <th>약품명</th>
<th>제형</th>
<th>용량</th> <th>용량</th>
<th>횟수</th> <th>횟수</th>
<th>일수</th> <th>일수</th>
@ -1563,7 +1562,7 @@
</thead> </thead>
<tbody> <tbody>
${data.medications.map((m, i) => ` ${data.medications.map((m, i) => `
<tr data-add-info="${escapeHtml(m.add_info || '')}" ${m.is_substituted ? 'class="substituted-row"' : ''}> <tr data-add-info="${escapeHtml(m.add_info || '')}" data-unit="${m.unit || '정'}" ${m.is_substituted ? 'class="substituted-row"' : ''}>
<td><input type="checkbox" class="med-check" data-code="${m.medication_code}" ${m.is_auto_print ? 'checked' : ''}></td> <td><input type="checkbox" class="med-check" data-code="${m.medication_code}" ${m.is_auto_print ? 'checked' : ''}></td>
<td> <td>
<div class="med-name"> <div class="med-name">
@ -1581,8 +1580,7 @@
</details> </details>
` : ''} ` : ''}
</td> </td>
<td>${m.formulation ? `<span class="med-form">${m.formulation}</span>` : '-'}</td> <td><span class="med-dosage">${m.dosage || '-'}${m.unit || '정'}</span></td>
<td><span class="med-dosage">${m.dosage || '-'}</span></td>
<td>${m.frequency || '-'}회</td> <td>${m.frequency || '-'}회</td>
<td>${m.duration || '-'}일</td> <td>${m.duration || '-'}일</td>
</tr> </tr>
@ -1821,7 +1819,7 @@
const disabled = m.status === 'removed' ? 'disabled' : ''; const disabled = m.status === 'removed' ? 'disabled' : '';
return ` return `
<tr class="${rowClass}" data-add-info="${escapeHtml(m.add_info || '')}"> <tr class="${rowClass}" data-add-info="${escapeHtml(m.add_info || '')}" data-unit="${m.unit || '정'}">
<td><input type="checkbox" class="med-check" data-code="${m.medication_code}" ${disabled}></td> <td><input type="checkbox" class="med-check" data-code="${m.medication_code}" ${disabled}></td>
<td> <td>
<div class="med-name"><span class="med-num">${i+1}</span>${m.med_name || m.medication_code}</div> <div class="med-name"><span class="med-num">${i+1}</span>${m.med_name || m.medication_code}</div>
@ -1859,7 +1857,7 @@
</thead> </thead>
<tbody> <tbody>
${currentMedications.map((m, i) => ` ${currentMedications.map((m, i) => `
<tr data-add-info="${escapeHtml(m.add_info || '')}"> <tr data-add-info="${escapeHtml(m.add_info || '')}" data-unit="${m.unit || '정'}">
<td><input type="checkbox" class="med-check" data-code="${m.medication_code}"></td> <td><input type="checkbox" class="med-check" data-code="${m.medication_code}"></td>
<td> <td>
<div class="med-name"><span class="med-num">${i+1}</span>${m.med_name || m.medication_code}</div> <div class="med-name"><span class="med-num">${i+1}</span>${m.med_name || m.medication_code}</div>
@ -2605,17 +2603,20 @@
// 약품명: 두 번째 셀의 .med-name // 약품명: 두 번째 셀의 .med-name
const medName = tr.querySelector('.med-name')?.textContent?.trim() || ''; const medName = tr.querySelector('.med-name')?.textContent?.trim() || '';
const addInfo = tr.dataset.addInfo || ''; const addInfo = tr.dataset.addInfo || '';
// 용량: 네 번째 셀 (index 3) // 용량: 세 번째 셀 (index 2) - 제형 컬럼 제거됨
const dosageText = cells[3]?.textContent?.replace(/[^0-9.]/g, '') || '0'; const dosageText = cells[2]?.textContent?.replace(/[^0-9.]/g, '') || '0';
const dosage = parseFloat(dosageText) || 0; const dosage = parseFloat(dosageText) || 0;
// 횟수: 다섯 번째 셀 (index 4) // 횟수: 네 번째 셀 (index 3)
const freqText = cells[4]?.textContent?.replace(/[^0-9]/g, '') || '0'; const freqText = cells[3]?.textContent?.replace(/[^0-9]/g, '') || '0';
const frequency = parseInt(freqText) || 0; const frequency = parseInt(freqText) || 0;
// 일수: 여섯 번째 셀 (index 5) // 일수: 다섯 번째 셀 (index 4)
const durText = cells[5]?.textContent?.replace(/[^0-9]/g, '') || '0'; const durText = cells[4]?.textContent?.replace(/[^0-9]/g, '') || '0';
const duration = parseInt(durText) || 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 { try {
const res = await fetch('/pmr/api/label/preview', { const res = await fetch('/pmr/api/label/preview', {
@ -2628,7 +2629,7 @@
dosage: dosage, dosage: dosage,
frequency: frequency, frequency: frequency,
duration: duration, duration: duration,
unit: '정' unit: unit
}) })
}); });
const data = await res.json(); const data = await res.json();