Begin health care sheet store

This commit is contained in:
Djery-Tom 2021-11-19 17:07:42 +01:00
parent 576d4e5062
commit 456208661b
32 changed files with 1081 additions and 19 deletions

View File

@ -0,0 +1,300 @@
<?php
namespace App\Http\Controllers;
use App\InsuranceState;
use App\InsuranceSubscriptionState;
use App\Models\AgentPlus;
use App\Models\NhAct;
use App\Models\NhDrugsAndDevice;
use App\Models\NhHealthCareSheet;
use App\Models\NhHealthCareSheetsHistory;
use App\Models\NhHealthCareSheetsPerformance;
use App\Models\NhHealthCareSheetsPrescription;
use App\Models\NhInsurance;
use App\Models\NhInsurancesSubscription;
use App\Models\NhMedicalPrescription;
use App\Models\NhNetworksConfig;
use App\Models\NhPerformance;
use App\Traits\ApiResponser;
use App\Traits\Helper;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Throwable;
class HealthCareSheetController extends Controller
{
use ApiResponser;
use Helper;
/**
* @OA\Get(
* path="/drugs-and-devices",
* summary="Rechercher les medicaments / appareillaages ( par reseau et par nom)",
* tags={"Médicaments / Appareillages"},
* security={{"api_key":{}}},
* @OA\Parameter(
* parameter="network_id",
* name="network_id",
* description="ID du reseau",
* @OA\Schema(
* type="integer"
* ),
* in="query",
* required=true
* ),
* @OA\Parameter(
* parameter="name",
* name="name",
* description="Nom du médicament / appareillage",
* @OA\Schema(
* type="string"
* ),
* in="query",
* required=true
* ),
* @OA\Response(
* response=200,
* description="OK",
* @OA\JsonContent(
* ref="#/components/schemas/ApiResponse",
* example = {
* "status" : 200,
* "response" : {{"id":2,"network_id":250,"code":"ABD","name":"Nivaquine","type":"Comprimé",
* "on_prescription":false,"created_at":"2021-11-16T09:13:30.000000Z","updated_at":"2021-11-16T09:13:30.000000Z"}},
* "error":null
* }
* )
* )
* )
*/
public function getDrugsAndDevices(Request $request)
{
$this->validate($request, [
'network_id' => 'required|integer',
'name' => 'required|string'
]);
$drugs = NhDrugsAndDevice::where('network_id', $request->input('network_id'))
->where('name', 'like', '%' . $request->input('name') . '%')->get();
return $this->successResponse($drugs);
}
/**
* @OA\Post(
* path="/drugs-and-devices",
* summary="Ajouter les medicaments / appareillages",
* tags={"Médicaments / Appareillages"},
* security={{"api_key":{}}},
* @OA\RequestBody(
* description="Corps de la requete",
* required=true,
* @OA\MediaType(
* mediaType="application/json",
* @OA\Schema(
* @OA\Property(
* property="network_id",
* description = "ID du reseau",
* type="integer",
* example= 250
* ),
* @OA\Property(
* property="code",
* description = "Code du médicament / appareillage",
* type="string",
* example= "ABD"
* ),
* @OA\Property(
* property="name",
* description = "Nom du médicament / appareillage",
* type="string",
* example= "Nivaquine"
* ),
* @OA\Property(
* property="type",
* description = "Type de médicament / appareillage",
* type="string",
* enum={"COMPRESSED","SYRUP","SOLUTION","SUPPOSITORY","DEVICE"},
* example= "COMPRESSED"
* ),
* @OA\Property(
* property="on_prescription",
* description = "Sous ordornance ou pas",
* type="bool",
* example= "false"
* )
* ),
* ),
* ),
* @OA\Response(
* response=200,
* description="OK",
* @OA\JsonContent(
* ref="#/components/schemas/ApiResponse",
* example = {
* "status" : 200,
* "response" : "Médicament / Appareillage enregistré",
* "error":null
* }
* )
* )
* )
*/
public function storeDrugsAndDevices(Request $request)
{
$this->validate($request, [
'network_id' => 'required|integer|exists:networks,id',
'name' => 'required|string',
'code' => 'required|string',
'type' => 'required|string|in:COMPRESSED,SYRUP,SOLUTION,SUPPOSITORY,DEVICE',
'on_prescription' => 'required|boolean'
]);
$drug = NhDrugsAndDevice::where('network_id', $request->input('network_id'))
->where('code', $request->input('code'))->first();
if (isset($drug)) {
return $this->errorResponse(trans('errors.drug_device_already_exists'));
}
NhDrugsAndDevice::create($request->all());
return $this->successResponse(trans('messages.drug_device_saved'));
}
public function storeHealthCareSheet(Request $request)
{
$this->validate($request, [
'insured_id' => 'required|string',
'network_agent_id' => 'required|integer|exists:networks_agents,id',
'password' => 'required|string',
'beneficiary_id' => 'nullable|int|exists:nh_having_rights,id',
'practitioner_lastname' => 'required|string',
'practitioner_firstname' => 'nullable|string',
'practitioner_provider_class_id' => 'required|integer',
'care_condition' => 'required|in:CURRENT_AFFECTION,LONG_TERM_AFFECTION,EXONERATION',
'accident_date' => 'nullable|date_format:Y-m-d|before:today',
'pregnancy_start_at' => 'nullable|date_format:Y-m-d|before:today',
'pregnancy_end_at' => 'required_with:pregnancy_start_at|date_format:Y-m-d|after:pregnancy_start_at',
'performances' => 'nullable|array',
'performances.*.act_code' => 'required|string',
'performances.*.amount' => 'required|numeric',
'performances.*.home_visit_fees' => 'nullable|numeric',
'prescriptions' => 'nullable|array',
'prescriptions.*.drug_or_device_id' => 'required|integer|exists:',
'prescriptions.*.dosage' => 'required|string',
'prescriptions.*.quantity' => 'required|integer',
'performances.*.unit_price' => 'required|numeric'
]);
$insurance = NhInsurance::where('insured_id', $request->input('insured_id'))->where('state', InsuranceState::PAID)->first();
if (!isset($insurance)) {
return $this->errorResponse(trans('errors.not_insured'));
}
$agent = AgentPlus::where('network_agent_id', $request->input('network_agent_id'))->first();
if (!checkPassword($request->input('password'), $agent->encrypted_password, $agent->salt))
return $this->errorResponse(trans('messages.incorrect_user_password'));
if ($request->has('beneficiary_id')) {
$beneficiary = $insurance->beneficiaries()->where('nh_having_rights.id', $request->input('beneficiary_id'))->first();
if (!isset($beneficiary)) {
return $this->errorResponse("Ce béneficiaire n'existe pas");
}
}
$nhConfig = NhNetworksConfig::where('network_id', $insurance->network_id)->first();
if (!isset($nhConfig)) {
return $this->errorResponse(trans('errors.nano_health_not_activated'));
}
$insuredPart = 0;
$insurerPart = 0;
switch ($request->input('care_condition')) {
case 'CURRENT_AFFECTION':
$insurerPart = $nhConfig->current_affection_percentage_insurer / 100;
$insuredPart = $nhConfig->current_affection_percentage_insured / 100;
break;
case 'LONG_TERM_AFFECTION':
$insurerPart = $nhConfig->long_term_affection_percentage_insurer / 100;
$insuredPart = $nhConfig->long_term_affection_percentage_insured / 100;
break;
case 'EXONERATION':
$insurerPart = $nhConfig->exoneration_percentage_insurer / 100;
$insuredPart = $nhConfig->exoneration_percentage_insured / 100;
break;
}
try {
DB::beginTransaction();
$datetime = $this->getCurrentTimeByCountryCode($insurance->network->country->code_country);
$healthCareSheet = NhHealthCareSheet::create(array_merge($request->all(), [
'health_care_sheet_id' => $this->generateSheetID(),
'insurance_id' => $insurance->id,
'patient_lastname' => isset($beneficiary) ? $beneficiary->lastname : $insurance->user->lastname,
'patient_firstname' => isset($beneficiary) ? $beneficiary->firstname : $insurance->user->firstname,
'patient_situation' => isset($beneficiary) ? 'HAVING_RIGHT' : 'INSURED',
'state' => InsuranceSubscriptionState::UNDER_VALIDATION
]));
foreach ($request->input('performances', []) as $p) {
$act = NhAct::where('code', $p['code'])->first();
$performance = NhPerformance::create([
'act_id' => $act->id,
'amount' => $p['amount'],
'home_visit_fees' => $p['home_visit_fees'],
'moderator_ticket' => $insuredPart * $p['amount'], // to calculate,
'insurance_amount' => $insurerPart * $p['amount'], // to calculate, montant de l'assurance
'created_at' => $datetime, 'updated_at' => $datetime,
]);
NhHealthCareSheetsPerformance::create([
'sheet_id' => $healthCareSheet->id,
'performance_id' => $performance->id,
'created_at' => $datetime, 'updated_at' => $datetime,
]);
}
foreach ($request->input('prescriptions', []) as $p) {
$amount = $p['unit_price'] * $p['quantity'];
$prescription = NhMedicalPrescription::create(array_merge($p, [
'insured_paid_amount' => $insuredPart * $amount, // to calculate,
'insurer_paid_amount' => $insurerPart * $amount, // to calculate, montant de l'assurance
'created_at' => $datetime, 'updated_at' => $datetime,
]));
NhHealthCareSheetsPrescription::create([
'sheet_id' => $healthCareSheet->id,
'prescription_id' => $prescription->id,
'created_at' => $datetime, 'updated_at' => $datetime,
]);
}
NhHealthCareSheetsHistory::create([
'action' => 'ADD',
'health_care_sheet_id' => $healthCareSheet->health_care_sheet_id,
'state' => $healthCareSheet->state,
'created_at' => $datetime, 'updated_at' => $datetime,
]);
DB::commit();
return $this->successResponse(trans('messages.successful_transaction'));
} catch (Throwable $e) {
Log::error($e->getMessage() . '\n' . $e->getTraceAsString());
DB::rollBack();
return $this->errorResponse(trans('errors.unexpected_error'), 500);
}
}
public function generateSheetID(): string
{
do {
$code = generateTransactionCode();
$codeCorrect = NhHealthCareSheet::where('health_care_sheet_id', $code)->count() < 0;
} while ($codeCorrect);
return $code;
}
}

