Move nh_provider_class_id to networks_agents

This commit is contained in:
Djery-Tom 2021-11-23 17:16:17 +01:00
parent 456208661b
commit 2005b15208
3 changed files with 114 additions and 4 deletions

View File

@ -181,10 +181,10 @@ class HealthCareSheetController extends Controller
'performances.*.amount' => 'required|numeric', 'performances.*.amount' => 'required|numeric',
'performances.*.home_visit_fees' => 'nullable|numeric', 'performances.*.home_visit_fees' => 'nullable|numeric',
'prescriptions' => 'nullable|array', 'prescriptions' => 'nullable|array',
'prescriptions.*.drug_or_device_id' => 'required|integer|exists:', 'prescriptions.*.drug_or_device_id' => 'required|integer|exists:nh_drugs_and_devices,id',
'prescriptions.*.dosage' => 'required|string', 'prescriptions.*.dosage' => 'required|string',
'prescriptions.*.quantity' => 'required|integer', 'prescriptions.*.quantity' => 'required|integer',
'performances.*.unit_price' => 'required|numeric' 'prescriptions.*.unit_price' => 'required|numeric'
]); ]);
$insurance = NhInsurance::where('insured_id', $request->input('insured_id'))->where('state', InsuranceState::PAID)->first(); $insurance = NhInsurance::where('insured_id', $request->input('insured_id'))->where('state', InsuranceState::PAID)->first();
@ -241,11 +241,11 @@ class HealthCareSheetController extends Controller
])); ]));
foreach ($request->input('performances', []) as $p) { foreach ($request->input('performances', []) as $p) {
$act = NhAct::where('code', $p['code'])->first(); $act = NhAct::where('code', $p['act_code'])->first();
$performance = NhPerformance::create([ $performance = NhPerformance::create([
'act_id' => $act->id, 'act_id' => $act->id,
'amount' => $p['amount'], 'amount' => $p['amount'],
'home_visit_fees' => $p['home_visit_fees'], 'home_visit_fees' => $p['home_visit_fees'] ?? null,
'moderator_ticket' => $insuredPart * $p['amount'], // to calculate, 'moderator_ticket' => $insuredPart * $p['amount'], // to calculate,
'insurance_amount' => $insurerPart * $p['amount'], // to calculate, montant de l'assurance 'insurance_amount' => $insurerPart * $p['amount'], // to calculate, montant de l'assurance
'created_at' => $datetime, 'updated_at' => $datetime, 'created_at' => $datetime, 'updated_at' => $datetime,

View File

@ -0,0 +1,40 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class MoveNhProviderClassIdToAgentsTableInNetworksAgentsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('agents', function (Blueprint $table) {
$table->dropColumn('nh_provider_class_id');
});
Schema::table('networks_agents', function (Blueprint $table) {
$table->integer('nh_provider_class_id')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('agents', function (Blueprint $table) {
$table->integer('nh_provider_class_id')->nullable();
});
Schema::table('networks_agents', function (Blueprint $table) {
$table->dropColumn('nh_provider_class_id');
});
}
}

View File

@ -0,0 +1,70 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class UpdateAgentPlusView3 extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
DB::statement("CREATE OR REPLACE VIEW `agent_plus` AS
SELECT
`ag`.`id` AS `id`,
`ag`.`uid` AS `uid`,
`ag`.`firstname` AS `firstname`,
`ag`.`adresse` AS `adresse`,
`ag`.`lastname` AS `lastname`,
`ag`.`email` AS `email`,
`ag`.`encrypted_password` AS `encrypted_password`,
`ag`.`salt` AS `salt`,
`ag`.`longitude` AS `longitude`,
`ag`.`latitude` AS `latitude`,
`na`.`phone` AS `phone`,
`ag`.`active` AS `active`,
`ag`.`date_created` AS `created`,
`ag`.`open_hours` AS `openHours`,
`ag`.`close_hours` AS `closeHours`,
`na`.`solde` AS `solde`,
`na`.`etat` AS `etat`,
`ne`.`name` AS `network`,
`cti`.`name` AS `country`,
`cg`.`code_parrain` AS `code_parrain`,
`cg`.`category` AS `category`,
`cg`.`code_membre` AS `code_membre`,
`ag`.`number_geoBysuper` AS `number_geoBysuper`,
`ag`.`number_super` AS `number_super`,
`ne`.`id` AS `network_id`,
`ne`.`country_id` AS `country_id`,
`cti`.`code_dial` AS `code_dial`,
`na`.`transactionNumber` AS `transactionNumber`,
`na`.`id` AS `network_agent_id`,
`pc`.`name` AS `provider_class`,
`pc`.`id` AS `provider_class_id`,
`t`.`name` AS `town_name`,
`ag`.`town_id` AS `town_id`
FROM
((((((`agents` `ag`
JOIN `networks_agents` `na` ON ((`na`.`agent_id` = `ag`.`id`)))
JOIN `networks` `ne` ON ((`ne`.`id` = `na`.`network_id`)))
JOIN `countries` `cti` ON ((`cti`.`id` = `ne`.`country_id`)))
JOIN `codeGenerer` `cg` ON ((`cg`.`id` = `na`.`codeGenerer_id`)))
JOIn `towns` `t` on ((`ag`.`town_id` = `t`.`id`))
LEFT JOIN `nh_provider_classes` `pc` on ((`pc`.`id` = `na`.`nh_provider_class_id`))));");
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}