added Urdu language
[openemr.git] / interface / reports / edi_271.php
blobb0b800508f09e8e7583c086d514ba180ff8c9212
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/patient.inc");
22 include_once("$srcdir/report.inc");
23 include_once("$srcdir/calendar.inc");
24 include_once("$srcdir/edi.inc");
26 // END - INCLUDE STATEMENTS
29 // File location (URL or server path)
31 $target = $GLOBALS['edi_271_file_path'];
33 if(isset($_FILES) && !empty($_FILES))
36 $target = $target .time().basename( $_FILES['uploaded']['name']);
38 $FilePath = $target;
40 if ($_FILES['uploaded']['size'] > 350000)
42 $message .= htmlspecialchars( xl('Your file is too large'), ENT_NOQUOTES)."<br>";
46 if ($_FILES['uploaded']['type']!="text/plain")
48 $message .= htmlspecialchars( xl('You may only upload .txt files'), ENT_NOQUOTES)."<br>";
50 if(!isset($message))
52 if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
54 $message = htmlspecialchars( xl('The following EDI file has been uploaded').': "'. basename( $_FILES['uploaded']['name']).'"', ENT_NOQUOTES);
56 // Stores the content of the file
57 $Response271= file($FilePath);
59 // Counts the number of lines
60 $LineCount = count($Lines);
62 //This will be a two dimensional array
63 //that holds the content nicely organized
65 $DataSegment271 = array();
66 $Segments271 = array();
68 // We will use this as an index
69 $i = 0;
70 $j = 0;
71 $patientId = "";
73 // Loop through each line
74 foreach($Response271 as $Value)
76 // In the array store this line
77 // with values delimited by ^ (tilt)
78 // as separate array values
80 $DataSegment271[$i] = explode("^", $Value);
83 if(count($DataSegment271[$i])<6)
85 $messageEDI = true;
86 $message = "";
87 if(file_exists($target))
89 unlink($target);
92 else
94 foreach ($DataSegment271[$i] as $datastrings)
97 $Segments271[$j] = explode("*", $datastrings);
99 $segment = $Segments271[$j][0];
102 // Switch Case for Segment
104 switch ($segment)
106 case 'ISA':
108 $j = 0;
110 foreach($Segments271[$j] as $segmentVal){
112 if($j == 6)
114 $x12PartnerId = $segmentVal;
117 $j = $j + 1;
120 break;
122 case 'REF':
124 foreach($Segments271[$j] as $segmentVal){
126 if($segmentVal == "EJ")
128 $patientId = $Segments271[$j][2];
132 break;
134 case 'EB':
136 foreach($Segments271[$j] as $segmentVal){
140 break;
142 case 'MSG':
144 foreach($Segments271[$j] as $segmentVal){
146 if($segment != $segmentVal)
148 eligibility_response_save($segmentVal,$x12PartnerId);
150 eligibility_verification_save($segmentVal,$x12PartnerId,$patientId);
154 break;
162 // Increase the line index
163 $j++;
166 //Increase the line index
167 $i++;
171 else
173 $message .= htmlspecialchars( xl('Sorry, there was a problem uploading your file'), ENT_NOQUOTES). "<br><br>";
178 <html>
179 <head>
180 <?php html_header_show();?>
181 <title><?php echo htmlspecialchars( xl('EDI-271 Response File Upload'), ENT_NOQUOTES); ?></title>
182 <link rel=stylesheet href="<?php echo $css_header;?>" type="text/css">
183 <style type="text/css">
185 /* specifically include & exclude from printing */
186 @media print {
187 #report_parameters {
188 visibility: hidden;
189 display: none;
191 #report_parameters_daterange {
192 visibility: visible;
193 display: inline;
195 #report_results table {
196 margin-top: 0px;
200 /* specifically exclude some from the screen */
201 @media screen {
202 #report_parameters_daterange {
203 visibility: hidden;
204 display: none;
208 </style>
210 <script type="text/javascript" src="../../library/textformat.js"></script>
211 <script type="text/javascript" src="../../library/dialog.js?v=<?php echo $v_js_includes; ?>"></script>
212 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-3-2/index.js"></script>
214 <script type="text/javascript">
215 function edivalidation(){
217 var mypcc = "<?php echo htmlspecialchars( xl('Required Field Missing: Please choose the EDI-271 file to upload'), ENT_QUOTES);?>";
219 if(document.getElementById('uploaded').value == ""){
220 alert(mypcc);
221 return false;
223 else
225 $("#theform").submit();
229 </script>
231 </head>
232 <body class="body_top">
234 <div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>
235 <?php if(isset($message) && !empty($message))
238 <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>
239 <?php
240 $message = "";
242 if(isset($messageEDI))
245 <div style="margin-left:25%;width:50%;color:RED;text-align:center;font-family:arial;font-size:15px;background:#ECECEC;border:1px solid;" >
246 <?php echo htmlspecialchars( xl('Please choose the proper formatted EDI-271 file'), ENT_NOQUOTES); ?>
247 </div>
248 <?php
249 $messageEDI = "";
253 <div>
255 <span class='title'><?php echo htmlspecialchars( xl('EDI-271 File Upload'), ENT_NOQUOTES); ?></span>
257 <form enctype="multipart/form-data" name="theform" id="theform" action="edi_271.php" method="POST" onsubmit="return top.restoreSession()">
259 <div id="report_parameters">
260 <table>
261 <tr>
262 <td width='550px'>
263 <div style='float:left'>
264 <table class='text'>
265 <tr>
266 <td style='width:125px;' class='label_custom'> <?php echo htmlspecialchars( xl('Select EDI-271 file'), ENT_NOQUOTES); ?>: </td>
267 <td> <input name="uploaded" id="uploaded" type="file" size=37 /></td>
268 </tr>
269 </table>
270 </div>
271 </td>
272 <td align='left' valign='middle' height="100%">
273 <table style='border-left:1px solid; width:100%; height:100%' >
274 <tr>
275 <td>
276 <div style='margin-left:15px'>
277 <a href='#' class='css_button' onclick='return edivalidation(); '><span><?php echo htmlspecialchars( xl('Upload'), ENT_NOQUOTES); ?></span>
278 </a>
279 </div>
280 </td>
281 </tr>
282 </table>
283 </td>
284 </tr>
285 </table>
286 </div>
289 <input type="hidden" name="form_orderby" value="<?php echo htmlspecialchars( $form_orderby, ENT_QUOTES); ?>" />
290 <input type='hidden' name='form_refresh' id='form_refresh' value=''/>
292 </form>
293 </body>
294 </html>