ongoing internationalization of date widget
[openemr.git] / interface / reports / edi_271.php
blob76a686d187a1060b179872f0672c1bd75e6ff622
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.
10 // START - INCLUDE STATEMENTS
11 include_once(dirname(__file__)."/../globals.php");
12 include_once("$srcdir/forms.inc");
13 include_once("$srcdir/billing.inc");
14 include_once("$srcdir/patient.inc");
15 include_once("$srcdir/report.inc");
16 include_once("$srcdir/calendar.inc");
17 include_once("$srcdir/edi.inc");
19 // END - INCLUDE STATEMENTS
22 // File location (URL or server path)
24 $target = $GLOBALS['edi_271_file_path'];
26 if (isset($_FILES) && !empty($_FILES)) {
27 $target = $target .time().basename($_FILES['uploaded']['name']);
29 $FilePath = $target;
31 if ($_FILES['uploaded']['size'] > 350000) {
32 $message .= htmlspecialchars(xl('Your file is too large'), ENT_NOQUOTES)."<br>";
35 if ($_FILES['uploaded']['type']!="text/plain") {
36 $message .= htmlspecialchars(xl('You may only upload .txt files'), ENT_NOQUOTES)."<br>";
39 if (!isset($message)) {
40 if (move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) {
41 $message = htmlspecialchars(xl('The following EDI file has been uploaded').': "'. basename($_FILES['uploaded']['name']).'"', ENT_NOQUOTES);
43 // Stores the content of the file
44 $Response271= file($FilePath);
46 // Counts the number of lines
47 $LineCount = count($Lines);
49 //This will be a two dimensional array
50 //that holds the content nicely organized
52 $DataSegment271 = array();
53 $Segments271 = array();
55 // We will use this as an index
56 $i = 0;
57 $j = 0;
58 $patientId = "";
60 // Loop through each line
61 foreach ($Response271 as $Value) {
62 // In the array store this line
63 // with values delimited by ^ (tilt)
64 // as separate array values
66 $DataSegment271[$i] = explode("^", $Value);
69 if (count($DataSegment271[$i])<6) {
70 $messageEDI = true;
71 $message = "";
72 if (file_exists($target)) {
73 unlink($target);
75 } else {
76 foreach ($DataSegment271[$i] as $datastrings) {
77 $Segments271[$j] = explode("~", $datastrings);
79 $segment = $Segments271[$j][0];
82 // Switch Case for Segment
84 switch ($segment) {
85 case 'ISA':
86 $j = 0;
88 foreach ($Segments271[$j] as $segmentVal) {
89 if ($j == 6) {
90 $x12PartnerId = $segmentVal;
93 $j = $j + 1;
95 break;
97 case 'REF':
98 foreach ($Segments271[$j] as $segmentVal) {
99 if ($segmentVal == "EJ") {
100 $patientId = $Segments271[$j][2];
103 break;
105 case 'EB':
106 foreach ($Segments271[$j] as $segmentVal) {
108 break;
110 case 'MSG':
111 foreach ($Segments271[$j] as $segmentVal) {
112 if ($segment != $segmentVal) {
113 eligibility_response_save($segmentVal, $x12PartnerId);
115 eligibility_verification_save($segmentVal, $x12PartnerId, $patientId);
118 break;
123 // Increase the line index
124 $j++;
128 //Increase the line index
129 $i++;
132 } else {
133 $message .= htmlspecialchars(xl('Sorry, there was a problem uploading your file'), ENT_NOQUOTES). "<br><br>";
138 <html>
139 <head>
140 <?php html_header_show();?>
141 <title><?php echo htmlspecialchars(xl('EDI-271 Response File Upload'), ENT_NOQUOTES); ?></title>
142 <link rel=stylesheet href="<?php echo $css_header;?>" type="text/css">
143 <style type="text/css">
145 /* specifically include & exclude from printing */
146 @media print {
147 #report_parameters {
148 visibility: hidden;
149 display: none;
151 #report_parameters_daterange {
152 visibility: visible;
153 display: inline;
155 #report_results table {
156 margin-top: 0px;
160 /* specifically exclude some from the screen */
161 @media screen {
162 #report_parameters_daterange {
163 visibility: hidden;
164 display: none;
168 </style>
170 <script type="text/javascript" src="../../library/textformat.js"></script>
171 <script type="text/javascript" src="../../library/dialog.js?v=<?php echo $v_js_includes; ?>"></script>
172 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-3-2/index.js"></script>
174 <script type="text/javascript">
175 function edivalidation(){
177 var mypcc = "<?php echo htmlspecialchars(xl('Required Field Missing: Please choose the EDI-271 file to upload'), ENT_QUOTES);?>";
179 if(document.getElementById('uploaded').value == ""){
180 alert(mypcc);
181 return false;
183 else
185 $("#theform").submit();
189 </script>
191 </head>
192 <body class="body_top">
194 <div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>
195 <?php if (isset($message) && !empty($message)) {
197 <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>
198 <?php
199 $message = "";
202 if (isset($messageEDI)) {
204 <div style="margin-left:25%;width:50%;color:RED;text-align:center;font-family:arial;font-size:15px;background:#ECECEC;border:1px solid;" >
205 <?php echo htmlspecialchars(xl('Please choose the proper formatted EDI-271 file'), ENT_NOQUOTES); ?>
206 </div>
207 <?php
208 $messageEDI = "";
212 <div>
214 <span class='title'><?php echo htmlspecialchars(xl('EDI-271 File Upload'), ENT_NOQUOTES); ?></span>
216 <form enctype="multipart/form-data" name="theform" id="theform" action="edi_271.php" method="POST" onsubmit="return top.restoreSession()">
218 <div id="report_parameters">
219 <table>
220 <tr>
221 <td width='550px'>
222 <div style='float:left'>
223 <table class='text'>
224 <tr>
225 <td style='width:125px;' class='label_custom'> <?php echo htmlspecialchars(xl('Select EDI-271 file'), ENT_NOQUOTES); ?>: </td>
226 <td> <input name="uploaded" id="uploaded" type="file" size=37 /></td>
227 </tr>
228 </table>
229 </div>
230 </td>
231 <td align='left' valign='middle' height="100%">
232 <table style='border-left:1px solid; width:100%; height:100%' >
233 <tr>
234 <td>
235 <div style='margin-left:15px'>
236 <a href='#' class='css_button' onclick='return edivalidation(); '><span><?php echo htmlspecialchars(xl('Upload'), ENT_NOQUOTES); ?></span>
237 </a>
238 </div>
239 </td>
240 </tr>
241 </table>
242 </td>
243 </tr>
244 </table>
245 </div>
248 <input type="hidden" name="form_orderby" value="<?php echo htmlspecialchars($form_orderby, ENT_QUOTES); ?>" />
249 <input type='hidden' name='form_refresh' id='form_refresh' value=''/>
251 </form>
252 </body>
253 </html>