-
Notifications
You must be signed in to change notification settings - Fork 2
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
feat(#59) : 약 복용률 계산하는 메서드 추가, #61
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
87388fe
tmp : 통계 티이블
j2noo 92b47c8
refactor(#59) : 약 복용 정보 등록 당일만 가능하도록 수정
j2noo aad934a
Feat(#59) : 약 복용률 계산하는 메서드 완성
j2noo d6c3ca4
delete(#59) : 통계 테이블제거
j2noo 3e69270
feat(#59) : swagger에서 null 포함하지 않는 어노테이션 공통적으로 추가
j2noo 70c63df
fix(#59) : 스웨거 @Operation 개행 수정
j2noo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
src/main/java/com/remind/api/connection/dto/response/AcceptConnectionResponseDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
src/main/java/com/remind/api/connection/dto/response/RequestConnectionResponseDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
src/main/java/com/remind/api/member/dto/CautionPatientDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
src/main/java/com/remind/api/member/dto/response/KakaoGetMemberInfoResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
src/main/java/com/remind/api/member/dto/response/KakaoLoginResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
src/main/java/com/remind/api/member/dto/response/OnboardingResponseDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
package com.remind.api.member.dto.response; | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import com.remind.core.domain.member.enums.RolesType; | ||
import lombok.Builder; | ||
|
||
@Builder | ||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
public record OnboardingResponseDto(Long userId, RolesType rolesType) { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
src/main/java/com/remind/api/member/dto/response/TokenResponseDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
src/main/java/com/remind/api/member/service/PatientService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package com.remind.api.member.service; | ||
|
||
import com.remind.api.takingMedicine.service.TakingMedicineService; | ||
import com.remind.core.domain.common.enums.MemberErrorCode; | ||
import com.remind.core.domain.common.enums.PresciptionErrorCode; | ||
import com.remind.core.domain.common.exception.MemberException; | ||
import com.remind.core.domain.common.exception.PrescriptionException; | ||
import com.remind.core.domain.member.Member; | ||
import com.remind.core.domain.member.Patient; | ||
import com.remind.core.domain.member.repository.MemberRepository; | ||
import com.remind.core.domain.member.repository.PatientRepository; | ||
import com.remind.core.domain.prescription.Prescription; | ||
import com.remind.core.domain.prescription.repository.PrescriptionRepository; | ||
import com.remind.core.domain.takingMedicine.enums.MedicinesType; | ||
import com.remind.core.domain.takingMedicine.repository.TakingMedicineRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class PatientService { | ||
private final PrescriptionRepository prescriptionRepository; | ||
private final PatientRepository patientRepository; | ||
private final MemberRepository memberRepository; | ||
private final TakingMedicineRepository takingMedicineRepository; | ||
|
||
/** | ||
* 환자id와 처방id로 복용률을 업데이트 하는 메서드 | ||
* @param patientId | ||
* @param prescriptionId | ||
*/ | ||
public void updateTakingMedicineRate(Long patientId, Long prescriptionId) { | ||
Prescription prescription = prescriptionRepository.findById(prescriptionId) | ||
.orElseThrow(() -> new PrescriptionException(PresciptionErrorCode.PRESCRIPTION_NOT_FOUND)); | ||
Patient patient = patientRepository.findById(patientId) | ||
.orElseThrow(() -> new MemberException(MemberErrorCode.MEMBER_NOT_FOUND)); | ||
Member member = memberRepository.findById(patientId) | ||
.orElseThrow(() -> new MemberException(MemberErrorCode.MEMBER_NOT_FOUND)); | ||
|
||
// 아침, 점심, 저녁 약 실제 복용 횟수 | ||
int realBreakfastCount = takingMedicineRepository.countByPrescriptionIdAndMedicinesType(prescriptionId, MedicinesType.BREAKFAST); | ||
int realLunchCount = takingMedicineRepository.countByPrescriptionIdAndMedicinesType(prescriptionId, MedicinesType.LUNCH); | ||
int realDinnerCount = takingMedicineRepository.countByPrescriptionIdAndMedicinesType(prescriptionId, MedicinesType.DINNER); | ||
int realCount = realBreakfastCount + realLunchCount + realDinnerCount; | ||
|
||
// 아침, 점심, 저녁에 먹어야하는 복용 횟수 | ||
int totalBreakfastCount = prescription.getBreakfastImportance() == 0 ? 0 : (prescription.getPeriod() + 1); | ||
int totalLunchCount = prescription.getLunchImportance() == 0 ? 0 : (prescription.getPeriod() + 1); | ||
int totalDinnerCount = prescription.getDinnerImportance() == 0 ? 0 : (prescription.getPeriod() + 1); | ||
int totalCount = totalBreakfastCount + totalLunchCount + totalDinnerCount; | ||
|
||
|
||
Double breakfastRate = totalBreakfastCount == 0 ? 0 : (double)realBreakfastCount / totalBreakfastCount; | ||
Double lunchRate = totalLunchCount == 0 ? 0 : (double)realLunchCount / totalLunchCount; | ||
Double dinnerRate = totalDinnerCount == 0 ? 0 : (double) realDinnerCount / totalDinnerCount; | ||
Double totalRate = totalCount == 0 ? 0 : (double)realCount / totalCount; | ||
|
||
|
||
patient.updateTakingMedicineRate(breakfastRate, lunchRate, dinnerRate, totalRate); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
src/main/java/com/remind/api/prescription/dto/response/CreatePrescriptionResponseDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
src/main/java/com/remind/api/takingMedicine/dto/response/CreateTakingMedicineResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
...main/java/com/remind/api/takingMedicine/dto/response/DailyTakingMedicineInfoResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
비즈니스 로직이 만약 아침 약이 없으면 중요도 0으로 들어가고 아침 약이 존재하면 중요도가 무조건 >=1인거야?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
어어 맞아. 중요도를 입력하지 않으면 해당 약이 없는거!