Skip to content

Commit

Permalink
Merge pull request #33 from 9oormthon-univ/feat/#32
Browse files Browse the repository at this point in the history
✨ 진단서 검증 기능 구현
  • Loading branch information
GiHwan2 authored Nov 23, 2024
2 parents bd1f009 + 167501c commit 5cac7b6
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 8 deletions.
78 changes: 78 additions & 0 deletions src/main/java/com/ivory/ivory/domain/Disease.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package com.ivory.ivory.domain;

public enum Disease {
// 유행성 질병
COLD("감기"),
CONJUNCTIVITIS("눈병"),
STOMATITIS("구내염"),
TRANSMISSIBLE("전염"), // 전염 여부는 별도 로직으로 처리 가능

// 제1급 감염병
EBOLA("에볼라"),
MARBURG_FEVER("마버그열"),
LASSA_FEVER("라싸열"),
CRIMEAN_CONGO_HEMORRHAGIC_FEVER("크리미안콩고출혈열"),
SOUTH_AMERICAN_HEMORRHAGIC_FEVER("남아메리카출혈열"),
RIFT_VALLEY_FEVER("리프트밸리열"),
SMALLPOX("두창"),
PLAGUE("페스트"),
ANTHRAX("탄저"),
BOTULISM("보툴리눔독소증"),
TULAREMIA("야토병"),
SARS("SARS"),
MERS("MERS"),
H5N1("동물인플루엔자인체감염증"),
H1N1("신종인플루엔자"),
DIPHTHERIA("디프테리아"),

// 제2급 감염병
TUBERCULOSIS("결핵"),
CHICKENPOX("수두"),
MEASLES("홍역"),
CHOLERA("콜레라"),
TYPHOID_FEVER("장티푸스"),
PARATYPHOID_FEVER("파라티푸스"),
SHIGELLOSIS("세균성이질"),
EHEC("장출혈성대장균"),
HEPATITIS_A("A형간염"),
// 생략된 다른 제2급 감염병...

// 제3급 감염병
TETANUS("파상풍"),
HEPATITIS_B("B형간염"),
HEPATITIS_C("C형간염"),
JAPANESE_ENCEPHALITIS("일본뇌염"),
MALARIA("말라리아"),
// 생략된 다른 제3급 감염병...

// 제4급 감염병
INFLUENZA("인플루엔자"),
HAND_FOOT_MOUTH_DISEASE("수족구병"),
PARASITIC_INFECTION("기생충 감염"),
GONORRHEA("임질"),
CHLAMYDIA("클라미디아"),
COVID_19("코로나19");

private final String name;

Disease(String name) {
this.name = name;
}

public String getName() {
return name;
}

public static Disease findByDiagnosisName(String diagnosisName) {
if (diagnosisName == null || diagnosisName.isEmpty()) {
throw new IllegalArgumentException("진단명이 비어있습니다.");
}

for (Disease disease : Disease.values()) {
if (diagnosisName.contains(disease.getName())) {
return disease;
}
}
throw new IllegalArgumentException("적합하지 않은 질병명입니다: " + diagnosisName);
}
}
11 changes: 7 additions & 4 deletions src/main/java/com/ivory/ivory/domain/MedicalCertificate.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import com.ivory.ivory.util.entity.BaseEntity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
Expand Down Expand Up @@ -36,8 +38,9 @@ public class MedicalCertificate extends BaseEntity {
@Column(name = "diagnosis_date", nullable = true)
private LocalDate diagnosisDate;

@Column(name = "diagnosis_name", nullable = true)
private String diagnosisName;
@Enumerated(EnumType.STRING)
@Column(name = "disease", nullable = true)
private Disease disease;

@Column(name = "diagnosis_content", nullable = true)
private String diagnosisContent;
Expand All @@ -50,11 +53,11 @@ public class MedicalCertificate extends BaseEntity {
private Child child;

@Builder
public MedicalCertificate(String name, String address, LocalDate diagnosisDate, String diagnosisName, String diagnosisContent, String doctorName, Child child) {
public MedicalCertificate(String name, String address, LocalDate diagnosisDate, Disease disease, String diagnosisContent, String doctorName, Child child) {
this.name = name;
this.address = address;
this.diagnosisDate = diagnosisDate;
this.diagnosisName = diagnosisName;
this.disease = disease;
this.diagnosisContent = diagnosisContent;
this.doctorName = doctorName;
this.child = child;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.ivory.ivory.domain.AbsenceCertificate;
import com.ivory.ivory.domain.Child;
import com.ivory.ivory.domain.Disease;
import com.ivory.ivory.domain.MedicalCertificate;
import com.ivory.ivory.dto.AbsenceCertificateRequestDto;
import com.ivory.ivory.dto.AbsenceCertificateResponseDto;
Expand Down Expand Up @@ -60,12 +61,11 @@ public MedicalCertificateResponseDto addMedicalCertificate(MedicalCertificateReq
String diagnosisContent = parseData.get("의견");
String doctorName = parseData.get("의사명");


MedicalCertificate medicalCertificate = MedicalCertificate.builder()
.name(name)
.address(address)
.diagnosisDate(diagnosisDate != null ? DateUtil.parseToLocalDate(diagnosisDate) : null)
.diagnosisName(diagnosisName)
.disease(Disease.findByDiagnosisName(diagnosisName))
.diagnosisContent(diagnosisContent)
.doctorName(doctorName)
.child(child)
Expand All @@ -78,7 +78,7 @@ public MedicalCertificateResponseDto addMedicalCertificate(MedicalCertificateReq
.name(medicalCertificate.getName())
.address(medicalCertificate.getAddress())
.diagnosisDate(medicalCertificate.getDiagnosisDate())
.diagnosisName(medicalCertificate.getDiagnosisName())
.diagnosisName(medicalCertificate.getDisease().getName())
.diagnosisContent(medicalCertificate.getDiagnosisContent())
.doctorName(medicalCertificate.getDoctorName())
.build();
Expand Down Expand Up @@ -147,7 +147,7 @@ public MedicalCertificateResponseDto getMedicalCertificateDetail(Long medicalCer
.name(medicalCertificate.getName())
.address(medicalCertificate.getAddress())
.diagnosisDate(medicalCertificate.getDiagnosisDate())
.diagnosisName(medicalCertificate.getDiagnosisName())
.diagnosisName(medicalCertificate.getDisease().getName())
.diagnosisContent(medicalCertificate.getDiagnosisContent())
.doctorName(medicalCertificate.getDoctorName())
.build();
Expand Down

0 comments on commit 5cac7b6

Please sign in to comment.