Files
streamline-emr/docker/_streamline-src/database/seeders/DataCorrectionIncomeAccountStrings.php
T

66 lines
3.0 KiB
PHP
Executable File

<?php
use Illuminate\Database\Seeder;
class DataCorrectionIncomeAccountStrings extends Seeder
{
/**
* Run the database seeders.
*
* @return void
*/
public function run()
{
$service_payments = \Streamline\Models\ServiceDeposit::all();
$investigation_payments = \Streamline\Models\InvestigationDeposit::all();
$procedure_payments = \Streamline\Models\ProcedureDeposit::all();
$sundry_payments = \Streamline\Models\SundryDeposit::all();
$treatment_payments = \Streamline\Models\TreatmentDeposits::all();
foreach ($service_payments as $payment){
$income_account_array = [];
$item_array = explode(',', $payment->items_ids);
for ($x = 0; $x < count($item_array); $x ++){
$income_account_array[] = get_name($item_array[$x], 'id', 'account_id', 'services');
}
\Streamline\Models\ServiceDeposit::where('id', $payment->id)->update(['current_chart_of_accounts'=> implode(',',$income_account_array)]);
}
foreach ($investigation_payments as $payment){
$income_account_array = [];
$item_array = explode(',', $payment->investigation_items);
for ($x = 0; $x < count($item_array); $x ++){
$income_account_array[] = get_name($item_array[$x], 'id', 'account_id', 'investigations');
}
\Streamline\Models\InvestigationDeposit::where('id', $payment->id)->update(['current_chart_of_accounts'=> implode(',',$income_account_array)]);
}
foreach ($procedure_payments as $payment){
$income_account_array = [];
$item_array = explode(',', $payment->procedure_items);
for ($x = 0; $x < count($item_array); $x ++){
$income_account_array[] = get_name($item_array[$x], 'id', 'account_id', 'procedures');
}
\Streamline\Models\ProcedureDeposit::where('id', $payment->id)->update(['current_chart_of_accounts'=> implode(',',$income_account_array)]);
}
foreach ($treatment_payments as $payment){
$income_account_array = [];
$item_array = explode(',', $payment->treatment_items);
for ($x = 0; $x < count($item_array); $x ++){
$income_account_array[] = get_name($item_array[$x], 'id', 'account_id', 'drugs');
}
\Streamline\Models\TreatmentDeposits::where('id', $payment->id)->update(['current_chart_of_accounts'=> implode(',',$income_account_array)]);
}
foreach ($sundry_payments as $payment){
$income_account_array = [];
$item_array = explode(',', $payment->sundry_items);
for ($x = 0; $x < count($item_array); $x ++){
$income_account_array[] = get_name($item_array[$x], 'id', 'account_id', 'sundries');
}
\Streamline\Models\SundryDeposit::where('id', $payment->id)->update(['current_chart_of_accounts'=> implode(',',$income_account_array)]);
}
}
}