Skip to content

Commit

Permalink
Merge branch 'main' into feat/reports
Browse files Browse the repository at this point in the history
  • Loading branch information
andreiio committed Oct 1, 2024
2 parents ce2cf63 + 34a5062 commit c1417b9
Show file tree
Hide file tree
Showing 39 changed files with 1,082 additions and 798 deletions.
28 changes: 14 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ RUN npm run build

FROM vendor

ARG S6_OVERLAY_VERSION=3.1.6.2
ARG S6_OVERLAY_VERSION=3.2.0.0

ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-noarch.tar.xz /tmp
RUN tar -C / -Jxpf /tmp/s6-overlay-noarch.tar.xz
Expand All @@ -77,30 +77,30 @@ ARG REVISION

RUN echo "$VERSION (${REVISION:0:7})" > /var/www/.version

ENV APP_ENV production
ENV APP_DEBUG false
ENV LOG_CHANNEL stderr
ENV CACHE_DRIVER database
ENV QUEUE_CONNECTION database
ENV SESSION_DRIVER database
ENV APP_ENV=production
ENV APP_DEBUG=false
ENV LOG_CHANNEL=stderr
ENV CACHE_DRIVER=database
ENV QUEUE_CONNECTION=database
ENV SESSION_DRIVER=database

# The number of jobs to process before stopping
ENV WORKER_MAX_JOBS 50
ENV WORKER_MAX_JOBS=50

# Number of seconds to sleep when no job is available
ENV WORKER_SLEEP 30
ENV WORKER_SLEEP=30

# Number of seconds to rest between jobs
ENV WORKER_REST 1
ENV WORKER_REST=1

# The number of seconds a child process can run
ENV WORKER_TIMEOUT 600
ENV WORKER_TIMEOUT=600

# Number of times to attempt a job before logging it failed
ENV WORKER_TRIES 3
ENV WORKER_TRIES=3

ENV S6_CMD_WAIT_FOR_SERVICES_MAXTIME 0
ENV SENTRY_SAMPLE_RATE=0

ENV SENTRY_SAMPLE_RATE 0
ENV PHP_PM_MAX_CHILDREN=64

EXPOSE 80
1 change: 1 addition & 0 deletions app/Enums/Beneficiary/Ethnicity.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ enum Ethnicity: string

case ROMANIAN = 'romanian';
case HUNGARIAN = 'hungarian';
case ROMA = 'roma';
case UKRAINIAN = 'ukrainian';
case GERMAN = 'german';
case LIPOVAN = 'lipovan';
Expand Down
25 changes: 25 additions & 0 deletions app/Enums/Beneficiary/ReasonRemoved.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

declare(strict_types=1);

namespace App\Enums\Beneficiary;

use App\Concerns;

enum ReasonRemoved: string
{
use Concerns\Enums\Arrayable;
use Concerns\Enums\Comparable;
use Concerns\Enums\HasLabel;

case DECEASED_HOME = 'deceased_home';
case DECEASED_HOSPITAL = 'deceased_hospital';
case RELOCATED_CITY = 'relocated_city';
case RELOCATED_ABROAD = 'relocated_abroad';
case OTHER = 'other';

protected function labelKeyPrefix(): ?string
{
return 'beneficiary.reason_removed';
}
}
2 changes: 2 additions & 0 deletions app/Enums/CommunityActivity/Campaign.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ enum Campaign: string
case LOCAL = 'local';
case ACTIVITY = 'activity';
case INTERVENTION = 'intervention';
case SCREENING = 'screening';
case EPIDEM_TRIAGE = 'epidem_triage';

