another billing class and moved reports to billing (#2683)
[openemr.git] / interface / billing / edi_271.php
blobc1e51cff0b188140bb73d2fd316273bd2e3d625b
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");
22 use OpenEMR\Billing\EDI_270;
23 use OpenEMR\Common\Csrf\CsrfUtils;
24 use OpenEMR\Core\Header;
26 if (!empty($_POST)) {
27 if (!CsrfUtils::verifyCsrfToken($_POST["csrf_token_form"])) {
28 CsrfUtils::csrfNotVerified();
32 // File location (URL or server path)
33 $target = $GLOBALS['edi_271_file_path'];
34 $batch_log = '';
36 if (isset($_FILES) && !empty($_FILES)) {
37 $target = $target .time().basename($_FILES['uploaded']['name']);
39 if ($_FILES['uploaded']['size'] > 350000) {
40 $message .= xlt('Your file is too large')."<br>";
42 if ($_FILES['uploaded']['type'] != "text/plain") {
43 $message .= xlt('You may only upload .txt files')."<br>";
45 if (!isset($message)) {
46 $file_moved = move_uploaded_file($_FILES['uploaded']['tmp_name'], $target);
47 if ($file_moved) {
48 $message = xlt('The following EDI file has been uploaded') . ': "' . text(basename($_FILES['uploaded']['name'])) . '"';
49 $Response271 = file($target);
50 if ($Response271) {
51 $batch_log = EDI_270::parseEdi271($Response271);
52 } else {
53 $message = xlt('The following EDI file upload failed to open') . ': "' . text(basename($_FILES['uploaded']['name'])) . '"';
55 } else {
56 $message = xlt('The following EDI file failed save to archive') . ': "' . text(basename($_FILES['uploaded']['name'])) . '"';
58 } else {
59 $message .= xlt('Sorry, there was a problem uploading your file') . "<br><br>";
62 if ($batch_log && !$GLOBALS['disable_eligibility_log']) {
63 $fn = sprintf(
64 'elig-batch_log_%s.txt',
65 date("Y-m-d:H:i:s")
67 $batch_log = str_replace('~', "~\r", $batch_log);
68 while (@ob_end_flush()) {
70 header('Content-Type: text/plain');
71 header("Content-Length: " . strlen($batch_log));
72 header('Content-Disposition: attachment; filename="' . $fn . '"');
73 ob_start();
74 echo $batch_log;
75 exit();
78 <html>
79 <head>
80 <title><?php echo xlt('EDI-271 Response File Upload'); ?></title>
82 <?php Header::setupHeader(['no_bootstrap', 'no_fontawesome']); ?>
84 <style type="text/css">
85 /* specifically include & exclude from printing */
86 @media print {
87 #report_parameters {
88 visibility: hidden;
89 display: none;
91 #report_parameters_daterange {
92 visibility: visible;
93 display: inline;
95 #report_results table {
96 margin-top: 0px;
99 /* specifically exclude some from the screen */
100 @media screen {
101 #report_parameters_daterange {
102 visibility: hidden;
103 display: none;
106 </style>
107 <script type="text/javascript">
108 function edivalidation() {
109 var mypcc = <?php echo xlj('Required Field Missing: Please choose the EDI-271 file to upload'); ?>;
110 if (document.getElementById('uploaded').value == "") {
111 alert(mypcc);
112 return false;
113 } else {
114 $("#theform").trigger("submit");
117 </script>
118 </head>
119 <body class="body_top">
120 <div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>
121 <?php if (isset($message) && !empty($message)) { ?>
122 <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>
123 <?php
124 $message = "";
126 if (isset($messageEDI)) { ?>
127 <div style="margin-left:25%;width:50%;color:RED;text-align:center;font-family:arial;font-size:15px;background:#ECECEC;border:1px solid;" >
128 <?php echo xlt('Please choose the proper formatted EDI-271 file'); ?>
129 </div>
130 <?php
131 $messageEDI = "";
132 } ?>
133 <div>
134 <span class='title'><?php echo xlt('EDI-271 File Upload'); ?></span>
135 <form enctype="multipart/form-data" name="theform" id="theform" action="edi_271.php" method="POST" onsubmit="return top.restoreSession()">
136 <input type="hidden" name="csrf_token_form" value="<?php echo attr(CsrfUtils::collectCsrfToken()); ?>" />
137 <div id="report_parameters">
138 <table>
139 <tr>
140 <td width='550px'>
141 <div style='float:left'>
142 <table class='text'>
143 <tr>
144 <td style='width:125px;' class='label_custom'> <?php echo xlt('Select EDI-271 file'); ?>: </td>
145 <td> <input name="uploaded" id="uploaded" type="file" size=37 /></td>
146 </tr>
147 </table>
148 </div>
149 </td>
150 <td align='left' valign='middle' height="100%">
151 <table style='border-left:1px solid; width:100%; height:100%' >
152 <tr>
153 <td>
154 <div style='margin-left:15px'>
155 <a href='#' class='css_button' onclick='return edivalidation(); '><span><?php echo xlt('Upload'); ?></span>
156 </a>
157 </div>
158 </td>
159 </tr>
160 </table>
161 </td>
162 </tr>
163 </table>
164 </div>
165 <input type="hidden" name="form_orderby" value="<?php echo attr($form_orderby); ?>" />
166 <input type='hidden' name='form_refresh' id='form_refresh' value=''/>
167 </form>
168 </body>
169 </html>