3 * Functions to globally validate and prepare data for sql database insertion.
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
;
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'];
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);
48 $message = xlt('The following EDI file has been uploaded') . ': "' . text(basename($_FILES['uploaded']['name'])) . '"';
49 $Response271 = file($target);
51 $batch_log = EDI_270
::parseEdi271($Response271);
53 $message = xlt('The following EDI file upload failed to open') . ': "' . text(basename($_FILES['uploaded']['name'])) . '"';
56 $message = xlt('The following EDI file failed save to archive') . ': "' . text(basename($_FILES['uploaded']['name'])) . '"';
59 $message .= xlt('Sorry, there was a problem uploading your file') . "<br><br>";
62 if ($batch_log && !$GLOBALS['disable_eligibility_log']) {
64 'elig-batch_log_%s.txt',
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 . '"');
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 */
91 #report_parameters_daterange {
95 #report_results table {
99 /* specifically exclude some from the screen */
101 #report_parameters_daterange {
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
== "") {
114 $
("#theform").trigger("submit");
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
>
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'); ?
>
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">
141 <div style
='float:left'>
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
>
150 <td align
='left' valign
='middle' height
="100%">
151 <table style
='border-left:1px solid; width:100%; height:100%' >
154 <div style
='margin-left:15px'>
155 <a href
='#' class='css_button' onclick
='return edivalidation(); '><span
><?php
echo xlt('Upload'); ?
></span
>
165 <input type
="hidden" name
="form_orderby" value
="<?php echo attr($form_orderby); ?>" />
166 <input type
='hidden' name
='form_refresh' id
='form_refresh' value
=''/>