2 include_once("../../globals.php");
3 include_once("$srcdir/forms.inc");
4 include_once("$srcdir/billing.inc");
5 include_once("$srcdir/pnotes.inc");
6 include_once("$srcdir/patient.inc");
7 include_once("$srcdir/report.inc");
8 require_once("$srcdir/options.inc.php");
9 include_once(dirname(__file__
) . "/../../../library/classes/Document.class.php");
10 include_once(dirname(__file__
) . "/../../../library/classes/Note.class.php");
15 function postToGet($arin) {
17 foreach ($arin as $key => $val) {
18 $getstring.=urlencode($key)."=".urlencode($val)."&";
25 <?php
html_header_show();?
>
26 <link rel
=stylesheet href
="<?echo $css_header;?>" type
="text/css">
29 <body bgcolor
="#ffffff" topmargin
=0 rightmargin
=0 leftmargin
=2 bottommargin
=0 marginwidth
=2 marginheight
=0>
32 if (sizeof($_GET) > 0) {
38 $titleres = getPatientData($pid, "fname,lname,providerID");
39 /********************************************************************
40 $sql = "select * from facility where billing_location = 1";
41 ********************************************************************/
42 if ($_SESSION['pc_facility']) {
43 $sql = "select * from facility where id=" . $_SESSION['pc_facility'];
45 $sql = "select * from facility where billing_location = 1";
47 /*******************************************************************/
48 $db = $GLOBALS['adodb']['db'];
49 $results = $db->Execute($sql);
52 $facility = $results->fields
;
55 $practice_logo = "../../../custom/practice_logo.gif";
56 if (file_exists($practice_logo)) {
57 echo "<img src='$practice_logo' align='left'>\n";
60 <h2
><?
=$facility['name']?
></h2
>
61 <?
=$facility['street']?
><br
>
62 <?
=$facility['city']?
>, <?
=$facility['state']?
> <?
=$facility['postal_code']?
><br clear
='all'>
63 <?
=$facility['phone']?
><br
>
66 <a href
="javascript:window.close();"><font
class=title
><?
print $titleres{"fname"} . " " . $titleres{"lname"};?
></font
></a
><br
>
67 <span
class=text
><?
xl('Generated on','e'); ?
>: <?
print date("Y-m-d");?
></span
>
71 //$provider = getProviderName($titleres['providerID']);
73 //print "Provider: " . $provider . "</br>";
75 $inclookupres = sqlStatement("select distinct formdir from forms where pid='$pid'");
76 while($result = sqlFetchArray($inclookupres)) {
77 include_once("{$GLOBALS['incdir']}/forms/" . $result{"formdir"} . "/report.php");
82 foreach ($ar as $key => $val) {
83 if (!$printed && strpos($key, "newpatient_") === 0) {
84 $billing = getPatientBillingEncounter($pid, $val);
85 foreach ($billing as $b) {
86 if(!empty($b['provider_name'])) {
87 echo "Provider: " . $b['provider_name'] . "<br>";
95 foreach ($ar as $key => $val) {
99 if (!empty($ar['newpatient'])){
100 foreach ($ar['newpatient'] as $be) {
101 $ta = split(":", $be);
102 $billing = getPatientBillingEncounter($pid, $ta[1]);
104 foreach ($billing as $b) {
105 if(!empty($b['provider_name'])) {
106 echo "Provider: " . $b['provider_name'] . "<br>";
116 if (stristr($key,"include_")) {
117 //print "include: $val<br>\n";
119 if ($val == "demographics") {
121 print "<br><font class=bold>".xl('Patient Data').":</font><br>";
122 printRecDataOne($patient_data_array, getRecPatientData ($pid), $N);
124 } elseif ($val == "history") {
126 print "<br><font class=bold>".xl('History Data').":</font><br>";
127 printRecDataOne($history_data_array, getRecHistoryData ($pid), $N);
129 } elseif ($val == "employer") {
131 print "<br><font class=bold>".xl('Employer Data').":</font><br>";
132 printRecDataOne($employer_data_array, getRecEmployerData ($pid), $N);
134 } elseif ($val == "insurance") {
136 print "<br><font class=bold>".xl('Primary Insurance Data').":</font><br>";
137 printRecDataOne($insurance_data_array, getRecInsuranceData ($pid,"primary"), $N);
138 print "<font class=bold>".xl('Secondary Insurance Data').":</font><br>";
139 printRecDataOne($insurance_data_array, getRecInsuranceData ($pid,"secondary"), $N);
140 print "<font class=bold>".xl('Tertiary Insurance Data').":</font><br>";
141 printRecDataOne($insurance_data_array, getRecInsuranceData ($pid,"tertiary"), $N);
143 } elseif ($val == "billing") {
145 print "<br><font class=bold>".xl('Billing Information').":</font><br>";
146 if (count($ar['newpatient']) > 0) {
149 echo "<tr><td width=\"400\" class=bold>Code</td><td class=bold>".xl('Fee')."</td></tr>\n";
152 foreach ($ar['newpatient'] as $be) {
153 $ta = split(":",$be);
154 $billing = getPatientBillingEncounter($pid,$ta[1]);
155 $billings[] = $billing;
156 foreach ($billing as $b) {
158 echo "<td class=text>";
159 echo $b['code_type'] . ":\t" . $b['code'] . " " . $b['code_text'] . " ";
161 echo "<td class=text>";
166 if ($b['code_type'] == "COPAY") {
167 $copays +
= $b['fee'];
171 echo "<tr><td> </td></tr>";
172 echo "<tr><td class=bold>".xl('Sub-Total')."</td><td class=text>" . sprintf("%0.2f",$total) . "</td></tr>";
173 echo "<tr><td class=bold>".xl('Paid')."</td><td class=text>" . sprintf("%0.2f",$copays) . "</td></tr>";
174 echo "<tr><td class=bold>".xl('Total')."</td><td class=text>" . sprintf("%0.2f",($total - $copays)) . "</td></tr>";
177 //print_r($billings);
181 printPatientBilling($pid);
186 } elseif ($val == "allergies") {
187 print "<font class=bold>".xl('Patient Allergies').":</font><br>";
188 printListData($pid, "allergy", "1");
189 } elseif ($val == "medications") {
190 print "<font class=bold>".xl('Patient Medications').":</font><br>";
191 printListData($pid, "medication", "1");
192 } elseif ($val == "medical_problems") {
193 print "<font class=bold>".xl('Patient Medical Problems').":</font><br>";
194 printListData($pid, "medical_problem", "1");
197 } elseif ($val == "immunizations") {
198 print "<font class=bold>".xl('Patient Immunization').":</font><br>";
199 $sql = "select i1.immunization_id as immunization_id, if(i1.administered_date,concat(i1.administered_date,' - ') ,substring(i1.note,1,20) ) as immunization_data from immunizations i1 where i1.patient_id = $pid order by administered_date desc";
200 $result = sqlStatement($sql);
201 while ($row=sqlFetchArray($result)) {
202 echo "<span class=text> " . $row{'immunization_data'} .
203 generate_display_field(array('data_type'=>'1','list_id'=>'immunizations'), $row['immunization_id']) .
207 } elseif ($val == "notes") {
209 print "<font class=bold>".xl('Patient Notes').":</font><br>";
210 printPatientNotes($pid);
212 } elseif ($val == "transactions") {
214 print "<font class=bold>".xl('Patient Transactions').":</font><br>";
215 printPatientTransactions($pid);
221 if ($key == "documents") {
223 foreach($val as $valkey => $valvalue) {
224 $document_id = $valvalue;
225 if (!is_numeric($document_id)) continue;
226 $d = new Document($document_id);
227 $fname = basename($d->get_url());
228 $extension = substr($fname, strrpos($fname,"."));
229 echo "Document '" . $fname ."'<br>";
230 $notes = Note
::notes_factory($d->get_id());
232 foreach ($notes as $note) {
234 echo '<td>Note #' . $note->get_id() . '</td>';
237 echo '<td>Date: '.$note->get_date().'</td>';
240 echo '<td>'.$note->get_note().'<br><br></td>';
244 if ($extension == ".png" ||
$extension == ".jpg" ||
$extension == ".jpeg" ||
$extension == ".gif") {
245 echo '<img src="' . $GLOBALS['webroot'] . "/controller.php?document&retrieve&patient_id=&document_id=" . $document_id . '"><br><br>';
248 // echo "<b>NOTE</b>: ".xl('Document')." '" . $fname ."'".xl('cannot be displayed inline becuase its type is not supported by the browser.')."<br><br>";
250 // This requires ImageMagick to be installed.
251 $from_file = $d->get_url_filepath();
252 $to_file = substr($from_file, 0, strrpos($from_file, '.')) . '_converted.jpg';
253 if (! is_file($to_file)) exec("convert -density 200 '$from_file' -append -resize 850 '$to_file'");
254 if (is_file($to_file)) {
255 $to_url = $GLOBALS['webroot'] . "/documents/$pid/" . basename($to_file);
256 echo "<img src='$to_url'><br><br>\n";
258 echo "<b>NOTE</b>: " . xl('Document') . "'" . $fname . "' " .
259 xl('cannot be converted to JPEG. Perhaps ImageMagick is not installed?') .
267 else if (strpos($key, "issue_") === 0) {
273 preg_match('/^(.*)_(\d+)$/', $key, $res);
275 $irow = sqlQuery("SELECT type, title, comments, diagnosis " .
276 "FROM lists WHERE id = '$rowid'");
277 $diagnosis = $irow['diagnosis'];
278 echo "<span class='bold'>" . $irow['title'] . ":</span><span class='text'> " .
279 $irow['comments'] . "</span><br>\n";
280 // Show issue's chief diagnosis and its description:
282 $crow = sqlQuery("SELECT code_text FROM codes WHERE " .
283 "code = '$diagnosis' AND " .
284 "(code_type = 2 OR code_type = 4 OR code_type = 5)" .
286 echo "<span class='bold'> Diagnosis: </span><span class='text'>" .
287 $irow['diagnosis'] . " " . $crow['code_text'] . "</span><br>\n";
292 // Otherwise we have an "encounter form" form field whose name is like
293 // dirname_formid, with a value which is the encounter ID.
297 $form_encounter = $val;
298 preg_match('/^(.*)_(\d+)$/', $key, $res);
300 $formres = getFormNameByFormdir($res[1]);
301 $dateres = getEncounterDateByEncounter($form_encounter);
302 if ($res[1] == 'newpatient') print "<br>\n";
303 print "<span class='bold'>" . $formres{"form_name"} .
304 "</span><span class=text>(" . date("Y-m-d",strtotime($dateres{"date"})) .
305 ")" . "</span><br>\n";
306 call_user_func($res[1] . "_report", $pid, $form_encounter, $N, $form_id);
307 if ($res[1] == 'newpatient') {
308 $bres = sqlStatement("SELECT date, code, code_text FROM billing WHERE " .
309 "pid = '$pid' AND encounter = '$form_encounter' AND activity = 1 AND " .
310 "(code_type = 'CPT4' OR code_type = 'OPCS') " .
312 while ($brow=sqlFetchArray($bres)) {
313 echo "<span class='bold'> Procedure: </span><span class='text'>" .
314 $brow['code'] . " " . $brow['code_text'] . "</span><br>\n";
322 print "</br></br>".xl('Signature').": _______________________________</br>";