forked from openemr/openemr
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Enhance Insurance Eligibility - Add real time - Fix 271 x12 parse - add back some partner configs * log download buffer over run fix * eligibility rework - add Office Ally real time interface (MIME) - rewrite 271 parse - rework demographics eligibility tab - bug fixes * - bug fix a sql query escape breaks delete query - batch patient fetch now groups by patient ie unique patients in list - deleted eligibility_response table in database - fix various escaping * - add enable Enable Office Ally Insurance Eligibility in globals
- Loading branch information
Showing
6 changed files
with
923 additions
and
616 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,9 +9,11 @@ | |
* @link https://www.open-emr.org | ||
* @author Terry Hill <[email protected]> | ||
* @author Brady Miller <[email protected]> | ||
* @author Jerry Padgett <[email protected]> | ||
* @copyright Copyright (c) 2010 MMF Systems, Inc | ||
* @copyright Copyright (c) 2016 Terry Hill <[email protected]> | ||
* @copyright Copyright (c) 2017 Brady Miller <[email protected]> | ||
* @copyright Copyright (c) 2019 Jerry Padgett <[email protected]> | ||
* @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3 | ||
*/ | ||
|
||
|
@@ -24,6 +26,7 @@ | |
require_once("$srcdir/edi.inc"); | ||
|
||
use OpenEMR\Core\Header; | ||
use OpenEMR\Common\Http\oeHttp; | ||
|
||
if (!empty($_POST)) { | ||
if (!verifyCsrfToken($_POST["csrf_token_form"])) { | ||
|
@@ -47,7 +50,8 @@ | |
$form_facility = $_POST['form_facility'] ? $_POST['form_facility'] : ''; | ||
$form_provider = $_POST['form_users'] ? $_POST['form_users'] : ''; | ||
$exclude_policy = $_POST['removedrows'] ? $_POST['removedrows'] : ''; | ||
$X12info = $_POST['form_x12'] ? explode("|", $_POST['form_x12']) : ''; | ||
$x12_partner = $_POST['form_x12'] ? $_POST['form_x12'] : ''; | ||
$X12info = getX12Partner($x12_partner); | ||
|
||
//Set up the sql variable binding array (this prevents sql-injection attacks) | ||
$sqlBindArray = array(); | ||
|
@@ -74,59 +78,54 @@ | |
|
||
if ($exclude_policy != "") { | ||
$arrayExplode = explode(",", $exclude_policy); | ||
array_walk($arrayExplode, 'arrFormated'); | ||
$exclude_policy = implode(",", $arrayExplode); | ||
$where .= " AND i.policy_number not in (".add_escape_custom($exclude_policy).")"; | ||
array_walk($arrayExplode, 'arrFormated'); | ||
$exclude_policy = implode(",", $arrayExplode); | ||
$exclude_policy = add_escape_custom($exclude_policy); | ||
$where .= " AND i.policy_number NOT IN ('$exclude_policy')"; | ||
} | ||
|
||
$where .= " AND (i.policy_number is not null and i.policy_number != '')"; | ||
|
||
$query = sprintf(" SELECT DATE_FORMAT(e.pc_eventDate, '%%Y%%m%%d') as pc_eventDate, | ||
e.pc_facility, | ||
p.lname, | ||
p.fname, | ||
p.mname, | ||
DATE_FORMAT(p.dob, '%%Y%%m%%d') as dob, | ||
p.ss, | ||
p.sex, | ||
p.pid, | ||
p.pubpid, | ||
i.subscriber_ss, | ||
i.policy_number, | ||
i.provider as payer_id, | ||
i.subscriber_relationship, | ||
i.subscriber_lname, | ||
i.subscriber_fname, | ||
i.subscriber_mname, | ||
DATE_FORMAT(i.subscriber_dob, '%%m/%%d/%%Y') as subscriber_dob, | ||
i.policy_number, | ||
i.subscriber_sex, | ||
DATE_FORMAT(i.date,'%%Y%%m%%d') as date, | ||
d.lname as provider_lname, | ||
d.fname as provider_fname, | ||
d.npi as provider_npi, | ||
d.upin as provider_pin, | ||
f.federal_ein as federal_ein, | ||
f.facility_npi as facility_npi, | ||
f.name as facility_name, | ||
c.name as payer_name | ||
FROM openemr_postcalendar_events AS e | ||
LEFT JOIN users AS d on (e.pc_aid is not null and e.pc_aid = d.id) | ||
LEFT JOIN facility AS f on (f.id = e.pc_facility) | ||
LEFT JOIN patient_data AS p ON p.pid = e.pc_pid | ||
LEFT JOIN insurance_data AS i ON (i.id =( | ||
SELECT id | ||
FROM insurance_data AS i | ||
WHERE pid = p.pid AND type = 'primary' | ||
ORDER BY date DESC | ||
LIMIT 1 | ||
) | ||
) | ||
LEFT JOIN insurance_companies as c ON (c.id = i.provider) | ||
WHERE %s ", $where); | ||
$where .= " AND (i.policy_number is NOT NULL AND i.policy_number != '')"; | ||
$where .= " GROUP BY p.pid ORDER BY c.name"; | ||
$query = sprintf("SELECT DATE_FORMAT(e.pc_eventDate, '%%Y%%m%%d') as pc_eventDate, | ||
e.pc_facility, | ||
p.lname, | ||
p.fname, | ||
p.mname, | ||
DATE_FORMAT(p.dob, '%%Y%%m%%d') as dob, | ||
p.ss, | ||
p.sex, | ||
p.pid, | ||
p.pubpid, | ||
i.subscriber_ss, | ||
i.policy_number, | ||
i.provider as payer_id, | ||
i.subscriber_relationship, | ||
i.subscriber_lname, | ||
i.subscriber_fname, | ||
i.subscriber_mname, | ||
DATE_FORMAT(i.subscriber_dob, '%%m/%%d/%%Y') as subscriber_dob, | ||
i.policy_number, | ||
i.subscriber_sex, | ||
DATE_FORMAT(i.date,'%%Y%%m%%d') as date, | ||
d.lname as provider_lname, | ||
d.fname as provider_fname, | ||
d.npi as provider_npi, | ||
d.upin as provider_pin, | ||
f.federal_ein as federal_ein, | ||
f.facility_npi as facility_npi, | ||
f.name as facility_name, | ||
c.cms_id as cms_id, | ||
c.name as payer_name | ||
FROM openemr_postcalendar_events AS e | ||
LEFT JOIN users AS d on (e.pc_aid is not null and e.pc_aid = d.id) | ||
LEFT JOIN facility AS f on (f.id = e.pc_facility) | ||
LEFT JOIN patient_data AS p ON p.pid = e.pc_pid | ||
LEFT JOIN insurance_data AS i ON (i.id =(SELECT id FROM insurance_data AS i WHERE pid = p.pid AND type = 'primary' ORDER BY date DESC LIMIT 1)) | ||
LEFT JOIN insurance_companies as c ON (c.id = i.provider) | ||
WHERE %s ", $where); | ||
|
||
// Run the query | ||
$res = sqlStatement($query, $sqlBindArray); | ||
$res = sqlStatement($query, $sqlBindArray); | ||
|
||
// Get the facilities information | ||
$facilities = getUserFacilities($_SESSION['authId']); | ||
|
@@ -137,6 +136,26 @@ | |
//Get the x12 partners information | ||
$clearinghouses = getX12Partner(); | ||
|
||
if (isset($_POST['form_xmit']) && !empty($_POST['form_xmit']) && $res) { | ||
$eFlag = !$GLOBALS['disable_eligibility_log']; | ||
$log = requestRealTimeEligible($res, $X12info, $segTer, $compEleSep, $eFlag); | ||
if ($eFlag) { | ||
$fn = sprintf( | ||
'elig-log_%s_%s.txt', | ||
strtolower(str_replace(' ', '', $X12info['name'])), | ||
date("Y-m-d:H:i:s") | ||
); | ||
$log = str_replace('~', "~\r", $log); | ||
while (@ob_end_flush()) { | ||
} | ||
header('Content-Type: text/plain'); | ||
header("Content-Length: " . strlen($log)); | ||
header('Content-Disposition: attachment; filename="' . $fn . '"'); | ||
ob_start(); | ||
echo $log; | ||
exit(); | ||
} | ||
} | ||
|
||
if (isset($_POST['form_savefile']) && !empty($_POST['form_savefile']) && $res) { | ||
header('Content-Type: text/plain'); | ||
|
@@ -212,21 +231,20 @@ function deletetherow(id){ | |
} | ||
|
||
// To validate the batch file generation - for the required field [clearing house/x12 partner] | ||
function validate_batch() | ||
{ | ||
if(document.getElementById('form_x12').value=='') | ||
{ | ||
function validate_batch(eFlag) { | ||
if (document.getElementById('form_x12').value == '') { | ||
alert(stringBatch); | ||
return false; | ||
} | ||
else | ||
{ | ||
document.getElementById('form_savefile').value = "true"; | ||
document.theform.submit(); | ||
else { | ||
if (eFlag === true) { | ||
document.getElementById('form_xmit').value = "true"; | ||
} else { | ||
document.getElementById('form_savefile').value = "true"; | ||
} | ||
|
||
document.theform.submit(); | ||
} | ||
|
||
|
||
} | ||
|
||
// To Clear the hidden input field | ||
|
@@ -235,13 +253,14 @@ function validate_policy() | |
{ | ||
document.getElementById('removedrows').value = ""; | ||
document.getElementById('form_savefile').value = ""; | ||
document.getElementById('form_xmit').value = ""; | ||
return true; | ||
} | ||
|
||
// To toggle the clearing house empty validation message | ||
function toggleMessage(id,x12){ | ||
|
||
var spanstyle = new String(); | ||
var spanstyle = String(); | ||
|
||
spanstyle = document.getElementById(id).style.visibility; | ||
selectoption = document.getElementById(x12).value; | ||
|
@@ -337,20 +356,19 @@ function toggleMessage(id,x12){ | |
<?php echo xlt('X12 Partner'); ?>: | ||
</td> | ||
<td colspan='5'> | ||
<select name='form_x12' id='form_x12' class='form-control' onchange='return toggleMessage("emptyVald","form_x12");' > | ||
<option value=''>--<?php echo xlt('select'); ?>--</option> | ||
<?php | ||
if (isset($clearinghouses) && !empty($clearinghouses)) { | ||
foreach ($clearinghouses as $clearinghouse) { ?> | ||
<option value='<?php echo attr($clearinghouse['id']."|".$clearinghouse['id_number']."|".$clearinghouse['x12_sender_id']."|".$clearinghouse['x12_receiver_id']."|".$clearinghouse['x12_version']."|".$clearinghouse['processing_format']); ?>' | ||
<?php echo $clearinghouse['id'] == $X12info[0] ? " selected " : null; ?> | ||
><?php echo text($clearinghouse['name']); ?></option> | ||
<?php | ||
} | ||
} | ||
?> | ||
</select> | ||
<span id='emptyVald' style='color:red;font-size:12px;'> * <?php echo xlt('Clearing house info required for EDI 270 batch creation.'); ?></span> | ||
<select name='form_x12' id='form_x12' class='form-control' onchange='return toggleMessage("emptyVald","form_x12");'> | ||
<option value=''>--<?php echo xlt('select'); ?>--</option> | ||
<?php | ||
if (isset($clearinghouses) && !empty($clearinghouses)) { | ||
foreach ($clearinghouses as $clearinghouse) { | ||
echo "<option value='" . attr($clearinghouse['id']) . "'" . | ||
($clearinghouse['id'] == $X12info['id'] ? " selected " : '') . ">" . text($clearinghouse['name']) . "</option>"; | ||
} | ||
} | ||
?> | ||
</select> | ||
<span id='emptyVald' style='color:red;font-size:12px;visibility: <?php echo $X12info['id'] ? "hidden" : ""; ?>'> * | ||
<?php echo xlt('Clearing house info required for EDI 270 batch creation.'); ?></span> | ||
</td> | ||
</tr> | ||
</table> | ||
|
@@ -365,9 +383,15 @@ function toggleMessage(id,x12){ | |
<a href='#' class='btn btn-default btn-refresh' onclick='validate_policy(); $("#theform").submit();'> | ||
<?php echo xlt('Refresh'); ?> | ||
</a> | ||
<a href='#' class='btn btn-default btn-transmit' onclick='return validate_batch();'> | ||
<a href='#' class='btn btn-default btn-transmit' onclick='return validate_batch(false);'> | ||
<?php echo xlt('Create batch'); ?> | ||
<input type='hidden' name='form_savefile' id='form_savefile' value=''></input> | ||
|
||
<?php if ($GLOBALS['enable_oa']) { | ||
echo "<a href='#' class='btn btn-default btn-transmit' onclick='return validate_batch(true);'>" . xlt('Request Eligibility') . "</a>\n"; | ||
} | ||
?> | ||
<input type='hidden' name='form_xmit' id='form_xmit' value=''></input> | ||
</a> | ||
</div> | ||
</div> | ||
|
@@ -378,7 +402,6 @@ function toggleMessage(id,x12){ | |
</tr> | ||
</table> | ||
</div> | ||
|
||
<div class='text'> | ||
<?php echo xlt('Please choose date range criteria above, and click Refresh to view results.'); ?> | ||
</div> | ||
|
Oops, something went wrong.