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'];
68 acl_reqs['Certificates']=['admin','users'];
70 acl_reqs['Native Data Loads']=['admin','super'];
71 acl_reqs['External Data Loads']=['admin','super'];
72 acl_reqs['Merge Patient']=['admin','super'];
74 global_reqs['Fax/Scan']=['enable_hylafax','enable_scanner'];
77 function set_acl_reqs(entry)
81 if(entry.label in acl_reqs)
83 var reqs=acl_reqs[entry.label];
86 if(entry.url.indexOf(reqs[2])!==-1)
88 entry.acl_req=[reqs[0],reqs[1]];
93 entry.acl_req=acl_reqs[entry.label];
96 if(entry.label in global_reqs)
98 entry.global_req=global_reqs[entry.label];
103 function setTarget(entry,target)
111 for(var idx=0;idx<entry.children.length;idx++)
113 setTarget(entry.children[idx],target);
117 function post_process(menu_entries)
119 for(var idx=0;idx<menu_entries.length;idx++)
121 var curEntry=menu_entries[idx];
122 set_acl_reqs(curEntry);
123 if(curEntry.label in targets)
125 setTarget(curEntry,targets[curEntry.label]);
127 post_process(curEntry.children);
130 function parse_link(link,entry)
134 var parameters=link.substring(link.indexOf('(')+1,link.indexOf(')'));
139 if(link.indexOf("loadFrame2")===-1)
141 var url=parameters.replace(/\'/g,"").replace(/\"/g,"").replace("../","/interface/");
143 entry.target="report";
147 parameters=parameters.replace(/\'/g,"").replace(/\"/g,"");
148 var params=parameters.split(",");
149 entry.target=params[1];
150 if(entry.target==='RTop')
154 if(entry.target==='RBot')
160 entry.url=params[2].replace("../","/");
161 if(entry.url.indexOf("/")>0)
163 entry.url="/interface/"+entry.url;
170 function menu_entry(label,link,menu_id)
174 self.menu_id=menu_id;
175 parse_link(link,self);
178 self.helperText=helperText;
182 if(menu_id.charAt(3)==='1')
184 if(self.label==='Summary')
194 if(menu_id.charAt(3)==='2')
198 // Special case for "Current" visit entry
199 if(self.label==="Current")
210 function menu_entry_from_jq(elem)
212 return new menu_entry(elem.text(),elem.attr("onClick"),elem.attr("id"));
215 function analyze_menu()
217 alert('I think you will never see this. --Rod'); // debugging
221 setTimeout(analyze_menu,1000);
229 setTimeout(analyze_menu,1000);
233 var jqLeft=top.left_nav.$(top.left_nav.document)
234 var $=top.left_nav.$;
235 jqLeft.ready(function(){
237 var menuTop=jqLeft.find("#navigation-slide");
238 menuTop.children().each(
243 var anchor=jqElem.children("a");
244 var subMenu = jqElem.children("ul");
246 var newEntry=menu_entry_from_jq(anchor);
249 // 2 (Second) level menu items
250 subMenu.children("li").each(function(idx,elem)
252 var sub_anchor=$(elem).children("a");
253 var sub_entry=menu_entry_from_jq(sub_anchor);
254 if(sub_anchor.length!==1)
256 alert(sub_anchor.text());
258 var subSubMenu=$(elem).children("ul");
259 //Third Level Menu Items
260 if(subSubMenu.length>0 && sub_entry.label !=="Visit Forms")
262 subSubMenu.children("li").each(function(idx,elem)
264 var sub_sub_anchor=$(elem).children("a");
265 var sub_sub_entry=menu_entry_from_jq(sub_sub_anchor);
266 sub_entry.children.push(sub_sub_entry);
271 //End Third Level Menu Items
272 newEntry.children.push(sub_entry);
274 // End Second level menu items
281 menu_entries.push(newEntry);
287 var popups = jqLeft.find("select[name='popups'] option");
288 var popups_menu_header=new menu_entry("Popups","","popup");
289 menu_entries.push(popups_menu_header);
290 popups.each(function(idx,elem)
293 if(jqElem.val()!=='')
295 var popup_entry=new menu_entry(jqElem.text(),jqElem.val(),"Popup:"+jqElem.text());
296 popup_entry.target="pop";
297 popup_entry.requirement=1;
298 popups_menu_header.children.push(popup_entry);
303 post_process(menu_entries);
304 var data=$("<div id='#menuData'></div>");
305 data.text("$menu_json=\""+JSON.stringify(menu_entries).replace(/\"/g,"\\\"")+"\";");
306 $("body").append(data);
309 var toID=setTimeout(analyze_menu,1000);