Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public MedicationGroupItemResponse toGroupItemResponse(Medication medication) {
medication.getStartDate(),
medication.getEndDate(),
medication.getTotalDays(),
medication.getUsageStorageInfo(),
medication.getMemo()
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ public record MedicationCreateRequest(
@Schema(description = "병원 이름 — 직접 입력, 없으면 null")
String hospitalName,

@Schema(description = "메모 (복용방법 + 보관방법 자동 생성 또는 사용자 직접 입력, 없으면 null)")
@Schema(description = "사용자 자유 입력 메모 (항상 빈값으로 시작, 없으면 null)")
String memo
) {}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ public record MedicationGroupItemResponse(
@Schema(description = "총 복용 일수 (없으면 null)")
Integer totalDays,

@Schema(description = "메모 — OCR 자동 생성 또는 사용자 직접 입력 (없으면 null)")
@Schema(description = "복용법 + 보관법 자동 생성 — DrugInfo 연결 시에만 채워짐, OCR 등록 시 null")
String usageStorageInfo,

@Schema(description = "사용자 자유 입력 메모 (없으면 null)")
String memo
) {}
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,11 @@ public class Medication extends BaseEntity {
@Column(name = "prescription_date")
private LocalDate prescriptionDate; // 처방 날짜

@Column(name = "usage_storage_info", columnDefinition = "TEXT")
private String usageStorageInfo; // DrugInfo 연결 시 자동 생성 (복용법 + 보관법), OCR 등록 시 null

@Column(name = "memo", columnDefinition = "TEXT")
private String memo; // 복용 방법 + 보관법 자동 입력
private String memo; // 사용자 자유 입력, 항상 빈값으로 시작

@Column(name = "is_active", nullable = false)
private Boolean isActive; // 현재 복용 중인지 여부 (복용 종료 시 false로 변경)
Expand All @@ -78,7 +81,8 @@ public Medication(Senior senior, String hospitalName, DrugInfo drugInfo,
String drugName, String drugNickname, String drugType,
String imageUrl, String dosagePerTime, Integer timesPerDay,
Integer totalDays, LocalDate startDate, LocalDate endDate,
LocalDate prescriptionDate, String memo, Boolean isActive, Long ocrResultId) {
LocalDate prescriptionDate, String usageStorageInfo, String memo,
Boolean isActive, Long ocrResultId) {
this.senior = senior;
this.hospitalName = hospitalName;
this.drugInfo = drugInfo;
Expand All @@ -92,6 +96,7 @@ public Medication(Senior senior, String hospitalName, DrugInfo drugInfo,
this.startDate = startDate;
this.endDate = endDate;
this.prescriptionDate = prescriptionDate;
this.usageStorageInfo = usageStorageInfo;
this.memo = memo;
this.isActive = isActive;
this.ocrResultId = ocrResultId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,10 @@ private MedicationResponse doRegister(Long userId, MedicationCreateRequest reque
.startDate(request.startDate())
.endDate(endDate)
.prescriptionDate(request.prescriptionDate())
.usageStorageInfo(buildUsageStorageInfo(drugInfo))
.memo(request.memo())
.isActive(true)
.ocrResultId(request.ocrResultId())
.memo(request.memo())
.build();

Medication saved = medicationRepository.save(medication);
Expand Down Expand Up @@ -105,4 +106,14 @@ private DrugInfo resolveDrugInfo(Long drugInfoId) {
return drugInfoRepository.findById(drugInfoId)
.orElseThrow(() -> new CallCareException(ErrorCode.DRUG_NOT_FOUND));
}

private String buildUsageStorageInfo(DrugInfo drugInfo) {
if (drugInfo == null) return null;
String usage = drugInfo.getUseMethodQesitm();
String deposit = drugInfo.getDepositMethodQesitm();
if (usage == null && deposit == null) return null;
if (usage == null) return deposit;
if (deposit == null) return usage;
return usage + "\n\n" + deposit;
}
}