1313use App \Enums \VictimPerceptionOfTheRiskSchema ;
1414use App \Enums \Violence ;
1515use App \Enums \ViolenceHistorySchema ;
16+ use App \Enums \ViolenceMeans ;
1617use App \Enums \ViolencesTypesSchema ;
18+ use App \Filament \Organizations \Resources \Cases \CaseResource ;
19+ use App \Filament \Schemas \Components \SectionWithRecordActions ;
1720use App \Forms \Components \DatePicker ;
1821use App \Forms \Components \Select ;
22+ use App \Infolists \Components \Actions \EditAction ;
1923use App \Infolists \Components \DateEntry ;
2024use App \Infolists \Components \EnumEntry ;
25+ use App \Models \Beneficiary ;
2126use App \Models \User ;
2227use Filament \Forms \Components \Checkbox ;
2328use Filament \Forms \Components \CheckboxList ;
@@ -68,25 +73,33 @@ public static function getEvaluationDetailsFormComponents(): array
6873 public static function getEvaluationDetailsInfolistComponents (): array
6974 {
7075 return [
71- Group::make ()
72- ->columns ()
73- ->relationship ('evaluateDetails ' )
76+ SectionWithRecordActions::make (__ ('beneficiary.wizard.details.label ' ))
77+ ->headerActions ([
78+ EditAction::make ()
79+ ->url (fn (Beneficiary $ record ): string => CaseResource::getUrl ('edit_initial_evaluation ' , ['record ' => $ record ])),
80+ ])
7481 ->schema ([
75- DateEntry::make ('registered_date ' )
76- ->label (__ ('beneficiary.section.initial_evaluation.labels.registered_date ' )),
77-
78- TextEntry::make ('file_number ' )
79- ->label (__ ('beneficiary.section.initial_evaluation.labels.file_number ' ))
80- ->placeholder (__ ('beneficiary.placeholder.file_number ' )),
81-
82- TextEntry::make ('specialist.full_name ' )
83- ->label (__ ('beneficiary.section.initial_evaluation.labels.specialist ' ))
84- ->placeholder (__ ('beneficiary.placeholder.specialist ' )),
85-
86- TextEntry::make ('method_of_identifying_the_service ' )
87- ->label (__ ('beneficiary.section.initial_evaluation.labels.method_of_identifying_the_service ' ))
88- ->placeholder (__ ('beneficiary.placeholder.method_of_identifying_the_service ' ))
89- ->columnSpanFull (),
82+ Group::make ()
83+ ->columns (2 )
84+ ->relationship ('evaluateDetails ' )
85+ ->schema ([
86+ DateEntry::make ('registered_date ' )
87+ ->label (__ ('beneficiary.section.initial_evaluation.labels.registered_date ' )),
88+
89+ TextEntry::make ('file_number ' )
90+ ->label (__ ('beneficiary.section.initial_evaluation.labels.file_number ' ))
91+ ->placeholder (__ ('beneficiary.placeholder.file_number ' )),
92+
93+ TextEntry::make ('specialist.full_name ' )
94+ ->label (__ ('beneficiary.section.initial_evaluation.labels.specialist ' ))
95+ ->placeholder (__ ('beneficiary.placeholder.specialist ' ))
96+ ->columnSpanFull (),
97+
98+ TextEntry::make ('method_of_identifying_the_service ' )
99+ ->label (__ ('beneficiary.section.initial_evaluation.labels.method_of_identifying_the_service ' ))
100+ ->placeholder (__ ('beneficiary.placeholder.method_of_identifying_the_service ' ))
101+ ->columnSpanFull (),
102+ ]),
90103 ]),
91104 ];
92105 }
@@ -120,11 +133,11 @@ public static function getViolenceFormComponents(): array
120133 Section::make ()
121134 ->relationship ('violence ' )
122135 ->maxWidth ('3xl ' )
123- ->columns ()
136+ ->columns (2 )
124137 ->schema ([
125138 Select::make ('violence_types ' )
126139 ->label (__ ('beneficiary.section.initial_evaluation.labels.violence_type ' ))
127- ->placeholder (__ ('beneficiary.placeholder.violence_type ' ))
140+ ->placeholder (__ ('beneficiary.section.initial_evaluation.placeholders.select_many ' ))
128141 ->options (Violence::options ())
129142 ->multiple ()
130143 ->required (),
@@ -141,6 +154,18 @@ public static function getViolenceFormComponents(): array
141154 ->options (Frequency::options ())
142155 ->required (),
143156
157+ Select::make ('violence_means ' )
158+ ->label (__ ('beneficiary.section.initial_evaluation.labels.violence_means ' ))
159+ ->placeholder (__ ('beneficiary.section.initial_evaluation.placeholders.select_many ' ))
160+ ->options (ViolenceMeans::options ())
161+ ->multiple (),
162+
163+ TextInput::make ('violence_means_specify ' )
164+ ->label (__ ('beneficiary.section.initial_evaluation.labels.violence_means_specify ' ))
165+ ->placeholder (__ ('beneficiary.placeholder.violence_means_specify ' ))
166+ ->maxLength (100 )
167+ ->columnSpanFull (),
168+
144169 RichEditor::make ('description ' )
145170 ->label (__ ('beneficiary.section.initial_evaluation.labels.description ' ))
146171 ->placeholder (__ ('beneficiary.placeholder.description ' ))
@@ -156,7 +181,7 @@ public static function getViolenceInfolistComponents(): array
156181 return [
157182 Group::make ()
158183 ->relationship ('violence ' )
159- ->columns ()
184+ ->columns (2 )
160185 ->schema ([
161186 TextEntry::make ('violence_types ' )
162187 ->label (__ ('beneficiary.section.initial_evaluation.labels.violence_type ' )),
@@ -169,6 +194,15 @@ public static function getViolenceInfolistComponents(): array
169194 ->label (__ ('beneficiary.section.initial_evaluation.labels.frequency_violence ' ))
170195 ->placeholder (__ ('beneficiary.placeholder.frequency_violence ' )),
171196
197+ TextEntry::make ('violence_means ' )
198+ ->label (__ ('beneficiary.section.initial_evaluation.labels.violence_means ' ))
199+ ->placeholder (__ ('beneficiary.placeholder.violence_means_specify ' )),
200+
201+ TextEntry::make ('violence_means_specify ' )
202+ ->label (__ ('beneficiary.section.initial_evaluation.labels.violence_means_specify ' ))
203+ ->placeholder (__ ('beneficiary.placeholder.violence_means_specify ' ))
204+ ->columnSpanFull (),
205+
172206 TextEntry::make ('description ' )
173207 ->label (__ ('beneficiary.section.initial_evaluation.labels.description ' ))
174208 ->placeholder (__ ('beneficiary.placeholder.description ' ))
@@ -240,6 +274,69 @@ public static function getBeneficiarySituationInfolistComponents(): array
240274 ];
241275 }
242276
277+ public static function getRiskFactorsInfolistComponents (): array
278+ {
279+ return [
280+ Group::make ()
281+ ->relationship ('riskFactors ' )
282+ ->schema ([
283+ Section::make (__ ('beneficiary.section.initial_evaluation.heading.violence_history ' ))
284+ ->schema (self ::getInfolistSchemaFromEnum (ViolenceHistorySchema::options ())),
285+ Section::make (__ ('beneficiary.section.initial_evaluation.heading.violences_types ' ))
286+ ->schema (self ::getInfolistSchemaFromEnum (ViolencesTypesSchema::options ())),
287+ Section::make (__ ('beneficiary.section.initial_evaluation.heading.risk_factors ' ))
288+ ->schema (self ::getInfolistSchemaFromEnum (RiskFactorsSchema::options ())),
289+ Section::make (__ ('beneficiary.section.initial_evaluation.heading.victim_perception_of_the_risk ' ))
290+ ->schema (self ::getInfolistSchemaFromEnum (VictimPerceptionOfTheRiskSchema::options ())),
291+ Section::make (__ ('beneficiary.section.initial_evaluation.heading.aggravating_factors ' ))
292+ ->schema (self ::getInfolistSchemaFromEnum (AggravatingFactorsSchema::options ())),
293+ Section::make (__ ('beneficiary.section.initial_evaluation.heading.social_support ' ))
294+ ->columns ()
295+ ->schema (self ::getSocialSupportInfolistSchema ()),
296+ ]),
297+ ];
298+ }
299+
300+ public static function getSocialSupportInfolistSchema (): array
301+ {
302+ return [
303+ TextEntry::make ('extended_family_can_provide ' )
304+ ->label (__ ('beneficiary.section.initial_evaluation.labels.extended_family_can_provide ' ))
305+ ->formatStateUsing (fn ($ record ) => $ record ?->extended_family_can_not_provide
306+ ? $ record ->extended_family_can_not_provide ->label ()
307+ : ($ record ?->extended_family_can_provide
308+ ? $ record ->extended_family_can_provide ->map (fn ($ v ) => $ v ->label ())->implode (', ' )
309+ : null )),
310+
311+ TextEntry::make ('friends_can_provide ' )
312+ ->label (__ ('beneficiary.section.initial_evaluation.labels.friends_can_provide ' ))
313+ ->formatStateUsing (fn ($ record ) => $ record ?->friends_can_not_provide
314+ ? $ record ->friends_can_not_provide ->label ()
315+ : ($ record ?->friends_can_provide
316+ ? $ record ->friends_can_provide ->map (fn ($ v ) => $ v ->label ())->implode (', ' )
317+ : null )),
318+ ];
319+ }
320+
321+ public static function getRequestedServicesInfolistComponents (): array
322+ {
323+ return [
324+ Group::make ()
325+ ->relationship ('requestedServices ' )
326+ ->schema ([
327+ TextEntry::make ('requested_services ' )
328+ ->label (__ ('beneficiary.section.initial_evaluation.heading.types_of_requested_services ' ))
329+ ->formatStateUsing (fn ($ state ) => filled ($ state )
330+ ? collect ($ state )->map (fn ($ v ) => $ v ->label ())->implode (', ' )
331+ : null ),
332+
333+ TextEntry::make ('other_services_description ' )
334+ ->label (__ ('beneficiary.section.initial_evaluation.labels.other_services_description ' ))
335+ ->placeholder (__ ('beneficiary.placeholder.other_services ' )),
336+ ]),
337+ ];
338+ }
339+
243340 public static function getViolenceHistorySchema (): array
244341 {
245342 $ enumOptions = ViolenceHistorySchema::options ();
@@ -364,7 +461,7 @@ public static function getInfolistSchemaFromEnum(array $enumOptions): array
364461
365462 $ result ??= '- ' ;
366463
367- $ description = data_get ($ record ->riskFactors ->risk_factors , "{$ key }.description " );
464+ $ description = data_get ($ record? ->riskFactors? ->risk_factors, "{$ key }.description " );
368465
369466 if (filled ($ description )) {
370467 $ result .= " ( {$ description }) " ;
0 commit comments