Focus the search term on load
[openemr.git] / interface / billing / edi_history_main.php
blob6dafcaa21aa38f7e4742b71a270b0773ceb2980d
1 <?php
2 /*
3 * edi_history_main.php
4 *
5 * Copyright 2012 Kevin McCormick Longview, Texas
6 *
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; version 3 or later. You should have
16 * received a copy of the GNU General Public License along with this program;
17 * if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 * <http://opensource.org/licenses/gpl-license.php>
22 * @author Kevin McCormick
23 * @link: http://www.open-emr.org
24 * @package OpenEMR
25 * @subpackage ediHistory
28 /* these lines for OpenEMR
29 */
30 $sanitize_all_escapes=true;
31 $fake_register_globals=false;
32 require_once(dirname(__FILE__) . "/../globals.php");
34 /**
35 * this define is used to prevent direct access to the included scripts
36 * which have the corresponding definition commented for now
38 define('SITE_IN', 1);
40 // define constants
41 // since enounter digits are sequential, digit length should rarely change
42 // however for a startup they may, or a "mask" value of 1000 or 10000
43 // would be a good idea if there are problems with deciphering the pid-encounter
44 // same idea for pid value, but since encounter is unique and always last, it is essential
45 // possibly check the mask value in OpenEMR globals to set this
46 /**
47 * Try and prevent panic if patient invoice number is mangled by treating the last
48 * digits as the encounter number
50 if (!defined("IBR_ENCOUNTER_DIGIT_LENGTH")) define("IBR_ENCOUNTER_DIGIT_LENGTH", "5");
51 /**
52 * these delimiters are hardcoded into OpenEMR batch files
53 */
54 if (!defined("SEG_ELEM_DELIM")) define( "SEG_ELEM_DELIM" , "*");
55 if (!defined("SEG_TERM_DELIM")) define( "SEG_TERM_DELIM" , "~");
56 /**
57 * clearinghouse practice
59 if (!defined("IBR_DELIMITER")) define("IBR_DELIMITER", "|");
61 // path will be "$srcdir/edihistory/filename.php"
62 require_once("$srcdir/edihistory/csv_record_include.php"); //dirname(__FILE__) . "/edihist/csv_record_include.php");
63 require_once("$srcdir/edihistory/ibr_era_read.php"); //dirname(__FILE__) . "/edihist/ibr_era_read.php");
64 require_once("$srcdir/edihistory/ibr_code_arrays.php"); //dirname(__FILE__) . "/edihist/ibr_code_arrays.php");
65 require_once("$srcdir/edihistory/ibr_ebr_read.php"); //dirname(__FILE__) . "/edihist/ibr_ebr_read.php");
66 require_once("$srcdir/edihistory/ibr_997_read.php"); //dirname(__FILE__) . "/edihist/ibr_997_read.php");
67 require_once("$srcdir/edihistory/ibr_277_read.php"); //dirname(__FILE__) . "/edihist/ibr_277_read.php");
68 require_once("$srcdir/edihistory/ibr_status_code_arrays.php"); //dirname(__FILE__) . "/edihist/ibr_status_code_arrays.php");
69 require_once("$srcdir/edihistory/ibr_batch_read.php"); //dirname(__FILE__) . "/edihist/ibr_batch_read.php");
70 require_once("$srcdir/edihistory/ibr_ack_read.php"); //dirname(__FILE__) . "/edihist/ibr_ack_read.php");
71 require_once("$srcdir/edihistory/ibr_uploads.php"); //dirname(__FILE__) . "/edihist/ibr_uploads.php");
72 require_once("$srcdir/edihistory/ibr_io.php"); //dirname(__FILE__) . "/edihist/ibr_io.php");
74 // php may output line endings if include files are utf-8
75 ob_clean();
77 if (isset($GLOBALS['OE_SITE_DIR'])) {
78 $ibr_upldir = csv_edih_basedir();
79 $ibr_tmp = csv_edih_tmpdir();
80 } else {
81 die("EDI History: Did not get directory path information!");
84 // if we are not set up, create directories and csv files
85 //if (!is_dir(dirname(__FILE__) . '/edihist' . IBR_HISTORY_DIR) ) {
86 if (!is_dir($ibr_upldir)) {
88 echo "setup with base directory: $ibr_upldir <br />" .PHP_EOL;
89 $is_set = csv_setup($html_str );
90 if (!$is_set) {
91 print $html_str;
92 csv_clear_tmpdir();
93 exit;
97 /* ******* remove functions to separate file ******* */
98 /*
99 * functions called in the if stanzas are now in ibr_io.php
102 if (strtolower($_SERVER['REQUEST_METHOD']) == 'post') {
104 if ( isset($_POST['NewFiles']) ) {
105 // process new files button clicked
106 $html_str = ibr_disp_newfiles();
108 } elseif ( isset($_POST['Batch-enctr']) && isset($_POST['enctrbatch']) ) {
109 // may be ajax for dialog or straight for new window
110 $html_str = is_xhr() ? '' : ibr_html_heading('textdisplay');
111 $html_str .= ibr_disp_claimst();
113 } elseif (isset($_POST['eraText']) && $_POST['enctrEra'] ) {
114 // get the text of an era remittance from the file
115 $html_str = is_xhr() ? '' : ibr_html_heading('textdisplay');
116 $html_str .= ibr_disp_eraClp();
118 } elseif (isset($_POST['csvshowtable'])) {
119 // should be ajax
120 $html_str = is_xhr() ? '' : ibr_html_heading('csvtable');
121 $html_str .= ibr_disp_csvtable();
123 } elseif (isset($_POST['subpid835']) ) {
124 // era table display for patient id
125 $html_str = is_xhr() ? '' : ibr_html_heading('eradisplay');
126 $html_str .= ibr_disp_era_post();
128 } elseif (isset($_POST['subenctr835']) ) {
129 // era table display for encounter ibr_disp_era_get()
130 $html_str = is_xhr() ? '' : ibr_html_heading('eradisplay');
131 $html_str .= ibr_disp_era_post();
133 } elseif (isset($_POST['subtrace835']) ) {
134 // era table display be trace number
135 $html_str = is_xhr() ? '' : ibr_html_heading('eradisplay');
136 $html_str .= ibr_disp_era_post();
138 } elseif (isset($_POST['fileERA']) && isset($_FILES['fileUplEra'])) {
139 // upload local files for display _FILES accessed in called functions
140 $html_str = is_xhr() ? 'XHR XMLHttpRequest' : ibr_html_heading('eradisplay');
141 $html_str .= ibr_disp_eraFileUpl();
143 } elseif (isset($_POST['fileX12']) ) {
144 // upload local x12 file
145 $html_str = is_xhr() ? '' : ibr_html_heading('x12display');
146 //$html_str .= ibr_disp_fileUpl();
147 $html_str .= ibr_disp_fileText();
149 } elseif (isset($_POST['uplsubmt']) && isset($_FILES['fileUplMulti']) ) {
150 // upload multiple files for sorting and storage
151 // output is a popup window and full html is required
152 $html_str = ibr_html_heading('newfiles');
153 $html_str .= ibr_disp_fileMulti();
155 } elseif (isset($_POST['putnotes']) ) {
156 $html_str = ibr_history_notes();
158 } else {
159 $html_str = ibr_html_heading('error');
160 $html_str .= "<p>Error: unrecognized value in POST array</p>".PHP_EOL;
161 foreach($_POST as $ky => $val) {
162 $html_str .= "$ky : $val <br />".PHP_EOL;
164 } // end if (strtolower($_SERVER['REQUEST_METHOD']) == 'post')
166 } elseif (strtolower($_SERVER['REQUEST_METHOD']) == 'get') {
168 if (isset($_GET['srvinfo']) && $_GET['srvinfo'] == 'yes') {
169 // initial ajax request
170 $html_str = ibr_inivals();
172 } elseif (isset($_GET['csvtbllist']) && $_GET['csvtbllist'] == 'yes') {
173 // initial ajax request
174 $html_str = csv_table_select_list();
176 } elseif (isset($_GET['ckprocessed']) && $_GET['ckprocessed'] == 'yes') {
177 // initial ajax request
178 $html_str = ibr_disp_is_era_processed();
180 } elseif (isset($_GET['fvkey']) ) {
181 // this will output to a new window (target=_blank)
182 $html_str .= ibr_disp_fileText();
184 } elseif (isset($_GET['btctln'])) {
185 $html_str .= ibr_disp_fileText();
187 } elseif (isset($_GET['erafn']) ) {
188 $html_str = is_xhr() ? '' : ibr_html_heading('eradisplay');
189 $html_str .= ibr_disp_era_get();
191 } elseif ( isset($_GET['fvbatch']) ) {
192 $html_str = is_xhr() ? '' : ibr_html_heading('textdisplay');
193 $html_str .= ibr_disp_claimst();
195 } elseif ( isset($_GET['chenctr']) ) {
196 $html_str = is_xhr() ? '' : ibr_html_heading('claimstatus');
197 $html_str .= ibr_disp_clmhist();
199 } elseif ( isset($_GET['rspfile']) ) {
200 $html_str = is_xhr() ? '' : ibr_html_heading('claimstatus');
201 $html_str .= ibr_disp_status_resp();
203 } elseif ( isset($_GET['dprfile']) ) {
204 $html_str = is_xhr() ? '' : ibr_html_heading('claimstatus');
205 $html_str .= ibr_disp_dpr_message();
207 } elseif ( isset($_GET['ebrfile']) ) {
208 $html_str = is_xhr() ? '' : ibr_html_heading('claimstatus');
209 $html_str .= ibr_disp_ebr_message();
211 } elseif ( isset($_GET['fv997']) ) {
212 $html_str = is_xhr() ? '' : ibr_html_heading('claimstatus');
213 $html_str .= ibr_disp_997_message();
215 } elseif ( isset($_GET['ackfile']) ) {
216 $html_str = is_xhr() ? '' : ibr_html_heading('claimstatus');
217 $html_str .= ibr_disp_ta1_message();
219 } elseif ( isset($_GET['batchicn']) ) {
220 $html_str = is_xhr() ? '' : ibr_html_heading('claimstatus');
221 $html_str .= ibr_disp_997_for_batch();
223 } elseif (array_key_exists('showlog', $_GET)) {
224 $la = filter_input(INPUT_GET, 'showlog', FILTER_SANITIZE_STRING);
225 $html_str = ($la) ? csv_log_html() : "input parameter error<br />" ;
227 } elseif (array_key_exists('archivelog', $_GET)) {
228 $la = filter_input(INPUT_GET, 'archivelog', FILTER_SANITIZE_STRING);
229 $html_str = ($la) ? csv_log_archive() : "input parameter error<br />" ;
231 } elseif (array_key_exists('getnotes', $_GET) ) {
232 $la = filter_input(INPUT_GET, 'getnotes', FILTER_SANITIZE_STRING);
233 $html_str = ($la) ? ibr_history_notes() : "input parameter error<br />";
235 } else {
236 $html_str = "EDI History: unknown parameter<br />" .PHP_EOL;
237 //$html_str .= var_dump($_GET) . PHP_EOL;
240 } else {
241 die("EDI History: invalid input method <br />");
245 $isclear = csv_clear_tmpdir();
246 if (!$isclear) {
247 echo "file contents remain in $ibr_tmp <br />".PHP_EOL;
248 csv_edihist_log("file contents remain in $ibr_tmp");
251 if (!$html_str) {
252 csv_edihist_log("no html output!");
253 die("No content in response <br />" . PHP_EOL);
256 print $html_str;