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@sparmy.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/classes/Address.class.php");
34 require_once("$srcdir/classes/InsuranceCompany.class.php");
35 require_once("$srcdir/classes/Document.class.php");
36 require_once("$srcdir/options.inc.php");
37 require_once("../history/history.inc.php");
38 require_once("$srcdir/formatting.inc.php");
39 require_once("$srcdir/edi.inc");
40 require_once("$srcdir/invoice_summary.inc.php");
41 require_once("$srcdir/clinical_rules.php");
42 require_once("$srcdir/options.js.php");
44 require_once(dirname(__FILE__
)."/../../../library/appointments.inc.php");
46 if (isset($_GET['set_pid'])) {
47 include_once("$srcdir/pid.inc");
48 setpid($_GET['set_pid']);
51 $active_reminders = false;
52 $all_allergy_alerts = false;
53 if ($GLOBALS['enable_cdr']) {
55 if ($GLOBALS['enable_allergy_check'] && $GLOBALS['enable_alert_log']) {
56 //Check for new allergies conflicts and throw popup if any exist(note need alert logging to support this)
57 $new_allergy_alerts = allergy_conflict($pid,'new',$_SESSION['authUser']);
58 if (!empty($new_allergy_alerts)) {
59 $pop_warning = '<script type="text/javascript">alert(\'' . xls('WARNING - FOLLOWING ACTIVE MEDICATIONS ARE ALLERGIES') . ':\n';
60 foreach ($new_allergy_alerts as $new_allergy_alert) {
61 $pop_warning .= addslashes($new_allergy_alert) . '\n';
63 $pop_warning .= '\')</script>';
67 if ((!isset($_SESSION['alert_notify_pid']) ||
($_SESSION['alert_notify_pid'] != $pid)) && isset($_GET['set_pid']) && $GLOBALS['enable_cdr_crp']) {
68 // showing a new patient, so check for active reminders and allergy conflicts, which use in active reminder popup
69 $active_reminders = active_alert_summary($pid,"reminders-due",'','default',$_SESSION['authUser'],TRUE);
70 if ($GLOBALS['enable_allergy_check']) {
71 $all_allergy_alerts = allergy_conflict($pid,'all',$_SESSION['authUser'],TRUE);
76 function print_as_money($money) {
77 preg_match("/(\d*)\.?(\d*)/",$money,$moneymatches);
78 $tmp = wordwrap(strrev($moneymatches[1]),3,",",1);
79 $ccheck = strrev($tmp);
80 if ($ccheck[0] == ",") {
81 $tmp = substr($ccheck,1,strlen($ccheck)-1);
83 if ($moneymatches[2] != "") {
84 return "$ " . strrev($tmp) . "." . $moneymatches[2];
86 return "$ " . strrev($tmp);
90 // get an array from Photos category
91 function pic_array($pid,$picture_directory) {
93 $sql_query = "select documents.id from documents join categories_to_documents " .
94 "on documents.id = categories_to_documents.document_id " .
95 "join categories on categories.id = categories_to_documents.category_id " .
96 "where categories.name like ? and documents.foreign_id = ?";
97 if ($query = sqlStatement($sql_query, array($picture_directory,$pid))) {
98 while( $results = sqlFetchArray($query) ) {
99 array_push($pics,$results['id']);
104 // Get the document ID of the first document in a specific catg.
105 function get_document_by_catg($pid,$doc_catg) {
109 if ($pid and $doc_catg) {
110 $result = sqlQuery("SELECT d.id, d.date, d.url FROM " .
111 "documents AS d, categories_to_documents AS cd, categories AS c " .
112 "WHERE d.foreign_id = ? " .
113 "AND cd.document_id = d.id " .
114 "AND c.id = cd.category_id " .
115 "AND c.name LIKE ? " .
116 "ORDER BY d.date DESC LIMIT 1", array($pid, $doc_catg) );
119 return($result['id']);
122 // Display image in 'widget style'
123 function image_widget($doc_id,$doc_catg)
125 global $pid, $web_root;
126 $docobj = new Document($doc_id);
127 $image_file = $docobj->get_url_file();
128 $image_width = $GLOBALS['generate_doc_thumb'] == 1 ?
'' : 'width=100';
129 $extension = substr($image_file, strrpos($image_file,"."));
130 $viewable_types = array('.png','.jpg','.jpeg','.png','.bmp','.PNG','.JPG','.JPEG','.PNG','.BMP'); // image ext supported by fancybox viewer
131 if ( in_array($extension,$viewable_types) ) { // extention matches list
132 $to_url = "<td> <a href = $web_root" .
133 "/controller.php?document&retrieve&patient_id=$pid&document_id=$doc_id&as_file=false&original_file=true&disable_exit=false&show_original=true" .
134 "/tmp$extension" . // Force image type URL for fancybo
135 " onclick=top.restoreSession(); class='image_modal'>" .
136 " <img src = $web_root" .
137 "/controller.php?document&retrieve&patient_id=$pid&document_id=$doc_id&as_file=false" .
138 " $image_width alt='$doc_catg:$image_file'> </a> </td> <td valign='center'>".
139 htmlspecialchars($doc_catg) . '<br /> ' . htmlspecialchars($image_file) .
143 $to_url = "<td> <a href='" . $web_root . "/controller.php?document&retrieve" .
144 "&patient_id=$pid&document_id=$doc_id'" .
145 " onclick='top.restoreSession()' class='css_button_small'>" .
147 htmlspecialchars( xl("View"), ENT_QUOTES
)."</a> " .
148 htmlspecialchars( "$doc_catg - $image_file", ENT_QUOTES
) .
153 echo "</tr></table>";
156 // Determine if the Vitals form is in use for this site.
157 $tmp = sqlQuery("SELECT count(*) AS count FROM registry WHERE " .
158 "directory = 'vitals' AND state = 1");
159 $vitals_is_registered = $tmp['count'];
161 // Get patient/employer/insurance information.
163 $result = getPatientData($pid, "*, DATE_FORMAT(DOB,'%Y-%m-%d') as DOB_YMD");
164 $result2 = getEmployerData($pid);
165 $result3 = getInsuranceData($pid, "primary", "copay, provider, DATE_FORMAT(`date`,'%Y-%m-%d') as effdate");
167 if ($result3['provider']) { // Use provider in case there is an ins record w/ unassigned insco
168 $insco_name = getInsuranceProvider($result3['provider']);
174 <?php
html_header_show();?
>
175 <link rel
="stylesheet" href
="<?php echo $css_header;?>" type
="text/css">
176 <link rel
="stylesheet" type
="text/css" href
="../../../library/js/fancybox/jquery.fancybox-1.2.6.css" media
="screen" />
177 <style type
="text/css">@import
url(../../../library
/dynarch_calendar
.css
);</style
>
178 <script type
="text/javascript" src
="../../../library/textformat.js"></script
>
179 <script type
="text/javascript" src
="../../../library/dynarch_calendar.js"></script
>
180 <?php
include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?
>
181 <script type
="text/javascript" src
="../../../library/dynarch_calendar_setup.js"></script
>
182 <script type
="text/javascript" src
="../../../library/dialog.js?v=<?php echo $v_js_includes; ?>"></script
>
183 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-6-4/index.js"></script
>
184 <script type
="text/javascript" src
="../../../library/js/common.js"></script
>
185 <script type
="text/javascript" src
="../../../library/js/fancybox/jquery.fancybox-1.2.6.js"></script
>
186 <script type
="text/javascript" language
="JavaScript">
188 var mypcc
= '<?php echo htmlspecialchars($GLOBALS['phone_country_code
'],ENT_QUOTES); ?>';
190 function oldEvt(apptdate
, eventid
) {
191 dlgopen('../../main/calendar/add_edit_event.php?date=' + apptdate +
'&eid=' + eventid
, '_blank', 775, 500);
194 function advdirconfigure() {
195 dlgopen('advancedirectives.php', '_blank', 500, 450);
198 function refreshme() {
199 top
.restoreSession();
203 // Process click on Delete link.
204 function deleteme() {
205 dlgopen('../deleter.php?patient=<?php echo htmlspecialchars($pid,ENT_QUOTES); ?>', '_blank', 500, 450);
209 // Called by the deleteme.php window on a successful delete.
210 function imdeleted() {
211 parent
.left_nav
.clearPatient();
215 dlgopen('../../main/calendar/add_edit_event.php?patientid=<?php echo htmlspecialchars($pid,ENT_QUOTES); ?>', '_blank', 775, 500);
219 function sendimage(pid
, what
) {
220 // alert('Not yet implemented.'); return false;
221 dlgopen('../upload_dialog.php?patientid=' + pid +
'&file=' + what
,
228 <script type
="text/javascript">
230 function toggleIndicator(target
,div
) {
232 $mode = $
(target
).find(".indicator").text();
233 if ( $mode == "<?php echo htmlspecialchars(xl('collapse'),ENT_QUOTES); ?>" ) {
234 $
(target
).find(".indicator").text( "<?php echo htmlspecialchars(xl('expand'),ENT_QUOTES); ?>" );
236 $
.post( "../../../library/ajax/user_settings.php", { target
: div
, mode
: 0 });
238 $
(target
).find(".indicator").text( "<?php echo htmlspecialchars(xl('collapse'),ENT_QUOTES); ?>" );
240 $
.post( "../../../library/ajax/user_settings.php", { target
: div
, mode
: 1 });
244 $
(document
).ready(function(){
247 if($GLOBALS['erx_enable']){
248 //$soap_status=sqlQuery("select soap_import_status from patient_data where pid=?",array($pid));
249 $soap_status=sqlStatement("select soap_import_status,pid from patient_data where pid=? and soap_import_status in ('1','3')",array($pid));
250 while($row_soapstatus=sqlFetchArray($soap_status)){
251 //if($soap_status['soap_import_status']=='1' || $soap_status['soap_import_status']=='3'){ ?>
252 top
.restoreSession();
255 url
: "../../soap_functions/soap_patientfullmedication.php",
258 patient
:<?php
echo $row_soapstatus['pid']; ?
>,
261 success
: function(thedata
){
263 msg_updation+
=thedata
;
271 //elseif($soap_status['soap_import_status']=='3'){ ?>
272 top
.restoreSession();
275 url
: "../../soap_functions/soap_allergy.php",
278 patient
:<?php
echo $row_soapstatus['pid']; ?
>,
281 success
: function(thedata
){
283 msg_updation+
=thedata
;
290 if($GLOBALS['erx_import_status_message']){ ?
>
300 $
("#stats_div").load("stats.php", { 'embeddedScreen' : true }, function() {
301 // (note need to place javascript code here also to get the dynamic link to work)
302 $
(".rx_modal").fancybox( {
303 'overlayOpacity' : 0.0,
304 'showCloseButton' : true,
307 'centerOnScroll' : false,
308 'callbackOnClose' : function() {
313 $
("#pnotes_ps_expand").load("pnotes_fragment.php");
314 $
("#disclosures_ps_expand").load("disc_fragment.php");
316 <?php
if ($GLOBALS['enable_cdr'] && $GLOBALS['enable_cdr_crw']) { ?
>
317 top
.restoreSession();
318 $
("#clinical_reminders_ps_expand").load("clinical_reminders_fragment.php", { 'embeddedScreen' : true }, function() {
319 // (note need to place javascript code here also to get the dynamic link to work)
320 $
(".medium_modal").fancybox( {
321 'overlayOpacity' : 0.0,
322 'showCloseButton' : true,
325 'centerOnScroll' : false,
326 'callbackOnClose' : function() {
333 <?php
if ($GLOBALS['enable_cdr'] && $GLOBALS['enable_cdr_prw']) { ?
>
334 top
.restoreSession();
335 $
("#patient_reminders_ps_expand").load("patient_reminders_fragment.php");
338 <?php
if ($vitals_is_registered && acl_check('patients', 'med')) { ?
>
339 // Initialize the Vitals form if it is registered and user is authorized.
340 $
("#vitals_ps_expand").load("vitals_fragment.php");
343 // Initialize track_anything
344 $
("#track_anything_ps_expand").load("track_anything_fragment.php");
347 // Initialize labdata
348 $
("#labdata_ps_expand").load("labdata_fragment.php");
350 // Initialize for each applicable LBF form.
351 $gfres = sqlStatement("SELECT option_id FROM list_options WHERE " .
352 "list_id = 'lbfnames' AND option_value > 0 AND activity = 1 ORDER BY seq, title");
353 while($gfrow = sqlFetchArray($gfres)) {
355 $
("#<?php echo $gfrow['option_id']; ?>_ps_expand").load("lbf_fragment.php?formname=<?php echo $gfrow['option_id']; ?>");
365 // modal for dialog boxes
366 $
(".large_modal").fancybox( {
367 'overlayOpacity' : 0.0,
368 'showCloseButton' : true,
371 'centerOnScroll' : false
374 // modal for image viewer
375 $
(".image_modal").fancybox( {
376 'overlayOpacity' : 0.0,
377 'showCloseButton' : true,
378 'centerOnScroll' : false,
382 $
(".iframe1").fancybox( {
384 'overlayOpacity' : 0.0,
385 'showCloseButton' : true,
389 // special size for patient portal
390 $
(".small_modal").fancybox( {
391 'overlayOpacity' : 0.0,
392 'showCloseButton' : true,
395 'centerOnScroll' : false
398 <?php
if ($active_reminders ||
$all_allergy_alerts) { ?
>
399 // show the active reminder modal
400 $
("#reminder_popup_link").fancybox({
401 'overlayOpacity' : 0.0,
402 'showCloseButton' : true,
405 'centerOnScroll' : false
411 // JavaScript stuff to do when a new patient is set.
413 function setMyPatient() {
414 // Avoid race conditions with loading of the left_nav or Title frame.
415 if (!parent
.allFramesLoaded()) {
416 setTimeout("setMyPatient()", 500);
419 <?php
if (isset($_GET['set_pid'])) { ?
>
420 parent
.left_nav
.setPatient(<?php
echo "'" . addslashes($result['fname']) . " " . addslashes($result['lname']) .
421 "'," . addslashes($pid) . ",'" . addslashes($result['pubpid']) .
422 "','', ' " . xls('DOB') . ": " . addslashes(oeFormatShortDate($result['DOB_YMD'])) . " " . xls('Age') . ": " . addslashes(getPatientAgeDisplay($result['DOB_YMD'])) . "'"; ?
>);
423 var EncounterDateArray
= new Array;
424 var CalendarCategoryArray
= new Array;
425 var EncounterIdArray
= new Array;
428 //Encounter details are stored to javacript as array.
429 $result4 = sqlStatement("SELECT fe.encounter,fe.date,openemr_postcalendar_categories.pc_catname FROM form_encounter AS fe ".
430 " left join openemr_postcalendar_categories on fe.pc_catid=openemr_postcalendar_categories.pc_catid WHERE fe.pid = ? order by fe.date desc", array($pid));
431 if(sqlNumRows($result4)>0) {
432 while($rowresult4 = sqlFetchArray($result4)) {
434 EncounterIdArray
[Count
] = '<?php echo addslashes($rowresult4['encounter
']); ?>';
435 EncounterDateArray
[Count
] = '<?php echo addslashes(oeFormatShortDate(date("Y-m-d", strtotime($rowresult4['date
'])))); ?>';
436 CalendarCategoryArray
[Count
] = '<?php echo addslashes(xl_appt_category($rowresult4['pc_catname
'])); ?>';
442 parent
.left_nav
.setPatientEncounter(EncounterIdArray
,EncounterDateArray
,CalendarCategoryArray
);
443 <?php
} // end setting new pid ?>
444 parent
.left_nav
.syncRadios();
445 <?php
if ( (isset($_GET['set_pid']) ) && (isset($_GET['set_encounterid'])) && ( intval($_GET['set_encounterid']) > 0 ) ) {
446 $encounter = intval($_GET['set_encounterid']);
447 $_SESSION['encounter'] = $encounter;
448 $query_result = sqlQuery("SELECT `date` FROM `form_encounter` WHERE `encounter` = ?", array($encounter)); ?
>
449 encurl
= 'encounter/encounter_top.php?set_encounter=' +
<?php
echo attr($encounter);?
> +
'&pid=' +
<?php
echo attr($pid);?
>;
450 <?php
if ($GLOBALS['new_tabs_layout']) { ?
>
451 parent
.left_nav
.setEncounter('<?php echo oeFormatShortDate(date("Y-m-d", strtotime($query_result['date
']))); ?>', '<?php echo attr($encounter); ?>', 'enc');
452 top
.restoreSession();
453 parent
.left_nav
.loadFrame('enc2', 'enc', 'patient_file/' + encurl
);
455 var othername
= (window
.name
== 'RTop') ?
'RBot' : 'RTop';
456 parent
.left_nav
.setEncounter('<?php echo oeFormatShortDate(date("Y-m-d", strtotime($query_result['date
']))); ?>', '<?php echo attr($encounter); ?>', othername
);
457 top
.restoreSession();
458 parent
.frames
[othername
].location
.href
= '../' + encurl
;
460 <?php
} // end setting new encounter id (only if new pid is also set) ?>
463 $
(window
).load(function() {
469 <style type
="css/text">
478 <body
class="body_top patient-demographics">
480 <a href
='../reminder/active_reminder_popup.php' id
='reminder_popup_link' style
='visibility: false;' class='iframe' onclick
='top.restoreSession()'></a
>
483 $thisauth = acl_check('patients', 'demo');
485 if ($result['squad'] && ! acl_check('squads', $result['squad'])) {
490 echo "<p>(" . htmlspecialchars(xl('Demographics not authorized'),ENT_NOQUOTES
) . ")</p>\n";
491 echo "</body>\n</html>\n";
496 <table
class="table_header">
500 <?php
echo htmlspecialchars(getPatientName($pid),ENT_NOQUOTES
); ?
>
503 <?php
if (acl_check('admin', 'super') && $GLOBALS['allow_pat_delete']) : ?
>
504 <td style
='padding-left:1em;' class="delete">
505 <a
class='css_button iframe'
506 href
='../deleter.php?patient="<?php echo htmlspecialchars($pid,ENT_QUOTES);?>'
507 onclick
='top.restoreSession()'>
508 <span
><?php
echo htmlspecialchars(xl('Delete'),ENT_NOQUOTES
);?
></span
>
511 <?php
endif; // Allow PT delete
512 if($GLOBALS['erx_enable']): ?
>
513 <td style
="padding-left:1em;" class="erx">
514 <a
class="css_button" href
="../../eRx.php?page=medentry" onclick
="top.restoreSession()">
515 <span
><?php
echo htmlspecialchars(xl('NewCrop MedEntry'),ENT_NOQUOTES
);?
></span
>
518 <td style
="padding-left:1em;">
519 <a
class="css_button iframe1"
520 href
="../../soap_functions/soap_accountStatusDetails.php"
521 onclick
="top.restoreSession()">
522 <span
><?php
echo htmlspecialchars(xl('NewCrop Account Status'),ENT_NOQUOTES
);?
></span
>
525 <td id
='accountstatus'></td
>
526 <?php
endif; // eRX Enabled
528 $portalUserSetting = true; //flag to see if patient has authorized access to portal
529 if($GLOBALS['portal_onsite_enable'] && $GLOBALS['portal_onsite_address']):
530 $portalStatus = sqlQuery("SELECT allow_patient_portal FROM patient_data WHERE pid=?",array($pid));
531 if ($portalStatus['allow_patient_portal']=='YES'):
532 $portalLogin = sqlQuery("SELECT pid FROM `patient_access_onsite` WHERE `pid`=?", array($pid));?
>
533 <td style
='padding-left:1em;'>
534 <a
class='css_button iframe small_modal'
535 href
='create_portallogin.php?portalsite=on&patient=<?php echo htmlspecialchars($pid,ENT_QUOTES);?>'
536 onclick
='top.restoreSession()'>
537 <?php
$display = (empty($portalLogin)) ?
xlt('Create Onsite Portal Credentials') : xlt('Reset Onsite Portal Credentials'); ?
>
538 <span
><?php
echo $display; ?
></span
>
543 $portalUserSetting = false;
544 endif; // allow patient portal
545 endif; // Onsite Patient Portal
546 if($GLOBALS['portal_offsite_enable'] && $GLOBALS['portal_offsite_address']):
547 $portalStatus = sqlQuery("SELECT allow_patient_portal FROM patient_data WHERE pid=?",array($pid));
548 if ($portalStatus['allow_patient_portal']=='YES'):
549 $portalLogin = sqlQuery("SELECT pid FROM `patient_access_offsite` WHERE `pid`=?", array($pid));
551 <td style
='padding-left:1em;'>
552 <a
class='css_button iframe small_modal'
553 href
='create_portallogin.php?portalsite=off&patient=<?php echo htmlspecialchars($pid,ENT_QUOTES);?>'
554 onclick
='top.restoreSession()'>
556 <?php
$text = (empty($portalLogin)) ?
xlt('Create Offsite Portal Credentials') : xlt('Reset Offsite Portal Credentials'); ?
>
563 $portalUserSetting = false;
564 endif; // allow_patient_portal
565 endif; // portal_offsite_enable
566 if (!($portalUserSetting)): // Show that the patient has not authorized portal access ?>
567 <td style
='padding-left:1em;'>
568 <?php
echo htmlspecialchars( xl('Patient has not authorized the Patient Portal.'), ENT_NOQUOTES
);?
>
573 // If patient is deceased, then show this (along with the number of days patient has been deceased for)
574 $days_deceased = is_patient_deceased($pid);
575 if ($days_deceased != null): ?
>
576 <td
class="deceased" style
="padding-left:1em;font-weight:bold;color:red">
578 if ($days_deceased == 0) {
579 echo xlt("DECEASED (Today)");
581 else if ($days_deceased == 1) {
582 echo xlt("DECEASED (1 day ago)");
585 echo xlt("DECEASED") . " (" . text($days_deceased) . " " . xlt("days ago") . ")";
597 // Get the document ID of the patient ID card if access to it is wanted here.
598 $idcard_doc_id = false;
599 if ($GLOBALS['patient_id_category_name']) {
600 $idcard_doc_id = get_document_by_catg($pid, $GLOBALS['patient_id_category_name']);
604 <table cellspacing
='0' cellpadding
='0' border
='0' class="subnav">
606 <td
class="small" colspan
='4'>
607 <a href
="../history/history.php" onclick
='top.restoreSession()'>
608 <?php
echo htmlspecialchars(xl('History'),ENT_NOQUOTES
); ?
></a
>
610 <?php
//note that we have temporarily removed report screen from the modal view ?>
611 <a href
="../report/patient_report.php" onclick
='top.restoreSession()'>
612 <?php
echo htmlspecialchars(xl('Report'),ENT_NOQUOTES
); ?
></a
>
614 <?php
//note that we have temporarily removed document screen from the modal view ?>
615 <a href
="../../../controller.php?document&list&patient_id=<?php echo $pid;?>" onclick
='top.restoreSession()'>
616 <?php
echo htmlspecialchars(xl('Documents'),ENT_NOQUOTES
); ?
></a
>
618 <a href
="../transaction/transactions.php" class='iframe large_modal' onclick
='top.restoreSession()'>
619 <?php
echo htmlspecialchars(xl('Transactions'),ENT_NOQUOTES
); ?
></a
>
621 <a href
="stats_full.php?active=all" onclick
='top.restoreSession()'>
622 <?php
echo htmlspecialchars(xl('Issues'),ENT_NOQUOTES
); ?
></a
>
624 <a href
="../../reports/pat_ledger.php?form=1&patient_id=<?php echo attr($pid);?>" onclick
='top.restoreSession()'>
625 <?php
echo xlt('Ledger'); ?
></a
>
627 <a href
="../../reports/external_data.php" onclick
='top.restoreSession()'>
628 <?php
echo xlt('External Data'); ?
></a
>
630 <!-- DISPLAYING HOOKS STARTS HERE
-->
632 $module_query = sqlStatement("SELECT msh.*,ms.menu_name,ms.path,m.mod_ui_name,m.type FROM modules_hooks_settings AS msh
633 LEFT OUTER JOIN modules_settings AS ms ON obj_name=enabled_hooks AND ms.mod_id=msh.mod_id
634 LEFT OUTER JOIN modules AS m ON m.mod_id=ms.mod_id
635 WHERE fld_type=3 AND mod_active=1 AND sql_run=1 AND attached_to='demographics' ORDER BY mod_id");
636 $DivId = 'mod_installer';
637 if (sqlNumRows($module_query)) {
640 while ($modulerow = sqlFetchArray($module_query)) {
641 $DivId = 'mod_'.$modulerow['mod_id'];
642 $new_category = $modulerow['mod_ui_name'];
645 if($modulerow['type'] == 0) {
646 $modulePath = $GLOBALS['customModDir'];
651 $modulePath = $GLOBALS['zendModDir'];
653 $relative_link = "../../modules/".$modulePath."/".$modulerow['path'];
654 $nickname = $modulerow['menu_name'] ?
$modulerow['menu_name'] : 'Noname';
656 $modid = $modulerow['mod_id'];
659 <a href
="<?php echo $relative_link; ?>" onclick
='top.restoreSession()'>
660 <?php
echo xlt($nickname); ?
></a
>
665 <!-- DISPLAYING HOOKS ENDS HERE
-->
669 </table
> <!-- end header
-->
671 <div style
='margin-top:10px' class="main"> <!-- start main content div
-->
672 <table border
="0" cellspacing
="0" cellpadding
="0" width
="100%">
674 <td
class="demographics-box" align
="left" valign
="top">
675 <!-- start left column div
-->
676 <div style
='float:left; margin-right:20px'>
678 <table cellspacing
=0 cellpadding
=0>
679 <?php
if (!$GLOBALS['hide_billing_widget']) { ?
>
683 // Billing expand collapse widget
684 $widgetTitle = xl("Billing");
685 $widgetLabel = "billing";
686 $widgetButtonLabel = xl("Edit");
687 $widgetButtonLink = "return newEvt();";
688 $widgetButtonClass = "";
689 $linkMethod = "javascript";
690 $bodyClass = "notab";
693 if ($GLOBALS['force_billing_widget_open']) {
694 $forceExpandAlways = true;
697 $forceExpandAlways = false;
699 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
700 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
701 $widgetAuth, $fixedWidth, $forceExpandAlways);
705 //PATIENT BALANCE,INS BALANCE naina@capminds.com
706 $patientbalance = get_patient_balance($pid, false);
707 //Debit the patient balance from insurance balance
708 $insurancebalance = get_patient_balance($pid, true) - $patientbalance;
709 $totalbalance=$patientbalance +
$insurancebalance;
711 // Show current balance and billing note, if any.
712 echo "<table border='0'><tr><td>" .
713 "<table ><tr><td><span class='bold'><font color='red'>" .
714 xlt('Patient Balance Due') .
715 " : " . text(oeFormatMoney($patientbalance)) .
716 "</font></span></td></tr>".
717 "<tr><td><span class='bold'><font color='red'>" .
718 xlt('Insurance Balance Due') .
719 " : " . text(oeFormatMoney($insurancebalance)) .
720 "</font></span></td></tr>".
721 "<tr><td><span class='bold'><font color='red'>" .
722 xlt('Total Balance Due').
723 " : " . text(oeFormatMoney($totalbalance)) .
724 "</font></span></td></td></tr>";
725 if (!empty($result['billing_note'])) {
726 echo "<tr><td><span class='bold'><font color='red'>" .
727 xlt('Billing Note') . ":" .
728 text($result['billing_note']) .
729 "</font></span></td></tr>";
731 if ($result3['provider']) { // Use provider in case there is an ins record w/ unassigned insco
732 echo "<tr><td><span class='bold'>" .
733 xlt('Primary Insurance') . ': ' . text($insco_name) .
734 "</span> ";
735 if ($result3['copay'] > 0) {
736 echo "<span class='bold'>" .
737 xlt('Copay') . ': ' . text($result3['copay']) .
738 "</span> ";
740 echo "<span class='bold'>" .
741 xlt('Effective Date') . ': ' . text(oeFormatShortDate($result3['effdate'])) .
744 echo "</table></td></tr></td></tr></table><br>";
747 </div
> <!-- required
for expand_collapse_widget
-->
754 // Demographics expand collapse widget
755 $widgetTitle = xl("Demographics");
756 $widgetLabel = "demographics";
757 $widgetButtonLabel = xl("Edit");
758 $widgetButtonLink = "demographics_full.php";
759 $widgetButtonClass = "";
760 $linkMethod = "html";
762 $widgetAuth = acl_check('patients', 'demo', '', 'write');
764 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
765 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
766 $widgetAuth, $fixedWidth);
770 <?php
display_layout_tabs('DEM', $result, $result2); ?
>
772 <div
class="tabContainer">
773 <?php
display_layout_tabs_data('DEM', $result, $result2); ?
>
776 </div
> <!-- required
for expand_collapse_widget
-->
783 $insurance_count = 0;
784 foreach (array('primary','secondary','tertiary') as $instype) {
785 $enddate = 'Present';
786 $query = "SELECT * FROM insurance_data WHERE " .
787 "pid = ? AND type = ? " .
788 "ORDER BY date DESC";
789 $res = sqlStatement($query, array($pid, $instype) );
790 while( $row = sqlFetchArray($res) ) {
791 if ($row['provider'] ) $insurance_count++
;
795 if ( $insurance_count > 0 ) {
796 // Insurance expand collapse widget
797 $widgetTitle = xl("Insurance");
798 $widgetLabel = "insurance";
799 $widgetButtonLabel = xl("Edit");
800 $widgetButtonLink = "demographics_full.php";
801 $widgetButtonClass = "";
802 $linkMethod = "html";
804 $widgetAuth = acl_check('patients', 'demo', '', 'write');
806 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
807 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
808 $widgetAuth, $fixedWidth);
810 if ( $insurance_count > 0 ) {
813 <ul
class="tabNav"><?php
814 ///////////////////////////////// INSURANCE SECTION
816 foreach (array('primary','secondary','tertiary') as $instype) {
818 $query = "SELECT * FROM insurance_data WHERE " .
819 "pid = ? AND type = ? " .
820 "ORDER BY date DESC";
821 $res = sqlStatement($query, array($pid, $instype) );
823 $enddate = 'Present';
825 while( $row = sqlFetchArray($res) ) {
826 if ($row['provider'] ) {
828 $ins_description = ucfirst($instype);
829 $ins_description = xl($ins_description);
830 $ins_description .= strcmp($enddate, 'Present') != 0 ?
" (".xl('Old').")" : "";
832 <li
<?php
echo $first ?
'class="current"' : '' ?
>><a href
="#">
833 <?php
echo htmlspecialchars($ins_description,ENT_NOQUOTES
); ?
></a
></li
>
837 $enddate = $row['date'];
840 // Display the eligibility tab
841 echo "<li><a href='#'>" .
842 htmlspecialchars( xl('Eligibility'), ENT_NOQUOTES
) . "</a></li>";
848 <div
class="tabContainer">
851 foreach (array('primary','secondary','tertiary') as $instype) {
852 $enddate = 'Present';
854 $query = "SELECT * FROM insurance_data WHERE " .
855 "pid = ? AND type = ? " .
856 "ORDER BY date DESC";
857 $res = sqlStatement($query, array($pid, $instype) );
858 while( $row = sqlFetchArray($res) ) {
859 if ($row['provider'] ) {
861 <div
class="tab <?php echo $first ? 'current' : '' ?>">
862 <table border
='0' cellpadding
='0' width
='100%'>
864 $icobj = new InsuranceCompany($row['provider']);
865 $adobj = $icobj->get_address();
866 $insco_name = trim($icobj->get_name());
869 <td valign
='top' colspan
='3'>
871 <?php
if (strcmp($enddate, 'Present') != 0) echo htmlspecialchars(xl("Old"),ENT_NOQUOTES
)." "; ?
>
872 <?php
$tempinstype=ucfirst($instype); echo htmlspecialchars(xl($tempinstype.' Insurance'),ENT_NOQUOTES
); ?
>
873 <?php
if (strcmp($row['date'], '0000-00-00') != 0) { ?
>
874 <?php
echo htmlspecialchars(xl('from','',' ',' ').$row['date'],ENT_NOQUOTES
); ?
>
876 <?php
echo htmlspecialchars(xl('until','',' ',' '),ENT_NOQUOTES
);
877 echo (strcmp($enddate, 'Present') != 0) ?
$enddate : htmlspecialchars(xl('Present'),ENT_NOQUOTES
); ?
>:</span
>
885 echo htmlspecialchars($insco_name,ENT_NOQUOTES
) . '<br>';
886 if (trim($adobj->get_line1())) {
887 echo htmlspecialchars($adobj->get_line1(),ENT_NOQUOTES
) . '<br>';
888 echo htmlspecialchars($adobj->get_city() . ', ' . $adobj->get_state() . ' ' . $adobj->get_zip(),ENT_NOQUOTES
);
891 echo "<font color='red'><b>".htmlspecialchars(xl('Unassigned'),ENT_NOQUOTES
)."</b></font>";
895 <?php
echo htmlspecialchars(xl('Policy Number'),ENT_NOQUOTES
); ?
>:
896 <?php
echo htmlspecialchars($row['policy_number'],ENT_NOQUOTES
) ?
><br
>
897 <?php
echo htmlspecialchars(xl('Plan Name'),ENT_NOQUOTES
); ?
>:
898 <?php
echo htmlspecialchars($row['plan_name'],ENT_NOQUOTES
); ?
><br
>
899 <?php
echo htmlspecialchars(xl('Group Number'),ENT_NOQUOTES
); ?
>:
900 <?php
echo htmlspecialchars($row['group_number'],ENT_NOQUOTES
); ?
></span
>
903 <span
class='bold'><?php
echo htmlspecialchars(xl('Subscriber'),ENT_NOQUOTES
); ?
>: </span
><br
>
904 <span
class='text'><?php
echo htmlspecialchars($row['subscriber_fname'] . ' ' . $row['subscriber_mname'] . ' ' . $row['subscriber_lname'],ENT_NOQUOTES
); ?
>
906 if ($row['subscriber_relationship'] != "") {
907 echo "(" . htmlspecialchars($row['subscriber_relationship'],ENT_NOQUOTES
) . ")";
911 <?php
echo htmlspecialchars(xl('S.S.'),ENT_NOQUOTES
); ?
>:
912 <?php
echo htmlspecialchars($row['subscriber_ss'],ENT_NOQUOTES
); ?
><br
>
913 <?php
echo htmlspecialchars(xl('D.O.B.'),ENT_NOQUOTES
); ?
>:
914 <?php
if ($row['subscriber_DOB'] != "0000-00-00 00:00:00") echo htmlspecialchars($row['subscriber_DOB'],ENT_NOQUOTES
); ?
><br
>
915 <?php
echo htmlspecialchars(xl('Phone'),ENT_NOQUOTES
); ?
>:
916 <?php
echo htmlspecialchars($row['subscriber_phone'],ENT_NOQUOTES
); ?
>
920 <span
class='bold'><?php
echo htmlspecialchars(xl('Subscriber Address'),ENT_NOQUOTES
); ?
>: </span
><br
>
921 <span
class='text'><?php
echo htmlspecialchars($row['subscriber_street'],ENT_NOQUOTES
); ?
><br
>
922 <?php
echo htmlspecialchars($row['subscriber_city'],ENT_NOQUOTES
); ?
>
923 <?php
if($row['subscriber_state'] != "") echo ", "; echo htmlspecialchars($row['subscriber_state'],ENT_NOQUOTES
); ?
>
924 <?php
if($row['subscriber_country'] != "") echo ", "; echo htmlspecialchars($row['subscriber_country'],ENT_NOQUOTES
); ?
>
925 <?php
echo " " . htmlspecialchars($row['subscriber_postal_code'],ENT_NOQUOTES
); ?
></span
>
927 <?php
if (trim($row['subscriber_employer'])) { ?
>
928 <br
><span
class='bold'><?php
echo htmlspecialchars(xl('Subscriber Employer'),ENT_NOQUOTES
); ?
>: </span
><br
>
929 <span
class='text'><?php
echo htmlspecialchars($row['subscriber_employer'],ENT_NOQUOTES
); ?
><br
>
930 <?php
echo htmlspecialchars($row['subscriber_employer_street'],ENT_NOQUOTES
); ?
><br
>
931 <?php
echo htmlspecialchars($row['subscriber_employer_city'],ENT_NOQUOTES
); ?
>
932 <?php
if($row['subscriber_employer_city'] != "") echo ", "; echo htmlspecialchars($row['subscriber_employer_state'],ENT_NOQUOTES
); ?
>
933 <?php
if($row['subscriber_employer_country'] != "") echo ", "; echo htmlspecialchars($row['subscriber_employer_country'],ENT_NOQUOTES
); ?
>
934 <?php
echo " " . htmlspecialchars($row['subscriber_employer_postal_code'],ENT_NOQUOTES
); ?
>
942 <?php
if ($row['copay'] != "") { ?
>
943 <span
class='bold'><?php
echo htmlspecialchars(xl('CoPay'),ENT_NOQUOTES
); ?
>: </span
>
944 <span
class='text'><?php
echo htmlspecialchars($row['copay'],ENT_NOQUOTES
); ?
></span
>
947 <span
class='bold'><?php
echo htmlspecialchars(xl('Accept Assignment'),ENT_NOQUOTES
); ?
>:</span
>
948 <span
class='text'><?php
if($row['accept_assignment'] == "TRUE") echo xl("YES"); ?
>
949 <?php
if($row['accept_assignment'] == "FALSE") echo xl("NO"); ?
></span
>
950 <?php
if (!empty($row['policy_type'])) { ?
>
952 <span
class='bold'><?php
echo htmlspecialchars(xl('Secondary Medicare Type'),ENT_NOQUOTES
); ?
>: </span
>
953 <span
class='text'><?php
echo htmlspecialchars($policy_types[$row['policy_type']],ENT_NOQUOTES
); ?
></span
>
956 <td valign
='top'></td
>
957 <td valign
='top'></td
>
964 } // end if ($row['provider'])
965 $enddate = $row['date'];
970 // Display the eligibility information
971 echo "<div class='tab'>";
972 show_eligibility_information($pid,true);
975 ///////////////////////////////// END INSURANCE SECTION
988 // Notes expand collapse widget
989 $widgetTitle = xl("Notes");
990 $widgetLabel = "pnotes";
991 $widgetButtonLabel = xl("Edit");
992 $widgetButtonLink = "pnotes_full.php?form_active=1";
993 $widgetButtonClass = "";
994 $linkMethod = "html";
995 $bodyClass = "notab";
998 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
999 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
1000 $widgetAuth, $fixedWidth);
1004 <div style
='margin-left:10px' class='text'><img src
='../../pic/ajax-loader.gif'/></div
><br
/>
1008 <?php
if ( (acl_check('patients', 'med')) && ($GLOBALS['enable_cdr'] && $GLOBALS['enable_cdr_prw']) ) {
1009 echo "<tr><td width='650px'>";
1010 // patient reminders collapse widget
1011 $widgetTitle = xl("Patient Reminders");
1012 $widgetLabel = "patient_reminders";
1013 $widgetButtonLabel = xl("Edit");
1014 $widgetButtonLink = "../reminder/patient_reminders.php?mode=simple&patient_id=".$pid;
1015 $widgetButtonClass = "";
1016 $linkMethod = "html";
1017 $bodyClass = "notab";
1020 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth); ?
>
1022 <div style
='margin-left:10px' class='text'><image src
='../../pic/ajax-loader.gif'/></div
><br
/>
1026 <?php
} //end if prw is activated ?>
1031 // disclosures expand collapse widget
1032 $widgetTitle = xl("Disclosures");
1033 $widgetLabel = "disclosures";
1034 $widgetButtonLabel = xl("Edit");
1035 $widgetButtonLink = "disclosure_full.php";
1036 $widgetButtonClass = "";
1037 $linkMethod = "html";
1038 $bodyClass = "notab";
1041 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
1042 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
1043 $widgetAuth, $fixedWidth);
1046 <div style
='margin-left:10px' class='text'><img src
='../../pic/ajax-loader.gif'/></div
><br
/>
1050 <?php
if ($GLOBALS['amendments']) { ?
>
1053 <?php
// Amendments widget
1054 $widgetTitle = xlt('Amendments');
1055 $widgetLabel = "amendments";
1056 $widgetButtonLabel = xlt("Edit");
1057 $widgetButtonLink = $GLOBALS['webroot'] . "/interface/patient_file/summary/main_frameset.php?feature=amendment";
1058 $widgetButtonClass = "iframe rx_modal";
1059 $linkMethod = "html";
1060 $bodyClass = "summary_item small";
1062 $fixedWidth = false;
1063 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
1064 $sql = "SELECT * FROM amendments WHERE pid = ? ORDER BY amendment_date DESC";
1065 $result = sqlStatement($sql, array($pid) );
1067 if (sqlNumRows($result) == 0) {
1068 echo " <table><tr>\n";
1069 echo " <td colspan='$numcols' class='text'> " . xlt('None') . "</td>\n";
1070 echo " </tr></table>\n";
1073 while ($row=sqlFetchArray($result)){
1074 echo " ";
1075 echo "<a class= '" . $widgetButtonClass . "' href='" . $widgetButtonLink . "&id=" . attr($row['amendment_id']) . "' onclick='top.restoreSession()'>" . text($row['amendment_date']);
1076 echo " " . text($row['amendment_desc']);
1086 <?php
// labdata expand collapse widget
1087 $widgetTitle = xl("Labs");
1088 $widgetLabel = "labdata";
1089 $widgetButtonLabel = xl("Trend");
1090 $widgetButtonLink = "../summary/labdata.php";#"../encounter/trend_form.php?formname=labdata";
1091 $widgetButtonClass = "";
1092 $linkMethod = "html";
1093 $bodyClass = "notab";
1094 // check to see if any labdata exist
1095 $spruch = "SELECT procedure_report.date_collected AS date " .
1096 "FROM procedure_report " .
1097 "JOIN procedure_order ON procedure_report.procedure_order_id = procedure_order.procedure_order_id " .
1098 "WHERE procedure_order.patient_id = ? " .
1099 "ORDER BY procedure_report.date_collected DESC ";
1100 $existLabdata = sqlQuery($spruch, array($pid) );
1101 if ($existLabdata) {
1105 $widgetAuth = false;
1108 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
1109 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
1110 $widgetAuth, $fixedWidth);
1113 <div style
='margin-left:10px' class='text'><img src
='../../pic/ajax-loader.gif'/></div
><br
/>
1117 <?php
// end labdata ?>
1122 <?php
if ($vitals_is_registered && acl_check('patients', 'med')) { ?
>
1125 <?php
// vitals expand collapse widget
1126 $widgetTitle = xl("Vitals");
1127 $widgetLabel = "vitals";
1128 $widgetButtonLabel = xl("Trend");
1129 $widgetButtonLink = "../encounter/trend_form.php?formname=vitals";
1130 $widgetButtonClass = "";
1131 $linkMethod = "html";
1132 $bodyClass = "notab";
1133 // check to see if any vitals exist
1134 $existVitals = sqlQuery("SELECT * FROM form_vitals WHERE pid=?", array($pid) );
1139 $widgetAuth = false;
1142 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
1143 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
1144 $widgetAuth, $fixedWidth);
1147 <div style
='margin-left:10px' class='text'><img src
='../../pic/ajax-loader.gif'/></div
><br
/>
1151 <?php
} // end if ($vitals_is_registered && acl_check('patients', 'med')) ?>
1154 // This generates a section similar to Vitals for each LBF form that
1155 // supports charting. The form ID is used as the "widget label".
1157 $gfres = sqlStatement("SELECT option_id, title FROM list_options WHERE " .
1158 "list_id = 'lbfnames' AND " .
1159 "option_value > 0 AND activity = 1 " .
1160 "ORDER BY seq, title");
1161 while($gfrow = sqlFetchArray($gfres)) {
1165 <?php
// vitals expand collapse widget
1166 $vitals_form_id = $gfrow['option_id'];
1167 $widgetTitle = $gfrow['title'];
1168 $widgetLabel = $vitals_form_id;
1169 $widgetButtonLabel = xl("Trend");
1170 $widgetButtonLink = "../encounter/trend_form.php?formname=$vitals_form_id";
1171 $widgetButtonClass = "";
1172 $linkMethod = "html";
1173 $bodyClass = "notab";
1174 // check to see if any instances exist for this patient
1175 $existVitals = sqlQuery(
1176 "SELECT * FROM forms WHERE pid = ? AND formdir = ? AND deleted = 0",
1177 array($pid, $vitals_form_id));
1178 $widgetAuth = $existVitals ?
true : false;
1180 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
1181 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
1182 $widgetAuth, $fixedWidth);
1185 <div style
='margin-left:10px' class='text'>
1186 <image src
='../../pic/ajax-loader.gif'/>
1189 </div
> <!-- This is required by
expand_collapse_widget(). -->
1199 <!-- end left column div
-->
1201 <!-- start right column div
-->
1210 // If there is an ID Card or any Photos show the widget
1211 $photos = pic_array($pid, $GLOBALS['patient_photo_category_name']);
1212 if ($photos or $idcard_doc_id )
1214 $widgetTitle = xl("ID Card") . '/' . xl("Photos");
1215 $widgetLabel = "photos";
1216 $linkMethod = "javascript";
1217 $bodyClass = "notab-right";
1218 $widgetAuth = false;
1219 $fixedWidth = false;
1220 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel ,
1221 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
1222 $widgetAuth, $fixedWidth);
1226 if ($idcard_doc_id) {
1227 image_widget($idcard_doc_id, $GLOBALS['patient_id_category_name']);
1230 foreach ($photos as $photo_doc_id) {
1231 image_widget($photo_doc_id, $GLOBALS['patient_photo_category_name']);
1240 // Advance Directives
1241 if ($GLOBALS['advance_directives_warning']) {
1242 // advance directives expand collapse widget
1243 $widgetTitle = xl("Advance Directives");
1244 $widgetLabel = "directives";
1245 $widgetButtonLabel = xl("Edit");
1246 $widgetButtonLink = "return advdirconfigure();";
1247 $widgetButtonClass = "";
1248 $linkMethod = "javascript";
1249 $bodyClass = "summary_item small";
1251 $fixedWidth = false;
1252 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
1253 $counterFlag = false; //flag to record whether any categories contain ad records
1254 $query = "SELECT id FROM categories WHERE name='Advance Directive'";
1255 $myrow2 = sqlQuery($query);
1257 $parentId = $myrow2['id'];
1258 $query = "SELECT id, name FROM categories WHERE parent=?";
1259 $resNew1 = sqlStatement($query, array($parentId) );
1260 while ($myrows3 = sqlFetchArray($resNew1)) {
1261 $categoryId = $myrows3['id'];
1262 $nameDoc = $myrows3['name'];
1263 $query = "SELECT documents.date, documents.id " .
1265 "INNER JOIN categories_to_documents " .
1266 "ON categories_to_documents.document_id=documents.id " .
1267 "WHERE categories_to_documents.category_id=? " .
1268 "AND documents.foreign_id=? " .
1269 "ORDER BY documents.date DESC";
1270 $resNew2 = sqlStatement($query, array($categoryId, $pid) );
1271 $limitCounter = 0; // limit to one entry per category
1272 while (($myrows4 = sqlFetchArray($resNew2)) && ($limitCounter == 0)) {
1273 $dateTimeDoc = $myrows4['date'];
1274 // remove time from datetime stamp
1275 $tempParse = explode(" ",$dateTimeDoc);
1276 $dateDoc = $tempParse[0];
1277 $idDoc = $myrows4['id'];
1278 echo "<a href='$web_root/controller.php?document&retrieve&patient_id=" .
1279 htmlspecialchars($pid,ENT_QUOTES
) . "&document_id=" .
1280 htmlspecialchars($idDoc,ENT_QUOTES
) . "&as_file=true' onclick='top.restoreSession()'>" .
1281 htmlspecialchars(xl_document_category($nameDoc),ENT_NOQUOTES
) . "</a> " .
1282 htmlspecialchars($dateDoc,ENT_NOQUOTES
);
1284 $limitCounter = $limitCounter +
1;
1285 $counterFlag = true;
1289 if (!$counterFlag) {
1290 echo " " . htmlspecialchars(xl('None'),ENT_NOQUOTES
);
1293 <?php
} // close advanced dir block
1295 // This is a feature for a specific client. -- Rod
1296 if ($GLOBALS['cene_specific']) {
1299 $imagedir = $GLOBALS['OE_SITE_DIR'] . "/documents/$pid/demographics";
1300 $imagepath = "$web_root/sites/" . $_SESSION['site_id'] . "/documents/$pid/demographics";
1302 echo " <a href='' onclick=\"return sendimage($pid, 'photo');\" " .
1303 "title='Click to attach patient image'>\n";
1304 if (is_file("$imagedir/photo.jpg")) {
1305 echo " <img src='$imagepath/photo.jpg' /></a>\n";
1307 echo " Attach Patient Image</a><br />\n";
1309 echo " <br /> <br />\n";
1311 echo " <a href='' onclick=\"return sendimage($pid, 'fingerprint');\" " .
1312 "title='Click to attach fingerprint'>\n";
1313 if (is_file("$imagedir/fingerprint.jpg")) {
1314 echo " <img src='$imagepath/fingerprint.jpg' /></a>\n";
1316 echo " Attach Biometric Fingerprint</a><br />\n";
1318 echo " <br /> <br />\n";
1321 // Show Clinical Reminders for any user that has rules that are permitted.
1322 $clin_rem_check = resolve_rules_sql('','0',TRUE,'',$_SESSION['authUser']);
1323 if ( (!empty($clin_rem_check)) && ($GLOBALS['enable_cdr'] && $GLOBALS['enable_cdr_crw']) ) {
1324 // clinical summary expand collapse widget
1325 $widgetTitle = xl("Clinical Reminders");
1326 $widgetLabel = "clinical_reminders";
1327 $widgetButtonLabel = xl("Edit");
1328 $widgetButtonLink = "../reminder/clinical_reminders.php?patient_id=".$pid;;
1329 $widgetButtonClass = "";
1330 $linkMethod = "html";
1331 $bodyClass = "summary_item small";
1333 $fixedWidth = false;
1334 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
1336 echo "<div style='margin-left:10px' class='text'><image src='../../pic/ajax-loader.gif'/></div><br/>";
1341 // Show current and upcoming appointments.
1343 // Recurring appointment support and Appointment Display Sets
1344 // added to Appointments by Ian Jardine ( epsdky ).
1346 if (isset($pid) && !$GLOBALS['disable_calendar']) {
1348 $current_date2 = date('Y-m-d');
1350 $apptNum = (int)$GLOBALS['number_of_appts_to_show'];
1351 if($apptNum != 0) $apptNum2 = abs($apptNum);
1352 else $apptNum2 = 10;
1354 $mode1 = !$GLOBALS['appt_display_sets_option'];
1355 $colorSet1 = $GLOBALS['appt_display_sets_color_1'];
1356 $colorSet2 = $GLOBALS['appt_display_sets_color_2'];
1357 $colorSet3 = $GLOBALS['appt_display_sets_color_3'];
1358 $colorSet4 = $GLOBALS['appt_display_sets_color_4'];
1360 if($mode1) $extraAppts = 1;
1361 else $extraAppts = 6;
1362 $events = fetchNextXAppts($current_date2, $pid, $apptNum2 +
$extraAppts);
1366 $apptNumber = count($events);
1368 if($apptNumber <= $apptNum2) {
1369 $extraApptDate = '';
1371 } else if($mode1 && $apptNumber == $apptNum2 +
1) {
1372 $extraApptDate = $events[$apptNumber - 1]['pc_eventDate'];
1377 } else if($apptNumber == $apptNum2 +
6) {
1378 $extraApptDate = $events[$apptNumber - 1]['pc_eventDate'];
1383 } else { // mode 2 - $apptNum2 < $apptNumber < $apptNum2 + 6
1384 $extraApptDate = '';
1389 $limitApptIndx = $apptNum2 - 1;
1390 $limitApptDate = $events[$limitApptIndx]['pc_eventDate'];
1392 switch ($selectNum) {
1395 $lastApptIndx = $apptNumber - 1;
1396 $thisNumber = $lastApptIndx - $limitApptIndx;
1397 for($i = 1; $i <= $thisNumber; ++
$i) {
1398 if($events[$limitApptIndx +
$i]['pc_eventDate'] != $limitApptDate) {
1399 $extraApptDate = $events[$limitApptIndx +
$i]['pc_eventDate'];
1400 $events = array_slice($events, 0, $limitApptIndx +
$i);
1407 for($i = 1; $i <= $limitApptIndx; ++
$i) {
1408 if($events[$limitApptIndx - $i]['pc_eventDate'] != $limitApptDate) {
1409 $firstApptIndx = $apptNum2 - $i;
1416 if($extraApptDate) {
1417 if($extraApptDate != $limitApptDate) $apptStyle2 = " style='background-color:" . attr($colorSet3) . ";'";
1418 else $apptStyle2 = " style='background-color:" . attr($colorSet4) . ";'";
1423 // appointments expand collapse widget
1424 $widgetTitle = xl("Appointments");
1425 $widgetLabel = "appointments";
1426 $widgetButtonLabel = xl("Add");
1427 $widgetButtonLink = "return newEvt();";
1428 $widgetButtonClass = "";
1429 $linkMethod = "javascript";
1430 $bodyClass = "summary_item small";
1431 $widgetAuth = $resNotNull; // $resNotNull reflects state of query in fetchAppointments
1432 $fixedWidth = false;
1433 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
1439 foreach($events as $row) { //////
1441 $dayname = date("l", strtotime($row['pc_eventDate'])); //////
1443 $disphour = substr($row['pc_startTime'], 0, 2) +
0;
1444 $dispmin = substr($row['pc_startTime'], 3, 2);
1445 if ($disphour >= 12) {
1447 if ($disphour > 12) $disphour -= 12;
1449 $etitle = xl('(Click to edit)');
1450 if ($row['pc_hometext'] != "") {
1451 $etitle = xl('Comments').": ".($row['pc_hometext'])."\r\n".$etitle;
1454 if($extraApptDate && $count > $firstApptIndx) {
1455 $apptStyle = $apptStyle2;
1457 if($row['pc_eventDate'] != $priorDate) {
1458 $priorDate = $row['pc_eventDate'];
1459 $toggleSet = !$toggleSet;
1461 if($toggleSet) $apptStyle = " style='background-color:" . attr($colorSet2) . ";'";
1462 else $apptStyle = " style='background-color:" . attr($colorSet1) . ";'";
1465 echo "<div " . $apptStyle . ">";
1466 echo "<a href='javascript:oldEvt(" . htmlspecialchars(preg_replace("/-/", "", $row['pc_eventDate']),ENT_QUOTES
) . ', ' . htmlspecialchars($row['pc_eid'],ENT_QUOTES
) . ")' title='" . htmlspecialchars($etitle,ENT_QUOTES
) . "'>";
1467 echo "<b>" . htmlspecialchars($row['pc_eventDate'],ENT_NOQUOTES
) . ", ";
1468 echo htmlspecialchars(sprintf("%02d", $disphour) .":$dispmin " . xl($dispampm) . " (" . xl($dayname),ENT_NOQUOTES
) . ")</b> ";
1469 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
)."'>";
1470 echo "<span title='" . generate_display_field(array('data_type'=>'1','list_id'=>'apptstat'),$row['pc_apptstatus']) . "'>";
1471 echo "<br>" . xlt('Status') . "( " . htmlspecialchars($row['pc_apptstatus'],ENT_NOQUOTES
) . " ) </span>";
1472 echo htmlspecialchars(xl_appt_category($row['pc_catname']),ENT_NOQUOTES
) . "\n";
1473 if ($row['pc_hometext']) echo " <span style='color:green'> Com</span>";
1474 echo "<br>" . htmlspecialchars($row['ufname'] . " " . $row['ulname'],ENT_NOQUOTES
) . "</a></div>\n";
1477 if ($resNotNull) { //////
1479 echo " " . htmlspecialchars(xl('None'),ENT_NOQUOTES
);
1481 if($extraApptDate) echo "<div style='color:#0000cc;'><b>" . attr($extraApptDate) . " ( + ) </b></div>";
1482 else echo "<div><hr></div>";
1486 } // End of Appointments.
1489 /* Widget that shows recurrences for appointments. */
1490 if (isset($pid) && !$GLOBALS['disable_calendar'] && $GLOBALS['appt_recurrences_widget']) {
1492 $widgetTitle = xl("Recurrent Appointments");
1493 $widgetLabel = "recurrent_appointments";
1494 $widgetButtonLabel = xl("Add");
1495 $widgetButtonLink = "return newEvt();";
1496 $widgetButtonClass = "";
1497 $linkMethod = "javascript";
1498 $bodyClass = "summary_item small";
1499 $widgetAuth = false;
1500 $fixedWidth = false;
1501 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel, $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
1506 //Fetch patient's recurrences. Function returns array with recurrence appointments' category, recurrence pattern (interpreted), and end date.
1507 $recurrences = fetchRecurrences($pid);
1508 if($recurrences[0] == false){ //if there are no recurrent appointments:
1510 echo "<span>" . xlt('None') . "</span>";
1515 foreach ($recurrences as $row) {
1516 //checks if there are recurrences and if they are current (git didn't end yet)
1517 if ($row == false ||
!recurrence_is_current($row['pc_endDate']))
1520 echo "<span>" . xlt('Appointment Category') . ': ' . text($row['pc_title']) . "</span>";
1522 echo "<span>" . xlt('Recurrence') . ': ' . text($row['pc_recurrspec']) . "</span>";
1524 $red_text = ""; //if ends in a week, make font red
1525 if (ends_in_a_week($row['pc_endDate'])) {
1526 $red_text = " style=\"color:red;\" ";
1528 echo "<span" . $red_text . ">" . xlt('End Date') . ': ' . text($row['pc_endDate']) . "</span>";
1534 /* End of recurrence widget */
1537 // Show PAST appointments.
1538 // added by Terry Hill to allow reverse sorting of the appointments
1540 if ($GLOBALS['num_past_appointments_to_show'] < 0) {
1541 $direction = "DESC";
1542 ($showpast = -1 * $GLOBALS['num_past_appointments_to_show'] );
1546 $showpast = $GLOBALS['num_past_appointments_to_show'];
1549 if (isset($pid) && !$GLOBALS['disable_calendar'] && $showpast > 0) {
1550 $query = "SELECT e.pc_eid, e.pc_aid, e.pc_title, e.pc_eventDate, " .
1551 "e.pc_startTime, e.pc_hometext, u.fname, u.lname, u.mname, " .
1552 "c.pc_catname, e.pc_apptstatus " .
1553 "FROM openemr_postcalendar_events AS e, users AS u, " .
1554 "openemr_postcalendar_categories AS c WHERE " .
1555 "e.pc_pid = ? AND e.pc_eventDate < CURRENT_DATE AND " .
1556 "u.id = e.pc_aid AND e.pc_catid = c.pc_catid " .
1557 "ORDER BY e.pc_eventDate $direction , e.pc_startTime DESC " .
1558 "LIMIT " . $showpast;
1560 $pres = sqlStatement($query, array($pid) );
1562 // appointments expand collapse widget
1563 $widgetTitle = xl("Past Appointments");
1564 $widgetLabel = "past_appointments";
1565 $widgetButtonLabel = '';
1566 $widgetButtonLink = '';
1567 $widgetButtonClass = '';
1568 $linkMethod = "javascript";
1569 $bodyClass = "summary_item small";
1570 $widgetAuth = false; //no button
1571 $fixedWidth = false;
1572 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
1574 while($row = sqlFetchArray($pres)) {
1576 $dayname = date("l", strtotime($row['pc_eventDate']));
1578 $disphour = substr($row['pc_startTime'], 0, 2) +
0;
1579 $dispmin = substr($row['pc_startTime'], 3, 2);
1580 if ($disphour >= 12) {
1582 if ($disphour > 12) $disphour -= 12;
1584 if ($row['pc_hometext'] != "") {
1585 $etitle = xl('Comments').": ".($row['pc_hometext'])."\r\n".$etitle;
1587 echo "<a href='javascript:oldEvt(" . htmlspecialchars(preg_replace("/-/", "", $row['pc_eventDate']),ENT_QUOTES
) . ', ' . htmlspecialchars($row['pc_eid'],ENT_QUOTES
) . ")' title='" . htmlspecialchars($etitle,ENT_QUOTES
) . "'>";
1588 echo "<b>" . htmlspecialchars(xl($dayname) . ", " . $row['pc_eventDate'],ENT_NOQUOTES
) . "</b>" . xlt("Status") . "(";
1589 echo " " . generate_display_field(array('data_type'=>'1','list_id'=>'apptstat'),$row['pc_apptstatus']) . ")<br>"; // can't use special char parser on this
1590 echo htmlspecialchars("$disphour:$dispmin ") . xl($dispampm) . " ";
1591 echo htmlspecialchars($row['fname'] . " " . $row['lname'],ENT_NOQUOTES
) . "</a><br>\n";
1593 if (isset($pres) && $res != null) {
1595 echo " " . htmlspecialchars(xl('None'),ENT_NOQUOTES
);
1600 // END of past appointments
1605 <div id
='stats_div'>
1607 <div style
='margin-left:10px' class='text'><img src
='../../pic/ajax-loader.gif'/></div
><br
/>
1612 <?php
// TRACK ANYTHING -----
1614 // Determine if track_anything form is in use for this site.
1615 $tmp = sqlQuery("SELECT count(*) AS count FROM registry WHERE " .
1616 "directory = 'track_anything' AND state = 1");
1617 $track_is_registered = $tmp['count'];
1618 if($track_is_registered){
1620 // track_anything expand collapse widget
1621 $widgetTitle = xl("Tracks");
1622 $widgetLabel = "track_anything";
1623 $widgetButtonLabel = xl("Tracks");
1624 $widgetButtonLink = "../../forms/track_anything/create.php";
1625 $widgetButtonClass = "";
1626 $widgetAuth = ""; // don't show the button
1627 $linkMethod = "html";
1628 $bodyClass = "notab";
1629 // check to see if any tracks exist
1630 $spruch = "SELECT id " .
1634 $existTracks = sqlQuery($spruch, array($pid, "track_anything") );
1636 $fixedWidth = false;
1637 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
1638 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
1639 $widgetAuth, $fixedWidth);
1642 <div style
='margin-left:10px' class='text'><img src
='../../pic/ajax-loader.gif'/></div
><br
/>
1646 <?php
} // end track_anything ?>
1649 </div
> <!-- end right column div
-->
1656 </div
> <!-- end main content div
-->
1658 <script language
='JavaScript'>
1659 // Array of skip conditions for the checkSkipConditions() function.
1661 <?php
echo $condition_str; ?
>
1663 checkSkipConditions();