View File

@ -273,7 +273,7 @@ class InsuranceController extends Controller
$nbOfBeneficiaries = $insurance->beneficiaries()->count(); $nbOfBeneficiaries = $insurance->beneficiaries()->count();
$networkConfig = NhNetworksConfig::where('network_id', $insurance->network_id)->first(); $networkConfig = NhNetworksConfig::where('network_id', $insurance->network_id)->first();
if ((sizeof($request->input('beneficiaries')) + $nbOfBeneficiaries) > $networkConfig->max_number_of_beneficiaries) if ((sizeof($request->input('beneficiaries', [])) + $nbOfBeneficiaries) > $networkConfig->max_number_of_beneficiaries)
return $this->errorResponse(trans('errors.number_of_beneficiaries_exceeded')); return $this->errorResponse(trans('errors.number_of_beneficiaries_exceeded'));
$monthPrice = $networkConfig->monthsPricesGrid()->where('number_of_months', $insurance->number_of_months)->first(); $monthPrice = $networkConfig->monthsPricesGrid()->where('number_of_months', $insurance->number_of_months)->first();
@ -288,7 +288,7 @@ class InsuranceController extends Controller
'network_id' => $insurance->network_id, 'network_id' => $insurance->network_id,
'user_id' => $insurance->user_id, 'user_id' => $insurance->user_id,
'insurance_subscription_id' => $this->generateSubscriptionID(), 'insurance_subscription_id' => $this->generateSubscriptionID(),
'number_of_beneficiaries' => sizeof($request->input('beneficiaries')), 'number_of_beneficiaries' => sizeof($request->input('beneficiaries', [])),
'number_of_months' => $monthPrice->number_of_months, 'number_of_months' => $monthPrice->number_of_months,
'bonus_amount' => $monthPrice->min_amount, 'bonus_amount' => $monthPrice->min_amount,
'insurance_action' => InsuranceAction::ADDITION_OF_BENEFICIARY 'insurance_action' => InsuranceAction::ADDITION_OF_BENEFICIARY

