From 90bee3bb81686b7f60ebf9879680e8d778bca55c Mon Sep 17 00:00:00 2001 From: stephen waite Date: Sat, 7 Oct 2023 19:20:44 -0400 Subject: [PATCH] feat: minor refactor x12 insurance eligibility api (#6915) * feat: minor refactor x12 insurance eligibility api * bump db version * typo --- controllers/C_InsuranceCompany.class.php | 2 +- interface/billing/edi_270.php | 2 +- .../patient_file/summary/demographics.php | 4 +- library/classes/X12Partner.class.php | 66 +++++++++++++++++++ library/globals.inc.php | 6 +- sql/7_0_1-to-7_0_2_upgrade.sql | 24 +++++++ sql/database.sql | 6 ++ src/Billing/EDI270.php | 6 +- templates/patient/card/insurance.html.twig | 2 +- templates/x12_partners/general_edit.html | 42 ++++++++++++ version.php | 2 +- 11 files changed, 150 insertions(+), 12 deletions(-) diff --git a/controllers/C_InsuranceCompany.class.php b/controllers/C_InsuranceCompany.class.php index a1c54906e42..bd0a3da9224 100644 --- a/controllers/C_InsuranceCompany.class.php +++ b/controllers/C_InsuranceCompany.class.php @@ -16,7 +16,7 @@ public 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->assign("SUPPORT_ELIGIBILITY_REQUESTS", $GLOBALS['enable_eligibility_requests']); $this->InsuranceCompany = new InsuranceCompany(); } diff --git a/interface/billing/edi_270.php b/interface/billing/edi_270.php index b148c4915c4..8af06ba3aa2 100644 --- a/interface/billing/edi_270.php +++ b/interface/billing/edi_270.php @@ -433,7 +433,7 @@ function toggleMessage(id,x12){ - " . xlt('Request Eligibility') . "\n"; } ?> diff --git a/interface/patient_file/summary/demographics.php b/interface/patient_file/summary/demographics.php index bdd9c5d792d..b4d8904e08a 100644 --- a/interface/patient_file/summary/demographics.php +++ b/interface/patient_file/summary/demographics.php @@ -1377,7 +1377,7 @@ function filterActiveIssues(array $i): array } } - if ($GLOBALS["enable_oa"]) { + if ($GLOBALS["enable_eligibility_requests"]) { if (($_POST['status_update'] ?? '') === 'true') { unset($_POST['status_update']); $showEligibility = true; @@ -1414,7 +1414,7 @@ function filterActiveIssues(array $i): array 'initiallyCollapsed' => (getUserSetting($id) == 0) ? true : false, 'ins' => $insArr, 'eligibility' => $output, - 'enable_oa' => $GLOBALS['enable_oa'], + 'enable_eligibility_requests' => $GLOBALS['enable_eligibility_requests'], 'auth' => AclMain::aclCheckCore('patients', 'demo', '', 'write'), 'prependedInjection' => $dispatchResult->getPrependedInjection(), 'appendedInjection' => $dispatchResult->getAppendedInjection(), diff --git a/library/classes/X12Partner.class.php b/library/classes/X12Partner.class.php index 4cd6f4a531c..968f7f3c9a9 100644 --- a/library/classes/X12Partner.class.php +++ b/library/classes/X12Partner.class.php @@ -47,6 +47,12 @@ class X12Partner extends ORDataObject var $x12_sftp_port; var $x12_sftp_local_dir; var $x12_sftp_remote_dir; + var $x12_client_id; + var $x12_client_secret; + var $x12_token_endpoint; + var $x12_eligibility_endpoint; + var $x12_claim_status_endpoint; + var $x12_attachment_endpoint; /** * Constructor sets all Insurance attributes to their default value @@ -429,4 +435,64 @@ function get_x12_dtp03_type_array() 'E' => 'Subscriber Effective Date', ); } + + function set_x12_client_id($string) + { + $this->x12_client_id = $string; + } + + function get_x12_client_id() + { + return $this->x12_client_id; + } + + function set_x12_client_secret($string) + { + $this->x12_client_secret = $string; + } + + function get_x12_client_secret() + { + return $this->x12_client_secret; + } + + function set_x12_token_endpoint($string) + { + $this->x12_token_endpoint = $string; + } + + function get_x12_token_endpoint() + { + return $this->x12_token_endpoint; + } + + function set_x12_eligibility_endpoint($string) + { + $this->x12_eligibility_endpoint = $string; + } + + function get_x12_eligibility_endpoint() + { + return $this->x12_eligibility_endpoint; + } + + function set_x12_claim_status_endpoint($string) + { + $this->x12_claim_status_endpoint = $string; + } + + function get_x12_claim_status_endpoint() + { + return $this->x12_claim_status_endpoint; + } + + function set_x12_attachment_endpoint($string) + { + $this->x12_attachment_endpoint = $string; + } + + function get_x12_attachment_endpoint() + { + return $this->x12_attachment_endpoint; + } } diff --git a/library/globals.inc.php b/library/globals.inc.php index b22b4a315f9..bf90240afe6 100644 --- a/library/globals.inc.php +++ b/library/globals.inc.php @@ -2010,11 +2010,11 @@ function gblTimeZones() ), // Insurance Tab 'Insurance' => array( - 'enable_oa' => array( - xl('Enable Office Ally Insurance Eligibility'), + 'enable_eligibility_requests' => array( + xl('Enable Insurance Eligibility'), 'bool', '0', - xl('Allow insurance eligibility checks using Office Ally') + xl('Allow insurance eligibility checks using an X12 Partner') ), 'simplified_demographics' => array( diff --git a/sql/7_0_1-to-7_0_2_upgrade.sql b/sql/7_0_1-to-7_0_2_upgrade.sql index 20376b4052c..cbecfcea9ec 100644 --- a/sql/7_0_1-to-7_0_2_upgrade.sql +++ b/sql/7_0_1-to-7_0_2_upgrade.sql @@ -553,4 +553,28 @@ CREATE TABLE `edi_sequences` ( `id` int(9) unsigned NOT NULL default '0' ) ENGINE=InnoDB; INSERT INTO `edi_sequences` VALUES (0); +#EndIf + +#IfMissingColumn x12_partners x12_client_id; +ALTER TABLE `x12_partners` ADD COLUMN `x12_client_id` tinytext; +#EndIf + +#IfMissingColumn x12_partners x12_client_secret; +ALTER TABLE `x12_partners` ADD COLUMN `x12_client_secret` tinytext; +#EndIf + +#IfMissingColumn x12_partners x12_token_endpoint +ALTER TABLE `x12_partners` ADD COLUMN `x12_token_endpoint` tinytext; +#EndIf + +#IfMissingColumn x12_partners x12_eligibility_endpoint +ALTER TABLE `x12_partners` ADD COLUMN `x12_eligibility_endpoint` tinytext; +#EndIf + +#IfMissingColumn x12_partners x12_claim_status_endpoint +ALTER TABLE `x12_partners` ADD COLUMN `x12_claim_status_endpoint` tinytext; +#EndIf + +#IfMissingColumn x12_partners x12_attachment_endpoint +ALTER TABLE `x12_partners` ADD COLUMN `x12_attachment_endpoint` tinytext; #EndIf \ No newline at end of file diff --git a/sql/database.sql b/sql/database.sql index eb285fe948c..78a812a23f3 100644 --- a/sql/database.sql +++ b/sql/database.sql @@ -9105,6 +9105,12 @@ CREATE TABLE `x12_partners` ( `x12_sftp_port` varchar(255) DEFAULT NULL, `x12_sftp_local_dir` varchar(255) DEFAULT NULL, `x12_sftp_remote_dir` varchar(255) DEFAULT NULL, + `x12_token_endpoint` tinytext, + `x12_eligibility_endpoint` tinytext, + `x12_claim_status_endpoint` tinytext, + `x12_attachment_endpoint` tinytext, + `x12_client_id` tinytext, + `x12_client_secret` tinytext, PRIMARY KEY (`id`) ) ENGINE=InnoDB; diff --git a/src/Billing/EDI270.php b/src/Billing/EDI270.php index f436f88cdf1..9a4d093cfcd 100644 --- a/src/Billing/EDI270.php +++ b/src/Billing/EDI270.php @@ -16,7 +16,7 @@ * @copyright Copyright (c) 2016 Terry Hill * @copyright Copyright (c) 2017 Brady Miller * @copyright Copyright (c) 2019 Jerry Padgett - * @copyright Copyright (c) 2019 Stephen Waite + * @copyright Copyright (c) 2019-2023 Stephen Waite * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3 */ @@ -159,7 +159,7 @@ public static function createNM1($row, $nm1Cast, $X12info, $segTer, $compEleSep) $NM1[6] = ""; // Data Element not required. $NM1[7] = ""; // Data Element not required. $NM1[8] = "PI"; // 5010 no longer uses "46" - if ($GLOBALS['enable_oa']) { + if ($GLOBALS['enable_eligibility_requests']) { $payerId = $row['eligibility_id']; } else { $payerId = $row['cms_id']; @@ -849,7 +849,7 @@ public static function requestEligibility($partner = '', $x12_270 = '') $response = oeHttp::bodyFormat('body') //->setDebug('5000')/* @todo uncomment and set proxy port to debug eg Fiddler */ ->usingHeaders($headers) - ->post('https://wsd.officeally.com/TransactionSite/rtx.aspx', $mime_body); // @TODO put request urls in x12 partner's for versatility. + ->post($X12info['x12_eligibility_endpoint'], $mime_body); $formBody = $response->body(); $contentType = $response->header('Content-Type')[0]; diff --git a/templates/patient/card/insurance.html.twig b/templates/patient/card/insurance.html.twig index d5890c01c43..8da0abc17a8 100644 --- a/templates/patient/card/insurance.html.twig +++ b/templates/patient/card/insurance.html.twig @@ -89,7 +89,7 @@ {% endfor %}
- {% if enable_oa %} + {% if enable_eligibility_requests %}
diff --git a/templates/x12_partners/general_edit.html b/templates/x12_partners/general_edit.html index 9539569b6fc..2f2350c5b49 100644 --- a/templates/x12_partners/general_edit.html +++ b/templates/x12_partners/general_edit.html @@ -176,6 +176,48 @@
+
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+