2 require_once("../../globals.php");
3 require_once("$srcdir/patient.inc");
4 require_once("$srcdir/acl.inc");
5 require_once("$srcdir/classes/Address.class.php");
6 require_once("$srcdir/classes/InsuranceCompany.class.php");
7 require_once("./patient_picture.php");
8 require_once("$srcdir/options.inc.php");
9 if ($GLOBALS['concurrent_layout'] && $_GET['set_pid']) {
10 include_once("$srcdir/pid.inc");
11 setpid($_GET['set_pid']);
14 function print_as_money($money) {
15 preg_match("/(\d*)\.?(\d*)/",$money,$moneymatches);
16 $tmp = wordwrap(strrev($moneymatches[1]),3,",",1);
17 $ccheck = strrev($tmp);
18 if ($ccheck[0] == ",") {
19 $tmp = substr($ccheck,1,strlen($ccheck)-1);
21 if ($moneymatches[2] != "") {
22 return "$ " . strrev($tmp) . "." . $moneymatches[2];
24 return "$ " . strrev($tmp);
28 function get_patient_balance($pid) {
29 require_once($GLOBALS['fileroot'] . "/library/classes/WSWrapper.class.php");
30 $conn = $GLOBALS['adodb']['db'];
31 $customer_info['id'] = 0;
32 $sql = "SELECT foreign_id FROM integration_mapping AS im " .
33 "LEFT JOIN patient_data AS pd ON im.local_id = pd.id WHERE " .
34 "pd.pid = '" . $pid . "' AND im.local_table = 'patient_data' AND " .
35 "im.foreign_table = 'customer'";
36 $result = $conn->Execute($sql);
37 if($result && !$result->EOF
) {
38 $customer_info['id'] = $result->fields
['foreign_id'];
40 $function['ezybiz.customer_balance'] = array(new xmlrpcval($customer_info,"struct"));
41 $ws = new WSWrapper($function);
42 if(is_numeric($ws->value
)) {
43 return sprintf('%01.2f', $ws->value
);
52 <?php
html_header_show();?
>
53 <link rel
="stylesheet" href
="<?php echo $css_header;?>" type
="text/css">
54 <style type
="text/css">@import
url(../../../library
/dynarch_calendar
.css
);</style
>
55 <script type
="text/javascript" src
="../../../library/textformat.js"></script
>
56 <script type
="text/javascript" src
="../../../library/dynarch_calendar.js"></script
>
57 <script type
="text/javascript" src
="../../../library/dynarch_calendar_en.js"></script
>
58 <script type
="text/javascript" src
="../../../library/dynarch_calendar_setup.js"></script
>
59 <script type
="text/javascript" src
="../../../library/dialog.js"></script
>
60 <script language
="JavaScript">
62 var mypcc
= '<? echo $GLOBALS['phone_country_code
'] ?>';
64 function oldEvt(eventid
) {
65 dlgopen('../../main/calendar/add_edit_event.php?eid=' + eventid
, '_blank', 550, 270);
68 function refreshme() {
73 // Process click on Delete link.
75 dlgopen('../deleter.php?patient=<?php echo $pid ?>', '_blank', 500, 450);
79 // Called by the deleteme.php window on a successful delete.
80 function imdeleted() {
81 <?php
if ($GLOBALS['concurrent_layout']) { ?
>
82 parent
.left_nav
.clearPatient();
85 top
.location
.href
= '../main/main_screen.php';
90 var f
= document
.forms
[0];
92 if ($GLOBALS['athletic_team']) {
93 echo " if (f.form_userdate1.value != f.form_original_userdate1.value) {\n";
94 $irow = sqlQuery("SELECT id, title FROM lists WHERE " .
95 "pid = '$pid' AND enddate IS NULL ORDER BY begdate DESC LIMIT 1");
98 if (confirm('Do you wish to also set this new return date in the issue titled "<?php echo addslashes($irow['title
']) ?>"?')) {
99 f
.form_issue_id
.value
= '<?php echo $irow['id
'] ?>';
101 alert('OK, you will need to manually update the return date in any affected issue(s).');
104 alert('You have changed the return date but there are no open issues. You probably need to create or modify one.');
108 } // end athletic team
116 <body
class="body_top">
119 $result = getPatientData($pid);
120 $result2 = getEmployerData($pid);
122 $thisauth = acl_check('patients', 'demo');
124 if ($result['squad'] && ! acl_check('squads', $result['squad']))
129 echo "<p>(" . xl('Demographics not authorized') . ")</p>\n";
130 echo "</body>\n</html>\n";
134 if ($thisauth == 'write') {
135 echo "<p><a href='demographics_full.php'";
136 if (! $GLOBALS['concurrent_layout']) echo " target='Main'";
137 echo " onclick='top.restoreSession()'><font class='title'>" .
138 xl('Demographics') . "</font>" .
139 "<font class='more'>$tmore</font></a>";
140 if (acl_check('admin', 'super')) {
141 echo " <a href='' onclick='return deleteme()'>" .
142 "<font class='more' style='color:red'>(".xl('Delete').")</font></a>";
147 // Get the document ID of the patient ID card if access to it is wanted here.
149 if ($GLOBALS['patient_id_category_name']) {
150 $tmp = sqlQuery("SELECT d.id, d.date, d.url FROM " .
151 "documents AS d, categories_to_documents AS cd, categories AS c " .
152 "WHERE d.foreign_id = $pid " .
153 "AND cd.document_id = d.id " .
154 "AND c.id = cd.category_id " .
155 "AND c.name LIKE '" . $GLOBALS['patient_id_category_name'] . "' " .
156 "ORDER BY d.date DESC LIMIT 1");
157 if ($tmp) $document_id = $tmp['id'];
161 <table border
="0" width
="100%">
164 <!-- Left column of main table
; contains another table
-->
166 <td align
="left" valign
="top">
167 <table border
='0' cellpadding
='0'>
170 display_layout_rows('DEM', $result, $result2);
172 echo " <table border='0' cellpadding='0' width='100%'>\n";
174 ///////////////////////////////// INSURANCE SECTION
176 foreach (array('primary','secondary','tertiary') as $instype) {
177 $enddate = 'Present';
179 $query = "SELECT * FROM insurance_data WHERE " .
180 "pid = '$pid' AND type = '$instype' " .
181 "ORDER BY date DESC";
182 $res = sqlStatement($query);
183 while ($row = sqlFetchArray($res)) {
184 if ($row['provider']) {
185 $icobj = new InsuranceCompany($row['provider']);
186 $adobj = $icobj->get_address();
187 $insco_name = trim($icobj->get_name());
190 <td valign
='top' colspan
='3'>
191 <br
><span
class='bold'>
192 <?php
if (strcmp($enddate, 'Present') != 0) echo "Old "; ?
>
193 <?php
xl(ucfirst($instype) . ' Insurance','e'); ?
>
194 <?php
if (strcmp($row['date'], '0000-00-00') != 0) { ?
>
195 <?php
xl(' from','e'); echo ' ' . $row['date']; ?
>
197 <?php
xl(' until ','e'); echo $enddate; ?
>
206 echo $insco_name . '<br>';
207 if (trim($adobj->get_line1())) {
208 echo $adobj->get_line1() . '<br>';
209 echo $adobj->get_city() . ', ' . $adobj->get_state() . ' ' . $adobj->get_zip();
212 echo "<font color='red'><b>Unassigned</b></font>";
216 <?php
xl('Policy Number','e'); ?
>: <?php
echo $row['policy_number'] ?
><br
>
217 Plan Name
: <?php
echo $row['plan_name']; ?
><br
>
218 Group Number
: <?php
echo $row['group_number']; ?
></span
>
221 <span
class='bold'><?php
xl('Subscriber','e'); ?
>: </span
><br
>
222 <span
class='text'><?php
echo $row['subscriber_fname'] . ' ' . $row['subscriber_mname'] . ' ' . $row['subscriber_lname'] ?
>
224 if ($row['subscriber_relationship'] != "") {
225 echo "(" . $row['subscriber_relationship'] . ")";
229 S
.S
.: <?php
echo $row['subscriber_ss']; ?
><br
>
230 <?php
xl('D.O.B.','e'); ?
>:
231 <?php
if ($row['subscriber_DOB'] != "0000-00-00 00:00:00") echo $row['subscriber_DOB']; ?
><br
>
232 Phone
: <?php
echo $row['subscriber_phone'] ?
>
236 <span
class='bold'><?php
xl('Subscriber Address','e'); ?
>: </span
><br
>
237 <span
class='text'><?php
echo $row['subscriber_street']; ?
><br
>
238 <?php
echo $row['subscriber_city']; ?
>
239 <?php
if($row['subscriber_state'] != "") echo ", "; echo $row['subscriber_state']; ?
>
240 <?php
if($row['subscriber_country'] != "") echo ", "; echo $row['subscriber_country']; ?
>
241 <?php
echo " " . $row['subscriber_postal_code']; ?
></span
>
243 <?php
if (trim($row['subscriber_employer'])) { ?
>
244 <br
><span
class='bold'><?php
xl('Subscriber Employer','e'); ?
>: </span
><br
>
245 <span
class='text'><?php
echo $row['subscriber_employer']; ?
><br
>
246 <?php
echo $row['subscriber_employer_street']; ?
><br
>
247 <?php
echo $row['subscriber_employer_city']; ?
>
248 <?php
if($row['subscriber_employer_city'] != "") echo ", "; echo $row['subscriber_employer_state']; ?
>
249 <?php
if($row['subscriber_employer_country'] != "") echo ", "; echo $row['subscriber_employer_country']; ?
>
250 <?php
echo " " . $row['subscriber_employer_postal_code']; ?
>
258 <?php
if ($row['copay'] != "") { ?
>
259 <span
class='bold'><?php
xl('CoPay','e'); ?
>: </span
>
260 <span
class='text'><?php
echo $row['copay']; ?
></span
>
263 <td valign
='top'></td
>
264 <td valign
='top'></td
>
267 } // end if ($row['provider'])
268 $enddate = $row['date'];
272 ///////////////////////////////// END INSURANCE SECTION
278 <!-- Right column of main table
-->
280 <td valign
="top" class="text">
283 // This stuff only applies to athletic team use of OpenEMR. The client
284 // insisted on being able to quickly change fitness and return date here:
286 if ($GLOBALS['athletic_team']) {
287 // blue green yellow red orange
288 $fitcolors = array('#6677ff','#00cc00','#ffff00','#ff3333','#ff8800','#ffeecc','#ffccaa');
289 $fitcolor = $fitcolors[0];
290 $form_fitness = $_POST['form_fitness'];
291 $form_userdate1 = fixDate($_POST['form_userdate1'], '');
292 $form_issue_id = $_POST['form_issue_id'];
294 $returndate = $form_userdate1 ?
"'$form_userdate1'" : "NULL";
295 sqlStatement("UPDATE patient_data SET fitness = '$form_fitness', " .
296 "userdate1 = $returndate WHERE pid = '$pid'");
297 // Update return date in the designated issue, if requested.
298 if ($form_issue_id) {
299 sqlStatement("UPDATE lists SET returndate = $returndate WHERE " .
300 "id = '$form_issue_id'");
303 $form_fitness = $result['fitness'];
304 if (! $form_fitness) $form_fitness = 1;
305 $form_userdate1 = $result['userdate1'];
307 $fitcolor = $fitcolors[$form_fitness - 1];
308 echo " <form method='post' action='demographics.php' onsubmit='return validate()'>\n";
309 echo " <span class='bold'>Fitness to Play:</span><br />\n";
310 echo " <select name='form_fitness' style='background-color:$fitcolor'>\n";
311 $res = sqlStatement("SELECT * FROM list_options WHERE " .
312 "list_id = 'fitness' ORDER BY seq");
313 while ($row = sqlFetchArray($res)) {
314 $key = $row['option_id'];
315 echo " <option value='$key'";
316 if ($key == $form_fitness) echo " selected";
317 echo ">" . $row['title'] . "</option>\n";
320 echo " <br /><span class='bold'>Return to Play:</span><br>\n";
321 echo " <input type='text' size='10' name='form_userdate1' id='form_userdate1' " .
322 "value='$form_userdate1' " .
323 "title='" . xl('yyyy-mm-dd Date of return to play') . "' " .
324 "onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)' />\n" .
325 " <img src='../../pic/show_calendar.gif' align='absbottom' width='24' height='22' " .
326 "id='img_userdate1' border='0' alt='[?]' style='cursor:pointer' " .
327 "title='" . xl('Click here to choose a date') . "'>\n";
328 echo " <input type='hidden' name='form_original_userdate1' value='$form_userdate1' />\n";
329 echo " <input type='hidden' name='form_issue_id' value='' />\n";
330 echo "<p><input type='submit' name='form_submit' value='Change' /></p>\n";
334 if ($GLOBALS['oer_config']['ws_accounting']['enabled']) {
335 // Show current balance and billing note, if any.
336 echo "<span class='bold'><font color='#ee6600'>Balance Due: $" .
337 get_patient_balance($pid) . "</font><br />";
338 if ($result['genericname2'] == 'Billing') {
339 xl('Billing Note') . ":";
340 echo "<span class='bold'><font color='red'>" .
341 $result['genericval2'] . "</font></span>";
343 echo "</span><br />";
346 // If there is a patient ID card, then show a link to it.
348 echo "<a href='/".$web_root."/controller.php?document&retrieve" .
349 "&patient_id=$pid&document_id=$document_id' style='color:#00cc00' " .
350 "onclick='top.restoreSession()'>Click for ID card</a><br />";
353 // Show current and upcoming appointments.
355 $query = "SELECT e.pc_eid, e.pc_aid, e.pc_title, e.pc_eventDate, " .
356 "e.pc_startTime, u.fname, u.lname, u.mname " .
357 "FROM openemr_postcalendar_events AS e, users AS u WHERE " .
358 "e.pc_pid = '$pid' AND e.pc_eventDate >= CURRENT_DATE AND " .
360 "ORDER BY e.pc_eventDate, e.pc_startTime";
361 $res = sqlStatement($query);
362 while($row = sqlFetchArray($res)) {
363 $dayname = date("l", strtotime($row['pc_eventDate']));
365 $disphour = substr($row['pc_startTime'], 0, 2) +
0;
366 $dispmin = substr($row['pc_startTime'], 3, 2);
367 if ($disphour >= 12) {
369 if ($disphour > 12) $disphour -= 12;
371 echo "<a href='javascript:oldEvt(" . $row['pc_eid'] .
372 ")'><b>$dayname " . $row['pc_eventDate'] . "</b><br>";
373 echo "$disphour:$dispmin $dispampm " . $row['pc_title'] . "<br>\n";
374 echo $row['fname'] . " " . $row['lname'] . "</a><br> <br>\n";
383 <?php
if ($GLOBALS['concurrent_layout'] && $_GET['set_pid']) { ?
>
384 <script language
='JavaScript'>
385 parent
.left_nav
.setPatient(<?php
echo "'" . $result['fname'] . " " . $result['lname'] . "',$pid,''"; ?
>);
386 parent
.left_nav
.setRadio(window
.name
, 'dem');
387 <?php
if (!$_GET['is_new']) { // if new pt, do not load other frame ?>
388 var othername
= (window
.name
== 'RTop') ?
'RBot' : 'RTop';
389 parent
.left_nav
.setRadio(othername
, 'sum');
390 parent
.left_nav
.loadFrame('sum1', othername
, 'patient_file/summary/summary_bottom.php');
395 $patient_pics = pic_array();
396 foreach ($patient_pics as $var) {
401 <?php
if ($GLOBALS['athletic_team']) { ?
>
402 <script language
='JavaScript'>
403 Calendar
.setup({inputField
:"form_userdate1", ifFormat
:"%Y-%m-%d", button
:"img_userdate1"});