View File

@ -106,7 +106,7 @@ class InsuranceSubscriptionController extends Controller
$networkConfig = $subscription->nhNetworkConfig; $networkConfig = $subscription->nhNetworkConfig;
$monthPrice = $networkConfig->monthsPricesGrid()->where('number_of_months', $subscription->number_of_months)->first(); $monthPrice = $networkConfig->monthsPricesGrid()->where('number_of_months', $subscription->number_of_months)->first();
$beneficiaries = array_merge($subscription->beneficiaries->toArray(), $request->input('beneficiaries')); $beneficiaries = array_merge($subscription->beneficiaries->toArray(), $request->input('beneficiaries', []));
} else { } else {
$networkConfig = NhNetworksConfig::where('network_id', $request->input('network_id'))->first(); $networkConfig = NhNetworksConfig::where('network_id', $request->input('network_id'))->first();
if (!isset($networkConfig) || $networkConfig->configWallet->type != 'ilink_sante') if (!isset($networkConfig) || $networkConfig->configWallet->type != 'ilink_sante')
@ -114,7 +114,7 @@ class InsuranceSubscriptionController extends Controller
$monthPrice = $networkConfig->monthsPricesGrid()->where('id', $request->input('month_price_id'))->first(); $monthPrice = $networkConfig->monthsPricesGrid()->where('id', $request->input('month_price_id'))->first();
$beneficiaries = $request->input('beneficiaries'); $beneficiaries = $request->input('beneficiaries', []);
} }
if (!isset($monthPrice)) if (!isset($monthPrice))
@ -305,7 +305,7 @@ class InsuranceSubscriptionController extends Controller
} }
$networkConfig = NhNetworksConfig::where('network_id', $request->input('network_id'))->first(); $networkConfig = NhNetworksConfig::where('network_id', $request->input('network_id'))->first();
if (sizeof($request->input('beneficiaries')) > $networkConfig->max_number_of_beneficiaries) if (sizeof($request->input('beneficiaries', [])) > $networkConfig->max_number_of_beneficiaries)
return $this->errorResponse(trans('errors.number_of_beneficiaries_exceeded')); return $this->errorResponse(trans('errors.number_of_beneficiaries_exceeded'));
$monthPrice = $networkConfig->monthsPricesGrid()->where('id', $request->input('month_price_id'))->first(); $monthPrice = $networkConfig->monthsPricesGrid()->where('id', $request->input('month_price_id'))->first();
@ -316,7 +316,7 @@ class InsuranceSubscriptionController extends Controller
DB::beginTransaction(); DB::beginTransaction();
$datetime = $this->getCurrentTimeByCountryCode($networkConfig->network->country->code_country); $datetime = $this->getCurrentTimeByCountryCode($networkConfig->network->country->code_country);
$subscription = new NhInsurancesSubscription($request->all()); $subscription = new NhInsurancesSubscription($request->all());
$subscription->number_of_beneficiaries = sizeof($request->input('beneficiaries')); $subscription->number_of_beneficiaries = sizeof($request->input('beneficiaries', []));
$subscription->insurance_subscription_id = $this->generateSubscriptionID(); $subscription->insurance_subscription_id = $this->generateSubscriptionID();
$subscription->number_of_months = $monthPrice->number_of_months; $subscription->number_of_months = $monthPrice->number_of_months;
$subscription->bonus_amount = $monthPrice->min_amount; $subscription->bonus_amount = $monthPrice->min_amount;

