Focus the search term on load
[openemr.git] / interface / reports / edi_271.php
blobb2afe6026564e3adae94e748c028b47088a34f06
1 <?php
2 // Copyright (C) 2010 MMF Systems, Inc>
3 //
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
9 //SANITIZE ALL ESCAPES
10 $sanitize_all_escapes=true;
13 //STOP FAKE REGISTER GLOBALS
14 $fake_register_globals=false;
17 // START - INCLUDE STATEMENTS
18 include_once(dirname(__file__)."/../globals.php");
19 include_once("$srcdir/forms.inc");
20 include_once("$srcdir/billing.inc");
21 include_once("$srcdir/pnotes.inc");
22 include_once("$srcdir/patient.inc");
23 include_once("$srcdir/report.inc");
24 include_once("$srcdir/calendar.inc");
25 include_once("$srcdir/classes/Document.class.php");
26 include_once("$srcdir/classes/Note.class.php");
27 include_once("$srcdir/sqlconf.php");
28 include_once("$srcdir/edi.inc");
30 // END - INCLUDE STATEMENTS
33 // File location (URL or server path)
35 $target = $GLOBALS['edi_271_file_path'];
37 if(isset($_FILES) && !empty($_FILES))
40 $target = $target .time().basename( $_FILES['uploaded']['name']);
42 $FilePath = $target;
44 if ($_FILES['uploaded']['size'] > 350000)
46 $message .= htmlspecialchars( xl('Your file is too large'), ENT_NOQUOTES)."<br>";
50 if ($_FILES['uploaded']['type']!="text/plain")
52 $message .= htmlspecialchars( xl('You may only upload .txt files'), ENT_NOQUOTES)."<br>";
54 if(!isset($message))
56 if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
58 $message = htmlspecialchars( xl('The following EDI file has been uploaded').': "'. basename( $_FILES['uploaded']['name']).'"', ENT_NOQUOTES);
60 // Stores the content of the file
61 $Response271= file($FilePath);
63 // Counts the number of lines
64 $LineCount = count($Lines);
66 //This will be a two dimensional array
67 //that holds the content nicely organized
69 $DataSegment271 = array();
70 $Segments271 = array();
72 // We will use this as an index
73 $i = 0;
74 $j = 0;
75 $patientId = "";
77 // Loop through each line
78 foreach($Response271 as $Value)
80 // In the array store this line
81 // with values delimited by ^ (tilt)
82 // as separate array values
84 $DataSegment271[$i] = explode("^", $Value);
87 if(count($DataSegment271[$i])<6)
89 $messageEDI = true;
90 $message = "";
91 if(file_exists($target))
93 unlink($target);
96 else
98 foreach ($DataSegment271[$i] as $datastrings)
101 $Segments271[$j] = explode("*", $datastrings);
103 $segment = $Segments271[$j][0];
106 // Switch Case for Segment
108 switch ($segment)
110 case 'ISA':
112 $j = 0;
114 foreach($Segments271[$j] as $segmentVal){
116 if($j == 6)
118 $x12PartnerId = $segmentVal;
121 $j = $j + 1;
124 break;
126 case 'REF':
128 foreach($Segments271[$j] as $segmentVal){
130 if($segmentVal == "EJ")
132 $patientId = $Segments271[$j][2];
136 break;
138 case 'EB':
140 foreach($Segments271[$j] as $segmentVal){
144 break;
146 case 'MSG':
148 foreach($Segments271[$j] as $segmentVal){
150 if($segment != $segmentVal)
152 eligibility_response_save($segmentVal,$x12PartnerId);
154 eligibility_verification_save($segmentVal,$x12PartnerId,$patientId);
158 break;
166 // Increase the line index
167 $j++;
170 //Increase the line index
171 $i++;
175 else
177 $message .= htmlspecialchars( xl('Sorry, there was a problem uploading your file'), ENT_NOQUOTES). "<br><br>";
182 <html>
183 <head>
184 <?php html_header_show();?>
185 <title><?php echo htmlspecialchars( xl('EDI-271 Response File Upload'), ENT_NOQUOTES); ?></title>
186 <link rel=stylesheet href="<?php echo $css_header;?>" type="text/css">
187 <style type="text/css">
189 /* specifically include & exclude from printing */
190 @media print {
191 #report_parameters {
192 visibility: hidden;
193 display: none;
195 #report_parameters_daterange {
196 visibility: visible;
197 display: inline;
199 #report_results table {
200 margin-top: 0px;
204 /* specifically exclude some from the screen */
205 @media screen {
206 #report_parameters_daterange {
207 visibility: hidden;
208 display: none;
212 </style>
214 <script type="text/javascript" src="../../library/textformat.js"></script>
215 <script type="text/javascript" src="../../library/dialog.js"></script>
216 <script type="text/javascript" src="../../library/js/jquery.1.3.2.js"></script>
218 <script type="text/javascript">
219 function edivalidation(){
221 var mypcc = "<?php echo htmlspecialchars( xl('Required Field Missing: Please choose the EDI-271 file to upload'), ENT_QUOTES);?>";
223 if(document.getElementById('uploaded').value == ""){
224 alert(mypcc);
225 return false;
227 else
229 $("#theform").submit();
233 </script>
235 </head>
236 <body class="body_top">
238 <div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>
239 <?php if(isset($message) && !empty($message))
242 <div style="margin-left:25%;width:50%;color:RED;text-align:center;font-family:arial;font-size:15px;background:#ECECEC;border:1px solid;" ><?php echo $message; ?></div>
243 <?php
244 $message = "";
246 if(isset($messageEDI))
249 <div style="margin-left:25%;width:50%;color:RED;text-align:center;font-family:arial;font-size:15px;background:#ECECEC;border:1px solid;" >
250 <?php echo htmlspecialchars( xl('Please choose the proper formatted EDI-271 file'), ENT_NOQUOTES); ?>
251 </div>
252 <?php
253 $messageEDI = "";
257 <div>
259 <span class='title'><?php echo htmlspecialchars( xl('EDI-271 File Upload'), ENT_NOQUOTES); ?></span>
261 <form enctype="multipart/form-data" name="theform" id="theform" action="edi_271.php" method="POST" onsubmit="return top.restoreSession()">
263 <div id="report_parameters">
264 <table>
265 <tr>
266 <td width='550px'>
267 <div style='float:left'>
268 <table class='text'>
269 <tr>
270 <td style='width:125px;' class='label'> <?php echo htmlspecialchars( xl('Select EDI-271 file'), ENT_NOQUOTES); ?>: </td>
271 <td> <input name="uploaded" id="uploaded" type="file" size=37 /></td>
272 </tr>
273 </table>
274 </div>
275 </td>
276 <td align='left' valign='middle' height="100%">
277 <table style='border-left:1px solid; width:100%; height:100%' >
278 <tr>
279 <td>
280 <div style='margin-left:15px'>
281 <a href='#' class='css_button' onclick='return edivalidation(); '><span><?php echo htmlspecialchars( xl('Upload'), ENT_NOQUOTES); ?></span>
282 </a>
283 </div>
284 </td>
285 </tr>
286 </table>
287 </td>
288 </tr>
289 </table>
290 </div>
293 <input type="hidden" name="form_orderby" value="<?php echo htmlspecialchars( $form_orderby, ENT_QUOTES); ?>" />
294 <input type='hidden' name='form_refresh' id='form_refresh' value=''/>
296 </form>
297 </body>
298 </html>