Skip to content

Commit

Permalink
Merge pull request #35 from Sirius506775/develope
Browse files Browse the repository at this point in the history
[BE / Feat] 환자의 비대면 진료기록 목록을 조회한다.
  • Loading branch information
Sirius506775 authored Nov 17, 2023
2 parents 47b976e + 5f1287f commit 3b6927d
Show file tree
Hide file tree
Showing 9 changed files with 86 additions and 38 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,11 @@ jobs:
port: ${{ secrets.NCP_SERVER_PORT }}
script: |
docker login -u ${{ secrets.NCP_ACCESS_KEY }} -p ${{ secrets.NCP_SECRET_KEY }} ${{ secrets.NCP_CONTAINER_REGISTRY }}
docker pull ${{ secrets.NCP_CONTAINER_REGISTRY }}/rehab-server:${{ steps.timestamp.outputs.timestamp }}
latest_tag=$(docker pull --quiet ${{ secrets.NCP_CONTAINER_REGISTRY }}/rehab-server:latest | grep -oP "(?<=digest: ).*")
docker pull --quiet ${{ secrets.NCP_CONTAINER_REGISTRY }}/rehab-server:${latest_tag}
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
docker run -d -p 443:443 ${{ secrets.NCP_CONTAINER_REGISTRY }}/rehab-server:${{ steps.timestamp.outputs.timestamp }}
docker run -d -p 443:443 ${{ secrets.NCP_CONTAINER_REGISTRY }}/rehab-server:${latest_tag}
docker image prune -f
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.hallym.rehab.domain.chart.controller;

import com.hallym.rehab.domain.chart.dto.AIRecordDTO;
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 @@ -12,6 +13,7 @@
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