View File

@ -24,9 +24,19 @@ class InsuredController extends Controller
/** /**
* @OA\Get( * @OA\Get(
* path="/insured", * path="/insured",
* summary="Rechercher un assuré", * summary="Rechercher un assuré (par reseau , par nom ou par numero de telephone)",
* tags={"Assurés"}, * tags={"Assurés"},
* security={{"api_key":{}}}, * security={{"api_key":{}}},
* @OA\Parameter(
* parameter="network_id",
* name="network_id",
* description="ID du reseau",
* @OA\Schema(
* type="integer"
* ),
* in="query",
* required=true
* ),
* @OA\Parameter( * @OA\Parameter(
* parameter="name", * parameter="name",
* name="name", * name="name",
@ -56,11 +66,8 @@ class InsuredController extends Controller
* "status" : 200, * "status" : 200,
* "response" : {{"id":4,"network_id":250,"user_id":349,"insured_id":"GJKS8ZGBEJTL","number_of_months":3,"bonus_amount":"150000.00", * "response" : {{"id":4,"network_id":250,"user_id":349,"insured_id":"GJKS8ZGBEJTL","number_of_months":3,"bonus_amount":"150000.00",
* "number_of_beneficiaries":2,"total_bonus_amount":"495000.00","start_at":"2021-11-11T21:54:02.000000Z","end_at":"2022-02-11T21:54:02.000000Z", * "number_of_beneficiaries":2,"total_bonus_amount":"495000.00","start_at":"2021-11-11T21:54:02.000000Z","end_at":"2022-02-11T21:54:02.000000Z",
* "state":"PAID","created_at":"2021-11-11T20:54:02.000000Z","updated_at":"2021-11-11T20:54:02.000000Z","user":{"id":349,"uid":"5fcb90ab7197f8.26608831", * "state":"PAID","created_at":"2021-11-11T20:54:02.000000Z","updated_at":"2021-11-11T20:54:02.000000Z","user":{"id":349,
* "firstname":null,"lastname":"Tom Di","phone":"+237690716648","email":"ddoubletom@gmail.com","user_code":"vdVtq7ym9S","numero_carte":null, * "firstname":null,"lastname":"Tom Di","phone":"+237690716648","email":"ddoubletom@gmail.com"},"network":{"id":250,"name":"Cnamgs-pharmacies"}}},
* "expiration_date":null,"adresse":"kotto","solde":0,"salt":"dbbaea33d9","validation_code":"xuty8dbq","active":1,"date_modified":"2020-12-05T14:52:43.000000Z",
* "date_created":"2020-12-05T14:52:43.000000Z","network_id":185,"group_id":null,"balance_credit":0,"balance_epargne":0,"balance_nano_health":11335000,
* "date_adhesion":null,"id_bank_country":null,"iban":null},"network":{"id":250,"name":"Cnamgs-pharmacies"}}},
* "error":null * "error":null
* } * }
* ) * )
@ -71,10 +78,11 @@ class InsuredController extends Controller
{ {
$name = $request->input('name'); $name = $request->input('name');
$phone = $request->input('phone'); $phone = $request->input('phone');
$network_id = $request->input('network_id');
$insured = NhInsurance::with(['user', 'network:id,name'])->whereHas('user', function ($query) use ($name, $phone) { $insured = NhInsurance::with(['user:id,firstname,lastname,phone,email', 'network:id,name', 'beneficiaries'])->whereHas('user', function ($query) use ($name, $phone) {
$query->where('lastname', 'like', '%' . $name . '%')->orWhere('phone', 'like', '%' . $phone . '%'); $query->where('lastname', 'like', '%' . $name . '%')->orWhere('phone', 'like', '%' . $phone . '%');
})->limit(20)->get(); })->where('network_id', $network_id)->get();
return $this->successResponse($insured); return $this->successResponse($insured);
} }

View File

@ -14,6 +14,7 @@ use Illuminate\Database\Eloquent\Model;
* *
* @property int $id * @property int $id
* @property int $nh_network_config_id * @property int $nh_network_config_id
* @property string $code
* @property string $name * @property string $name
* @property string $billing_type * @property string $billing_type
* @property string $authorization_type * @property string $authorization_type
@ -32,6 +33,7 @@ class NhAct extends Model
protected $fillable = [ protected $fillable = [
'nh_network_config_id', 'nh_network_config_id',
'code',
'name', 'name',
'billing_type', 'billing_type',
'authorization_type' 'authorization_type'

View File

@ -0,0 +1,42 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
/**
* Class NhDrugsAndDevice
*
* @property int $id
* @property int $network_id
* @property string $code
* @property string $name
* @property string $type
* @property boolean $on_prescription
* @property Carbon $created_at
* @property Carbon $updated_at
*
* @package App\Models
*/
class NhDrugsAndDevice extends Model
{
protected $table = 'nh_drugs_and_devices';
protected $casts = [
'network_id' => 'int',
'on_prescription' => 'boolean'
];
protected $fillable = [
'network_id',
'code',
'name',
'type',
'on_prescription'
];
}

