123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931 |
- /**
- * consent/search
- */
- var mcare_mobile_consentSearch = function(){
- //상속
- mplus_mobile_consent.call(this);
- //변수
- var div = $("<div></div>");
- var tr = $("<tr></tr>");
- var th = $("<th></th>");
- var td = $("<td></td>");
- var table = $("<table></table>");
- var li = $("<li></li>");
- var a = $("<a></a>");
- var span = $("<span></span>");
- var button = $("<button></button>");
- $crudServiceBaseUrl = contextPath + "/mobile";
-
- var $btnSearchPatient = $('#btnSearchPatient');
- var $btnTotalSearchConsent = $('#btnTotalSearchConsent');
- var $btnSearchConsent = $('#btnSearchConsent');
- var $sltHospital = $('#sltHospital');
- var $sltTreament = $('#sltTreament');
- var $dtpSrchdd = $('#dtpSrchdd');
- var $sltDoctor = $('#sltDoctor');
- var $txtSearchPatient = $('#txtSearchPatient');
- var $ulPatientList = $('#ulPatientList');
- var $ulAgreementCheck = $("#ulAgreementCheck");
- var $ulAgreementList = $("#ulAgreementList");
- var $ulConsentList = $("#ulConsentList");
- var $ulSetList = $('#ulSetList');
- var $dtpConsentStartDt = $('#dtpConsentStartDt');
- var $dtpConsentEndDt = $('#dtpConsentEndDt');
- var $sltCategory = $('#sltCategory');
- var $sltCategoryLower = $('#sltCategoryLower');
- var $txtConsentSrch = $('#txtConsentSrch');
- var $tabSet = $('#tabSet');
- var todayDateStr = '';
-
- var $menuType = 'SR';
-
- var self = this;
-
- patientList = [];
- var patientInfo;
- var unfinishedConsentList = [];
- var agreementList = [];
- var setList = [];
- var totalConsentList = [];
- var doctorId;
- var doctorNm;
- var targetOrdType;
- /**
- * 초기화
- */
- this.init = function(){
- formDataInit();
- addEvent();
- initDropDownList();
- initSetList();
- if(jobKindCd=='0330'||jobKindCd=='0640'){
- $sltTreament.selectpicker('val', deptCd);
- if($sltTreament.val()==null) {
- $sltTreament.selectpicker('val', '');
- }else{
- showDoctorList(deptCd);
- }
- };
- };
-
- var formDataInit = function(){
- // datepicker 초기화
- $('.datepicker').datepicker({'format': 'yyyy/mm/dd'});
- var today = new Date();
- var prevDay = new Date(Date.parse(new Date()) - 7 * 1000 * 60 * 60 * 24); //일주일전!!
- todayDateStr = moment(today).format('YYYY/MM/DD');
- var prevDayStr = moment(prevDay).format('YYYY/MM/DD');
- $("#divDtpSrchdd").datepicker('update', todayDateStr);
- $("#divDtpConsentStartDt").datepicker('update', prevDayStr);
- $("#divDtpConsentEndDt").datepicker('update', todayDateStr);
- };
-
- /**
- * 이벤트 등록
- */
- var addEvent = function(){
- $btnSearchPatient.on("click", function(e){
- $('span[name^="sort_"]').attr('sortType', '');
- searchPatientList();
- });
- $btnTotalSearchConsent.on("click", function(e){
- searchTotalConsentList('Y');
- });
- $btnSearchConsent.on("click", function(e){
- searchConsentList();
- });
- $tabSet.on("click", function(e){
- initSetList();
- });
- $('span[name^="sort_"]').on("click", function(e){
- self.loading("show");
- setTimeout(function(){
- var sortData = e.currentTarget.attributes.name.value.split('_');
- var sortKey = sortData[1];
- var sortType = sortData[2];
- var sortClassName = sortData[3];
- var sortOrder = $('span.'+sortClassName+'[name^="sort_"]')[0].attributes.sortType.value;
-
- $('span[name^="sort_"]').attr('sortType', '');
-
- if(sortOrder==undefined || sortOrder=='up'){
- sortPatientList(sortKey, sortType, 'down');
- $('span.'+sortClassName+'[name^="sort_"]').attr('sortType', 'down');
- }else{
- sortPatientList(sortKey, sortType, 'up');
- $('span.'+sortClassName+'[name^="sort_"]').attr('sortType', 'up');
- };
- self.loading("hide");
- }, 300);
- });
- };
-
- var initDropDownList = function(){
- //병동리스트
- var wardResult = self.hospital.getWardList();
-
- $sltHospital.empty();
- for(var i=0; i<wardResult.length; i++){
- var option = $('<option value='+wardResult[i].deptcd+'>'+wardResult[i].deptnm+'</option>');
- $sltHospital.append(option);
- };
-
- $sltHospital.children(":first").attr("selected", true);
- $sltHospital.selectpicker('refresh');
-
- //부서리스트
- var deptParam = {ordtype: $menuType};
- var deptResult = self.hospital.getDeptList(deptParam);
-
- $sltTreament.empty();
- for(var i=0; i<deptResult.length; i++){
- var option = $('<option value='+deptResult[i].deptcd+'>'+deptResult[i].deptnm+'</option>');
- $sltTreament.append(option);
- };
-
- $sltTreament.children(":first").attr("selected", true);
- $sltTreament.selectpicker('refresh');
-
- //진료과에 따른 의사조회 이벤트 연결
- $sltTreament.change(function() {
- showDoctorList(this.value);
- });
-
- //카테고리조회
- var categoryParam = {
- categoryId: '1'
- };
- var categoryResult = self.consent.getCategoryForDropdown(categoryParam);
-
- $sltCategory.empty();
- for(var i=0; i<categoryResult.length; i++){
- var option = $('<option value='+categoryResult[i].categoryId+'>'+categoryResult[i].categoryName+'</option>');
- $sltCategory.append(option);
- };
-
- $sltCategory.children(":first").attr("selected", true);
- $sltCategory.selectpicker('refresh');
- showCategoryLowerList(categoryResult[0].categoryId);
- //진료과에따른 하위 카테고리조회
- $sltCategory.change(function() {
- showCategoryLowerList(this.value);
- });
- };
-
- var showCategoryLowerList = function(categoryId){
- var param = {
- categoryId: categoryId
- };
- var result = self.consent.getCategoryForDropdown(param);
-
- $sltCategoryLower.empty();
- for(var i=0; i<result.length; i++){
- var option = $('<option value='+result[i].categoryId+'>'+result[i].categoryName+'</option>');
- $sltCategoryLower.append(option);
- };
-
- $sltCategoryLower.children(":first").attr("selected", true);
- $sltCategoryLower.selectpicker('refresh');
- };
-
- //진료과에 따른 의사조회
- var showDoctorList = function(doctorid){
- var param = {
- srchdd: $dtpSrchdd[0].value.replace(/\//g,''),
- orddeptcd: doctorid
- };
- var result = self.hospital.getDoctorList(param);
-
- $sltDoctor.empty();
- for(var i=0; i<result.length; i++){
- var option = $('<option value='+result[i].doctorid+'>'+result[i].doctornm+'</option>');
- $sltDoctor.append(option);
- };
-
- $sltDoctor.children(":first").attr("selected", true);
- $sltDoctor.selectpicker('refresh');
- };
-
- //환자리스트 조회
- var searchPatientList = function(){
- initPatientInfo();
- var param = { srchdd: $dtpSrchdd[0].value.replace(/\//g,''),
- orddeptcd: $sltTreament.val(),
- doctorid: $sltDoctor.val(),
- pid: $txtSearchPatient.val(),
- ordtype: $(':radio[name="searchRadio"]:checked').val()
- };
- targetOrdType = param.ordtype;
- self.patient.getPatientList($menuType, param, 'N');
- };
-
- //환자리스트 정렬
- var sortPatientList = function(sortKey, sortType, order){
- self.patient.setPatientList($menuType, patientList, sortKey, sortType, order);
- };
-
- //환자정보 초기화
- var initPatientInfo = function(){
- $ulAgreementList.empty();
- patientInfo = {};
- $("#tbPatientInfo").empty();
- unfinishedConsentList = [];
- $ulAgreementCheck.empty();
- $("#consentTap1 .sub-title").empty();
- };
- //환자정보 조회
- getPatientInfo = function(seq){
- initPatientInfo();
- var data = patientList[seq];
- var patientParam = { pid: data.pid,
- orddd: data.indd.replace(/\//g,''),
- ordtype: data.ordtype,
- orddeptcd: data.orddeptcd
- };
- var patientResult = self.hospital.getPatientInfo(patientParam);
- // target 환자 정보를 보관해 둔다
- patientInfo = patientResult[0];
- if( patientInfo == undefined ) {return;};
- doctorId = data.doctorid; //설명의사 설정하기위해 주치의ID를 보관
- doctorNm = data.doctornm; //설명의사 설정 - 주치의 이름 보관
-
- $("#divDtpConsentStartDt").datepicker('update', moment(patientInfo.ioaddate).format('YYYY/MM/DD'));
-
- for(var i=0; i<patientResult.length; i++){
- //환자정보 바인딩
- var trData = tr.clone().html(th.clone().text("입원일")).append(td.clone().text(moment(patientResult[i].ioaddate).format('YYYY/MM/DD')));
- var trData2 = tr.clone().html(th.clone().text("주치의")).append(td.clone().text(patientResult[i].iomaindrNm));
- var trData3 = tr.clone().html(th.clone().text("진단명")).append(td.clone().text(patientResult[i].iodxNm));
- var tdData4 = td.clone();
- for(var j=0; j<1; j++){
- tdData5= tdData4.append("").append("</br>"); //alert Data
- };
- var trData6 = tr.clone().addClass("infoalert").html(th.clone().text("Alert")).append(tdData5);
- var tableData = table.clone().addClass("patientData").html(trData).append(trData2).append(trData3).append(trData6);
- $("#consentTap1 .sub-title").text(patientResult[i].ioptID+" " + patientResult[i].ioptName+" "+ editAgeToIdNum(patientResult[i].iosexAgeYM) + "/"+patientResult[i].iojuminNo.split('-')[0]);
- $("#tbPatientInfo").append(tableData);
- };
- getUnfinishedConsentInfo(data);
- };
- //미작성동의서 조회
- var getUnfinishedConsentInfo = function(data){
- var consentParam = {
- patientCode: data.pid,
- startDt: patientInfo.ioaddate,
- endDt: moment(todayDateStr).format('YYYYMMDD'),
- consentState: "'UNFINISHED', 'TEMP'",
- jobKindCd: indexPage=='O'&&(jobKindCd=='1140'||jobKindCd=='1113')? 'ALL': jobKindCd
- };
- var consentResult = self.consent.getConsentList(consentParam);
- unfinishedConsentList = consentResult;
- //미작성동의서 리스트 바인딩
- var divCheckbox = div.clone().addClass("checkbox3 checkbox-check checkbox-light");
- $ulAgreementCheck.empty();
- for(var i=0; i<consentResult.length; i++){
- $ulAgreementCheck.append(
- li.clone().html(
- divCheckbox.clone().html($("<input type='checkbox' id='chkConsentUnfinished_"+(i+1)+"'></input>"))
- .append($("<label for='chkConsentUnfinished_"+(i+1)+"'></label>"))
- .append(span.clone().addClass("detail").text(consentResult[i].consentName))
- .append(span.clone().addClass("label "+
- (consentResult[i].consentState=='TEMP'? "label-temp":
- consentResult[i].consentState=='UNFINISHED'? "label-unfinished":
- consentResult[i].consentState=='ELECTR_CMP'? "label-electrCmp":
- consentResult[i].consentState=='CERTIFY_CMP'? "label-certifyCmp":
- consentResult[i].consentState=='PAPER_OUT'? "label-paperOut":
- consentResult[i].consentState=='VERBAL'? "label-verbal":"label-default")
- ).text(consentResult[i].consentStateDisp))
- .append(button.clone().addClass("text-right btn btn-default")
- .text("삭제").attr("seq", i))))
- };
- $('#ulAgreementCheck li').on("click", function(e){
- if(e.toElement.localName == "label") {//체크박스 클릭
- var input = $(this).children().children("input");
- $(input).prop("checked", !$(input).prop("checked"));
- if($(input).prop("checked")) { $(this).addClass('checked') }
- else { $(this).removeClass('checked') }
- }else if(e.toElement.localName == "button"){//버튼클릭
-
- }else{//동의서 내용 클릭
- if(!$(this).hasClass("checked")){
- var input = $(this).children().children("input");
- $(input).prop("checked", true);
- $(this).addClass('checked');
- };
-
- // 외래>담당의가 일반의사인 경우 무조건 출력전용이므로 alert 메시지 띄우고 리턴한다.
- // 16.12.12 #6225 siyoung.ahn
- if( targetOrdType == 'O' && doctorId.startsWith('5000')) {
- self.alert("담당의가 일반의사인 경우 출력전용입니다.");
- return;
- }
-
- //선택한 동의서만 가지고오기
- var selectedItems = $('#ulAgreementCheck li[class="checked"] input');
- var selectedConsentList = [];
- var printOnlyList = [];
- for( var i = 0; i < selectedItems.length; i++ ){
- // sequence 추출
- var seq = selectedItems[i].id.split('_')[1];
- seq = seq - 1;
-
- // 동의서 상태 체크
- var param = {consentmstrid: unfinishedConsentList[seq].consentMstRid,
- consentState: unfinishedConsentList[seq].consentState};
-
- var state = self.consent.checkConsentState(param);
- if( state == undefined ) { printOnlyList.push("["+unfinishedConsentList[seq].consentName+"] - 상태 조회 실패"); }
- else if (state.text == '-1') { printOnlyList.push("["+unfinishedConsentList[seq].consentName+"] - 상태 조회 실패"); }
- else if (state.text == '1') { printOnlyList.push("["+unfinishedConsentList[seq].consentName+"] - 이미 작성된 동의서"); }
- else if (state.text == '0'){
- selectedConsentList.push(unfinishedConsentList[seq]);
- }
- }
-
- // 외래로 검색한 경우에 설명의사 처리
- var userId = loginUserId;
- var userName = loginUserName;
- if( targetOrdType == 'O') {
- userId = doctorId;
- userName = doctorNm;
- }
-
- var printOnlyAlertMsg = '';
- for(var j=0; j<printOnlyList.length; j++){
- printOnlyAlertMsg = printOnlyAlertMsg + printOnlyList[j];
- if(j!=printOnlyList.length-1) printOnlyAlertMsg = printOnlyAlertMsg +"\n";
- };
-
- if(printOnlyAlertMsg.length>0) {
- self.confirm("작성이 불가능한 동의서입니다.\n\n" + printOnlyAlertMsg, function(confirm){
- if(confirm){
- var global = self.consent.makeGlobalParam(patientInfo, userId);
- var consent = self.consent.makeConsentParam(patientInfo, selectedConsentList, userName);
-
- var jsonssg = {
- "type" : "command",
- "functionType" : "consent",
- "value" : {
- "callbackFn" : "window.activeObj.consentCallback"
- },
- "userId": userId,
- "globalParam" : global,
- "consentParam" : consent
- };
- self.toNative(jsonssg);
- }
- });
- }else{
- if(selectedConsentList.length > 0){
- var global = self.consent.makeGlobalParam(patientInfo, userId);
- var consent = self.consent.makeConsentParam(patientInfo, selectedConsentList, userName);
-
- var jsonssg = {
- "type" : "command",
- "functionType" : "consent",
- "value" : {
- "callbackFn" : "window.activeObj.consentCallback"
- },
- "userId" : userId,
- "globalParam" : global,
- "consentParam" : consent
- };
- self.toNative(jsonssg);
- };
- };
- };
- e.stopPropagation();
- e.preventDefault();
- });
- $('#ulAgreementCheck li button').on("click", function(e){
- self.confirm("삭제하시겠습니까?", function(confirm){
- if(confirm){
- $('#txtSeq').val(e.currentTarget.attributes.seq.value);
- $('#mplusConsentDeleteForm').modal('show');
- $('#btnConsentDelete').unbind();
- $('#btnConsentDelete').on('click', function(){
- var checkVal = $('#mplusConsentDeleteForm input[name=consentDeleteRadio]:checked').val();
- var deleteReasonText = $('#consentDeleteTextarea').val();
- deleteConsent($('#txtSeq').val(),
- checkVal=="slt4"? deleteReasonText: $('#mplusConsentDeleteForm input[name=consentDeleteRadio]:checked')[0].attributes.dataReason.value);
- });
- }
- });
- });
- };
-
- //동의서이력 리스트 초기화
- var searchTotalConsentList = function(alertYn){
- $ulAgreementList.empty();
- var divCheckbox = div.clone().addClass("checkbox3 checkbox-check checkbox-light");
- if($('#ulPatientList .list-group-item.active').parent()[0]==undefined){
- self.alert('조회할 환자를 선택해주세요.');
- return;
- };
- if( patientInfo == undefined ){
- self.alert('환자 정보가 정상 조회되지 않았습니다.');
- return;
- };
-
- var temIndex = $('#ulPatientList .list-group-item.active').parent()[0].id.split('_')[1];
- var data = patientList[temIndex];
- var temConsentState = self.consent.makeConsentStateParam();
- if(temConsentState==undefined) return;
- $('#agreeListHeader .consentHeader').css('display', 'none');
-
- var param = {
- patientCode: data.pid,
- startDt: $dtpConsentStartDt[0].value.replace(/\//g,''),
- endDt: $dtpConsentEndDt[0].value.replace(/\//g,''),
- consentState: temConsentState,
- jobKindCd: indexPage=='O'&&(jobKindCd=='1140'||jobKindCd=='1113')? 'ALL': jobKindCd
- };
- var result = self.consent.getConsentList(param);
- // 오른쪽 동의서 리스트 보관
- agreementList = result;
-
- if(alertYn=='Y'&&(result==undefined||result.length==0)) {
- self.alert('조회된 데이터가 없습니다.');
- return;
- }else if(alertYn=='N'&&(result==undefined||result.length==0)) {return;};
- for(var i=0; i<result.length; i++){
- $ulAgreementList.addClass("agreementCheck").append(
- li.clone().html(
- divCheckbox.clone().html($("<input type='checkbox' id='chkConsentPatient_"+(i+1)+"'></input>"))
- .append($("<label for='chkConsentPatient_"+(i+1)+"'></label>"))
- .append(span.clone().addClass("document").text(result[i].consentName)
- .append(span.clone().addClass("label "+
- (result[i].consentState=='TEMP'? "label-temp":
- result[i].consentState=='UNFINISHED'? "label-unfinished":
- result[i].consentState=='ELECTR_CMP'? "label-electrCmp":
- result[i].consentState=='CERTIFY_CMP'? "label-certifyCmp":
- result[i].consentState=='PAPER_OUT'? "label-paperOut":
- result[i].consentState=='VERBAL'? "label-verbal":"label-default")
- ).text(result[i].consentStateDisp)))
-
- ));
- };
- $('#ulAgreementList li').on("click", function(e){
- // 체크박스 클릭했을 때
- if(e.toElement.localName == "label") {
- var input = $(this).children().children("input");
- $(input).prop("checked", !$(input).prop("checked"));
- if($(input).prop("checked")) { $(this).addClass('checked') }
- else { $(this).removeClass('checked') }
- }else{
- // 동의서 내용을 클릭했을 때
- if(!$(this).hasClass("checked")){
- var input = $(this).children().children("input");
- $(input).prop("checked", true);
- $(this).addClass('checked');
- };
-
- var selectedSeq = $(this).children().children("input").attr('id').split('_')[1];
- var lastSelectedItem = agreementList[selectedSeq - 1];
- // 클릭한 동의서의 상태 체크
- // 환자서명이거나 전자인증의 경우 모두 체크해제 하고, 해당 동의서의 이미지를 띄움
- if( lastSelectedItem.consentState == 'ELECTR_CMP' || lastSelectedItem.consentState == 'CERTIFY_CMP' ) {
- // 체크해제
- $('#ulAgreementList li[class="checked"] input').prop("checked", false);
- $('#ulAgreementList li[class="checked"]').removeClass("checked");
-
- var param = {consentMstRid : lastSelectedItem.consentMstRid};
- var consentImageList = self.consent.getConsentImage(param);
-
- if(consentImageList == undefined || consentImageList.length==0) {
- self.alert("동의서 이미지 조회 실패");
- return;
- };
- var imagePathList = [];
- $('#consentImgBox').empty();
- for( var i = 0; i < consentImageList.length; i++ ) {
- $('#consentImgBox').append(
- div.clone().append(
- "<img data-u='image' src='"+consentImageList[i].imagePath+"' width='100%'>"
- )
- )
- }
- $('.modal-backdrop').removeClass('in');
- $('.modal').modal('hide');
- $('#mplusConsentImageForm').modal("show");
- };
-
- // 외래>담당의가 일반의사인 경우 무조건 출력전용이므로 alert 메시지 띄우고 리턴한다.
- // 16.12.12 #6225 siyoung.ahn
- if( targetOrdType == 'O' && doctorId.startsWith('5000')) {
- self.alert("담당의가 일반의사인 경우 출력전용입니다.");
- return;
- }
-
- //선택한 동의서만 가지고오기
- var selectedItems = $('#ulAgreementList li[class="checked"] input');
- var selectedConsentList = [];
- var printOnlyList = [];
-
- for( var i = 0; i < selectedItems.length; i++ ){
- // sequence 추출
- var seq = selectedItems[i].id.split('_')[1];
- seq = seq - 1;
- // data add
- if(agreementList[seq].consentState=="PAPER_OUT"|| agreementList[seq].consentState=="FNU_PRINT"){
- //동의서 상태가 출력/FNU출력인 경우 걸러내기
- printOnlyList.push("["+agreementList[seq].consentName+"] - "+agreementList[seq].consentStateDisp);
- }else{
- // 동의서 상태 체크
- var param = {consentmstrid: agreementList[seq].consentMstRid,
- consentState: agreementList[seq].consentState};
-
- var state = self.consent.checkConsentState(param);
- if( state == undefined ) { printOnlyList.push("["+agreementList[seq].consentName+"] - 상태 조회 실패"); }
- else if (state.text == '-1') { printOnlyList.push("["+agreementList[seq].consentName+"] - 상태 조회 실패"); }
- else if (state.text == '1') { printOnlyList.push("["+agreementList[seq].consentName+"] - 이미 작성된 동의서"); }
- else if (state.text == '0'){
- selectedConsentList.push(agreementList[seq]);
- }
- };
- };
- var printOnlyAlertMsg = '';
- for(var j=0; j<printOnlyList.length; j++){
- printOnlyAlertMsg = printOnlyAlertMsg +printOnlyList[j];
- if(j!=printOnlyList.length-1) printOnlyAlertMsg = printOnlyAlertMsg +"\n";
- };
-
- var userId = loginUserId;
- var userName = loginUserName;
- if( targetOrdType == 'O') {
- userId = doctorId;
- userName = doctorNm;
- }
-
- if(printOnlyAlertMsg.length>0) {
- self.confirm("출력전용 및 작성이 불가능한 동의서입니다.\n\n" + printOnlyAlertMsg, function(confirm){
- if(confirm){
- if(selectedConsentList.length > 0){
- var global = self.consent.makeGlobalParam(patientInfo, userId);
- var consent = self.consent.makeConsentParam(patientInfo, selectedConsentList, userName);
-
- // 유효성 검사 추가할 것
- var jsonssg = {
- "type" : "command",
- "functionType" : "consent",
- "value" : {
- "callbackFn" : "window.activeObj.consentCallback"
- },
- "userId" : userId,
- "globalParam" : global,
- "consentParam" : consent
- };
- self.toNative(jsonssg);
- };
- }
- });
- }else{
- if(selectedConsentList.length > 0){
- var global = self.consent.makeGlobalParam(patientInfo, userId);
- var consent = self.consent.makeConsentParam(patientInfo, selectedConsentList, userName);
-
- var jsonssg = {
- "type" : "command",
- "functionType" : "consent",
- "value" : {
- "callbackFn" : "window.activeObj.consentCallback"
- },
- "userId" : userId,
- "globalParam" : global,
- "consentParam" : consent
- };
- self.toNative(jsonssg);
- };
- };
- };
- e.stopPropagation();
- e.preventDefault();
- });
- };
-
- //즐겨찾기 리스트 조회
- var initSetList = function(){
- //set리스트 바인딩
- $ulSetList.empty();
- var param = {};
- var result = self.consent.getConsentSetList(param);
- setList = result;
- var divCheckbox = div.clone().addClass("checkbox3 checkbox-check checkbox-light");
- for(var i=0; i<result.length; i++){
- $ulSetList.addClass("agreementCheck").append(
- li.clone().html(
- divCheckbox.clone().html($("<input type='checkbox' id='chkSetList_"+(i+1)+"'></input>"))
- .append($("<label for='chkSetList_"+(i+1)+"'></label>"))
- .append(span.clone().addClass("document").text(result[i].formName))
- .append(button.clone().addClass("text-right btn btn-default")
- .text("삭제").attr("formCd", result[i].formCd))
- ));
-
- };
- $('#ulSetList li').on("click", function(e){
- if(e.toElement.localName == "label") { //체크박스 클릭
- var input = $(this).children().children("input");
- $(input).prop("checked", !$(input).prop("checked"));
- if($(input).prop("checked")) {
- $(this).addClass('checked')
- }else {
- $(this).removeClass('checked')
- };
- }else if(e.toElement.localName == "button"){ //버큰클릭
-
- }else{ //동의서내용 클릭
- if(!$(this).hasClass("checked")){
- var input = $(this).children().children("input");
- $(input).prop("checked", true);
- $(this).addClass('checked');
- };
-
- if($('#ulPatientList .list-group-item.active').parent()[0]==undefined){
- self.alert('환자를 선택해주세요.');
- return;
- };
-
- // 외래>담당의가 일반의사인 경우 무조건 출력전용이므로 alert 메시지 띄우고 리턴한다.
- // 16.12.12 #6225 siyoung.ahn
- if( targetOrdType == 'O' && doctorId.startsWith('5000')) {
- self.alert("담당의가 일반의사인 경우 출력전용입니다.");
- return;
- }
-
- //선택한 동의서만 가지고오기
- var selectedItems = $('#ulSetList li[class="checked"] input');
- var selectedConsentList = [];
- var printOnlyList = [];
- for( var i = 0; i < selectedItems.length; i++ ){
- // sequence 추출
- var seq = selectedItems[i].id.split('_')[1];
- seq = seq - 1;
- if(setList[seq].printOnly=="Y"){
- printOnlyList.push(setList[seq].formName);
- }else{
- //data add
- selectedConsentList.push(setList[seq]);
- };
- };
-
- var userId = loginUserId;
- var userName = loginUserName;
- if( targetOrdType == 'O') {
- userId = doctorId;
- userName = doctorNm;
- }
-
- var printOnlyAlertMsg = '';
- for(var j=0; j<printOnlyList.length; j++){
- printOnlyAlertMsg = printOnlyAlertMsg +"["+printOnlyList[j]+"]";
- if(j!=printOnlyList.length-1) printOnlyAlertMsg = printOnlyAlertMsg +"\n";
- };
- if(printOnlyAlertMsg.length>0) {
- self.confirm(printOnlyAlertMsg+"\n출력전용 동의서 입니다. \nPC에서 출력하세요.", function(confirm){
- if(confirm){
- if(selectedConsentList.length > 0){
- var global = self.consent.makeGlobalParam(patientInfo, userId);
- var consent = self.consent.makeNewConsentParam(patientInfo, selectedConsentList, userName);
-
- var jsonssg = {
- "type" : "command",
- "functionType" : "consent",
- "value" : {
- "callbackFn" : "window.activeObj.consentCallback"
- },
- "userId": userId,
- "globalParam" : global,
- "consentParam" : consent
- };
- self.toNative(jsonssg);
- };
- }
- });
- }else{
- if(selectedConsentList.length > 0){
- var global = self.consent.makeGlobalParam(patientInfo, userId);
- var consent = self.consent.makeNewConsentParam(patientInfo, selectedConsentList, userName);
-
- var jsonssg = {
- "type" : "command",
- "functionType" : "consent",
- "value" : {
- "callbackFn" : "window.activeObj.consentCallback"
- },
- "userId": userId,
- "globalParam" : global,
- "consentParam" : consent
- };
- self.toNative(jsonssg);
- };
- };
- };
- e.stopPropagation();
- e.preventDefault();
- });
- $('#ulSetList li button').on("click", function(e){
- delUserFormSetList(e);
- });
- };
-
- //동의서 검색
- var searchConsentList = function(){
- var param = {
- categoryId: $sltCategoryLower.val(),
- keyWord: $txtConsentSrch.val()
- };
- var result = self.consent.getConsentBySearch(param);
- // 오른쪽 동의서 리스트 보관
- totalConsentList = result;
- $ulConsentList.empty();
- if(result==undefined||result.length==0) {
- self.alert('조회된 데이터가 없습니다.');
- return;
- };
- //동의서 조회 리스트 바인딩
- var divCheckbox = div.clone().addClass("checkbox3 checkbox-check checkbox-light");
- for(var i=0; i<result.length; i++){
- $ulConsentList.addClass("agreementCheck").append(
- li.clone().html(
- divCheckbox.clone().html($("<input type='checkbox' id='chkConsentSearch_"+(i+1)+"'></input>"))
- .append($("<label for='chkConsentSearch_"+(i+1)+"'></label>"))
- .append(span.clone().addClass("document").text(result[i].formName)
- )
- .append(button.clone().addClass("text-right btn btn-default")
- .text("추가").attr("formCd", result[i].formCd))
-
- ));
- };
-
- $('#ulConsentList li').on("click", function(e){
- if(e.toElement.localName == "label") { //체크박스 클릭
- var input = $(this).children().children("input");
- $(input).prop("checked", !$(input).prop("checked"));
- if($(input).prop("checked")) $(this).addClass('checked')
- else $(this).removeClass('checked')
- }else if(e.toElement.localName == "button"){ //버튼클릭
-
- }else{ //동의서 내용 클릭
- if(!$(this).hasClass("checked")){
- var input = $(this).children().children("input");
- $(input).prop("checked", true);
- $(this).addClass('checked');
- };
-
- if($('#ulPatientList .list-group-item.active').parent()[0]==undefined){
- self.alert('환자를 선택해주세요.');
- return;
- };
-
- // 외래>담당의가 일반의사인 경우 무조건 출력전용이므로 alert 메시지 띄우고 리턴한다.
- // 16.12.12 #6225 siyoung.ahn
- if( targetOrdType == 'O' && doctorId.startsWith('5000')) {
- self.alert("담당의가 일반의사인 경우 출력전용입니다.");
- return;
- }
-
- //선택한 동의서만 가지고오기
- var selectedItems = $('#ulConsentList li[class="checked"] input');
- var selectedConsentList = [];
- var printOnlyList = [];
- for( var i = 0; i < selectedItems.length; i++ ){
- // sequence 추출
- var seq = selectedItems[i].id.split('_')[1];
- seq = seq - 1;
- if(totalConsentList[seq].prntOnly=="Y"){
- printOnlyList.push(totalConsentList[seq].formName);
- }else{
- //data add
- selectedConsentList.push(totalConsentList[seq]);
- };
- };
- var printOnlyAlertMsg = '';
- for(var j=0; j<printOnlyList.length; j++){
- printOnlyAlertMsg = printOnlyAlertMsg +"["+printOnlyList[j]+"]";
- if(j!=printOnlyList.length-1) printOnlyAlertMsg = printOnlyAlertMsg +"\n";
- };
-
- var userId = loginUserId;
- var userName = loginUserName;
- if( targetOrdType == 'O') {
- userId = doctorId;
- userName = doctorNm;
- }
-
- if(printOnlyAlertMsg.length>0) {
- self.confirm(printOnlyAlertMsg+"\n출력전용 동의서 입니다. \nPC에서 출력하세요.", function(confirm){
- if(confirm){
- if(selectedConsentList.length > 0){
- var global = self.consent.makeGlobalParam(patientInfo, userId);
- var consent = self.consent.makeNewConsentParam(patientInfo, selectedConsentList, userName);
-
- // 유효성 검사 추가할 것
- var jsonssg = {
- "type" : "command",
- "functionType" : "consent",
- "value" : {
- "callbackFn" : "window.activeObj.consentCallback"
- },
- "userId": userId,
- "globalParam" : global,
- "consentParam" : consent
- };
- self.toNative(jsonssg);
- };
- }
- });
- }else{
- if(selectedConsentList.length > 0){
- var global = self.consent.makeGlobalParam(patientInfo, userId);
- var consent = self.consent.makeNewConsentParam(patientInfo, selectedConsentList, userName);
-
- // 유효성 검사 추가할 것
-
- var jsonssg = {
- "type" : "command",
- "functionType" : "consent",
- "value" : {
- "callbackFn" : "window.activeObj.consentCallback"
- },
- "userId": userId,
- "globalParam" : global,
- "consentParam" : consent
- };
- self.toNative(jsonssg);
- };
- };
- };
- e.stopPropagation();
- e.preventDefault();
- });
- $('#ulConsentList li button').on("click", function(e){
- setUserFormSetList(e);
- });
- }
- //즐겨찾기 삭제
- var delUserFormSetList = function(e){
- self.confirm("삭제하시겠습니까?", function(confirm){
- if(confirm){
- var result = self.consent.delUserFormSetList({"formcd": e.currentTarget.attributes.formCd.value});
- if(result.formcd!=null){
- initSetList();
- /*self.alert("삭제되었습니다.");*///16.11.12 고객사요청으로 제거
- }else{
- self.alert("실패했습니다.");
- }
- };
- })
- }
-
- //즐겨찾기 추가
- var setUserFormSetList = function(e){
- self.confirm("즐겨찾기로 추가하시겠습니까?", function(confirm){
- if(confirm){
- var result = self.consent.setUserFormSetList({"formcd": e.currentTarget.attributes.formCd.value});
- if(result.formcd!=null){
- /*self.alert("추가되었습니다.");*///16.11.12 고객사요청으로 제거
- }else{
- self.alert("실패했습니다.");
- }
- };
- })
- }
-
- //동의서 삭제
- var deleteConsent = function(seq, reason){
- $("#mplusConsentDeleteForm").modal("hide");
- var delConsentInfo = unfinishedConsentList[seq];
- var delConsentParam = { "consentMstRid": delConsentInfo.consentMstRid,
- "patientCode": delConsentInfo.patientCode,
- "clnDeptCode": delConsentInfo.clnDeptCd,
- "ward": delConsentInfo.ward==null? "": delConsentInfo.ward,
- "roomcd": delConsentInfo.roomCd==null? "": delConsentInfo.roomCd,
- "formRid": delConsentInfo.formRid==null? "":delConsentInfo.formRid,
- "consentState": delConsentInfo.consentState==null? "":delConsentInfo.consentState,
- "reasonForUseN": reason
- }
- var result = self.consent.delConsent(delConsentParam);
- if(result.text==delConsentInfo.consentMstRid){
- /*self.alert("삭제되었습니다.");*///16.11.12 고객사요청으로 제거
- getUnfinishedConsentInfo(patientList[$('#ulPatientList li a.active')[0].attributes.seq.value]);
- }else{
- self.alert("실패했습니다.");
- }
- }
-
- // 단말기에서 호출할 콜백
- this.consentCallback = function(data) {
- //self.alert(data);
- // 미작성 동의서 리프레쉬
- getUnfinishedConsentInfo(patientList[$('#ulPatientList li a.active')[0].attributes.seq.value]);
- // 오른쪽 동의서 리스트 리프레쉬
- // 동의서 리스트가 오픈되어있을 떄만 해야하나?
- searchTotalConsentList('N');
- }
- };
|