From bdb7cb83d58a37bec590a2bb92ee10e1bcf48372 Mon Sep 17 00:00:00 2001 From: Alex Popa Date: Wed, 8 Jan 2025 17:16:20 +0200 Subject: [PATCH] add fields in beneficiary personal information --- .../EditBeneficiaryPersonalInformation.php | 32 +++++++++++++++++++ .../ViewBeneficiaryPersonalInformation.php | 20 ++++++++++++ app/Models/BeneficiaryDetails.php | 8 +++++ ...dd_fields_in_beneficiary_details_table.php | 20 ++++++++++++ lang/ro/beneficiary.php | 5 +++ 5 files changed, 85 insertions(+) create mode 100644 database/migrations/2025_01_08_144541_add_fields_in_beneficiary_details_table.php diff --git a/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/EditBeneficiaryPersonalInformation.php b/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/EditBeneficiaryPersonalInformation.php index 2648d8ba..c3b867bb 100644 --- a/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/EditBeneficiaryPersonalInformation.php +++ b/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/EditBeneficiaryPersonalInformation.php @@ -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; @@ -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') @@ -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') diff --git a/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/ViewBeneficiaryPersonalInformation.php b/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/ViewBeneficiaryPersonalInformation.php index 00bb1c46..1aa3cddb 100644 --- a/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/ViewBeneficiaryPersonalInformation.php +++ b/app/Filament/Organizations/Resources/BeneficiaryResource/Pages/ViewBeneficiaryPersonalInformation.php @@ -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') @@ -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') diff --git a/app/Models/BeneficiaryDetails.php b/app/Models/BeneficiaryDetails.php index 57c312c3..e5ed716e 100644 --- a/app/Models/BeneficiaryDetails.php +++ b/app/Models/BeneficiaryDetails.php @@ -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; @@ -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 = [ @@ -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, ]; } diff --git a/database/migrations/2025_01_08_144541_add_fields_in_beneficiary_details_table.php b/database/migrations/2025_01_08_144541_add_fields_in_beneficiary_details_table.php new file mode 100644 index 00000000..70fb1522 --- /dev/null +++ b/database/migrations/2025_01_08_144541_add_fields_in_beneficiary_details_table.php @@ -0,0 +1,20 @@ +string('drug_consumption')->nullable(); + $table->json('drug_types')->nullable(); + $table->string('other_current_medication')->nullable(); + $table->string('medication_observations')->nullable(); + }); + } +}; diff --git a/lang/ro/beneficiary.php b/lang/ro/beneficiary.php index 23d589c3..6e9307a7 100644 --- a/lang/ro/beneficiary.php +++ b/lang/ro/beneficiary.php @@ -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', ], ],