Skip to content

Commit

Permalink
add eligibility to insurance setup (openemr#2287)
Browse files Browse the repository at this point in the history
* add eligibility to insurance setup

* escaping

* test dates minor fix

* Don't want effective date darn it. it needs to be dos.
  • Loading branch information
sjpadgett authored Mar 21, 2019
1 parent 6245377 commit d3cbd1b
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 12 deletions.
1 change: 1 addition & 0 deletions controllers/C_InsuranceCompany.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ function __construct($template_mod = "general")
$this->assign("CURRENT_ACTION", $GLOBALS['webroot']."/controller.php?" . "practice_settings&insurance_company&");
$this->assign("STYLE", $GLOBALS['style']);
$this->assign("SUPPORT_ENCOUNTER_CLAIMS", $GLOBALS['support_encounter_claims']);
$this->assign("SUPPORT_ELIGIBILITY_REQUESTS", $GLOBALS['enable_oa']);
$this->InsuranceCompany = new InsuranceCompany();
}

Expand Down
2 changes: 1 addition & 1 deletion interface/reports/edi_270.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
f.facility_npi as facility_npi,
f.name as facility_name,
c.cms_id as cms_id,
c.alt_cms_id as alt_cms_id,
c.eligibility_id as eligibility_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)
Expand Down
27 changes: 26 additions & 1 deletion library/classes/InsuranceCompany.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,11 @@ class InsuranceCompany extends ORDataObject
var $attn;
var $cms_id;
var $alt_cms_id;
var $eligibility_id;
//this is now deprecated use new x12 partners instead
var $x12_receiver_id;
var $x12_default_partner_id;

