protected function billing_save_common($insurance_id_1, $insurance_id_2, $eid) { DB::table('billing')->where('eid', '=', $eid)->delete(); $this->audit('Delete'); $pid = Session::get('pid'); $practiceInfo = Practiceinfo::find(Session::get('practice_id')); $encounterInfo = Encounters::find($eid); $bill_complex = $encounterInfo->bill_complex; $row = Demographics::find($pid); if ($insurance_id_1 == '0' || $insurance_id_1 == '') { $data0 = array('eid' => $eid, 'pid' => $pid, 'insurance_id_1' => $insurance_id_1, 'insurance_id_2' => $insurance_id_2, 'bill_complex' => $bill_complex); DB::table('billing')->insert($data0); $this->audit('Add'); $data_encounter = array('bill_submitted' => 'Done'); DB::table('encounters')->where('eid', '=', $eid)->update($data_encounter); $this->audit('Update'); return 'Billing Saved!'; exit(0); } $data_encounter = array('bill_submitted' => 'No'); DB::table('encounters')->where('eid', '=', $eid)->update($data_encounter); $this->audit('Update'); $result1 = Insurance::find($insurance_id_1); $bill_Box11C = $result1->insurance_plan_name; $bill_Box11C = $this->string_format($bill_Box11C, 29); $bill_Box1A = $result1->insurance_id_num; $bill_Box1A = $this->string_format($bill_Box1A, 29); $bill_Box4 = $result1->insurance_insu_lastname . ', ' . $result1->insurance_insu_firstname; $bill_Box4 = $this->string_format($bill_Box4, 29); $result2 = Addressbook::find($result1->address_id); if ($result2->insurance_plan_type == 'Medicare') { $bill_Box1 = "X "; $bill_Box1P = 'Medicare'; } if ($result2->insurance_plan_type == 'Medicaid') { $bill_Box1 = " X "; $bill_Box1P = 'Medicaid'; } if ($result2->insurance_plan_type == 'Tricare') { $bill_Box1 = " X "; $bill_Box1P = 'Tricare'; } if ($result2->insurance_plan_type == 'ChampVA') { $bill_Box1 = " X "; $bill_Box1P = 'ChampVA'; } if ($result2->insurance_plan_type == 'Group Health Plan') { $bill_Box1 = " X "; $bill_Box1P = 'Group Health Plan'; } if ($result2->insurance_plan_type == 'FECA') { $bill_Box1 = " X "; $bill_Box1P = 'FECA'; } if ($result2->insurance_plan_type == 'Other') { $bill_Box1 = " X"; $bill_Box1P = 'Other'; } $bill_payor_id = $result2->insurance_plan_payor_id; $bill_payor_id = $this->string_format($bill_payor_id, 5); if ($result2->street_address2 == '') { $bill_ins_add1 = $result2->street_address1; } else { $bill_ins_add1 = $result2->street_address1 . ', ' . $result2->street_address2; } $bill_ins_add1 = $this->string_format($bill_ins_add1, 29); $bill_ins_add2 = $result2->city . ', ' . $result2->state . ' ' . $result2->zip; $bill_ins_add2 = $this->string_format($bill_ins_add2, 29); if ($result2->insurance_plan_assignment == 'Yes') { $bill_Box27 = "X "; $bill_Box27P = "Yes"; } else { $bill_Box27 = " X"; $bill_Box27P = "No"; } if ($result1->insurance_relationship == 'Self') { $bill_Box6 = "X "; $bill_Box6P = "SelfBox6"; } if ($result1->insurance_relationship == 'Spouse') { $bill_Box6 = " X "; $bill_Box6P = "Spouse"; } if ($result1->insurance_relationship == 'Child') { $bill_Box6 = " X "; $bill_Box6P = "Child"; } if ($result1->insurance_relationship == 'Other') { $bill_Box6 = " X"; $bill_Box6P = "Other"; } $bill_Box7A = $result1->insurance_insu_address; $bill_Box7A = $this->string_format($bill_Box7A, 29); $bill_Box7B = $result1->insurance_insu_city; $bill_Box7B = $this->string_format($bill_Box7B, 23); $bill_Box7C = $result1->insurance_insu_state; $bill_Box7C = $this->string_format($bill_Box7C, 4); $bill_Box7D = $result1->insurance_insu_zip; $bill_Box7D = $this->string_format($bill_Box7D, 12); $bill_Box11 = $result1->insurance_group; $bill_Box11 = $this->string_format($bill_Box11, 29); $bill_Box11A1 = $this->human_to_unix($result1->insurance_insu_dob); $bill_Box11A1 = date('m d Y', $bill_Box11A1); if ($result1->insurance_insu_gender == 'm') { $bill_Box11A2 = "X "; $bill_Box11A2P = 'M'; } elseif ($result1->insurance_insu_gender == 'f') { $bill_Box11A2 = " X"; $bill_Box11A2P = 'F'; } else { $bill_Box11A2 = " "; $bill_Box11A2P = 'U'; } if ($insurance_id_2 == '' || $insurance_id_2 == '0') { $bill_Box9D = ''; $bill_Box9 = ''; $bill_Box9A = ''; $bill_Box9B1 = ' '; $bill_Box9B2 = ' '; $bill_Box9B2P = ''; $bill_Box9C = ""; $bill_Box11D = ' X'; $bill_Box11DP = 'No'; } else { $result3 = Insurance::find($insurance_id_2); $bill_Box9D = $result3->insurance_plan_name; $bill_Box9 = $result3->insurance_insu_lastname . ', ' . $result3->insurance_insu_firstname; $bill_Box9A = $result3->insurance_group; $bill_Box9B1 = $this->human_to_unix($result3->insurance_insu_dob); $bill_Box9B1 = date('m d Y', $bill_Box9B1); if ($result3->insurance_insu_gender == 'm') { $bill_Box9B2 = "X "; $bill_Box9B2P = 'M'; } elseif ($result3->insurance_insu_gender == 'f') { $bill_Box9B2 = " X"; $bill_Box9B2P = 'F'; } else { $bill_Box9B2 = " "; $bill_Box9B2P = 'U'; } $bill_Box11D = 'X '; $bill_Box11DP = 'Yes'; if ($row->employer != '') { $bill_Box9C = $row->employer; } else { $bill_Box9C = ""; } } $bill_Box9D = $this->string_format($bill_Box9D, 28); $bill_Box9 = $this->string_format($bill_Box9, 28); $bill_Box9A = $this->string_format($bill_Box9A, 28); $bill_Box9C = $this->string_format($bill_Box9C, 28); $bill_Box2 = $row->lastname . ', ' . $row->firstname; $bill_Box2 = $this->string_format($bill_Box2, 28); $bill_Box3A = $this->human_to_unix($row->DOB); $bill_Box3A = date('m d Y', $bill_Box3A); if ($row->sex == 'm') { $bill_Box3B = "X "; $bill_Box3BP = 'M'; } elseif ($row->sex == 'f') { $bill_Box3B = " X"; $bill_Box3BP = 'F'; } else { $bill_Box3B = " "; $bill_Box3BP = 'U'; } if ($row->marital_status == 'Single') { $bill_Box8A = "X "; $bill_Box8AP = 'SingleBox8'; } else { if ($row->marital_status == 'Married') { $bill_Box8A = " X "; $bill_Box8AP = 'Married'; } else { $bill_Box8A = " X"; $bill_Box8AP = 'Other'; } } if ($row->employer != '') { $bill_Box8B = "X "; $bill_Box8BP = "EmployedBox8"; $bill_Box11B = $row->employer; } else { $bill_Box8B = " "; $bill_Box8BP = ""; $bill_Box11B = ""; } $bill_Box11B = $this->string_format($bill_Box11B, 29); $bill_Box5A = $row->address; $bill_Box5A = $this->string_format($bill_Box5A, 28); $bill_Box5B = $row->city; $bill_Box5B = $this->string_format($bill_Box5B, 24); $bill_Box5C = $row->state; $bill_Box5C = $this->string_format($bill_Box5C, 3); $bill_Box5D = $row->zip; $bill_Box5D = $this->string_format($bill_Box5D, 12); $bill_Box5E = $row->phone_home; $bill_Box5E = $this->string_format($bill_Box5E, 14); $bill_Box10 = $encounterInfo->encounter_condition; $bill_Box10 = $this->string_format($bill_Box10, 19); $work = $encounterInfo->encounter_condition_work; if ($work == 'Yes') { $bill_Box10A = "X "; $bill_Box10AP = 'Yes'; } else { $bill_Box10A = " X"; $bill_Box10AP = 'No'; } $auto = $encounterInfo->encounter_condition_auto; if ($auto == 'Yes') { $bill_Box10B1 = "X "; $bill_Box10B1P = 'Yes'; $bill_Box10B2 = $encounterInfo->encounter_condition_auto_state; } else { $bill_Box10B1 = " X"; $bill_Box10B1P = 'No'; $bill_Box10B2 = ""; } $bill_Box10B2 = $this->string_format($bill_Box10B2, 3); $other = $encounterInfo->encounter_condition_other; if ($other == 'Yes') { $bill_Box10C = "X "; $bill_Box10CP = "Yes"; } else { $bill_Box10C = " X"; $bill_Box10CP = 'No'; } $provider = $encounterInfo->encounter_provider; $user_row = User::where('displayname', '=', $provider)->where('group_id', '=', '2')->first(); $result4 = Providers::find($user_row->id); $npi = $result4->npi; if ($encounterInfo->referring_provider != 'Primary Care Provider' || $encounterInfo->referring_provider != '') { $bill_Box17 = $this->string_format($encounterInfo->referring_provider, 26); $bill_Box17A = $this->string_format($encounterInfo->referring_provider_npi, 17); } else { if ($encounterInfo->referring_provider != 'Primary Care Provider') { $bill_Box17 = $this->string_format('', 26); $bill_Box17A = $this->string_format('', 17); } else { $bill_Box17 = $this->string_format($provider, 26); $bill_Box17A = $this->string_format($npi, 17); } } $bill_Box21A = $practiceInfo->icd; if ($result2->insurance_box_31 == 'n') { $bill_Box31 = $this->string_format($provider, 21); } else { $provider2 = User::find($encounterInfo->user_id); $provider2a = $provider2->lastname . ", " . $provider2->firstname; $bill_Box31 = $this->string_format($provider2a, 21); } $bill_Box33B = $this->string_format($provider, 29); $pos = $encounterInfo->encounter_location; $bill_Box25 = $practiceInfo->tax_id; $bill_Box25 = $this->string_format($bill_Box25, 15); $bill_Box26 = $this->string_format($pid . '_' . $eid, 14); $bill_Box32A = $practiceInfo->practice_name; $bill_Box32A = $this->string_format($bill_Box32A, 26); $bill_Box32B = $practiceInfo->street_address1; if ($practiceInfo->street_address2 != '') { $bill_Box32B .= ', ' . $practiceInfo->street_address2; } $bill_Box32B = $this->string_format($bill_Box32B, 26); $bill_Box32C = $practiceInfo->city . ', ' . $practiceInfo->state . ' ' . $practiceInfo->zip; $bill_Box32C = $this->string_format($bill_Box32C, 26); if ($result2->insurance_box_32a == 'n') { $bill_Box32D = $practiceInfo->npi; } else { $provider3 = Providers::find($encounterInfo->user_id); $bill_Box32D = $provider3->npi; } $bill_Box32D = $this->string_format($bill_Box32D, 10); $bill_Box33A = $practiceInfo->phone; $bill_Box33A = $this->string_format($bill_Box33A, 14); $bill_Box33C = $practiceInfo->billing_street_address1; if ($practiceInfo->billing_street_address2 != '') { $bill_Box33C .= ', ' . $practiceInfo->billing_street_address2; } $bill_Box33C = $this->string_format($bill_Box33C, 29); $bill_Box33D = $practiceInfo->billing_city . ', ' . $practiceInfo->billing_state . ' ' . $practiceInfo->billing_zip; $bill_Box33D = $this->string_format($bill_Box33D, 29); $result5 = DB::table('billing_core')->where('eid', '=', $eid)->where('cpt', 'NOT LIKE', "sp%")->orderBy('cpt_charge', 'desc')->get(); $num_rows5 = count($result5); if ($num_rows5 > 0) { $result6 = Assessment::find($eid); $bill_Box21_1 = $this->string_format($result6->assessment_icd1, 8); $bill_Box21_2 = $this->string_format($result6->assessment_icd2, 8); $bill_Box21_3 = $this->string_format($result6->assessment_icd3, 8); $bill_Box21_4 = $this->string_format($result6->assessment_icd4, 8); $bill_Box21_5 = $this->string_format($result6->assessment_icd5, 8); $bill_Box21_6 = $this->string_format($result6->assessment_icd6, 8); $bill_Box21_7 = $this->string_format($result6->assessment_icd7, 8); $bill_Box21_8 = $this->string_format($result6->assessment_icd8, 8); $bill_Box21_9 = $this->string_format($result6->assessment_icd9, 8); $bill_Box21_10 = $this->string_format($result6->assessment_icd10, 8); $bill_Box21_11 = $this->string_format($result6->assessment_icd11, 8); $bill_Box21_12 = $this->string_format($result6->assessment_icd12, 8); $i = 0; foreach ($result5 as $key5 => $value5) { $cpt_charge5[$key5] = $value5->cpt_charge; } array_multisort($cpt_charge5, SORT_DESC, $result5); while ($i < $num_rows5) { $cpt_final[$i] = (array) $result5[$i]; $cpt_final[$i]['dos_f'] = str_replace('/', '', $cpt_final[$i]['dos_f']); $cpt_final[$i]['dos_f'] = $this->string_format($cpt_final[$i]['dos_f'], 8); $cpt_final[$i]['dos_t'] = str_replace('/', '', $cpt_final[$i]['dos_t']); $cpt_final[$i]['dos_t'] = $this->string_format($cpt_final[$i]['dos_t'], 8); $cpt_final[$i]['pos'] = $this->string_format($pos, 5); $cpt_final[$i]['cpt'] = $this->string_format($cpt_final[$i]['cpt'], 6); $cpt_final[$i]['modifier'] = $this->string_format($cpt_final[$i]['modifier'], 11); $cpt_final[$i]['unit1'] = $cpt_final[$i]['unit']; $cpt_final[$i]['unit'] = $this->string_format($cpt_final[$i]['unit'], 5); $cpt_final[$i]['cpt_charge'] = number_format($cpt_final[$i]['cpt_charge'], 2, ' ', ''); $cpt_final[$i]['cpt_charge1'] = $cpt_final[$i]['cpt_charge']; $cpt_final[$i]['cpt_charge'] = $this->string_format($cpt_final[$i]['cpt_charge'], 8); $cpt_final[$i]['npi'] = $this->string_format($npi, 11); $cpt_final[$i]['icd_pointer'] = $this->string_format($cpt_final[$i]['icd_pointer'], 4); $i++; } if ($num_rows5 < 6) { $array['dos_f'] = $this->string_format('', 8); $array['dos_t'] = $this->string_format('', 8); $array['pos'] = $this->string_format('', 5); $array['cpt'] = $this->string_format('', 6); $array['modifier'] = $this->string_format('', 11); $array['unit1'] = '0'; $array['unit'] = $this->string_format('', 5); $array['cpt_charge1'] = '0'; $array['cpt_charge'] = $this->string_format('', 8); $array['npi'] = $this->string_format('', 11); $array['icd_pointer'] = $this->string_format('', 4); $cpt_final = array_pad($cpt_final, 6, $array); } $bill_Box28 = $cpt_final[0]['cpt_charge1'] * $cpt_final[0]['unit1'] + $cpt_final[1]['cpt_charge1'] * $cpt_final[1]['unit1'] + $cpt_final[2]['cpt_charge1'] * $cpt_final[2]['unit1'] + $cpt_final[3]['cpt_charge1'] * $cpt_final[3]['unit1'] + $cpt_final[4]['cpt_charge1'] * $cpt_final[4]['unit1'] + $cpt_final[5]['cpt_charge1'] * $cpt_final[5]['unit1']; $bill_Box28 = number_format($bill_Box28, 2, ' ', ''); $bill_Box28 = $this->string_format($bill_Box28, 9); $bill_Box29 = $this->string_format('0 00', 8); $bill_Box30 = $this->string_format($bill_Box28, 8); $data1 = array('eid' => $eid, 'pid' => $pid, 'insurance_id_1' => $insurance_id_1, 'insurance_id_2' => $insurance_id_2, 'bill_complex' => $bill_complex, 'bill_Box11C' => $bill_Box11C, 'bill_payor_id' => $bill_payor_id, 'bill_ins_add1' => $bill_ins_add1, 'bill_ins_add2' => $bill_ins_add2, 'bill_Box1' => $bill_Box1, 'bill_Box1P' => $bill_Box1P, 'bill_Box1A' => $bill_Box1A, 'bill_Box2' => $bill_Box2, 'bill_Box3A' => $bill_Box3A, 'bill_Box3B' => $bill_Box3B, 'bill_Box3BP' => $bill_Box3BP, 'bill_Box4' => $bill_Box4, 'bill_Box5A' => $bill_Box5A, 'bill_Box6' => $bill_Box6, 'bill_Box6P' => $bill_Box6P, 'bill_Box7A' => $bill_Box7A, 'bill_Box5B' => $bill_Box5B, 'bill_Box5C' => $bill_Box5C, 'bill_Box8A' => $bill_Box8A, 'bill_Box8AP' => $bill_Box8AP, 'bill_Box7B' => $bill_Box7B, 'bill_Box7C' => $bill_Box7C, 'bill_Box5D' => $bill_Box5D, 'bill_Box5E' => $bill_Box5E, 'bill_Box8B' => $bill_Box8B, 'bill_Box8BP' => $bill_Box8BP, 'bill_Box7D' => $bill_Box7D, 'bill_Box9' => $bill_Box9, 'bill_Box11' => $bill_Box11, 'bill_Box9A' => $bill_Box9A, 'bill_Box10' => $bill_Box10, 'bill_Box10A' => $bill_Box10A, 'bill_Box10AP' => $bill_Box10AP, 'bill_Box11A1' => $bill_Box11A1, 'bill_Box11A2' => $bill_Box11A2, 'bill_Box11A2P' => $bill_Box11A2P, 'bill_Box9B1' => $bill_Box9B1, 'bill_Box9B2' => $bill_Box9B2, 'bill_Box9B2P' => $bill_Box9B2P, 'bill_Box10B1' => $bill_Box10B1, 'bill_Box10B1P' => $bill_Box10B1P, 'bill_Box10B2' => $bill_Box10B2, 'bill_Box11B' => $bill_Box11B, 'bill_Box9C' => $bill_Box9C, 'bill_Box10C' => $bill_Box10C, 'bill_Box10CP' => $bill_Box10CP, 'bill_Box9D' => $bill_Box9D, 'bill_Box11D' => $bill_Box11D, 'bill_Box11DP' => $bill_Box11DP, 'bill_Box17' => $bill_Box17, 'bill_Box17A' => $bill_Box17A, 'bill_Box21A' => $bill_Box21A, 'bill_Box21_1' => $bill_Box21_1, 'bill_Box21_2' => $bill_Box21_2, 'bill_Box21_3' => $bill_Box21_3, 'bill_Box21_4' => $bill_Box21_4, 'bill_Box21_5' => $bill_Box21_5, 'bill_Box21_6' => $bill_Box21_6, 'bill_Box21_7' => $bill_Box21_7, 'bill_Box21_8' => $bill_Box21_8, 'bill_Box21_9' => $bill_Box21_9, 'bill_Box21_10' => $bill_Box21_10, 'bill_Box21_11' => $bill_Box21_11, 'bill_Box21_12' => $bill_Box21_12, 'bill_DOS1F' => $cpt_final[0]['dos_f'], 'bill_DOS1T' => $cpt_final[0]['dos_t'], 'bill_DOS2F' => $cpt_final[1]['dos_f'], 'bill_DOS2T' => $cpt_final[1]['dos_t'], 'bill_DOS3F' => $cpt_final[2]['dos_f'], 'bill_DOS3T' => $cpt_final[2]['dos_t'], 'bill_DOS4F' => $cpt_final[3]['dos_f'], 'bill_DOS4T' => $cpt_final[3]['dos_t'], 'bill_DOS5F' => $cpt_final[4]['dos_f'], 'bill_DOS5T' => $cpt_final[4]['dos_t'], 'bill_DOS6F' => $cpt_final[5]['dos_f'], 'bill_DOS6T' => $cpt_final[5]['dos_t'], 'bill_Box24B1' => $cpt_final[0]['pos'], 'bill_Box24B2' => $cpt_final[1]['pos'], 'bill_Box24B3' => $cpt_final[2]['pos'], 'bill_Box24B4' => $cpt_final[3]['pos'], 'bill_Box24B5' => $cpt_final[4]['pos'], 'bill_Box24B6' => $cpt_final[5]['pos'], 'bill_Box24D1' => $cpt_final[0]['cpt'], 'bill_Box24D2' => $cpt_final[1]['cpt'], 'bill_Box24D3' => $cpt_final[2]['cpt'], 'bill_Box24D4' => $cpt_final[3]['cpt'], 'bill_Box24D5' => $cpt_final[4]['cpt'], 'bill_Box24D6' => $cpt_final[5]['cpt'], 'bill_Modifier1' => $cpt_final[0]['modifier'], 'bill_Modifier2' => $cpt_final[1]['modifier'], 'bill_Modifier3' => $cpt_final[2]['modifier'], 'bill_Modifier4' => $cpt_final[3]['modifier'], 'bill_Modifier5' => $cpt_final[4]['modifier'], 'bill_Modifier6' => $cpt_final[5]['modifier'], 'bill_Box24E1' => $cpt_final[0]['icd_pointer'], 'bill_Box24E2' => $cpt_final[1]['icd_pointer'], 'bill_Box24E3' => $cpt_final[2]['icd_pointer'], 'bill_Box24E4' => $cpt_final[3]['icd_pointer'], 'bill_Box24E5' => $cpt_final[4]['icd_pointer'], 'bill_Box24E6' => $cpt_final[5]['icd_pointer'], 'bill_Box24F1' => number_format($cpt_final[0]['cpt_charge'] * $cpt_final[0]['unit'], 2, ' ', ''), 'bill_Box24F2' => number_format($cpt_final[1]['cpt_charge'] * $cpt_final[1]['unit'], 2, ' ', ''), 'bill_Box24F3' => number_format($cpt_final[2]['cpt_charge'] * $cpt_final[2]['unit'], 2, ' ', ''), 'bill_Box24F4' => number_format($cpt_final[3]['cpt_charge'] * $cpt_final[3]['unit'], 2, ' ', ''), 'bill_Box24F5' => number_format($cpt_final[4]['cpt_charge'] * $cpt_final[4]['unit'], 2, ' ', ''), 'bill_Box24F6' => number_format($cpt_final[5]['cpt_charge'] * $cpt_final[5]['unit'], 2, ' ', ''), 'bill_Box24G1' => $cpt_final[0]['unit'], 'bill_Box24G2' => $cpt_final[1]['unit'], 'bill_Box24G3' => $cpt_final[2]['unit'], 'bill_Box24G4' => $cpt_final[3]['unit'], 'bill_Box24G5' => $cpt_final[4]['unit'], 'bill_Box24G6' => $cpt_final[5]['unit'], 'bill_Box24J1' => $cpt_final[0]['npi'], 'bill_Box24J2' => $cpt_final[1]['npi'], 'bill_Box24J3' => $cpt_final[2]['npi'], 'bill_Box24J4' => $cpt_final[3]['npi'], 'bill_Box24J5' => $cpt_final[4]['npi'], 'bill_Box24J6' => $cpt_final[5]['npi'], 'bill_Box25' => $bill_Box25, 'bill_Box26' => $bill_Box26, 'bill_Box27' => $bill_Box27, 'bill_Box27P' => $bill_Box27P, 'bill_Box28' => $bill_Box28, 'bill_Box29' => $bill_Box29, 'bill_Box30' => $bill_Box30, 'bill_Box31' => $bill_Box31, 'bill_Box32A' => $bill_Box32A, 'bill_Box32B' => $bill_Box32B, 'bill_Box32C' => $bill_Box32C, 'bill_Box32D' => $bill_Box32D, 'bill_Box33A' => $bill_Box33A, 'bill_Box33B' => $bill_Box33B, 'bill_Box33C' => $bill_Box33C, 'bill_Box33D' => $bill_Box33D, 'bill_Box33E' => $bill_Box32D); DB::table('billing')->insert($data1); $this->audit('Add'); unset($cpt_final[0]); unset($cpt_final[1]); unset($cpt_final[2]); unset($cpt_final[3]); unset($cpt_final[4]); unset($cpt_final[5]); if ($num_rows5 > 6 && $num_rows5 < 11) { $k = 6; foreach ($cpt_final as $k => $v) { $l = $k - 6; $cpt_final[$l] = $cpt_final[$k]; unset($cpt_final[$k]); $k++; } $num_rows6 = count($cpt_final); if ($num_rows6 < 6) { $array1['dos_f'] = $this->string_format('', 8); $array1['dos_t'] = $this->string_format('', 8); $array1['pos'] = $this->string_format('', 5); $array1['cpt'] = $this->string_format('', 6); $array1['modifier'] = $this->string_format('', 11); $array1['unit1'] = '0'; $array1['unit'] = $this->string_format('', 5); $array1['cpt_charge1'] = '0'; $array1['cpt_charge'] = $this->string_format('', 8); $array1['npi'] = $this->string_format('', 11); $array1['icd_pointer'] = $this->string_format('', 4); $cpt_final = array_pad($cpt_final, 6, $array1); } $bill_Box28 = $cpt_final[0]['cpt_charge1'] * $cpt_final[0]['unit1'] + $cpt_final[1]['cpt_charge1'] * $cpt_final[1]['unit1'] + $cpt_final[2]['cpt_charge1'] * $cpt_final[2]['unit1'] + $cpt_final[3]['cpt_charge1'] * $cpt_final[3]['unit1'] + $cpt_final[4]['cpt_charge1'] * $cpt_final[4]['unit1'] + $cpt_final[5]['cpt_charge1'] * $cpt_final[5]['unit1']; $bill_Box28 = number_format($bill_Box28, 2, ' ', ''); $bill_Box28 = $this->string_format($bill_Box28, 9); $bill_Box29 = $this->string_format('0 00', 8); $bill_Box30 = $this->string_format($bill_Box28, 8); $data2 = array('eid' => $eid, 'pid' => $pid, 'insurance_id_1' => $insurance_id_1, 'insurance_id_2' => $insurance_id_2, 'bill_complex' => $bill_complex, 'bill_Box11C' => $bill_Box11C, 'bill_payor_id' => $bill_payor_id, 'bill_ins_add1' => $bill_ins_add1, 'bill_ins_add2' => $bill_ins_add2, 'bill_Box1' => $bill_Box1, 'bill_Box1P' => $bill_Box1P, 'bill_Box1A' => $bill_Box1A, 'bill_Box2' => $bill_Box2, 'bill_Box3A' => $bill_Box3A, 'bill_Box3B' => $bill_Box3B, 'bill_Box3BP' => $bill_Box3BP, 'bill_Box4' => $bill_Box4, 'bill_Box5A' => $bill_Box5A, 'bill_Box6' => $bill_Box6, 'bill_Box6P' => $bill_Box6P, 'bill_Box7A' => $bill_Box7A, 'bill_Box5B' => $bill_Box5B, 'bill_Box5C' => $bill_Box5C, 'bill_Box8A' => $bill_Box8A, 'bill_Box8AP' => $bill_Box8AP, 'bill_Box7B' => $bill_Box7B, 'bill_Box7C' => $bill_Box7C, 'bill_Box5D' => $bill_Box5D, 'bill_Box5E' => $bill_Box5E, 'bill_Box8B' => $bill_Box8B, 'bill_Box8BP' => $bill_Box8BP, 'bill_Box7D' => $bill_Box7D, 'bill_Box9' => $bill_Box9, 'bill_Box11' => $bill_Box11, 'bill_Box9A' => $bill_Box9A, 'bill_Box10' => $bill_Box10, 'bill_Box10A' => $bill_Box10A, 'bill_Box10AP' => $bill_Box10AP, 'bill_Box11A1' => $bill_Box11A1, 'bill_Box11D' => $bill_Box11D, 'bill_Box11DP' => $bill_Box11DP, 'bill_Box11A2' => $bill_Box11A2, 'bill_Box11A2P' => $bill_Box11A2P, 'bill_Box9B1' => $bill_Box9B1, 'bill_Box9B2' => $bill_Box9B2, 'bill_Box9B2P' => $bill_Box9B2P, 'bill_Box10B1' => $bill_Box10B1, 'bill_Box10B1P' => $bill_Box10B1P, 'bill_Box10B2' => $bill_Box10B2, 'bill_Box11B' => $bill_Box11B, 'bill_Box9C' => $bill_Box9C, 'bill_Box10C' => $bill_Box10C, 'bill_Box10CP' => $bill_Box10CP, 'bill_Box9D' => $bill_Box9D, 'bill_Box11D' => $bill_Box11D, 'bill_Box11DP' => $bill_Box11DP, 'bill_Box17' => $bill_Box17, 'bill_Box17A' => $bill_Box17A, 'bill_Box21A' => $bill_Box21A, 'bill_Box21_1' => $bill_Box21_1, 'bill_Box21_2' => $bill_Box21_2, 'bill_Box21_3' => $bill_Box21_3, 'bill_Box21_4' => $bill_Box21_4, 'bill_Box21_5' => $bill_Box21_5, 'bill_Box21_6' => $bill_Box21_6, 'bill_Box21_7' => $bill_Box21_7, 'bill_Box21_8' => $bill_Box21_8, 'bill_Box21_9' => $bill_Box21_9, 'bill_Box21_10' => $bill_Box21_10, 'bill_Box21_11' => $bill_Box21_11, 'bill_Box21_12' => $bill_Box21_12, 'bill_DOS1F' => $cpt_final[0]['dos_f'], 'bill_DOS1T' => $cpt_final[0]['dos_t'], 'bill_DOS2F' => $cpt_final[1]['dos_f'], 'bill_DOS2T' => $cpt_final[1]['dos_t'], 'bill_DOS3F' => $cpt_final[2]['dos_f'], 'bill_DOS3T' => $cpt_final[2]['dos_t'], 'bill_DOS4F' => $cpt_final[3]['dos_f'], 'bill_DOS4T' => $cpt_final[3]['dos_t'], 'bill_DOS5F' => $cpt_final[4]['dos_f'], 'bill_DOS5T' => $cpt_final[4]['dos_t'], 'bill_DOS6F' => $cpt_final[5]['dos_f'], 'bill_DOS6T' => $cpt_final[5]['dos_t'], 'bill_Box24B1' => $cpt_final[0]['pos'], 'bill_Box24B2' => $cpt_final[1]['pos'], 'bill_Box24B3' => $cpt_final[2]['pos'], 'bill_Box24B4' => $cpt_final[3]['pos'], 'bill_Box24B5' => $cpt_final[4]['pos'], 'bill_Box24B6' => $cpt_final[5]['pos'], 'bill_Box24D1' => $cpt_final[0]['cpt'], 'bill_Box24D2' => $cpt_final[1]['cpt'], 'bill_Box24D3' => $cpt_final[2]['cpt'], 'bill_Box24D4' => $cpt_final[3]['cpt'], 'bill_Box24D5' => $cpt_final[4]['cpt'], 'bill_Box24D6' => $cpt_final[5]['cpt'], 'bill_Modifier1' => $cpt_final[0]['modifier'], 'bill_Modifier2' => $cpt_final[1]['modifier'], 'bill_Modifier3' => $cpt_final[2]['modifier'], 'bill_Modifier4' => $cpt_final[3]['modifier'], 'bill_Modifier5' => $cpt_final[4]['modifier'], 'bill_Modifier6' => $cpt_final[5]['modifier'], 'bill_Box24E1' => $cpt_final[0]['icd_pointer'], 'bill_Box24E2' => $cpt_final[1]['icd_pointer'], 'bill_Box24E3' => $cpt_final[2]['icd_pointer'], 'bill_Box24E4' => $cpt_final[3]['icd_pointer'], 'bill_Box24E5' => $cpt_final[4]['icd_pointer'], 'bill_Box24E6' => $cpt_final[5]['icd_pointer'], 'bill_Box24F1' => number_format($cpt_final[0]['cpt_charge'] * $cpt_final[0]['unit'], 2, ' ', ''), 'bill_Box24F2' => number_format($cpt_final[1]['cpt_charge'] * $cpt_final[1]['unit'], 2, ' ', ''), 'bill_Box24F3' => number_format($cpt_final[2]['cpt_charge'] * $cpt_final[2]['unit'], 2, ' ', ''), 'bill_Box24F4' => number_format($cpt_final[3]['cpt_charge'] * $cpt_final[3]['unit'], 2, ' ', ''), 'bill_Box24F5' => number_format($cpt_final[4]['cpt_charge'] * $cpt_final[4]['unit'], 2, ' ', ''), 'bill_Box24F6' => number_format($cpt_final[5]['cpt_charge'] * $cpt_final[5]['unit'], 2, ' ', ''), 'bill_Box24G1' => $cpt_final[0]['unit'], 'bill_Box24G2' => $cpt_final[1]['unit'], 'bill_Box24G3' => $cpt_final[2]['unit'], 'bill_Box24G4' => $cpt_final[3]['unit'], 'bill_Box24G5' => $cpt_final[4]['unit'], 'bill_Box24G6' => $cpt_final[5]['unit'], 'bill_Box24J1' => $cpt_final[0]['npi'], 'bill_Box24J2' => $cpt_final[1]['npi'], 'bill_Box24J3' => $cpt_final[2]['npi'], 'bill_Box24J4' => $cpt_final[3]['npi'], 'bill_Box24J5' => $cpt_final[4]['npi'], 'bill_Box24J6' => $cpt_final[5]['npi'], 'bill_Box25' => $bill_Box25, 'bill_Box26' => $bill_Box26, 'bill_Box27' => $bill_Box27, 'bill_Box27P' => $bill_Box27P, 'bill_Box28' => $bill_Box28, 'bill_Box29' => $bill_Box29, 'bill_Box30' => $bill_Box30, 'bill_Box31' => $bill_Box31, 'bill_Box32A' => $bill_Box32A, 'bill_Box32B' => $bill_Box32B, 'bill_Box32C' => $bill_Box32C, 'bill_Box32D' => $bill_Box32D, 'bill_Box33A' => $bill_Box33A, 'bill_Box33B' => $bill_Box33B, 'bill_Box33C' => $bill_Box33C, 'bill_Box33D' => $bill_Box33D, 'bill_Box33E' => $bill_Box32D); DB::table('billing')->insert($data2); $this->audit('Add'); unset($cpt_final[0]); unset($cpt_final[1]); unset($cpt_final[2]); unset($cpt_final[3]); unset($cpt_final[4]); unset($cpt_final[5]); } } else { return "No CPT charges filed. Billing not saved."; exit(0); } return 'Billing saved and waiting to be submitted!'; }
private function setInsuranceData() { if (isset($this->phkRequestData['insurance_id']) && !isset($this->phkRequestData['insurance_text'])) { App::import("Model", "Insurance"); $insurance = new Insurance(); $result = $insurance->find("first", array('conditions' => array('Insurance.id' => $this->phkRequestData['insurance_id']))); if (count($result)) { $this->phkRequestData['insurance_id'] = $result['Insurance']['id']; $this->phkRequestData['insurance_text'] = $result['Insurance']['title']; } } }
public function postGetInsuranceInfo() { $insurance_id_1 = Input::get('insurance_id_1'); $insurance_id_2 = Input::get('insurance_id_2'); if ($insurance_id_1 != '') { if ($insurance_id_1 == '0') { $arr['result1'] = 'Self pay; no insurance.'; $arr['result2'] = 'None chosen.'; } else { $result1 = Insurance::find($insurance_id_1); if ($result1) { $arr['result1'] = $result1->insurance_plan_name; } else { $arr['result1'] = 'None chosen.'; } } } else { $arr['result1'] = 'None chosen.'; } if ($insurance_id_2 != '') { $result2 = Insurance::find($insurance_id_2); if ($result2) { $arr['result2'] = $result2->insurance_plan_name; } else { $arr['result2'] = 'None chosen.'; } } else { $arr['result2'] = 'None chosen.'; } echo json_encode($arr); }