2 * Copyright (C) 2016 Kevin Yeh <kevin.y@integralemr.com>
4 * LICENSE: This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 3
7 * of the License, or (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
16 * @author Kevin Yeh <kevin.y@integralemr.com>
17 * @link http://www.open-emr.org
21 targets['Calendar']='lst';
22 targets['Flow Board']='lst';
23 targets['Messages ']='pat';
24 targets['Administration']='adm';
25 targets['Reports']='rep';
26 targets['Miscellaneous']='msc';
28 targets['Patients']='lst';
33 //Billing Menu Restrictions
34 acl_reqs['EDI History']=['acct','eob'];
35 global_reqs['EDI History']='enable_edihistory_in_left_menu'
37 // Administration Menu restrictions
38 acl_reqs['Globals']=['admin','super'];
39 acl_reqs['Facilities']=['admin','users'];
40 acl_reqs['Users']=['admin','users'];
41 acl_reqs['Addr Book']=['admin','practice'];
42 acl_reqs['Practice']=['admin','practice'];
43 acl_reqs['Codes']=['admin','superbill'];
44 acl_reqs['Layouts']=['admin','super'];
45 acl_reqs['Lists']=['admin','super'];
46 acl_reqs['ACL']=['admin','acl'];
47 acl_reqs['Files']=['admin','super'];
48 acl_reqs['Backup']=['admin','super'];
51 acl_reqs['Rules']=['admin','super'];
52 global_reqs['Rules']='enable_cdr'
54 acl_reqs['Alerts']=['admin','super'];
55 global_reqs['Alerts']='enable_cdr'
57 acl_reqs['Patient Reminders']=['admin','super'];
58 global_reqs['Patient Reminders']='enable_cdr'
61 acl_reqs['Language']=['admin','language'];
62 acl_reqs['Forms']=['admin','forms'];
64 acl_reqs['Calendar']=['admin','calendar','main/calendar/index.php?module=PostCalendar&type=admin&func=modifyconfig']
66 acl_reqs['Logs']=['admin','users'];
69 acl_reqs['Database']=['admin','database'];
70 global_reqs['Database']="!disable_phpmyadmin_link";
72 acl_reqs['Certificates']=['admin','users'];
74 acl_reqs['Native Data Loads']=['admin','super'];
75 acl_reqs['External Data Loads']=['admin','super'];
76 acl_reqs['Merge Patient']=['admin','super'];
78 global_reqs['Fax/Scan']=['enable_hylafax','enable_scanner'];
81 function set_acl_reqs(entry)
85 if(entry.label in acl_reqs)
87 var reqs=acl_reqs[entry.label];
90 if(entry.url.indexOf(reqs[2])!==-1)
92 entry.acl_req=[reqs[0],reqs[1]];
97 entry.acl_req=acl_reqs[entry.label];
100 if(entry.label in global_reqs)
102 entry.global_req=global_reqs[entry.label];
107 function setTarget(entry,target)
115 for(var idx=0;idx<entry.children.length;idx++)
117 setTarget(entry.children[idx],target);
121 function post_process(menu_entries)
123 for(var idx=0;idx<menu_entries.length;idx++)
125 var curEntry=menu_entries[idx];
126 set_acl_reqs(curEntry);
127 if(curEntry.label in targets)
129 setTarget(curEntry,targets[curEntry.label]);
131 post_process(curEntry.children);
134 function parse_link(link,entry)
138 var parameters=link.substring(link.indexOf('(')+1,link.indexOf(')'));
143 if(link.indexOf("loadFrame2")===-1)
145 var url=parameters.replace(/\'/g,"").replace(/\"/g,"").replace("../","/interface/");
147 entry.target="report";
151 parameters=parameters.replace(/\'/g,"").replace(/\"/g,"");
152 var params=parameters.split(",");
153 entry.target=params[1];
154 if(entry.target==='RTop')
158 if(entry.target==='RBot')
164 entry.url=params[2].replace("../","/");
165 if(entry.url.indexOf("/")>0)
167 entry.url="/interface/"+entry.url;
174 function menu_entry(label,link,menu_id)
178 self.menu_id=menu_id;
179 parse_link(link,self);
182 self.helperText=helperText;
186 if(menu_id.charAt(3)==='1')
188 if(self.label==='Summary')
198 if(menu_id.charAt(3)==='2')
202 // Special case for "Current" visit entry
203 if(self.label==="Current")
214 function menu_entry_from_jq(elem)
216 return new menu_entry(elem.text(),elem.attr("onClick"),elem.attr("id"));
219 function analyze_menu()
221 alert('I think you will never see this. --Rod'); // debugging
225 setTimeout(analyze_menu,1000);
233 setTimeout(analyze_menu,1000);
237 var jqLeft=top.left_nav.$(top.left_nav.document)
238 var $=top.left_nav.$;
239 jqLeft.ready(function(){
241 var menuTop=jqLeft.find("#navigation-slide");
242 menuTop.children().each(
247 var anchor=jqElem.children("a");
248 var subMenu = jqElem.children("ul");
250 var newEntry=menu_entry_from_jq(anchor);
253 // 2 (Second) level menu items
254 subMenu.children("li").each(function(idx,elem)
256 var sub_anchor=$(elem).children("a");
257 var sub_entry=menu_entry_from_jq(sub_anchor);
258 if(sub_anchor.length!==1)
260 alert(sub_anchor.text());
262 var subSubMenu=$(elem).children("ul");
263 //Third Level Menu Items
264 if(subSubMenu.length>0 && sub_entry.label !=="Visit Forms")
266 subSubMenu.children("li").each(function(idx,elem)
268 var sub_sub_anchor=$(elem).children("a");
269 var sub_sub_entry=menu_entry_from_jq(sub_sub_anchor);
270 sub_entry.children.push(sub_sub_entry);
275 //End Third Level Menu Items
276 newEntry.children.push(sub_entry);
278 // End Second level menu items
285 menu_entries.push(newEntry);
291 var popups = jqLeft.find("select[name='popups'] option");
292 var popups_menu_header=new menu_entry("Popups","","popup");
293 menu_entries.push(popups_menu_header);
294 popups.each(function(idx,elem)
297 if(jqElem.val()!=='')
299 var popup_entry=new menu_entry(jqElem.text(),jqElem.val(),"Popup:"+jqElem.text());
300 popup_entry.target="pop";
301 popup_entry.requirement=1;
302 popups_menu_header.children.push(popup_entry);
307 post_process(menu_entries);
308 var data=$("<div id='#menuData'></div>");
309 data.text("$menu_json=\""+JSON.stringify(menu_entries).replace(/\"/g,"\\\"")+"\";");
310 $("body").append(data);
313 var toID=setTimeout(analyze_menu,1000);