feat: Phase 2 - 성분코드 기반 투약주기/병용약 JOIN 구현

- component_guide 테이블 생성 (PostgreSQL)
- IC2030126 (메벤다졸+프라지퀸텔) 샘플 데이터 입력
- 미리보기 API: apc + component_guide LEFT JOIN
- 모달에 투약주기, 병용약 섹션 추가 (보라색/녹색 강조)
This commit is contained in:
thug0bin 2026-03-04 20:44:37 +09:00
parent 4352a8b9a8
commit 9ff25dcbce
2 changed files with 46 additions and 9 deletions

View File

@ -6636,14 +6636,22 @@ def api_animal_drug_info_preview():
with pg_engine.connect() as conn:
result = conn.execute(text("""
SELECT
product_name,
company_name,
main_ingredient,
efficacy_effect,
dosage_instructions,
precautions
FROM apc
WHERE apc = :apc
a.product_name,
a.company_name,
a.main_ingredient,
a.efficacy_effect,
a.dosage_instructions,
a.precautions,
a.component_code,
g.component_name_ko,
g.dosing_interval_adult,
g.dosing_interval_high_risk,
g.dosing_interval_puppy,
g.companion_drugs,
g.contraindication as guide_contraindication
FROM apc a
LEFT JOIN component_guide g ON a.component_code = g.component_code
WHERE a.apc = :apc
LIMIT 1
"""), {'apc': apc})
row = result.fetchone()
@ -6673,6 +6681,17 @@ def api_animal_drug_info_preview():
text = re.sub(r'\s+(\d+)\)\s*', r'\n \1) ', text)
return text.strip()
# 투약주기 조합
dosing_interval = None
if row.dosing_interval_adult:
parts = []
parts.append(f"일반: {row.dosing_interval_adult}")
if row.dosing_interval_high_risk:
parts.append(f"고위험: {row.dosing_interval_high_risk}")
if row.dosing_interval_puppy:
parts.append(f"새끼: {row.dosing_interval_puppy}")
dosing_interval = '\n'.join(parts)
return jsonify({
'success': True,
'data': {
@ -6681,7 +6700,13 @@ def api_animal_drug_info_preview():
'main_ingredient': row.main_ingredient if row.main_ingredient != 'NaN' else None,
'efficacy_effect': format_items(strip_html(row.efficacy_effect)),
'dosage_instructions': format_items(strip_html(row.dosage_instructions)),
'precautions': format_items(strip_html(row.precautions))
'precautions': format_items(strip_html(row.precautions)),
# 성분 가이드 (component_guide JOIN)
'component_code': row.component_code,
'component_name': row.component_name_ko,
'dosing_interval': dosing_interval,
'companion_drugs': row.companion_drugs,
'guide_contraindication': row.guide_contraindication
}
})

View File

@ -1165,6 +1165,18 @@
<p style="margin:0;font-size:13px;line-height:1.7;color:#334155;white-space:pre-line;">${escapeHtml(info.precautions.substring(0, 800))}${info.precautions.length > 800 ? '...' : ''}</p>
</div>` : ''}
${info.dosing_interval ? `
<div style="margin-bottom:12px;background:#faf5ff;padding:12px;border-radius:8px;border:2px solid #c084fc;">
<h5 style="margin:0 0 6px;color:#7c3aed;">▶ 투약 주기 ⭐</h5>
<p style="margin:0;font-size:13px;line-height:1.7;color:#334155;white-space:pre-line;">${escapeHtml(info.dosing_interval)}</p>
</div>` : ''}
${info.companion_drugs ? `
<div style="margin-bottom:12px;background:#ecfdf5;padding:12px;border-radius:8px;border:2px solid #34d399;">
<h5 style="margin:0 0 6px;color:#059669;">▶ 함께 투약 권장 💊</h5>
<p style="margin:0;font-size:13px;line-height:1.7;color:#334155;">${escapeHtml(info.companion_drugs)}</p>
</div>` : ''}
<div style="display:flex;gap:10px;margin-top:20px;">
<button onclick="document.getElementById('animalDrugModal').remove()"
style="flex:1;padding:10px;border:1px solid #e2e8f0;background:#fff;border-radius:6px;cursor:pointer;">닫기</button>