feat(drug-usage): 단위 마스터 + 총사용량 표시 + 순차 API 호출

- drug_unit.py: SUNG_CODE 기반 단위 판별 함수 추가
- 조제 상세에 총사용량 + 단위 표시 (예: 1,230정)
- API 순차 호출로 DB 세션 충돌 방지
This commit is contained in:
thug0bin
2026-03-11 21:47:53 +09:00
parent 91f36273e9
commit 80b3919ac9
3 changed files with 198 additions and 7 deletions

View File

@@ -392,6 +392,16 @@
background: #fef3c7;
color: #92400e;
}
.usage-badge {
display: inline-block;
padding: 2px 10px;
font-size: 12px;
font-weight: 600;
background: linear-gradient(135deg, #10b981, #059669);
color: #fff;
border-radius: 12px;
margin-left: 8px;
}
.detail-table-wrapper {
max-height: 300px;
overflow-y: auto;
@@ -805,14 +815,13 @@
mainRow.classList.add('expanded');
expandedDrugCode = drugCode;
// 데이터 로드
// 데이터 로드 (순차 호출 - DB 세션 충돌 방지)
const startDate = document.getElementById('startDate').value.replace(/-/g, '');
const endDate = document.getElementById('endDate').value.replace(/-/g, '');
// 입고 데이터 로드
loadImports(drugCode, startDate, endDate);
// 조제 데이터 로드
loadPrescriptions(drugCode, startDate, endDate);
// 입고 데이터 로드 후 조제 데이터 로드 (순차)
await loadImports(drugCode, startDate, endDate);
await loadPrescriptions(drugCode, startDate, endDate);
}
// ═══ 입고 데이터 로드 ═══
@@ -901,8 +910,13 @@
).join('') + `<span class="patient-badge more">외 ${uniqueCount - 3}명</span>`;
}
// 총 사용량 + 단위
const totalUsage = data.total_usage || 0;
const unit = data.unit || '개';
const usageBadge = `<span class="usage-badge">${formatNumber(totalUsage)}${unit}</span>`;
container.innerHTML = `
<h4>💊 조제목록 <span class="count">(${data.total_count}건)</span> <span class="patient-info">${patientBadges}</span></h4>
<h4>💊 조제목록 <span class="count">(${data.total_count}건)</span> ${usageBadge} <span class="patient-info">${patientBadges}</span></h4>
<div class="detail-table-wrapper">
<table class="detail-table" style="table-layout:fixed;">
<colgroup>