2 include_once("../../globals.php");
5 include_once("$srcdir/forms.inc");
6 include_once("$srcdir/billing.inc");
7 include_once("$srcdir/pnotes.inc");
8 include_once("$srcdir/patient.inc");
9 include_once("$srcdir/report.inc");
10 include_once(dirname(__file__
) . "/../../../library/classes/Document.class.php");
11 include_once(dirname(__file__
) . "/../../../library/classes/Note.class.php");
14 function postToGet($arin) {
16 foreach ($arin as $key => $val) {
17 $getstring.=urlencode($key)."=".urlencode($val)."&";
27 <link rel
=stylesheet href
="<?echo $css_header;?>" type
="text/css">
31 <body bgcolor
="#ffffff" topmargin
=0 rightmargin
=0 leftmargin
=2 bottommargin
=0 marginwidth
=2 marginheight
=0>
34 if (sizeof($_GET) > 0) {
40 $titleres = getPatientData($pid, "fname,lname,providerID");
41 $sql = "select * from facility where billing_location = 1";
42 $db = $GLOBALS['adodb']['db'];
43 $results = $db->Execute($sql);
46 $facility = $results->fields
;
51 <h2
><?
=$facility['name']?
></h2
>
52 <?
=$facility['street']?
><br
>
53 <?
=$facility['city']?
>, <?
=$facility['state']?
> <?
=$facility['postal_code']?
><br
>
57 <a href
="javascript:window.close();"><font
class=title
><?
print $titleres{"fname"} . " " . $titleres{"lname"};?
></font
></a
><br
>
58 <span
class=text
>Generated on
: <?
print date("Y-m-d");?
></span
>
62 //$provider = getProviderName($titleres['providerID']);
64 //print "Provider: " . $provider . "</br>";
66 $inclookupres = sqlStatement("select distinct formdir from forms where pid='$pid'");
67 while($result = sqlFetchArray($inclookupres)) {
68 include_once("{$GLOBALS['incdir']}/forms/" . $result{"formdir"} . "/report.php");
73 foreach ($ar as $key => $val) {
74 if(!empty($ar['newpatient'])){
75 foreach ($ar['newpatient'] as $be) {
78 $billing = getPatientBillingEncounter($pid,$ta[1]);
81 foreach ($billing as $b) {
82 if(!empty($b['provider_name'])){
83 echo "Provider: " . $b['provider_name'] . "<br>";
92 if (stristr($key,"include_")) {
93 //print "include: $val<br>\n";
95 if ($val == "demographics") {
97 print "<font class=bold>Patient Data:</font><br>";
98 printRecDataOne($patient_data_array, getRecPatientData ($pid), $N);
100 } elseif ($val == "history") {
102 print "<font class=bold>History Data:</font><br>";
103 printRecDataOne($history_data_array, getRecHistoryData ($pid), $N);
105 } elseif ($val == "employer") {
107 print "<font class=bold>Employer Data:</font><br>";
108 printRecDataOne($employer_data_array, getRecEmployerData ($pid), $N);
110 } elseif ($val == "insurance") {
112 print "<font class=bold>Primary Insurance Data:</font><br>";
113 printRecDataOne($insurance_data_array, getRecInsuranceData ($pid,"primary"), $N);
114 print "<font class=bold>Secondary Insurance Data:</font><br>";
115 printRecDataOne($insurance_data_array, getRecInsuranceData ($pid,"secondary"), $N);
117 print "<font class=bold>Tertiary Insurance Data:</font><br>";
118 printRecDataOne($insurance_data_array, getRecInsuranceData ($pid,"tertiary"), $N);
120 } elseif ($val == "billing") {
121 print "<font class=bold>Billing Information:</font><br>";
122 if (count($ar['newpatient']) > 0) {
125 echo "<tr><td width=\"400\" class=bold>Code</td><td class=bold>Fee</td></tr>\n";
128 foreach ($ar['newpatient'] as $be) {
129 $ta = split(":",$be);
130 $billing = getPatientBillingEncounter($pid,$ta[1]);
131 $billings[] = $billing;
132 foreach ($billing as $b) {
134 echo "<td class=text>";
135 echo $b['code_type'] . ":\t" . $b['code'] . " " . $b['code_text'] . " ";
137 echo "<td class=text>";
142 if ($b['code_type'] == "COPAY") {
143 $copays +
= $b['fee'];
147 echo "<tr><td> </td></tr>";
148 echo "<tr><td class=bold>Sub-Total</td><td class=text>" . sprintf("%0.2f",$total) . "</td></tr>";
149 echo "<tr><td class=bold>Paid</td><td class=text>" . sprintf("%0.2f",$copays) . "</td></tr>";
150 echo "<tr><td class=bold>Total</td><td class=text>" . sprintf("%0.2f",($total - $copays)) . "</td></tr>";
153 //print_r($billings);
157 printPatientBilling($pid);
160 } elseif ($val == "allergies") {
161 print "<font class=bold>Patient Allergies:</font><br>";
162 printListData($pid, "allergy", "1");
163 } elseif ($val == "medications") {
164 print "<font class=bold>Patient Medications:</font><br>";
165 printListData($pid, "medication", "1");
166 } elseif ($val == "medical_problems") {
167 print "<font class=bold>Patient Medical Problems:</font><br>";
168 printListData($pid, "medical_problem", "1");
169 } elseif ($val == "immunizations") {
170 print "<font class=bold>Patient Immunization:</font><br>";
171 $sql = "select if(i1.administered_date,concat(i1.administered_date,' - ',i2.name) ,substring(i1.note,1,20) ) as immunization_data from immunizations i1 left join immunization i2 on i1.immunization_id = i2.id where i1.patient_id = $pid order by administered_date desc";
173 $result = sqlStatement($sql);
175 while ($row=sqlFetchArray($result)){
176 echo "<span class=text> " . $row{'immunization_data'} . "</span>
179 } elseif ($val == "notes") {
180 print "<font class=bold>Patient Notes:</font><br>";
181 printPatientNotes($pid);
182 } elseif ($val == "transactions") {
183 print "<font class=bold>Patient Transactions:</font><br>";
184 printPatientTransactions($pid);
187 if ($key == "documents") {
189 foreach($val as $valkey => $valvalue) {
190 $document_id = $valvalue;
191 if (!is_numeric($document_id)) continue;
192 $d = new Document($document_id);
193 $fname = basename($d->get_url());
194 $extension = substr($fname, strrpos($fname,"."));
195 echo "Document '" . $fname ."'<br>";
196 $notes = Note
::notes_factory($d->get_id());
198 foreach ($notes as $note) {
201 echo '<td>Note #' . $note->get_id() . '</td>';
204 echo '<td>Date: '.$note->get_date().'</td>';
207 echo '<td>'.$note->get_note().'<br><br></td>';
212 if ($extension == ".png" ||
$extension == ".jpg" ||
$extension == ".jpeg" ||
$extension == ".gif") {
213 echo '<img src="' . $GLOBALS['webroot'] . "/controller.php?document&retrieve&patient_id=&document_id=" . $document_id . '"><br><br>';
216 echo "<b>NOTE</b>: Document '" . $fname ."' cannot be displayed inline becuase its type is not supported by the browser.<br><br>";
221 //print "$key:$val<br>\n";
222 foreach ($val as $valkey => $valvalue ) {
223 preg_match_all('/^(\d+?)\:(\d+?)$/',$valvalue,$res);
225 $form_id = $res[1][0];
226 $form_encounter = $res[2][0];
227 //print $res[0][0] . " " . $res[1][0] . " " . $res[2][0] . "<br>\n";
229 $formres = getFormNameByFormdir($key);
230 $dateres = getEncounterDateByEncounter($form_encounter);
231 print "<span class=bold>" . $formres{"form_name"} . "</span><span class=text>(" . date("Y-m-d",strtotime($dateres{"date"})) . ")" . "</span><br>\n";
232 call_user_func($key . "_report", $pid, $form_encounter, $N, $form_id);
238 print "</br></br>Signature: _______________________________</br>";