제04장: 우울증 탐지 - WIA-MENTAL-003

弘益人間 · 널리 인간을 이롭게 하라

API 사양 및 데이터 모델

제4장에서는 WIA-MENTAL-003 표준의 API 사양과 데이터 모델을 상세히 다룹니다. 우울증 감지 시스템의 성공적인 구현은 잘 정의된 API와 표준화된 데이터 형식에 달려 있습니다. 이 장에서는 다양한 시스템 구성 요소 간의 통신을 가능하게 하는 RESTful API 엔드포인트, 데이터 스키마, 보안 메커니즘을 포괄적으로 설명합니다.

핵심 API 엔드포인트

WIA-MENTAL-003 표준은 우울증 감지 시스템의 다양한 측면을 처리하기 위한 포괄적인 API 엔드포인트 세트를 정의합니다:

엔드포인트HTTP 메서드기능인증
/api/v1/assessments/depressionPOST, GET우울증 평가 제출 및 조회OAuth 2.0
/api/v1/biomarkers/collectPOST디지털 바이오마커 데이터 수집Bearer Token
/api/v1/predictions/riskPOST우울증 위험 예측 요청OAuth 2.0
/api/v1/patients/{id}/timelineGET환자의 시간 경과 데이터 조회RBAC
/api/v1/interventions/recommendPOST개입 권장사항 생성Clinical Role
/api/v1/reports/generatePOST임상 보고서 생성OAuth 2.0

우울증 평가 API

우울증 평가 API는 PHQ-9, BDI-II, MADRS 등 다양한 표준화된 평가 도구의 결과를 제출하고 조회할 수 있게 합니다:

// 우울증 평가 제출 API
POST /api/v1/assessments/depression
Authorization: Bearer {access_token}
Content-Type: application/json

{
  "resourceType": "MentalHealth.DepressionAssessment",
  "patient": {
    "id": "patient-12345",
    "reference": "Patient/12345"
  },
  "assessment": {
    "type": "PHQ-9",
    "version": "1.0",
    "date": "2025-12-28T14:30:00Z",
    "administeredBy": {
      "type": "self",
      "clinicianId": null
    }
  },
  "responses": [
    {
      "questionId": "phq9_q1",
      "questionText": "Little interest or pleasure in doing things",
      "score": 2,
      "answer": "More than half the days"
    },
    {
      "questionId": "phq9_q2",
      "questionText": "Feeling down, depressed, or hopeless",
      "score": 2,
      "answer": "More than half the days"
    },
    {
      "questionId": "phq9_q3",
      "questionText": "Trouble falling/staying asleep, or sleeping too much",
      "score": 3,
      "answer": "Nearly every day"
    },
    {
      "questionId": "phq9_q4",
      "questionText": "Feeling tired or having little energy",
      "score": 3,
      "answer": "Nearly every day"
    },
    {
      "questionId": "phq9_q5",
      "questionText": "Poor appetite or overeating",
      "score": 1,
      "answer": "Several days"
    },
    {
      "questionId": "phq9_q6",
      "questionText": "Feeling bad about yourself",
      "score": 2,
      "answer": "More than half the days"
    },
    {
      "questionId": "phq9_q7",
      "questionText": "Trouble concentrating on things",
      "score": 1,
      "answer": "Several days"
    },
    {
      "questionId": "phq9_q8",
      "questionText": "Moving or speaking slowly/being fidgety",
      "score": 0,
      "answer": "Not at all"
    },
    {
      "questionId": "phq9_q9",
      "questionText": "Thoughts of being better off dead or hurting yourself",
      "score": 1,
      "answer": "Several days"
    }
  ],
  "scoring": {
    "totalScore": 15,
    "maxScore": 27,
    "severity": "moderately_severe",
    "interpretation": "Moderately severe depression (15-19)",
    "suicidalIdeation": {
      "present": true,
      "score": 1,
      "requiresImmediateAttention": true
    }
  },
  "functionalImpairment": {
    "questionText": "If you checked off any problems, how difficult have these made it for you to do your work, take care of things at home, or get along with other people?",
    "answer": "Very difficult",
    "score": 3
  },
  "metadata": {
    "deviceId": "mobile-app-ios-001",
    "appVersion": "2.1.4",
    "locale": "ko-KR",
    "timezone": "Asia/Seoul",
    "completionTime": 185
  }
}