View File

@ -0,0 +1,41 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
/**
* Class NhHealthCareInstitution
*
* @property int $id
* @property int $network_id
* @property string $code
* @property string $name
* @property string $phone
* @property string $email
* @property Carbon $created_at
* @property Carbon $updated_at
*
* @package App\Models
*/
class NhHealthCareInstitution extends Model
{
protected $table = 'nh_health_care_institutions';
protected $casts = [
'network_id' => 'int'
];
protected $fillable = [
'network_id',
'code',
'name',
'phone',
'email'
];
}

View File

@ -0,0 +1,69 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
/**
* Class NhHealthCareSheet
*
* @property int $id
* @property string $health_care_sheet_id
* @property int $insurance_id
* @property int $network_agent_id
* @property string $patient_lastname
* @property string|null $patient_firstname
* @property string $patient_situation
* @property string $practitioner_lastname
* @property string|null $practitioner_firstname
* @property string|null $practitioner_provider_class_id
* @property string $care_condition
* @property Carbon|null $accident_date
* @property Carbon|null $pregnancy_start_at
* @property Carbon|null $pregnancy_end_at
* @property float $amount
* @property string $state
* @property Carbon $created_at
* @property Carbon $updated_at
*
* @package App\Models
*/
class NhHealthCareSheet extends Model
{
protected $table = 'nh_health_care_sheets';
protected $casts = [
'insurance_id' => 'int',
'network_agent_id' => 'int',
'amount' => 'float'
];
protected $dates = [
'accident_date',
'pregnancy_start_at',
'pregnancy_end_at'
];
protected $fillable = [
'health_care_sheet_id',
'insurance_id',
'network_agent_id',
'patient_lastname',
'patient_firstname',
'patient_situation',
'practitioner_lastname',
'practitioner_firstname',
'practitioner_provider_class_id',
'care_condition',
'accident_date',
'pregnancy_start_at',
'pregnancy_end_at',
'amount',
'state'
];
}

View File

@ -0,0 +1,41 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
/**
* Class NhInsurancesSubscriptionsHistory
*
* @property int $id
* @property string $action
* @property string $health_care_sheet_id
* @property int|null $nh_validating_agent_id
* @property string $state
* @property Carbon $created_at
* @property Carbon $updated_at
*
* @package App\Models
*/
class NhHealthCareSheetsHistory extends Model
{
protected $table = 'nh_health_care_sheets_history';
protected $casts = [
'nh_validating_agent_id' => 'int'
];
protected $fillable = [
'action',
'health_care_sheet_id',
'nh_validating_agent_id',
'state',
'created_at',
'updated_at'
];
}

