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
="<?php 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
><?php
xl('Generated on','e'); ?
>: <?
print date("Y-m-d");?
></span
>
72 //$provider = getProviderName($titleres['providerID']);
74 //print "Provider: " . $provider . "</br>";
76 $inclookupres = sqlStatement("select distinct formdir from forms where pid='$pid'");
77 while($result = sqlFetchArray($inclookupres)) {
78 include_once("{$GLOBALS['incdir']}/forms/" . $result{"formdir"} . "/report.php");
83 foreach ($ar as $key => $val) {
84 if (!$printed && strpos($key, "newpatient_") === 0) {
85 $billing = getPatientBillingEncounter($pid, $val);
86 foreach ($billing as $b) {
87 if(!empty($b['provider_name'])) {
88 echo "Provider: " . $b['provider_name'] . "<br>";
96 foreach ($ar as $key => $val) {
100 if (!empty($ar['newpatient'])){
101 foreach ($ar['newpatient'] as $be) {
102 $ta = split(":", $be);
103 $billing = getPatientBillingEncounter($pid, $ta[1]);
105 foreach ($billing as $b) {
106 if(!empty($b['provider_name'])) {
107 echo "Provider: " . $b['provider_name'] . "<br>";
117 if (stristr($key,"include_")) {
118 //print "include: $val<br>\n";
120 if ($val == "demographics") {
122 print "<br><font class=bold>".xl('Patient Data').":</font><br>";
123 printRecDataOne($patient_data_array, getRecPatientData ($pid), $N);
125 } elseif ($val == "history") {
127 print "<br><font class=bold>".xl('History Data').":</font><br>";
128 printRecDataOne($history_data_array, getRecHistoryData ($pid), $N);
130 } elseif ($val == "employer") {
132 print "<br><font class=bold>".xl('Employer Data').":</font><br>";
133 printRecDataOne($employer_data_array, getRecEmployerData ($pid), $N);
135 } elseif ($val == "insurance") {
137 print "<br><font class=bold>".xl('Primary Insurance Data').":</font><br>";
138 printRecDataOne($insurance_data_array, getRecInsuranceData ($pid,"primary"), $N);
139 print "<font class=bold>".xl('Secondary Insurance Data').":</font><br>";
140 printRecDataOne($insurance_data_array, getRecInsuranceData ($pid,"secondary"), $N);
141 print "<font class=bold>".xl('Tertiary Insurance Data').":</font><br>";
142 printRecDataOne($insurance_data_array, getRecInsuranceData ($pid,"tertiary"), $N);
144 } elseif ($val == "billing") {
146 print "<br><font class=bold>".xl('Billing Information').":</font><br>";
147 if (count($ar['newpatient']) > 0) {
150 echo "<tr><td width=\"400\" class=bold>Code</td><td class=bold>".xl('Fee')."</td></tr>\n";
153 foreach ($ar['newpatient'] as $be) {
154 $ta = split(":",$be);
155 $billing = getPatientBillingEncounter($pid,$ta[1]);
156 $billings[] = $billing;
157 foreach ($billing as $b) {
159 echo "<td class=text>";
160 echo $b['code_type'] . ":\t" . $b['code'] . " " . $b['code_text'] . " ";
162 echo "<td class=text>";
167 if ($b['code_type'] == "COPAY") {
168 $copays +
= $b['fee'];
172 echo "<tr><td> </td></tr>";
173 echo "<tr><td class=bold>".xl('Sub-Total')."</td><td class=text>" . sprintf("%0.2f",$total) . "</td></tr>";
174 echo "<tr><td class=bold>".xl('Paid')."</td><td class=text>" . sprintf("%0.2f",$copays) . "</td></tr>";
175 echo "<tr><td class=bold>".xl('Total')."</td><td class=text>" . sprintf("%0.2f",($total - $copays)) . "</td></tr>";
178 //print_r($billings);
182 printPatientBilling($pid);
187 } elseif ($val == "allergies") {
188 print "<font class=bold>".xl('Patient Allergies').":</font><br>";
189 printListData($pid, "allergy", "1");
190 } elseif ($val == "medications") {
191 print "<font class=bold>".xl('Patient Medications').":</font><br>";
192 printListData($pid, "medication", "1");
193 } elseif ($val == "medical_problems") {
194 print "<font class=bold>".xl('Patient Medical Problems').":</font><br>";
195 printListData($pid, "medical_problem", "1");
198 } elseif ($val == "immunizations") {
199 print "<font class=bold>".xl('Patient Immunization').":</font><br>";
200 $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";
201 $result = sqlStatement($sql);
202 while ($row=sqlFetchArray($result)) {
203 echo "<span class=text> " . $row{'immunization_data'} .
204 generate_display_field(array('data_type'=>'1','list_id'=>'immunizations'), $row['immunization_id']) .
208 } elseif ($val == "notes") {
210 print "<font class=bold>".xl('Patient Notes').":</font><br>";
211 printPatientNotes($pid);
213 } elseif ($val == "transactions") {
215 print "<font class=bold>".xl('Patient Transactions').":</font><br>";
216 printPatientTransactions($pid);
222 if ($key == "documents") {
224 foreach($val as $valkey => $valvalue) {
225 $document_id = $valvalue;
226 if (!is_numeric($document_id)) continue;
227 $d = new Document($document_id);
228 $fname = basename($d->get_url());
229 $extension = substr($fname, strrpos($fname,"."));
230 echo "Document '" . $fname ."'<br>";
231 $notes = Note
::notes_factory($d->get_id());
233 foreach ($notes as $note) {
235 echo '<td>Note #' . $note->get_id() . '</td>';
238 echo '<td>Date: '.$note->get_date().'</td>';
241 echo '<td>'.$note->get_note().'<br><br></td>';
245 if ($extension == ".png" ||
$extension == ".jpg" ||
$extension == ".jpeg" ||
$extension == ".gif") {
246 echo '<img src="' . $GLOBALS['webroot'] . "/controller.php?document&retrieve&patient_id=&document_id=" . $document_id . '"><br><br>';
249 // echo "<b>NOTE</b>: ".xl('Document')." '" . $fname ."'".xl('cannot be displayed inline becuase its type is not supported by the browser.')."<br><br>";
251 // This requires ImageMagick to be installed.
252 $from_file = $d->get_url_filepath();
253 if($d->get_storagemethod()==1 ){
254 $from_file = $d->get_couch_url($pid,$encounter);
256 $to_file = substr($from_file, 0, strrpos($from_file, '.')) . '_converted.jpg';
257 if (! is_file($to_file)) exec("convert -density 200 '$from_file' -append -resize 850 '$to_file'");
258 if (is_file($to_file)) {
259 $to_url = $GLOBALS['webroot'] . "/sites/" . $_SESSION['site_id'] .
260 "/documents/$pid/" . basename($to_file);
261 echo "<img src='$to_url'><br><br>\n";
263 echo "<b>NOTE</b>: " . xl('Document') . "'" . $fname . "' " .
264 xl('cannot be converted to JPEG. Perhaps ImageMagick is not installed?') .
267 if($d->get_storagemethod()==1 ){
274 else if (strpos($key, "issue_") === 0) {
280 preg_match('/^(.*)_(\d+)$/', $key, $res);
282 $irow = sqlQuery("SELECT type, title, comments, diagnosis " .
283 "FROM lists WHERE id = '$rowid'");
284 $diagnosis = $irow['diagnosis'];
285 echo "<span class='bold'>" . $irow['title'] . ":</span><span class='text'> " .
286 $irow['comments'] . "</span><br>\n";
287 // Show issue's chief diagnosis and its description:
289 $crow = sqlQuery("SELECT code_text FROM codes WHERE " .
290 "code = '$diagnosis' AND " .
291 "(code_type = 2 OR code_type = 4 OR code_type = 5)" .
293 echo "<span class='bold'> Diagnosis: </span><span class='text'>" .
294 $irow['diagnosis'] . " " . $crow['code_text'] . "</span><br>\n";
299 // Otherwise we have an "encounter form" form field whose name is like
300 // dirname_formid, with a value which is the encounter ID.
304 $form_encounter = $val;
305 preg_match('/^(.*)_(\d+)$/', $key, $res);
307 $formres = getFormNameByFormdir($res[1]);
308 $dateres = getEncounterDateByEncounter($form_encounter);
309 if ($res[1] == 'newpatient') print "<br>\n";
310 print "<span class='bold'>" . $formres{"form_name"} .
311 "</span><span class=text>(" . date("Y-m-d",strtotime($dateres{"date"})) .
312 ")" . "</span><br>\n";
313 call_user_func($res[1] . "_report", $pid, $form_encounter, $N, $form_id);
314 if ($res[1] == 'newpatient') {
315 $bres = sqlStatement("SELECT date, code, code_text FROM billing WHERE " .
316 "pid = '$pid' AND encounter = '$form_encounter' AND activity = 1 AND " .
317 "(code_type = 'CPT4' OR code_type = 'OPCS') " .
319 while ($brow=sqlFetchArray($bres)) {
320 echo "<span class='bold'> Procedure: </span><span class='text'>" .
321 $brow['code'] . " " . $brow['code_text'] . "</span><br>\n";
329 print "</br></br>".xl('Signature').": _______________________________</br>";