protected function labelKeyPrefix(): ?string
{
Expand Down
1 change: 1 addition & 0 deletions app/Enums/Intervention/CaseInitiator.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ enum CaseInitiator: string

case NURSE = 'nurse';
case GP = 'gp';
case SPECIALIST = 'specialist';
case TEAM = 'team';
case DPH = 'dph';
case OTHER = 'other';
Expand Down
3 changes: 3 additions & 0 deletions app/Enums/VacationType.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ enum VacationType: string
case MEDICAL = 'medical';
case REST = 'rest';
case CHILD = 'child';
case special = 'special';
case BLOOD_DONATION = 'blood_donation';
case OTHER = 'other';

protected function labelKeyPrefix(): ?string
{
Expand Down
5 changes: 2 additions & 3 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace App\Exceptions;

use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Sentry\Laravel\Integration;
use Throwable;

class Handler extends ExceptionHandler
Expand Down Expand Up @@ -46,9 +47,7 @@ class Handler extends ExceptionHandler
public function register()
{
$this->reportable(function (Throwable $e) {
if (app()->bound('sentry')) {
app('sentry')->captureException($e);
}
Integration::captureUnhandledException($e);
});
}
}
38 changes: 34 additions & 4 deletions app/Filament/Forms/Components/BeneficiaryProgram.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@

namespace App\Filament\Forms\Components;

use App\Enums\Beneficiary\ReasonRemoved;
use App\Enums\Beneficiary\Status;
use App\Models\Beneficiary;
use App\Models\User;
use Filament\Forms\Components\Grid;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Illuminate\Contracts\Database\Eloquent\Builder;
Expand Down Expand Up @@ -42,6 +44,23 @@ protected function getViewComponents(): array
Value::make('status')
->label(__('field.current_status')),

Value::make('reason_removed')
->visible(fn (callable $get) => Status::REMOVED->is($get('status')))
->label(__('field.reason_removed'))
->content(function (Beneficiary $record) {
$parts = [];

if ($record->reason_removed instanceof ReasonRemoved) {
$parts[] = $record->reason_removed->label();
}

if (filled($record->reason_removed_notes)) {
$parts[] = "({$record->reason_removed_notes})";
}

return implode(' ', $parts);
}),

Value::make('nurse')
->label(__('field.allocated_nurse'))
->content(fn (Beneficiary $record) => "#{$record->nurse->id} {$record->nurse->full_name}"),
Expand Down Expand Up @@ -87,11 +106,22 @@ protected function getEditComponents(): array
->reactive()
->required(),

TextInput::make('reason_removed')
->label(__('field.reason_removed'))
Grid::make('status_reason')
->columns()
->visible(fn (callable $get) => Status::REMOVED->is($get('status')))
->maxLength(200)
->required(),
->schema([
Select::make('reason_removed')
->label(__('field.reason_removed'))
->placeholder(__('placeholder.choose'))
->options(ReasonRemoved::options())
->reactive()
->required(),

TextInput::make('reason_removed_notes')
->label(__('field.reason_removed_notes'))
->maxLength(200)
->required(fn (callable $get) => ReasonRemoved::OTHER->is($get('reason_removed'))),
]),

];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ViewAppointment extends ViewRecord
protected function getTitle(): string
{
return __('appointment.header.view', [
'beneficiary' => $this->getRecord()->beneficiary->full_name,
'beneficiary' => $this->getRecord()->beneficiary?->full_name,
'date' => $this->getRecord()->date->toFormattedDate(),
'start_time' => $this->getRecord()->start_time,
]);
Expand Down
7 changes: 7 additions & 0 deletions app/Filament/Resources/CatagraphyResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ public static function form(Form $form): Form
->label(__('field.evaluation_date'))
->required(),

Checkbox::make('is_social_case')
->label($categories->get('SOC'))
->columnSpanFull(),
]),

Subsection::make()
Expand Down Expand Up @@ -226,6 +229,10 @@ public static function form(Form $form): Form
->multiple()
->searchable(),

Checkbox::make('is_vaccinated_on_schedule')
->label($categories->get('VCC'))
->columnSpanFull(),

