diff --git a/backend/pmr_api.py b/backend/pmr_api.py index d806c78..2573292 100644 --- a/backend/pmr_api.py +++ b/backend/pmr_api.py @@ -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 '- 정보 없음'} diff --git a/backend/templates/pmr.html b/backend/templates/pmr.html index c469db3..bfe799b 100644 --- a/backend/templates/pmr.html +++ b/backend/templates/pmr.html @@ -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 || '',