Skip to content

Commit

Permalink
#24 환자 식별번호 변경 작업
Browse files Browse the repository at this point in the history
 - 환자 식별을 위한 기준정보 변경
   기존 주민번호 삭제
   변경 성명, 생년월일, 성별, 연락처 변경
 - 대상 API
   /api/identity [POST]
   /api/patient  [POST]
  • Loading branch information
developer-Fwa committed Mar 28, 2022
1 parent a1bc1e5 commit 7b8a7a4
Show file tree
Hide file tree
Showing 10 changed files with 93 additions and 65 deletions.
32 changes: 27 additions & 5 deletions src/main/java/kr/co/hconnect/domain/IdentityInfo.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
package kr.co.hconnect.domain;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.time.LocalDate;

/**
* 본인인증 확인 정보
* 본인인증 확인 정보 (성명, 생년월일, 성별, 휴대폰)
*/
@Getter
@Setter
Expand All @@ -21,9 +24,28 @@ public class IdentityInfo implements Serializable {
private static final long serialVersionUID = 8476775768748997896L;

/**
* 주민번호
* 성명
*/
@NotNull(message = "{validation.null.ssn}")
@Pattern(regexp = "^[0-9]{13}", message = "{validation.checked.ssn}")
private String ssn;
@NotNull(message = "{validation.null.name}")
@Size(max = 50, message = "{validation.size.patientNm}")
private String patientNm;
/**
* 생년월일
*/
@NotNull(message = "{validation.null.birthday}")
@JsonFormat(pattern = "yyyyMMdd")
private LocalDate birthDate;
/**
* 성별
*/
@NotNull(message = "{validation.null.sex}")
@Pattern(regexp = "^[MF]$", message = "{validation.patternMismatch.sex}")
private String sex;
/**
* 휴대폰
*/
@NotNull(message = "{validation.null.cellphone}")
@Pattern(regexp = "^[0-9]+$",message = "{validation.patternMismatch.cellphone}")
@Size(max = 15, message = "{validation.size.cellPhone}")
private String cellPhone;
}
7 changes: 0 additions & 7 deletions src/main/java/kr/co/hconnect/domain/Patient.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,6 @@ public class Patient extends BaseResponse {
@NotNull(message = "{validation.null.name}", groups = { PatientValidationGroups.add.class })
@Size(max = 50, message = "{validation.size.patientNm}", groups = { PatientValidationGroups.add.class })
private String patientNm;
/**
* 주민번호
*/
@NotNull(message = "{validation.null.ssn}", groups = { PatientValidationGroups.add.class })
@Pattern(regexp = "^[0-9]{13}", message = "{validation.checked.ssn}", groups = { PatientValidationGroups.add.class })
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private String ssn;
/**
* 생년월일
*/
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/kr/co/hconnect/repository/PatientDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ public Patient selectPatientByLoginId(String loginId) {
}

/**
* 환자정보 조회-주민번호(암호화) 기준
* @param ssn 주민번호(암호화)
* 환자정보 조회-본인인증 확인 정보 기준
* @param identityInfo 본인인증 확인 정보 (성명, 생년월일, 성별, 휴대폰)
* @return Patient
*/
public Patient selectPatientBySsn(String ssn) {
return selectOne("kr.co.hconnect.sqlmapper.selectPatientBySsn", ssn);
public Patient selectPatientByIdentityInfo(IdentityInfo identityInfo) {
return selectOne("kr.co.hconnect.sqlmapper.selectPatientByIdentityInfo", identityInfo);
}

/**
Expand All @@ -54,11 +54,11 @@ public List<Patient> selectPatientBySearchExistLoginInfo(SearchExistLoginInfo se
/**
* 본인인증 내역 확인
*
* @param ssn 주민번호(암호화)
* @param identityInfo 본인인증 확인 정보 (성명, 생년월일, 성별, 휴대폰)
* @return IdentityResult
*/
public IdentityResult selectIdentityInfo(String ssn) throws TooManyResultsException {
return selectOne("kr.co.hconnect.sqlmapper.selectIdentityInfo", ssn);
public IdentityResult selectIdentityInfo(IdentityInfo identityInfo) throws TooManyResultsException {
return selectOne("kr.co.hconnect.sqlmapper.selectIdentityInfo", identityInfo);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/kr/co/hconnect/rest/LoginRestController.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public IdentityResult checkIdentity(@Valid @RequestBody IdentityInfo identityInf

try {
// 본인인증 내역 확인
identityResult = patientService.selectIdentityInfo(identityInfo.getSsn());
identityResult = patientService.selectIdentityInfo(identityInfo);

if (identityResult != null) {
// 환자정보 존재
Expand Down
28 changes: 17 additions & 11 deletions src/main/java/kr/co/hconnect/service/PatientService.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,20 @@ public Patient savePatientInfo(Patient patient)

// 환자정보 신규생성
if (patient.getFlag().equals("A")) {
// 주민번호 기준 환자정보 존재여부 확인
Patient patientBySsn = patientDao.selectPatientBySsn(CryptoUtils.encrypt(patient.getSsn()));
// 환자정보 존재여부 확인 (성명, 생년월일, 성별, 휴대폰)
IdentityInfo identityInfo = new IdentityInfo();
identityInfo.setPatientNm(patient.getPatientNm());
identityInfo.setBirthDate(patient.getBirthDate());
identityInfo.setSex(patient.getSex());
identityInfo.setCellPhone(patient.getCellPhone());

Patient patientByIdentityInfo = patientDao.selectPatientByIdentityInfo(identityInfo);

if (patientBySsn == null) {
// 전달받은 주민번호 기준 환자정보 존재여부 확인
throw new NotFoundPatientInfoException(messageSource.getMessage("message.notfound.ssn"
if (patientByIdentityInfo == null) {
// 전달받은 본인인증 기준 환자정보 존재여부 확인
throw new NotFoundPatientInfoException(messageSource.getMessage("message.notfound.IdentityInfo"
, null, Locale.getDefault()));
} else if (!StringUtils.isEmpty(patientBySsn.getLoginId())) {
} else if (!StringUtils.isEmpty(patientByIdentityInfo.getLoginId())) {
// 전달받은 주민번호 기준 로그인ID 생성여부 확인
throw new DuplicatePatientInfoException(messageSource.getMessage("message.duplicate.patientInfo"
, null, Locale.getDefault()));
Expand All @@ -123,7 +129,7 @@ public Patient savePatientInfo(Patient patient)
, null, Locale.getDefault()));
}

patient.setPatientId(patientBySsn.getPatientId());
patient.setPatientId(patientByIdentityInfo.getPatientId());

// 비밀번호 암호화
patient.setPassword(CryptoUtils.encrypt(patient.getPassword()));
Expand Down Expand Up @@ -191,10 +197,10 @@ public int updatePatientPasswordByLoginId(LoginInfo loginInfo) throws NotFoundPa
/**
* 본인인증 내역 확인
*
* @param ssn 주민번호
* @return IdentityResult
* @param identityInfo 본인인증 확인 정보 (성명, 생년월일, 성별, 휴대폰)
* @return IdentityResult 본인인증 완료 정보
*/
public IdentityResult selectIdentityInfo(String ssn) throws NotFoundPatientInfoException {
return patientDao.selectIdentityInfo(CryptoUtils.encrypt(ssn));
public IdentityResult selectIdentityInfo(IdentityInfo identityInfo) throws NotFoundPatientInfoException {
return patientDao.selectIdentityInfo(identityInfo);
}
}
6 changes: 1 addition & 5 deletions src/main/resources/message/message-common.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ validation.null.guardianCellPhone=보호자 연락처가 누락되었습니다
validation.null.zipcode=우편번호가 누락되었습니다
validation.null.address=주소가 누락되었습니다
validation.null.addressDetail=상세주소가 누락되었습니다
validation.null.ssn=주민번호가 누락되었습니다
validation.null.result=측정결과 누락
validation.null.sleepType=수면유형이 누락되었습니다
validation.null.resultDate=측정일자가 누락되었습니다
Expand All @@ -26,9 +25,6 @@ validation.null.deviceNm=디바이스 이름이 누락되었습니다
validation.null.deviceInfo=디바이스 정보가 누락되었습니다
validation.null.quarantineStatus=격리 상태 구분이 누락되었습니다

# validation - Checked
validation.checked.ssn=주민번호를 확인하세요

# validation - PatternMismatch
validation.patternMismatch.sex=성별 유형을 확인하세요
validation.patternMismatch.cellphone=휴대폰 번호 입력 유형을 확인하세요
Expand Down Expand Up @@ -75,7 +71,7 @@ message.found.notice=신규 알림이 있습니다
# message - NotFound
message.notfound.admissionInfo=내원중인 격리/입소내역이 존재하지 않습니다
message.notfound.patientInfo=환자정보가 존재하지 않습니다
message.notfound.ssn=해당 주민번호로 생성된 환자정보가 존재하지 않습니다
message.notfound.IdentityInfo=해당 정보로 생성된 환자정보가 존재하지 않습니다
message.notfound.loginId=해당 로그인 아이디가 존재하지 않습니다
message.notfound.notice=신규 알림이 없습니다
message.notfound.searchResultList=측정결과가 존재하지 않습니다
Expand Down
32 changes: 17 additions & 15 deletions src/main/resources/sqlmapper/patient.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
, LOGIN_ID -- 로그인ID
, PASSWORD -- 비밀번호
, PATIENT_NM -- 성명
, SSN -- 주민번호
, BIRTH_DATE -- 생년월일
, SEX -- 성별
, CELL_PHONE -- 휴대폰
Expand All @@ -22,14 +21,13 @@
]]>
</select>

<!-- 환자정보 조회-주민번호(암호화) 기준 -->
<select id="selectPatientBySsn" parameterType="String" resultType="kr.co.hconnect.domain.Patient">
<!-- 환자정보 조회-성명, 생년월일, 성별, 휴대폰 기준 -->
<select id="selectPatientByIdentityInfo" parameterType="kr.co.hconnect.domain.IdentityInfo" resultType="kr.co.hconnect.domain.Patient">
<![CDATA[
SELECT PATIENT_ID -- 환자ID
, LOGIN_ID -- 로그인ID
, PASSWORD -- 비밀번호
, PATIENT_NM -- 성명
, SSN -- 주민번호
, BIRTH_DATE -- 생년월일
, SEX -- 성별
, CELL_PHONE -- 휴대폰
Expand All @@ -38,7 +36,10 @@
, ADDRESS1 -- 주소
, ADDRESS2 -- 상세주소
FROM PATIENT
WHERE SSN = #{ssn}
WHERE PATIENT_NM = #{patientNm}
AND BIRTH_DATE = #{birthDate}
AND SEX = #{sex}
AND CELL_PHONE = #{cellPhone}
]]>
</select>

Expand All @@ -49,7 +50,6 @@
, LOGIN_ID -- 로그인ID
, PASSWORD -- 비밀번호
, PATIENT_NM -- 성명
, SSN -- 주민번호
, BIRTH_DATE -- 생년월일
, SEX -- 성별
, CELL_PHONE -- 휴대폰
Expand All @@ -70,7 +70,6 @@
, LOGIN_ID -- 로그인ID
, PASSWORD -- 비밀번호
, PATIENT_NM -- 성명
, SSN -- 주민번호
, BIRTH_DATE -- 생년월일
, SEX -- 성별
, CELL_PHONE -- 휴대폰
Expand Down Expand Up @@ -131,20 +130,23 @@
</update>

<!-- 본인인증 내역 확인 -->
<select id="selectIdentityInfo" parameterType="String" resultType="kr.co.hconnect.domain.IdentityResult">
<select id="selectIdentityInfo" parameterType="kr.co.hconnect.domain.IdentityInfo" resultType="kr.co.hconnect.domain.IdentityResult">
<![CDATA[
SELECT IFNULL(B.QANTN_DIV, '0') AS QUARANTINE_DIV
, CASE
WHEN IFNULL(A.LOGIN_ID, '') <> ''
THEN 'Y'
ELSE 'N'
END AS REGISTER_YN
FROM PATIENT A
LEFT OUTER JOIN admission B ON A.PATIENT_ID = B.PATIENT_ID
AND B.ADMISSION_DATE <= NOW()
AND B.DSCHGE_DATE IS NULL
AND B.DEL_YN = 'N'
WHERE A.SSN = #{ssn}
END AS REGISTER_YN
FROM PATIENT A
LEFT OUTER JOIN admission B ON A.PATIENT_ID = B.PATIENT_ID
AND B.ADMISSION_DATE <= NOW()
AND B.DSCHGE_DATE IS NULL
AND B.DEL_YN = 'N'
WHERE A.PATIENT_NM = #{patientNm}
AND A.BIRTH_DATE = #{birthDate}
AND A.SEX = #{sex}
AND A.CELL_PHONE = #{cellPhone}
]]>
</select>

Expand Down
20 changes: 14 additions & 6 deletions src/test/java/kr/co/hconnect/rest/LoginRestControllerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import javax.sql.DataSource;

import static org.hamcrest.CoreMatchers.is;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
Expand Down Expand Up @@ -137,7 +136,10 @@ public void givenLoginInfo_whenLogin_ThenNotFoundAccount() throws Exception {
public void givenIdentityInfo_whenIdentity_thenSuccess() throws Exception {
String content =
"{\n" +
" \"ssn\": \"8812051999999\"\n" +
" \"patientNm\": \"shy-unittest\",\n" +
" \"birthDate\": \"19881205\",\n" +
" \"sex\": \"M\",\n" +
" \"cellPhone\": \"01092615960\"\n" +
"}";

mvc.perform(post("/api/identity")
Expand All @@ -157,8 +159,11 @@ public void givenIdentityInfo_whenIdentity_thenSuccess() throws Exception {
public void givenIdentityInfo_whenIdentity_thenSuccessNotFound() throws Exception {
String content =
"{\n" +
" \"ssn\": \"8812059999999\"\n" +
"}";
" \"patientNm\": \"shy-unittest1111111\",\n" +
" \"birthDate\": \"19881205\",\n" +
" \"sex\": \"M\",\n" +
" \"cellPhone\": \"01092615960\"\n" +
"}";

mvc.perform(post("/api/identity")
.contentType(MediaType.APPLICATION_JSON_UTF8)
Expand All @@ -177,8 +182,11 @@ public void givenIdentityInfo_whenIdentity_thenSuccessNotFound() throws Exceptio
public void givenIdentityInfo_whenIdentity_thenFailMultiAdmission() throws Exception {
String content =
"{\n" +
" \"ssn\": \"8812051555555\"\n" +
"}";
" \"patientNm\": \"shy-unittest2\",\n" +
" \"birthDate\": \"19881205\",\n" +
" \"sex\": \"M\",\n" +
" \"cellPhone\": \"01092619999\"\n" +
"}";

mvc.perform(post("/api/identity")
.contentType(MediaType.APPLICATION_JSON_UTF8)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@

import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.is;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
Expand Down Expand Up @@ -118,7 +119,7 @@ public void givenPatient_whenCreatePatient_thenSuccess() throws Exception {
" \"loginId\" : \"junitTestPatient\",\n" +
" \"password\" : \"1234\",\n" +
" \"patientNm\" : \"회원가입용\",\n" +
" \"ssn\" : \"8812051525252\",\n" +
// " \"ssn\" : \"8812051525252\",\n" +
" \"birthDate\" : \"19881205\",\n" +
" \"sex\" : \"M\",\n" +
" \"cellPhone\" : \"01012345678\",\n" +
Expand Down Expand Up @@ -146,7 +147,7 @@ public void givenPatientOverSizeParam_whenCreatePatient_thenSizeCheckedFail() th
" \"loginId\" : \"123456789012345678901\",\n" +
" \"password\" : \"123456789012345678901\",\n" +
" \"patientNm\" : \"123456789012345678901234567890123456789012345678901\",\n" +
" \"ssn\" : \"8812051525252\",\n" +
// " \"ssn\" : \"8812051525252\",\n" +
" \"birthDate\" : \"19881205\",\n" +
" \"sex\" : \"M\",\n" +
" \"cellPhone\" : \"1234567890123451\",\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
INSERT
INTO PATIENT ( PATIENT_ID, LOGIN_ID, PASSWORD, PATIENT_NM, SSN
, BIRTH_DATE, SEX, CELL_PHONE, ZIP_CODE, ADDRESS1, ADDRESS2)
VALUES ( 'PTESTSHY99', 'testshy', 'bOFW4fVzdPuNJp89%2FeNG%2FA%3D%3D', 'shy-unittest', 'OQdb%2FlUq81M781GbkM8Vng%3D%3D'
VALUES ( 'PTESTSHY99', 'testshy', 'bOFW4fVzdPuNJp89%2FeNG%2FA%3D%3D', 'shy-unittest', 'OQdb%2FlUq81M781GbkM8Vng%3D%3D' -- 8812051999999
, '1988-12-05', 'M', '01092615960', '111111', '서울시', '헬스커넥트');

/* 격리/입소내역 생성 */
Expand All @@ -27,14 +27,14 @@ INSERT
INTO PATIENT ( PATIENT_ID, LOGIN_ID, PASSWORD, PATIENT_NM, SSN
, BIRTH_DATE, SEX, CELL_PHONE, ZIP_CODE, ADDRESS1
, ADDRESS2)
VALUES ( 'PTESTDUP01', 'testshydup1', 'bOFW4fVzdPuNJp89%2FeNG%2FA%3D%3D', 'shy-DUP', 'OQdb%2FlUq81M781GbkM8Vng%3D%3D'
VALUES ( 'PTESTDUP01', 'testshydup1', 'bOFW4fVzdPuNJp89%2FeNG%2FA%3D%3D', 'shy-DUP', 'OQdb%2FlUq81M781GbkM8Vng%3D%3D' -- 8812051999999
, '1988-12-05', 'M', '01092615960', '111111', '서울시', '헬스커넥트');

INSERT
INTO PATIENT ( PATIENT_ID, LOGIN_ID, PASSWORD, PATIENT_NM, SSN
, BIRTH_DATE, SEX, CELL_PHONE, ZIP_CODE, ADDRESS1
, ADDRESS2)
VALUES ( 'PTESTDUP02', 'testshydup2', 'bOFW4fVzdPuNJp89%2FeNG%2FA%3D%3D', 'shy-DUP', 'OQdb%2FlUq81M781GbkM8Vng%3D%3D'
VALUES ( 'PTESTDUP02', 'testshydup2', 'bOFW4fVzdPuNJp89%2FeNG%2FA%3D%3D', 'shy-DUP', 'OQdb%2FlUq81M781GbkM8Vng%3D%3D' -- 8812051999999
, '1988-12-05', 'M', '01092615960', '111111', '서울시', '헬스커넥트');

/* 격리상태 저장을 위한 입소정보 생성 */
Expand All @@ -53,8 +53,8 @@ INSERT
INTO PATIENT ( PATIENT_ID, LOGIN_ID, PASSWORD, PATIENT_NM, SSN
, BIRTH_DATE, SEX, CELL_PHONE, ZIP_CODE, ADDRESS1
, ADDRESS2)
VALUES ( 'TESTPTNT99', NULL, NULL, '회원가입용', 'yH3roR4%2B1OJ1tL%2FgX%2Bh28w%3D%3D'
, '1988-12-05', 'M', NULL, NULL, NULL, NULL);
VALUES ( 'TESTPTNT99', NULL, NULL, '회원가입용', 'yH3roR4%2B1OJ1tL%2FgX%2Bh28w%3D%3D' -- 8812051525252
, '1988-12-05', 'M', '01012345678', NULL, NULL, NULL);



0 comments on commit 7b8a7a4

Please sign in to comment.