Select::make('cat_ssa')
->label($categories->get('SSA'))
->placeholder(__('placeholder.select_many'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ protected function form(Form $form): Form
->schema([
Value::make('evaluation_date')
->label(__('field.evaluation_date')),

VulnerabilityChips::make('cat_soc')
->label($categories->get('SOC'))
->columnSpanFull(),
]),

Subsection::make()
Expand Down Expand Up @@ -119,6 +123,10 @@ protected function form(Form $form): Form
VulnerabilityChips::make('cat_ns')
->label($categories->get('NS')),

VulnerabilityChips::make('cat_vcc')
->label($categories->get('VCC'))
->columnSpanFull(),

VulnerabilityChips::make('cat_ssa')
->label($categories->get('SSA')),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function mount(...$args): void

public function getTitle(): string
{
return sprintf(
return \sprintf(
'%s: %s',
$this->getRecord()->type,
$this->getRecord()->name
Expand Down Expand Up @@ -158,15 +158,15 @@ protected function getActions(): array
Pages\Actions\EditAction::make()
->label(__('intervention.action.edit'))
->url(BeneficiaryResource::getUrl('interventions.edit', [
$this->getBeneficiary(),
$this->getRecord(),
'beneficiary' => $this->getBeneficiary(),
'record' => $this->getRecord(),
]))
->color('secondary'),

Pages\Actions\DeleteAction::make()
->label(__('intervention.action.delete'))
->successRedirectUrl(BeneficiaryResource::getUrl('interventions.index', [
$this->getBeneficiary(),
'beneficiary' => $this->getBeneficiary(),
])),

// Action::make('export')
Expand Down
2 changes: 1 addition & 1 deletion app/Filament/Resources/VacationResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public static function getEditFormSchema(): array

DatePicker::make('end_date')
->label(__('field.end_date'))
->after('start_date')
->afterOrEqual('start_date')
->required(),
])
->columnSpanFull(),
Expand Down
10 changes: 6 additions & 4 deletions app/Imports/ServicesImport.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,25 @@ public function collection(Collection $rows): void
{
$this->importCategories($rows);

Service::insert(
Service::upsert(
$rows->map(fn (Collection $row) => [
'code' => $row['code'],
'name' => $row['name'],
'category_id' => $this->categories->get($row['category']),
])->toArray()
])->toArray(),
'id'
);
}

private function importCategories(Collection $rows): void
{
ServiceCategory::insert(
ServiceCategory::upsert(
$rows->pluck('category')
->unique()
->map(fn (string $name) => ['name' => $name])
->values()
->all()
->all(),
'id'
);

$this->categories = ServiceCategory::pluck('id', 'name');
Expand Down
19 changes: 19 additions & 0 deletions app/Listeners/Sentry/RemoveUserContext.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

declare(strict_types=1);

namespace App\Listeners\Sentry;

use App\Listeners\Auth\Logout;
use function Sentry\configureScope;
use Sentry\State\Scope;

class RemoveUserContext
{
public function handle(Logout $event): void
{
configureScope(function (Scope $scope) {
$scope->removeUser();
});
}
}
30 changes: 30 additions & 0 deletions app/Listeners/Sentry/SetUserContext.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

declare(strict_types=1);

namespace App\Listeners\Sentry;

use App\Models\User;
use Illuminate\Auth\Events\Authenticated;
use Illuminate\Auth\Events\Login;
use function Sentry\configureScope;
use Sentry\State\Scope;

class SetUserContext
{
public function handle(Login | Authenticated $event): void
{
/** @var User */
$user = $event->user;

if (blank($user)) {
return;
}

configureScope(function (Scope $scope) use ($user) {
$scope->setUser([
'id' => $user->getKey(),
]);
});
}
}
3 changes: 3 additions & 0 deletions app/Models/Beneficiary.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use App\Concerns\HasLocation;
use App\Enums\Beneficiary\Ethnicity;
use App\Enums\Beneficiary\IDType;
use App\Enums\Beneficiary\ReasonRemoved;
use App\Enums\Beneficiary\Type;
use App\Enums\Beneficiary\WorkStatus;
use App\Enums\Gender;
Expand Down Expand Up @@ -59,6 +60,7 @@ class Beneficiary extends Model
'phone',
'notes',
'reason_removed',
'reason_removed_notes',

'nurse_id',
'family_id',
Expand All @@ -73,6 +75,7 @@ class Beneficiary extends Model
'gender' => Gender::class,
'ethnicity' => Ethnicity::class,
'work_status' => WorkStatus::class,
'reason_removed' => ReasonRemoved::class,
'integrated' => 'boolean',
'date_of_birth' => 'date',
'does_not_have_cnp' => 'boolean',
Expand Down
Loading

0 comments on commit c1417b9

Please sign in to comment.