feat: PAAI 분석에 환자 특이사항(CUSETC) 포함

추가:
- AI 프롬프트에 '환자 특이사항' 섹션 추가
- 알러지, 기저질환, 주의사항 등 약사가 입력한 메모 활용
- 예: '투석실 환자' → AI가 신장약물 주의사항 안내

변경 파일:
- pmr_api.py: patient_note 파라미터 추가, build_paai_prompt 수정
- pmr.html: requestSnapshot에 patient_note 포함
- prescription_trigger.py: cusetc → patient_note 전달

효과:
- 환자별 맞춤 복약 안내 품질 향상
- 알러지/금기 정보 반영으로 안전성 강화
This commit is contained in:
thug0bin 2026-03-05 11:04:03 +09:00
parent cb90d4a7a6
commit 7ac3f7a8b4
2 changed files with 12 additions and 2 deletions

View File

@ -975,6 +975,7 @@ def paai_analyze():
pre_serial = data.get('pre_serial')
cus_code = data.get('cus_code')
patient_name = data.get('patient_name')
patient_note = data.get('patient_note', '') # 환자 특이사항 (알러지, 기저질환 등)
disease_info = data.get('disease_info', {})
current_medications = data.get('current_medications', [])
previous_serial = data.get('previous_serial')
@ -1056,7 +1057,8 @@ def paai_analyze():
current_medications=current_medications,
prescription_changes=prescription_changes,
kims_interactions=kims_interactions,
otc_history=otc_history
otc_history=otc_history,
patient_note=patient_note
)
# 5. Clawdbot AI 호출 (WebSocket)
@ -1146,7 +1148,8 @@ def build_paai_prompt(
current_medications: list,
prescription_changes: dict,
kims_interactions: list,
otc_history: dict
otc_history: dict,
patient_note: str = ''
) -> str:
"""AI 프롬프트 생성"""
@ -1194,11 +1197,17 @@ def build_paai_prompt(
for item in otc_history['frequent_items'][:5]:
otc_lines.append(f"- {item.get('name', '?')} ({item.get('count', 0)}회 구매)")
# 환자 특이사항 (알러지, 기저질환 등)
note_text = patient_note.strip() if patient_note else ''
prompt = f"""당신은 약사를 보조하는 AI입니다. 환자 정보와 KIMS 상호작용 데이터를 바탕으로 분석해주세요.
## 환자 질병
{chr(10).join(diseases) if diseases else '- 정보 없음'}
## 환자 특이사항 (알러지/기저질환/주의사항)
{note_text if note_text else '- 없음'}
## 현재 처방
{chr(10).join(med_lines) if med_lines else '- 정보 없음'}

View File

@ -1893,6 +1893,7 @@
pre_serial: preSerial,
cus_code: currentPrescriptionData.cus_code,
patient_name: patientName,
patient_note: currentPrescriptionData.cusetc || '', // 환자 특이사항 (알러지, 기저질환 등)
disease_info: {
code_1: currentPrescriptionData.st1 || '',
name_1: currentPrescriptionData.st1_name || '',