feat: Phase 2 - 성분코드 기반 투약주기/병용약 JOIN 구현
- component_guide 테이블 생성 (PostgreSQL) - IC2030126 (메벤다졸+프라지퀸텔) 샘플 데이터 입력 - 미리보기 API: apc + component_guide LEFT JOIN - 모달에 투약주기, 병용약 섹션 추가 (보라색/녹색 강조)
This commit is contained in:
@@ -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
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user