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);
165 var resultTranslated = js_xl("ajax error");
166 alert(resultTranslated.msg);
175 $("#facility_fax_no").change(function(){
176 if($("#facility_fax_no").val()){
177 $("#fax_no_tr").show();
178 $("#fax_no").attr('style','background:#ccc;');
179 $("#fax_no").attr('readonly','readonly');
180 $("#fax_no").val($("#facility_fax_no").val());
182 var resultTranslated = js_xl("No Fax Number Saved For The Selected Organization");
183 alert(resultTranslated.msg);
188 $(".showcomponentsForCCDA-div").click(function(){
189 $("#componentsForCCDA").slideToggle('slow');
192 //check all for component
193 $('#chkall_cmp1').click(function(event) {
195 $("#chkall_cmp_div1").removeClass("selected_check");
196 $('.chkbxcmp_click1').each(function() {
198 $(".selected_check").removeClass("selected_check");
202 $("#chkall_cmp_div1").addClass("selected_check");
203 $('.chkbxcmp_click1').each(function() {
204 this.checked = false;
205 $(".chkdivcmp1").addClass("selected_check");
209 $(".chkbxcmp_click1").click(function(){
210 chk_cmp_id = $(this).attr('id');
211 if($(this).is(":checked")){
212 $("#"+chk_cmp_id).removeClass("selected_check");
214 $("#"+chk_cmp_id).addClass("selected_check");
216 chkbx_click_len = $(".chkbxcmp_click1").length;
217 chkbx_click_checked_len = $(".chkbxcmp_click1:checked").length;
218 if(chkbx_click_checked_len == chkbx_click_len){
219 $("#chkall_cmp1").attr("checked",true);
220 $("#chkall_cmp_div1").removeClass("selected_check");
222 $("#chkall_cmp1").attr("checked",false);
223 $("#chkall_cmp_div1").addClass("selected_check");
227 function getComponents(val){
230 url : APP_URL+"/application/sendto/ajax",
233 ajax_mode : 'get_componets',
237 success: function(json){
238 $(".ap-st-st-5").html("");
239 $(".ap-st-st-4").attr("checked",false);
242 components = JSON.parse(json);
243 for(form_id in components){
245 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>";
247 checkBox+="<div class='clear'></div>";
248 $(".ap-st-st-4").attr("checked",true);
249 $(".ap-st-st-5").html(checkBox);
253 var resultTranslated = js_xl("Something went wrong");
254 alert(resultTranslated.msg);
260 var send_to = $('input:radio[name="send_to"]:checked').val();
261 var cover_letter = 0;
262 if($("#include_coverletter").is(":checked")) cover_letter = 1;
263 $('.activity_indicator').css({
266 $("#downloadccda").val('');
267 $("#downloadccr").val('');
268 $("#downloadccd").val('');
270 $(".check_component1").each(function(){
271 if($(this).is(":checked")){
274 comp += $(this).val();
277 if(send_to == "printer" || send_to == "fax"){
279 formnames_title = "";
281 $(".check_component").each(function(){
282 if($(this).is(":checked")){
286 formnames_title +="***";
288 formnames += $(this).val();
289 formnames_title += $(this).attr("ref");
292 if(send_to == "printer"){
294 url += "covering_letter="+cover_letter+"&selected_cform="+$("#selected_cform").val();
295 url += "&formnames="+formnames+"&formnames_title="+formnames_title;
296 window.open(WEB_ROOT+"/interface/patient_file/encounter/print_report.php?"+url,"Print",'width=1000,height=800,resizable=yes,scrollbars=yes');
297 $('.ap-st-st-12').fadeToggle();
298 $('.activity_indicator').css({"display" :"none"});
300 if(send_to == "fax"){
303 url : APP_URL+"/application/sendto/ajax",
306 ajax_mode : 'send_fax',
308 attentionto : $("#attention_to").val(),
309 selectedforms : formnames,
310 form_sel_title:formnames_title,
311 selected_cform : $("#selected_cform").val(),
312 covering_letter : $("#include_coverletter").val(),
313 visit_duration : $("#include_visitduration").val(),
314 fax_no : $('#fax_no').val()
317 success: function(data){
318 $('.activity_indicator').css({"display" :"none"});
321 var resultTranslated = js_xl("Fax sending failed");
322 alert(resultTranslated.msg);
323 $('.activity_indicator').css({"display" :"none"});
328 else if(send_to == "hie"){
329 var str = ''; var combination = '';
330 components = document.getElementsByName('ccda');
331 for(i=0 ; i<components.length ; i++){
332 if(components[i].checked){
334 str += components[i].value;
338 if(document.getElementById('ccda_pid')){
339 combination = document.getElementById('ccda_pid').value;
342 pid_encounter = document.getElementsByName('ccda_pid[]');
343 for(i=0 ; i<pid_encounter.length ; i++){
344 if(pid_encounter[i].checked){
345 if(combination) combination += '|';
346 combination += pid_encounter[i].value;
350 if(combination == ''){
351 $('.ap-st-st-12').fadeToggle();
352 $('.activity_indicator').css({"display" :"none"});
353 var resultTranslated = js_xl("Please select atleast one patient.");
354 alert(resultTranslated.msg);
360 url : APP_URL+"/encounterccdadispatch/index?combination="+combination+"§ions="+str+"&send=1&recipient=hie&components="+comp,
364 success: function(thedata){
365 $('.ap-st-st-12').fadeToggle();
366 $('.activity_indicator').css({"display" :"none"});
367 var resultTranslated = js_xl('Successfully Sent');
368 alert(resultTranslated.msg);
371 $('.activity_indicator').css({"display" :"none"});
372 var resultTranslated = js_xl("Send To HIE failed");
373 alert(resultTranslated.msg);
378 else if(send_to == "download"){
379 $('.activity_indicator').css({"display" :"none"});
380 obj = document.getElementsByName('download_format');
382 for(i=0 ; i<obj.length ; i++){
383 if (obj[i].disabled == false && obj[i].checked == true) {
388 var resultTranslated = js_xl("Please select a format");
389 alert(resultTranslated.msg);
392 $('#hl7button').trigger('click');
394 else if(send_to == "emr_direct") {
395 format = $('input:radio[name="phimail_format"]:checked').val();
398 if($("#ccda_pid").val()){
399 combination = $("#ccda_pid").val();
402 pid_encounter = document.getElementsByName('ccda_pid[]');
403 for(i=0 ; i<pid_encounter.length ; i++){
404 if(pid_encounter[i].checked){
405 if(combination) combination += '|';
406 combination += pid_encounter[i].value;
410 if(combination == ''){
411 $('.ap-st-st-12').fadeOut();
412 $('.activity_indicator').css({"display" :"none"});
413 var resultTranslated = js_xl("Please select atleast one patient.");
414 alert(resultTranslated.msg);
417 $(".chkbx_cmps").each(function(){
418 if($(this).is(":checked")){
420 if(components) components +="|";
421 components += $(this).val();
424 recipients = $(".emr_to_phimail").val();
425 var referral_reason = $("#referral_reason").val();
426 if(recipients != '') {
429 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,
436 url : APP_URL+"/encountermanager/transmitCCD?combination="+combination+"&recipients="+recipients+"&xml_type="+format,
440 success: function(thedata){
441 $('.ap-st-st-12').fadeOut();
442 $('.activity_indicator').css({"display" :"none"});
443 var resultTranslated = js_xl(thedata);
444 alert(resultTranslated.msg);
447 $('.ap-st-st-12').fadeOut();
448 $('.activity_indicator').css({"display" :"none"});
449 var resultTranslated = js_xl("Failed to send");
450 alert(resultTranslated.msg);
455 $('.activity_indicator').css({"display" :"none"});
456 var resultTranslated = js_xl("Please Specify Atleast One Direct Address");
457 alert(resultTranslated.msg);
460 else if(send_to == "download_all") {
462 if($('#ccda_pid').val()) {
463 pids = $('#ccda_pid').val();
464 pids = pids.split("_");
469 pids = document.getElementsByName('ccda_pid[]');
470 for(i=0 ; i<pids.length ; i++){
478 $('.ap-st-st-12').fadeOut();
479 $('.activity_indicator').css({"display" :"none"});
480 var resultTranslated = js_xl("Please select atleast one patient.");
481 alert(resultTranslated.msg);
485 var download_format = $('input:radio[name="downloadformat"]:checked').val();
486 if(download_format == 'ccda') {
487 if($('#ccda_pid').val()) {
488 window.location.assign(WEB_ROOT+"/interface/modules/zend_modules/public/encountermanager/index?pid_ccda="+pid+"&downloadccda=download_ccda&components="+comp);
491 $('#components').val(comp);
492 $('#download_ccda').trigger("click");
493 $(".check_pid").prop("checked",false);
496 else if(download_format == 'ccr') {
497 if($('#ccda_pid').val()) {
498 window.location.assign(WEB_ROOT+"/interface/modules/zend_modules/public/encountermanager/index?pid_ccr="+pid+"&downloadccr=download_ccr");
501 $('#download_ccr').trigger("click");
502 $(".check_pid").prop("checked",false);
505 else if(download_format == 'ccd') {
506 if($('#ccda_pid').val()) {
507 window.location.assign(WEB_ROOT+"/interface/modules/zend_modules/public/encountermanager/index?pid_ccd="+pid+"&downloadccd=download_ccd");
510 $('#download_ccd').trigger("click");
511 $(".check_pid").prop("checked",false);
514 //$(".check_pid").prop("checked",false);
515 $('.ap-st-st-12').fadeOut();
516 $('.activity_indicator').css({"display" :"none"});