View File

@ -0,0 +1,38 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
/**
* Class NhHealthCareSheetsPerformance
*
* @property int $id
* @property int $sheet_id
* @property int $performance_id
* @property Carbon $created_at
* @property Carbon $updated_at
*
* @package App\Models
*/
class NhHealthCareSheetsPerformance extends Model
{
protected $table = 'nh_health_care_sheets_performances';
protected $casts = [
'sheet_id' => 'int',
'performance_id' => 'int'
];
protected $fillable = [
'sheet_id',
'performance_id',
'created_at',
'updated_at'
];
}

View File

@ -0,0 +1,36 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
/**
* Class NhHealthCareSheetsPrescription
*
* @property int $id
* @property int $sheet_id
* @property int $prescription_id
* @property Carbon $created_at
* @property Carbon $updated_at
*
* @package App\Models
*/
class NhHealthCareSheetsPrescription extends Model
{
protected $table = 'nh_health_care_sheets_prescriptions';
protected $casts = [
'sheet_id' => 'int',
'prescription_id' => 'int'
];
protected $fillable = [
'sheet_id',
'prescription_id'
];
}

View File

@ -34,6 +34,8 @@ class NhInsurancesPayment extends Model
'insurance_subscription_id', 'insurance_subscription_id',
'insured_id', 'insured_id',
'amount', 'amount',
'reason' 'reason',
'created_at',
'updated_at'
]; ];
} }

View File

@ -37,6 +37,8 @@ class NhInsurancesSubscriptionsHistory extends Model
'insurance_subscription_id', 'insurance_subscription_id',
'agent_id', 'agent_id',
'nh_validating_agent_id', 'nh_validating_agent_id',
'insurance_subscription_state' 'insurance_subscription_state',
'created_at',
'updated_at'
]; ];
} }

View File

@ -0,0 +1,49 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
/**
* Class NhMedicalPrescription
*
* @property int $id
* @property int $drug_or_device_id
* @property string $dosage
* @property int $quantity
* @property float $unit_price
* @property float $insured_paid_amount
* @property float $insurer_paid_amount
* @property Carbon $created_at
* @property Carbon $updated_at
*
* @package App\Models
*/
class NhMedicalPrescription extends Model
{
protected $table = 'nh_medical_prescriptions';
protected $casts = [
'drug_or_device_id' => 'int',
'quantity' => 'int',
'unit_price' => 'float',
'insured_paid_amount' => 'float',
'insurer_paid_amount' => 'float'
];
protected $fillable = [
'drug_or_device_id',
'dosage',
'quantity',
'unit_price',
'insured_paid_amount',
'insurer_paid_amount',
'created_at',
'updated_at'
];
}

View File

@ -0,0 +1,47 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
/**
* Class NhPerformance
*
* @property int $id
* @property int $act_id
* @property float $amount
* @property float $moderator_ticket
* @property float $insurance_amount
* @property float|null $home_visit_fees
* @property Carbon $created_at
* @property Carbon $updated_at
*
* @package App\Models
*/
class NhPerformance extends Model
{
protected $table = 'nh_performances';
protected $casts = [
'act_id' => 'int',
'amount' => 'float',
'moderator_ticket' => 'float',
'insurance_amount' => 'float',
'home_visit_fees' => 'float'
];
protected $fillable = [
'act_id',
'amount',
'moderator_ticket',
'insurance_amount',
'home_visit_fees',
'created_at',
'updated_at'
];
}

View File

