1 /* +-----------------------------------------------------------------------------+
2 * OpenEMR - Open Source Electronic Medical Record
3 * Copyright (C) 2013 Z&H Consultancy Services Private Limited <sam@zhservices.com>
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Affero General Public License as
7 * published by the Free Software Foundation, either version 3 of the
8 * License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Affero General Public License for more details.
15 * You should have received a copy of the GNU Affero General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 * @author BASIL PT <basil@zhservices.com>
18 * @author FASALU RAHMAN K.M <fasalu@zhservices.com>
19 * @author Riju K P <rijukp@zhservices.com>
20 * +------------------------------------------------------------------------------+
23 // Hide Menu if clicked outside
24 $(document).mouseup(function (e){
25 var container = $(".ap-st-st-12");
26 var buttons = $(".send-to");
27 if(!container.is(e.target) && container.has(e.target).length === 0 && !buttons.is(e.target) )
29 $(".ap-st-st-12").css("display","none");
37 window.addRule = function (selector, styles, sheet) {
39 styles = (function (styles) {
40 if (typeof styles === "string") return styles;
42 for (var prop in styles) {
43 if (styles.hasOwnProperty(prop)) {
44 var val = styles[prop];
45 prop = prop.replace(/([A-Z])/g, "-$1").toLowerCase(); // convert to dash-case
46 clone += prop + ":" + (prop === "content" ? '"' + val + '"' : val) + "; ";
51 sheet = sheet || document.styleSheets[document.styleSheets.length - 1];
53 if (sheet.insertRule) sheet.insertRule(selector + " {" + styles + "}", sheet.cssRules.length);
54 else if (sheet.addRule) sheet.addRule(selector, styles);
60 if ($) $.fn.addRule = function (styles, sheet) {
61 addRule(this.selector, styles, sheet);
65 }(this.jQuery || this.Zepto));
67 $(document).ready(function(){
69 /* show hide on click */
70 $('.send-to').click(function(){
71 //var pos = $(this).position();
72 //$('.ap-st-st-12').fadeToggle().css({
73 // "left" : (pos.left)+"px",
74 // "top" : (pos.top+35)+"px"
76 $('.se_in_15').fadeOut();
77 var cleintwidth = $(window).width();
78 var pos = $(this).position();
79 var sendLeft = $('.ap-st-st-12').width()+pos.left;
81 if(sendLeft > cleintwidth){
83 right : ((cleintwidth-pos.left)-74)+"px",
84 top : (pos.top+35)+"px"
87 $('.ap-st-st-12:after').addRule({ left :"98%" });
88 $('.ap-st-st-12:before').addRule({ left :"98%" });
91 var sendCss = { left : (pos.left+5)+"px", top : (pos.top+35)+"px" }
93 $('.ap-st-st-12').fadeToggle().css(sendCss);
96 $(".ap-st-st-4").click(function(){
97 if($(this).is(":checked")){
98 $(".check_component").attr("checked",true);
99 $(".selected_check").removeClass("selected_check");
101 $(".check_component").removeAttr("checked");
102 $(".option_wrap").addClass("selected_check");
107 $(".ap-st-st-5").on("click",".check_component",function(){
108 checkedCount = $('[name="componentcheckbox[]"]:checked').length;
109 if(check_count == checkedCount) $(".ap-st-st-4").attr("checked",true);
110 else $(".ap-st-st-4").attr("checked",false);
111 $(this).parent().toggleClass("selected_check");
114 // Toggle Fax Section
115 $('[name="send_to"]').click(function(){
116 if($(this).attr("id") == "send_to_fax") {
117 $(".ap-st-st-8").show();
118 $(".display_block").removeClass("display_block");
119 $("#combination_form_div").addClass("display_block");
121 else if($(this).attr("id") == "send_to_printer"){
122 $(".ap-st-st-8").hide();
123 $(".display_block").removeClass("display_block");
124 $("#combination_form_div").addClass("display_block");
126 else if($(this).attr("id") == "send_to_hie"){
127 $(".display_block").removeClass("display_block");
128 $("#hie_div").addClass("display_block");
130 else if($(this).attr("id") == "send_to_emrdirect"){
131 $(".display_block").removeClass("display_block");
132 $("#emrDirect_div").addClass("display_block");
134 else if($(this).attr("id") == "download_all"){
135 $(".display_block").removeClass("display_block");
136 $("#download_all_div").addClass("display_block");
141 $("#fax_reciever").change(function(){
142 if($("#fax_reciever").val() != ''){
143 if($(this).val() == 'other'){
144 $("#fax_no").attr('style','');
145 $("#fax_no").attr('readonly',false);
146 $("#fax_no").val('');
147 $("#facility_tr").hide();
148 $("#fax_no_tr").show();
150 $("#fax_no_tr").hide();
151 $("#facility_tr").show();
154 url : APP_URL+"/application/sendto/ajax",
157 ajax_mode : 'fax_details',
158 req_list : $("#fax_reciever").val(),
160 success: function(thedata){
161 $("#facility_fax_no").html(thedata);
174 $("#facility_fax_no").change(function(){
175 if($("#facility_fax_no").val()){
176 $("#fax_no_tr").show();
177 $("#fax_no").attr('style','background:#ccc;');
178 $("#fax_no").attr('readonly','readonly');
179 $("#fax_no").val($("#facility_fax_no").val());
181 var resultTranslated = js_xl("No Fax Number Saved For The Selected Organization");
182 alert(resultTranslated.msg);
187 $(".showcomponentsForCCDA-div").click(function(){
188 $("#componentsForCCDA").slideToggle('slow');
191 //check all for component
192 $('#chkall_cmp1').click(function(event) {
194 $("#chkall_cmp_div1").removeClass("selected_check");
195 $('.chkbxcmp_click1').each(function() {
197 $(".selected_check").removeClass("selected_check");
201 $("#chkall_cmp_div1").addClass("selected_check");
202 $('.chkbxcmp_click1').each(function() {
203 this.checked = false;
204 $(".chkdivcmp1").addClass("selected_check");
208 $(".chkbxcmp_click1").click(function(){
209 chk_cmp_id = $(this).attr('id');
210 if($(this).is(":checked")){
211 $("#"+chk_cmp_id).removeClass("selected_check");
213 $("#"+chk_cmp_id).addClass("selected_check");
215 chkbx_click_len = $(".chkbxcmp_click1").length;
216 chkbx_click_checked_len = $(".chkbxcmp_click1:checked").length;
217 if(chkbx_click_checked_len == chkbx_click_len){
218 $("#chkall_cmp1").attr("checked",true);
219 $("#chkall_cmp_div1").removeClass("selected_check");
221 $("#chkall_cmp1").attr("checked",false);
222 $("#chkall_cmp_div1").addClass("selected_check");
226 function getComponents(val){
229 url : APP_URL+"/application/sendto/ajax",
232 ajax_mode : 'get_componets',
236 success: function(json){
237 $(".ap-st-st-5").html("");
238 $(".ap-st-st-4").attr("checked",false);
241 components = JSON.parse(json);
242 for(form_id in components){
244 checkBox += "<div class='option_wrap'><input checked name='componentcheckbox[]' class='check_component' type='checkbox' value='"+form_id+"' ref='"+components[form_id]+"' > "+components[form_id]+"</div>";
246 checkBox+="<div class='clear'></div>";
247 $(".ap-st-st-4").attr("checked",true);
248 $(".ap-st-st-5").html(checkBox);
252 var resultTranslated = js_xl("Something went wrong");
253 alert(resultTranslated.msg);
259 var send_to = $('input:radio[name="send_to"]:checked').val();
260 var cover_letter = 0;
261 if($("#include_coverletter").is(":checked")) cover_letter = 1;
262 $('.activity_indicator').css({
265 $("#downloadccda").val('');
266 $("#downloadccr").val('');
267 $("#downloadccd").val('');
269 $(".check_component1").each(function(){
270 if($(this).is(":checked")){
273 comp += $(this).val();
276 if(send_to == "printer" || send_to == "fax"){
278 formnames_title = "";
280 $(".check_component").each(function(){
281 if($(this).is(":checked")){
285 formnames_title +="***";
287 formnames += $(this).val();
288 formnames_title += $(this).attr("ref");
291 if(send_to == "printer"){
293 url += "covering_letter="+cover_letter+"&selected_cform="+$("#selected_cform").val();
294 url += "&formnames="+formnames+"&formnames_title="+formnames_title;
295 window.open(WEB_ROOT+"/interface/patient_file/encounter/print_report.php?"+url,"Print",'width=1000,height=800,resizable=yes,scrollbars=yes');
296 $('.ap-st-st-12').fadeToggle();
297 $('.activity_indicator').css({"display" :"none"});
299 if(send_to == "fax"){
302 url : APP_URL+"/application/sendto/ajax",
305 ajax_mode : 'send_fax',
307 attentionto : $("#attention_to").val(),
308 selectedforms : formnames,
309 form_sel_title:formnames_title,
310 selected_cform : $("#selected_cform").val(),
311 covering_letter : $("#include_coverletter").val(),
312 visit_duration : $("#include_visitduration").val(),
313 fax_no : $('#fax_no').val()
316 success: function(data){
317 $('.activity_indicator').css({"display" :"none"});
320 var resultTranslated = js_xl("Fax sending failed");
321 alert(resultTranslated.msg);
322 $('.activity_indicator').css({"display" :"none"});
327 else if(send_to == "hie"){
328 var str = ''; var combination = '';
329 components = document.getElementsByName('ccda');
330 for(i=0 ; i<components.length ; i++){
331 if(components[i].checked){
333 str += components[i].value;
337 if(document.getElementById('ccda_pid')){
338 combination = document.getElementById('ccda_pid').value;
341 pid_encounter = document.getElementsByName('ccda_pid[]');
342 for(i=0 ; i<pid_encounter.length ; i++){
343 if(pid_encounter[i].checked){
344 if(combination) combination += '|';
345 combination += pid_encounter[i].value;
349 if(combination == ''){
350 $('.ap-st-st-12').fadeToggle();
351 $('.activity_indicator').css({"display" :"none"});
352 var resultTranslated = js_xl("Please select at least one patient.");
353 alert(resultTranslated.msg);
359 url : APP_URL+"/encounterccdadispatch/index?combination="+combination+"§ions="+str+"&send=1&recipient=hie&components="+comp,
363 success: function(thedata){
364 $('.ap-st-st-12').fadeToggle();
365 $('.activity_indicator').css({"display" :"none"});
366 var resultTranslated = js_xl('Successfully Sent');
367 alert(resultTranslated.msg);
370 $('.activity_indicator').css({"display" :"none"});
371 var resultTranslated = js_xl("Send To HIE failed");
372 alert(resultTranslated.msg);
377 else if(send_to == "download"){
378 $('.activity_indicator').css({"display" :"none"});
379 obj = document.getElementsByName('download_format');
381 for(i=0 ; i<obj.length ; i++){
382 if (obj[i].disabled == false && obj[i].checked == true) {
387 var resultTranslated = js_xl("Please select a format");
388 alert(resultTranslated.msg);
391 $('#hl7button').trigger('click');
393 else if(send_to == "emr_direct") {
394 format = $('input:radio[name="phimail_format"]:checked').val();
397 if($("#ccda_pid").val()){
398 combination = $("#ccda_pid").val();
401 pid_encounter = document.getElementsByName('ccda_pid[]');
402 for(i=0 ; i<pid_encounter.length ; i++){
403 if(pid_encounter[i].checked){
404 if(combination) combination += '|';
405 combination += pid_encounter[i].value;
409 if(combination == ''){
410 $('.ap-st-st-12').fadeOut();
411 $('.activity_indicator').css({"display" :"none"});
412 var resultTranslated = js_xl("Please select at least one patient.");
413 alert(resultTranslated.msg);
416 $(".chkbx_cmps").each(function(){
417 if($(this).is(":checked")){
419 if(components) components +="|";
420 components += $(this).val();
423 recipients = $(".emr_to_phimail").val();
424 var referral_reason = $("#referral_reason").val();
425 if(recipients != '') {
428 url : APP_URL+"/encounterccdadispatch/index?combination="+combination+"§ions="+components+"&view=1&emr_transfer=1&recipient=emr_direct¶m="+recipients+"&referral_reason="+referral_reason+"&components="+comp,
435 url : APP_URL+"/encountermanager/transmitCCD?combination="+combination+"&recipients="+recipients+"&xml_type="+format,
439 success: function(thedata){
440 $('.ap-st-st-12').fadeOut();
441 $('.activity_indicator').css({"display" :"none"});
442 var resultTranslated = js_xl(thedata);
443 alert(resultTranslated.msg);
446 $('.ap-st-st-12').fadeOut();
447 $('.activity_indicator').css({"display" :"none"});
448 var resultTranslated = js_xl("Failed to send");
449 alert(resultTranslated.msg);
454 $('.activity_indicator').css({"display" :"none"});
455 var resultTranslated = js_xl("Please Specify at least One Direct Address");
456 alert(resultTranslated.msg);
459 else if(send_to == "download_all") {
461 if($('#ccda_pid').val()) {
462 pids = $('#ccda_pid').val();
463 pids = pids.split("_");
468 pids = document.getElementsByName('ccda_pid[]');
469 for(i=0 ; i<pids.length ; i++){
477 $('.ap-st-st-12').fadeOut();
478 $('.activity_indicator').css({"display" :"none"});
479 var resultTranslated = js_xl("Please select at least one patient.");
480 alert(resultTranslated.msg);
484 var download_format = $('input:radio[name="downloadformat"]:checked').val();
485 if(download_format == 'ccda') {
486 if($('#ccda_pid').val()) {
487 window.location.assign(WEB_ROOT+"/interface/modules/zend_modules/public/encountermanager/index?pid_ccda="+pid+"&downloadccda=download_ccda&components="+comp);
490 $('#components').val(comp);
491 $('#download_ccda').trigger("click");
492 $(".check_pid").prop("checked",false);
495 else if(download_format == 'ccr') {
496 if($('#ccda_pid').val()) {
497 window.location.assign(WEB_ROOT+"/interface/modules/zend_modules/public/encountermanager/index?pid_ccr="+pid+"&downloadccr=download_ccr");
500 $('#download_ccr').trigger("click");
501 $(".check_pid").prop("checked",false);
504 else if(download_format == 'ccd') {
505 if($('#ccda_pid').val()) {
506 window.location.assign(WEB_ROOT+"/interface/modules/zend_modules/public/encountermanager/index?pid_ccd="+pid+"&downloadccd=download_ccd");
509 $('#download_ccd').trigger("click");
510 $(".check_pid").prop("checked",false);
513 //$(".check_pid").prop("checked",false);
514 $('.ap-st-st-12').fadeOut();
515 $('.activity_indicator').css({"display" :"none"});