Просмотр исходного кода

[진료관리] 데이터 추가시 recordedDate null 일 때 처리 추가 - 컨트롤러에 작업했던 것 사이드 이펙트 최소화 위해 서비스로 옮김.

sjpark 4 лет назад
Родитель
Сommit
7770e0e152

+ 0 - 10
src/main/java/com/lemon/lifecenter/controller/ClinicController.java

@@ -359,13 +359,6 @@ public class ClinicController extends LifeCenterController {
 	public @ResponseBody String insertPhrDataAPI(@ModelAttribute("dto") final PatientPHRHistoryDTO dto) {
 
 		try {
-			SimpleDateFormat format = new SimpleDateFormat ( "yyyy-MM-dd HH:mm");
-			Date time = new Date();
-			String recordedDate = format.format(time);
-
-			if (dto.getRecordedDate() == null) {
-				dto.setRecordedDate(recordedDate);
-			}
 			phrService.insertPHR(dto);
 			
 			if (dto.getPhrValueExtra() != null) {
@@ -380,9 +373,6 @@ public class ClinicController extends LifeCenterController {
 		        if (dto.getRecordedDate() != null) {
 		        	pulseRateDto.setRecordedDate(dto.getRecordedDate());
 		        }
-		        else {
-		        	pulseRateDto.setRecordedDate(recordedDate);
-		        }
 		        phrService.insertPHR(pulseRateDto);
 			}
 

+ 8 - 0
src/main/java/com/lemon/lifecenter/service/PHRService.java

@@ -30,6 +30,14 @@ public class PHRService {
 	private ClinicConfigurationMapper mapperClinicConfiguration;
 	
 	public void insertPHR(PatientPHRHistoryDTO dto) {
+
+    SimpleDateFormat format = new SimpleDateFormat ( "yyyy-MM-dd HH:mm");
+    Date time = new Date();
+    String recordedDate = format.format(time);
+
+    if (dto.getRecordedDate() == null) {
+      dto.setRecordedDate(recordedDate);
+    }
 		mapperHistory.insertPHRHistory(dto);
 		
 		// 해당 환자가 속해 있는 센터의 설정 정보 가져오기