@ -124,7 +124,7 @@ trait Helper
$subscription->state = InsuranceSubscriptionState::UNDER_VALIDATION; $subscription->state = InsuranceSubscriptionState::UNDER_VALIDATION;
$beneficiariesBonus = 0; $beneficiariesBonus = 0;
foreach ($request->input('beneficiaries') as $b) { foreach ($request->input('beneficiaries', []) as $b) {
$beneficiary = new NhHavingRight($b); $beneficiary = new NhHavingRight($b);
$beneficiary->bonus_amount = $this->calculateBeneficiaryBonusAmount($beneficiary, $networkConfig->yearsPricesGrid, $monthPrice); $beneficiary->bonus_amount = $this->calculateBeneficiaryBonusAmount($beneficiary, $networkConfig->yearsPricesGrid, $monthPrice);
$beneficiariesBonus += $beneficiary->bonus_amount; $beneficiariesBonus += $beneficiary->bonus_amount;

View File

@ -0,0 +1,46 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateNhHealthCareSheetsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('nh_health_care_sheets', function (Blueprint $table) {
$table->id();
$table->string('health_care_sheet_id')->unique();
$table->integer('insurance_id');
$table->integer('network_agent_id');
$table->string('patient_lastname');
$table->string('patient_firstname')->nullable();
$table->enum('patient_situation', ['INSURED', 'HAVING_RIGHT'])->default('INSURED')->comment('Situation du patient, assuré ou ayant droit');
$table->string('practitioner_lastname');
$table->string('practitioner_firstname')->nullable();
$table->string('practitioner_provider_class_id')->nullable();
$table->enum('care_condition', ['CURRENT_AFFECTION', 'LONG_TERM_AFFECTION', 'EXONERATION'])->default('CURRENT_AFFECTION')->comment('Condition de prise en charge');
$table->date('accident_date')->nullable()->comment("Date de l'accident");
$table->date('pregnancy_start_at')->nullable()->comment("Date debut de la grossesse");
$table->date('pregnancy_end_at')->nullable()->comment("Date de fin de la grossesse ou date accouchement");
$table->enum('state', ['UNDER_VALIDATION', 'ACCEPTED', 'REJECTED'])->default('UNDER_VALIDATION');
$table->timestamp('created_at')->useCurrent();
$table->timestamp('updated_at')->useCurrent();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('nh_health_care_sheets');
}
}

View File

@ -0,0 +1,39 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateNhDrugsAndDevicesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
// Table des medicaments et appareillages
Schema::create('nh_drugs_and_devices', function (Blueprint $table) {
$table->id();
$table->integer('network_id');
$table->string('code');
$table->string('name');
$table->enum('type', ['COMPRESSED', 'SYRUP', 'SOLUTION', 'SUPPOSITORY', 'DEVICE'])->default('COMPRESSED')
->comment(" Type :Comprimé ; sirop ; solution ,supositoire ou appareillage ");
$table->boolean('on_prescription')->default(0)->comment("Sous ordonnance ou pas");
$table->timestamp('created_at')->useCurrent();
$table->timestamp('updated_at')->useCurrent();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('nh_drugs_and_devices');
}
}

View File

@ -0,0 +1,38 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateNhPerformancesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
// Table des prestations de soins
Schema::create('nh_performances', function (Blueprint $table) {
$table->id();
$table->integer('act_id');
$table->decimal('amount', 10, 2)->default(0);
$table->decimal('moderator_ticket', 10, 2)->default(0)->comment("Ticket modérateur (Part assuré)");
$table->decimal('insurance_amount', 10, 2)->default(0)->comment("Montant à payer par assurance");
$table->decimal('home_visit_fees', 10, 2)->nullable()->comment("Frais de visite à domicile");
$table->timestamp('created_at')->useCurrent();
$table->timestamp('updated_at')->useCurrent();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('nh_performances');
}
}

View File

@ -0,0 +1,38 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateNhMedicalPrescriptionsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('nh_medical_prescriptions', function (Blueprint $table) {
$table->id();
$table->integer('drug_or_device_id')->comment("ID du medicaments ou appareillage");
$table->string('dosage')->comment("Posologie");
$table->tinyInteger('quantity');
$table->decimal('unit_price');
$table->decimal('insured_paid_amount')->comment("Part à payer par assuré");
$table->decimal('insurer_paid_amount')->comment("Part à la charge assureur ");
$table->timestamp('created_at')->useCurrent();
$table->timestamp('updated_at')->useCurrent();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('nh_medical_prescriptions');
}
}

View File

@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateNhHealthCareSheetsPerformancesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('nh_health_care_sheets_performances', function (Blueprint $table) {
$table->id();
$table->integer('sheet_id');
$table->integer('performance_id');
$table->timestamp('created_at')->useCurrent();
$table->timestamp('updated_at')->useCurrent();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('nh_health_care_sheets_performances');
}
}

View File

@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateNhHealthCareSheetsPrescriptionsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('nh_health_care_sheets_prescriptions', function (Blueprint $table) {
$table->id();
$table->integer('sheet_id');
$table->integer('prescription_id');
$table->timestamp('created_at')->useCurrent();
$table->timestamp('updated_at')->useCurrent();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('nh_health_care_sheets_prescriptions');
}
}

View File

@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddCodeInNhActsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('nh_acts', function (Blueprint $table) {
$table->string('code')->after('nh_network_config_id');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('nh_acts', function (Blueprint $table) {
$table->dropColumn('code');
});
}
}

View File

@ -0,0 +1,71 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class UpdateAgentPlusView2 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` = `ag`.`nh_provider_class_id`))));");
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}

View File

@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateNhHealthCareSheetsHistory extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('nh_health_care_sheets_history', function (Blueprint $table) {
$table->id();
$table->enum('action', ['ADD', 'EDIT'])->comment("Action effectuée");
$table->string('health_care_sheet_id');
$table->integer('nh_validating_agent_id')->nullable();
$table->string('state');
$table->timestamp('created_at')->useCurrent();
$table->timestamp('updated_at')->useCurrent();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('nh_health_care_sheets_history');
}
}

View File

@ -32,4 +32,5 @@ return [
'subscription_be_already_paid' => "This subscription has already been paid", 'subscription_be_already_paid' => "This subscription has already been paid",
"subscription_cannot_be_submitted" => "Your previous application :state . You cannot submit another one at this time", "subscription_cannot_be_submitted" => "Your previous application :state . You cannot submit another one at this time",
"not_insured" => "You are not insured", "not_insured" => "You are not insured",
'drug_device_already_exists' => "This drug / device code already exists",
]; ];

View File

@ -90,4 +90,5 @@ Your request to add a beneficiary to your insurance is being validated.
- Premium amount: :bonus_amount - Premium amount: :bonus_amount
- Number of beneficiaries : :number_of_beneficiaries - Number of beneficiaries : :number_of_beneficiaries
", ",
'drug_device_saved' => "Drug / Device registered",
]; ];

View File

@ -14,5 +14,10 @@ return [
"ENDED" => 'ENDED', "ENDED" => 'ENDED',
"ADDITION_OF_BENEFICIARY" => "ADDITION OF BENEFICIARY", "ADDITION_OF_BENEFICIARY" => "ADDITION OF BENEFICIARY",
"DELETION_OF_BENEFICIARY" => "DELETION OF BENEFICIARY", "DELETION_OF_BENEFICIARY" => "DELETION OF BENEFICIARY",
"ACTIVATION" => "INSURANCE ACTIVATION" "ACTIVATION" => "INSURANCE ACTIVATION",
"COMPRESSED" => "Compressed",
"SYRUP" => "Syrup",
"SOLUTION" => "Solution",
"SUPPOSITORY" => "Suppository",
"DEVICE" => "Device"
]; ];

View File

@ -32,4 +32,5 @@ return [
'subscription_be_already_paid' => "Cette souscription a déjà été payée", 'subscription_be_already_paid' => "Cette souscription a déjà été payée",
"subscription_cannot_be_submitted" => "Votre demande précédente :state. Vous ne pouvez pas en soumettre une autre pour l'instant", "subscription_cannot_be_submitted" => "Votre demande précédente :state. Vous ne pouvez pas en soumettre une autre pour l'instant",
"not_insured" => "Vous n'êtes pas assuré", "not_insured" => "Vous n'êtes pas assuré",
'drug_device_already_exists' => "Ce code médicament / appareillage existe deja",
]; ];

View File

@ -90,4 +90,5 @@ Votre demande d'ajout d'ayant droit à votre assurance est en cours de validatio
- Montant de la prime : :bonus_amount - Montant de la prime : :bonus_amount
- Nombre d'ayants droit : :number_of_beneficiaries - Nombre d'ayants droit : :number_of_beneficiaries
", ",
'drug_device_saved' => "Médicament / Appareillage enregistré",
]; ];

View File

@ -14,5 +14,10 @@ return [
"ENDED" => 'TERMINÉE', "ENDED" => 'TERMINÉE',
"ADDITION_OF_BENEFICIARY" => "AJOUT D'AYANT DROIT", "ADDITION_OF_BENEFICIARY" => "AJOUT D'AYANT DROIT",
"DELETION_OF_BENEFICIARY" => "SUPPRESSION D'AYANT DROIT", "DELETION_OF_BENEFICIARY" => "SUPPRESSION D'AYANT DROIT",
"ACTIVATION" => "ACTIVATION DE L'ASSURANCE" "ACTIVATION" => "ACTIVATION DE L'ASSURANCE",
"COMPRESSED" => "Comprimé",
"SYRUP" => "Sirop",
"SOLUTION" => "Solution",
"SUPPOSITORY" => "Suppositoire",
"DEVICE" => "Appareillage"
]; ];

View File

@ -37,6 +37,9 @@ $router->group(['prefix' => '', 'middleware' => 'auth'], function () use ($route
$router->get('', 'InsuredController@getInsured'); $router->get('', 'InsuredController@getInsured');
}); });
$router->get('drugs-and-devices', 'HealthCareSheetController@getDrugsAndDevices');
$router->post('drugs-and-devices', 'HealthCareSheetController@storeDrugsAndDevices');
$router->post('health-care-sheets', 'HealthCareSheetController@storeHealthCareSheet');
//QRCode for agents //QRCode for agents
$router->get('qrcode/generate/{id_user}', 'QRCodeController@generate'); $router->get('qrcode/generate/{id_user}', 'QRCodeController@generate');