diff --git a/src/main/java/com/ivory/ivory/domain/Disease.java b/src/main/java/com/ivory/ivory/domain/Disease.java new file mode 100644 index 0000000..c6915fb --- /dev/null +++ b/src/main/java/com/ivory/ivory/domain/Disease.java @@ -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); + } +} \ No newline at end of file diff --git a/src/main/java/com/ivory/ivory/domain/MedicalCertificate.java b/src/main/java/com/ivory/ivory/domain/MedicalCertificate.java index 9c1c1b4..b8c605c 100644 --- a/src/main/java/com/ivory/ivory/domain/MedicalCertificate.java +++ b/src/main/java/com/ivory/ivory/domain/MedicalCertificate.java @@ -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; @@ -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; @@ -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; diff --git a/src/main/java/com/ivory/ivory/service/MedicalCertificateService.java b/src/main/java/com/ivory/ivory/service/MedicalCertificateService.java index bd44f48..4ca3536 100644 --- a/src/main/java/com/ivory/ivory/service/MedicalCertificateService.java +++ b/src/main/java/com/ivory/ivory/service/MedicalCertificateService.java @@ -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; @@ -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) @@ -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(); @@ -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();