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

[BE / feat] 검색 조건에 따른 환자 차트 정보 목록을 반환한다. #41

Merged
merged 22 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
3538dd8
chore : Change url
Sirius506775 Nov 20, 2023
771685d
chore : Add regDate field in RecordDTO
Sirius506775 Nov 20, 2023
c043552
comment : Add Comment javadoc
Sirius506775 Nov 20, 2023
c7be1eb
feat : Create getMyStaffInfo method in UserController
Sirius506775 Nov 20, 2023
4dd94f3
feat : Create MyStaffDetailDTO to get patient.s staff info
Sirius506775 Nov 20, 2023
6c46b9b
chore : Add valid annotation on dtos
Sirius506775 Nov 20, 2023
1fe70d8
feat : Create getMyStaffInfo service layer
Sirius506775 Nov 20, 2023
a785a1b
refactor : Modify Throwable param in StaffNotFoundException
Sirius506775 Nov 20, 2023
8e78dda
perf : recordSet에 "@BatchSize"를 추가하여 한 번에 가져올 데이터 양 제한 (#25)
Sirius506775 Nov 20, 2023
a15e1c4
feat : 환자 차트 목록 조회에 사용할 ChartListAllDTO 생성 (#25)
Sirius506775 Nov 20, 2023
47ac962
rename : 환자 차트 목록 조회 시, 의사 mid 뿐만이 아닌 staff의 mid를 사용하게끔 파라미터 수정 (#25)
Sirius506775 Nov 20, 2023
f9ffe88
refactor : 환자 차트 목록 조회 시, 검색 조건 sortBy와 metrics_rate 추가 (#25)
Sirius506775 Nov 20, 2023
4bf142e
build : Change ssh-action version
Sirius506775 Nov 20, 2023
984f8aa
refactor : getPageable에 검색 조건 추가
Sirius506775 Nov 20, 2023
149cce7
chore : Add ignore file
Sirius506775 Nov 20, 2023
5505c7b
feat : 재활치료사 정보 반환을 위한 TherapistRespoonseDTO 생성
Sirius506775 Nov 20, 2023
33274d7
rename : userId를 patient_id로 변경
Sirius506775 Nov 20, 2023
0b94f65
feat : Metrics_rate를 반환하는 메소드 분리하여 "@Component"으로 빈 추가
Sirius506775 Nov 20, 2023
b4eea82
feat : 수행도 평균 반환을 위한 metrics_rate 필드 추가
Sirius506775 Nov 20, 2023
b391644
feat : 조건에 따른 환자 차트 목록 조회를 위한 Service Layer 구현
Sirius506775 Nov 20, 2023
0c74ddd
feat : Querydsl을 이용한 목록 조회 클래스 구현
Sirius506775 Nov 20, 2023
7c719b4
Merge branch 'main' into main
Sirius506775 Nov 20, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ jobs:

- name: Unzip application.tar file to application-secret.yml
run: |
whoami
cd $RESOURCE_PATH
tar xvf application.tar
shell: bash
Expand Down Expand Up @@ -74,7 +73,7 @@ jobs:
secrets: |
GIT_AUTH_TOKEN=${{ secrets.GIT_TOKEN }}
- name: Connect to Server and Pull from Container Registry
uses: appleboy/[email protected].4
uses: appleboy/[email protected].6
with:
host: ${{ secrets.NCP_SERVER_IP }}
username: ${{ secrets.NCP_SERVER_USERNAME }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ application-local.yml
application-secret.yml
application-jypRasp.yml
application-email.yml
keystore_contents.txt

*.wav
*.json
Expand Down
37 changes: 37 additions & 0 deletions src/main/java/com/hallym/rehab/domain/chart/MetricsUtil.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.hallym.rehab.domain.chart;

import com.hallym.rehab.domain.video.entity.VideoMetrics;
import com.hallym.rehab.domain.video.repository.VideoMetricsRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.List;
@Component
@RequiredArgsConstructor
public class MetricsUtil {

private final VideoMetricsRepository videoMetricsRepository;

/**
* patient_id를 받아 Metrics들을 찾고 특정 한도를 넘는 것의 비율을 반환
*
* @param patient_id
* @return rate of over70
*/
public double getRateMetricsByPatientId(String patient_id) {
List<VideoMetrics> metricsList = videoMetricsRepository.findMetricsByPatientId(patient_id);

int allCount = metricsList.size();

if (allCount == 0) {
return 0;
}

int over60Count = (int) metricsList.stream()
.filter(metrics -> metrics.getMetrics() >= 60)
.count();

return (double) over60Count / allCount * 100;
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.hallym.rehab.domain.chart.controller;

import com.hallym.rehab.domain.chart.dto.AIRecordDTO;
import com.hallym.rehab.domain.chart.dto.ChartListAllDTO;
import com.hallym.rehab.domain.chart.dto.ChartRequestDTO;
import com.hallym.rehab.domain.chart.dto.ChartResponseDTO;
import com.hallym.rehab.domain.chart.service.ChartService;
Expand All @@ -16,55 +17,83 @@
import java.util.List;

@RestController
@RequestMapping("/chart")
@RequiredArgsConstructor
@Slf4j
public class ChartController {

private final ChartService chartService;

@PreAuthorize("hasAuthority('ROLE_PATIENT')")
@GetMapping("/auth/patient/{patient_mid}")
/**
* 환자는 본인의 차트 정보를 조회힌다.
* @param patient_mid
* @return ChartResponseDTO
*/
@GetMapping("/chart/patient/{patient_mid}")
public ChartResponseDTO getChartOneByPatient(@PathVariable String patient_mid) {

return chartService.getChartDetailByPatient(patient_mid);
}

/**
* 로그인한 의료진은 나의 환자 차트 목록에서 cno로 특정 차트를 상세 조회한다.
* @param cno
* @return ChartResponseDTO
*/
@PreAuthorize("hasAuthority('ROLE_DOCTOR') or hasAuthority('ROLE_THERAPIST')")
@GetMapping("/auth/staff/{cno}")
@GetMapping("/auth/chart/{cno}")
public ChartResponseDTO getChartOneByStaff(@PathVariable Long cno) {

return chartService.getChartDetailByStaff(cno);
}

/**
* AI비대면 요약 정보 목록을 조회한다.
* @param patient_mid
* @return AIRecordDT의 List
*/
@PreAuthorize("hasAuthority('ROLE_DOCTOR') or hasAuthority('ROLE_THERAPIST') or hasAuthority('ROLE_PATIENT')")
@GetMapping("/auth/aiRecord/{patient_mid}")
@GetMapping("/auth/aiRecordList/{patient_mid}")
public List<AIRecordDTO> getAIRecordList(@PathVariable String patient_mid) {

return chartService.getAIRecords(patient_mid);
}


/**
* 로그인 한 의사는 환자 차트를 신규 등록한다.
* @param chartRequestDTO
* @return 신규 환자 mid
*/
@PreAuthorize("hasAuthority('ROLE_DOCTOR')")
@PostMapping("/auth/register")
@PostMapping("/auth/chart/register")
public String registerChart(@Valid @RequestBody ChartRequestDTO chartRequestDTO) {

return chartService.registerChartDetails(chartRequestDTO);
}

/**
* 의사는 차트를 삭제한다.
* @param cno
* @return 성공 시, "차트 삭제 완료" 반환
*/
@PreAuthorize("hasAuthority('ROLE_DOCTOR')")
@PostMapping("/auth/delete")
@PostMapping("/auth/chart/delete")
public ResponseEntity<String> deleteChart(@PathVariable Long cno) {

chartService.deleteChartDetails(cno);
return ResponseEntity.ok("차트 삭제 완료");
}

@PreAuthorize("hasAuthority('ROLE_DOCTOR') and authentication.principal.username == #doctor_id")
@GetMapping("/auth/list/{doctor_id}")
public PageResponseDTO<ChartResponseDTO> getChartList(PageRequestDTO pageRequestDTO, @PathVariable String doctor_id){
/**
* 로그인한 의료진은 mid를 전달하여 내가 담당한 환자의 차트 목록을 조회한다.
* @param mid #doctor pk or therapist pk
* @return PageResponseDTO<ChartListAllDTO>
*/
@PreAuthorize("hasAuthority('ROLE_DOCTOR') or hasAuthority('ROLE_THERAPIST')")
@GetMapping("/auth/chart/list/{mid}")
public PageResponseDTO<ChartListAllDTO> getChartList(PageRequestDTO pageRequestDTO, @PathVariable String mid){

return chartService.getChartList(doctor_id, pageRequestDTO);
return chartService.getChartList(mid, pageRequestDTO);
}


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.hallym.rehab.domain.chart.dto;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDate;
import java.util.List;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class ChartListAllDTO {

private long cno;

private String cd; //질병분류기호

private String phone;

private String sex;

private LocalDate birth;

private String patient_id; // 환자 ID

private String patient_name; //환자성함

private String doctor_name; // 담당의사

private String therapist_name; // 담당재활치료사

private double metrics_rate;

private LocalDate regDate;

private List<RecordDTO> medicalRecords;
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ public class RecordDTO {
private LocalDate schedule; //외래 일정
private String treatmentRecord; //진료 기록
private String exerciseRequest; //운동요청서
private LocalDate regDate;

public static RecordDTO of(Record record) {
return RecordDTO.builder()
.schedule(record.getSchedule())
.treatmentRecord(record.getTreatmentRecord())
.exerciseRequest(record.getExerciseRequest())
.record_no(record.getRecord_no())
.regDate(LocalDate.from(record.getRegDate()))
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.hallym.rehab.domain.user.entity.Staff;
import com.hallym.rehab.global.baseEntity.BaseTimeEntity;
import lombok.*;
import org.hibernate.annotations.BatchSize;
import org.hibernate.annotations.ColumnDefault;

import javax.persistence.*;
Expand Down Expand Up @@ -39,6 +40,8 @@ public class Chart extends BaseTimeEntity {
@Column(nullable = false)
private LocalDate birth; //생년월일

private Double metrics_rate;

@JsonBackReference
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "doctor_mid", nullable = false)
Expand All @@ -49,7 +52,7 @@ public class Chart extends BaseTimeEntity {
@JoinColumn(name = "therapist_mid", nullable = false)
private Staff therapist; // 담당재활치료사

@Builder.Default
@BatchSize(size = 10)
@OneToMany(mappedBy = "record_no", cascade = CascadeType.ALL)
private Set<Record> recordSet = new HashSet<>();;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package com.hallym.rehab.domain.chart.repository.search;

import com.hallym.rehab.domain.chart.entity.Chart;
import com.hallym.rehab.global.pageDTO.PageRequestDTO;
import com.hallym.rehab.domain.chart.dto.ChartListAllDTO;
import com.hallym.rehab.domain.user.entity.MemberRole;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;

public interface ChartSearch {

Page<Chart> search(PageRequestDTO pageRequestDTO);

Page<Chart> searchChartWithRecord(String doctor_id, PageRequestDTO pageRequestDTO);
Page<ChartListAllDTO> searchChartWithRecord(String mid, MemberRole role, String[] types, String keyword, String sortBy, Pageable pageable);
}
Loading
Loading