Skip to content

[Feat] 약 재등록 원클릭 — 단건 조회 API 구현 - #64

Merged
kangcheolung merged 4 commits into
developfrom
feature/63
Jul 9, 2026
Merged

[Feat] 약 재등록 원클릭 — 단건 조회 API 구현#64
kangcheolung merged 4 commits into
developfrom
feature/63

Conversation

@kangcheolung

@kangcheolung kangcheolung commented Jul 9, 2026

Copy link
Copy Markdown
Member

🔍️ 작업 내용

✨ 상세 설명

단건 조회 API — GET /api/medications/{medicationId}

  • 복용 종료된(isActive=false) 약 카드의 "약물 재등록" 버튼 클릭 시, 프론트가 이 API로 해당 약의 전체 정보를 조회
  • 반환 필드: drugName, drugNickname, drugType, imageUrl, dosagePerTime, timesPerDay, totalDays, startDate, endDate, hospitalName, prescriptionDate, memo, usageStorageInfo, isActive
  • 소유권 검증 (senior + userId) 포함

등록 확정은 기존 API 재사용

  • 사용자가 프리필된 등록 화면에서 확인/수정 후 "등록하기" 클릭 시 → 기존 POST /api/medications/batch 그대로 사용
  • Medication row 생성 + MedicationSchedule 자동 생성 (기존 createSchedules() 로직 그대로 적용)
  • 별도의 재등록 전용 등록 API는 만들지 않음

🛠️ 추후 리팩토링 및 고도화 계획

  • 약물노트 복용중/복용완료 상태 필터링 기능 (status=active/inactive 쿼리 파라미터) — 별도 이슈로 분리 예정

📸 스크린샷 (선택)

💬 리뷰 요구사항

  • 재등록 시 기존 비활성 약 row는 그대로 두고 새 row를 생성하는 방식이 맞는지 (같은 row를 재활성화하는 방식과 비교했을 때) 확인 부탁
  • 단건 조회 API 응답 필드가 프론트 등록 화면 프리필에 충분한지 확인 필요

Summary by CodeRabbit

  • New Features

    • 약 상세 정보를 한 번에 확인할 수 있는 조회 기능이 추가되었습니다.
    • 상세 조회 결과에는 약 정보, 복용 정보, 병원 정보, 메모, 활성 여부 등이 포함됩니다.
    • 재등록 화면에서 미리 채워질 수 있도록 관련 식별 정보도 함께 제공합니다.
  • Bug Fixes

    • 로그인 사용자와 소유 약물만 조회되도록 권한 검증이 강화되었습니다.
    • 존재하지 않는 약물 조회 시 적절한 오류가 반환됩니다.

kangcheolung and others added 4 commits July 10, 2026 01:04
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
재등록 버튼 클릭 시 호출 — 등록 화면 프리필에 필요한 전체 필드 반환

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: d583a432-3d6a-4d2e-aeda-3dd7a9ac55c1

📥 Commits

Reviewing files that changed from the base of the PR and between bf0eed9 and bd4c84a.

📒 Files selected for processing (4)
  • src/main/java/com/piuda/callcare/domain/medication/controller/MedicationController.java
  • src/main/java/com/piuda/callcare/domain/medication/converter/MedicationConverter.java
  • src/main/java/com/piuda/callcare/domain/medication/dto/response/MedicationDetailResponse.java
  • src/main/java/com/piuda/callcare/domain/medication/service/query/MedicationQueryService.java

📝 Walkthrough

Walkthrough

약 재등록 프리필을 위한 GET /api/medications/{medicationId} 단건 상세 조회 API가 추가되었다. MedicationDetailResponse DTO, MedicationConverter.toDetailResponse, MedicationQueryService.getDetail(소유권/존재 검증 포함), MedicationController.getDetail 엔드포인트가 함께 구현되었다.

Changes

약 상세 조회 기능

Layer / File(s) Summary
상세 응답 DTO 정의
MedicationDetailResponse.java
재등록 프리필에 필요한 약 정보 필드와 Swagger 설명을 담은 record DTO가 신설됨.
소유권 검증 및 상세 조회 서비스
MedicationQueryService.java
userId null, 약 미존재, 소유권 미일치 시 각각 예외(FORBIDDEN, MEDICATION_NOT_FOUND, FORBIDDEN)를 던지고 통과 시 상세 응답 반환하는 getDetail 추가.
엔티티→응답 변환 로직
MedicationConverter.java
Medication 필드를 MedicationDetailResponse로 매핑하고 drugInfo null 여부를 처리하는 toDetailResponse 추가.
상세 조회 엔드포인트 노출
MedicationController.java
GET /api/medications/{medicationId} 매핑이 추가되어 서비스 호출 결과를 ApiResponse로 반환.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant MedicationController
  participant MedicationQueryService
  participant MedicationConverter

  Client->>MedicationController: GET /api/medications/{medicationId}
  MedicationController->>MedicationQueryService: getDetail(userId, medicationId)
  MedicationQueryService->>MedicationQueryService: 소유권/존재 검증
  MedicationQueryService->>MedicationConverter: toDetailResponse(medication)
  MedicationConverter-->>MedicationQueryService: MedicationDetailResponse
  MedicationQueryService-->>MedicationController: MedicationDetailResponse
  MedicationController-->>Client: ApiResponse<MedicationDetailResponse>
Loading

Possibly related PRs

  • PIUDAProject/Backend#54: 동일한 MedicationDetailResponse/MedicationConverter.toDetailResponse 매핑과 getDetail 엔드포인트 플로우를 다룸.
  • PIUDAProject/Backend#56: 본 PR이 추가한 getDetail 플로우를 제거하고 getGroup/MedicationGroupItemResponse 모델로 전환해 동일 엔드포인트/변환 로직에서 직접 충돌.
  • PIUDAProject/Backend#58: usageStorageInfo 필드 처리와 관련해 동일한 컨버터/응답 매핑 흐름을 다룸.

Suggested labels: ✨ Feature

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 제목이 약 재등록용 단건 조회 API 구현이라는 핵심 변경을 정확히 요약합니다.
Linked Issues check ✅ Passed 단건 조회 API, 소유권 검증, Swagger용 DTO 추가가 이슈 #63의 요구사항과 일치합니다.
Out of Scope Changes check ✅ Passed 컨트롤러·서비스·컨버터·응답 DTO 변경만 포함되어 이슈 범위를 벗어난 변경은 보이지 않습니다.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/63

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@kangcheolung

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@kangcheolung
kangcheolung merged commit b16b308 into develop Jul 9, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feat] 약 재등록 원클릭 — 단건 조회 API 및 프리필 지원

1 participant