diff --git a/src/main/java/dbdr/domain/chart/controller/CareWorkerChartController.java b/src/main/java/dbdr/domain/chart/controller/CareWorkerChartController.java index 2e002b49..837edc61 100644 --- a/src/main/java/dbdr/domain/chart/controller/CareWorkerChartController.java +++ b/src/main/java/dbdr/domain/chart/controller/CareWorkerChartController.java @@ -7,6 +7,8 @@ import dbdr.domain.chart.service.ChartService; import dbdr.global.util.api.ApiUtils; import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; @@ -33,9 +35,11 @@ public class CareWorkerChartController { private final ChartService chartService; - @Operation(summary = "돌봄대상자 아이디로 차트 정보 조회") + @Operation(summary = "돌봄대상자 아이디로 차트 정보 조회", + security = @SecurityRequirement(name = "JWT")) @GetMapping("/recipient") public ResponseEntity>> getAllChartByRecipientId( + @Parameter(hidden = true) @RequestParam(value = "recipient-id", required = false) Long recipientId, @PageableDefault(size = DEFAULT_PAGE_SIZE, sort = "createdAt", direction = Sort.Direction.DESC) Pageable pageable) { // 환자 정보 접근 권한 확인 로직 필요 -> 요양사가 맡은 환자 정보만 조회 가능 @@ -43,7 +47,8 @@ public ResponseEntity>> getAllChart return ResponseEntity.ok(ApiUtils.success(recipients)); } - @Operation(summary = "차트 아이디로 차트 정보 조회") + @Operation(summary = "차트 아이디로 차트 정보 조회", + security = @SecurityRequirement(name = "JWT")) @GetMapping("/{chartId}") public ResponseEntity> getChartById(@PathVariable("chartId") Long chartId) { // 환자 정보 접근 권한 확인 로직 필요 -> 요양사가 맡은 환자 정보만 조회 가능 @@ -51,7 +56,8 @@ public ResponseEntity> getChartById(@Pat return ResponseEntity.ok(ApiUtils.success(chart)); } - @Operation(summary = "차트 추가") + @Operation(summary = "차트 추가", + security = @SecurityRequirement(name = "JWT")) @PostMapping public ResponseEntity> saveChart(@RequestBody ChartDetailRequest request) { // 환자 정보 접근 권한 확인 로직 필요 -> 요양사가 맡은 환자 정보만 저장 가능 @@ -59,7 +65,8 @@ public ResponseEntity> saveChart(@Reques return ResponseEntity.status(HttpStatus.CREATED).body(ApiUtils.success(chart)); } - @Operation(summary = "차트 아이디로 차트 수정") + @Operation(summary = "차트 아이디로 차트 수정", + security = @SecurityRequirement(name = "JWT")) @PutMapping("/{chartId}") public ResponseEntity> updateChart(@PathVariable("chartId") Long chartId, @RequestBody ChartDetailRequest request) { @@ -68,7 +75,8 @@ public ResponseEntity> updateChart(@Path return ResponseEntity.ok(ApiUtils.success(chart)); } - @Operation(summary = "차트 아이디로 차트 삭제") + @Operation(summary = "차트 아이디로 차트 삭제", + security = @SecurityRequirement(name = "JWT")) @DeleteMapping("/{chartId}") public ResponseEntity> deleteChart(@PathVariable("chartId") Long chartId) { // 환자 정보 접근 권한 확인 로직 필요 -> 요양사가 맡은 환자 정보만 삭제 가능 diff --git a/src/main/java/dbdr/domain/chart/dto/ChartMapper.java b/src/main/java/dbdr/domain/chart/dto/ChartMapper.java index 83fb04a9..eb7de954 100644 --- a/src/main/java/dbdr/domain/chart/dto/ChartMapper.java +++ b/src/main/java/dbdr/domain/chart/dto/ChartMapper.java @@ -15,68 +15,74 @@ import dbdr.domain.chart.entity.CognitiveManagement; import dbdr.domain.chart.entity.NursingManagement; import dbdr.domain.chart.entity.RecoveryTraining; +import dbdr.domain.recipient.entity.Recipient; +import dbdr.domain.recipient.service.RecipientService; import org.mapstruct.Mapper; import org.mapstruct.Mapping; import org.mapstruct.Mappings; +import org.springframework.beans.factory.annotation.Autowired; @Mapper(componentModel = "spring") -public interface ChartMapper { +public abstract class ChartMapper { + @Autowired + private RecipientService recipientService; + @Mappings({ @Mapping(source = "bodyManagement", target = "bodyManagement"), @Mapping(target = "chartId", source = "id")}) - ChartDetailResponse toResponse(Chart chart); + public abstract ChartDetailResponse toResponse(Chart chart); @Mappings({ - @Mapping(target = "bodyManagement", source = "bodyManagement"), - @Mapping(target = "nursingManagement", source = "nursingManagement"), - @Mapping(target = "cognitiveManagement", source = "cognitiveManagement"), - @Mapping(target = "recoveryTraining", source = "recoveryTraining"), - @Mapping(target = "conditionDisease", source = "conditionDisease"), - @Mapping(target = "recipient", source = "recipient") + @Mapping(target = "bodyManagement", source = "bodyManagement"), + @Mapping(target = "nursingManagement", source = "nursingManagement"), + @Mapping(target = "cognitiveManagement", source = "cognitiveManagement"), + @Mapping(target = "recoveryTraining", source = "recoveryTraining"), + @Mapping(target = "conditionDisease", source = "conditionDisease"), + @Mapping(target = "recipient", source = "recipientId") }) - Chart toEntity(ChartDetailRequest request); + public abstract Chart toEntity(ChartDetailRequest request); + + protected Recipient mapRecipient(Long recipientId) { + return recipientService.findRecipientById(recipientId); + } // BodyManagement 매핑 @Mappings({ - @Mapping(target = "wash", source = "physicalClear.wash"), - @Mapping(target = "bath", source = "physicalClear.bath"), - @Mapping(target = "mealType", source = "physicalMeal.mealType"), - @Mapping(target = "intakeAmount", source = "physicalMeal.intakeAmount"), - @Mapping(target = "has_walked", source = "physicalWalk.hasWalked"), - @Mapping(target = "has_companion", source = "physicalWalk.hasCompanion"), + @Mapping(target = "wash", source = "physicalClear.wash"), + @Mapping(target = "bath", source = "physicalClear.bath"), + @Mapping(target = "mealType", source = "physicalMeal.mealType"), + @Mapping(target = "intakeAmount", source = "physicalMeal.intakeAmount") }) - BodyManagementResponse toResponse(BodyManagement bodyManagement); + public abstract BodyManagementResponse toResponse(BodyManagement bodyManagement); @Mappings({ @Mapping(target = "physicalClear.wash", source = "wash"), @Mapping(target = "physicalClear.bath", source = "bath"), @Mapping(target = "physicalMeal.mealType", source = "mealType"), - @Mapping(target = "physicalMeal.intakeAmount", source = "intakeAmount"), - @Mapping(target = "physicalWalk.hasWalked", source = "has_walked"), - @Mapping(target = "physicalWalk.hasCompanion", source = "has_companion") + @Mapping(target = "physicalMeal.intakeAmount", source = "intakeAmount") }) - BodyManagement toEntity(BodyManagementRequest request); + public abstract BodyManagement toEntity(BodyManagementRequest request); // NursingManagement 매핑 @Mappings({ @Mapping(target = "systolic", source = "healthBloodPressure.systolic"), @Mapping(target = "diastolic", source = "healthBloodPressure.diastolic") }) - NursingManagementResponse toResponse(NursingManagement nursingManagement); + public abstract NursingManagementResponse toResponse(NursingManagement nursingManagement); @Mappings({ @Mapping(target = "healthBloodPressure.systolic", source = "systolic"), @Mapping(target = "healthBloodPressure.diastolic", source = "diastolic") }) - NursingManagement toEntity(NursingManagementRequest request); + public abstract NursingManagement toEntity(NursingManagementRequest request); // CognitiveManagement 매핑 - CognitiveManagementResponse toResponse(CognitiveManagement cognitiveManagement); + public abstract CognitiveManagementResponse toResponse(CognitiveManagement cognitiveManagement); - CognitiveManagement toEntity(CognitiveManagementRequest request); + public abstract CognitiveManagement toEntity(CognitiveManagementRequest request); // RecoveryTraining 매핑 - RecoveryTrainingResponse toResponse(RecoveryTraining recoveryTraining); + public abstract RecoveryTrainingResponse toResponse(RecoveryTraining recoveryTraining); - RecoveryTraining toEntity(RecoveryTrainingRequest request); + public abstract RecoveryTraining toEntity(RecoveryTrainingRequest request); } diff --git a/src/main/java/dbdr/domain/chart/dto/request/BodyManagementRequest.java b/src/main/java/dbdr/domain/chart/dto/request/BodyManagementRequest.java index 83530526..9cc104a6 100644 --- a/src/main/java/dbdr/domain/chart/dto/request/BodyManagementRequest.java +++ b/src/main/java/dbdr/domain/chart/dto/request/BodyManagementRequest.java @@ -3,21 +3,23 @@ import io.swagger.v3.oas.annotations.media.Schema; public record BodyManagementRequest( - @Schema(description = "세면 유무", example = "true") - boolean wash, // 세면 유무 - @Schema(description = "목욕 유무", example = "true") - boolean bath, // 목욕 유무 - @Schema(description = "식사 종류", example = "채식") - String mealType, // 식사 종류 - @Schema(description = "섭취량", example = "3회") - String intakeAmount, // 섭취량 - @Schema(description = "화장실 횟수", example = "6") - int physicalRestroom, // 화장실 횟수 - @Schema(description = "산책", example = "false") - boolean has_walked, // 산책 - @Schema(description = "외출 동행", example = "false") - boolean has_companion, // 외출 동행 - @Schema(description = "특이사항 입력", example = "평소보다 컨디션이 좋으셨다.") - String physicalNote // 특이사항 입력 + @Schema(description = "세면 유무", example = "true") + boolean wash, // 세면 유무 + @Schema(description = "목욕 유무", example = "true") + boolean bath, // 목욕 유무 + @Schema(description = "식사 종류", example = "채식") + String mealType, // 식사 종류 + @Schema(description = "섭취량", example = "3회") + String intakeAmount, // 섭취량 + @Schema(description = "화장실 횟수", example = "6") + int physicalRestroom, // 화장실 횟수 + @Schema(description = "산책", example = "false") + boolean has_walked, // 산책 + @Schema(description = "체위 변경 유므", example = "false") + boolean isPositionChangeRequired, // 체위 변경 유무 + @Schema(description = "이동 도움 유무", example = "false") + boolean isMobilityAssistance, // 이동 도움 유무 + @Schema(description = "특이사항 입력", example = "평소보다 컨디션이 좋으셨다.") + String physicalNote // 특이사항 입력 ) { } diff --git a/src/main/java/dbdr/domain/chart/dto/request/ChartDetailRequest.java b/src/main/java/dbdr/domain/chart/dto/request/ChartDetailRequest.java index 8510fe58..d9e2d2ff 100644 --- a/src/main/java/dbdr/domain/chart/dto/request/ChartDetailRequest.java +++ b/src/main/java/dbdr/domain/chart/dto/request/ChartDetailRequest.java @@ -1,25 +1,24 @@ package dbdr.domain.chart.dto.request; -import dbdr.domain.recipient.entity.Recipient; import io.swagger.v3.oas.annotations.media.Schema; public record ChartDetailRequest( - @Schema(description = "상태", example = "오늘은 상태가 매우 좋으셨다.") - String conditionDisease, - @Schema(description = "돌봄대상자", example = "{\"id\":\"1\"}") - Recipient recipient, - @Schema(description = "신체활동", example = "{\"wash\": true,\"bath\": true,\"mealType\": \"채식\"," - + "\"intakeAmount\": \"3회\",\"physicalRestroom\": 6,\"has_walked\": false," - + "\"has_companion\": false, \"physicalNote\": \"평소보다 컨디션이 좋으셨다.\"}") - BodyManagementRequest bodyManagement, - @Schema(description = "간호관리", example = "{\"systolic\": 300," - + "\"diastolic\": 200," - + "\"healthTemperature\": \"32도\"," - + "\"healthNote\": \"없음\"}") - NursingManagementRequest nursingManagement, - @Schema(description = "인지관리", example = "{\"cognitiveHelp\": true,\"cognitiveNote\": \"없음\"}") - CognitiveManagementRequest cognitiveManagement, - @Schema(description = "기능회복훈련", example = "{\"recoveryProgram\":\"회복\",\"recoveryTraining\": true,\"recoveryNote\": \"없음\"}") - RecoveryTrainingRequest recoveryTraining + @Schema(description = "상태", example = "오늘은 상태가 매우 좋으셨다.") + String conditionDisease, + @Schema(description = "돌봄대상자", example = "{\"id\":\"1\"}") + Long recipientId, + @Schema(description = "신체활동", example = "{\"wash\": true,\"bath\": true,\"mealType\": \"채식\"," + + "\"intakeAmount\": \"3회\",\"physicalRestroom\": 6,\"has_walked\": false," + + "\"has_companion\": false, \"physicalNote\": \"평소보다 컨디션이 좋으셨다.\"}") + BodyManagementRequest bodyManagement, + @Schema(description = "간호관리", example = "{\"systolic\": 300," + + "\"diastolic\": 200," + + "\"healthTemperature\": \"32도\"," + + "\"healthNote\": \"없음\"}") + NursingManagementRequest nursingManagement, + @Schema(description = "인지관리", example = "{\"cognitiveHelp\": true,\"cognitiveNote\": \"없음\"}") + CognitiveManagementRequest cognitiveManagement, + @Schema(description = "기능회복훈련", example = "{\"recoveryProgram\":\"회복\",\"recoveryTraining\": true,\"recoveryNote\": \"없음\"}") + RecoveryTrainingRequest recoveryTraining ) { } diff --git a/src/main/java/dbdr/domain/chart/dto/request/CognitiveManagementRequest.java b/src/main/java/dbdr/domain/chart/dto/request/CognitiveManagementRequest.java index a668a3ac..2b7ca22a 100644 --- a/src/main/java/dbdr/domain/chart/dto/request/CognitiveManagementRequest.java +++ b/src/main/java/dbdr/domain/chart/dto/request/CognitiveManagementRequest.java @@ -3,9 +3,11 @@ import io.swagger.v3.oas.annotations.media.Schema; public record CognitiveManagementRequest( - @Schema(description = "의사소통 도움 여부", example = "true") - boolean cognitiveHelp, // 의사소통 도움 여부 - @Schema(description = "인지 관리 특이사항", example = "없음") - String cognitiveNote // 인지 관리 특이사항 + @Schema(description = "의사소통 도움 여부", example = "true") + boolean cognitiveHelp, // 의사소통 도움 여부 + @Schema(description = "말벗 및 격려 여부", example = "true") + boolean isCompanionshipProvided, + @Schema(description = "인지 관리 특이사항", example = "없음") + String cognitiveNote // 인지 관리 특이사항 ) { } diff --git a/src/main/java/dbdr/domain/chart/dto/request/NursingManagementRequest.java b/src/main/java/dbdr/domain/chart/dto/request/NursingManagementRequest.java index 784fa780..96a83fd6 100644 --- a/src/main/java/dbdr/domain/chart/dto/request/NursingManagementRequest.java +++ b/src/main/java/dbdr/domain/chart/dto/request/NursingManagementRequest.java @@ -3,13 +3,19 @@ import io.swagger.v3.oas.annotations.media.Schema; public record NursingManagementRequest( - @Schema(description = "혈압 최고", example = "300") - int systolic, // 혈압 최고 - @Schema(description = "혈압 최저", example = "200") - int diastolic, // 혈압 최저 - @Schema(description = "체온", example = "32도") - String healthTemperature, // 체온 - @Schema(description = "건강 및 간호관리 특이사항", example = "없음") - String healthNote // 건강 및 간호관리 특이사항 + @Schema(description = "혈압 최고", example = "300") + int systolic, // 혈압 최고 + @Schema(description = "혈압 최저", example = "200") + int diastolic, // 혈압 최저 + @Schema(description = "체온", example = "32도") + String healthTemperature, // 체온 + @Schema(description = "건강 관리 제공 여부", example = "true") + boolean isHealthCareProvided, // 건강 관리 제공 여부 + @Schema(description = "간호 관리 제공 여부", example = "true") + boolean isNursingCareProvided, // 간호 관리 제공 여부 + @Schema(description = "응급 관리 제공 여부", example = "true") + boolean isEmergencyCareProvided, // 응급 관리 제공 여부 + @Schema(description = "건강 및 간호관리 특이사항", example = "없음") + String healthNote // 건강 및 간호관리 특이사항 ) { } diff --git a/src/main/java/dbdr/domain/chart/dto/request/RecoveryTrainingRequest.java b/src/main/java/dbdr/domain/chart/dto/request/RecoveryTrainingRequest.java index 997d9762..41e5e081 100644 --- a/src/main/java/dbdr/domain/chart/dto/request/RecoveryTrainingRequest.java +++ b/src/main/java/dbdr/domain/chart/dto/request/RecoveryTrainingRequest.java @@ -3,11 +3,15 @@ import io.swagger.v3.oas.annotations.media.Schema; public record RecoveryTrainingRequest( - @Schema(description = "회복 프로그램 이름", example = "회복") - String recoveryProgram, // 회복 프로그램 이름 - @Schema(description = "회복훈련 완료 여부", example = "true") - boolean recoveryTraining, // 회복훈련 완료 여부 - @Schema(description = "회복훈련 특이사항", example = "없음") - String recoveryNote // 회복훈련 특이사항 + @Schema(description = "회복 프로그램 이름", example = "회복") + String recoveryProgram, // 회복 프로그램 이름 + @Schema(description = "회복훈련 완료 여부", example = "true") + boolean recoveryTraining, // 회복훈련 완료 여부 + @Schema(description = "인지훈련 제공 여부", example = "true") + boolean isCognitiveTrainingProvided, // 인지훈련 제공 여부 + @Schema(description = "물리치료 제공 여부", example = "true") + boolean isPhysicalTherapyProvided, // 물리치료 제공 여부 + @Schema(description = "회복훈련 특이사항", example = "없음") + String recoveryNote // 회복훈련 특이사항 ) { } diff --git a/src/main/java/dbdr/domain/chart/dto/response/BodyManagementResponse.java b/src/main/java/dbdr/domain/chart/dto/response/BodyManagementResponse.java index 2527113a..064e9f3b 100644 --- a/src/main/java/dbdr/domain/chart/dto/response/BodyManagementResponse.java +++ b/src/main/java/dbdr/domain/chart/dto/response/BodyManagementResponse.java @@ -1,16 +1,15 @@ package dbdr.domain.chart.dto.response; -import com.fasterxml.jackson.annotation.JsonProperty; - public record BodyManagementResponse( - Long id, - @JsonProperty("세면 유무") boolean wash, // 세면 유무 - @JsonProperty("목욕 유무") boolean bath, // 목욕 유무 - @JsonProperty("식사 종류") String mealType, // 식사 종류 - @JsonProperty("섭취량") String intakeAmount, // 섭취량 - @JsonProperty("화장실 횟수") int physicalRestroom, // 화장실 횟수 - @JsonProperty("산책 유무") boolean has_walked, // 산책 - @JsonProperty("외출 동행 유무") boolean has_companion, // 외출 동행 - @JsonProperty("특이사항 입력") String physicalNote // 특이사항 입력 + Long id, + boolean wash, // 세면 유무 + boolean bath, // 목욕 유무 + String mealType, // 식사 종류 + String intakeAmount, // 섭취량 + int physicalRestroom, // 화장실 횟수 + boolean has_walked, // 산책 + boolean isPositionChangeRequired, // 체위 변경 유무 + boolean isMobilityAssistance, // 이동 도움 유무 + String physicalNote // 특이사항 입력 ) { } diff --git a/src/main/java/dbdr/domain/chart/dto/response/CognitiveManagementResponse.java b/src/main/java/dbdr/domain/chart/dto/response/CognitiveManagementResponse.java index 78d28473..d13d555c 100644 --- a/src/main/java/dbdr/domain/chart/dto/response/CognitiveManagementResponse.java +++ b/src/main/java/dbdr/domain/chart/dto/response/CognitiveManagementResponse.java @@ -1,10 +1,9 @@ package dbdr.domain.chart.dto.response; -import com.fasterxml.jackson.annotation.JsonProperty; - public record CognitiveManagementResponse( - Long id, - @JsonProperty("의사소통 도움 여부") boolean cognitiveHelp, // 의사소통 도움 여부 - @JsonProperty("인지관리 특이 사항") String cognitiveNote // 인지 관리 특이사항 + Long id, + boolean cognitiveHelp, // 의사소통 도움 여부 + boolean isCompanionshipProvided, + String cognitiveNote // 인지 관리 특이사항 ) { } diff --git a/src/main/java/dbdr/domain/chart/dto/response/NursingManagementResponse.java b/src/main/java/dbdr/domain/chart/dto/response/NursingManagementResponse.java index a1c6dd38..61d59cf3 100644 --- a/src/main/java/dbdr/domain/chart/dto/response/NursingManagementResponse.java +++ b/src/main/java/dbdr/domain/chart/dto/response/NursingManagementResponse.java @@ -1,12 +1,13 @@ package dbdr.domain.chart.dto.response; -import com.fasterxml.jackson.annotation.JsonProperty; - public record NursingManagementResponse( - Long id, - @JsonProperty("혈압 최고") int systolic, // 혈압 최고 - @JsonProperty("혈압 최저") int diastolic, // 혈압 최저 - @JsonProperty("체온") String healthTemperature, // 체온 - @JsonProperty("건강 및 간호관리 특이사항") String healthNote // 건강 및 간호관리 특이사항 + Long id, + int systolic, // 혈압 최고 + int diastolic, // 혈압 최저 + String healthTemperature, // 체온 + boolean isHealthCareProvided, // 건강 관리 제공 여부 + boolean isNursingCareProvided, // 간호 관리 제공 여부 + boolean isEmergencyCareProvided, + String healthNote // 건강 및 간호관리 특이사항 ) { } diff --git a/src/main/java/dbdr/domain/chart/dto/response/RecoveryTrainingResponse.java b/src/main/java/dbdr/domain/chart/dto/response/RecoveryTrainingResponse.java index 0b6dd774..e77c4520 100644 --- a/src/main/java/dbdr/domain/chart/dto/response/RecoveryTrainingResponse.java +++ b/src/main/java/dbdr/domain/chart/dto/response/RecoveryTrainingResponse.java @@ -1,11 +1,11 @@ package dbdr.domain.chart.dto.response; -import com.fasterxml.jackson.annotation.JsonProperty; - public record RecoveryTrainingResponse( - Long id, - @JsonProperty("회복 프로그램 이름") String recoveryProgram, // 회복 프로그램 이름 - @JsonProperty("회복훈련 완료 여부") boolean recoveryTraining, // 회복훈련 완료 여부 - @JsonProperty("회복훈련 특이사항") String recoveryNote // 회복훈련 특이사항 + Long id, + String recoveryProgram, // 회복 프로그램 이름 + boolean recoveryTraining, // 회복훈련 완료 여부 + boolean isCognitiveTrainingProvided, // 인지훈련 제공 여부 + boolean isPhysicalTherapyProvided, // 물리치료 제공 여부 + String recoveryNote // 회복훈련 특이사항 ) { } diff --git a/src/main/java/dbdr/domain/chart/entity/BodyManagement.java b/src/main/java/dbdr/domain/chart/entity/BodyManagement.java index c3e9f45d..e378241d 100644 --- a/src/main/java/dbdr/domain/chart/entity/BodyManagement.java +++ b/src/main/java/dbdr/domain/chart/entity/BodyManagement.java @@ -22,13 +22,24 @@ public class BodyManagement extends BaseEntity { @Embedded public PhysicalMeal physicalMeal; // 식사 종류와 섭취량 - @Embedded - public PhysicalWalk physicalWalk; // 산책 or 외출 동행 + @Embedded public PhysicalClear physicalClear; // 세면 및 목욕 체크박스 + @Comment("화장실 횟수") private int physicalRestroom; // 화장실 횟수 + @Comment("특이사항") @Column(columnDefinition = "TEXT") private String physicalNote; // 특이사항 입력 + + @Comment("체위 변경 유무") + private boolean isPositionChangeRequired; // 체위 변경 유무 + + @Comment("이동 도움 유무") + private boolean isMobilityAssistance; // 이동 도움 유무 + + @Comment("특이사항") + private boolean hasWalked;// 산책 + } diff --git a/src/main/java/dbdr/domain/chart/entity/CognitiveManagement.java b/src/main/java/dbdr/domain/chart/entity/CognitiveManagement.java index c29358ea..9beed62a 100644 --- a/src/main/java/dbdr/domain/chart/entity/CognitiveManagement.java +++ b/src/main/java/dbdr/domain/chart/entity/CognitiveManagement.java @@ -1,15 +1,14 @@ package dbdr.domain.chart.entity; -import org.hibernate.annotations.Comment; -import org.hibernate.annotations.SQLDelete; -import org.hibernate.annotations.SQLRestriction; - import dbdr.domain.core.base.entity.BaseEntity; import jakarta.persistence.Column; import jakarta.persistence.Entity; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; +import org.hibernate.annotations.Comment; +import org.hibernate.annotations.SQLDelete; +import org.hibernate.annotations.SQLRestriction; @Entity @Getter @@ -21,6 +20,9 @@ public class CognitiveManagement extends BaseEntity { @Comment("의사소통 도움 여부") private boolean cognitiveHelp; // 의사소통 도움 여부 + @Comment("말벗 및 격려 여부") + private boolean isCompanionshipProvided; // 말벗 및 격려 여부 + @Comment("인지 관리 특이사항") @Column(columnDefinition = "TEXT") private String cognitiveNote; // 인지 관리 특이사항 diff --git a/src/main/java/dbdr/domain/chart/entity/NursingManagement.java b/src/main/java/dbdr/domain/chart/entity/NursingManagement.java index cad75e66..eaccb94c 100644 --- a/src/main/java/dbdr/domain/chart/entity/NursingManagement.java +++ b/src/main/java/dbdr/domain/chart/entity/NursingManagement.java @@ -26,6 +26,15 @@ public class NursingManagement extends BaseEntity { @Comment("체온") private String healthTemperature; // 체온 + @Comment("건강 관리 제공 여부") + private boolean isHealthCareProvided; // 건강 관리 제공 여부 + + @Comment("간호 관리 제공 여부") + private boolean isNursingCareProvided; // 간호 관리 제공 여부 + + @Comment("응급 관리 제공 여부") + private boolean isEmergencyCareProvided; // 응급 관리 제공 여부 + @Comment("특이사항") @Column(columnDefinition = "TEXT") private String healthNote; // 건강 및 간호관리 특이사항 diff --git a/src/main/java/dbdr/domain/chart/entity/RecoveryTraining.java b/src/main/java/dbdr/domain/chart/entity/RecoveryTraining.java index 1e3d31b5..ec8bc814 100644 --- a/src/main/java/dbdr/domain/chart/entity/RecoveryTraining.java +++ b/src/main/java/dbdr/domain/chart/entity/RecoveryTraining.java @@ -26,6 +26,12 @@ public class RecoveryTraining extends BaseEntity { @Comment("회복 훈련 완료 여부") private boolean recoveryTraining; // 회복훈련 완료 여부 + @Comment("인지훈련 제공 여부") + private boolean isCognitiveTrainingProvided; // 인지훈련 제공 여부 + + @Comment("물리치료 제공 여부") + private boolean isPhysicalTherapyProvided; // 물리치료 제공 여부 + @Comment("회복 훈련 특이사항") @Column(columnDefinition = "TEXT") private String recoveryNote; // 회복훈련 특이사항 diff --git a/src/main/java/dbdr/domain/institution/controller/InstitutionAdminController.java b/src/main/java/dbdr/domain/institution/controller/InstitutionAdminController.java index f91eb331..24128d40 100644 --- a/src/main/java/dbdr/domain/institution/controller/InstitutionAdminController.java +++ b/src/main/java/dbdr/domain/institution/controller/InstitutionAdminController.java @@ -37,7 +37,7 @@ public ResponseEntity> showAllInstitution() { @Operation(summary = "요양원 하나의 정보 조회") @GetMapping("/{institutionId}") public ResponseEntity showOneInstitution(@PathVariable("institutionId") Long institutionId) { - InstitutionResponse institutionResponse = institutionService.getInstitutionById(institutionId); + InstitutionResponse institutionResponse = institutionService.getInstitutionResponseById(institutionId); return ResponseEntity.ok(institutionResponse); } @@ -53,9 +53,9 @@ public ResponseEntity addInstitution( @Operation(summary = "요양원 정보 수정") @PutMapping("/{institutionId}") public ResponseEntity updateInstitution(@PathVariable("institutionId") Long institutionId, - @Valid @RequestBody InstitutionRequest institutionRequest) { + @Valid @RequestBody InstitutionRequest institutionRequest) { InstitutionResponse institutionResponse = institutionService.updateInstitution(institutionId, - institutionRequest); + institutionRequest); return ResponseEntity.ok(institutionResponse); } diff --git a/src/main/java/dbdr/domain/institution/service/InstitutionService.java b/src/main/java/dbdr/domain/institution/service/InstitutionService.java index 436c85d5..11e659f5 100644 --- a/src/main/java/dbdr/domain/institution/service/InstitutionService.java +++ b/src/main/java/dbdr/domain/institution/service/InstitutionService.java @@ -4,10 +4,9 @@ import dbdr.domain.institution.dto.response.InstitutionResponse; import dbdr.domain.institution.entity.Institution; import dbdr.domain.institution.repository.InstitutionRepository; -import java.util.List; - import dbdr.global.exception.ApplicationError; import dbdr.global.exception.ApplicationException; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -31,7 +30,7 @@ public InstitutionResponse getInstitutionResponseById(Long id) { public InstitutionResponse updateInstitution(Long institutionId, InstitutionRequest institutionRequest) { ensureUniqueInstitutionNumber(institutionRequest.institutionNumber()); - Institution institution = getInstitution(institutionId); + Institution institution = getInstitutionById(institutionId); institution.updateInstitution(institutionRequest.institutionNumber(), institutionRequest.institutionName()); institutionRepository.save(institution); return new InstitutionResponse(institutionRequest.institutionNumber(), @@ -55,7 +54,7 @@ public InstitutionResponse addInstitution(InstitutionRequest institutionRequest) } public void deleteInstitutionById(Long institutionId) { - Institution institution = getInstitution(institutionId); + Institution institution = getInstitutionById(institutionId); institution.deactivate(); institutionRepository.delete(institution); } diff --git a/src/main/java/dbdr/domain/recipient/service/RecipientService.java b/src/main/java/dbdr/domain/recipient/service/RecipientService.java index af4ed04f..bd33762c 100644 --- a/src/main/java/dbdr/domain/recipient/service/RecipientService.java +++ b/src/main/java/dbdr/domain/recipient/service/RecipientService.java @@ -10,13 +10,12 @@ import dbdr.domain.recipient.repository.RecipientRepository; import dbdr.global.exception.ApplicationError; import dbdr.global.exception.ApplicationException; +import java.util.List; +import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.util.List; -import java.util.stream.Collectors; - @Service @RequiredArgsConstructor public class RecipientService { @@ -60,7 +59,8 @@ public RecipientResponseDTO createRecipient(RecipientRequestDTO recipientRequest } @Transactional - public RecipientResponseDTO updateRecipient(Long recipientId, RecipientRequestDTO recipientRequestDTO, Long institutionId, Long careworkerId) { + public RecipientResponseDTO updateRecipient(Long recipientId, RecipientRequestDTO recipientRequestDTO, + Long institutionId, Long careworkerId) { Recipient recipient = findRecipientById(recipientId); // 권한 검증 @@ -71,7 +71,7 @@ public RecipientResponseDTO updateRecipient(Long recipientId, RecipientRequestDT } @Transactional - public void deleteRecipient(Long recipientId, Long institutionId, Long careworkerId) { + public void deleteRecipient(Long recipientId, Long institutionId, Long careworkerId) { Recipient recipient = findRecipientById(recipientId); // 권한 검증 @@ -99,7 +99,7 @@ private void validateAccessPermission(Recipient recipient, Long institutionId, L } } - private Recipient findRecipientById(Long recipientId) { + public Recipient findRecipientById(Long recipientId) { return recipientRepository.findById(recipientId) .orElseThrow(() -> new ApplicationException(ApplicationError.RECIPIENT_NOT_FOUND)); } @@ -125,4 +125,5 @@ private RecipientResponseDTO toResponseDTO(Recipient recipient) { recipient.getCareworker() != null ? recipient.getCareworker().getId() : null ); } -} \ No newline at end of file +} + diff --git a/src/test/java/dbdr/chart/ChartMapperTest.java b/src/test/java/dbdr/chart/ChartMapperTest.java index 4189ccce..8d4257fc 100644 --- a/src/test/java/dbdr/chart/ChartMapperTest.java +++ b/src/test/java/dbdr/chart/ChartMapperTest.java @@ -1,8 +1,7 @@ package dbdr.chart; import static org.assertj.core.api.Assertions.assertThat; - -import java.time.LocalDate; +import static org.mockito.Mockito.when; import dbdr.domain.chart.dto.ChartMapper; import dbdr.domain.chart.dto.request.BodyManagementRequest; @@ -19,15 +18,24 @@ import dbdr.domain.chart.entity.NursingManagement; import dbdr.domain.chart.entity.PhysicalClear; import dbdr.domain.chart.entity.PhysicalMeal; -import dbdr.domain.chart.entity.PhysicalWalk; +import dbdr.domain.institution.entity.Institution; import dbdr.domain.recipient.entity.Recipient; - +import dbdr.domain.recipient.service.RecipientService; +import java.time.LocalDate; import org.junit.jupiter.api.Test; -import org.mapstruct.factory.Mappers; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.mock.mockito.MockBean; +@SpringBootTest public class ChartMapperTest { - private final ChartMapper chartMapper = Mappers.getMapper(ChartMapper.class); + @Autowired + private ChartMapper chartMapper; + + @MockBean + private RecipientService recipientService; + @Test void testToResponse_chartToChartDetailResponse() { @@ -45,24 +53,30 @@ void testToResponse_chartToChartDetailResponse() { @Test void testToEntity_chartDetailRequestToChart() { // given + Long recipientId = 1L; + Institution institution = Institution.builder() + .institutionName("HealthCare Institution") + .institutionNumber(100L) + .build(); Recipient recipient = Recipient.builder() - .name("John Doe") - .birth(LocalDate.of(1950, 1, 1)) - .gender("Male") - .careLevel("Level 1") - .careNumber("12345678") - .startDate(LocalDate.of(2020, 1, 1)) - .institution("HealthCare Institution") - .institutionNumber(100L) - .build(); - + .name("John Doe") + .birth(LocalDate.of(1950, 1, 1)) + .gender("Male") + .careLevel("Level 1") + .careNumber("12345678") + .startDate(LocalDate.of(2020, 1, 1)) + .institution(institution) + .institutionNumber(100L) + .build(); + + when(recipientService.findRecipientById(recipientId)).thenReturn(recipient); ChartDetailRequest request = new ChartDetailRequest( - "Flu", - recipient, - new BodyManagementRequest(true, false, "Lunch", "Full", 3, true, false, "Good"), - new NursingManagementRequest(120, 80, "36.5", "All good"), - new CognitiveManagementRequest(true, "No issues"), - new RecoveryTrainingRequest("Physical Therapy", true, "Completed") + "Flu", + recipientId, + new BodyManagementRequest(true, false, "Lunch", "Full", 3, true, false, true, "Good"), + new NursingManagementRequest(120, 80, "36.5", true, true, true, "All good"), + new CognitiveManagementRequest(true, true, "No issues"), + new RecoveryTrainingRequest("Physical Therapy", true, true, true, "Completed") ); // when @@ -75,7 +89,7 @@ void testToEntity_chartDetailRequestToChart() { assertThat(chart.getRecipient().getName()).isEqualTo("John Doe"); assertThat(chart.getNursingManagement()).isNotNull(); assertThat(chart.getBodyManagement().getPhysicalMeal().getMealType()).isEqualTo( - request.bodyManagement().mealType()); + request.bodyManagement().mealType()); } @Test @@ -83,8 +97,8 @@ void testToResponse_bodyManagementToBodyManagementResponse() { // given PhysicalClear physicalClear = new PhysicalClear(true, false); PhysicalMeal physicalMeal = new PhysicalMeal("Lunch", "Full"); - PhysicalWalk physicalWalk = new PhysicalWalk(true, false); - BodyManagement bodyManagement = new BodyManagement(physicalMeal, physicalWalk, physicalClear, 3, "Good"); + + BodyManagement bodyManagement = new BodyManagement(physicalMeal, physicalClear, 3, "Good", true, true, true); // when BodyManagementResponse response = chartMapper.toResponse(bodyManagement); @@ -101,7 +115,7 @@ void testToResponse_bodyManagementToBodyManagementResponse() { void testToEntity_bodyManagementRequestToBodyManagement() { // given BodyManagementRequest request = new BodyManagementRequest( - true, false, "Lunch", "Full", 3, true, false, "Good" + true, false, "Lunch", "Full", 3, true, false, false, "Good" ); // when @@ -119,7 +133,8 @@ void testToEntity_bodyManagementRequestToBodyManagement() { void testToResponse_nursingManagementToNursingManagementResponse() { // given HealthBloodPressure healthBloodPressure = new HealthBloodPressure(120, 80); - NursingManagement nursingManagement = new NursingManagement(healthBloodPressure, "36.5", "All good"); + NursingManagement nursingManagement = new NursingManagement(healthBloodPressure, "36.5", true, true, true, + "All good"); // when NursingManagementResponse response = chartMapper.toResponse(nursingManagement); @@ -133,7 +148,7 @@ void testToResponse_nursingManagementToNursingManagementResponse() { @Test void testToEntity_nursingManagementRequestToNursingManagement() { // given - NursingManagementRequest request = new NursingManagementRequest(120, 80, "36.5", "All good"); + NursingManagementRequest request = new NursingManagementRequest(120, 80, "36.5", true, true, true, "All good"); // when NursingManagement nursingManagement = chartMapper.toEntity(request); diff --git a/src/test/resources/application.yml b/src/test/resources/application.yml index 918aa915..df858014 100644 --- a/src/test/resources/application.yml +++ b/src/test/resources/application.yml @@ -1,9 +1,24 @@ -spring : - config : - test : - institution : - loginId : "testInstitution" - loginPassword : "passwordInstitution" - institutionNumber : "123" - institutionName : "돌다리요양원" +spring: + config: + test: + institution: + loginId: "testInstitution" + loginPassword: "passwordInstitution" + institutionNumber: "123" + institutionName: "돌다리요양원" + jwt: + secret: test + authheader: header + app: + version: v1 + + data: + redis: + port: 1000 + host: "host" + +line: + bot: + channel-token: "TEST" +