more fixes for new frame layout
[openemr.git] / interface / main / left_nav.php
blob77f48325756cad53e95bb64ea244cc68298ba745
1 <?php
2 // Copyright (C) 2006 Rod Roark <rod@sunsetsystems.com>
3 //
4 // 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 2
7 // of the License, or (at your option) any later version.
9 // This provides the left navigation frame when $GLOBALS['concurrent_layout']
10 // is true. Following are notes as to what else was changed for this feature:
12 // * interface/main/main_screen.php: the top-level frameset.
13 // * interface/main/finder/patient_select.php: loads stuff when a new patient
14 // is selected.
15 // * interface/patient_file/summary/demographics.php: this is the first frame
16 // loaded when a new patient is chosen, and in turn sets the current pid and
17 // then loads the initial bottom frame.
18 // * interface/patient_file/summary/demographics_full.php: added support for
19 // setting a new pid, needed for going to demographics from billing.
20 // * interface/patient_file/summary/demographics_save.php: redisplay
21 // demographics.php and not the frameset.
22 // * interface/patient_file/summary/summary_bottom.php: new frameset for the
23 // summary, prescriptions and notes for a selected patient, cloned from
24 // patient_summary.php.
25 // * interface/patient_file/encounter/encounter_bottom.php: new frameset for
26 // the selected encounter, mosting coding/billing stuff, cloned from
27 // patient_encounter.php. This will also self-load the superbill pages
28 // as requested.
29 // * interface/usergroup/user_info.php: removed Back link.
30 // * interface/usergroup/admin_frameset.php: new frameset for Admin pages,
31 // cloned from usergroup.php.
32 // * interface/main/onotes/office_comments.php: removed Back link target.
33 // * interface/main/onotes/office_comments_full.php: changed Back link.
34 // * interface/billing/billing_report.php: removed Back link; added logic
35 // to properly go to demographics or to an encounter when requested.
36 // * interface/new/new.php: removed Back link and revised form target.
37 // * interface/new/new_patient_save.php: modified to load the demographics
38 // page to the current frame instead of loading a new frameset.
39 // * interface/patient_file/history/history.php: target change.
40 // * interface/patient_file/history/history_full.php: target changes.
41 // * interface/patient_file/history/history_save.php: target change.
42 // * interface/patient_file/history/encounters.php: link/target changes.
43 // * interface/patient_file/history/encounters_full.php: link/target changes.
44 // * interface/patient_file/encounter/encounter_top.php: another new frameset
45 // cloned from patient_encounter.php.
46 // * interface/patient_file/encounter/forms.php: link target removal.
47 // * interface/patient_file/encounter/new_form.php: target change.
48 // * interface/forms/newpatient/new.php, view.php, save.php: link/target
49 // changes.
50 // * interface/patient_file/summary/immunizations.php: removed back link.
51 // * interface/patient_file/summary/pnotes.php: changed link targets.
52 // * interface/patient_file/summary/pnotes_full.php: changed back link and
53 // added set_pid logic.
54 // * interface/patient_file/transaction/transactions.php: various changes.
55 // * interface/patient_file/transaction/add_transaction.php: new return js.
56 // * interface/patient_file/encounter/superbill_codes.php: target and link
57 // changes.
58 // * interface/patient_file/encounter/superbill_custom_full.php: target and
59 // link changes.
60 // * interface/patient_file/encounter/diagnosis.php: target changes.
61 // * interface/patient_file/encounter/diagnosis_full.php: target and link
62 // changes.
63 // * interface/main/authorizations/authorizations.php: link and target changes.
64 // * library/api.inc: url change.
65 // * interface/patient_file/summary/rx_frameset.php: new frameset.
66 // * interface/patient_file/summary/rx_left.php: new for prescriptions.
67 // * all encounter forms: remove all instances of "target=Main" and change
68 // all instances of "patient_encounter.php" to "encounter_top.php".
70 // Our find_patient form, when submitted, invokes patient_select.php in the
71 // upper frame. When the patient is selected, demographics.php is invoked
72 // with the set_pid parameter, which establishes the new session pid and also
73 // calls the setPatient() function (below). In this case demographics.php
74 // will also load the summary frameset into the bottom frame, invoking our
75 // loadFrame() and setRadio() functions.
77 // Similarly, we have the concept of selecting an encounter from the
78 // Encounters list, and then having that "stick" until some other encounter
79 // or a new encounter is chosen. We also have a navigation item for creating
80 // a new encounter. interface/patient_file/encounter/encounter_top.php
81 // supports set_encounter to establish an encounter.
83 // TBD: Include active_pid and/or active_encounter in relevant submitted
84 // form data, and add logic to the save routines to make sure they match
85 // the corresponding session values.
87 include_once("../globals.php");
88 include_once("../../library/acl.inc");
90 // This array defines the list of primary documents that may be
91 // chosen. Each element value is an array of 3 values:
93 // * Name to appear in the navigation table
94 // * Usage: 0 = global, 1 = patient-specific, 2 = encounter-specific
95 // * The URL relative to the interface directory
97 $primary_docs = array(
98 'ros' => array('Roster' , 0, 'reports/players_report.php?embed=1'),
99 'cal' => array('Calendar' , 0, 'main/main_info.php'),
100 'pwd' => array('Password' , 0, 'usergroup/user_info.php'),
101 'adm' => array('Admin' , 0, 'usergroup/admin_frameset.php'),
102 'rep' => array('Reports' , 0, 'reports/index.php'),
103 'ono' => array('Ofc Notes' , 0, 'main/onotes/office_comments.php'),
104 'fax' => array('Fax/Scan' , 0, 'fax/faxq.php'),
105 'adb' => array('Addr Bk' , 0, 'usergroup/addrbook_list.php'),
106 'bil' => array('Billing' , 0, 'billing/billing_report.php'),
107 'sup' => array('Superbill' , 0, 'patient_file/encounter/superbill_custom_full.php'),
108 'aun' => array('Auth/notes', 0, 'main/authorizations/authorizations.php'),
109 'new' => array('New Pt' , 0, 'new/new.php'),
110 'dem' => array('Patient' , 1, 'patient_file/summary/demographics.php'),
111 'his' => array('History' , 1, 'patient_file/history/history.php'),
112 'ens' => array('Encounters', 1, 'patient_file/history/encounters.php'),
113 'nen' => array('New Enctr' , 1, 'forms/newpatient/new.php?autoloaded=1&calenc='),
114 'pre' => array('Rx' , 1, 'patient_file/summary/rx_frameset.php'),
115 'iss' => array('Issues' , 1, 'patient_file/summary/stats_full.php?active=all'),
116 'imm' => array('Immunize' , 1, 'patient_file/summary/immunizations.php'),
117 'doc' => array('Documents' , 1, '../controller.php?document&list&patient_id={PID}'),
118 'prp' => array('Pt Report' , 1, 'patient_file/report/patient_report.php'),
119 'pno' => array('Pt Notes' , 1, 'patient_file/summary/pnotes.php'),
120 'tra' => array('Transact' , 1, 'patient_file/transaction/transactions.php'),
121 'sum' => array('Summary' , 1, 'patient_file/summary/summary_bottom.php'),
122 'enc' => array('Encounter' , 2, 'patient_file/encounter/encounter_top.php'),
123 'cod' => array('Charges' , 2, 'patient_file/encounter/encounter_bottom.php'),
126 // This section decides which navigation items will not appear.
128 $disallowed = array();
130 $disallowed['adm'] = !(acl_check('admin', 'calendar') ||
131 acl_check('admin', 'database') || acl_check('admin', 'forms') ||
132 acl_check('admin', 'practice') || acl_check('admin', 'users'));
134 $disallowed['bil'] = !(acl_check('acct', 'rep') || acl_check('acct', 'eob') ||
135 acl_check('acct', 'bill'));
137 $tmp = acl_check('patients', 'demo');
138 $disallowed['new'] = !($tmp == 'write' || $tmp == 'addonly');
140 $disallowed['fax'] = !($GLOBALS['hylafax_server'] || $GLOBALS['scanner_output_directory']);
142 $disallowed['ros'] = !$GLOBALS['athletic_team'];
144 $disallowed['iss'] = !((acl_check('encounters', 'notes') == 'write' ||
145 acl_check('encounters', 'notes_a') == 'write') &&
146 acl_check('patients', 'med') == 'write');
148 <html>
149 <head>
150 <title>Navigation</title>
151 <link rel=stylesheet href="<?echo $css_header;?>" type="text/css">
153 <style type="text/css">
154 body {
155 font-family:sans-serif;
156 font-size:8pt;
157 font-weight:normal;
158 padding: 5px 3px 5px 3px;
160 .smalltext {
161 font-family:sans-serif;
162 font-size:8pt;
163 font-weight:normal;
165 a.navitem, a.navitem:visited {
166 color:#0000ff;
167 font-family:sans-serif;
168 font-size:8pt;
169 font-weight:bold;
171 .inputtext {
172 font-size:9pt;
173 font-weight:normal;
174 border-style:solid;
175 border-width:1px;
176 padding-left:2px;
177 padding-right:2px;
178 border-color: #000000;
179 background-color:transparent;
181 </style>
183 <script type="text/javascript" src="../../library/dialog.js"></script>
185 <script language='JavaScript'>
187 // Master values for current pid and encounter.
188 var active_pid = 0;
189 var active_encounter = 0;
191 // Expand and/or collapse frames in response to checkbox clicks.
192 // fnum indicates which checkbox was clicked (1=left, 2=right).
193 function toggleFrame(fnum) {
194 var f = document.forms[0];
195 var fset = top.document.getElementById('fsright');
196 if (!f.cb_top.checked && !f.cb_bot.checked) {
197 if (fnum == 1) f.cb_bot.checked = true;
198 else f.cb_top.checked = true;
200 var rows = f.cb_top.checked ? '*' : '0';
201 rows += f.cb_bot.checked ? ',*' : ',0';
202 fset.rows = rows;
203 fset.rows = rows;
206 // Load the specified url into the specified frame (RTop or RBot).
207 // The URL provided must be relative to interface.
208 function loadFrame(frame, url) {
209 var i = url.indexOf('{PID}');
210 if (i >= 0) url = url.substring(0,i) + active_pid + url.substring(i+5);
211 top.frames[frame].location = '<?php echo "$web_root/interface/" ?>' + url;
214 // Select a designated radio button. raname may be either the radio button
215 // array name (rb_top or rb_bot), or the frame name (RTop or RBot).
216 // You should call this if you directly load a document that does not
217 // correspond to the current radio button setting.
218 function setRadio(raname, rbid) {
219 var f = document.forms[0];
220 if (raname == 'RTop') raname = 'rb_top';
221 if (raname == 'RBot') raname = 'rb_bot';
222 for (var i = 0; i < f[raname].length; ++i) {
223 if (f[raname][i].value.substring(0,3) == rbid) {
224 f[raname][i].checked = true;
225 return true;
228 return false;
231 // Set disabled/enabled state of radio buttons and associated labels
232 // depending on whether there is an active patient or encounter.
233 function syncRadios() {
234 var f = document.forms[0];
235 for (var i = 0; i < f.rb_top.length; ++i) {
236 var da = false;
237 var rb1 = f.rb_top[i];
238 var rb2 = f.rb_bot[i];
239 var rbid = rb1.value.substring(0,3);
240 var usage = rb1.value.substring(3);
241 if (active_pid == 0 && usage > '0') da = true;
242 if (active_encounter == 0 && usage > '1') da = true;
243 // daemon_frame can also set special label colors, so don't mess with
244 // them unless we have to.
245 if (rb1.disabled != da) {
246 rb1.disabled = da;
247 rb2.disabled = da;
248 document.getElementById('lbl_' + rbid).style.color = da ? '#888888' : '#000000';
251 f.popups.disabled = (active_pid == 0);
254 // Process the click to find a patient by name, id, ssn or dob.
255 function findPatient(findby) {
256 var f = document.forms[0];
257 if (! f.cb_top.checked) {
258 f.cb_top.checked = true;
259 toggleFrame(1);
261 f.findBy.value = findby;
262 setRadio('rb_top', 'dem');
263 document.find_patient.submit();
266 // Helper function to set the contents of a div.
267 function setDivContent(id, content) {
268 if (document.getElementById) {
269 var x = document.getElementById(id);
270 x.innerHTML = '';
271 x.innerHTML = content;
273 else if (document.all) {
274 var x = document.all[id];
275 x.innerHTML = content;
279 // This is called automatically when a new patient is set, to make sure
280 // there are no patient-specific documents showing stale data. If a frame
281 // was just loaded with data for the correct patient, its name is passed so
282 // that it will not be zapped. At this point the new server-side pid is not
283 // assumed to be set, so this function will only load global data.
284 function reloadPatient(frname) {
285 var f = document.forms[0];
286 for (var i = 0; i < f.rb_top.length; ++i) {
287 if (f.rb_top[i].value.substring(3) > '0') {
288 if (frname != 'RTop' && f.rb_top[i].checked) {
289 loadFrame('RTop', '<?php echo $primary_docs['cal'][2]; ?>');
290 setRadio('rb_top', 'cal');
292 if (frname != 'RBot' && f.rb_bot[i].checked) {
293 loadFrame('RBot', '<?php echo $primary_docs['aun'][2]; ?>');
294 setRadio('rb_bot', 'aun');
300 // Reload encounter-specific frames, excluding a specified frame. At this
301 // point the new server-side encounter ID may not be set and loading the same
302 // document for the new encounter will not work, so load patient info instead.
303 function reloadEncounter(frname) {
304 var f = document.forms[0];
305 for (var i = 0; i < f.rb_top.length; ++i) {
306 if (f.rb_top[i].value.substring(3) > '1') {
307 if (frname != 'RTop' && f.rb_top[i].checked) {
308 loadFrame('RTop', '<?php echo $primary_docs['dem'][2]; ?>');
309 setRadio('rb_top', 'dem');
311 if (frname != 'RBot' && f.rb_bot[i].checked) {
312 loadFrame('RBot', '<?php echo $primary_docs['ens'][2]; ?>');
313 setRadio('rb_bot', 'ens');
319 // Call this to announce that the patient has changed. You must call this
320 // if you change the session PID, so that the navigation frame will show the
321 // correct patient and so that the other frame will be reloaded if it contains
322 // patient-specific information from the previous patient. frname is the name
323 // of the frame that the call came from, so we know to only reload content
324 // from the *other* frame if it is patient-specific.
325 function setPatient(pname, pid, frname) {
326 if (pid == active_pid) return;
327 var str = '<b>' + pname + ' (' + pid + ')</b>';
328 setDivContent('current_patient', str);
329 setDivContent('current_encounter', '<b>None</b>');
330 active_pid = pid;
331 active_encounter = 0;
332 if (frname) reloadPatient(frname);
333 syncRadios();
336 // Call this to announce that the encounter has changed. You must call this
337 // if you change the session encounter, so that the navigation frame will
338 // show the correct encounter and so that the other frame will be reloaded if
339 // it contains encounter-specific information from the previous encounter.
340 // frname is the name of the frame that the call came from, so we know to only
341 // reload encounter-specific content from the *other* frame.
342 function setEncounter(edate, eid, frname) {
343 if (eid == active_encounter) return;
344 if (!eid) edate = 'None';
345 var str = '<b>' + edate + '</b>';
346 setDivContent('current_encounter', str);
347 active_encounter = eid;
348 reloadEncounter(frname);
349 syncRadios();
352 // You must call this if you delete the active patient (or if for any other
353 // reason you "close" the active patient without opening a new one), so that
354 // the appearance of the navigation frame will be correct and so that any
355 // stale content will be reloaded.
356 function clearPatient() {
357 if (active_pid == 0) return;
358 var f = document.forms[0];
359 active_pid = 0;
360 active_encounter = 0;
361 setDivContent('current_encounter', '<b>None</b>');
362 setDivContent('current_patient', '<b>None</b>');
363 reloadPatient('');
364 syncRadios();
367 // You must call this if you delete the active encounter (or if for any other
368 // reason you "close" the active encounter without opening a new one), so that
369 // the appearance of the navigation frame will be correct and so that any
370 // stale content will be reloaded.
371 function clearEncounter() {
372 if (active_encounter == 0) return;
373 setDivContent('current_encounter', '<b>None</b>');
374 active_encounter = 0;
375 reloadEncounter('');
376 syncRadios();
379 // You can call this to make sure the session pid is what we expect.
380 function pidSanityCheck(pid) {
381 if (pid != active_pid) {
382 alert('Session patient ID is ' + pid + ', expecting ' + active_pid +
383 '. This session is unstable and should be abandoned. Do not use ' +
384 'OpenEMR in multiple browser windows!');
385 return false;
387 return true;
390 // You can call this to make sure the session encounter is what we expect.
391 function encounterSanityCheck(eid) {
392 if (eid != active_encounter) {
393 alert('Session encounter ID is ' + eid + ', expecting ' + active_encounter +
394 '. This session is unstable and should be abandoned. Do not use ' +
395 'OpenEMR in multiple browser windows!');
396 return false;
398 return true;
401 // This is invoked to pop up some window when a popup item is selected.
402 function selpopup(selobj) {
403 var i = selobj.selectedIndex;
404 var opt = selobj.options[i];
405 if (i > 0) {
406 var width = 750;
407 var height = 550;
408 if (opt.text == 'Export' || opt.text == 'Import') {
409 width = 500;
410 height = 400;
412 else if (opt.text == 'Refer') {
413 width = 700;
414 height = 500;
416 dlgopen(opt.value, '_blank', width, height);
418 selobj.selectedIndex = 0;
421 </script>
423 </head>
425 <body <?echo $nav_bg_line;?> topmargin='0' rightmargin='4' leftmargin='2'
426 bottommargin='0' marginheight='0'>
428 <form method='post' name='find_patient' target='RTop'
429 action='<?php echo $rootdir ?>/main/finder/patient_select.php'>
431 <table cellpadding='0' cellspacing='0' border='0'>
432 <tr>
433 <td colspan='3'>
434 <table cellpadding='0' cellspacing='0' border='0' width='100%'>
435 <tr>
436 <td class='smalltext' nowrap>
437 <input type='checkbox' name='cb_top' onclick='toggleFrame(1)' checked /><b>Top</b>
438 </td>
439 <td class='smalltext' align='right' nowrap>
440 <b>Bot</b><input type='checkbox' name='cb_bot' onclick='toggleFrame(2)' checked />
441 </td>
442 </tr>
443 </table>
444 </td>
445 </tr>
446 <?php
447 // Builds the table of radio buttons and their labels. Radio button values
448 // are comprised of the 3-character document id and the 1-digit usage type,
449 // so that JavaScript can easily access this information.
450 $default_top_rbid = $GLOBALS['athletic_team'] ? 'ros' : 'cal';
451 foreach ($primary_docs as $key => $varr) {
452 if ($disallowed[$key]) continue;
453 $label = $varr[0];
454 $usage = $varr[1];
455 $url = $varr[2];
456 echo " <tr>\n";
457 echo " <td class='smalltext'><input type='radio' name='rb_top' value='$key$usage' " .
458 "onclick=\"loadFrame('RTop','$url')\"";
459 if ($key == $default_top_rbid) echo " checked";
460 echo " /></td>\n";
461 echo " <td class='smalltext' id='lbl_$key'>$label</td>\n";
462 echo " <td class='smalltext'><input type='radio' name='rb_bot' value='$key$usage' " .
463 "onclick=\"loadFrame('RBot','$url')\"";
464 if ($key == 'aun') echo " checked";
465 echo " /></td>\n";
466 echo " </tr>\n";
469 </table>
471 <br /><hr />
473 Active Patient:<br />
474 <div id='current_patient'>
475 <b>None</b>
476 </div>
478 Active Encounter:<br />
479 <div id='current_encounter'>
480 <b>None</b>
481 </div>
483 <select name='popups' onchange='selpopup(this)'
484 style='background-color:transparent;font-size:9pt;'>
485 <option value=''><? xl('Popups','e'); ?></option>
486 <?php if (!$disallowed['iss']) { ?>
487 <option value='../patient_file/problem_encounter.php'><? xl('Issues','e'); ?></option>
488 <?php } ?>
489 <option value='../../custom/export_xml.php'><? xl('Export','e'); ?></option>
490 <option value='../../custom/import_xml.php'><? xl('Import','e'); ?></option>
491 <?php if ($GLOBALS['athletic_team']) { ?>
492 <option value='../reports/players_report.php'><? xl('Roster','e'); ?></option>
493 <?php } ?>
494 <option value='../reports/appointments_report.php?patient=<?php echo $pid ?>'><? xl('Appts','e'); ?></option>
495 <?php if (file_exists("$webserver_root/custom/refer.php")) { ?>
496 <option value='../../custom/refer.php'><? xl('Refer','e'); ?></option>
497 <?php } ?>
498 <?php if ($GLOBALS['inhouse_pharmacy']) { ?>
499 <option value='../patient_file/pos_checkout.php'><? xl('Payment','e'); ?></option>
500 <?php } else { ?>
501 <option value='../patient_file/front_payment.php'><? xl('Payment','e'); ?></option>
502 <?php } ?>
503 </select>
505 <hr />
507 <table cellpadding='0' cellspacing='0' border='0'>
508 <tr>
509 <td class='smalltext'>Find:&nbsp;</td>
510 <td class='smalltext' colspan='2'>
511 <input type="entry" size="7" name="patient" class='inputtext' style='width:65px;' />
512 </td>
513 </tr>
514 <tr>
515 <td class='smalltext'>by:</td>
516 <td class='smalltext'>
517 <a href="javascript:findPatient('Last');" class="navitem">Name</a>
518 </td>
519 <td class='smalltext' align='right'>
520 <a href="javascript:findPatient('ID');" class="navitem">ID</a>
521 </td>
522 </tr>
523 <tr>
524 <td class='smalltext'>&nbsp;</td>
525 <td class='smalltext'>
526 <a href="javascript:findPatient('SSN');" class="navitem">SSN</a>
527 </td>
528 <td class='smalltext' align='right'>
529 <a href="javascript:findPatient('DOB');" class="navitem">DOB</a>
530 </td>
531 </tr>
532 </table>
534 <hr />
535 <a href="../logout.php?auth=logout" target="_top" class="navitem" id="logout_link">
536 <? xl('Logout','e'); ?></a>
538 <input type='hidden' name='findBy' value='Last' />
540 </form>
542 <script language='JavaScript'>
543 syncRadios();
544 </script>
546 </body>
547 </html>