Skip to content

[BE] FastAPI 연동을 통한 요양기간 예측 기능 API 구현 #9

Description

@jiva-z

목적

  • AI 모델을 활용한 요양기간 예측 기능을 Spring Boot 애플리케이션에 통합
  • FastAPI 서버와의 연동을 통한 실시간 예측 서비스 제공
  • 진단명 검색 기능 구현

구현 내용

1. DTO 클래스 구현

  • PredictionRequestDto: 예측 요청 데이터 모델
    • disease (진단명)
    • sex (성별)
    • surgery (수술 여부)
    • age (연령대)
    • region (지역)
  • PredictionResponseDto: 예측 결과 응답 모델
    • predictedValue (예측된 요양기간)

2. FastAPI 연동 서비스 구현

  • WebClient 설정
  • 요양기간 예측 API 연동
  • 진단명 검색 API 연동
  • 예외 처리 및 로깅

3. REST API 엔드포인트 구현

  • POST /api/predictions: 요양기간 예측
  • GET /api/predictions/diagnoses: 진단명 검색

기술 스택

  • Spring Boot
  • WebClient
  • FastAPI
  • Lombok
  • SLF4J

API 명세

요양기간 예측 API

POST /api/predictions
Content-Type: application/json

{
    "disease": "S724(넙다리뼈 하단의 골절)",
    "sex": "남자",
    "surgery": "예",
    "age": "30-39세",
    "region": "부산지역"
}

진단명 검색 API

GET /api/predictions/diagnoses?keyword={검색어}

테스트 항목

  • FastAPI 서버 연결 테스트
  • 요양기간 예측 기능 테스트
  • 진단명 검색 기능 테스트
  • 예외 처리 테스트
  • 로깅 확인

고려사항

  1. FastAPI 서버 다운 시 fallback 처리
  2. 요청/응답 timeout 설정
  3. 대용량 트래픽 처리 방안
  4. 캐싱 전략 수립

추가 개선사항

  • 진단명 검색 결과 캐싱 구현
  • API 요청/응답 validation 강화
  • 성능 모니터링 지표 추가
  • API 문서화 (Swagger)

관련 문서

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions