2 // +-----------------------------------------------------------------------------+
3 // Copyright (C) 2011 Z&H Consultancy Services Private Limited <sam@zhservices.com>
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
18 // A copy of the GNU General Public License is included along with this program:
19 // openemr/interface/login/GnuGPL.html
20 // For more information write to the Free Software
21 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 // Author: Eldho Chacko <eldho@zhservices.com>
24 // Jacob T Paul <jacob@zhservices.com>
26 // +------------------------------------------------------------------------------+
28 //SANITIZE ALL ESCAPES
29 $sanitize_all_escapes=true;
32 //STOP FAKE REGISTER GLOBALS
33 $fake_register_globals=false;
36 require_once("server_audit.php");
37 class Userforms
extends UserAudit
{
41 public function issue_type($data){
42 if(UserService
::valid($data[0])=='existingpatient'){
44 require_once("../../library/lists.inc");
48 throw new SoapFault("Server", "credentials failed in issue_type error message");
54 public function print_report($data){
56 if(UserService
::valid($data[0])=='existingpatient'){
60 require_once("../../library/forms.inc");
61 require_once("../../library/billing.inc");
62 require_once("../../library/pnotes.inc");
63 require_once("../../library/patient.inc");
64 require_once("../../library/options.inc.php");
65 require_once("../../library/acl.inc");
66 require_once("../../library/lists.inc");
67 require_once("../../library/report.inc");
68 require_once("../../library/classes/Document.class.php");
69 require_once("../../library/classes/Note.class.php");
70 require_once("../../library/formatting.inc.php");
71 require_once("../../custom/code_types.inc.php");
72 foreach($repArr as $value){
75 $this->getIncudes($value);
76 $out .= ob_get_clean();
80 $this->getIid($value);
82 $this->getforms($value);
83 $out .= ob_get_clean();
90 throw new SoapFault("Server", "credentials failed in print_report error message");
97 public function print_ccr_report($data){
98 if(UserService
::valid($data[0])=='existingpatient'){
99 $ccraction = $data[1];
101 require_once("../../ccr/createCCR.php");
103 createCCR($ccraction,$raw);
104 $html = ob_get_clean();
105 if($ccraction=='viewccd')
108 $html = preg_replace('/<!DOCTYPE html PUBLIC "-\/\/W3C\/\/DTD HTML 4.01\/\/EN" "http:\/\/www.w3.org\/TR\/html4\/strict.dtd">/','',$html);
109 $pos1 = strpos($html,'body {');
110 $pos2 = strpos($html,'.h1center');
111 $tes = substr("$html",$pos1,($pos2-$pos1));
112 $html = str_replace($tes,'',$html);
113 $html = str_replace('h3>','h2>',$html);
114 $html = base64_encode($html);
117 $pos1 = strpos($html,'*{');
118 $pos2 = strpos($html,'h1');
119 $tes = substr("$html",$pos1,($pos2-$pos1));
120 $html = str_replace($tes,'',$html);
125 throw new SoapFault("Server", "credentials failed in print_ccr_report error message");
129 //Return the forms requested from Portal.
131 private function getforms($fId){
133 $GLOBALS['pid'] = $pid;
134 $inclookupres = sqlStatement("SELECT DISTINCT formdir FROM forms WHERE pid = ? AND deleted=0",array($pid));
135 while($result = sqlFetchArray($inclookupres)) {
136 $formdir = $result['formdir'];
137 if (substr($formdir,0,3) == 'LBF')
138 include_once($GLOBALS['incdir'] . "/forms/LBF/report.php");
140 include_once($GLOBALS['incdir'] . "/forms/$formdir/report.php");
143 $inclookupres = sqlStatement("SELECT encounter,form_id,formdir,id FROM forms WHERE pid = ? AND deleted=0
144 AND id =? ",array($pid,$fId));
145 while($result = sqlFetchArray($inclookupres)) {
146 $form_encounter=$result['encounter'];
147 $form_id=$result['form_id'];
148 $formdir = $result['formdir'];
151 if (substr($formdir,0,3) == 'LBF')
152 call_user_func("lbf_report", $pid, $form_encounter, $N, $form_id, $formdir);
154 call_user_func($formdir . "_report", $pid, $form_encounter, $N, $form_id);
158 <th
><?php
echo htmlspecialchars($formdir,ENT_QUOTES
);?
></th
>
168 private function getIid($val){
171 $inclookupres = sqlStatement("SELECT DISTINCT formdir FROM forms WHERE pid = ? AND deleted=?",array($pid,0));
172 while($result = sqlFetchArray($inclookupres)) {
173 $formdir = $result['formdir'];
174 if (substr($formdir,0,3) == 'LBF')
175 include_once($GLOBALS['incdir'] . "/forms/LBF/report.php");
177 include_once($GLOBALS['incdir'] . "/forms/$formdir/report.php");
184 $irow = sqlQuery("SELECT type, title, comments, diagnosis FROM lists WHERE id =? ",array($val));
185 $diagnosis = $irow['diagnosis'];
187 if ($prevIssueType != $irow['type'])
189 $disptype = $ISSUE_TYPES[$irow['type']][0];
191 <div
class='issue_type' style
='font-weight: bold;'><?php
echo htmlspecialchars($disptype,ENT_QUOTES
);?
>:</div
>
193 $prevIssueType = $irow['type'];
196 <div
class='text issue'>
197 <span
class='issue_title'><?php
echo htmlspecialchars($irow['title'],ENT_QUOTES
);?
>:</span
>
198 <span
class='issue_comments'><?php
echo htmlspecialchars($irow['comments'],ENT_QUOTES
);?
></span
>
203 <div
class='text issue_diag'>
204 <span
class='bold'>[<?php
echo htmlspecialchars(xl('Diagnosis'),ENT_QUOTES
);?
>]</span
><br
>
206 $dcodes = explode(";", $diagnosis);
207 foreach ($dcodes as $dcode)
210 <span
class='italic'><?php
echo htmlspecialchars($dcode,ENT_QUOTES
);?
></span
>:
212 echo htmlspecialchars(lookup_code_descriptions($dcode),ENT_QUOTES
);
221 if ($irow['type'] == 'ippf_gcac')
226 display_layout_rows('GCA', sqlQuery("SELECT * FROM lists_ippf_gcac WHERE id = ?",array($rowid)));
232 else if ($irow['type'] == 'contraceptive')
237 display_layout_rows('CON', sqlQuery("SELECT * FROM lists_ippf_con WHERE id = ?",array($rowid)));
253 private function getIncudes($val){
255 if ($val == "demographics")
259 <div
class='text demographics' id
='DEM'>
261 // printRecDataOne($patient_data_array, getRecPatientData ($pid), $N);
262 $result1 = getPatientData($pid);
263 $result2 = getEmployerData($pid);
266 <tr
><td
><h6
><?php
echo htmlspecialchars(xl('Patient Data').":",ENT_QUOTES
);?
></h6
></td
></tr
>
268 display_layout_rows('DEM', $result1, $result2);
274 elseif ($val == "history")
278 <div
class='text history' id
='HIS'>
280 $result1 = getHistoryData($pid);
283 <tr
><td
><h6
><?php
echo htmlspecialchars(xl('History Data').":",ENT_QUOTES
);?
></h6
></td
></tr
>
285 display_layout_rows('HIS', $result1);
291 elseif ($val == "insurance")
295 <div
class='text insurance'>";
296 <h6><?php echo htmlspecialchars(xl('Insurance Data').":",ENT_QUOTES);?></h6>
297 <br><span class=bold><?php echo htmlspecialchars(xl('Primary Insurance Data').":",ENT_QUOTES);?></span><br>
299 printRecDataOne($insurance_data_array, getRecInsuranceData ($pid,"primary
"), $N);
301 <span class=bold><?php echo htmlspecialchars(xl('Secondary Insurance Data').":",ENT_QUOTES);?></span><br>
303 printRecDataOne($insurance_data_array, getRecInsuranceData ($pid,"secondary
"), $N);
305 <span class=bold><?php echo htmlspecialchars(xl('Tertiary Insurance Data').":",ENT_QUOTES);?></span><br>
307 printRecDataOne($insurance_data_array, getRecInsuranceData ($pid,"tertiary
"), $N);
312 elseif ($val == "billing
")
316 <div class='text billing'>
317 <h6><?php echo htmlspecialchars(xl('Billing Information').":",ENT_QUOTES);?></h6>
319 if (count($ar['newpatient']) > 0) {
323 <tr><td width='400' class='bold'><?php echo htmlspecialchars(xl('Code'),ENT_QUOTES);?></td><td class='bold'><?php echo htmlspecialchars(xl('Fee'),ENT_QUOTES);?></td></tr>
327 foreach ($ar['newpatient'] as $be) {
328 $ta = split(":",$be);
329 $billing = getPatientBillingEncounter($pid,$ta[1]);
330 $billings[] = $billing;
331 foreach ($billing as $b) {
336 echo htmlspecialchars($b['code_type'],ENT_QUOTES) . ":\t" .htmlspecialchars( $b['code'],ENT_QUOTES) . " 
;". htmlspecialchars($b['modifier'],ENT_QUOTES) . " 
; 
; 
;" . htmlspecialchars($b['code_text'],ENT_QUOTES) . " 
; 
; 
; 
; 
;";
341 echo htmlspecialchars(oeFormatMoney($b['fee']),ENT_QUOTES);
347 if ($b['code_type'] == "COPAY
") {
348 $copays += $b['fee'];
352 echo "<tr
><td
> 
;</td
></tr
>";
353 echo "<tr
><td
class=bold
>".htmlspecialchars(xl('Sub-Total'),ENT_QUOTES)."</td
><td
class=text
>" . htmlspecialchars(oeFormatMoney($total + abs($copays)),ENT_QUOTES) . "</td
></tr
>";
354 echo "<tr
><td
class=bold
>".htmlspecialchars(xl('Paid'),ENT_QUOTES)."</td
><td
class=text
>" . htmlspecialchars(oeFormatMoney(abs($copays)),ENT_QUOTES) . "</td
></tr
>";
355 echo "<tr
><td
class=bold
>".htmlspecialchars(xl('Total'),ENT_QUOTES)."</td
><td
class=text
>" .htmlspecialchars(oeFormatMoney($total),ENT_QUOTES) . "</td
></tr
>";
358 //print_r($billings);
361 printPatientBilling($pid);
363 echo "</div
>\n"; // end of billing DIV
365 elseif ($val == "immunizations
")
370 <div class='text immunizations'>
371 <h6><?php echo htmlspecialchars(xl('Patient Immunization').":",ENT_QUOTES);?></h6>
373 $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
= ? order by administered_date desc
";
374 $result = sqlStatement($sql,array($pid));
375 while ($row=sqlFetchArray($result)) {
376 echo htmlspecialchars($row{'immunization_data'},ENT_QUOTES);
377 echo generate_display_field(array('data_type'=>'1','list_id'=>'immunizations'), $row['immunization_id']);
387 elseif ($val == "batchcom
")
391 <div class='text transactions'>
392 <h6><?php htmlspecialchars(xl('Patient Communication sent').":",ENT_QUOTES);?></h6>
394 $sql="SELECT
concat( 'Messsage Type: ', batchcom
.msg_type
, ', Message Subject: ', batchcom
.msg_subject
, ', Sent on:', batchcom
.msg_date_sent
) AS batchcom_data
, batchcom
.msg_text
, concat( users
.fname
, users
.lname
) AS user_name FROM `batchcom` JOIN `users` ON users
.id
= batchcom
.sent_by WHERE batchcom
.patient_id
=?
";
395 $result = sqlStatement($sql,array($pid));
396 while ($row=sqlFetchArray($result)) {
397 echo htmlspecialchars($row{'batchcom_data'}.", ".xl('By').": ".$row{'user_name'},ENT_QUOTES);
399 <br><?php echo htmlspecialchars(xl('Text'),ENT_QUOTES);?>:<br><?php echo htmlspecialchars($row{'msg_txt'},ENT_QUOTES);?><br>
406 elseif ($val == "notes
")
410 <div class='text notes'>
411 <h6><?php echo htmlspecialchars(xl('Patient Notes').":",ENT_QUOTES);?></h6>
413 printPatientNotes($pid);
418 elseif ($val == "transactions
")
422 <div class='text transactions'>
423 <h6><?php echo htmlspecialchars(xl('Patient Transactions').":",ENT_QUOTES);?></h6>
425 printPatientTransactions($pid);