4 * Patient summary screen.
6 * LICENSE: This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 3
9 * of the 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 General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
18 * @author Brady Miller <brady.g.miller@gmail.com>
19 * @link http://www.open-emr.org
22 //SANITIZE ALL ESCAPES
23 $sanitize_all_escapes=true;
26 //STOP FAKE REGISTER GLOBALS
27 $fake_register_globals=false;
30 require_once("../../globals.php");
31 require_once("$srcdir/patient.inc");
32 require_once("$srcdir/acl.inc");
33 require_once("$srcdir/options.inc.php");
34 require_once("../history/history.inc.php");
35 require_once("$srcdir/edi.inc");
36 require_once("$srcdir/invoice_summary.inc.php");
37 require_once("$srcdir/clinical_rules.php");
38 require_once("$srcdir/options.js.php");
39 require_once("$srcdir/group.inc");
41 require_once(dirname(__FILE__
)."/../../../library/appointments.inc.php");
43 if (isset($_GET['set_pid'])) {
44 include_once("$srcdir/pid.inc");
45 setpid($_GET['set_pid']);
48 $active_reminders = false;
49 $all_allergy_alerts = false;
50 if ($GLOBALS['enable_cdr']) {
52 if ($GLOBALS['enable_allergy_check'] && $GLOBALS['enable_alert_log']) {
53 //Check for new allergies conflicts and throw popup if any exist(note need alert logging to support this)
54 $new_allergy_alerts = allergy_conflict($pid,'new',$_SESSION['authUser']);
55 if (!empty($new_allergy_alerts)) {
56 $pop_warning = '<script type="text/javascript">alert(\'' . xls('WARNING - FOLLOWING ACTIVE MEDICATIONS ARE ALLERGIES') . ':\n';
57 foreach ($new_allergy_alerts as $new_allergy_alert) {
58 $pop_warning .= addslashes($new_allergy_alert) . '\n';
60 $pop_warning .= '\')</script>';
64 if ((!isset($_SESSION['alert_notify_pid']) ||
($_SESSION['alert_notify_pid'] != $pid)) && isset($_GET['set_pid']) && $GLOBALS['enable_cdr_crp']) {
65 // showing a new patient, so check for active reminders and allergy conflicts, which use in active reminder popup
66 $active_reminders = active_alert_summary($pid,"reminders-due",'','default',$_SESSION['authUser'],TRUE);
67 if ($GLOBALS['enable_allergy_check']) {
68 $all_allergy_alerts = allergy_conflict($pid,'all',$_SESSION['authUser'],TRUE);
73 function print_as_money($money) {
74 preg_match("/(\d*)\.?(\d*)/",$money,$moneymatches);
75 $tmp = wordwrap(strrev($moneymatches[1]),3,",",1);
76 $ccheck = strrev($tmp);
77 if ($ccheck[0] == ",") {
78 $tmp = substr($ccheck,1,strlen($ccheck)-1);
80 if ($moneymatches[2] != "") {
81 return "$ " . strrev($tmp) . "." . $moneymatches[2];
83 return "$ " . strrev($tmp);
87 // get an array from Photos category
88 function pic_array($pid,$picture_directory) {
90 $sql_query = "select documents.id from documents join categories_to_documents " .
91 "on documents.id = categories_to_documents.document_id " .
92 "join categories on categories.id = categories_to_documents.category_id " .
93 "where categories.name like ? and documents.foreign_id = ?";
94 if ($query = sqlStatement($sql_query, array($picture_directory,$pid))) {
95 while( $results = sqlFetchArray($query) ) {
96 array_push($pics,$results['id']);
101 // Get the document ID of the first document in a specific catg.
102 function get_document_by_catg($pid,$doc_catg) {
106 if ($pid and $doc_catg) {
107 $result = sqlQuery("SELECT d.id, d.date, d.url FROM " .
108 "documents AS d, categories_to_documents AS cd, categories AS c " .
109 "WHERE d.foreign_id = ? " .
110 "AND cd.document_id = d.id " .
111 "AND c.id = cd.category_id " .
112 "AND c.name LIKE ? " .
113 "ORDER BY d.date DESC LIMIT 1", array($pid, $doc_catg) );
116 return($result['id']);
119 // Display image in 'widget style'
120 function image_widget($doc_id,$doc_catg)
122 global $pid, $web_root;
123 $docobj = new Document($doc_id);
124 $image_file = $docobj->get_url_file();
125 $image_width = $GLOBALS['generate_doc_thumb'] == 1 ?
'' : 'width=100';
126 $extension = substr($image_file, strrpos($image_file,"."));
127 $viewable_types = array('.png','.jpg','.jpeg','.png','.bmp','.PNG','.JPG','.JPEG','.PNG','.BMP'); // image ext supported by fancybox viewer
128 if ( in_array($extension,$viewable_types) ) { // extention matches list
129 $to_url = "<td> <a href = $web_root" .
130 "/controller.php?document&retrieve&patient_id=$pid&document_id=$doc_id&as_file=false&original_file=true&disable_exit=false&show_original=true" .
131 "/tmp$extension" . // Force image type URL for fancybo
132 " onclick=top.restoreSession(); class='image_modal'>" .
133 " <img src = $web_root" .
134 "/controller.php?document&retrieve&patient_id=$pid&document_id=$doc_id&as_file=false" .
135 " $image_width alt='$doc_catg:$image_file'> </a> </td> <td valign='center'>".
136 htmlspecialchars($doc_catg) . '<br /> ' . htmlspecialchars($image_file) .
140 $to_url = "<td> <a href='" . $web_root . "/controller.php?document&retrieve" .
141 "&patient_id=$pid&document_id=$doc_id'" .
142 " onclick='top.restoreSession()' class='css_button_small'>" .
144 htmlspecialchars( xl("View"), ENT_QUOTES
)."</a> " .
145 htmlspecialchars( "$doc_catg - $image_file", ENT_QUOTES
) .
150 echo "</tr></table>";
153 // Determine if the Vitals form is in use for this site.
154 $tmp = sqlQuery("SELECT count(*) AS count FROM registry WHERE " .
155 "directory = 'vitals' AND state = 1");
156 $vitals_is_registered = $tmp['count'];
158 // Get patient/employer/insurance information.
160 $result = getPatientData($pid, "*, DATE_FORMAT(DOB,'%Y-%m-%d') as DOB_YMD");
161 $result2 = getEmployerData($pid);
162 $result3 = getInsuranceData($pid, "primary", "copay, provider, DATE_FORMAT(`date`,'%Y-%m-%d') as effdate");
164 if ($result3['provider']) { // Use provider in case there is an ins record w/ unassigned insco
165 $insco_name = getInsuranceProvider($result3['provider']);
171 <?php
html_header_show();?
>
172 <link rel
="stylesheet" href
="<?php echo $css_header;?>" type
="text/css">
173 <link rel
="stylesheet" type
="text/css" href
="../../../library/js/fancybox/jquery.fancybox-1.2.6.css" media
="screen" />
174 <style type
="text/css">@import
url(../../../library
/dynarch_calendar
.css
);</style
>
175 <script type
="text/javascript" src
="../../../library/textformat.js"></script
>
176 <script type
="text/javascript" src
="../../../library/dynarch_calendar.js"></script
>
177 <?php
include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?
>
178 <script type
="text/javascript" src
="../../../library/dynarch_calendar_setup.js"></script
>
179 <script type
="text/javascript" src
="../../../library/dialog.js?v=<?php echo $v_js_includes; ?>"></script
>
180 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-6-4/index.js"></script
>
181 <script type
="text/javascript" src
="../../../library/js/common.js"></script
>
182 <script type
="text/javascript" src
="../../../library/js/fancybox/jquery.fancybox-1.2.6.js"></script
>
183 <script type
="text/javascript" language
="JavaScript">
185 var mypcc
= '<?php echo htmlspecialchars($GLOBALS['phone_country_code
'],ENT_QUOTES); ?>';
187 function oldEvt(apptdate
, eventid
) {
188 dlgopen('../../main/calendar/add_edit_event.php?date=' + apptdate +
'&eid=' + eventid
, '_blank', 775, 500);
191 function advdirconfigure() {
192 dlgopen('advancedirectives.php', '_blank', 500, 450);
195 function refreshme() {
196 top
.restoreSession();
200 // Process click on Delete link.
201 function deleteme() {
202 dlgopen('../deleter.php?patient=<?php echo htmlspecialchars($pid,ENT_QUOTES); ?>', '_blank', 500, 450);
206 // Called by the deleteme.php window on a successful delete.
207 function imdeleted() {
208 parent
.left_nav
.clearPatient();
212 dlgopen('../../main/calendar/add_edit_event.php?patientid=<?php echo htmlspecialchars($pid,ENT_QUOTES); ?>', '_blank', 775, 500);
216 function sendimage(pid
, what
) {
217 // alert('Not yet implemented.'); return false;
218 dlgopen('../upload_dialog.php?patientid=' + pid +
'&file=' + what
,
225 <script type
="text/javascript">
227 function toggleIndicator(target
,div
) {
229 $mode = $
(target
).find(".indicator").text();
230 if ( $mode == "<?php echo htmlspecialchars(xl('collapse'),ENT_QUOTES); ?>" ) {
231 $
(target
).find(".indicator").text( "<?php echo htmlspecialchars(xl('expand'),ENT_QUOTES); ?>" );
233 $
.post( "../../../library/ajax/user_settings.php", { target
: div
, mode
: 0 });
235 $
(target
).find(".indicator").text( "<?php echo htmlspecialchars(xl('collapse'),ENT_QUOTES); ?>" );
237 $
.post( "../../../library/ajax/user_settings.php", { target
: div
, mode
: 1 });
241 $
(document
).ready(function(){
244 if($GLOBALS['erx_enable']){
245 //$soap_status=sqlQuery("select soap_import_status from patient_data where pid=?",array($pid));
246 $soap_status=sqlStatement("select soap_import_status,pid from patient_data where pid=? and soap_import_status in ('1','3')",array($pid));
247 while($row_soapstatus=sqlFetchArray($soap_status)){
248 //if($soap_status['soap_import_status']=='1' || $soap_status['soap_import_status']=='3'){ ?>
249 top
.restoreSession();
252 url
: "../../soap_functions/soap_patientfullmedication.php",
255 patient
:<?php
echo $row_soapstatus['pid']; ?
>,
258 success
: function(thedata
){
260 msg_updation+
=thedata
;
268 //elseif($soap_status['soap_import_status']=='3'){ ?>
269 top
.restoreSession();
272 url
: "../../soap_functions/soap_allergy.php",
275 patient
:<?php
echo $row_soapstatus['pid']; ?
>,
278 success
: function(thedata
){
280 msg_updation+
=thedata
;
287 if($GLOBALS['erx_import_status_message']){ ?
>
297 $
("#stats_div").load("stats.php", { 'embeddedScreen' : true }, function() {
298 // (note need to place javascript code here also to get the dynamic link to work)
299 $
(".rx_modal").fancybox( {
300 'overlayOpacity' : 0.0,
301 'showCloseButton' : true,
304 'centerOnScroll' : false,
305 'callbackOnClose' : function() {
310 $
("#pnotes_ps_expand").load("pnotes_fragment.php");
311 $
("#disclosures_ps_expand").load("disc_fragment.php");
313 <?php
if ($GLOBALS['enable_cdr'] && $GLOBALS['enable_cdr_crw']) { ?
>
314 top
.restoreSession();
315 $
("#clinical_reminders_ps_expand").load("clinical_reminders_fragment.php", { 'embeddedScreen' : true }, function() {
316 // (note need to place javascript code here also to get the dynamic link to work)
317 $
(".medium_modal").fancybox( {
318 'overlayOpacity' : 0.0,
319 'showCloseButton' : true,
322 'centerOnScroll' : false,
323 'callbackOnClose' : function() {
330 <?php
if ($GLOBALS['enable_cdr'] && $GLOBALS['enable_cdr_prw']) { ?
>
331 top
.restoreSession();
332 $
("#patient_reminders_ps_expand").load("patient_reminders_fragment.php");
335 <?php
if ($vitals_is_registered && acl_check('patients', 'med')) { ?
>
336 // Initialize the Vitals form if it is registered and user is authorized.
337 $
("#vitals_ps_expand").load("vitals_fragment.php");
340 // Initialize track_anything
341 $
("#track_anything_ps_expand").load("track_anything_fragment.php");
344 // Initialize labdata
345 $
("#labdata_ps_expand").load("labdata_fragment.php");
347 // Initialize for each applicable LBF form.
348 $gfres = sqlStatement("SELECT option_id FROM list_options WHERE " .
349 "list_id = 'lbfnames' AND option_value > 0 AND activity = 1 ORDER BY seq, title");
350 while($gfrow = sqlFetchArray($gfres)) {
352 $
("#<?php echo $gfrow['option_id']; ?>_ps_expand").load("lbf_fragment.php?formname=<?php echo $gfrow['option_id']; ?>");
362 // modal for dialog boxes
363 $
(".large_modal").fancybox( {
364 'overlayOpacity' : 0.0,
365 'showCloseButton' : true,
368 'centerOnScroll' : false
371 // modal for image viewer
372 $
(".image_modal").fancybox( {
373 'overlayOpacity' : 0.0,
374 'showCloseButton' : true,
375 'centerOnScroll' : false,
379 $
(".iframe1").fancybox( {
381 'overlayOpacity' : 0.0,
382 'showCloseButton' : true,
386 // special size for patient portal
387 $
(".small_modal").fancybox( {
388 'overlayOpacity' : 0.0,
389 'showCloseButton' : true,
392 'centerOnScroll' : false
395 <?php
if ($active_reminders ||
$all_allergy_alerts) { ?
>
396 // show the active reminder modal
397 $
("#reminder_popup_link").fancybox({
398 'overlayOpacity' : 0.0,
399 'showCloseButton' : true,
402 'centerOnScroll' : false
408 // JavaScript stuff to do when a new patient is set.
410 function setMyPatient() {
411 // Avoid race conditions with loading of the left_nav or Title frame.
412 if (!parent
.allFramesLoaded()) {
413 setTimeout("setMyPatient()", 500);
416 <?php
if (isset($_GET['set_pid'])) { ?
>
417 parent
.left_nav
.setPatient(<?php
echo "'" . addslashes($result['fname']) . " " . addslashes($result['lname']) .
418 "'," . addslashes($pid) . ",'" . addslashes($result['pubpid']) .
419 "','', ' " . xls('DOB') . ": " . addslashes(oeFormatShortDate($result['DOB_YMD'])) . " " . xls('Age') . ": " . addslashes(getPatientAgeDisplay($result['DOB_YMD'])) . "'"; ?
>);
420 var EncounterDateArray
= new Array;
421 var CalendarCategoryArray
= new Array;
422 var EncounterIdArray
= new Array;
425 //Encounter details are stored to javacript as array.
426 $result4 = sqlStatement("SELECT fe.encounter,fe.date,openemr_postcalendar_categories.pc_catname FROM form_encounter AS fe ".
427 " left join openemr_postcalendar_categories on fe.pc_catid=openemr_postcalendar_categories.pc_catid WHERE fe.pid = ? order by fe.date desc", array($pid));
428 if(sqlNumRows($result4)>0) {
429 while($rowresult4 = sqlFetchArray($result4)) {
431 EncounterIdArray
[Count
] = '<?php echo addslashes($rowresult4['encounter
']); ?>';
432 EncounterDateArray
[Count
] = '<?php echo addslashes(oeFormatShortDate(date("Y-m-d", strtotime($rowresult4['date
'])))); ?>';
433 CalendarCategoryArray
[Count
] = '<?php echo addslashes(xl_appt_category($rowresult4['pc_catname
'])); ?>';
439 parent
.left_nav
.setPatientEncounter(EncounterIdArray
,EncounterDateArray
,CalendarCategoryArray
);
440 <?php
} // end setting new pid ?>
441 parent
.left_nav
.syncRadios();
442 <?php
if ( (isset($_GET['set_pid']) ) && (isset($_GET['set_encounterid'])) && ( intval($_GET['set_encounterid']) > 0 ) ) {
443 $encounter = intval($_GET['set_encounterid']);
444 $_SESSION['encounter'] = $encounter;
445 $query_result = sqlQuery("SELECT `date` FROM `form_encounter` WHERE `encounter` = ?", array($encounter)); ?
>
446 encurl
= 'encounter/encounter_top.php?set_encounter=' +
<?php
echo attr($encounter);?
> +
'&pid=' +
<?php
echo attr($pid);?
>;
447 <?php
if ($GLOBALS['new_tabs_layout']) { ?
>
448 parent
.left_nav
.setEncounter('<?php echo oeFormatShortDate(date("Y-m-d", strtotime($query_result['date
']))); ?>', '<?php echo attr($encounter); ?>', 'enc');
449 top
.restoreSession();
450 parent
.left_nav
.loadFrame('enc2', 'enc', 'patient_file/' + encurl
);
452 var othername
= (window
.name
== 'RTop') ?
'RBot' : 'RTop';
453 parent
.left_nav
.setEncounter('<?php echo oeFormatShortDate(date("Y-m-d", strtotime($query_result['date
']))); ?>', '<?php echo attr($encounter); ?>', othername
);
454 top
.restoreSession();
455 parent
.frames
[othername
].location
.href
= '../' + encurl
;
457 <?php
} // end setting new encounter id (only if new pid is also set) ?>
460 $
(window
).load(function() {
466 <style type
="css/text">
475 <body
class="body_top patient-demographics">
477 <a href
='../reminder/active_reminder_popup.php' id
='reminder_popup_link' style
='visibility: false;' class='iframe' onclick
='top.restoreSession()'></a
>
480 $thisauth = acl_check('patients', 'demo');
482 if ($result['squad'] && ! acl_check('squads', $result['squad'])) {
487 echo "<p>(" . htmlspecialchars(xl('Demographics not authorized'),ENT_NOQUOTES
) . ")</p>\n";
488 echo "</body>\n</html>\n";
493 <table
class="table_header">
497 <?php
echo htmlspecialchars(getPatientName($pid),ENT_NOQUOTES
); ?
>
500 <?php
if (acl_check('admin', 'super') && $GLOBALS['allow_pat_delete']) : ?
>
501 <td style
='padding-left:1em;' class="delete">
502 <a
class='css_button iframe'
503 href
='../deleter.php?patient="<?php echo htmlspecialchars($pid,ENT_QUOTES);?>'
504 onclick
='top.restoreSession()'>
505 <span
><?php
echo htmlspecialchars(xl('Delete'),ENT_NOQUOTES
);?
></span
>
508 <?php
endif; // Allow PT delete
509 if($GLOBALS['erx_enable']): ?
>
510 <td style
="padding-left:1em;" class="erx">
511 <a
class="css_button" href
="../../eRx.php?page=medentry" onclick
="top.restoreSession()">
512 <span
><?php
echo htmlspecialchars(xl('NewCrop MedEntry'),ENT_NOQUOTES
);?
></span
>
515 <td style
="padding-left:1em;">
516 <a
class="css_button iframe1"
517 href
="../../soap_functions/soap_accountStatusDetails.php"
518 onclick
="top.restoreSession()">
519 <span
><?php
echo htmlspecialchars(xl('NewCrop Account Status'),ENT_NOQUOTES
);?
></span
>
522 <td id
='accountstatus'></td
>
523 <?php
endif; // eRX Enabled
525 $portalUserSetting = true; //flag to see if patient has authorized access to portal
526 if($GLOBALS['portal_onsite_enable'] && $GLOBALS['portal_onsite_address']):
527 $portalStatus = sqlQuery("SELECT allow_patient_portal FROM patient_data WHERE pid=?",array($pid));
528 if ($portalStatus['allow_patient_portal']=='YES'):
529 $portalLogin = sqlQuery("SELECT pid FROM `patient_access_onsite` WHERE `pid`=?", array($pid));?
>
530 <td style
='padding-left:1em;'>
531 <a
class='css_button iframe small_modal'
532 href
='create_portallogin.php?portalsite=on&patient=<?php echo htmlspecialchars($pid,ENT_QUOTES);?>'
533 onclick
='top.restoreSession()'>
534 <?php
$display = (empty($portalLogin)) ?
xlt('Create Onsite Portal Credentials') : xlt('Reset Onsite Portal Credentials'); ?
>
535 <span
><?php
echo $display; ?
></span
>
540 $portalUserSetting = false;
541 endif; // allow patient portal
542 endif; // Onsite Patient Portal
543 if($GLOBALS['portal_offsite_enable'] && $GLOBALS['portal_offsite_address']):
544 $portalStatus = sqlQuery("SELECT allow_patient_portal FROM patient_data WHERE pid=?",array($pid));
545 if ($portalStatus['allow_patient_portal']=='YES'):
546 $portalLogin = sqlQuery("SELECT pid FROM `patient_access_offsite` WHERE `pid`=?", array($pid));
548 <td style
='padding-left:1em;'>
549 <a
class='css_button iframe small_modal'
550 href
='create_portallogin.php?portalsite=off&patient=<?php echo htmlspecialchars($pid,ENT_QUOTES);?>'
551 onclick
='top.restoreSession()'>
553 <?php
$text = (empty($portalLogin)) ?
xlt('Create Offsite Portal Credentials') : xlt('Reset Offsite Portal Credentials'); ?
>
560 $portalUserSetting = false;
561 endif; // allow_patient_portal
562 endif; // portal_offsite_enable
563 if (!($portalUserSetting)): // Show that the patient has not authorized portal access ?>
564 <td style
='padding-left:1em;'>
565 <?php
echo htmlspecialchars( xl('Patient has not authorized the Patient Portal.'), ENT_NOQUOTES
);?
>
570 // If patient is deceased, then show this (along with the number of days patient has been deceased for)
571 $days_deceased = is_patient_deceased($pid);
572 if ($days_deceased != null): ?
>
573 <td
class="deceased" style
="padding-left:1em;font-weight:bold;color:red">
575 if ($days_deceased == 0) {
576 echo xlt("DECEASED (Today)");
578 else if ($days_deceased == 1) {
579 echo xlt("DECEASED (1 day ago)");
582 echo xlt("DECEASED") . " (" . text($days_deceased) . " " . xlt("days ago") . ")";
594 // Get the document ID of the patient ID card if access to it is wanted here.
595 $idcard_doc_id = false;
596 if ($GLOBALS['patient_id_category_name']) {
597 $idcard_doc_id = get_document_by_catg($pid, $GLOBALS['patient_id_category_name']);
601 <table cellspacing
='0' cellpadding
='0' border
='0' class="subnav">
603 <td
class="small" colspan
='4'>
604 <a href
="../history/history.php" onclick
='top.restoreSession()'>
605 <?php
echo htmlspecialchars(xl('History'),ENT_NOQUOTES
); ?
></a
>
607 <?php
//note that we have temporarily removed report screen from the modal view ?>
608 <a href
="../report/patient_report.php" onclick
='top.restoreSession()'>
609 <?php
echo htmlspecialchars(xl('Report'),ENT_NOQUOTES
); ?
></a
>
611 <?php
//note that we have temporarily removed document screen from the modal view ?>
612 <a href
="../../../controller.php?document&list&patient_id=<?php echo $pid;?>" onclick
='top.restoreSession()'>
613 <?php
echo htmlspecialchars(xl('Documents'),ENT_NOQUOTES
); ?
></a
>
615 <a href
="../transaction/transactions.php" class='iframe large_modal' onclick
='top.restoreSession()'>
616 <?php
echo htmlspecialchars(xl('Transactions'),ENT_NOQUOTES
); ?
></a
>
618 <a href
="stats_full.php?active=all" onclick
='top.restoreSession()'>
619 <?php
echo htmlspecialchars(xl('Issues'),ENT_NOQUOTES
); ?
></a
>
621 <a href
="../../reports/pat_ledger.php?form=1&patient_id=<?php echo attr($pid);?>" onclick
='top.restoreSession()'>
622 <?php
echo xlt('Ledger'); ?
></a
>
624 <a href
="../../reports/external_data.php" onclick
='top.restoreSession()'>
625 <?php
echo xlt('External Data'); ?
></a
>
627 <!-- DISPLAYING HOOKS STARTS HERE
-->
629 $module_query = sqlStatement("SELECT msh.*,ms.menu_name,ms.path,m.mod_ui_name,m.type FROM modules_hooks_settings AS msh
630 LEFT OUTER JOIN modules_settings AS ms ON obj_name=enabled_hooks AND ms.mod_id=msh.mod_id
631 LEFT OUTER JOIN modules AS m ON m.mod_id=ms.mod_id
632 WHERE fld_type=3 AND mod_active=1 AND sql_run=1 AND attached_to='demographics' ORDER BY mod_id");
633 $DivId = 'mod_installer';
634 if (sqlNumRows($module_query)) {
637 while ($modulerow = sqlFetchArray($module_query)) {
638 $DivId = 'mod_'.$modulerow['mod_id'];
639 $new_category = $modulerow['mod_ui_name'];
642 if($modulerow['type'] == 0) {
643 $modulePath = $GLOBALS['customModDir'];
648 $modulePath = $GLOBALS['zendModDir'];
650 $relative_link = "../../modules/".$modulePath."/".$modulerow['path'];
651 $nickname = $modulerow['menu_name'] ?
$modulerow['menu_name'] : 'Noname';
653 $modid = $modulerow['mod_id'];
656 <a href
="<?php echo $relative_link; ?>" onclick
='top.restoreSession()'>
657 <?php
echo xlt($nickname); ?
></a
>
662 <!-- DISPLAYING HOOKS ENDS HERE
-->
666 </table
> <!-- end header
-->
668 <div style
='margin-top:10px' class="main"> <!-- start main content div
-->
669 <table border
="0" cellspacing
="0" cellpadding
="0" width
="100%">
671 <td
class="demographics-box" align
="left" valign
="top">
672 <!-- start left column div
-->
673 <div style
='float:left; margin-right:20px'>
675 <table cellspacing
=0 cellpadding
=0>
676 <?php
if (!$GLOBALS['hide_billing_widget']) { ?
>
680 // Billing expand collapse widget
681 $widgetTitle = xl("Billing");
682 $widgetLabel = "billing";
683 $widgetButtonLabel = xl("Edit");
684 $widgetButtonLink = "return newEvt();";
685 $widgetButtonClass = "";
686 $linkMethod = "javascript";
687 $bodyClass = "notab";
690 if ($GLOBALS['force_billing_widget_open']) {
691 $forceExpandAlways = true;
694 $forceExpandAlways = false;
696 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
697 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
698 $widgetAuth, $fixedWidth, $forceExpandAlways);
702 //PATIENT BALANCE,INS BALANCE naina@capminds.com
703 $patientbalance = get_patient_balance($pid, false);
704 //Debit the patient balance from insurance balance
705 $insurancebalance = get_patient_balance($pid, true) - $patientbalance;
706 $totalbalance=$patientbalance +
$insurancebalance;
708 // Show current balance and billing note, if any.
709 echo "<table border='0'><tr><td>" .
710 "<table ><tr><td><span class='bold'><font color='red'>" .
711 xlt('Patient Balance Due') .
712 " : " . text(oeFormatMoney($patientbalance)) .
713 "</font></span></td></tr>".
714 "<tr><td><span class='bold'><font color='red'>" .
715 xlt('Insurance Balance Due') .
716 " : " . text(oeFormatMoney($insurancebalance)) .
717 "</font></span></td></tr>".
718 "<tr><td><span class='bold'><font color='red'>" .
719 xlt('Total Balance Due').
720 " : " . text(oeFormatMoney($totalbalance)) .
721 "</font></span></td></td></tr>";
722 if (!empty($result['billing_note'])) {
723 echo "<tr><td><span class='bold'><font color='red'>" .
724 xlt('Billing Note') . ":" .
725 text($result['billing_note']) .
726 "</font></span></td></tr>";
728 if ($result3['provider']) { // Use provider in case there is an ins record w/ unassigned insco
729 echo "<tr><td><span class='bold'>" .
730 xlt('Primary Insurance') . ': ' . text($insco_name) .
731 "</span> ";
732 if ($result3['copay'] > 0) {
733 echo "<span class='bold'>" .
734 xlt('Copay') . ': ' . text($result3['copay']) .
735 "</span> ";
737 echo "<span class='bold'>" .
738 xlt('Effective Date') . ': ' . text(oeFormatShortDate($result3['effdate'])) .
741 echo "</table></td></tr></td></tr></table><br>";
744 </div
> <!-- required
for expand_collapse_widget
-->
751 // Demographics expand collapse widget
752 $widgetTitle = xl("Demographics");
753 $widgetLabel = "demographics";
754 $widgetButtonLabel = xl("Edit");
755 $widgetButtonLink = "demographics_full.php";
756 $widgetButtonClass = "";
757 $linkMethod = "html";
759 $widgetAuth = acl_check('patients', 'demo', '', 'write');
761 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
762 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
763 $widgetAuth, $fixedWidth);
767 <?php
display_layout_tabs('DEM', $result, $result2); ?
>
769 <div
class="tabContainer">
770 <?php
display_layout_tabs_data('DEM', $result, $result2); ?
>
773 </div
> <!-- required
for expand_collapse_widget
-->
780 $insurance_count = 0;
781 foreach (array('primary','secondary','tertiary') as $instype) {
782 $enddate = 'Present';
783 $query = "SELECT * FROM insurance_data WHERE " .
784 "pid = ? AND type = ? " .
785 "ORDER BY date DESC";
786 $res = sqlStatement($query, array($pid, $instype) );
787 while( $row = sqlFetchArray($res) ) {
788 if ($row['provider'] ) $insurance_count++
;
792 if ( $insurance_count > 0 ) {
793 // Insurance expand collapse widget
794 $widgetTitle = xl("Insurance");
795 $widgetLabel = "insurance";
796 $widgetButtonLabel = xl("Edit");
797 $widgetButtonLink = "demographics_full.php";
798 $widgetButtonClass = "";
799 $linkMethod = "html";
801 $widgetAuth = acl_check('patients', 'demo', '', 'write');
803 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
804 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
805 $widgetAuth, $fixedWidth);
807 if ( $insurance_count > 0 ) {
810 <ul
class="tabNav"><?php
811 ///////////////////////////////// INSURANCE SECTION
813 foreach (array('primary','secondary','tertiary') as $instype) {
815 $query = "SELECT * FROM insurance_data WHERE " .
816 "pid = ? AND type = ? " .
817 "ORDER BY date DESC";
818 $res = sqlStatement($query, array($pid, $instype) );
820 $enddate = 'Present';
822 while( $row = sqlFetchArray($res) ) {
823 if ($row['provider'] ) {
825 $ins_description = ucfirst($instype);
826 $ins_description = xl($ins_description);
827 $ins_description .= strcmp($enddate, 'Present') != 0 ?
" (".xl('Old').")" : "";
829 <li
<?php
echo $first ?
'class="current"' : '' ?
>><a href
="#">
830 <?php
echo htmlspecialchars($ins_description,ENT_NOQUOTES
); ?
></a
></li
>
834 $enddate = $row['date'];
837 // Display the eligibility tab
838 echo "<li><a href='#'>" .
839 htmlspecialchars( xl('Eligibility'), ENT_NOQUOTES
) . "</a></li>";
845 <div
class="tabContainer">
848 foreach (array('primary','secondary','tertiary') as $instype) {
849 $enddate = 'Present';
851 $query = "SELECT * FROM insurance_data WHERE " .
852 "pid = ? AND type = ? " .
853 "ORDER BY date DESC";
854 $res = sqlStatement($query, array($pid, $instype) );
855 while( $row = sqlFetchArray($res) ) {
856 if ($row['provider'] ) {
858 <div
class="tab <?php echo $first ? 'current' : '' ?>">
859 <table border
='0' cellpadding
='0' width
='100%'>
861 $icobj = new InsuranceCompany($row['provider']);
862 $adobj = $icobj->get_address();
863 $insco_name = trim($icobj->get_name());
866 <td valign
='top' colspan
='3'>
868 <?php
if (strcmp($enddate, 'Present') != 0) echo htmlspecialchars(xl("Old"),ENT_NOQUOTES
)." "; ?
>
869 <?php
$tempinstype=ucfirst($instype); echo htmlspecialchars(xl($tempinstype.' Insurance'),ENT_NOQUOTES
); ?
>
870 <?php
if (strcmp($row['date'], '0000-00-00') != 0) { ?
>
871 <?php
echo htmlspecialchars(xl('from','',' ',' ').$row['date'],ENT_NOQUOTES
); ?
>
873 <?php
echo htmlspecialchars(xl('until','',' ',' '),ENT_NOQUOTES
);
874 echo (strcmp($enddate, 'Present') != 0) ?
$enddate : htmlspecialchars(xl('Present'),ENT_NOQUOTES
); ?
>:</span
>
882 echo htmlspecialchars($insco_name,ENT_NOQUOTES
) . '<br>';
883 if (trim($adobj->get_line1())) {
884 echo htmlspecialchars($adobj->get_line1(),ENT_NOQUOTES
) . '<br>';
885 echo htmlspecialchars($adobj->get_city() . ', ' . $adobj->get_state() . ' ' . $adobj->get_zip(),ENT_NOQUOTES
);
888 echo "<font color='red'><b>".htmlspecialchars(xl('Unassigned'),ENT_NOQUOTES
)."</b></font>";
892 <?php
echo htmlspecialchars(xl('Policy Number'),ENT_NOQUOTES
); ?
>:
893 <?php
echo htmlspecialchars($row['policy_number'],ENT_NOQUOTES
) ?
><br
>
894 <?php
echo htmlspecialchars(xl('Plan Name'),ENT_NOQUOTES
); ?
>:
895 <?php
echo htmlspecialchars($row['plan_name'],ENT_NOQUOTES
); ?
><br
>
896 <?php
echo htmlspecialchars(xl('Group Number'),ENT_NOQUOTES
); ?
>:
897 <?php
echo htmlspecialchars($row['group_number'],ENT_NOQUOTES
); ?
></span
>
900 <span
class='bold'><?php
echo htmlspecialchars(xl('Subscriber'),ENT_NOQUOTES
); ?
>: </span
><br
>
901 <span
class='text'><?php
echo htmlspecialchars($row['subscriber_fname'] . ' ' . $row['subscriber_mname'] . ' ' . $row['subscriber_lname'],ENT_NOQUOTES
); ?
>
903 if ($row['subscriber_relationship'] != "") {
904 echo "(" . htmlspecialchars($row['subscriber_relationship'],ENT_NOQUOTES
) . ")";
908 <?php
echo htmlspecialchars(xl('S.S.'),ENT_NOQUOTES
); ?
>:
909 <?php
echo htmlspecialchars($row['subscriber_ss'],ENT_NOQUOTES
); ?
><br
>
910 <?php
echo htmlspecialchars(xl('D.O.B.'),ENT_NOQUOTES
); ?
>:
911 <?php
if ($row['subscriber_DOB'] != "0000-00-00 00:00:00") echo htmlspecialchars($row['subscriber_DOB'],ENT_NOQUOTES
); ?
><br
>
912 <?php
echo htmlspecialchars(xl('Phone'),ENT_NOQUOTES
); ?
>:
913 <?php
echo htmlspecialchars($row['subscriber_phone'],ENT_NOQUOTES
); ?
>
917 <span
class='bold'><?php
echo htmlspecialchars(xl('Subscriber Address'),ENT_NOQUOTES
); ?
>: </span
><br
>
918 <span
class='text'><?php
echo htmlspecialchars($row['subscriber_street'],ENT_NOQUOTES
); ?
><br
>
919 <?php
echo htmlspecialchars($row['subscriber_city'],ENT_NOQUOTES
); ?
>
920 <?php
if($row['subscriber_state'] != "") echo ", "; echo htmlspecialchars($row['subscriber_state'],ENT_NOQUOTES
); ?
>
921 <?php
if($row['subscriber_country'] != "") echo ", "; echo htmlspecialchars($row['subscriber_country'],ENT_NOQUOTES
); ?
>
922 <?php
echo " " . htmlspecialchars($row['subscriber_postal_code'],ENT_NOQUOTES
); ?
></span
>
924 <?php
if (trim($row['subscriber_employer'])) { ?
>
925 <br
><span
class='bold'><?php
echo htmlspecialchars(xl('Subscriber Employer'),ENT_NOQUOTES
); ?
>: </span
><br
>
926 <span
class='text'><?php
echo htmlspecialchars($row['subscriber_employer'],ENT_NOQUOTES
); ?
><br
>
927 <?php
echo htmlspecialchars($row['subscriber_employer_street'],ENT_NOQUOTES
); ?
><br
>
928 <?php
echo htmlspecialchars($row['subscriber_employer_city'],ENT_NOQUOTES
); ?
>
929 <?php
if($row['subscriber_employer_city'] != "") echo ", "; echo htmlspecialchars($row['subscriber_employer_state'],ENT_NOQUOTES
); ?
>
930 <?php
if($row['subscriber_employer_country'] != "") echo ", "; echo htmlspecialchars($row['subscriber_employer_country'],ENT_NOQUOTES
); ?
>
931 <?php
echo " " . htmlspecialchars($row['subscriber_employer_postal_code'],ENT_NOQUOTES
); ?
>
939 <?php
if ($row['copay'] != "") { ?
>
940 <span
class='bold'><?php
echo htmlspecialchars(xl('CoPay'),ENT_NOQUOTES
); ?
>: </span
>
941 <span
class='text'><?php
echo htmlspecialchars($row['copay'],ENT_NOQUOTES
); ?
></span
>
944 <span
class='bold'><?php
echo htmlspecialchars(xl('Accept Assignment'),ENT_NOQUOTES
); ?
>:</span
>
945 <span
class='text'><?php
if($row['accept_assignment'] == "TRUE") echo xl("YES"); ?
>
946 <?php
if($row['accept_assignment'] == "FALSE") echo xl("NO"); ?
></span
>
947 <?php
if (!empty($row['policy_type'])) { ?
>
949 <span
class='bold'><?php
echo htmlspecialchars(xl('Secondary Medicare Type'),ENT_NOQUOTES
); ?
>: </span
>
950 <span
class='text'><?php
echo htmlspecialchars($policy_types[$row['policy_type']],ENT_NOQUOTES
); ?
></span
>
953 <td valign
='top'></td
>
954 <td valign
='top'></td
>
961 } // end if ($row['provider'])
962 $enddate = $row['date'];
967 // Display the eligibility information
968 echo "<div class='tab'>";
969 show_eligibility_information($pid,true);
972 ///////////////////////////////// END INSURANCE SECTION
985 // Notes expand collapse widget
986 $widgetTitle = xl("Notes");
987 $widgetLabel = "pnotes";
988 $widgetButtonLabel = xl("Edit");
989 $widgetButtonLink = "pnotes_full.php?form_active=1";
990 $widgetButtonClass = "";
991 $linkMethod = "html";
992 $bodyClass = "notab";
995 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
996 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
997 $widgetAuth, $fixedWidth);
1001 <div style
='margin-left:10px' class='text'><img src
='../../pic/ajax-loader.gif'/></div
><br
/>
1005 <?php
if ( (acl_check('patients', 'med')) && ($GLOBALS['enable_cdr'] && $GLOBALS['enable_cdr_prw']) ) {
1006 echo "<tr><td width='650px'>";
1007 // patient reminders collapse widget
1008 $widgetTitle = xl("Patient Reminders");
1009 $widgetLabel = "patient_reminders";
1010 $widgetButtonLabel = xl("Edit");
1011 $widgetButtonLink = "../reminder/patient_reminders.php?mode=simple&patient_id=".$pid;
1012 $widgetButtonClass = "";
1013 $linkMethod = "html";
1014 $bodyClass = "notab";
1017 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth); ?
>
1019 <div style
='margin-left:10px' class='text'><image src
='../../pic/ajax-loader.gif'/></div
><br
/>
1023 <?php
} //end if prw is activated ?>
1028 // disclosures expand collapse widget
1029 $widgetTitle = xl("Disclosures");
1030 $widgetLabel = "disclosures";
1031 $widgetButtonLabel = xl("Edit");
1032 $widgetButtonLink = "disclosure_full.php";
1033 $widgetButtonClass = "";
1034 $linkMethod = "html";
1035 $bodyClass = "notab";
1038 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
1039 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
1040 $widgetAuth, $fixedWidth);
1043 <div style
='margin-left:10px' class='text'><img src
='../../pic/ajax-loader.gif'/></div
><br
/>
1047 <?php
if ($GLOBALS['amendments']) { ?
>
1050 <?php
// Amendments widget
1051 $widgetTitle = xlt('Amendments');
1052 $widgetLabel = "amendments";
1053 $widgetButtonLabel = xlt("Edit");
1054 $widgetButtonLink = $GLOBALS['webroot'] . "/interface/patient_file/summary/main_frameset.php?feature=amendment";
1055 $widgetButtonClass = "iframe rx_modal";
1056 $linkMethod = "html";
1057 $bodyClass = "summary_item small";
1059 $fixedWidth = false;
1060 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
1061 $sql = "SELECT * FROM amendments WHERE pid = ? ORDER BY amendment_date DESC";
1062 $result = sqlStatement($sql, array($pid) );
1064 if (sqlNumRows($result) == 0) {
1065 echo " <table><tr>\n";
1066 echo " <td colspan='$numcols' class='text'> " . xlt('None') . "</td>\n";
1067 echo " </tr></table>\n";
1070 while ($row=sqlFetchArray($result)){
1071 echo " ";
1072 echo "<a class= '" . $widgetButtonClass . "' href='" . $widgetButtonLink . "&id=" . attr($row['amendment_id']) . "' onclick='top.restoreSession()'>" . text($row['amendment_date']);
1073 echo " " . text($row['amendment_desc']);
1083 <?php
// labdata expand collapse widget
1084 $widgetTitle = xl("Labs");
1085 $widgetLabel = "labdata";
1086 $widgetButtonLabel = xl("Trend");
1087 $widgetButtonLink = "../summary/labdata.php";#"../encounter/trend_form.php?formname=labdata";
1088 $widgetButtonClass = "";
1089 $linkMethod = "html";
1090 $bodyClass = "notab";
1091 // check to see if any labdata exist
1092 $spruch = "SELECT procedure_report.date_collected AS date " .
1093 "FROM procedure_report " .
1094 "JOIN procedure_order ON procedure_report.procedure_order_id = procedure_order.procedure_order_id " .
1095 "WHERE procedure_order.patient_id = ? " .
1096 "ORDER BY procedure_report.date_collected DESC ";
1097 $existLabdata = sqlQuery($spruch, array($pid) );
1098 if ($existLabdata) {
1102 $widgetAuth = false;
1105 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
1106 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
1107 $widgetAuth, $fixedWidth);
1110 <div style
='margin-left:10px' class='text'><img src
='../../pic/ajax-loader.gif'/></div
><br
/>
1114 <?php
// end labdata ?>
1119 <?php
if ($vitals_is_registered && acl_check('patients', 'med')) { ?
>
1122 <?php
// vitals expand collapse widget
1123 $widgetTitle = xl("Vitals");
1124 $widgetLabel = "vitals";
1125 $widgetButtonLabel = xl("Trend");
1126 $widgetButtonLink = "../encounter/trend_form.php?formname=vitals";
1127 $widgetButtonClass = "";
1128 $linkMethod = "html";
1129 $bodyClass = "notab";
1130 // check to see if any vitals exist
1131 $existVitals = sqlQuery("SELECT * FROM form_vitals WHERE pid=?", array($pid) );
1136 $widgetAuth = false;
1139 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
1140 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
1141 $widgetAuth, $fixedWidth);
1144 <div style
='margin-left:10px' class='text'><img src
='../../pic/ajax-loader.gif'/></div
><br
/>
1148 <?php
} // end if ($vitals_is_registered && acl_check('patients', 'med')) ?>
1151 // This generates a section similar to Vitals for each LBF form that
1152 // supports charting. The form ID is used as the "widget label".
1154 $gfres = sqlStatement("SELECT option_id, title FROM list_options WHERE " .
1155 "list_id = 'lbfnames' AND " .
1156 "option_value > 0 AND activity = 1 " .
1157 "ORDER BY seq, title");
1158 while($gfrow = sqlFetchArray($gfres)) {
1162 <?php
// vitals expand collapse widget
1163 $vitals_form_id = $gfrow['option_id'];
1164 $widgetTitle = $gfrow['title'];
1165 $widgetLabel = $vitals_form_id;
1166 $widgetButtonLabel = xl("Trend");
1167 $widgetButtonLink = "../encounter/trend_form.php?formname=$vitals_form_id";
1168 $widgetButtonClass = "";
1169 $linkMethod = "html";
1170 $bodyClass = "notab";
1171 // check to see if any instances exist for this patient
1172 $existVitals = sqlQuery(
1173 "SELECT * FROM forms WHERE pid = ? AND formdir = ? AND deleted = 0",
1174 array($pid, $vitals_form_id));
1175 $widgetAuth = $existVitals ?
true : false;
1177 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
1178 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
1179 $widgetAuth, $fixedWidth);
1182 <div style
='margin-left:10px' class='text'>
1183 <image src
='../../pic/ajax-loader.gif'/>
1186 </div
> <!-- This is required by
expand_collapse_widget(). -->
1196 <!-- end left column div
-->
1198 <!-- start right column div
-->
1207 // If there is an ID Card or any Photos show the widget
1208 $photos = pic_array($pid, $GLOBALS['patient_photo_category_name']);
1209 if ($photos or $idcard_doc_id )
1211 $widgetTitle = xl("ID Card") . '/' . xl("Photos");
1212 $widgetLabel = "photos";
1213 $linkMethod = "javascript";
1214 $bodyClass = "notab-right";
1215 $widgetAuth = false;
1216 $fixedWidth = false;
1217 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel ,
1218 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
1219 $widgetAuth, $fixedWidth);
1223 if ($idcard_doc_id) {
1224 image_widget($idcard_doc_id, $GLOBALS['patient_id_category_name']);
1227 foreach ($photos as $photo_doc_id) {
1228 image_widget($photo_doc_id, $GLOBALS['patient_photo_category_name']);
1237 // Advance Directives
1238 if ($GLOBALS['advance_directives_warning']) {
1239 // advance directives expand collapse widget
1240 $widgetTitle = xl("Advance Directives");
1241 $widgetLabel = "directives";
1242 $widgetButtonLabel = xl("Edit");
1243 $widgetButtonLink = "return advdirconfigure();";
1244 $widgetButtonClass = "";
1245 $linkMethod = "javascript";
1246 $bodyClass = "summary_item small";
1248 $fixedWidth = false;
1249 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
1250 $counterFlag = false; //flag to record whether any categories contain ad records
1251 $query = "SELECT id FROM categories WHERE name='Advance Directive'";
1252 $myrow2 = sqlQuery($query);
1254 $parentId = $myrow2['id'];
1255 $query = "SELECT id, name FROM categories WHERE parent=?";
1256 $resNew1 = sqlStatement($query, array($parentId) );
1257 while ($myrows3 = sqlFetchArray($resNew1)) {
1258 $categoryId = $myrows3['id'];
1259 $nameDoc = $myrows3['name'];
1260 $query = "SELECT documents.date, documents.id " .
1262 "INNER JOIN categories_to_documents " .
1263 "ON categories_to_documents.document_id=documents.id " .
1264 "WHERE categories_to_documents.category_id=? " .
1265 "AND documents.foreign_id=? " .
1266 "ORDER BY documents.date DESC";
1267 $resNew2 = sqlStatement($query, array($categoryId, $pid) );
1268 $limitCounter = 0; // limit to one entry per category
1269 while (($myrows4 = sqlFetchArray($resNew2)) && ($limitCounter == 0)) {
1270 $dateTimeDoc = $myrows4['date'];
1271 // remove time from datetime stamp
1272 $tempParse = explode(" ",$dateTimeDoc);
1273 $dateDoc = $tempParse[0];
1274 $idDoc = $myrows4['id'];
1275 echo "<a href='$web_root/controller.php?document&retrieve&patient_id=" .
1276 htmlspecialchars($pid,ENT_QUOTES
) . "&document_id=" .
1277 htmlspecialchars($idDoc,ENT_QUOTES
) . "&as_file=true' onclick='top.restoreSession()'>" .
1278 htmlspecialchars(xl_document_category($nameDoc),ENT_NOQUOTES
) . "</a> " .
1279 htmlspecialchars($dateDoc,ENT_NOQUOTES
);
1281 $limitCounter = $limitCounter +
1;
1282 $counterFlag = true;
1286 if (!$counterFlag) {
1287 echo " " . htmlspecialchars(xl('None'),ENT_NOQUOTES
);
1290 <?php
} // close advanced dir block
1292 // This is a feature for a specific client. -- Rod
1293 if ($GLOBALS['cene_specific']) {
1296 $imagedir = $GLOBALS['OE_SITE_DIR'] . "/documents/$pid/demographics";
1297 $imagepath = "$web_root/sites/" . $_SESSION['site_id'] . "/documents/$pid/demographics";
1299 echo " <a href='' onclick=\"return sendimage($pid, 'photo');\" " .
1300 "title='Click to attach patient image'>\n";
1301 if (is_file("$imagedir/photo.jpg")) {
1302 echo " <img src='$imagepath/photo.jpg' /></a>\n";
1304 echo " Attach Patient Image</a><br />\n";
1306 echo " <br /> <br />\n";
1308 echo " <a href='' onclick=\"return sendimage($pid, 'fingerprint');\" " .
1309 "title='Click to attach fingerprint'>\n";
1310 if (is_file("$imagedir/fingerprint.jpg")) {
1311 echo " <img src='$imagepath/fingerprint.jpg' /></a>\n";
1313 echo " Attach Biometric Fingerprint</a><br />\n";
1315 echo " <br /> <br />\n";
1318 // Show Clinical Reminders for any user that has rules that are permitted.
1319 $clin_rem_check = resolve_rules_sql('','0',TRUE,'',$_SESSION['authUser']);
1320 if ( (!empty($clin_rem_check)) && ($GLOBALS['enable_cdr'] && $GLOBALS['enable_cdr_crw']) ) {
1321 // clinical summary expand collapse widget
1322 $widgetTitle = xl("Clinical Reminders");
1323 $widgetLabel = "clinical_reminders";
1324 $widgetButtonLabel = xl("Edit");
1325 $widgetButtonLink = "../reminder/clinical_reminders.php?patient_id=".$pid;;
1326 $widgetButtonClass = "";
1327 $linkMethod = "html";
1328 $bodyClass = "summary_item small";
1330 $fixedWidth = false;
1331 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
1333 echo "<div style='margin-left:10px' class='text'><image src='../../pic/ajax-loader.gif'/></div><br/>";
1338 // Show current and upcoming appointments.
1340 // Recurring appointment support and Appointment Display Sets
1341 // added to Appointments by Ian Jardine ( epsdky ).
1343 if (isset($pid) && !$GLOBALS['disable_calendar']) {
1345 $current_date2 = date('Y-m-d');
1347 $apptNum = (int)$GLOBALS['number_of_appts_to_show'];
1348 if($apptNum != 0) $apptNum2 = abs($apptNum);
1349 else $apptNum2 = 10;
1351 $mode1 = !$GLOBALS['appt_display_sets_option'];
1352 $colorSet1 = $GLOBALS['appt_display_sets_color_1'];
1353 $colorSet2 = $GLOBALS['appt_display_sets_color_2'];
1354 $colorSet3 = $GLOBALS['appt_display_sets_color_3'];
1355 $colorSet4 = $GLOBALS['appt_display_sets_color_4'];
1357 if($mode1) $extraAppts = 1;
1358 else $extraAppts = 6;
1359 $events = fetchNextXAppts($current_date2, $pid, $apptNum2 +
$extraAppts, true);
1363 $apptNumber = count($events);
1365 if($apptNumber <= $apptNum2) {
1366 $extraApptDate = '';
1368 } else if($mode1 && $apptNumber == $apptNum2 +
1) {
1369 $extraApptDate = $events[$apptNumber - 1]['pc_eventDate'];
1374 } else if($apptNumber == $apptNum2 +
6) {
1375 $extraApptDate = $events[$apptNumber - 1]['pc_eventDate'];
1380 } else { // mode 2 - $apptNum2 < $apptNumber < $apptNum2 + 6
1381 $extraApptDate = '';
1386 $limitApptIndx = $apptNum2 - 1;
1387 $limitApptDate = $events[$limitApptIndx]['pc_eventDate'];
1389 switch ($selectNum) {
1392 $lastApptIndx = $apptNumber - 1;
1393 $thisNumber = $lastApptIndx - $limitApptIndx;
1394 for($i = 1; $i <= $thisNumber; ++
$i) {
1395 if($events[$limitApptIndx +
$i]['pc_eventDate'] != $limitApptDate) {
1396 $extraApptDate = $events[$limitApptIndx +
$i]['pc_eventDate'];
1397 $events = array_slice($events, 0, $limitApptIndx +
$i);
1404 for($i = 1; $i <= $limitApptIndx; ++
$i) {
1405 if($events[$limitApptIndx - $i]['pc_eventDate'] != $limitApptDate) {
1406 $firstApptIndx = $apptNum2 - $i;
1413 if($extraApptDate) {
1414 if($extraApptDate != $limitApptDate) $apptStyle2 = " style='background-color:" . attr($colorSet3) . ";'";
1415 else $apptStyle2 = " style='background-color:" . attr($colorSet4) . ";'";
1420 // appointments expand collapse widget
1421 $widgetTitle = xl("Appointments");
1422 $widgetLabel = "appointments";
1423 $widgetButtonLabel = xl("Add");
1424 $widgetButtonLink = "return newEvt();";
1425 $widgetButtonClass = "";
1426 $linkMethod = "javascript";
1427 $bodyClass = "summary_item small";
1428 $widgetAuth = $resNotNull; // $resNotNull reflects state of query in fetchAppointments
1429 $fixedWidth = false;
1430 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
1435 $therapyGroupCategories = array();
1436 $query = sqlStatement("SELECT pc_catid FROM openemr_postcalendar_categories WHERE pc_cattype = 3 AND pc_active = 1");
1437 while ($result = sqlFetchArray($query)){
1438 $therapyGroupCategories[] = $result['pc_catid'];
1442 foreach($events as $row) { //////
1444 $dayname = date("l", strtotime($row['pc_eventDate'])); //////
1446 $disphour = substr($row['pc_startTime'], 0, 2) +
0;
1447 $dispmin = substr($row['pc_startTime'], 3, 2);
1448 if ($disphour >= 12) {
1450 if ($disphour > 12) $disphour -= 12;
1452 $etitle = xl('(Click to edit)');
1453 if ($row['pc_hometext'] != "") {
1454 $etitle = xl('Comments').": ".($row['pc_hometext'])."\r\n".$etitle;
1457 if($extraApptDate && $count > $firstApptIndx) {
1458 $apptStyle = $apptStyle2;
1460 if($row['pc_eventDate'] != $priorDate) {
1461 $priorDate = $row['pc_eventDate'];
1462 $toggleSet = !$toggleSet;
1464 if($toggleSet) $apptStyle = " style='background-color:" . attr($colorSet2) . ";'";
1465 else $apptStyle = " style='background-color:" . attr($colorSet1) . ";'";
1468 echo "<div " . $apptStyle . ">";
1469 if(!in_array($row['pc_catid'], $therapyGroupCategories)){
1470 echo "<a href='javascript:oldEvt(" . htmlspecialchars(preg_replace("/-/", "", $row['pc_eventDate']),ENT_QUOTES
) . ', ' . htmlspecialchars($row['pc_eid'],ENT_QUOTES
) . ")' title='" . htmlspecialchars($etitle,ENT_QUOTES
) . "'>";
1472 echo "<span title='" . htmlspecialchars($etitle,ENT_QUOTES
) . "'>";
1474 echo "<b>" . htmlspecialchars($row['pc_eventDate'],ENT_NOQUOTES
) . ", ";
1475 echo htmlspecialchars(sprintf("%02d", $disphour) .":$dispmin " . xl($dispampm) . " (" . xl($dayname),ENT_NOQUOTES
) . ")</b> ";
1476 if ($row['pc_recurrtype']) echo "<img src='" . $GLOBALS['webroot'] . "/interface/main/calendar/modules/PostCalendar/pntemplates/default/images/repeating8.png' border='0' style='margin:0px 2px 0px 2px;' title='".htmlspecialchars(xl("Repeating event"),ENT_QUOTES
)."' alt='".htmlspecialchars(xl("Repeating event"),ENT_QUOTES
)."'>";
1477 echo "<span title='" . generate_display_field(array('data_type'=>'1','list_id'=>'apptstat'),$row['pc_apptstatus']) . "'>";
1478 echo "<br>" . xlt('Status') . "( " . htmlspecialchars($row['pc_apptstatus'],ENT_NOQUOTES
) . " ) </span>";
1479 echo htmlspecialchars(xl_appt_category($row['pc_catname']),ENT_NOQUOTES
) . "\n";
1480 if(in_array($row['pc_catid'], $therapyGroupCategories)) echo "<br><span>" . xlt('Group name') .": " . text(getGroup($row['pc_gid'])['group_name']) . "</span>\n";
1481 if ($row['pc_hometext']) echo " <span style='color:green'> Com</span>";
1482 echo "<br>" . htmlspecialchars($row['ufname'] . " " . $row['ulname'],ENT_NOQUOTES
);
1483 echo !in_array($row['pc_catid'], $therapyGroupCategories) ?
'</a>' : '<span>';
1487 if ($resNotNull) { //////
1489 echo " " . htmlspecialchars(xl('None'),ENT_NOQUOTES
);
1491 if($extraApptDate) echo "<div style='color:#0000cc;'><b>" . attr($extraApptDate) . " ( + ) </b></div>";
1492 else echo "<div><hr></div>";
1496 } // End of Appointments.
1499 /* Widget that shows recurrences for appointments. */
1500 if (isset($pid) && !$GLOBALS['disable_calendar'] && $GLOBALS['appt_recurrences_widget']) {
1502 $widgetTitle = xl("Recurrent Appointments");
1503 $widgetLabel = "recurrent_appointments";
1504 $widgetButtonLabel = xl("Add");
1505 $widgetButtonLink = "return newEvt();";
1506 $widgetButtonClass = "";
1507 $linkMethod = "javascript";
1508 $bodyClass = "summary_item small";
1509 $widgetAuth = false;
1510 $fixedWidth = false;
1511 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel, $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
1516 //Fetch patient's recurrences. Function returns array with recurrence appointments' category, recurrence pattern (interpreted), and end date.
1517 $recurrences = fetchRecurrences($pid);
1518 if($recurrences[0] == false){ //if there are no recurrent appointments:
1520 echo "<span>" . xlt('None') . "</span>";
1525 foreach ($recurrences as $row) {
1526 //checks if there are recurrences and if they are current (git didn't end yet)
1527 if ($row == false ||
!recurrence_is_current($row['pc_endDate']))
1530 echo "<span>" . xlt('Appointment Category') . ': ' . xlt($row['pc_catname']) . "</span>";
1532 echo "<span>" . xlt('Recurrence') . ': ' . text($row['pc_recurrspec']) . "</span>";
1534 $red_text = ""; //if ends in a week, make font red
1535 if (ends_in_a_week($row['pc_endDate'])) {
1536 $red_text = " style=\"color:red;\" ";
1538 echo "<span" . $red_text . ">" . xlt('End Date') . ': ' . text($row['pc_endDate']) . "</span>";
1544 /* End of recurrence widget */
1547 // Show PAST appointments.
1548 // added by Terry Hill to allow reverse sorting of the appointments
1550 if ($GLOBALS['num_past_appointments_to_show'] < 0) {
1551 $direction = "DESC";
1552 ($showpast = -1 * $GLOBALS['num_past_appointments_to_show'] );
1556 $showpast = $GLOBALS['num_past_appointments_to_show'];
1559 if (isset($pid) && !$GLOBALS['disable_calendar'] && $showpast > 0) {
1560 $query = "SELECT e.pc_eid, e.pc_aid, e.pc_title, e.pc_eventDate, " .
1561 "e.pc_startTime, e.pc_hometext, u.fname, u.lname, u.mname, " .
1562 "c.pc_catname, e.pc_apptstatus " .
1563 "FROM openemr_postcalendar_events AS e, users AS u, " .
1564 "openemr_postcalendar_categories AS c WHERE " .
1565 "e.pc_pid = ? AND e.pc_eventDate < CURRENT_DATE AND " .
1566 "u.id = e.pc_aid AND e.pc_catid = c.pc_catid " .
1567 "ORDER BY e.pc_eventDate $direction , e.pc_startTime DESC " .
1568 "LIMIT " . $showpast;
1570 $pres = sqlStatement($query, array($pid) );
1572 // appointments expand collapse widget
1573 $widgetTitle = xl("Past Appointments");
1574 $widgetLabel = "past_appointments";
1575 $widgetButtonLabel = '';
1576 $widgetButtonLink = '';
1577 $widgetButtonClass = '';
1578 $linkMethod = "javascript";
1579 $bodyClass = "summary_item small";
1580 $widgetAuth = false; //no button
1581 $fixedWidth = false;
1582 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
1584 while($row = sqlFetchArray($pres)) {
1586 $dayname = date("l", strtotime($row['pc_eventDate']));
1588 $disphour = substr($row['pc_startTime'], 0, 2) +
0;
1589 $dispmin = substr($row['pc_startTime'], 3, 2);
1590 if ($disphour >= 12) {
1592 if ($disphour > 12) $disphour -= 12;
1594 if ($row['pc_hometext'] != "") {
1595 $etitle = xl('Comments').": ".($row['pc_hometext'])."\r\n".$etitle;
1597 echo "<a href='javascript:oldEvt(" . htmlspecialchars(preg_replace("/-/", "", $row['pc_eventDate']),ENT_QUOTES
) . ', ' . htmlspecialchars($row['pc_eid'],ENT_QUOTES
) . ")' title='" . htmlspecialchars($etitle,ENT_QUOTES
) . "'>";
1598 echo "<b>" . htmlspecialchars(xl($dayname) . ", " . $row['pc_eventDate'],ENT_NOQUOTES
) . "</b>" . xlt("Status") . "(";
1599 echo " " . generate_display_field(array('data_type'=>'1','list_id'=>'apptstat'),$row['pc_apptstatus']) . ")<br>"; // can't use special char parser on this
1600 echo htmlspecialchars("$disphour:$dispmin ") . xl($dispampm) . " ";
1601 echo htmlspecialchars($row['fname'] . " " . $row['lname'],ENT_NOQUOTES
) . "</a><br>\n";
1603 if (isset($pres) && $res != null) {
1605 echo " " . htmlspecialchars(xl('None'),ENT_NOQUOTES
);
1610 // END of past appointments
1615 <div id
='stats_div'>
1617 <div style
='margin-left:10px' class='text'><img src
='../../pic/ajax-loader.gif'/></div
><br
/>
1622 <?php
// TRACK ANYTHING -----
1624 // Determine if track_anything form is in use for this site.
1625 $tmp = sqlQuery("SELECT count(*) AS count FROM registry WHERE " .
1626 "directory = 'track_anything' AND state = 1");
1627 $track_is_registered = $tmp['count'];
1628 if($track_is_registered){
1630 // track_anything expand collapse widget
1631 $widgetTitle = xl("Tracks");
1632 $widgetLabel = "track_anything";
1633 $widgetButtonLabel = xl("Tracks");
1634 $widgetButtonLink = "../../forms/track_anything/create.php";
1635 $widgetButtonClass = "";
1636 $widgetAuth = ""; // don't show the button
1637 $linkMethod = "html";
1638 $bodyClass = "notab";
1639 // check to see if any tracks exist
1640 $spruch = "SELECT id " .
1644 $existTracks = sqlQuery($spruch, array($pid, "track_anything") );
1646 $fixedWidth = false;
1647 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
1648 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
1649 $widgetAuth, $fixedWidth);
1652 <div style
='margin-left:10px' class='text'><img src
='../../pic/ajax-loader.gif'/></div
><br
/>
1656 <?php
} // end track_anything ?>
1659 </div
> <!-- end right column div
-->
1666 </div
> <!-- end main content div
-->
1668 <script language
='JavaScript'>
1669 // Array of skip conditions for the checkSkipConditions() function.
1671 <?php
echo $condition_str; ?
>
1673 checkSkipConditions();