@RestController
@RequestMapping("/chart")
Expand All @@ -21,18 +23,27 @@ public class ChartController {

private final ChartService chartService;

@GetMapping("/patient/{mid}")
public ChartResponseDTO getChartOneByPatient(@PathVariable String mid) {
@PreAuthorize("hasAuthority('ROLE_PATIENT')")
@GetMapping("/auth/patient/{patient_mid}")
public ChartResponseDTO getChartOneByPatient(@PathVariable String patient_mid) {

return chartService.getChartDetailByPatient(mid);
return chartService.getChartDetailByPatient(patient_mid);
}

@GetMapping("/staff/{cno}")
@PreAuthorize("hasAuthority('ROLE_DOCTOR') or hasAuthority('ROLE_THERAPIST')")
@GetMapping("/auth/staff/{cno}")
public ChartResponseDTO getChartOneByStaff(@PathVariable Long cno) {

return chartService.getChartDetailByStaff(cno);
}

@PreAuthorize("hasAuthority('ROLE_DOCTOR') or hasAuthority('ROLE_THERAPIST') or hasAuthority('ROLE_PATIENT')")
@GetMapping("/auth/aiRecord/{patient_mid}")
public List<AIRecordDTO> getAIRecordList(@PathVariable String patient_mid) {

return chartService.getAIRecords(patient_mid);
}


@PreAuthorize("hasAuthority('ROLE_DOCTOR')")
@PostMapping("/auth/register")
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/com/hallym/rehab/domain/chart/dto/AIRecordDTO.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.hallym.rehab.domain.chart.dto;

import lombok.*;

import java.time.LocalDate;

@Data
@Getter
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class AIRecordDTO {

private String staff_id;
private String summary;
private LocalDate regDate;
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public class ChartResponseDTO {

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

private LocalDate regDate;

private List<RecordDTO> medicalRecords;

private List<OnlineRecordDTO> OnlineRecords;
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
package com.hallym.rehab.domain.chart.service;

import com.hallym.rehab.domain.chart.dto.AIRecordDTO;
import com.hallym.rehab.domain.chart.dto.ChartRequestDTO;
import com.hallym.rehab.domain.chart.dto.ChartResponseDTO;
import com.hallym.rehab.global.pageDTO.PageRequestDTO;
import com.hallym.rehab.global.pageDTO.PageResponseDTO;

import java.util.List;

public interface ChartService {

ChartResponseDTO getChartDetailByPatient(String mid);

ChartResponseDTO getChartDetailByStaff(Long cno);

List<AIRecordDTO> getAIRecords(String patient_id);

String registerChartDetails(ChartRequestDTO registerDTO);

void deleteChartDetails(Long cno);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package com.hallym.rehab.domain.chart.service;

import com.amazonaws.services.kms.model.NotFoundException;
import com.hallym.rehab.domain.chart.dto.AIRecordDTO;
import com.hallym.rehab.domain.chart.dto.ChartRequestDTO;
import com.hallym.rehab.domain.chart.dto.ChartResponseDTO;
import com.hallym.rehab.domain.chart.dto.RecordDTO;
import com.hallym.rehab.domain.chart.entity.Chart;
import com.hallym.rehab.domain.chart.entity.Record;
import com.hallym.rehab.domain.chart.repository.ChartRepository;
import com.hallym.rehab.domain.chart.repository.RecordRepository;
import com.hallym.rehab.domain.reservation.entity.Reservation;
import com.hallym.rehab.domain.reservation.repository.ReservationRepository;
import com.hallym.rehab.domain.user.entity.MemberRole;
import com.hallym.rehab.domain.user.entity.Patient;
import com.hallym.rehab.domain.user.entity.Staff;
Expand All @@ -22,29 +25,23 @@
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
import java.time.LocalDate;
import java.util.*;
import java.util.stream.Collectors;

@Service
@Transactional
@RequiredArgsConstructor
@Slf4j
public class ChartServiceImpl implements ChartService{
public class ChartServiceImpl implements ChartService {

private final ChartRepository chartRepository;
private final StaffRepository staffRepository;
private final PatientRepository patientRepository;
private final RecordRepository recordRepository;
private final ReservationRepository reservationRepository;
private final PasswordEncoder passwordEncoder;

/**
* 환자 차트 정보 단일 조회
* @param cno chart의 pk
* @return Chart 엔티티를 변환한 ChartResponseDTO를 반환
*/
@Override
public ChartResponseDTO getChartDetailByPatient(String patient_id) {

Expand All @@ -67,8 +64,32 @@ public ChartResponseDTO getChartDetailByStaff(Long cno) {
return entityToDTO(chart);
}

@Override
public List<AIRecordDTO> getAIRecords(String patient_id) {
List<Reservation> reservations = reservationRepository.findAllByPatientMidWithSummary(patient_id);

List<AIRecordDTO> aiRecords = new ArrayList<>();

for (Reservation reservation : reservations) {
String staff_id = reservation.getStaff().getMid();
String summary = reservation.getRoom().getAudio().getSummary();
LocalDate summaryDate = LocalDate.from(reservation.getRoom().getRegDate());

AIRecordDTO aiRecord = AIRecordDTO.builder()
.staff_id(staff_id)
.summary(summary)
.regDate(summaryDate)
.build();

aiRecords.add(aiRecord);
}

return aiRecords;
}

/**
* 환자 차트 신규 등록
*
* @param registerDTO
*/
@Override
Expand All @@ -87,6 +108,7 @@ public String registerChartDetails(ChartRequestDTO registerDTO) {

/**
* 환자 차트 삭제
*
* @param cno chart의 pk
*/
@Override
Expand All @@ -97,7 +119,8 @@ public void deleteChartDetails(Long cno) {

/**
* 나의 담당 환자 차트 목록 조회
* @param doctor_id 담당 의사의 pk
*
* @param doctor_id 담당 의사의 pk
* @param pageRequestDTO
* @return
*/
Expand All @@ -120,7 +143,6 @@ public PageResponseDTO<ChartResponseDTO> getChartList(String doctor_id, PageRequ
return responseDTO;
}


public ChartResponseDTO entityToDTO(Chart chart) {

List<Record> recordList = recordRepository.findRecordByChart(chart);
Expand All @@ -129,7 +151,7 @@ public ChartResponseDTO entityToDTO(Chart chart) {
.map(RecordDTO::of)
.collect(Collectors.toList());

ChartResponseDTO chartResponseDTO = ChartResponseDTO.builder()
return ChartResponseDTO.builder()
.cno(chart.getCno())
.cd(chart.getCd())
.phone(chart.getPhone())
Expand All @@ -140,9 +162,8 @@ public ChartResponseDTO entityToDTO(Chart chart) {
.doctor_name(chart.getDoctor().getName())
.therapist_name(chart.getTherapist().getName())
.medicalRecords(recordDTOList)
.regDate(LocalDate.from(chart.getRegDate()))
.build();

return chartResponseDTO;
}

public Chart dtoToEntity(ChartRequestDTO chartRequestDTO) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,8 @@ public interface ReservationRepository extends JpaRepository<Reservation, Long>

@Query("SELECT r FROM Reservation r WHERE (r.patient.mid = :mid or r.staff.mid = :mid) and r.is_deleted = false")
Page<Reservation> findByMid(@Param("mid") String mid, Pageable pageable);

@Query("SELECT r FROM Reservation r WHERE r.patient.mid = :patient_id ORDER BY r.room.regDate ASC")
List<Reservation> findAllByPatientMidWithSummary(@Param("patient_id") String patientId);

}
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,15 @@ void createAudio() throws IOException, InterruptedException {
AudioRequestDTO user = AudioRequestDTO.builder()
.audioFile(patientAudioFile)
.rno(room.getRno())
.is_user(true).build();
.is_patient(true).build();

String result = audioService.registerAudio(user);
assertThat(result).isEqualTo("Success create Audio");

AudioRequestDTO admin = AudioRequestDTO.builder()
.audioFile(doctorAudioFile)
.rno(room.getRno())
.is_user(false).build();
.is_patient(false).build();

audioService.registerAudio(admin);
assertThat(result).isEqualTo("Success create Audio");
Expand Down

0 comments on commit 3b6927d

Please sign in to comment.