From 7ac3f7a8b44febee96c16c9fcb4342df1f972def Mon Sep 17 00:00:00 2001 From: thug0bin Date: Thu, 5 Mar 2026 11:04:03 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20PAAI=20=EB=B6=84=EC=84=9D=EC=97=90=20?= =?UTF-8?q?=ED=99=98=EC=9E=90=20=ED=8A=B9=EC=9D=B4=EC=82=AC=ED=95=AD(CUSET?= =?UTF-8?q?C)=20=ED=8F=AC=ED=95=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 추가: - AI 프롬프트에 '환자 특이사항' 섹션 추가 - 알러지, 기저질환, 주의사항 등 약사가 입력한 메모 활용 - 예: '투석실 환자' → AI가 신장약물 주의사항 안내 변경 파일: - pmr_api.py: patient_note 파라미터 추가, build_paai_prompt 수정 - pmr.html: requestSnapshot에 patient_note 포함 - prescription_trigger.py: cusetc → patient_note 전달 효과: - 환자별 맞춤 복약 안내 품질 향상 - 알러지/금기 정보 반영으로 안전성 강화 --- backend/pmr_api.py | 13 +++++++++++-- backend/templates/pmr.html | 1 + 2 files changed, 12 insertions(+), 2 deletions(-) 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 || '',