|
@@ -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,
|
|
|
+ }
|
|
|
+ }]
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
}
|