fromopenaiimportOpenAIclient=OpenAI()defsummarize_session(deidentified_transcript:str)->str:returnclient.chat.completions.create(model="gpt-4o-mini",messages=[{"role":"system","content":"Summarize psychotherapy session: mood, themes, risk indicators. Do NOT speculate diagnosis."},{"role":"user","content":deidentified_transcript},],).choices[0].message.content
Digital phenotyping (passive sensing)
# smartphone sensor → depression risk signaldefcompute_phenotype(daily_log:dict)->dict:return{"sleep_irregularity":np.std(daily_log["sleep_onset_times"]),"social_withdrawal":daily_log["calls_outgoing"]/max(daily_log["calls_baseline"],1),"physical_activity":daily_log["steps"]/7000,# ratio of recommended"screen_time_night":daily_log["screen_min_after_22"],}
Risk triage (suicidality)
HIGH_RISK_KEYWORDS=["plan to","end my life","suicide","kill myself"]deftriage(text:str,phq9_q9:int)->str:ifphq9_q9>=2orany(kintext.lower()forkinHIGH_RISK_KEYWORDS):return"ESCALATE_CLINICIAN_NOW"return"ROUTINE_FOLLOWUP"
결정 기준
증상/상황
1차 접근
경증 우울 (PHQ-9 5-9)
심리치료 / digital CBT
중등도 이상 (PHQ-9 ≥10)
SSRI + 심리치료
정신증 양성증상
atypical antipsychotic
양극성 maintenance
lithium 또는 valproate
치료저항성 우울
rTMS / esketamine / ECT
급성 자살위기
응급실 + 입원 평가
기본값 (스크리닝): PHQ-9 + GAD-7 + suicidality probe. 양성 시 임상가 referral.