// 응답
{
  "status": "success",
  "assessmentId": "assess-789456",
  "timestamp": "2025-12-28T14:32:15Z",
  "alerts": [
    {
      "type": "suicidal_ideation",
      "severity": "high",
      "message": "Patient reported thoughts of self-harm. Immediate clinical follow-up recommended.",
      "actionRequired": true,
      "recommendedActions": [
        "Contact patient within 24 hours",
        "Assess suicide risk using Columbia Scale",
        "Consider crisis intervention referral"
      ]
    },
    {
      "type": "severity_increase",
      "severity": "moderate",
      "message": "PHQ-9 score increased from 10 to 15 (50% increase) since last assessment.",
      "actionRequired": true
    }
  ],
  "nextAssessment": {
    "recommendedDate": "2026-01-04",
    "reason": "Moderately severe depression requires weekly monitoring"
  }
}

위험 예측 API

위험 예측 API는 디지털 바이오마커와 임상 데이터를 결합하여 우울증 악화 또는 재발 위험을 예측합니다:

// 우울증 위험 예측 요청
POST /api/v1/predictions/risk
Authorization: Bearer {access_token}
Content-Type: application/json

{
  "patientId": "patient-12345",
  "predictionType": "depression_onset",
  "timeWindow": "30_days",
  "dataSource": {
    "includeBiomarkers": true,
    "includeClinicalHistory": true,
    "includeSelfReports": true
  },
  "features": {
    "recentAssessments": [
      {
        "date": "2025-12-28",
        "type": "PHQ-9",
        "score": 15
      },
      {
        "date": "2025-12-21",
        "type": "PHQ-9",
        "score": 12
      },
      {
        "date": "2025-12-14",
        "type": "PHQ-9",
        "score": 10
      }
    ],
    "biomarkers": {
      "activity": {
        "avgDailySteps": 3200,
        "trend": "declining",
        "changeRate": -0.18
      },
      "sleep": {
        "avgDuration": 5.1,
        "avgEfficiency": 0.71,
        "irregularity": 1.8
      },
      "social": {
        "interactionFrequency": 8,
        "trend": "declining",
        "isolationScore": 0.68
      }
    },
    "clinicalHistory": {
      "previousEpisodes": 2,
      "treatmentHistory": "SSRI medication",
      "comorbidities": ["anxiety", "insomnia"]
    }
  }
}

// 응답
{
  "predictionId": "pred-456789",
  "timestamp": "2025-12-28T14:35:00Z",
  "prediction": {
    "riskLevel": "high",
    "riskScore": 0.76,
    "confidence": 0.88,
    "timeWindow": "30_days",
    "interpretation": "76% probability of significant depression worsening within 30 days"
  },
  "contributingFactors": [
    {
      "factor": "increasing_phq9_trend",
      "importance": 0.32,
      "description": "PHQ-9 scores showing consistent upward trend"
    },
    {
      "factor": "poor_sleep_quality",
      "importance": 0.24,
      "description": "Sleep efficiency below 75% with high variability"
    },
    {
      "factor": "social_withdrawal",
      "importance": 0.19,
      "description": "Social interactions decreased by 45% in past 2 weeks"
    },
    {
      "factor": "reduced_activity",
      "importance": 0.15,
      "description": "Daily step count 40% below baseline"
    },
    {
      "factor": "previous_episodes",
      "importance": 0.10,
      "description": "History of 2 previous depressive episodes"
    }
  ],
  "recommendations": {
    "clinical": [
      "Schedule urgent psychiatric evaluation",
      "Consider medication adjustment",
      "Increase therapy session frequency to weekly"
    ],
    "behavioral": [
      "Sleep hygiene intervention",
      "Behavioral activation therapy",
      "Social engagement support"
    ],
    "monitoring": [
      "Increase PHQ-9 frequency to weekly",
      "Daily mood tracking via app",
      "Weekly clinician check-ins"
    ]
  },
  "modelInfo": {
    "modelType": "gradient_boosting",
    "modelVersion": "2.3.1",
    "trainingData": "50,000 patients, 2019-2024",
    "validationAUC": 0.89
  }
}

데이터 보안 및 프라이버시

WIA-MENTAL-003 표준은 우울증 데이터의 민감성을 고려하여 엄격한 보안 및 프라이버시 요구사항을 명시합니다:

보안 요소요구사항구현 방법규정 준수
데이터 암호화 저장 시 AES-256, 전송 시 TLS 1.3+ 암호화 라이브러리, HTTPS HIPAA, GDPR
접근 제어 역할 기반 접근 제어 (RBAC) OAuth 2.0, JWT 토큰 HIPAA
감사 로깅 모든 데이터 접근 기록 중앙집중식 로그 시스템 HIPAA, SOC 2
데이터 최소화 필요한 데이터만 수집 명시적 동의, 목적 제한 GDPR
익명화 연구용 데이터 익명화 차등 프라이버시, K-익명성 GDPR, IRB
삭제 권리 사용자 데이터 삭제 요청 처리 자동화된 삭제 프로세스 GDPR Article 17
// 데이터 접근 제어 예시 (Node.js/Express)
const express = require('express');
const jwt = require('jsonwebtoken');