var $x12_default_eligibility_id;
/*
* OpenEMR used this value to determine special formatting for the specified type of payer.
* This value is a mutually exclusive choice answering the FB.Payer.isX API calls
Expand Down Expand Up @@ -232,6 +233,14 @@ function get_alt_cms_id()
{
return $this->alt_cms_id;
}
function set_eligibility_id($id)
{
$this->eligibility_id = $id;
}
function get_eligibility_id()
{
return $this->eligibility_id;
}
function set_ins_type_code($type)
{
$this->ins_type_code = $type;
Expand Down Expand Up @@ -311,6 +320,22 @@ function get_x12_default_partner_name()
return $xa[$this->get_x12_default_partner_id()];
}

function set_x12_default_eligibility_id($id)
{
$this->x12_default_eligibility_id = $id;
}

function get_x12_default_eligibility_id()
{
return $this->x12_default_eligibility_id;
}

function get_x12_default_eligibility_name()
{
$xa = $this->_utility_array($this->X12Partner->x12_partner_factory());
return $xa[$this->get_x12_default_eligibility_id()];
}

function populate()
{
parent::populate();
Expand Down
13 changes: 6 additions & 7 deletions library/edi.inc
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ function create_NM1($row, $nm1Cast, $X12info, $segTer, $compEleSep)
$NM1[7] = ""; // Data Element not required.
$NM1[8] = $X12info['id_number'] ? $X12info['id_number'] : "46"; // 46 - Electronic Transmitter Identification Number (ETIN)
if ($GLOBALS['enable_oa']) {
$payerId = $row['alt_cms_id'];
$payerId = $row['eligibility_id'];
} else {
$payerId = $row['cms_id'];
}
Expand Down Expand Up @@ -232,7 +232,7 @@ function create_DTP($row, $qual, $X12info, $segTer, $compEleSep)
if ($qual == '102') {
$DTP[3] = $row['date']; // Date
} else {
$DTP[3] = $DTP[3] ? $row['pc_eventDate'] : $row['date']; // Date of Service
$DTP[3] = !empty($row['pc_eventDate']) && $row['pc_eventDate'] > '20010101' ? $row['pc_eventDate'] : date("Ymd"); // Date of Service
}
$DTP['Created'] = implode('*', $DTP); // Data Element Separator
$DTP['Created'] = $DTP['Created'] . $segTer;
Expand Down Expand Up @@ -381,9 +381,9 @@ function requestEligibleTransaction($pid = 0, $eFlag = false)
f.facility_npi as facility_npi,
f.name as facility_name,
c.cms_id as cms_id,
c.alt_cms_id as alt_cms_id,
c.x12_default_partner_id as partner,
c.name as payer_name
c.eligibility_id as eligibility_id,
c.x12_default_eligibility_id as partner,
c.name as payer_name
FROM patient_data AS p
LEFT JOIN users AS d on (p.providerID = d.id)
LEFT JOIN facility AS f on (f.id = d.facility_id)
Expand Down Expand Up @@ -418,7 +418,7 @@ function requestRealTimeEligible($res, $X12info, $segTer, $compEleSep, $eFlag =
if ($row['providerID'] === 0 || !$row['provider_npi']) {
$error_accum .= xlt("Error") . ": " . xlt("Provider Missing Add one in Choices") . "\n";
}
if (!$row['alt_cms_id']) {
if (!$row['eligibility_id']) {
$error_accum .= xlt("Error") . ": " . xlt("Missing Insurance Payer Id") . "\n";
}
if (!$row['policy_number'] || !$row['subscriber_dob']) {
Expand Down Expand Up @@ -630,7 +630,6 @@ function show_eligibility_information($pid, $flag = false)
if ($title === 1) {
$showString = "<br><span><b>" . xlt("Nothing To Report") . "</b></span><br>";
}

$showString .= "</div>\n";
echo $showString;
}
Expand Down
14 changes: 13 additions & 1 deletion sql/5_0_1-to-5_0_2_upgrade.sql
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ ALTER TABLE `issue_encounter`

#IfNotColumnType onsite_documents pid bigint(20)
ALTER TABLE `onsite_documents`
MODIFY `pid` bigint(20) UNSIGNED DEFAULT NULL;
MODIFY `pid` bigint(20) UNSIGNED default NULL;
#EndIf

#IfNotColumnType patient_access_onsite pid bigint(20)
Expand Down Expand Up @@ -848,3 +848,15 @@ CREATE TABLE `benefit_eligibility` (
#IfTable eligibility_response
DROP TABLE `eligibility_response`;
#Endif

#IfTable x12_partners
ALTER TABLE `x12_partners` CHANGE `processing_format` `processing_format` ENUM('standard','medi-cal','cms','proxymed','oa-eligibility','avality-eligibility') DEFAULT NULL;
#Endif

#IfMissingColumn eligibility_id insurance_companies
ALTER TABLE `insurance_companies` ADD `eligibility_id` VARCHAR(32) DEFAULT NULL;
#Endif

#IfMissingColumn x12_default_eligibility_id insurance_companies
ALTER TABLE `insurance_companies` ADD `x12_default_eligibility_id` INT(11) DEFAULT NULL;
#Endif
4 changes: 3 additions & 1 deletion sql/database.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2899,6 +2899,8 @@ CREATE TABLE `insurance_companies` (
`x12_default_partner_id` int(11) default NULL,
`alt_cms_id` varchar(15) NOT NULL DEFAULT '',
`inactive` int(1) NOT NULL DEFAULT '0',
`eligibility_id` VARCHAR(32) default NULL,
`x12_default_eligibility_id` INT(11) default NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB;

Expand Down Expand Up @@ -7235,7 +7237,7 @@ CREATE TABLE `x12_partners` (
`id_number` varchar(255) default NULL,
`x12_sender_id` varchar(255) default NULL,
`x12_receiver_id` varchar(255) default NULL,
`processing_format` enum('standard','medi-cal','cms','proxymed') default NULL,
`processing_format` enum('standard','medi-cal','cms','proxymed','oa_eligibility','availity_eligibility') default NULL,
`x12_isa01` VARCHAR( 2 ) NOT NULL DEFAULT '00' COMMENT 'User logon Required Indicator',
`x12_isa02` VARCHAR( 10 ) NOT NULL DEFAULT ' ' COMMENT 'User Logon',
`x12_isa03` VARCHAR( 2 ) NOT NULL DEFAULT '00' COMMENT 'User password required Indicator',
Expand Down
20 changes: 19 additions & 1 deletion templates/insurance_companies/general_edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,14 @@
</div>
</div>
{/if}
{if $SUPPORT_ELIGIBILITY_REQUESTS}
<div class="form-group">
<label for="eligibility_id" class="control-label col-sm-2">{xlt t='Payer Id For Eligibility'}</label>
<div class="col-sm-8">
<input type="text" id="eligibility_id" name="eligibility_id" class="form-control" value="{$insurancecompany->get_eligibility_id()|attr}" onKeyDown="PreventIt(event)">
</div>
</div>
{/if}
<div class="form-group">
<label for="ins_type_code" class="control-label col-sm-2">{xlt t='Payer Type'}</label>
<div class="col-sm-8">
Expand All @@ -106,6 +114,16 @@
</select>
</div>
</div>
{if $SUPPORT_ELIGIBILITY_REQUESTS}
<div class="form-group">
<label for="x12_default_eligibility_id" class="control-label col-sm-2">{xlt t='Default Eligibility X12 Partner'}</label>
<div class="col-sm-8">
<select id="x12_default_eligibility_id" name="x12_default_eligibility_id" class="form-control">
{html_options options=$x12_partners selected=$insurancecompany->get_x12_default_eligibility_id()}
</select>
</div>
</div>
{/if}
<div class="btn-group col-sm-offset-2">
<a href="javascript:submit_insurancecompany();" class="btn btn-default btn-save" onclick="top.restoreSession()">
{xlt t='Save'}
Expand Down Expand Up @@ -139,4 +157,4 @@
} while ((endTime - startTime) < delay);
}
</script>
{/literal}
{/literal}

0 comments on commit d3cbd1b

Please sign in to comment.