From 9edfde7f69cdb0db4ce9d5daf3df367761602eec Mon Sep 17 00:00:00 2001 From: tony Date: Tue, 7 Feb 2012 22:49:01 -0800 Subject: [PATCH] Add date format cleaner for x12 5010 - tmccormi Wrapping onset date - yehster --- library/Claim.class.php | 43 ++++++++++++++++++++++++++++--------------- library/gen_x12_837.inc.php | 9 ++++++--- 2 files changed, 34 insertions(+), 18 deletions(-) diff --git a/library/Claim.class.php b/library/Claim.class.php index ab9121035..df15d9e7e 100644 --- a/library/Claim.class.php +++ b/library/Claim.class.php @@ -17,6 +17,21 @@ function x12clean($str) { return preg_replace('/[^A-Z0-9!"\\&\'()+,\\-.\\/;?= ]/', '', strtoupper($str)); } +// Make sure dates have no formatting and zero filled becomes blank +// Handles date time stamp formats as well +// +function cleanDate($date_field) + { + $cleandate = str_replace('-', '', substr($date_field, 0, 10)); + + if(substr_count($cleandate,'0')==8) + { + $cleandate=''; + } + + return ($cleandate); + } + class Claim { var $pid; // patient id @@ -37,7 +52,7 @@ class Claim { var $invoice; // result from get_invoice_summary() var $payers; // array of arrays, for all payers var $copay; // total of copays from the billing table - + function loadPayerInfo(&$billrow) { global $sl_err; $encounter_date = substr($this->encounter['date'], 0, 10); @@ -975,15 +990,13 @@ class Claim { return ''; } - function onsetDate() {//Without the else clause in the claim zero value is coming. - $replace_value=str_replace('-', '', substr($this->encounter['onset_date'], 0, 10)); - if($replace_value*1<>0) - { - return $replace_value; - } - else{ - return ''; - } + function onsetDate() { + return cleanDate($this->encounter['onset_date']); + } + + function onsetDateValid() + { + return onsetDate()!==''; } function serviceDate() { @@ -1015,11 +1028,11 @@ class Claim { } function offWorkFrom() { - return str_replace('-', '', substr($this->billing_options['off_work_from'], 0, 10)); + return cleanDate($this->billing_options['off_work_from']); } function offWorkTo() { - return str_replace('-', '', substr($this->billing_options['off_work_to'], 0, 10)); + return cleanDate($this->billing_options['off_work_to']); } function isHospitalized() { @@ -1027,11 +1040,11 @@ class Claim { } function hospitalizedFrom() { - return str_replace('-', '', substr($this->billing_options['hospitalization_date_from'], 0, 10)); + return cleanDate($this->billing_options['hospitalization_date_from']); } function hospitalizedTo() { - return str_replace('-', '', substr($this->billing_options['hospitalization_date_to'], 0, 10)); + return cleanDate($this->billing_options['hospitalization_date_to']); } function isOutsideLab() { @@ -1059,7 +1072,7 @@ class Claim { } function dateInitialTreatment() { - return str_replace('-', '', substr($this->billing_options['date_initial_treatment'], 0, 10)); + return cleanDate($this->billing_options['date_initial_treatment']); } // Returns an array of unique diagnoses. Periods are stripped. diff --git a/library/gen_x12_837.inc.php b/library/gen_x12_837.inc.php index c01779b23..90bddbda1 100644 --- a/library/gen_x12_837.inc.php +++ b/library/gen_x12_837.inc.php @@ -449,7 +449,10 @@ function gen_x12_837($pid, $encounter, &$log, $encounter_claim=false) { ($CMS_5010 ? "" : "*C") . "~\n"; - if ($claim->onsetDate() && ($claim->onsetDate()!==$claim->serviceDate())) { + if ($claim->onsetDate() && + ($claim->onsetDate()!== $claim->serviceDate()) && + ($claim->onsetDateValid()) + ) { ++$edicount; $out .= "DTP" . // Date of Onset "*431" . @@ -458,7 +461,7 @@ function gen_x12_837($pid, $encounter, &$log, $encounter_claim=false) { "~\n"; } - if ($claim->dateInitialTreatment()) { + if ($claim->dateInitialTreatment() && ($claim->onsetDateValid())) { ++$edicount; $out .= "DTP" . // Date of Initial Treatment "*454" . @@ -477,7 +480,7 @@ function gen_x12_837($pid, $encounter, &$log, $encounter_claim=false) { // Segment DTP*297 (Last Worked Date) omitted. // Segment DTP*296 (Authorized Return to Work Date) omitted. - if (strcmp($claim->facilityPOS(),'21') == 0) { + if (strcmp($claim->facilityPOS(),'21') == 0 && $claim->onsetDateValid() ) { ++$edicount; $out .= "DTP" . // Date of Hospitalization "*435" . -- 2.11.4.GIT