// 역할 기반 접근 제어 미들웨어
function requireRole(allowedRoles) {
  return (req, res, next) => {
    const token = req.headers.authorization?.split(' ')[1];

    if (!token) {
      return res.status(401).json({ error: 'No token provided' });
    }

    try {
      const decoded = jwt.verify(token, process.env.JWT_SECRET);
      const userRole = decoded.role;

      if (!allowedRoles.includes(userRole)) {
        return res.status(403).json({
          error: 'Insufficient permissions',
          required: allowedRoles,
          current: userRole
        });
      }

      req.user = decoded;
      next();
    } catch (error) {
      return res.status(401).json({ error: 'Invalid token' });
    }
  };
}

// 환자 자신의 데이터만 접근 가능
function requireOwnerOrClinician(req, res, next) {
  const requestedPatientId = req.params.patientId;
  const userId = req.user.userId;
  const userRole = req.user.role;

  if (userRole === 'clinician' || userRole === 'admin') {
    // 임상의는 자신이 담당하는 환자 데이터에 접근 가능
    // 실제 구현에서는 담당 환자 목록 확인 필요
    return next();
  }

  if (userId !== requestedPatientId) {
    return res.status(403).json({
      error: 'Cannot access other patient data'
    });
  }

  next();
}

// API 라우트 예시
const app = express();

// 환자 본인 또는 임상의만 접근 가능
app.get('/api/v1/patients/:patientId/assessments',
  requireRole(['patient', 'clinician', 'admin']),
  requireOwnerOrClinician,
  async (req, res) => {
    // 평가 데이터 조회 로직
  }
);

// 임상의만 위험 예측 요청 가능
app.post('/api/v1/predictions/risk',
  requireRole(['clinician', 'admin']),
  async (req, res) => {
    // 위험 예측 로직
  }
);

// 감사 로깅 미들웨어
app.use((req, res, next) => {
  const auditLog = {
    timestamp: new Date().toISOString(),
    userId: req.user?.userId,
    userRole: req.user?.role,
    action: `${req.method} ${req.path}`,
    ipAddress: req.ip,
    userAgent: req.get('user-agent')
  };

  // 감사 로그 저장
  saveAuditLog(auditLog);
  next();
});

기술 구현

성공적인 우울증 탐지 시스템은 다음을 통합합니다:

임상 증거

연구는 AI 기반 우울증 탐지의 효과를 입증합니다:

윤리적 고려 사항

책임 있는 AI 배포는 다음을 요구합니다:

弘益人間 (홍익인간)

"널리 인간을 이롭게 하라"

우울증 탐지 기술은 정신 건강 관리를 민주화하고, 전 세계 소외된 인구에게 증거 기반 검사를 제공하며, 조기 개입을 통해 고통을 줄이고 생명을 구함으로써 弘益人間의 원칙을 구현합니다. 우리의 목표는 지리적 위치, 경제적 지위 또는 전통적인 의료 자원에 대한 접근과 관계없이 모든 인류에게 혜택을 주는 것입니다.

실제 응용

우울증 탐지 시스템은 다양한 환경에서 배포됩니다:

미래 방향

우울증 탐지 기술의 미래는 다음을 포함합니다:

핵심 요약

  1. AI 기반 우울증 탐지는 85-92%의 민감도로 임상적으로 의미 있는 정확도를 달성합니다
  2. 디지털 바이오마커는 전통적인 평가로는 불가능한 연속적이고 객관적인 모니터링을 가능하게 합니다
  3. 여러 데이터 양식을 결합하면 단일 양식 접근 방식보다 18-24% 정확도가 향상됩니다
  4. 개인정보 보호 및 윤리적 고려 사항은 임상 효과만큼 중요합니다
  5. 성공적인 배포는 기존 임상 워크플로우 및 EHR 시스템과의 통합이 필요합니다
  6. 임상 검증 및 규제 승인은 의료 환경에서 배포하기 전에 필수적입니다
  7. 弘益人間의 원칙은 전 세계적으로 공평한 접근과 인류 전체에 대한 혜택을 요구합니다

복습 질문

  1. 이 장에서 다룬 주요 기술 구성 요소는 무엇입니까?
  2. AI 기반 우울증 탐지의 임상 증거는 무엇을 보여줍니까?
  3. 책임 있는 AI 배포를 위한 주요 윤리적 고려 사항은 무엇입니까?
  4. 다중 모드 데이터 통합이 단일 모드 접근 방식보다 어떻게 성능을 향상시킵니까?
  5. 弘益人間의 원칙이 우울증 탐지 기술에 어떻게 적용됩니까?
  6. 우울증 탐지 시스템의 미래 방향은 무엇입니까?