Portal updates and general bug fixes (#2318)
[openemr.git] / interface / reports / edi_271.php
blob7796710a8a20353d9091ccd9d76f78f5060cab14
1 <?php
2 /**
3 * Functions to globally validate and prepare data for sql database insertion.
5 * @package OpenEMR
6 * @link http://www.open-emr.org
7 * @author MMF Systems, Inc
8 * @author Brady Miller <brady.g.miller@gmail.com>
9 * @author Jerry Padgett <sjpadgett@gmail.com>
10 * @copyright Copyright (c) 2010 MMF Systems, Inc
11 * @copyright Copyright (c) 2018 Brady Miller <brady.g.miller@gmail.com>
12 * @copyright Copyright (c) 2019 Jerry Padgett <sjpadgett@gmail.com>
13 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
16 require_once(dirname(__file__)."/../globals.php");
17 require_once("$srcdir/forms.inc");
18 require_once("$srcdir/patient.inc");
19 require_once("$srcdir/report.inc");
20 require_once("$srcdir/calendar.inc");
21 require_once("$srcdir/edi.inc");
23 use OpenEMR\Core\Header;
25 if (!empty($_POST)) {
26 if (!verifyCsrfToken($_POST["csrf_token_form"])) {
27 csrfNotVerified();
31 // File location (URL or server path)
32 $target = $GLOBALS['edi_271_file_path'];
33 $batch_log = '';
35 if (isset($_FILES) && !empty($_FILES)) {
36 $target = $target .time().basename($_FILES['uploaded']['name']);
38 if ($_FILES['uploaded']['size'] > 350000) {
39 $message .= xlt('Your file is too large')."<br>";
41 if ($_FILES['uploaded']['type']!="text/plain") {
42 $message .= xlt('You may only upload .txt files')."<br>";
44 if (!isset($message)) {
45 $file_location = move_uploaded_file($_FILES['uploaded']['tmp_name'], $target);
46 $message = xlt('The following EDI file has been uploaded') . ': "' . text(basename($_FILES['uploaded']['name'])) . '"';
47 $Response271 = file($_FILES['uploaded']['tmp_name']);
48 $batch_log = parseEdi271($Response271);
49 } else {
50 $message .= xlt('Sorry, there was a problem uploading your file') . "<br><br>";
53 if ($batch_log && !$GLOBALS['disable_eligibility_log']) {
54 $fn = sprintf(
55 'elig-batch_log_%s.txt',
56 date("Y-m-d:H:i:s")
58 $batch_log = str_replace('~', "~\r", $batch_log);
59 while (@ob_end_flush()) {
61 header('Content-Type: text/plain');
62 header("Content-Length: " . strlen($batch_log));
63 header('Content-Disposition: attachment; filename="' . $fn . '"');
64 ob_start();
65 echo $batch_log;
66 exit();
69 <html>
70 <head>
71 <title><?php echo xlt('EDI-271 Response File Upload'); ?></title>
73 <?php Header::setupHeader(['no_bootstrap', 'no_fontawesome']); ?>
75 <style type="text/css">
76 /* specifically include & exclude from printing */
77 @media print {
78 #report_parameters {
79 visibility: hidden;
80 display: none;
82 #report_parameters_daterange {
83 visibility: visible;
84 display: inline;
86 #report_results table {
87 margin-top: 0px;
90 /* specifically exclude some from the screen */
91 @media screen {
92 #report_parameters_daterange {
93 visibility: hidden;
94 display: none;
97 </style>
98 <script type="text/javascript">
99 function edivalidation() {
100 var mypcc = <?php echo xlj('Required Field Missing: Please choose the EDI-271 file to upload'); ?>;
101 if (document.getElementById('uploaded').value == "") {
102 alert(mypcc);
103 return false;
104 } else {
105 $("#theform").trigger("submit");
108 </script>
109 </head>
110 <body class="body_top">
111 <div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>
112 <?php if (isset($message) && !empty($message)) { ?>
113 <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>
114 <?php
115 $message = "";
117 if (isset($messageEDI)) { ?>
118 <div style="margin-left:25%;width:50%;color:RED;text-align:center;font-family:arial;font-size:15px;background:#ECECEC;border:1px solid;" >
119 <?php echo xlt('Please choose the proper formatted EDI-271 file'); ?>
120 </div>
121 <?php
122 $messageEDI = "";
123 } ?>
124 <div>
125 <span class='title'><?php echo xlt('EDI-271 File Upload'); ?></span>
126 <form enctype="multipart/form-data" name="theform" id="theform" action="edi_271.php" method="POST" onsubmit="return top.restoreSession()">
127 <input type="hidden" name="csrf_token_form" value="<?php echo attr(collectCsrfToken()); ?>" />
128 <div id="report_parameters">
129 <table>
130 <tr>
131 <td width='550px'>
132 <div style='float:left'>
133 <table class='text'>
134 <tr>
135 <td style='width:125px;' class='label_custom'> <?php echo xlt('Select EDI-271 file'); ?>: </td>
136 <td> <input name="uploaded" id="uploaded" type="file" size=37 /></td>
137 </tr>
138 </table>
139 </div>
140 </td>
141 <td align='left' valign='middle' height="100%">
142 <table style='border-left:1px solid; width:100%; height:100%' >
143 <tr>
144 <td>
145 <div style='margin-left:15px'>
146 <a href='#' class='css_button' onclick='return edivalidation(); '><span><?php echo xlt('Upload'); ?></span>
147 </a>
148 </div>
149 </td>
150 </tr>
151 </table>
152 </td>
153 </tr>
154 </table>
155 </div>
156 <input type="hidden" name="form_orderby" value="<?php echo attr($form_orderby); ?>" />
157 <input type='hidden' name='form_refresh' id='form_refresh' value=''/>
158 </form>
159 </body>
160 </html>