feat(pmr): 라벨 단위 정규화 + 제형 컬럼 제거
- SUNG_CODE 기반 단위 자동 판별 (정/캡슐/mL/포 등) - 제형 컬럼 제거, 용량에 단위 직접 표시 (예: 1정, 0.5mL) - previewLabels() 셀 인덱스 수정
This commit is contained in:
parent
80b3919ac9
commit
849ce4c3c0
@ -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,
|
||||
|
||||
@ -1555,7 +1555,6 @@
|
||||
<tr>
|
||||
<th style="width:40px;"><input type="checkbox" id="checkAll" onchange="toggleAll(this)"></th>
|
||||
<th>약품명</th>
|
||||
<th>제형</th>
|
||||
<th>용량</th>
|
||||
<th>횟수</th>
|
||||
<th>일수</th>
|
||||
@ -1563,7 +1562,7 @@
|
||||
</thead>
|
||||
<tbody>
|
||||
${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>
|
||||
<div class="med-name">
|
||||
@ -1581,8 +1580,7 @@
|
||||
</details>
|
||||
` : ''}
|
||||
</td>
|
||||
<td>${m.formulation ? `<span class="med-form">${m.formulation}</span>` : '-'}</td>
|
||||
<td><span class="med-dosage">${m.dosage || '-'}</span></td>
|
||||
<td><span class="med-dosage">${m.dosage || '-'}${m.unit || '정'}</span></td>
|
||||
<td>${m.frequency || '-'}회</td>
|
||||
<td>${m.duration || '-'}일</td>
|
||||
</tr>
|
||||
@ -1821,7 +1819,7 @@
|
||||
const disabled = m.status === 'removed' ? 'disabled' : '';
|
||||
|
||||
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>
|
||||
<div class="med-name"><span class="med-num">${i+1}</span>${m.med_name || m.medication_code}</div>
|
||||
@ -1859,7 +1857,7 @@
|
||||
</thead>
|
||||
<tbody>
|
||||
${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>
|
||||
<div class="med-name"><span class="med-num">${i+1}</span>${m.med_name || m.medication_code}</div>
|
||||
@ -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();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user