change eligibility batch from ssn to policy number, minor fix to filename with extra...
[openemr.git] / library / ajax / payment_ajax.php
blob7640b998433ca41028c12cc63a1691bcc38cbd77
1 <?php
2 // +-----------------------------------------------------------------------------+
3 // Copyright (C) 2010 Z&H Consultancy Services Private Limited <sam@zhservices.com>
4 //
5 //
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 // Paul Simon K <paul@zhservices.com>
26 // +------------------------------------------------------------------------------+
27 //===============================================================================
28 //This section handles ajax for insurance,patient and for encounters.
29 //===============================================================================
30 require_once("../../interface/globals.php");
31 //=================================
32 if (isset($_REQUEST["ajax_mode"])) {
33 AjaxDropDownCode();
36 //=================================
37 function AjaxDropDownCode()
39 if ($_REQUEST["ajax_mode"] == "set") {//insurance
40 $CountIndex=1;
41 $StringForAjax="<div id='AjaxContainerInsurance'><table width='552' border='1' cellspacing='0' cellpadding='0'>
42 <tr class='text' bgcolor='#dddddd'>
43 <td width='50'>".htmlspecialchars(xl('Code'), ENT_QUOTES)."</td>
44 <td width='300'>".htmlspecialchars(xl('Name'), ENT_QUOTES)."</td>
45 <td width='200'>".htmlspecialchars(xl('Address'), ENT_QUOTES)."</td>
46 </tr>".
47 //ProcessKeyForColoring(event,$CountIndex)==>Shows the navigation in the listing by change of colors and focus.Happens when down or up arrow is pressed.
48 //PlaceValues(event,'&nbsp;','')==>Used while -->KEY PRESS<-- over list.List vanishes and the clicked one gets listed in the parent page's text box.
49 //PutTheValuesClick('&nbsp;','')==>Used while -->CLICK<-- over list.List vanishes and the clicked one gets listed in the parent page's text box.
50 "<tr class='text' height='20' bgcolor='$bgcolor' id=\"tr_insurance_$CountIndex\"
51 onkeydown=\"ProcessKeyForColoring(event,$CountIndex);PlaceValues(event,'&nbsp;','')\" onclick=\"PutTheValuesClick('&nbsp;','')\">
52 <td colspan='3' align='center'><a id='anchor_insurance_code_$CountIndex' href='#'></a></td>
53 </tr>";
54 $insurance_text_ajax=formData('insurance_text_ajax', '', true);
55 $res = sqlStatement("SELECT insurance_companies.id,name,city,state,country FROM insurance_companies
56 left join addresses on insurance_companies.id=addresses.foreign_id where name like '$insurance_text_ajax%' or insurance_companies.id like '$insurance_text_ajax%' ORDER BY name");
57 while ($row = sqlFetchArray($res)) {
58 if ($CountIndex%2==1) {
59 $bgcolor='#ddddff';
60 } else {
61 $bgcolor='#ffdddd';
64 $CountIndex++;
65 $Id=$row['id'];
66 $Name=$row['name'];
67 $City=$row['city'];
68 $State=$row['state'];
69 $Country=$row['country'];
70 $Address=$City.', '.$State.', '.$Country;
71 $StringForAjax.="<tr class='text' bgcolor='$bgcolor' id=\"tr_insurance_$CountIndex\"
72 onkeydown='ProcessKeyForColoring(event,$CountIndex);PlaceValues(event,\"".htmlspecialchars($Id, ENT_QUOTES)."\",\"".htmlspecialchars($Name, ENT_QUOTES)."\")'
73 onclick='PutTheValuesClick(\"".htmlspecialchars($Id, ENT_QUOTES)."\",\"".htmlspecialchars($Name, ENT_QUOTES)."\")'>
74 <td><a id='anchor_insurance_code_$CountIndex' href='#'>".htmlspecialchars($Id)."</a></td>
75 <td><a href='#'>".htmlspecialchars($Name)."</a></td>
76 <td><a href='#'>".htmlspecialchars($Address)."</a></td>
77 </tr>";
80 $StringForAjax.="</table></div>";
81 echo strlen($_REQUEST['insurance_text_ajax']).'~`~`'.$StringForAjax;
82 die;
85 //===============================================================================
86 if ($_REQUEST["ajax_mode"] == "set_patient") {//patient.
87 //From 2 areas this ajax is called.So 2 pairs of functions are used.
88 //PlaceValues==>Used while -->KEY PRESS<-- over list.List vanishes and the clicked one gets listed in the parent page's text box.
89 //PutTheValuesClick==>Used while -->CLICK<-- over list.List vanishes and the clicked one gets listed in the parent page's text box.
90 //PlaceValuesDistribute==>Used while -->KEY PRESS<-- over list.List vanishes and the clicked one gets listed in the parent page's text box.
91 //PutTheValuesClickDistribute==>Used while -->CLICK<-- over list.List vanishes and the clicked one gets listed in the parent page's text box.
92 if (isset($_REQUEST['patient_code']) && $_REQUEST['patient_code']!='') {
93 $patient_code=formData('patient_code', '', true);
94 if (isset($_REQUEST['submit_or_simple_type']) && $_REQUEST['submit_or_simple_type']=='Simple') {
95 $StringToAppend="PutTheValuesClickPatient";
96 $StringToAppend2="PlaceValuesPatient";
97 } else {
98 $StringToAppend="PutTheValuesClickDistribute";
99 $StringToAppend2="PlaceValuesDistribute";
102 $patient_code_complete=$_REQUEST['patient_code'];//we need the spaces here
103 } elseif (isset($_REQUEST['insurance_text_ajax']) && $_REQUEST['insurance_text_ajax']!='') {
104 $patient_code=formData('insurance_text_ajax', '', true);
105 $StringToAppend="PutTheValuesClick";
106 $StringToAppend2="PlaceValues";
107 $patient_code_complete=$_REQUEST['insurance_text_ajax'];//we need the spaces here
110 $CountIndex=1;
111 $StringForAjax="<div id='AjaxContainerPatient'><table width='452' border='1' cellspacing='0' cellpadding='0'>
112 <tr class='text' bgcolor='#dddddd'>
113 <td width='50'>".htmlspecialchars(xl('Code'), ENT_QUOTES)."</td>
114 <td width='100'>".htmlspecialchars(xl('Last Name'), ENT_QUOTES)."</td>
115 <td width='100'>".htmlspecialchars(xl('First Name'), ENT_QUOTES)."</td>
116 <td width='100'>".htmlspecialchars(xl('Middle Name'), ENT_QUOTES)."</td>
117 <td width='100'>".htmlspecialchars(xl('Date of Birth'), ENT_QUOTES)."</td>
118 </tr>".
119 //ProcessKeyForColoring(event,$CountIndex)==>Shows the navigation in the listing by change of colors and focus.Happens when down or up arrow is pressed.
120 "<tr class='text' height='20' bgcolor='$bgcolor' id=\"tr_insurance_$CountIndex\"
121 onkeydown=\"ProcessKeyForColoring(event,$CountIndex);$StringToAppend2(event,'&nbsp;','')\" onclick=\"$StringToAppend('&nbsp;','')\">
122 <td colspan='5' align='center'><a id='anchor_insurance_code_$CountIndex' href='#'></a></td>
123 </tr>
126 $res = sqlStatement("SELECT pid as id,fname,lname,mname,DOB FROM patient_data
127 where fname like '$patient_code%' or lname like '$patient_code%' or mname like '$patient_code%' or
128 CONCAT(lname,' ',fname,' ',mname) like '$patient_code%' or pid like '$patient_code%' ORDER BY lname");
129 while ($row = sqlFetchArray($res)) {
130 if ($CountIndex%2==1) {
131 $bgcolor='#ddddff';
132 } else {
133 $bgcolor='#ffdddd';
136 $CountIndex++;
137 $Id=$row['id'];
138 $fname=$row['fname'];
139 $lname=$row['lname'];
140 $mname=$row['mname'];
141 $Name=$lname.' '.$fname.' '.$mname;
142 $DOB=oeFormatShortDate($row['DOB']);
143 $StringForAjax.="<tr class='text' bgcolor='$bgcolor' id=\"tr_insurance_$CountIndex\"
144 onkeydown='ProcessKeyForColoring(event,$CountIndex);$StringToAppend2(event,\"".htmlspecialchars($Id, ENT_QUOTES)."\",\"".htmlspecialchars($Name, ENT_QUOTES)."\")' onclick=\"$StringToAppend('".addslashes($Id)."','".htmlspecialchars(addslashes($Name), ENT_QUOTES)."')\">
145 <td><a id='anchor_insurance_code_$CountIndex' href='#' >".htmlspecialchars($Id)."</a></td>
146 <td><a href='#'>".htmlspecialchars($lname)."</a></td>
147 <td><a href='#'>".htmlspecialchars($fname)."</a></td>
148 <td><a href='#'>".htmlspecialchars($mname)."</a></td>
149 <td><a href='#'>".htmlspecialchars($DOB)."</a></td>
150 </tr>";
153 $StringForAjax.="</table></div>";
154 echo strlen($patient_code_complete).'~`~`'.$StringForAjax;
155 die;
158 //===============================================================================
159 if ($_REQUEST["ajax_mode"] == "encounter") {//encounter
160 //PlaceValuesEncounter==>Used while -->KEY PRESS<-- over list.List vanishes and the clicked one gets listed in the parent page's text box.
161 //PutTheValuesClickEncounter==>Used while -->CLICK<-- over list.List vanishes and the clicked one gets listed in the parent page's text box.
162 if (isset($_REQUEST['encounter_patient_code'])) {
163 $patient_code=formData('encounter_patient_code', '', true);
164 $StringToAppend="PutTheValuesClickEncounter";
165 $StringToAppend2="PlaceValuesEncounter";
168 $CountIndex=1;
169 $StringForAjax="<div id='AjaxContainerEncounter'><table width='202' border='1' cellspacing='0' cellpadding='0'>
170 <tr class='text' bgcolor='#dddddd'>
171 <td width='100'>".htmlspecialchars(xl('Encounter'), ENT_QUOTES)."</td>
172 <td width='100'>".htmlspecialchars(xl('Date'), ENT_QUOTES)."</td>
173 </tr>".
174 //ProcessKeyForColoring(event,$CountIndex)==>Shows the navigation in the listing by change of colors and focus.Happens when down or up arrow is pressed.
175 "<tr class='text' height='20' bgcolor='$bgcolor' id=\"tr_insurance_$CountIndex\"
176 onkeydown=\"ProcessKeyForColoring(event,$CountIndex);$StringToAppend2(event,'&nbsp;','')\" onclick=\"$StringToAppend('&nbsp;','')\">
177 <td colspan='2' align='center'><a id='anchor_insurance_code_$CountIndex' href='#'></a></td>
178 </tr>
181 $res = sqlStatement("SELECT date,encounter FROM form_encounter
182 where pid ='$patient_code' ORDER BY encounter");
183 while ($row = sqlFetchArray($res)) {
184 if ($CountIndex%2==1) {
185 $bgcolor='#ddddff';
186 } else {
187 $bgcolor='#ffdddd';
190 $CountIndex++;
191 $Date=$row['date'];
192 $Date=explode(' ', $Date);
193 $Date=oeFormatShortDate($Date[0]);
194 $Encounter=$row['encounter'];
195 $StringForAjax.="<tr class='text' bgcolor='$bgcolor' id=\"tr_insurance_$CountIndex\"
196 onkeydown=\"ProcessKeyForColoring(event,$CountIndex);$StringToAppend2(event,'".htmlspecialchars($Encounter, ENT_QUOTES)."','".htmlspecialchars($Date, ENT_QUOTES)."')\" onclick=\"$StringToAppend('".htmlspecialchars($Encounter, ENT_QUOTES)."','".htmlspecialchars($Date, ENT_QUOTES)."')\">
197 <td><a id='anchor_insurance_code_$CountIndex' href='#' >".htmlspecialchars($Encounter)."</a></td>
198 <td><a href='#'>".htmlspecialchars($Date)."</a></td>
199 </tr>";
202 $StringForAjax.="</table></div>";
203 echo $StringForAjax;
204 die;