Skip to content

Commit

Permalink
add fields in beneficiary personal information
Browse files Browse the repository at this point in the history
  • Loading branch information
alexPopaCode4 committed Jan 8, 2025
1 parent 44318c2 commit bdb7cb8
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use App\Enums\DisabilityDegree;
use App\Enums\DisabilityType;
use App\Enums\Diseases;
use App\Enums\Drug;
use App\Enums\HomeOwnership;
use App\Enums\Income;
use App\Enums\IncomeSource;
Expand Down Expand Up @@ -132,6 +133,22 @@ public static function beneficiarySection(): array
->maxLength(250),
]),

Grid::make()
->schema([
Select::make('drug_consumption')
->label(__('beneficiary.section.personal_information.label.drug_consumption'))
->placeholder(__('placeholder.select_one'))
->options(Ternary::options())
->live(),

Select::make('drug_types')
->label(__('beneficiary.section.personal_information.label.drug_types'))
->placeholder(__('beneficiary.section.personal_information.placeholders.select_drugs'))
->options(Drug::options())
->multiple()
->visible(fn (Get $get) => Ternary::isYes($get('drug_consumption'))),
]),

Grid::make()
->schema([
Select::make('psychiatric_history')
Expand Down Expand Up @@ -197,6 +214,21 @@ public static function beneficiarySection(): array
->visible(fn (Get $get) => Ternary::isYes($get('disabilities'))),
]),

Grid::make()
->schema([
Select::make('other_current_medication')
->label(__('beneficiary.section.personal_information.label.other_current_medication'))
->placeholder(__('placeholder.select_one'))
->options(Ternary::options())
->live(),

TextInput::make('medication_observations')
->label(__('beneficiary.section.personal_information.label.medication_observations'))
->placeholder(__('placeholder.input_text'))
->maxLength(100)
->visible(fn (Get $get) => Ternary::isYes($get('other_current_medication'))),
]),

Grid::make()
->schema([
Select::make('criminal_history')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,16 @@ protected static function beneficiarySection(): array
->visible(fn (Beneficiary $record) => $record->details->health_status?->contains(Diseases::MENTAL_ILLNESSES)),
]),

Grid::make()
->schema([
TextEntry::make('drug_consumption')
->label(__('beneficiary.section.personal_information.label.drug_consumption')),

TextEntry::make('drug_types')
->label(__('beneficiary.section.personal_information.label.drug_types'))
->visible(fn (Beneficiary $record) => Ternary::isYes($record->details->drug_consumption)),
]),

Grid::make()
->schema([
EnumEntry::make('psychiatric_history')
Expand Down Expand Up @@ -179,6 +189,16 @@ protected static function beneficiarySection(): array
->visible(fn (Beneficiary $beneficiary) => Ternary::isYes($beneficiary->details->disabilities)),
]),

Grid::make()
->schema([
TextEntry::make('other_current_medication')
->label(__('beneficiary.section.personal_information.label.other_current_medication')),

TextEntry::make('medication_observations')
->label(__('beneficiary.section.personal_information.label.medication_observations'))
->visible(fn (Beneficiary $beneficiary) => Ternary::isYes($beneficiary->details->other_current_medication)),
]),

Grid::make()
->schema([
EnumEntry::make('current_contraception')
Expand Down
8 changes: 8 additions & 0 deletions app/Models/BeneficiaryDetails.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use App\Enums\DisabilityDegree;
use App\Enums\DisabilityType;
use App\Enums\Diseases;
use App\Enums\Drug;
use App\Enums\HomeOwnership;
use App\Enums\Income;
use App\Enums\IncomeSource;
Expand Down Expand Up @@ -55,6 +56,10 @@ class BeneficiaryDetails extends Model
'current_contraception',
'observations_contraception',
'net_income',
'drug_consumption',
'drug_types',
'other_current_medication',
'medication_observations',
];

protected $casts = [
Expand All @@ -72,5 +77,8 @@ class BeneficiaryDetails extends Model
'type_of_disability' => AsEnumCollection::class . ':' . DisabilityType::class,
'degree_of_disability' => DisabilityDegree::class,
'income_source' => AsEnumCollection::class . ':' . IncomeSource::class,
'drug_consumption' => Ternary::class,
'drug_types' => AsEnumCollection::class . ':' . Drug::class,
'other_current_medication' => Ternary::class,
];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

declare(strict_types=1);

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
public function up(): void
{
Schema::table('beneficiary_details', function (Blueprint $table) {
$table->string('drug_consumption')->nullable();
$table->json('drug_types')->nullable();
$table->string('other_current_medication')->nullable();
$table->string('medication_observations')->nullable();
});
}
};
5 changes: 5 additions & 0 deletions lang/ro/beneficiary.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,14 @@
'degree_of_disability' => 'Încadrare în grad de handicap',
'observations_disability' => 'Observații dizabilitate/ handicap',
'income_source' => 'Sursa venitului',
'drug_consumption' => 'Consum de substanțe beneficiar',
'drug_types' => 'Tip de substanțe consumate',
'other_current_medication' => 'Altă medicație curentă',
'medication_observations' => 'Observații medicație',
],
'placeholders' => [
'select_many' => 'Alege toate variantele care se potrivesc',
'select_drugs' => 'Alege substanțele',
],
],

Expand Down

0 comments on commit bdb7cb8

Please sign in to comment.