"use strict";
/**
* mplus_modal_medicalhistory
*/
var mplus_modal_medicalhistory = function(){
// 상속
mplus_common.call(this);
// 상위 객체 생성
//var mplusPatient = new mplus_mobile_patient();
//var mplusNursing = new mplus_nursing();
//super
var self = this;
//==== 변수 { ====
var varResultLists = [];
//==== 변수 } ====
/**
* 초기화
*/
this.init = function(){ //여기서 모든화면 콤보박스데이터를 집어넣자!!! 그래야지 화면이동할때 속도가 오래걸리지않음!!!
// 초기 화면 조건 구성
initCondition();
// 이벤트 초기화
addEvent();
};
//==== 초기화 설정 { ====
var initCondition = function(){
// 초기 화면 조건 구성
// 일자 설정
initStartEndDate();
searchMedicalHis();
};
var searchMedicalHis = function(){
var param = {
userId:gLoginUserId,
patientId:gPatientId,
startDt: moment($("#txtInMedicalHisStartDt").val()).format("YYYYMMDD"),
endDt: moment($("#txtInMedicalHisEndDt").val()).format("YYYYMMDD")
};
self.medical.getOpHistoryList(param, processSearchMedicalOpHisList);
self.medical.getInHistoryList(param, processSearchMedicalInHisList);
self.medical.getOutHistoryList(param, processSearchMedicalOutHisList);
};
var processSearchMedicalInHisList = function(lists){
//console.log(JSON.stringify(lists));
var strDisplayTemp = "";
$("#divMedicalInHistoryResultRows").empty();
for( var i = 0; i < lists.length; i++){
strDisplayTemp += "
"
+ "
"
+ "
입원
"
+ "
" + ((moment(lists[i].hospitalizationDt).format("YYYY-MM-DD") != "Invalid date") ? moment(lists[i].hospitalizationDt).format("YYYY-MM-DD") : "-") + "
"
+ "
" + lists[i].deptNm + "
"
+ "
" + lists[i].doctorNm + "
"
+ "
"
+ "
"
+ "
" + ((lists[i].wardNm != undefined) ? (lists[i].wardNm) : "")
+ ((lists[i].roomNm != undefined) ? ("
" + lists[i].roomNm+"/") : "")
+ ((lists[i].bedNm != undefined) ? (lists[i].bedNm + "
") : "") + "
"
+ "
" + lists[i].diagnosisNm + "
"
+ "
"
+ "
"
;
//console.log( i + " : " + lists[i].deptNm);
}
$("#divMedicalInHistoryResultRows").append(strDisplayTemp); // element 추가
};
var processSearchMedicalOutHisList = function(lists){
//console.log(JSON.stringify(lists));
var strDisplayTemp = "";
$("#divMedicalOutHistoryResultRows").empty();
for( var i = 0; i < lists.length; i++){
strDisplayTemp += ""
+ "
"
+ "
외래
"
+ "
" + ((moment(lists[i].visitDt).format("YYYY-MM-DD") != "Invalid date") ? moment(lists[i].visitDt).format("YYYY-MM-DD") : "-") + "
"
+ "
" + lists[i].deptNm + "
"
+ "
" + lists[i].doctorNm + "
"
+ "
"
+ "
"
+ "
" + ((lists[i].wardNm != undefined) ? (lists[i].wardNm+"/") : "")
+ ((lists[i].roomNm != undefined) ? (lists[i].roomNm+"/") : "")
+ ((lists[i].bedNm != undefined) ? (lists[i].bedNm) : "") + "
"
+ "
" + lists[i].diagnosisNm + "
"
+ "
"
+ "
"
;
//console.log( i + " : " + lists[i].deptNm);
}
$("#divMedicalOutHistoryResultRows").append(strDisplayTemp); // element 추가
};
var processSearchMedicalOpHisList = function(lists){
//console.log(JSON.stringify(lists));
var strDisplayTemp = "";
$("#divMedicalOpHistoryResultRows").empty();
for( var i = 0; i < lists.length; i++){
strDisplayTemp += ""
+ "
"
+ "
수술
"
+ "
" + ((moment(lists[i].operationDt).format("YYYY-MM-DD") != "Invalid date") ? moment(lists[i].operationDt).format("YYYY-MM-DD") : "-") + "
"
+ "
" + lists[i].deptNm + "
"
+ "
" + lists[i].operationDrNm + "
"
+ "
"
+ "
"
+ "
" + ((lists[i].wardNm != undefined) ? (lists[i].wardNm+"/") : "")
+ ((lists[i].roomNm != undefined) ? (lists[i].roomNm+"/") : "")
+ ((lists[i].bedNm != undefined) ? (lists[i].bedNm) : "") + "
"
+ "
" + lists[i].operationNm + "
"
+ "
"
+ "
"
;
//console.log( i + " : " + lists[i].deptNm);
}
$("#divMedicalOpHistoryResultRows").append(strDisplayTemp); // element 추가
};
var initStartEndDate = function(){
//오늘일자 로드
var varToday = new Date();
//일요일이면 차주 가져오기
//다른 요일이면 해당 요일 처리
$("#txtInMedicalHisEndDt").val( moment(varToday).format("YYYY-MM-DD") );
$("#txtInMedicalHisStartDt").val( moment().subtract(1, 'months').format("YYYY-MM-DD") );
};
//==== 초기화 설정 } ====
//==== 이벤트 설정 { ====
var addEvent = function(){
//$("#btnLogout").on("click", function(){
// logout();
//});
eventColumnClick();
eventRowClick();
eventConditionClick();
};
var eventConditionClick = function(){
// 1일
$("#btnMedicalHisOneDaySearch").off("click"); // 기존 이벤트 해제
$("#btnMedicalHisOneDaySearch").on("click", function(e){
$("#txtInMedicalHisStartDt").val( moment().subtract(1, 'days').format("YYYY-MM-DD") );
searchMedicalHis();
});
// 1달 버튼클릭
$("#btnMedicalHisOneMonthSearch").off('click'); // 기존 이벤트 해제
$("#btnMedicalHisOneMonthSearch").on('click', function(e){
$("#txtInMedicalHisStartDt").val( moment().subtract(1, 'months').format("YYYY-MM-DD") );
searchMedicalHis();
});
// 3달 버튼클릭
$("#btnMedicalHisThreeMonthSearch").off('click'); // 기존 이벤트 해제
$("#btnMedicalHisThreeMonthSearch").on('click', function(e){
$("#txtInMedicalHisStartDt").val( moment().subtract(3, 'months').format("YYYY-MM-DD") );
searchMedicalHis();
});
// 6달 버튼클릭
$("#btnMedicalHisSixMonthSearch").off('click'); // 기존 이벤트 해제
$("#btnMedicalHisSixMonthSearch").on('click', function(e){
var varSelDate = new Date($("#txtInMedicalHisEndDt").val());
varSelDate.setDate(varSelDate.getDate() - 1);
varSelDate.setMonth(varSelDate.getMonth() - 6);
$("#txtInMedicalHisStartDt").val( moment(varSelDate).format("YYYY-MM-DD") );
});
// 1년 버튼클릭
$("#btnMedicalHisOneYearSearch").off('click'); // 기존 이벤트 해제
$("#btnMedicalHisOneYearSearch").on('click', function(e){
var varSelDate = new Date($("#txtInMedicalHisEndDt").val());
varSelDate.setDate(varSelDate.getDate() - 1);
varSelDate.setFullYear(varSelDate.getFullYear() - 1);
$("#txtInMedicalHisStartDt").val( moment(varSelDate).format("YYYY-MM-DD") );
});
// 조회버튼
$("#btnMedicalHisSearch").off('click'); // 기존 이벤트 해제
$("#btnMedicalHisSearch").on('click', function(e){
//로우 초기화
$("#divMedicalInHistoryResultRows").empty();
$("#divMedicalOutHistoryResultRows").empty();
$("#divMedicalOpHistoryResultRows").empty();
searchMedicalHis();
});
};
var eventColumnClick = function(){
};
var eventRowClick = function(){
};
//==== 이벤트 설정 } ====
//==== 서비스 실행 { ====
//==== 서비스 실행 { ====
};