Created
May 16, 2023 20:29
PatientConditionesManage.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Livewire; | |
use Filament\Forms; | |
use Filament\Tables; | |
use Livewire\Component; | |
use App\Models\Condition; | |
use App\Models\Encounter; | |
use App\Models\PatientCondition; | |
use Filament\Forms\Components\Select; | |
use Filament\Forms\Components\Textarea; | |
use Filament\Forms\Components\DatePicker; | |
use Illuminate\Database\Eloquent\Builder; | |
class PatientConditionsManage extends Component implements Tables\Contracts\HasTable | |
{ | |
use Tables\Concerns\InteractsWithTable; | |
public $encounter_id; | |
protected Encounter $encounter; | |
public function mount($encounter_id): void | |
{ | |
$this->encounter = Encounter::find($encounter_id); | |
$this->encounter_id = $encounter_id; | |
} | |
protected function getFormSchema(): array | |
{ | |
return [ | |
Select::make('type') | |
->label('Tipo') | |
->options([ | |
'personal_condition' => 'Condición personal', | |
'familiar_condition' => 'Condición familiar', | |
'procedure' => 'Procedimiento' | |
]), | |
Select::make('condition_id') | |
->label('Condición') | |
->getSearchResultsUsing(fn ($search) => Condition::where('name', 'like', '%' . $search . '%')->get()), | |
Select::make('clinical_status') | |
->label('Estado clínico') | |
->options([ | |
'active' => 'Activo', | |
'recurrence' => 'Recurrencia', | |
'relapse' => 'Recaída', | |
'inactive' => 'Inactivo', | |
'remission' => 'Remisión', | |
'resolved' => 'Resuelto', | |
'unknown' => 'Desconocido' | |
]), | |
DatePicker::make('onset_date') | |
->label('Fecha de inicio'), | |
DatePicker::make('abatement_date') | |
->label('Fecha de finalización'), | |
Textarea::make('note') | |
->label('Nota'), | |
]; | |
} | |
protected function getTableQuery(): Builder | |
{ | |
return PatientCondition::where('patient_id', Encounter::find($this->encounter_id)->patient_id); | |
} | |
protected function getTableColumns(): array | |
{ | |
return []; | |
} | |
protected function getTableFilters(): array | |
{ | |
return []; | |
} | |
protected function getTableHeaderActions(): array | |
{ | |
return [ | |
Tables\Actions\CreateAction::make(), | |
]; | |
} | |
protected function getTableActions(): array | |
{ | |
return [ | |
Tables\Actions\EditAction::make(), | |
]; | |
} | |
public function render() | |
{ | |
return view('livewire.patient-conditions-manage'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment