[Feat]: 약물노트 병원+처방일 그룹 상세 조회 API 구현 - #56
Conversation
DrugInfo 기반 상세 응답 폐기, 약물노트 그룹 상세 조회용 DTO로 교체 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
병원명 + 처방일 조합으로 그룹 조회, null 파라미터 처리 포함 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
병원명 + 처방일 기준 그룹 내 약 리스트 조회, userId 소유권 검증 포함 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Warning Review limit reached
Next review available in: 47 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthrough약물노트의 "약 상세 정보 조회" 기능( Changes약 상세 조회 → 그룹 조회 전환
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related PRs
Suggested labels: 버그/성능/설계 관점 코멘트: 삭제된 상세 조회 대신 그룹 조회로 완전히 갈아탄 점은 명확하지만, 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
src/main/java/com/piuda/callcare/domain/medication/dto/response/MedicationGroupItemResponse.java (1)
16-37: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win
@Schema에nullable = true누락 — null 허용 필드 문서 부정확
drugType,imageUrl,endDate,totalDays,memo필드는 설명에 "(없으면 null)"로 명시되어 있으나@Schema(nullable = true)가 설정되지 않았습니다. springdoc 2.8.9는 참조 타입 필드를 기본적으로 non-nullable로 생성하므로, OpenAPI 스펙을 소비하는 클라이언트에서 null 처리 누락이 발생할 수 있습니다.♻️ 제안: nullable 필드에 `@Schema`(nullable = true) 추가
`@Schema`(description = "약 종류 (없으면 null)", nullable = true) String drugType, `@Schema`(description = "약 이미지 URL (없으면 null)", nullable = true) String imageUrl, `@Schema`(description = "1일 복용 횟수") Integer timesPerDay, `@Schema`(description = "1회 복용량 (예: 1정, 5ml)") String dosagePerTime, `@Schema`(description = "복용 시작일") LocalDate startDate, `@Schema`(description = "복용 종료일 (없으면 null)", nullable = true) LocalDate endDate, `@Schema`(description = "총 복용 일수 (없으면 null)", nullable = true) Integer totalDays, `@Schema`(description = "메모 — OCR 자동 생성 또는 사용자 직접 입력 (없으면 null)", nullable = true) String memo🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/main/java/com/piuda/callcare/domain/medication/dto/response/MedicationGroupItemResponse.java` around lines 16 - 37, The OpenAPI annotations in MedicationGroupItemResponse are missing nullable metadata for fields documented as “없으면 null”, so update the `@Schema` declarations on drugType, imageUrl, endDate, totalDays, and memo to explicitly set nullable = true. Keep the existing DTO shape intact and ensure the nullable flag is applied on the relevant record components so springdoc generates the correct schema.src/main/java/com/piuda/callcare/domain/medication/repository/MedicationRepository.java (1)
31-43: 🚀 Performance & Scalability | 🔵 TrivialJPQL null-safe 패턴 및 정렬 로직 검증 완료
(:param IS NULL AND m.field IS NULL) OR m.field = :param패턴이 null 파라미터와 non-null 파라미터 모두에 대해 올바르게 동작합니다.m.createdAt기준 오름차순 정렬도BaseEntity의@CreatedDate필드와 일치합니다. 엔티티 필드 경로(m.senior.id,m.hospitalName,m.prescriptionDate,m.isActive)도Medication엔티티 정의와 정확히 매칭됩니다.운영 관점 제안:
findByGroup쿼리가senior_id,hospital_name,prescription_date,is_active조건으로 필터링하므로, 해당 컬럼 조합에 복합 인덱스를 추가하면 대량 데이터 환경에서 성능이 크 개선됩니다.CREATE INDEX idx_medication_group ON medication (senior_id, hospital_name, prescription_date, is_active);🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/main/java/com/piuda/callcare/domain/medication/repository/MedicationRepository.java` around lines 31 - 43, The `findByGroup` query in `MedicationRepository` is correct, but its filter pattern can benefit from a composite index for better performance on large datasets. Add a database index covering the columns used by this query (`senior_id`, `hospital_name`, `prescription_date`, `is_active`) through the project’s migration/schema mechanism so the `Medication` lookups for group retrieval stay efficient.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@src/main/java/com/piuda/callcare/domain/medication/service/query/MedicationQueryService.java`:
- Around line 26-30: The ownership check in MedicationQueryService.getGroup is
incorrectly skipped when userId is null, which can allow unauthorized access to
another senior’s medication data. Update getGroup so
seniorRepository.findByIdAndUser_Id is always used to verify that the given
seniorId belongs to the requesting user, regardless of whether userId is
present, and keep throwing CallCareException with ErrorCode.SENIOR_NOT_FOUND
when the senior is missing or not owned by the caller. Use the getGroup method
and seniorRepository lookup as the key points for the fix.
---
Nitpick comments:
In
`@src/main/java/com/piuda/callcare/domain/medication/dto/response/MedicationGroupItemResponse.java`:
- Around line 16-37: The OpenAPI annotations in MedicationGroupItemResponse are
missing nullable metadata for fields documented as “없으면 null”, so update the
`@Schema` declarations on drugType, imageUrl, endDate, totalDays, and memo to
explicitly set nullable = true. Keep the existing DTO shape intact and ensure
the nullable flag is applied on the relevant record components so springdoc
generates the correct schema.
In
`@src/main/java/com/piuda/callcare/domain/medication/repository/MedicationRepository.java`:
- Around line 31-43: The `findByGroup` query in `MedicationRepository` is
correct, but its filter pattern can benefit from a composite index for better
performance on large datasets. Add a database index covering the columns used by
this query (`senior_id`, `hospital_name`, `prescription_date`, `is_active`)
through the project’s migration/schema mechanism so the `Medication` lookups for
group retrieval stay efficient.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 6eb09ee4-4ffc-449e-b666-53e604ef2dff
📒 Files selected for processing (6)
src/main/java/com/piuda/callcare/domain/medication/controller/MedicationController.javasrc/main/java/com/piuda/callcare/domain/medication/converter/MedicationConverter.javasrc/main/java/com/piuda/callcare/domain/medication/dto/response/MedicationDetailResponse.javasrc/main/java/com/piuda/callcare/domain/medication/dto/response/MedicationGroupItemResponse.javasrc/main/java/com/piuda/callcare/domain/medication/repository/MedicationRepository.javasrc/main/java/com/piuda/callcare/domain/medication/service/query/MedicationQueryService.java
💤 Files with no reviewable changes (1)
- src/main/java/com/piuda/callcare/domain/medication/dto/response/MedicationDetailResponse.java
인증 없는 요청으로 타인 약물 데이터 조회 방지 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
🔍️작업 내용
✨ 상세 설명
약물노트 병원+처방일 그룹 상세 조회 API 구현
변경 내용
GET /api/medications/{id}/detail제거GET /api/medications/group신규 추가seniorId,hospitalName(선택),prescriptionDate(선택)hospitalName + prescriptionDate조합 (둘 다 null 허용)삭제
MedicationDetailResponseMedicationConverter.toDetailResponse()MedicationQueryService.getDetail()🛠 추후 리팩토링 및 고도화 계획
GET /api/medications/**permitAll 제거 및 소유권 검증 의무화💬 리뷰 요구사항
Summary by CodeRabbit
그룹 상세 조회API로 약 리스트와 메모를 함께 확인할 수 있으며, 병원명과 처방일로도 필터링할 수 있습니다.