Explorar o código

Merge remote-tracking branch 'origin/simplatform' into databank

huiwon.seo %!s(int64=4) %!d(string=hai) anos
pai
achega
42706af24a

+ 30 - 16
src/main/java/com/lemon/lifecenter/controller/ClinicController.java

@@ -256,21 +256,21 @@ public class ClinicController extends LifeCenterController {
 	public @ResponseBody String insertPhrDataAPI(@ModelAttribute("dto") final PatientPHRHistoryDTO dto) {
 
 		try {
-      phrService.insertPHR(dto);
-      if (dto.getPhrValueExtra() != null) {
-        PatientPHRHistoryDTO pulseRateDto = new PatientPHRHistoryDTO();
-        pulseRateDto.setPatientIdx(dto.getPatientIdx());
-        pulseRateDto.setPhrType("pulseRate");
-        pulseRateDto.setPhrValue(dto.getPhrValueExtra());
-        pulseRateDto.setRecordedByName(dto.getRecordedByName());
-        if (dto.getRecordedById() != null) {
-          pulseRateDto.setRecordedById(dto.getRecordedById());
-        }
-        if (dto.getRecordedDate() != null) {
-          pulseRateDto.setRecordedDate(dto.getRecordedDate());
-        }
-        phrService.insertPHR(pulseRateDto);
-      }
+			phrService.insertPHR(dto);
+			if (dto.getPhrValueExtra() != null) {
+		        PatientPHRHistoryDTO pulseRateDto = new PatientPHRHistoryDTO();
+		        pulseRateDto.setPatientIdx(dto.getPatientIdx());
+		        pulseRateDto.setPhrType("pulseRate");
+		        pulseRateDto.setPhrValue(dto.getPhrValueExtra());
+		        pulseRateDto.setRecordedByName(dto.getRecordedByName());
+		        if (dto.getRecordedById() != null) {
+		          pulseRateDto.setRecordedById(dto.getRecordedById());
+		        }
+		        if (dto.getRecordedDate() != null) {
+		          pulseRateDto.setRecordedDate(dto.getRecordedDate());
+		        }
+		        phrService.insertPHR(pulseRateDto);
+			}
 
 			JSONObject json = new JSONObject();
 
@@ -436,7 +436,21 @@ public class ClinicController extends LifeCenterController {
       PatientPHRHistoryDTO bp = bloodPressureResult.get(bloodPressureIndex);
       PatientPHRHistoryDTO pr = pulseRateResult.get(pulseRateIndex);
 
-      int dateDiffer = bp.getRecordedDateFormatted().compareTo(pr.getRecordedDateFormatted());
+      SimpleDateFormat originalFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
+      SimpleDateFormat targetFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
+      String bpRecordedDateFormatted = bp.getRecordedDate();
+      String prRecordedDateFormatted = pr.getRecordedDate();
+      try {
+        Date t = originalFormat.parse(bpRecordedDateFormatted);
+        bpRecordedDateFormatted = targetFormat.format(t);
+        Date t2 = originalFormat.parse(prRecordedDateFormatted);
+        prRecordedDateFormatted = targetFormat.format(t2);
+      }
+      catch (Exception e) {
+      }
+
+      int dateDiffer = bpRecordedDateFormatted.compareTo(prRecordedDateFormatted);
       if (dateDiffer == 0) {
         union.setCreateDate(bp.getCreateDate());
         union.setRecordedDate(bp.getRecordedDate());

+ 81 - 27
src/main/webapp/WEB-INF/jsp/clinic/info.jsp

@@ -175,38 +175,82 @@ function handlePhrData() {
   var phrType = $('#healthInfo').attr("data-phr-type");
 	var phrValue = "";
 	if (phrType === "bloodPressure") {
-		phrValueSystolic = $("#phrValueSystolic").val();
-		phrValueDiastolic = $("#phrValueDiastolic").val();
-    phrValuePulseRate = $("#phrValuePulseRate").val();
+		var phrValueSystolic = $("#phrValueSystolic").val();
+		var phrValueDiastolic = $("#phrValueDiastolic").val();
+    var phrValuePulseRate = $("#phrValuePulseRate").val();
+    const recordedDate = $("#eventDateTime1").val() === "" ? null : $("#eventDateTime1").val();
 
 		// 유효성 체크
-		var errorMessage = checkValidForPhrData("bloodPressureSystolic", phrValueSystolic);
-		if (errorMessage) {
-			alert(errorMessage);
+		var errorMessage1 = checkValidForPhrData("bloodPressureSystolic", phrValueSystolic);
+
+		var errorMessage2 = checkValidForPhrData("bloodPressureDiastolic", phrValueDiastolic);
+    
+    var errorMessage3 = checkValidForPhrData("pulseRate", phrValuePulseRate);
+
+    // 수축기 F 이완기 S
+    if (errorMessage1 && !errorMessage2) {
+      alert(errorMessage1);
 			$("#phrValueSystolic").focus();
 			return;
-		}
-
-		errorMessage = checkValidForPhrData("bloodPressureDiastolic", phrValueDiastolic);
-		if (errorMessage) {
-			alert(errorMessage);
+    }
+    // 수축기 S 이완기 F
+    else if (!errorMessage1 && errorMessage2) {
+      alert(errorMessage2);
 			$("#phrValueDiastolic").focus();
 			return;
     }
-    
-    errorMessage = checkValidForPhrData("pulseRate", phrValuePulseRate);
-		if (errorMessage) {
-			alert(errorMessage);
-			$("#phrValuePulseRate").focus();
-			return;
-		}
-
-    // 저장 진행
-    const recordedDate = $("#eventDateTime1").val() === "" ? null : $("#eventDateTime1").val();
-    createPhrData(mPatientIdx, "bloodPressure", recordedDate, phrValueSystolic, phrValueDiastolic, phrValuePulseRate);
+    // 수축기 F 이완기 F
+    else if (errorMessage1 && errorMessage2) {
+
+      // 미입력 에러
+	    if ((!phrValueSystolic || phrValueSystolic.length === 0) && (!phrValueDiastolic || phrValueDiastolic.length === 0)) {
+        // 맥박 F
+        if (errorMessage3) {
+          alert(errorMessage3);
+          $("#phrValuePulseRate").focus();
+          return;
+        }
+        // 맥박 S
+        else {
+          // 맥박만 저장
+          createPhrData(mPatientIdx, "pulseRate", recordedDate, phrValuePulseRate);
+        }
+      }
+      // min max 오류
+      else {
+        if (errorMessage1) {
+          alert(errorMessage1);
+          $("#phrValueSystolic").focus();
+          return;
+        }
+      }
+    }
+    // 수축기 S 이완기 S
+    else if (!errorMessage1 && !errorMessage2) {
+      // 맥박 F
+      if (errorMessage3) {
+        // 미입력 오류
+        if (!phrValuePulseRate || phrValuePulseRate.length === 0) {
+          // 혈압만 저장
+          createPhrData(mPatientIdx, "bloodPressure", recordedDate, phrValueSystolic, phrValueDiastolic);
+        }
+        // min max 오류
+        else {
+          alert(errorMessage3);
+			    $("#phrValuePulseRate").focus();
+			    return;
+        }
+      }
+      // 맥박 S
+      else {
+        // 혈압, 매박 모두 저장
+        createPhrData(mPatientIdx, "bloodPressure", recordedDate, phrValueSystolic, phrValueDiastolic, phrValuePulseRate);
+      }
+    }
 
 		$("#phrValueSystolic").val(PHR_VALUE_DEFAULT.BLOOD_PRESSURE_SYSTOLIC.VALUE);
 		$("#phrValueDiastolic").val(PHR_VALUE_DEFAULT.BLOOD_PRESSURE_DIASTOLIC.VALUE);
+    $("#phrValuePulseRate").val(PHR_VALUE_DEFAULT.PULSE_RATE.VALUE);
 	}
 	else {
 		phrValue = $("#phrValue").val();
@@ -251,7 +295,7 @@ function createPhrData(patientIdx, phrType, recordedDate, phrValue, phrValue2, p
         dataType : "json",
         success  : function( datas ){
 
-            retrievePhrData(phrType);
+            retrievePhrData(phrType === "pulseRate" ? "bloodPressure" : phrType);
         },
         error : ajaxErrorHandler
     }).done( function(){
@@ -283,7 +327,6 @@ function retrievePhrData(phrType) {
         dataType : "json",
         success  : function( datas ){
 
-          console.log(JSON.stringify(datas));
 						if (phrType==="bloodPressure") {
 							drawBPChart(datas);
 						}
@@ -376,12 +419,16 @@ function drawBPChart(data) {
 	var y1Datas = [];
   var y2Datas = [];
   var y3Datas = [];
+  var ymin = 1000;
 	data.forEach(function(d) {
 		var t = chartDateFormatter(d.recordedDate);
 		xDatas.push(t);
-		y1Datas.push(d.phrValue);
-    y2Datas.push(d.phrValue2);
-    y3Datas.push(d.phrValueExtra);
+		y1Datas.push(d.phrValue === "" ? Number.NaN : d.phrValue);
+    y2Datas.push(d.phrValue2 === "" ? Number.NaN : d.phrValue2);
+    y3Datas.push(d.phrValueExtra === "" ? Number.NaN : d.phrValueExtra);
+    if (d.phrValue !== null && d.phrValue !== "")  ymin = Math.min(ymin, d.phrValue);
+    if (d.phrValue2 !== null && d.phrValue2 !== "")  ymin = Math.min(ymin, d.phrValue2);
+    if (d.phrValueExtra !== null && d.phrValueExtra !== "")  ymin = Math.min(ymin, d.phrValueExtra);
 	});
 	var ctx = document.getElementById("bloodPressurePulseChart").getContext('2d');
 	myCharts["bloodPressurePulseChart"] = new Chart(ctx, {
@@ -415,6 +462,13 @@ function drawBPChart(data) {
                 drawTime: "afterDatasetsDraw",
                 // annotations: annotationData,
               },
+        scales: {
+            yAxes: [{
+                ticks: {
+                    suggestedMin: ymin - 10,
+                }
+            }]
+        }
 	    }
 	});
 }

+ 0 - 1
src/main/webapp/WEB-INF/jsp/clinic/state.jsp

@@ -275,7 +275,6 @@ $(document).ready(function() {
     setPageSize(viewEntry);
     retrieveStateData(1, true);
 
-    console.log(viewEntry);
     if(viewEntry === '10000'){
       $('.patients-list').addClass('all');
     }