From da4c971e847c6c26d7f9e7dff0db4bb4d9a510e9 Mon Sep 17 00:00:00 2001 From: kangcheolung Date: Fri, 10 Jul 2026 20:16:13 +0900 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20MedicationRepository=20=EB=AA=A9?= =?UTF-8?q?=EB=A1=9D/=EA=B2=80=EC=83=89=20=EC=BF=BC=EB=A6=AC=EC=97=90=20is?= =?UTF-8?q?Active=20=EC=98=B5=EC=85=94=EB=84=90=20=ED=95=84=ED=84=B0=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit null이면 전체, true/false면 해당 상태만 조회 Co-Authored-By: Claude Sonnet 4.6 --- .../medication/repository/MedicationRepository.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/piuda/callcare/domain/medication/repository/MedicationRepository.java b/src/main/java/com/piuda/callcare/domain/medication/repository/MedicationRepository.java index 43959b9..928d85f 100644 --- a/src/main/java/com/piuda/callcare/domain/medication/repository/MedicationRepository.java +++ b/src/main/java/com/piuda/callcare/domain/medication/repository/MedicationRepository.java @@ -29,19 +29,22 @@ public interface MedicationRepository extends JpaRepository { """) List findActiveWithDrugInfoBySeniorId(@Param("seniorId") Long seniorId); - // 약물노트 전체 리스트: 활성/비활성 관계없이 전체 조회 (startDate DESC → hospitalName ASC 정렬) + // 약물노트 전체 리스트: isActive null이면 전체, true/false면 해당 상태만 조회 @Query(""" SELECT m FROM Medication m WHERE m.senior.id = :seniorId + AND (:isActive IS NULL OR m.isActive = :isActive) ORDER BY m.startDate DESC, m.hospitalName ASC NULLS LAST """) - List findAllBySeniorId(@Param("seniorId") Long seniorId); + List findAllBySeniorId(@Param("seniorId") Long seniorId, + @Param("isActive") Boolean isActive); - // 약물노트 검색: 약 이름/별명/병원명 키워드 + 날짜 범위 필터 (활성/비활성 모두 포함) + // 약물노트 검색: 약 이름/별명/병원명 키워드 + 날짜 범위 + 상태 필터 @Query(""" SELECT m FROM Medication m WHERE m.senior.id = :seniorId AND m.startDate >= :fromDate + AND (:isActive IS NULL OR m.isActive = :isActive) AND (LOWER(m.drugName) LIKE LOWER(CONCAT('%', :keyword, '%')) OR LOWER(m.drugNickname) LIKE LOWER(CONCAT('%', :keyword, '%')) OR LOWER(m.hospitalName) LIKE LOWER(CONCAT('%', :keyword, '%'))) @@ -49,7 +52,8 @@ OR LOWER(m.hospitalName) LIKE LOWER(CONCAT('%', :keyword, '%'))) """) List searchByKeyword(@Param("seniorId") Long seniorId, @Param("keyword") String keyword, - @Param("fromDate") LocalDate fromDate); + @Param("fromDate") LocalDate fromDate, + @Param("isActive") Boolean isActive); // 약물노트 그룹 상세 조회: 병원명 + 처방일 조합이 그룹 키 (둘 다 null 가능) @Query(""" From 586ac3f000d3ca163eccc00201dd7e1852bc545f Mon Sep 17 00:00:00 2001 From: kangcheolung Date: Fri, 10 Jul 2026 20:16:21 +0900 Subject: [PATCH 2/3] =?UTF-8?q?feat:=20MedicationQueryService=20getNoteLis?= =?UTF-8?q?t/searchNotes=EC=97=90=20isActive=20=ED=95=84=ED=84=B0=20?= =?UTF-8?q?=ED=8C=8C=EB=9D=BC=EB=AF=B8=ED=84=B0=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 4.6 --- .../service/query/MedicationQueryService.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/piuda/callcare/domain/medication/service/query/MedicationQueryService.java b/src/main/java/com/piuda/callcare/domain/medication/service/query/MedicationQueryService.java index 81b6ac8..10e9e82 100644 --- a/src/main/java/com/piuda/callcare/domain/medication/service/query/MedicationQueryService.java +++ b/src/main/java/com/piuda/callcare/domain/medication/service/query/MedicationQueryService.java @@ -52,22 +52,22 @@ public List getGroup(Long userId, Long seniorId, St .toList(); } - // 시니어의 약 전체 목록 (활성/비활성 모두) — startDate+병원 기준 그룹화 - public List getNoteList(Long userId, Long seniorId) { + // 시니어의 약 목록 — isActive: true(복용중) / false(복용완료) / null(전체) + public List getNoteList(Long userId, Long seniorId, Boolean isActive) { if (userId == null) throw new CallCareException(ErrorCode.FORBIDDEN); seniorRepository.findByIdAndUser_Id(seniorId, userId) .orElseThrow(() -> new CallCareException(ErrorCode.SENIOR_NOT_FOUND)); - List medications = medicationRepository.findAllBySeniorId(seniorId); + List medications = medicationRepository.findAllBySeniorId(seniorId, isActive); return toNoteGroupResponses(medications); } - // 약 이름/별명/병원명 키워드 검색 + 기간 필터 (1w·1m·3m·1y) - public List searchNotes(Long userId, Long seniorId, String keyword, String period) { + // 약 이름/별명/병원명 키워드 검색 + 기간 필터 + 상태 필터 + public List searchNotes(Long userId, Long seniorId, String keyword, String period, Boolean isActive) { if (userId == null) throw new CallCareException(ErrorCode.FORBIDDEN); seniorRepository.findByIdAndUser_Id(seniorId, userId) .orElseThrow(() -> new CallCareException(ErrorCode.SENIOR_NOT_FOUND)); LocalDate fromDate = resolveFromDate(period); - List medications = medicationRepository.searchByKeyword(seniorId, keyword, fromDate); + List medications = medicationRepository.searchByKeyword(seniorId, keyword, fromDate, isActive); return toNoteGroupResponses(medications); } From 1df3b007cbfb97df5def46d02d763e3965164704 Mon Sep 17 00:00:00 2001 From: kangcheolung Date: Fri, 10 Jul 2026 20:16:26 +0900 Subject: [PATCH 3/3] =?UTF-8?q?feat:=20=EC=95=BD=EB=AC=BC=EB=85=B8?= =?UTF-8?q?=ED=8A=B8=20=EB=AA=A9=EB=A1=9D/=EA=B2=80=EC=83=89=20=EC=97=94?= =?UTF-8?q?=EB=93=9C=ED=8F=AC=EC=9D=B8=ED=8A=B8=EC=97=90=20isActive=20?= =?UTF-8?q?=ED=95=84=ED=84=B0=20=ED=8C=8C=EB=9D=BC=EB=AF=B8=ED=84=B0=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit isActive=true(복용중) / isActive=false(복용완료) / 미전달(전체) Co-Authored-By: Claude Sonnet 4.6 --- .../controller/MedicationController.java | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/piuda/callcare/domain/medication/controller/MedicationController.java b/src/main/java/com/piuda/callcare/domain/medication/controller/MedicationController.java index a8d03bb..bf4415b 100644 --- a/src/main/java/com/piuda/callcare/domain/medication/controller/MedicationController.java +++ b/src/main/java/com/piuda/callcare/domain/medication/controller/MedicationController.java @@ -63,24 +63,32 @@ public ResponseEntity>> getGroup( return ResponseUtils.ok(medicationQueryService.getGroup(userId, seniorId, hospitalName, prescriptionDate)); } - @Operation(summary = "약물노트 목록 조회", description = "복용 시작일 + 병원 기준으로 그룹화된 약물 목록을 반환합니다.") + @Operation( + summary = "약물노트 목록 조회", + description = "복용 시작일 + 병원 기준으로 그룹화된 약물 목록을 반환합니다. isActive=true(복용중만) / isActive=false(복용완료만) / 미전달(전체)." + ) @GetMapping("/notes") public ResponseEntity>> getNoteList( @AuthenticationPrincipal Long userId, - @RequestParam Long seniorId + @RequestParam Long seniorId, + @RequestParam(required = false) Boolean isActive ) { - return ResponseUtils.ok(medicationQueryService.getNoteList(userId, seniorId)); + return ResponseUtils.ok(medicationQueryService.getNoteList(userId, seniorId, isActive)); } - @Operation(summary = "약물노트 검색", description = "약 이름/별명/병원명으로 검색합니다. period: 1w·1m·3m·1y (기본 1y)") + @Operation( + summary = "약물노트 검색", + description = "약 이름/별명/병원명으로 검색합니다. period: 1w·1m·3m·1y (기본 1y). isActive=true(복용중만) / isActive=false(복용완료만) / 미전달(전체)." + ) @GetMapping("/notes/search") public ResponseEntity>> searchNotes( @AuthenticationPrincipal Long userId, @RequestParam Long seniorId, @RequestParam String keyword, - @RequestParam(required = false, defaultValue = "1y") String period + @RequestParam(required = false, defaultValue = "1y") String period, + @RequestParam(required = false) Boolean isActive ) { - return ResponseUtils.ok(medicationQueryService.searchNotes(userId, seniorId, keyword, period)); + return ResponseUtils.ok(medicationQueryService.searchNotes(userId, seniorId, keyword, period, isActive)); } @Operation(summary = "약 수정", description = "null 필드는 변경하지 않습니다. timesPerDay 변경 시 스케줄을 재생성합니다.")