kdrug-inventory-system/test_custom_prescription.html
시골약사 1441c01fb4 feat: 실시간 커스텀 처방(가감방) 감지 시스템 구현
- 프론트엔드: 조제 시 실시간 커스텀 처방 감지
  - 처방 선택 시 원래 구성 약재 저장
  - 약재 추가/삭제/변경 시 즉시 감지
  - 가감방 뱃지 및 변경 내용 표시

- 백엔드: 커스텀 처방 자동 감지 및 저장
  - compounds 테이블에 커스텀 관련 필드 추가
  - 조제 시 원 처방과 비교하여 변경사항 자동 감지
  - 커스텀 처방 정보 저장 (추가/제거/변경된 약재)

- 환자 조제 내역에 커스텀 처방 표시
  - 가감방 뱃지 표시
  - 변경 내용 상세 표시

- DB 마이그레이션 스크립트 추가
  - is_custom, custom_summary, custom_type 필드 추가
  - compound_ingredients에 modification_type, original_grams 필드 추가

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-02-17 01:28:44 +00:00

128 lines
5.2 KiB
HTML

<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<title>커스텀 처방 실시간 감지 테스트</title>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<style>
body { font-family: sans-serif; margin: 20px; }
.container { max-width: 800px; margin: auto; }
.badge { padding: 2px 8px; border-radius: 4px; color: white; }
.bg-warning { background-color: #ffc107; color: #333; }
.alert { padding: 10px; margin-top: 10px; border-radius: 4px; }
.alert-warning { background-color: #fff3cd; border: 1px solid #ffeaa7; }
</style>
</head>
<body>
<div class="container">
<h1>커스텀 처방 감지 테스트</h1>
<div style="margin: 20px 0;">
<h3>시나리오:</h3>
<p>십전대보탕을 선택한 후, 약재를 추가/삭제/변경하면 "가감방" 표시가 나타납니다.</p>
</div>
<div id="testResult" style="margin-top: 20px; padding: 20px; border: 1px solid #ddd;">
<h3>테스트 결과:</h3>
<div id="resultContent">테스트를 시작하려면 페이지를 새로고침하세요.</div>
</div>
</div>
<script>
// 원래 처방 구성 저장용 변수
let originalFormulaIngredients = {};
// 테스트 시나리오
function runTest() {
const results = [];
// 1. 십전대보탕 원래 구성 저장
originalFormulaIngredients = {
'3052A12AM': { herb_name: '감초', grams_per_cheop: 1.5 },
'3047A10AM': { herb_name: '당귀', grams_per_cheop: 3.0 },
'3065A10AM': { herb_name: '백출', grams_per_cheop: 3.0 },
'3064B19AM': { herb_name: '백작약', grams_per_cheop: 3.0 },
'3073B11AM': { herb_name: '숙지황', grams_per_cheop: 3.0 },
'3054A14AM': { herb_name: '인삼', grams_per_cheop: 3.0 },
'3072A17AM': { herb_name: '천궁', grams_per_cheop: 3.0 },
'3056A18AM': { herb_name: '황기', grams_per_cheop: 3.0 },
'3063A18AM': { herb_name: '백복령', grams_per_cheop: 3.0 },
'3055A13AM': { herb_name: '육계', grams_per_cheop: 1.5 }
};
// 2. 현재 약재 구성 (구기자 추가)
const currentIngredients = {
'3052A12AM': 1.5, // 감초
'3047A10AM': 3.0, // 당귀
'3065A10AM': 3.0, // 백출
'3064B19AM': 3.0, // 백작약
'3073B11AM': 3.0, // 숙지황
'3054A14AM': 3.0, // 인삼
'3072A17AM': 3.0, // 천궁
'3056A18AM': 3.0, // 황기
'3063A18AM': 3.0, // 백복령
'3055A13AM': 1.5, // 육계
'3147H1AHM': 3.0 // 구기자 (추가)
};
// 3. 커스텀 감지 로직
const customDetails = [];
let isCustom = false;
// 추가된 약재 확인
for (const code in currentIngredients) {
if (!originalFormulaIngredients[code]) {
customDetails.push(`구기자 ${currentIngredients[code]}g 추가`);
isCustom = true;
}
}
// 삭제된 약재 확인
for (const code in originalFormulaIngredients) {
if (!currentIngredients[code]) {
customDetails.push(`${originalFormulaIngredients[code].herb_name} 제거`);
isCustom = true;
}
}
// 용량 변경된 약재 확인
for (const code in currentIngredients) {
if (originalFormulaIngredients[code]) {
const originalGrams = originalFormulaIngredients[code].grams_per_cheop;
const currentGrams = currentIngredients[code];
if (Math.abs(originalGrams - currentGrams) > 0.01) {
const herbName = originalFormulaIngredients[code].herb_name;
customDetails.push(`${herbName} ${originalGrams}g→${currentGrams}g`);
isCustom = true;
}
}
}
// 4. 결과 표시
if (isCustom) {
const badgeHtml = `
<div class="alert alert-warning">
<span class="badge bg-warning">가감방</span>
<small style="margin-left: 10px;">${customDetails.join(' | ')}</small>
</div>
`;
$('#resultContent').html(`
<p><strong>✅ 테스트 성공!</strong></p>
<p>십전대보탕에 구기자 3g를 추가한 경우:</p>
${badgeHtml}
<p style="margin-top: 10px;">커스텀 처방이 정상적으로 감지되었습니다.</p>
`);
} else {
$('#resultContent').html('<p>❌ 커스텀 처방이 감지되지 않았습니다.</p>');
}
}
// 페이지 로드 시 테스트 실행
$(document).ready(function() {
runTest();
});
</script>
</body>
</html>