Advertisement
fernandezekiel

something's wrong

Jan 29th, 2014
289
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.41 KB | None | 0 0
  1. class SomeCommand
  2. {
  3.  
  4.     public $headerFields = [
  5.         'STATEMENT_COUNTER', 'PATIENT_ID', 'PRACTICE_NAME', 'PRACTICE_ADDRESS_1', 'PRACTICE_ADDRESS_2',
  6.         'PRACTICE_CITY', 'PRACTICE_STATE', 'PRACTICE_ZIP', 'PRACTICE_PHONE', 'PATIENTC_CONTROL_NUM', 'PATIENT_NAME',
  7.         'RESPONSIBLE_NAME', 'RESPONSIBLE_PHONE', 'PATIENT_ADDRESS1', 'PATIENT_ADDRESS_2', 'PATIENT_CITY', 'PATIENT_STATE',
  8.         'PATIENT_ZIP', 'PATIENT_STATEMENT_ID', 'PRIMARY_INSURANCE', 'INSURED_NAME', 'SECONDARY_INSURANCE', 'SECONDARY_INSURED_NAME',
  9.         'STATEMENT_BAL', 'STATEMENT_BAL_0_to_30', 'STATEMENT_BAL_30_to_60', 'STATEMENT_BAL_60_to_90', 'STATEMENT_BAL_90_to_120',
  10.         'STATEMENT_BAL_120', 'SYSDATE', 'LAST_PAID_DATE', 'LAST_PAID_AMT', 'BILLER_PHONE', 'SYSDATE_plus_15', 'CREDIT_CARD_VAL'
  11.     ];
  12.  
  13.     public function createPattern($fields, $type)
  14.     {
  15.         $ret = "/" . $type . '*';
  16.         foreach ($fields as $field) {
  17.             $ret .= "(?P<" . strtolower($field) . ">\S+)\*";
  18.         }
  19.  
  20.         $ret .= "/";
  21.         return $ret;
  22.  
  23.     }
  24.     public function run($args)
  25.     {
  26.  
  27.         $headerPattern = $this->createPattern($this->headerFields, 'STH');
  28.         echo "Pattern is: " . $headerPattern . "\n";
  29.  
  30.         $input = $this->createTestHeaderInput('test');
  31.         echo "Input is: " . $input . "\n";
  32.         preg_match($headerPattern, $input, $matches);
  33.         print_r($matches);die;
  34.     }
  35.  
  36.     private function createTestHeaderInput($word)
  37.     {
  38.         $x = sizeof($this->headerFields);
  39.  
  40.         return "STH*" . str_repeat($word . '*', $x) . '~';
  41.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement