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");
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);
29 function get_billing_note($pid) {
30 $conn = $GLOBALS['adodb']['db'];
32 $sql = "select genericname2, genericval2 " .
33 "from patient_data where pid = '$pid' limit 1";
34 $resnote = $conn->Execute($sql);
35 if($resnote && !$resnote->EOF && $resnote->fields['genericname2'] == 'Billing') {
36 $billing_note = $resnote->fields['genericval2'];
42 function get_patient_balance($pid) {
43 require_once($GLOBALS['fileroot'] . "/library/classes/WSWrapper.class.php");
44 $conn = $GLOBALS['adodb']['db'];
45 $customer_info['id'] = 0;
46 $sql = "SELECT foreign_id FROM integration_mapping AS im " .
47 "LEFT JOIN patient_data AS pd ON im.local_id = pd.id WHERE " .
48 "pd.pid = '" . $pid . "' AND im.local_table = 'patient_data' AND " .
49 "im.foreign_table = 'customer'";
50 $result = $conn->Execute($sql);
51 if($result && !$result->EOF
) {
52 $customer_info['id'] = $result->fields
['foreign_id'];
54 $function['ezybiz.customer_balance'] = array(new xmlrpcval($customer_info,"struct"));
55 $ws = new WSWrapper($function);
56 if(is_numeric($ws->value
)) {
57 return sprintf('%01.2f', $ws->value
);
66 <link rel
=stylesheet href
="<?echo $css_header;?>" type
="text/css">
67 <script type
="text/javascript" src
="../../../library/dialog.js"></script
>
68 <script language
="JavaScript">
70 function oldEvt(eventid
) {
71 dlgopen('../../main/calendar/add_edit_event.php?eid=' + eventid
, '_blank', 550, 270);
74 function refreshme() {
79 // Process click on Delete link.
81 dlgopen('../deleter.php?patient=<?php echo $pid ?>', '_blank', 500, 450);
85 // Called by the deleteme.php window on a successful delete.
86 function imdeleted() {
87 <?php
if ($GLOBALS['concurrent_layout']) { ?
>
88 parent
.left_nav
.clearPatient();
91 top
.location
.href
= '../main/main_screen.php';
98 <body
<?
echo $top_bg_line;?
> topmargin
=0 rightmargin
=0 leftmargin
=2 bottommargin
=0 marginwidth
=2 marginheight
=0>
101 $result = getPatientData($pid);
102 $result2 = getEmployerData($pid);
104 $thisauth = acl_check('patients', 'demo');
106 if ($result['squad'] && ! acl_check('squads', $result['squad']))
111 echo "<p>(" . xl('Demographics not authorized') . ")</p>\n";
112 echo "</body>\n</html>\n";
116 if ($thisauth == 'write') {
117 echo "<p><a href='demographics_full.php'";
118 if (! $GLOBALS['concurrent_layout']) echo " target='Main'";
119 echo " onclick='top.restoreSession()'><font class='title'>" .
120 xl('Demographics') . "</font>" .
121 "<font class='more'>$tmore</font></a>";
122 if (acl_check('admin', 'super')) {
123 echo " <a href='' onclick='return deleteme()'>" .
124 "<font class='more' style='color:red'>(".xl('Delete').")</font></a>";
129 // Get the document ID of the patient ID card if access to it is wanted here.
131 if ($GLOBALS['patient_id_category_name']) {
132 $tmp = sqlQuery("SELECT d.id, d.date, d.url FROM " .
133 "documents AS d, categories_to_documents AS cd, categories AS c " .
134 "WHERE d.foreign_id = $pid " .
135 "AND cd.document_id = d.id " .
136 "AND c.id = cd.category_id " .
137 "AND c.name LIKE '" . $GLOBALS['patient_id_category_name'] . "' " .
138 "ORDER BY d.date DESC LIMIT 1");
139 if ($tmp) $document_id = $tmp['id'];
143 <table border
="0" width
="100%">
145 <td align
="left" valign
="top">
146 <table border
='0' cellpadding
='0' width
='100%'>
148 <td valign
='top' width
='33%'>
149 <span
class='bold'><?php
xl('Name','e'); ?
>: </span
>
152 if ($document_id) echo "<a href='/openemr/controller.php?document&retrieve" .
153 "&patient_id=$pid&document_id=$document_id' style='color:#00cc00' " .
154 "onclick='top.restoreSession()'>";
155 if (!$GLOBALS['omit_employers']) echo $result['title'] . ' ';
156 echo $result['fname'] . ' ' . $result['mname'] . ' ' . $result['lname'];
157 if ($document_id) echo "</a>";
160 <span
class='bold'><?
xl('Number','e'); ?
>: </span
><span
class='text'><?
echo $result{"pubpid"}?
></span
>
162 <td valign
='top' width
='33%'>
164 if ($result{"DOB"} && $result{"DOB"} != "0000-00-00") {
166 <span
class='bold'><?
xl('DOB','e'); ?
>: </span
>
173 <?php
if ($result{"ss"} != "") { ?
>
174 <span
class='bold'><?php
xl('S.S.','e'); ?
>: </span
>
176 <span
class='text'><?php
echo $result{"ss"} ?
></span
>
178 <td valign
='top' width
='34%'>
179 <?php
if ($result{"sex"} != "") { ?
>
180 <span
class='bold'><?php
xl('Sex','e'); ?
>: </span
>
182 <span
class='text'><?php
echo $result{"sex"} ?
></span
>
187 <?php
if (($result{"street"} != "") ||
($result{"city"} != "") ||
($result{"state"} != "") ||
($result{"country_code"} != "") ||
($result{"postal_code"} != "")) {?
>
188 <span
class='bold'><?
xl('Address','e'); ?
>: </span
>
190 <br
><span
class='text'><?
echo $result{"street"}?
><br
><?
echo $result{"city"}?
><?
if($result{"city"} != ""){echo ", ";}?
><?
echo $result{"state"};?
>
191 <?
if($result{"country_code"} != ""){ echo ", "; }?
><?
echo $result{"country_code"}?
>
193 echo $result{"postal_code"}?
>
198 if ( ($result{"contact_relationship"} != "") ||
199 ($result{"phone_contact"} != "") ||
200 ($result{"phone_home"} != "") ||
201 ($result{"phone_biz"} != "") ||
202 ($result{"email"} != "") ||
203 ($result{"phone_cell"} != "") ){
205 <span
class='bold'><?
xl('Emergency Contact','e'); ?
>: </span
><?
}?
><span
class='text'><?
echo $result{"contact_relationship"}?
><?
echo " "?
>
207 if ($result{"phone_contact"} != "") {
208 echo " " . $result{"phone_contact"};
210 if ($result{"phone_home"} != "") {
211 echo "<br><span class='bold'>Home:</span> ";
212 echo $result{"phone_home"};
214 if ($result{"phone_biz"} != "") {
215 echo "<br><span class='bold'>Work:</span> ";
216 echo $result{"phone_biz"};
218 if ($result{"phone_cell"} != "") {
219 echo "<br><span class='bold'>Mobile:</span> ";
220 echo $result{"phone_cell"};
222 if ($result{"email"} != "") {
223 echo "<br><span class='bold'>".xl('Email').": </span>";
224 echo '<a class=link_submit href="mailto:' . $result{"email"} . '">' . $result{"email"} . '</a>';
230 if ($result{"status"} != "") {
231 echo "<span class='bold'>".xl('Marital Status').": </span>";
232 echo "<span class='text'>" . $result{"status"} . "</span>";
238 <?php
if (!$GLOBALS['athletic_team']) { ?
>
240 <td colspan
='3' valign
='top'>
242 $opt_out = ($result{"hipaa_mail"} == 'YES') ?
'ALLOWS' : 'DOES NOT ALLOW';
243 echo "<span class='text'>Patient $opt_out Mailed Information </span>";
248 <td colspan
='2' valign
='top'>
250 $opt_out = ($result{"hipaa_voice"} == 'YES') ?
'ALLOWS' : 'DOES NOT ALLOW';
251 echo "<span class='text'>Patient $opt_out Voice Messages </span>";
254 <td colspan
='1' valign
='top'>
256 echo "<span class='bold'><font color='#ee6600'>Balance Due: $" .
257 get_patient_balance($pid) . "</font>";
258 if ($result['genericname2'] == 'Billing')
259 echo "<br>" . xl('Billing Note') . ":";
265 <td colspan
='2' valign
='top'>
267 $opt_out = ($result{"hipaa_notice"} == 'YES') ?
'RECEIVED' : 'DID NOT RECEIVE';
268 echo "<span class='text'>Patient $opt_out Notice Information </span>";
271 <td colspan
='1' valign
='top'>
273 if ($result['genericname2'] == 'Billing')
274 echo "<span class='bold'><font color='red'>" .
275 $result['genericval2'] . "</font></span>";
280 <td colspan
='3' valign
='top'>
282 if ( $result["hipaa_message"] == "" ) {
283 echo "<span class='text'><b>Leave a message with :</b> " .
284 $result{"fname"} . " " . $result{"mname"} . " " .
285 $result{"lname"} . "</span>";
288 echo "<span class='text'><b>Leave a message with :</b> " .
289 $result{"hipaa_message"} . "</span>";
297 <td colspan
='3' valign
='top'>
303 <?php
if ($GLOBALS['omit_employers']) { ?
>
306 <td valign
='top' colspan
='2'>
309 <td
><span
class='bold'>Listed Family Members
:</span
></td
>
313 <td
><?php
if ($result{"genericname1"} != "") { ?
><span
class='text'> 
; 
; 
;<?
=$result{"genericname1"}?
></span
><?php
} ?
></td
>
314 <td
><?php
if ($result{"genericval1"} != "") { ?
><span
class='text'> 
; 
; 
;<?
=$result{"genericval1"}?
></span
><?php
} ?
></td
>
317 <td
><?php
if ($result{"genericname2"} != "") { ?
><span
class='text'> 
; 
; 
;<?
=$result{"genericname2"}?
></span
><?php
} ?
></td
>
318 <td
><?php
if ($result{"genericval2"} != "") { ?
><span
class='text'> 
; 
; 
;<?
=$result{"genericval2"}?
></span
><?php
} ?
></td
>
322 <td valign
='top'></td
>
325 <?php
} else { ///// end omit_employers ///// ?>
329 <?php
if ($result{"occupation"} != "") { ?
>
330 <span
class='bold'><?php
xl('Occupation','e'); ?
>: </span
><span
class='text'><?
echo $result{"occupation"}?
></span
><br
>
332 <?php
if ($result2{"name"} != "") { ?
>
333 <span
class='bold'><?php
xl('Employer','e'); ?
>: </span
><span
class='text'><?php
echo $result2{"name"} ?
></span
>
337 <?php
if (($result2{"street"} != "") ||
($result2{"city"} != "") ||
($result2{"state"} != "") ||
($result2{"country"} != "") ||
($result2{"postal_code"} != "")) { ?
>
338 <span
class='bold'><?
xl('Employer Address','e'); ?
>:</span
>
341 <?php
echo $result2{"street"}?
><br
><?php
echo $result2{"city"} ?
><?php
if($result2{"city"} != "") { echo ", "; } ?
><?php
echo $result2{"state"} ?
>
342 <?php
if($result2{"country"} != "") { echo ", "; } echo $result2{"country"} ?
>
343 <?php
if($result2{"postal_code"} != "") {echo " "; } ?
>
344 <?php
echo $result2{"postal_code"} ?
>
350 // This stuff only applies to athletic team use of OpenEMR:
351 if ($GLOBALS['athletic_team']) {
352 // blue dk green yellow red orange
353 $fitcolors = array('#6677ff', '#00cc00', '#ffff00', '#ff3333', '#ff8800', '#ffeecc', '#ffccaa');
354 $fitcolor = $fitcolors[0];
355 $fitness = $_POST['form_fitness'];
357 sqlStatement("UPDATE patient_data SET fitness = '$fitness' WHERE pid = '$pid'");
359 $fitness = $result['fitness'];
360 if (! $fitness) $fitness = 1;
362 $fitcolor = $fitcolors[$fitness - 1];
364 <form method
='post' action
='demographics.php'>
365 <span
class='bold'><?
xl('Fitness to Play','e'); ?
>:</span
><br
>
366 <select name
='form_fitness' onchange
='top.restoreSession();document.forms[0].submit()' style
='background-color:<? echo $fitcolor ?>'>
367 <option value
='1'<?
if ($fitness == 1) echo ' selected' ?
>><?
xl('Full Play','e'); ?
></option
>
368 <option value
='2'<?
if ($fitness == 2) echo ' selected' ?
>><?
xl('Full Training','e'); ?
></option
>
369 <option value
='3'<?
if ($fitness == 3) echo ' selected' ?
>><?
xl('Restricted Training','e'); ?
></option
>
370 <option value
='4'<?
if ($fitness == 4) echo ' selected' ?
>><?
xl('Injured Out','e'); ?
></option
>
371 <option value
='5'<?
if ($fitness == 5) echo ' selected' ?
>><?
xl('Rehabilitation','e'); ?
></option
>
372 <option value
='6'<?
if ($fitness == 6) echo ' selected' ?
>><?
xl('Illness','e'); ?
></option
>
373 <option value
='7'<?
if ($fitness == 7) echo ' selected' ?
>><?
xl('International Duty','e'); ?
></option
>
376 <?php
} // end athletic team ?>
381 <?php
if (! $GLOBALS['athletic_team']) { ?
>
382 <?php
if ($result{"ethnoracial"} != "") { ?
><span
class='bold'><?
xl('Race/Ethnicity','e'); ?
>: </span
><span
class='text'><?
echo $result{"ethnoracial"};?
></span
><br
><?
} ?
>
383 <?php
if ($result{"language"} != "") { ?
><span
class='bold'><?
xl('Language','e'); ?
>: </span
><span
class='text'><?
echo ucfirst($result{"language"});?
></span
><br
><?
} ?
>
384 <?php
if ($result{"interpretter"} != "") { ?
><span
class='bold'><?
xl('Interpreter','e'); ?
>: </span
><span
class='text'><?
echo $result{"interpretter"};?
></span
><br
><?
} ?
>
385 <?php
if ($result{"family_size"} != "") { ?
><span
class='bold'><?
xl('Family Size','e'); ?
>: </span
><span
class='text'><?
echo $result{"family_size"};?
></span
><br
><?
} ?
>
389 <?php
if (! $GLOBALS['athletic_team']) { ?
>
390 <?php
if ($result{"financial_review"} != "0000-00-00 00:00:00") {?
><span
class='bold'><?
xl('Financial Review Date','e'); ?
>: </span
><span
class='text'><?
echo date("n/j/Y",strtotime($result{"financial_review"}));?
></span
><br
><?
}?
>
391 <?php
if ($result{"monthly_income"} != "") {?
><span
class='bold'><?
xl('Monthly Income','e'); ?
>: </span
><span
class='text'><?
echo print_as_money($result{"monthly_income"});?
></span
><br
><?
}?
>
392 <?php
if ($result{"migrantseasonal"} != "") {?
><span
class='bold'><?
xl('Migrant/Seasonal','e'); ?
>: </span
><span
class='text'><?
echo $result{"migrantseasonal"};?
></span
><br
><?
}?
>
393 <?php
if ($result{"homeless"} != "") {?
><span
class='bold'><?
xl('Homeless, etc','e'); ?
>.: </span
><span
class='text'><?
echo $result{"homeless"};?
></span
><br
><?
}?
>
399 <td
><?
if ($result{"genericname1"} != "") {?
><span
class='bold'><?
=$result{"genericname1"}?
></span
>:<?
}?
> </td
>
400 <td
><?
if ($result{"genericval1"} != "") {?
><span
class='text'><?
=$result{"genericval1"}?
></span
><?
}?
></td
>
403 <td
><?
if ($result{"genericname2"} != "") {?
><span
class='bold'><?
=$result{"genericname2"}?
></span
>:<?
}?
> </td
>
404 <td
><?
if ($result{"genericval2"} != "") {?
><span
class='text'><?
=$result{"genericval2"}?
></span
><?
}?
></td
>
410 <?php
} ///// end not omit_employers ///// ?>
414 //////////////////////////////////REFERRAL SECTION
416 if ($result{"referrer"} != "" ||
$result{"referrerID"} != "")
420 <td valign
='top' colspan
='3'>
421 <span
class='bold'><?
xl('Primary Provider','e'); ?
>: </span
><span
class='text'><?
=getProviderName($result['providerID'])?
></span
><br
>
422 <!--<span
class='bold'>Primary Provider ID
: </span
><span
class='text'><?
=$result{"referrerID"}?
></span
>-->
428 ///////////////////////////////// INSURANCE SECTION
430 foreach (array('primary','secondary','tertiary') as $instype) {
431 $enddate = 'Present';
433 $query = "SELECT * FROM insurance_data WHERE " .
434 "pid = '$pid' AND type = '$instype' " .
435 "ORDER BY date DESC";
436 $res = sqlStatement($query);
437 while ($row = sqlFetchArray($res)) {
438 if ($row['provider']) {
439 $icobj = new InsuranceCompany($row['provider']);
440 $adobj = $icobj->get_address();
441 $insco_name = trim($icobj->get_name());
444 <td valign
='top' colspan
='3'>
445 <br
><span
class='bold'>
446 <?php
if (strcmp($enddate, 'Present') != 0) echo "Old "; ?
>
447 <?php
xl(ucfirst($instype) . ' Insurance','e'); ?
>
448 <?php
if (strcmp($row['date'], '0000-00-00') != 0) { ?
>
449 <?php
xl(' from','e'); echo ' ' . $row['date']; ?
>
451 <?php
xl(' until ','e'); echo $enddate; ?
>
460 echo $insco_name . '<br>';
461 if (trim($adobj->get_line1())) {
462 echo $adobj->get_line1() . '<br>';
463 echo $adobj->get_city() . ', ' . $adobj->get_state() . ' ' . $adobj->get_zip();
466 echo "<font color='red'><b>Unassigned</b></font>";
470 <?php
xl('Policy Number','e'); ?
>: <?php
echo $row['policy_number'] ?
><br
>
471 Plan Name
: <?php
echo $row['plan_name']; ?
><br
>
472 Group Number
: <?
echo $row['group_number']; ?
></span
>
475 <span
class='bold'><?php
xl('Subscriber','e'); ?
>: </span
><br
>
476 <span
class='text'><?php
echo $row['subscriber_fname'] . ' ' . $row['subscriber_mname'] . ' ' . $row['subscriber_lname'] ?
>
478 if ($row['subscriber_relationship'] != "") {
479 echo "(" . $row['subscriber_relationship'] . ")";
483 S
.S
.: <?php
echo $row['subscriber_ss']; ?
><br
>
484 <?php
xl('D.O.B.','e'); ?
>:
485 <?php
if ($row['subscriber_DOB'] != "0000-00-00 00:00:00") echo $row['subscriber_DOB']; ?
><br
>
486 Phone
: <?php
echo $row['subscriber_phone'] ?
>
490 <span
class='bold'><?php
xl('Subscriber Address','e'); ?
>: </span
><br
>
491 <span
class='text'><?php
echo $row['subscriber_street']; ?
><br
>
492 <?php
echo $row['subscriber_city']; ?
>
493 <?php
if($row['subscriber_state'] != "") echo ", "; echo $row['subscriber_state']; ?
>
494 <?php
if($row['subscriber_country'] != "") echo ", "; echo $row['subscriber_country']; ?
>
495 <?php
echo " " . $row['subscriber_postal_code']; ?
></span
>
497 <?php
if (trim($row['subscriber_employer'])) { ?
>
498 <br
><span
class='bold'><?php
xl('Subscriber Employer','e'); ?
>: </span
><br
>
499 <span
class='text'><?php
echo $row['subscriber_employer']; ?
><br
>
500 <?php
echo $row['subscriber_employer_street']; ?
><br
>
501 <?php
echo $row['subscriber_employer_city']; ?
>
502 <?php
if($row['subscriber_employer_city'] != "") echo ", "; echo $row['subscriber_employer_state']; ?
>
503 <?php
if($row['subscriber_employer_country'] != "") echo ", "; echo $row['subscriber_employer_country']; ?
>
504 <?php
echo " " . $row['subscriber_employer_postal_code']; ?
>
512 <?php
if ($row['copay'] != "") { ?
>
513 <span
class='bold'><?php
xl('CoPay','e'); ?
>: </span
>
514 <span
class='text'><?php
echo $row['copay']; ?
></span
>
517 <td valign
='top'></td
>
518 <td valign
='top'></td
>
521 } // end if ($row['provider'])
522 $enddate = $row['date'];
526 ///////////////////////////////// END INSURANCE SECTION
531 <td valign
="top" class="text">
534 $query = "SELECT e.pc_eid, e.pc_aid, e.pc_title, e.pc_eventDate, " .
535 "e.pc_startTime, u.fname, u.lname, u.mname " .
536 "FROM openemr_postcalendar_events AS e, users AS u WHERE " .
537 "e.pc_pid = '$pid' AND e.pc_eventDate >= CURRENT_DATE AND " .
539 "ORDER BY e.pc_eventDate, e.pc_startTime";
540 $res = sqlStatement($query);
541 while($row = sqlFetchArray($res)) {
542 $dayname = date("l", strtotime($row['pc_eventDate']));
544 $disphour = substr($row['pc_startTime'], 0, 2) +
0;
545 $dispmin = substr($row['pc_startTime'], 3, 2);
546 if ($disphour >= 12) {
548 if ($disphour > 12) $disphour -= 12;
550 echo "<a href='javascript:oldEvt(" . $row['pc_eid'] .
551 ")'><b>$dayname " . $row['pc_eventDate'] . "</b><br>";
552 echo "$disphour:$dispmin $dispampm " . $row['pc_title'] . "<br>\n";
553 echo $row['fname'] . " " . $row['lname'] . "</a><br> <br>\n";
561 <?php
if ($GLOBALS['concurrent_layout'] && $_GET['set_pid']) { ?
>
562 <script language
='JavaScript'>
563 parent
.left_nav
.setPatient(<?php
echo "'" . $result['fname'] . " " . $result['lname'] . "',$pid,''"; ?
>);
564 parent
.left_nav
.setRadio(window
.name
, 'dem');
565 <?php
if (!$_GET['is_new']) { // if new pt, do not load other frame ?>
566 var othername
= (window
.name
== 'RTop') ?
'RBot' : 'RTop';
567 parent
.left_nav
.setRadio(othername
, 'sum');
568 parent
.left_nav
.loadFrame(othername
, 'patient_file/summary/summary_bottom.php');
573 $patient_pics = pic_array();
574 foreach ($patient_pics as $var) {