2 // Copyright (C) 2006 Rod Roark <rod@sunsetsystems.com>
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
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
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
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
58 // * interface/patient_file/encounter/superbill_custom_full.php: target and
60 // * interface/patient_file/encounter/diagnosis.php: target changes.
61 // * interface/patient_file/encounter/diagnosis_full.php: target and link
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 'imp' => array('Import' , 0, '../custom/import.php'),
107 'bil' => array('Billing' , 0, 'billing/billing_report.php'),
108 'sup' => array('Superbill' , 0, 'patient_file/encounter/superbill_custom_full.php'),
109 'aun' => array('Auth/notes', 0, 'main/authorizations/authorizations.php'),
110 'new' => array('New Pt' , 0, 'new/new.php'),
111 'dem' => array('Patient' , 1, 'patient_file/summary/demographics.php'),
112 'his' => array('History' , 1, 'patient_file/history/history.php'),
113 'ens' => array('Encounters', 1, 'patient_file/history/encounters.php'),
114 'nen' => array('New Enctr' , 1, 'forms/newpatient/new.php?autoloaded=1&calenc='),
115 'pre' => array('Rx' , 1, 'patient_file/summary/rx_frameset.php'),
116 'iss' => array('Issues' , 1, 'patient_file/summary/stats_full.php?active=all'),
117 'imm' => array('Immunize' , 1, 'patient_file/summary/immunizations.php'),
118 'doc' => array('Documents' , 1, '../controller.php?document&list&patient_id={PID}'),
119 'prp' => array('Pt Report' , 1, 'patient_file/report/patient_report.php'),
120 'pno' => array('Pt Notes' , 1, 'patient_file/summary/pnotes.php'),
121 'tra' => array('Transact' , 1, 'patient_file/transaction/transactions.php'),
122 'sum' => array('Summary' , 1, 'patient_file/summary/summary_bottom.php'),
123 'enc' => array('Encounter' , 2, 'patient_file/encounter/encounter_top.php'),
124 'cod' => array('Charges' , 2, 'patient_file/encounter/encounter_bottom.php'),
127 // This section decides which navigation items will not appear.
129 $disallowed = array();
131 $disallowed['adm'] = !(acl_check('admin', 'calendar') ||
132 acl_check('admin', 'database') ||
acl_check('admin', 'forms') ||
133 acl_check('admin', 'practice') ||
acl_check('admin', 'users'));
135 $disallowed['bil'] = !(acl_check('acct', 'rep') ||
acl_check('acct', 'eob') ||
136 acl_check('acct', 'bill'));
138 $tmp = acl_check('patients', 'demo');
139 $disallowed['new'] = !($tmp == 'write' ||
$tmp == 'addonly');
141 if ( isset ($GLOBALS['hylafax_server']) && isset ($GLOBALS['scanner_output_directory']) ) {
142 $disallowed['fax'] = !($GLOBALS['hylafax_server'] ||
$GLOBALS['scanner_output_directory']);
145 $disallowed['ros'] = !$GLOBALS['athletic_team'];
147 $disallowed['iss'] = !((acl_check('encounters', 'notes') == 'write' ||
148 acl_check('encounters', 'notes_a') == 'write') &&
149 acl_check('patients', 'med') == 'write');
151 $disallowed['imp'] = $disallowed['new'] ||
152 !is_readable("$webserver_root/custom/import.php");
156 <title
>Navigation
</title
>
157 <link rel
=stylesheet href
="<?echo $css_header;?>" type
="text/css">
159 <style type
="text/css">
161 font
-family
:sans
-serif
;
164 padding
: 5px
3px
5px
3px
;
167 font
-family
:sans
-serif
;
171 a
.navitem
, a
.navitem
:visited
{
173 font
-family
:sans
-serif
;
184 border
-color
: #000000;
185 background
-color
:transparent
;
189 <script type
="text/javascript" src
="../../library/dialog.js"></script
>
191 <script language
='JavaScript'>
193 // Master values for current pid and encounter.
195 var active_encounter
= 0;
197 // Expand and/or collapse frames in response to checkbox clicks.
198 // fnum indicates which checkbox was clicked (1=left, 2=right).
199 function toggleFrame(fnum
) {
200 var f
= document
.forms
[0];
201 var fset
= top
.document
.getElementById('fsright');
202 if (!f
.cb_top
.checked
&& !f
.cb_bot
.checked
) {
203 if (fnum
== 1) f
.cb_bot
.checked
= true;
204 else f
.cb_top
.checked
= true;
206 var rows
= f
.cb_top
.checked ?
'*' : '0';
207 rows +
= f
.cb_bot
.checked ?
',*' : ',0';
212 // Load the specified url into the specified frame (RTop or RBot).
213 // The URL provided must be relative to interface.
214 function loadFrame(frame
, url
) {
215 var i
= url
.indexOf('{PID}');
216 if (i
>= 0) url
= url
.substring(0,i
) + active_pid + url
.substring(i+
5);
217 top
.frames
[frame
].location
= '<?php echo "$web_root/interface/" ?>' + url
;
220 // Select a designated radio button. raname may be either the radio button
221 // array name (rb_top or rb_bot), or the frame name (RTop or RBot).
222 // You should call this if you directly load a document that does not
223 // correspond to the current radio button setting.
224 function setRadio(raname
, rbid
) {
225 var f
= document
.forms
[0];
226 if (raname
== 'RTop') raname
= 'rb_top';
227 if (raname
== 'RBot') raname
= 'rb_bot';
228 for (var i
= 0; i
< f
[raname
].length
; ++i
) {
229 if (f
[raname
][i
].value
.substring(0,3) == rbid
) {
230 f
[raname
][i
].checked
= true;
237 // Set disabled/enabled state of radio buttons and associated labels
238 // depending on whether there is an active patient or encounter.
239 function syncRadios() {
240 var f
= document
.forms
[0];
241 for (var i
= 0; i
< f
.rb_top
.length
; ++i
) {
243 var rb1
= f
.rb_top
[i
];
244 var rb2
= f
.rb_bot
[i
];
245 var rbid
= rb1
.value
.substring(0,3);
246 var usage
= rb1
.value
.substring(3);
247 if (active_pid
== 0 && usage
> '0') da
= true;
248 if (active_encounter
== 0 && usage
> '1') da
= true;
249 // daemon_frame can also set special label colors, so don't mess with
250 // them unless we have to.
251 if (rb1
.disabled
!= da
) {
254 document
.getElementById('lbl_' + rbid
).style
.color
= da ?
'#888888' : '#000000';
257 f
.popups
.disabled
= (active_pid
== 0);
260 // Process the click to find a patient by name, id, ssn or dob.
261 function findPatient(findby
) {
262 var f
= document
.forms
[0];
263 if (! f
.cb_top
.checked
) {
264 f
.cb_top
.checked
= true;
267 f
.findBy
.value
= findby
;
268 setRadio('rb_top', 'dem');
269 document
.find_patient
.submit();
272 // Helper function to set the contents of a div.
273 function setDivContent(id
, content
) {
274 if (document
.getElementById
) {
275 var x
= document
.getElementById(id
);
277 x
.innerHTML
= content
;
279 else if (document
.all
) {
280 var x
= document
.all
[id
];
281 x
.innerHTML
= content
;
285 // This is called automatically when a new patient is set, to make sure
286 // there are no patient-specific documents showing stale data. If a frame
287 // was just loaded with data for the correct patient, its name is passed so
288 // that it will not be zapped. At this point the new server-side pid is not
289 // assumed to be set, so this function will only load global data.
290 function reloadPatient(frname
) {
291 var f
= document
.forms
[0];
292 for (var i
= 0; i
< f
.rb_top
.length
; ++i
) {
293 if (f
.rb_top
[i
].value
.substring(3) > '0') {
294 if (frname
!= 'RTop' && f
.rb_top
[i
].checked
) {
295 loadFrame('RTop', '<?php echo $primary_docs['cal
'][2]; ?>');
296 setRadio('rb_top', 'cal');
298 if (frname
!= 'RBot' && f
.rb_bot
[i
].checked
) {
299 loadFrame('RBot', '<?php echo $primary_docs['aun
'][2]; ?>');
300 setRadio('rb_bot', 'aun');
306 // Reload encounter-specific frames, excluding a specified frame. At this
307 // point the new server-side encounter ID may not be set and loading the same
308 // document for the new encounter will not work, so load patient info instead.
309 function reloadEncounter(frname
) {
310 var f
= document
.forms
[0];
311 for (var i
= 0; i
< f
.rb_top
.length
; ++i
) {
312 if (f
.rb_top
[i
].value
.substring(3) > '1') {
313 if (frname
!= 'RTop' && f
.rb_top
[i
].checked
) {
314 loadFrame('RTop', '<?php echo $primary_docs['dem
'][2]; ?>');
315 setRadio('rb_top', 'dem');
317 if (frname
!= 'RBot' && f
.rb_bot
[i
].checked
) {
318 loadFrame('RBot', '<?php echo $primary_docs['ens
'][2]; ?>');
319 setRadio('rb_bot', 'ens');
325 // Call this to announce that the patient has changed. You must call this
326 // if you change the session PID, so that the navigation frame will show the
327 // correct patient and so that the other frame will be reloaded if it contains
328 // patient-specific information from the previous patient. frname is the name
329 // of the frame that the call came from, so we know to only reload content
330 // from the *other* frame if it is patient-specific.
331 function setPatient(pname
, pid
, frname
) {
332 if (pid
== active_pid
) return;
333 var str
= '<b>' + pname +
' (' + pid +
')</b>';
334 setDivContent('current_patient', str
);
335 setDivContent('current_encounter', '<b>None</b>');
337 active_encounter
= 0;
338 if (frname
) reloadPatient(frname
);
342 // Call this to announce that the encounter has changed. You must call this
343 // if you change the session encounter, so that the navigation frame will
344 // show the correct encounter and so that the other frame will be reloaded if
345 // it contains encounter-specific information from the previous encounter.
346 // frname is the name of the frame that the call came from, so we know to only
347 // reload encounter-specific content from the *other* frame.
348 function setEncounter(edate
, eid
, frname
) {
349 if (eid
== active_encounter
) return;
350 if (!eid
) edate
= 'None';
351 var str
= '<b>' + edate +
'</b>';
352 setDivContent('current_encounter', str
);
353 active_encounter
= eid
;
354 reloadEncounter(frname
);
358 // You must call this if you delete the active patient (or if for any other
359 // reason you "close" the active patient without opening a new one), so that
360 // the appearance of the navigation frame will be correct and so that any
361 // stale content will be reloaded.
362 function clearPatient() {
363 if (active_pid
== 0) return;
364 var f
= document
.forms
[0];
366 active_encounter
= 0;
367 setDivContent('current_encounter', '<b>None</b>');
368 setDivContent('current_patient', '<b>None</b>');
373 // You must call this if you delete the active encounter (or if for any other
374 // reason you "close" the active encounter without opening a new one), so that
375 // the appearance of the navigation frame will be correct and so that any
376 // stale content will be reloaded.
377 function clearEncounter() {
378 if (active_encounter
== 0) return;
379 setDivContent('current_encounter', '<b>None</b>');
380 active_encounter
= 0;
385 // You can call this to make sure the session pid is what we expect.
386 function pidSanityCheck(pid
) {
387 if (pid
!= active_pid
) {
388 alert('Session patient ID is ' + pid +
', expecting ' + active_pid +
389 '. This session is unstable and should be abandoned. Do not use ' +
390 'OpenEMR in multiple browser windows!');
396 // You can call this to make sure the session encounter is what we expect.
397 function encounterSanityCheck(eid
) {
398 if (eid
!= active_encounter
) {
399 alert('Session encounter ID is ' + eid +
', expecting ' + active_encounter +
400 '. This session is unstable and should be abandoned. Do not use ' +
401 'OpenEMR in multiple browser windows!');
407 // This is invoked to pop up some window when a popup item is selected.
408 function selpopup(selobj
) {
409 var i
= selobj
.selectedIndex
;
410 var opt
= selobj
.options
[i
];
414 if (opt
.text
== 'Export' || opt
.text
== 'Import') {
418 else if (opt
.text
== 'Refer') {
422 dlgopen(opt
.value
, '_blank', width
, height
);
424 selobj
.selectedIndex
= 0;
431 <body
<?
echo $nav_bg_line;?
> topmargin
='0' rightmargin
='4' leftmargin
='2'
432 bottommargin
='0' marginheight
='0'>
434 <form method
='post' name
='find_patient' target
='RTop'
435 action
='<?php echo $rootdir ?>/main/finder/patient_select.php'>
437 <table cellpadding
='0' cellspacing
='0' border
='0'>
440 <table cellpadding
='0' cellspacing
='0' border
='0' width
='100%'>
442 <td
class='smalltext' nowrap
>
443 <input type
='checkbox' name
='cb_top' onclick
='toggleFrame(1)' checked
/><b
>Top
</b
>
445 <td
class='smalltext' align
='right' nowrap
>
446 <b
>Bot
</b
><input type
='checkbox' name
='cb_bot' onclick
='toggleFrame(2)' checked
/>
453 // Builds the table of radio buttons and their labels. Radio button values
454 // are comprised of the 3-character document id and the 1-digit usage type,
455 // so that JavaScript can easily access this information.
456 $default_top_rbid = $GLOBALS['athletic_team'] ?
'ros' : 'cal';
457 foreach ($primary_docs as $key => $varr) {
458 if (!empty($disallowed[$key])) continue;
463 echo " <td class='smalltext'><input type='radio' name='rb_top' value='$key$usage' " .
464 "onclick=\"loadFrame('RTop','$url')\"";
465 if ($key == $default_top_rbid) echo " checked";
467 echo " <td class='smalltext' id='lbl_$key'>$label</td>\n";
468 echo " <td class='smalltext'><input type='radio' name='rb_bot' value='$key$usage' " .
469 "onclick=\"loadFrame('RBot','$url')\"";
470 if ($key == 'aun') echo " checked";
479 Active Patient
:<br
/>
480 <div id
='current_patient'>
484 Active Encounter
:<br
/>
485 <div id
='current_encounter'>
489 <select name
='popups' onchange
='selpopup(this)'
490 style
='background-color:transparent;font-size:9pt;'>
491 <option value
=''><?
xl('Popups','e'); ?
></option
>
492 <?php
if (!$disallowed['iss']) { ?
>
493 <option value
='../patient_file/problem_encounter.php'><?
xl('Issues','e'); ?
></option
>
495 <option value
='../../custom/export_xml.php'><?
xl('Export','e'); ?
></option
>
496 <option value
='../../custom/import_xml.php'><?
xl('Import','e'); ?
></option
>
497 <?php
if ($GLOBALS['athletic_team']) { ?
>
498 <option value
='../reports/players_report.php'><?
xl('Roster','e'); ?
></option
>
500 <option value
='../reports/appointments_report.php?patient=<?php echo $pid ?>'><?
xl('Appts','e'); ?
></option
>
501 <?php
if (file_exists("$webserver_root/custom/refer.php")) { ?
>
502 <option value
='../../custom/refer.php'><?
xl('Refer','e'); ?
></option
>
504 <?php
if ($GLOBALS['inhouse_pharmacy']) { ?
>
505 <option value
='../patient_file/pos_checkout.php'><?
xl('Payment','e'); ?
></option
>
507 <option value
='../patient_file/front_payment.php'><?
xl('Payment','e'); ?
></option
>
513 <table cellpadding
='0' cellspacing
='0' border
='0'>
515 <td
class='smalltext'>Find
: 
;</td
>
516 <td
class='smalltext' colspan
='2'>
517 <input type
="entry" size
="7" name
="patient" class='inputtext' style
='width:65px;' />
521 <td
class='smalltext'>by
:</td
>
522 <td
class='smalltext'>
523 <a href
="javascript:findPatient('Last');" class="navitem">Name
</a
>
525 <td
class='smalltext' align
='right'>
526 <a href
="javascript:findPatient('ID');" class="navitem">ID
</a
>
530 <td
class='smalltext'> 
;</td
>
531 <td
class='smalltext'>
532 <a href
="javascript:findPatient('SSN');" class="navitem">SSN
</a
>
534 <td
class='smalltext' align
='right'>
535 <a href
="javascript:findPatient('DOB');" class="navitem">DOB
</a
>
541 <a href
="../logout.php?auth=logout" target
="_top" class="navitem" id
="logout_link">
542 <?
xl('Logout','e'); ?
></a
>
544 <input type
='hidden' name
='findBy' value
='Last' />
548 <script language
='JavaScript'>