feat: PMR 효능효과(add_info) 추가
- CD_MC.PRINT_TYPE JOIN으로 효능 조회 - 약품 테이블에 효능 표시 - 라벨 미리보기에 효능 포함
This commit is contained in:
@@ -316,6 +316,14 @@
|
||||
<script>
|
||||
let currentPrescriptionId = null;
|
||||
|
||||
// HTML 이스케이프
|
||||
function escapeHtml(text) {
|
||||
if (!text) return '';
|
||||
const div = document.createElement('div');
|
||||
div.textContent = text;
|
||||
return div.innerHTML;
|
||||
}
|
||||
|
||||
// 초기화
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const today = new Date().toISOString().split('T')[0];
|
||||
@@ -429,11 +437,12 @@
|
||||
</thead>
|
||||
<tbody>
|
||||
${data.medications.map(m => `
|
||||
<tr>
|
||||
<tr data-add-info="${escapeHtml(m.add_info || '')}">
|
||||
<td><input type="checkbox" class="med-check" data-code="${m.medication_code}" ${m.is_auto_print ? 'checked' : ''}></td>
|
||||
<td>
|
||||
<div class="med-name">${m.med_name || m.medication_code}</div>
|
||||
<div class="med-code">${m.medication_code}</div>
|
||||
${m.add_info ? `<div style="font-size:0.75rem;color:#6b7280;">${escapeHtml(m.add_info)}</div>` : ''}
|
||||
</td>
|
||||
<td>${m.formulation ? `<span class="med-form">${m.formulation}</span>` : '-'}</td>
|
||||
<td><span class="med-dosage">${m.dosage || '-'}</span></td>
|
||||
@@ -481,8 +490,8 @@
|
||||
|
||||
// 라벨 미리보기
|
||||
async function previewLabels() {
|
||||
const rows = document.querySelectorAll('.med-check:checked');
|
||||
if (rows.length === 0) {
|
||||
const checkboxes = document.querySelectorAll('.med-check:checked');
|
||||
if (checkboxes.length === 0) {
|
||||
alert('미리보기할 약품을 선택하세요');
|
||||
return;
|
||||
}
|
||||
@@ -496,12 +505,24 @@
|
||||
|
||||
container.innerHTML = '';
|
||||
|
||||
for (const checkbox of rows) {
|
||||
for (const checkbox of checkboxes) {
|
||||
const tr = checkbox.closest('tr');
|
||||
const medName = tr.querySelector('.med-name')?.textContent || '';
|
||||
const dosage = parseFloat(tr.cells[3]?.querySelector('.med-dosage')?.textContent) || 0;
|
||||
const frequency = parseInt(tr.cells[4]?.textContent) || 0;
|
||||
const duration = parseInt(tr.cells[5]?.textContent) || 0;
|
||||
const cells = tr.querySelectorAll('td');
|
||||
|
||||
// 약품명: 두 번째 셀의 .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';
|
||||
const dosage = parseFloat(dosageText) || 0;
|
||||
// 횟수: 다섯 번째 셀 (index 4)
|
||||
const freqText = cells[4]?.textContent?.replace(/[^0-9]/g, '') || '0';
|
||||
const frequency = parseInt(freqText) || 0;
|
||||
// 일수: 여섯 번째 셀 (index 5)
|
||||
const durText = cells[5]?.textContent?.replace(/[^0-9]/g, '') || '0';
|
||||
const duration = parseInt(durText) || 0;
|
||||
|
||||
console.log('Preview data:', { patientName, medName, addInfo, dosage, frequency, duration });
|
||||
|
||||
try {
|
||||
const res = await fetch('/pmr/api/label/preview', {
|
||||
@@ -510,6 +531,7 @@
|
||||
body: JSON.stringify({
|
||||
patient_name: patientName,
|
||||
med_name: medName,
|
||||
add_info: addInfo,
|
||||
dosage: dosage,
|
||||
frequency: frequency,
|
||||
duration: duration,
|
||||
@@ -517,12 +539,15 @@
|
||||
})
|
||||
});
|
||||
const data = await res.json();
|
||||
console.log('Preview response:', data.success, data.error);
|
||||
|
||||
if (data.success) {
|
||||
if (data.success && data.image) {
|
||||
const img = document.createElement('img');
|
||||
img.src = data.image;
|
||||
img.style.cssText = 'max-width:100%;border:1px solid #ddd;border-radius:8px;';
|
||||
container.appendChild(img);
|
||||
} else {
|
||||
console.error('Preview failed:', data.error);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Preview error:', err);
|
||||
@@ -530,7 +555,7 @@
|
||||
}
|
||||
|
||||
if (container.children.length === 0) {
|
||||
container.innerHTML = '<p style="color:#999;">미리보기 생성 실패</p>';
|
||||
container.innerHTML = '<p style="color:#999;">미리보기 생성 실패 - 콘솔(F12) 확인</p>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user