Ver Fonte

[진료관리 상세] 의료진 메모 수정 및 삭제 기능 추가.

sjpark há 4 anos atrás
pai
commit
9f4cad903d

+ 51 - 7
src/main/java/com/lemon/lifecenter/controller/ClinicController.java

@@ -206,7 +206,7 @@ public class ClinicController extends LifeCenterController {
 	}
 
 	@RequestMapping("/api/state")
-	public @ResponseBody List<PatientPHRLatestDTO> state(HttpServletRequest request,
+	public @ResponseBody List<PatientPHRLatestDTO> getStateAPI(HttpServletRequest request,
 			@RequestParam(value = "page", required = true, defaultValue = "1") int page,
 			@RequestParam(value = "searchText", required = false, defaultValue = "") String searchText) {
 
@@ -229,7 +229,7 @@ public class ClinicController extends LifeCenterController {
 	}
 
 	@RequestMapping("/api/phrDatas")
-	public @ResponseBody List<PatientPHRHistoryDTO> phrDatas(
+	public @ResponseBody List<PatientPHRHistoryDTO> getPhrDatasAPI(
 			@RequestParam(value = "patientIdx", required = true, defaultValue = "") int patientIdx,
 			@RequestParam(value = "phrType", required = true, defaultValue = "temperature") String phrType) {
 
@@ -242,7 +242,7 @@ public class ClinicController extends LifeCenterController {
 	}
 
 	@RequestMapping(value = "/api/phrData", method = RequestMethod.POST)
-	public @ResponseBody String insertPhrData(@ModelAttribute("dto") final PatientPHRHistoryDTO dto) {
+	public @ResponseBody String insertPhrDataAPI(@ModelAttribute("dto") final PatientPHRHistoryDTO dto) {
 
 		try {
 			phrService.insertPHR(dto);
@@ -264,7 +264,7 @@ public class ClinicController extends LifeCenterController {
 	}
 
 	@RequestMapping("/api/symptomDatas")
-	public @ResponseBody List<PatientSymptomSimDTO> symptomDatas(
+	public @ResponseBody List<PatientSymptomSimDTO> getSymptomDatasAPI(
 			@RequestParam(value = "patientIdx", required = true, defaultValue = "") int patientIdx) {
 
 		PatientSymptomSimDTO dto = new PatientSymptomSimDTO();
@@ -275,7 +275,7 @@ public class ClinicController extends LifeCenterController {
 	}
 
 	@RequestMapping(value = "/api/symptomData", method = RequestMethod.POST)
-	public @ResponseBody String symptomData(@ModelAttribute("dto") final PatientSymptomSimDTO dto) {
+	public @ResponseBody String insertSymptomDataAPI(@ModelAttribute("dto") final PatientSymptomSimDTO dto) {
 
 		try {
 			phrService.insertSymptom(dto);
@@ -297,7 +297,7 @@ public class ClinicController extends LifeCenterController {
 	}
 
 	@RequestMapping("/api/memoDatas")
-	public @ResponseBody List<PatientMemoDTO> memoDatas(
+	public @ResponseBody List<PatientMemoDTO> getMemoDatasAPI(
 			@RequestParam(value = "patientIdx", required = true, defaultValue = "") int patientIdx) {
 
 		PatientMemoDTO dto = new PatientMemoDTO();
@@ -307,7 +307,7 @@ public class ClinicController extends LifeCenterController {
 	}
 
 	@RequestMapping(value = "/api/memoData", method = RequestMethod.POST)
-	public @ResponseBody String memoData(@ModelAttribute("dto") final PatientMemoDTO dto) {
+	public @ResponseBody String insertMemoDataAPI(@ModelAttribute("dto") final PatientMemoDTO dto) {
 
 		try {
 			clinicService.insertMemo(dto);
@@ -328,6 +328,50 @@ public class ClinicController extends LifeCenterController {
 		}
 	}
 
+  @RequestMapping(value = "/api/memoData", method = RequestMethod.DELETE)
+	public @ResponseBody String deleteMemoDataAPI(@ModelAttribute("dto") final PatientMemoDTO dto) {
+
+		try {
+			clinicService.deleteMemo(dto);
+
+			JSONObject json = new JSONObject();
+
+			json.put("code", "00");
+			json.put("message", "");
+
+			return json.toString();
+		} catch (Exception e) {
+			JSONObject json = new JSONObject();
+
+			json.put("code", "01");
+			json.put("message", e.getLocalizedMessage());
+
+			return json.toString();
+		}
+	}
+
+  @RequestMapping(value = "/api/memoData", method = RequestMethod.PATCH)
+	public @ResponseBody String updateMemoDataAPI(@ModelAttribute("dto") final PatientMemoDTO dto) {
+
+		try {
+			clinicService.updateMemo(dto);
+
+			JSONObject json = new JSONObject();
+
+			json.put("code", "00");
+			json.put("message", "");
+
+			return json.toString();
+		} catch (Exception e) {
+			JSONObject json = new JSONObject();
+
+			json.put("code", "01");
+			json.put("message", e.getLocalizedMessage());
+
+			return json.toString();
+		}
+	}
+
 	private void getPhrDataListExcel(HttpServletRequest request, HttpServletResponse response, PatientDTO patientDto, String phrType, List<PatientPHRHistoryDTO> data) {
         Workbook workbook = new XSSFWorkbook();
         Sheet sheet1 = workbook.createSheet("PHR");

+ 118 - 16
src/main/webapp/WEB-INF/jsp/clinic/info.jsp

@@ -498,7 +498,7 @@ function retrieveSymptomData() {
  * 메모 탭 처리
  */
 
- function handleMemoData() {
+function insertMemoData() {
 
 	 var memoContent = $("#memoContent").val().trim();
 
@@ -508,14 +508,54 @@ function retrieveSymptomData() {
 		return;
 	}
 
-	createMemoData(memoContent);
-
-	$("#memoContent").val("");
+	requestInsertMemoData(memoContent);
 
 	$("#defaultModalPrimaryMemo").modal("hide");
 }
 
-function createMemoData(memoContent) {
+function deleteMemoData() {
+
+	const memoId = $("#defaultModalPrimaryMemo").data("memoid");
+
+	if (memoId === undefined || memoId === null || memoId === "") {
+    alert("오류! 삭제할 메모를 찾을 수 없습니다.");
+    return;
+  }
+
+  const result = confirm("메모를 삭제하시겠습니까?\n삭제후에는 복구가 불가능 합니다.");
+  if(result){
+    requestDeleteMemoData(memoId);
+  
+  $("#defaultModalPrimaryMemo").modal("hide");
+  }  
+}
+
+function modifyMemoData() {
+
+	const memoId = $("#defaultModalPrimaryMemo").data("memoid");
+
+	if (memoId === undefined || memoId === null || memoId === "") {
+    alert("오류! 삭제할 메모를 찾을 수 없습니다.");
+    return;
+  }
+
+  var memoContent = $("#memoContent").val().trim();
+
+	if (!memoContent) {
+		alert("메모 내용을 입력해 주세요.");
+		$("#memoContent").val("");
+		return;
+	}
+
+  const result = confirm("메모를 수정하시겠습니까?");
+  if(result){
+    requestUpdateMemoData(memoId, memoContent);
+  
+  $("#defaultModalPrimaryMemo").modal("hide");
+  }  
+}
+
+function requestInsertMemoData(memoContent) {
 	
 	$.ajax({
         url      : "./api/memoData",
@@ -531,6 +571,42 @@ function createMemoData(memoContent) {
     });
 }
 
+function requestDeleteMemoData(memoIdx) {
+	
+	$.ajax({
+        url      : "./api/memoData",
+        data     : {idx:memoIdx},
+        method   : "DELETE",
+        dataType : "json",
+        success  : function( datas ){
+
+            retrieveMemoData();
+        },
+        error : ajaxErrorHandler
+    }).done( function(){
+    });
+}
+
+function requestUpdateMemoData(memoIdx, memoContent) {
+	
+	$.ajax({
+        url      : "./api/memoData",
+        data     : {idx:memoIdx, contents:memoContent},
+        method   : "PATCH",
+        dataType : "json",
+        success  : function( datas ){
+          if (datas.code === "00") {
+            retrieveMemoData();
+          }
+          else {
+            alert("메모 수정 실패.\n" + datas.code);
+          }
+        },
+        error : ajaxErrorHandler
+    }).done( function(){
+    });
+}
+
 function retrieveMemoData() {
 	var ignoreCache = moment().unix();
 	var params = {patientIdx: ${patientIdx}, ignoreCache:ignoreCache};
@@ -547,9 +623,9 @@ function retrieveMemoData() {
 				html = "";
 				contents = datas.forEach(function(d) {
 					html += "<tr>";
-          html += "<td>" + gridDateFormatter(d.createDate) + "</td>";
+          html += "<td>" + gridDateFormatter(d.updateDate) + "</td>";
           if (d.canModify) {
-            html += "<td><pre class='contentsEdit'>" + d.contents + "</pre></td>";
+            html += "<td><pre id='memo_"+d.idx+"' class='contentsEdit' onClick='modifyMemo("+d.idx+")'>" + d.contents + "</pre></td>";
           }
           else {
             html += "<td><pre>" + d.contents + "</pre></td>";
@@ -799,7 +875,7 @@ $(document).ready(function() {
 	});
 
 	// 의료진 메모 추가 클릭 이벤트
-	$(document).on('click','[data-target="#defaultModalPrimaryMemo"]',function(){
+	$(document).on('click','.addMemo',function(){
 		var memoInfoHTML = '';
 			memoInfoHTML += '<th>내용</th>';
 			memoInfoHTML += '<td>';
@@ -808,14 +884,35 @@ $(document).ready(function() {
 			memoInfoHTML += '	</div>';
 			memoInfoHTML += '</td>';
 		
-		$('#memoInfo').html(memoInfoHTML);
+    $('#memoInfo').html(memoInfoHTML);
+    $('.addMemoTools').show();
+    $('.modifMemoTools').hide();
+    $('#defaultModalPrimaryMemo').modal();
 		setTimeout(function (){
 			$('#memoInfo').find('.form-row textarea').focus();
-		}, 500);
-		
-	});
+    }, 500);
+  });
 });
 
+function modifyMemo(memoId) {
+  $("#defaultModalPrimaryMemo").data("memoid", memoId);
+  const content = $("#memo_"+memoId).html();
+  var memoInfoHTML = '';
+			memoInfoHTML += '<th>내용</th>';
+			memoInfoHTML += '<td>';
+			memoInfoHTML += '	<div class="form-row">';
+			memoInfoHTML += '		<textarea id="memoContent" class="form-control" rows="15" placeholder="내용을 입력하세요">'+content+'</textarea>';
+			memoInfoHTML += '	</div>';
+			memoInfoHTML += '</td>';
+		
+    $('#memoInfo').html(memoInfoHTML);
+    $('.addMemoTools').hide();
+    $('.modifMemoTools').show();
+    $('#defaultModalPrimaryMemo').modal();
+		setTimeout(function (){
+			$('#memoInfo').find('.form-row textarea').focus();
+    }, 500);
+}
 
 </script>
 </head>
@@ -939,7 +1036,7 @@ $(document).ready(function() {
 		</div>
 	</div>
 
-	<div class="modal fade" id="defaultModalPrimaryMemo" tabindex="-1" role="dialog" aria-hidden="true">
+	<div class="modal fade" id="defaultModalPrimaryMemo" tabindex="-1" role="dialog" aria-hidden="true" data-memoid="">
 		<div class="modal-dialog" role="document">
 			<div class="modal-content">
 				<div class="modal-header">
@@ -966,9 +1063,14 @@ $(document).ready(function() {
 						</tr>
 					</table>
 				</div>
-				<div class="modal-footer">
+        <div class="addMemoTools modal-footer">
+					<button type="button" class="btn btn-outline-primary" data-dismiss="modal">취소</button>
+					<button type="button" class="btn btn-primary" onclick="insertMemoData()">등록</button>
+				</div>
+				<div class="modifMemoTools modal-footer">
+					<button type="button" class="removeMemo btn btn-danger" onclick="deleteMemoData()">삭제</button>
 					<button type="button" class="btn btn-outline-primary" data-dismiss="modal">취소</button>
-					<button type="button" class="btn btn-primary" onclick="handleMemoData()">등록</button>
+					<button type="button" class="btn btn-primary" onclick="modifyMemoData()">수정</button>
 				</div>
 			</div>
 		</div>
@@ -1128,7 +1230,7 @@ $(document).ready(function() {
 									<div class="card-header">
 										<h1 class="h4">
 											- 의료진 메모
-											<button type="button" class="btn btn-primary ml-2" data-toggle="modal" data-target="#defaultModalPrimaryMemo">메모추가</button>
+											<button type="button" class="addMemo btn btn-primary ml-2" data-toggle="modal">메모추가</button>
 										<button class="btn btn-success text-right" style="float:right;" onclick="getExcel('memo');">Excel 다운로드</button>
 										</h1>
 									</div>