Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: chart #71

Merged
merged 12 commits into from
Nov 4, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -33,33 +35,38 @@
public class CareWorkerChartController {
private final ChartService chartService;

@Operation(summary = "돌봄대상자 아이디로 차트 정보 조회")
@Operation(summary = "돌봄대상자 아이디로 차트 정보 조회",
security = @SecurityRequirement(name = "JWT"))
@GetMapping("/recipient")
public ResponseEntity<ApiUtils.ApiResult<Page<ChartDetailResponse>>> 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) {
// 환자 정보 접근 권한 확인 로직 필요 -> 요양사가 맡은 환자 정보만 조회 가능
Page<ChartDetailResponse> recipients = chartService.getAllChartByRecipientId(recipientId, pageable);
return ResponseEntity.ok(ApiUtils.success(recipients));
}

@Operation(summary = "차트 아이디로 차트 정보 조회")
@Operation(summary = "차트 아이디로 차트 정보 조회",
security = @SecurityRequirement(name = "JWT"))
@GetMapping("/{chartId}")
public ResponseEntity<ApiUtils.ApiResult<ChartDetailResponse>> getChartById(@PathVariable("chartId") Long chartId) {
// 환자 정보 접근 권한 확인 로직 필요 -> 요양사가 맡은 환자 정보만 조회 가능
ChartDetailResponse chart = chartService.getChartById(chartId);
return ResponseEntity.ok(ApiUtils.success(chart));
}

@Operation(summary = "차트 추가")
@Operation(summary = "차트 추가",
security = @SecurityRequirement(name = "JWT"))
@PostMapping
public ResponseEntity<ApiUtils.ApiResult<ChartDetailResponse>> saveChart(@RequestBody ChartDetailRequest request) {
// 환자 정보 접근 권한 확인 로직 필요 -> 요양사가 맡은 환자 정보만 저장 가능
ChartDetailResponse chart = chartService.saveChart(request);
return ResponseEntity.status(HttpStatus.CREATED).body(ApiUtils.success(chart));
}

@Operation(summary = "차트 아이디로 차트 수정")
@Operation(summary = "차트 아이디로 차트 수정",
security = @SecurityRequirement(name = "JWT"))
@PutMapping("/{chartId}")
public ResponseEntity<ApiUtils.ApiResult<ChartDetailResponse>> updateChart(@PathVariable("chartId") Long chartId,
@RequestBody ChartDetailRequest request) {
Expand All @@ -68,7 +75,8 @@ public ResponseEntity<ApiUtils.ApiResult<ChartDetailResponse>> updateChart(@Path
return ResponseEntity.ok(ApiUtils.success(chart));
}

@Operation(summary = "차트 아이디로 차트 삭제")
@Operation(summary = "차트 아이디로 차트 삭제",
security = @SecurityRequirement(name = "JWT"))
@DeleteMapping("/{chartId}")
public ResponseEntity<ApiUtils.ApiResult<String>> deleteChart(@PathVariable("chartId") Long chartId) {
// 환자 정보 접근 권한 확인 로직 필요 -> 요양사가 맡은 환자 정보만 삭제 가능
Expand Down
58 changes: 32 additions & 26 deletions src/main/java/dbdr/domain/chart/dto/ChartMapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 // 특이사항 입력
) {
}
35 changes: 17 additions & 18 deletions src/main/java/dbdr/domain/chart/dto/request/ChartDetailRequest.java
Original file line number Diff line number Diff line change
@@ -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
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 // 인지 관리 특이사항
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 // 건강 및 간호관리 특이사항
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 // 회복훈련 특이사항
) {
}
Original file line number Diff line number Diff line change
@@ -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 // 특이사항 입력
) {
}
Original file line number Diff line number Diff line change
@@ -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 // 인지 관리 특이사항
) {
}
Original file line number Diff line number Diff line change
@@ -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 // 건강 및 간호관리 특이사항
) {
}
Loading