From 456208661bbe67c10dd2b5c49c0cf0987ae03bfa Mon Sep 17 00:00:00 2001 From: Djery-Tom Date: Fri, 19 Nov 2021 17:07:42 +0100 Subject: [PATCH] Begin health care sheet store --- .../Controllers/HealthCareSheetController.php | 300 ++++++++++++++++++ app/Http/Controllers/InsuranceController.php | 4 +- .../InsuranceSubscriptionController.php | 8 +- app/Http/Controllers/InsuredController.php | 24 +- app/Models/NhAct.php | 2 + app/Models/NhDrugsAndDevice.php | 42 +++ app/Models/NhHealthCareInstitution.php | 41 +++ app/Models/NhHealthCareSheet.php | 69 ++++ app/Models/NhHealthCareSheetsHistory.php | 41 +++ app/Models/NhHealthCareSheetsPerformance.php | 38 +++ app/Models/NhHealthCareSheetsPrescription.php | 36 +++ app/Models/NhInsurancesPayment.php | 4 +- .../NhInsurancesSubscriptionsHistory.php | 4 +- app/Models/NhMedicalPrescription.php | 49 +++ app/Models/NhPerformance.php | 47 +++ app/Traits/Helper.php | 2 +- ...454_create_nh_health_care_sheets_table.php | 46 +++ ...1216_create_nh_drugs_and_devices_table.php | 39 +++ ...17_074340_create_nh_performances_table.php | 38 +++ ..._create_nh_medical_prescriptions_table.php | 38 +++ ..._health_care_sheets_performances_table.php | 34 ++ ...health_care_sheets_prescriptions_table.php | 34 ++ ...11_17_112620_add_code_in_nh_acts_table.php | 32 ++ ...1_11_18_161542_update_agent_plus_view2.php | 71 +++++ ...4_create_nh_health_care_sheets_history.php | 36 +++ resources/lang/en/errors.php | 1 + resources/lang/en/messages.php | 1 + resources/lang/en/states.php | 7 +- resources/lang/fr/errors.php | 1 + resources/lang/fr/messages.php | 1 + resources/lang/fr/states.php | 7 +- routes/web.php | 3 + 32 files changed, 1081 insertions(+), 19 deletions(-) create mode 100755 app/Http/Controllers/HealthCareSheetController.php create mode 100644 app/Models/NhDrugsAndDevice.php create mode 100644 app/Models/NhHealthCareInstitution.php create mode 100644 app/Models/NhHealthCareSheet.php create mode 100644 app/Models/NhHealthCareSheetsHistory.php create mode 100644 app/Models/NhHealthCareSheetsPerformance.php create mode 100644 app/Models/NhHealthCareSheetsPrescription.php create mode 100644 app/Models/NhMedicalPrescription.php create mode 100644 app/Models/NhPerformance.php create mode 100644 database/migrations/2021_11_16_064454_create_nh_health_care_sheets_table.php create mode 100644 database/migrations/2021_11_16_071216_create_nh_drugs_and_devices_table.php create mode 100644 database/migrations/2021_11_17_074340_create_nh_performances_table.php create mode 100644 database/migrations/2021_11_17_082212_create_nh_medical_prescriptions_table.php create mode 100644 database/migrations/2021_11_17_112317_create_nh_health_care_sheets_performances_table.php create mode 100644 database/migrations/2021_11_17_112554_create_nh_health_care_sheets_prescriptions_table.php create mode 100644 database/migrations/2021_11_17_112620_add_code_in_nh_acts_table.php create mode 100644 database/migrations/2021_11_18_161542_update_agent_plus_view2.php create mode 100644 database/migrations/2021_11_19_034014_create_nh_health_care_sheets_history.php diff --git a/app/Http/Controllers/HealthCareSheetController.php b/app/Http/Controllers/HealthCareSheetController.php new file mode 100755 index 0000000..2b81b0e --- /dev/null +++ b/app/Http/Controllers/HealthCareSheetController.php @@ -0,0 +1,300 @@ +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; + } +} diff --git a/app/Http/Controllers/InsuranceController.php b/app/Http/Controllers/InsuranceController.php index 06b59e1..d572cc0 100644 --- a/app/Http/Controllers/InsuranceController.php +++ b/app/Http/Controllers/InsuranceController.php @@ -273,7 +273,7 @@ class InsuranceController extends Controller $nbOfBeneficiaries = $insurance->beneficiaries()->count(); $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')); $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, 'user_id' => $insurance->user_id, '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, 'bonus_amount' => $monthPrice->min_amount, 'insurance_action' => InsuranceAction::ADDITION_OF_BENEFICIARY diff --git a/app/Http/Controllers/InsuranceSubscriptionController.php b/app/Http/Controllers/InsuranceSubscriptionController.php index f67d2cf..a19ce62 100644 --- a/app/Http/Controllers/InsuranceSubscriptionController.php +++ b/app/Http/Controllers/InsuranceSubscriptionController.php @@ -106,7 +106,7 @@ class InsuranceSubscriptionController extends Controller $networkConfig = $subscription->nhNetworkConfig; $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 { $networkConfig = NhNetworksConfig::where('network_id', $request->input('network_id'))->first(); 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(); - $beneficiaries = $request->input('beneficiaries'); + $beneficiaries = $request->input('beneficiaries', []); } if (!isset($monthPrice)) @@ -305,7 +305,7 @@ class InsuranceSubscriptionController extends Controller } $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')); $monthPrice = $networkConfig->monthsPricesGrid()->where('id', $request->input('month_price_id'))->first(); @@ -316,7 +316,7 @@ class InsuranceSubscriptionController extends Controller DB::beginTransaction(); $datetime = $this->getCurrentTimeByCountryCode($networkConfig->network->country->code_country); $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->number_of_months = $monthPrice->number_of_months; $subscription->bonus_amount = $monthPrice->min_amount; diff --git a/app/Http/Controllers/InsuredController.php b/app/Http/Controllers/InsuredController.php index d70e0a4..81187bd 100755 --- a/app/Http/Controllers/InsuredController.php +++ b/app/Http/Controllers/InsuredController.php @@ -24,9 +24,19 @@ class InsuredController extends Controller /** * @OA\Get( * path="/insured", - * summary="Rechercher un assuré", + * summary="Rechercher un assuré (par reseau , par nom ou par numero de telephone)", * tags={"Assurés"}, * 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", @@ -56,11 +66,8 @@ class InsuredController extends Controller * "status" : 200, * "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", - * "state":"PAID","created_at":"2021-11-11T20:54:02.000000Z","updated_at":"2021-11-11T20:54:02.000000Z","user":{"id":349,"uid":"5fcb90ab7197f8.26608831", - * "firstname":null,"lastname":"Tom Di","phone":"+237690716648","email":"ddoubletom@gmail.com","user_code":"vdVtq7ym9S","numero_carte":null, - * "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"}}}, + * "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"},"network":{"id":250,"name":"Cnamgs-pharmacies"}}}, * "error":null * } * ) @@ -71,10 +78,11 @@ class InsuredController extends Controller { $name = $request->input('name'); $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 . '%'); - })->limit(20)->get(); + })->where('network_id', $network_id)->get(); return $this->successResponse($insured); } diff --git a/app/Models/NhAct.php b/app/Models/NhAct.php index 3e35c7a..e235417 100644 --- a/app/Models/NhAct.php +++ b/app/Models/NhAct.php @@ -14,6 +14,7 @@ use Illuminate\Database\Eloquent\Model; * * @property int $id * @property int $nh_network_config_id + * @property string $code * @property string $name * @property string $billing_type * @property string $authorization_type @@ -32,6 +33,7 @@ class NhAct extends Model protected $fillable = [ 'nh_network_config_id', + 'code', 'name', 'billing_type', 'authorization_type' diff --git a/app/Models/NhDrugsAndDevice.php b/app/Models/NhDrugsAndDevice.php new file mode 100644 index 0000000..f095ea0 --- /dev/null +++ b/app/Models/NhDrugsAndDevice.php @@ -0,0 +1,42 @@ + 'int', + 'on_prescription' => 'boolean' + ]; + + protected $fillable = [ + 'network_id', + 'code', + 'name', + 'type', + 'on_prescription' + ]; +} diff --git a/app/Models/NhHealthCareInstitution.php b/app/Models/NhHealthCareInstitution.php new file mode 100644 index 0000000..4bcd6bd --- /dev/null +++ b/app/Models/NhHealthCareInstitution.php @@ -0,0 +1,41 @@ + 'int' + ]; + + protected $fillable = [ + 'network_id', + 'code', + 'name', + 'phone', + 'email' + ]; +} diff --git a/app/Models/NhHealthCareSheet.php b/app/Models/NhHealthCareSheet.php new file mode 100644 index 0000000..fd9a3e1 --- /dev/null +++ b/app/Models/NhHealthCareSheet.php @@ -0,0 +1,69 @@ + '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' + ]; +} diff --git a/app/Models/NhHealthCareSheetsHistory.php b/app/Models/NhHealthCareSheetsHistory.php new file mode 100644 index 0000000..736f5ee --- /dev/null +++ b/app/Models/NhHealthCareSheetsHistory.php @@ -0,0 +1,41 @@ + 'int' + ]; + + protected $fillable = [ + 'action', + 'health_care_sheet_id', + 'nh_validating_agent_id', + 'state', + 'created_at', + 'updated_at' + ]; +} diff --git a/app/Models/NhHealthCareSheetsPerformance.php b/app/Models/NhHealthCareSheetsPerformance.php new file mode 100644 index 0000000..36b6d70 --- /dev/null +++ b/app/Models/NhHealthCareSheetsPerformance.php @@ -0,0 +1,38 @@ + 'int', + 'performance_id' => 'int' + ]; + + protected $fillable = [ + 'sheet_id', + 'performance_id', + 'created_at', + 'updated_at' + ]; +} diff --git a/app/Models/NhHealthCareSheetsPrescription.php b/app/Models/NhHealthCareSheetsPrescription.php new file mode 100644 index 0000000..46de0bf --- /dev/null +++ b/app/Models/NhHealthCareSheetsPrescription.php @@ -0,0 +1,36 @@ + 'int', + 'prescription_id' => 'int' + ]; + + protected $fillable = [ + 'sheet_id', + 'prescription_id' + ]; +} diff --git a/app/Models/NhInsurancesPayment.php b/app/Models/NhInsurancesPayment.php index da53ee7..7264167 100644 --- a/app/Models/NhInsurancesPayment.php +++ b/app/Models/NhInsurancesPayment.php @@ -34,6 +34,8 @@ class NhInsurancesPayment extends Model 'insurance_subscription_id', 'insured_id', 'amount', - 'reason' + 'reason', + 'created_at', + 'updated_at' ]; } diff --git a/app/Models/NhInsurancesSubscriptionsHistory.php b/app/Models/NhInsurancesSubscriptionsHistory.php index db19778..4b29923 100644 --- a/app/Models/NhInsurancesSubscriptionsHistory.php +++ b/app/Models/NhInsurancesSubscriptionsHistory.php @@ -37,6 +37,8 @@ class NhInsurancesSubscriptionsHistory extends Model 'insurance_subscription_id', 'agent_id', 'nh_validating_agent_id', - 'insurance_subscription_state' + 'insurance_subscription_state', + 'created_at', + 'updated_at' ]; } diff --git a/app/Models/NhMedicalPrescription.php b/app/Models/NhMedicalPrescription.php new file mode 100644 index 0000000..31e2016 --- /dev/null +++ b/app/Models/NhMedicalPrescription.php @@ -0,0 +1,49 @@ + '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' + ]; +} diff --git a/app/Models/NhPerformance.php b/app/Models/NhPerformance.php new file mode 100644 index 0000000..7d124eb --- /dev/null +++ b/app/Models/NhPerformance.php @@ -0,0 +1,47 @@ + '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' + ]; +} diff --git a/app/Traits/Helper.php b/app/Traits/Helper.php index 7ec2656..6067b3c 100644 --- a/app/Traits/Helper.php +++ b/app/Traits/Helper.php @@ -124,7 +124,7 @@ trait Helper $subscription->state = InsuranceSubscriptionState::UNDER_VALIDATION; $beneficiariesBonus = 0; - foreach ($request->input('beneficiaries') as $b) { + foreach ($request->input('beneficiaries', []) as $b) { $beneficiary = new NhHavingRight($b); $beneficiary->bonus_amount = $this->calculateBeneficiaryBonusAmount($beneficiary, $networkConfig->yearsPricesGrid, $monthPrice); $beneficiariesBonus += $beneficiary->bonus_amount; diff --git a/database/migrations/2021_11_16_064454_create_nh_health_care_sheets_table.php b/database/migrations/2021_11_16_064454_create_nh_health_care_sheets_table.php new file mode 100644 index 0000000..2865e35 --- /dev/null +++ b/database/migrations/2021_11_16_064454_create_nh_health_care_sheets_table.php @@ -0,0 +1,46 @@ +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'); + } +} diff --git a/database/migrations/2021_11_16_071216_create_nh_drugs_and_devices_table.php b/database/migrations/2021_11_16_071216_create_nh_drugs_and_devices_table.php new file mode 100644 index 0000000..88b182c --- /dev/null +++ b/database/migrations/2021_11_16_071216_create_nh_drugs_and_devices_table.php @@ -0,0 +1,39 @@ +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'); + } +} diff --git a/database/migrations/2021_11_17_074340_create_nh_performances_table.php b/database/migrations/2021_11_17_074340_create_nh_performances_table.php new file mode 100644 index 0000000..4b2bf78 --- /dev/null +++ b/database/migrations/2021_11_17_074340_create_nh_performances_table.php @@ -0,0 +1,38 @@ +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'); + } +} diff --git a/database/migrations/2021_11_17_082212_create_nh_medical_prescriptions_table.php b/database/migrations/2021_11_17_082212_create_nh_medical_prescriptions_table.php new file mode 100644 index 0000000..336e055 --- /dev/null +++ b/database/migrations/2021_11_17_082212_create_nh_medical_prescriptions_table.php @@ -0,0 +1,38 @@ +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'); + } +} diff --git a/database/migrations/2021_11_17_112317_create_nh_health_care_sheets_performances_table.php b/database/migrations/2021_11_17_112317_create_nh_health_care_sheets_performances_table.php new file mode 100644 index 0000000..5dbd404 --- /dev/null +++ b/database/migrations/2021_11_17_112317_create_nh_health_care_sheets_performances_table.php @@ -0,0 +1,34 @@ +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'); + } +} diff --git a/database/migrations/2021_11_17_112554_create_nh_health_care_sheets_prescriptions_table.php b/database/migrations/2021_11_17_112554_create_nh_health_care_sheets_prescriptions_table.php new file mode 100644 index 0000000..b5a66d0 --- /dev/null +++ b/database/migrations/2021_11_17_112554_create_nh_health_care_sheets_prescriptions_table.php @@ -0,0 +1,34 @@ +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'); + } +} diff --git a/database/migrations/2021_11_17_112620_add_code_in_nh_acts_table.php b/database/migrations/2021_11_17_112620_add_code_in_nh_acts_table.php new file mode 100644 index 0000000..b1fb3d9 --- /dev/null +++ b/database/migrations/2021_11_17_112620_add_code_in_nh_acts_table.php @@ -0,0 +1,32 @@ +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'); + }); + } +} diff --git a/database/migrations/2021_11_18_161542_update_agent_plus_view2.php b/database/migrations/2021_11_18_161542_update_agent_plus_view2.php new file mode 100644 index 0000000..93a0942 --- /dev/null +++ b/database/migrations/2021_11_18_161542_update_agent_plus_view2.php @@ -0,0 +1,71 @@ +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'); + } +} diff --git a/resources/lang/en/errors.php b/resources/lang/en/errors.php index c9cfd51..5b66a3b 100755 --- a/resources/lang/en/errors.php +++ b/resources/lang/en/errors.php @@ -32,4 +32,5 @@ return [ '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", "not_insured" => "You are not insured", + 'drug_device_already_exists' => "This drug / device code already exists", ]; diff --git a/resources/lang/en/messages.php b/resources/lang/en/messages.php index 7f5aa8c..65448ec 100755 --- a/resources/lang/en/messages.php +++ b/resources/lang/en/messages.php @@ -90,4 +90,5 @@ Your request to add a beneficiary to your insurance is being validated. - Premium amount: :bonus_amount - Number of beneficiaries : :number_of_beneficiaries ", + 'drug_device_saved' => "Drug / Device registered", ]; diff --git a/resources/lang/en/states.php b/resources/lang/en/states.php index 9451317..e7001e3 100755 --- a/resources/lang/en/states.php +++ b/resources/lang/en/states.php @@ -14,5 +14,10 @@ return [ "ENDED" => 'ENDED', "ADDITION_OF_BENEFICIARY" => "ADDITION OF BENEFICIARY", "DELETION_OF_BENEFICIARY" => "DELETION OF BENEFICIARY", - "ACTIVATION" => "INSURANCE ACTIVATION" + "ACTIVATION" => "INSURANCE ACTIVATION", + "COMPRESSED" => "Compressed", + "SYRUP" => "Syrup", + "SOLUTION" => "Solution", + "SUPPOSITORY" => "Suppository", + "DEVICE" => "Device" ]; diff --git a/resources/lang/fr/errors.php b/resources/lang/fr/errors.php index 8b5ff26..32a0812 100755 --- a/resources/lang/fr/errors.php +++ b/resources/lang/fr/errors.php @@ -32,4 +32,5 @@ return [ '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", "not_insured" => "Vous n'êtes pas assuré", + 'drug_device_already_exists' => "Ce code médicament / appareillage existe deja", ]; diff --git a/resources/lang/fr/messages.php b/resources/lang/fr/messages.php index 449db4c..b6aaa0f 100755 --- a/resources/lang/fr/messages.php +++ b/resources/lang/fr/messages.php @@ -90,4 +90,5 @@ Votre demande d'ajout d'ayant droit à votre assurance est en cours de validatio - Montant de la prime : :bonus_amount - Nombre d'ayants droit : :number_of_beneficiaries ", + 'drug_device_saved' => "Médicament / Appareillage enregistré", ]; diff --git a/resources/lang/fr/states.php b/resources/lang/fr/states.php index a68b6d7..80c4d27 100755 --- a/resources/lang/fr/states.php +++ b/resources/lang/fr/states.php @@ -14,5 +14,10 @@ return [ "ENDED" => 'TERMINÉE', "ADDITION_OF_BENEFICIARY" => "AJOUT 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" ]; diff --git a/routes/web.php b/routes/web.php index ff17b55..25b34a9 100644 --- a/routes/web.php +++ b/routes/web.php @@ -37,6 +37,9 @@ $router->group(['prefix' => '', 'middleware' => 'auth'], function () use ($route $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 $router->get('qrcode/generate/{id_user}', 'QRCodeController@generate');