Skip to content

Commit

Permalink
Merge branch 'main' of github.com:code4romania/asistent-medical-comun…
Browse files Browse the repository at this point in the history
…itar
  • Loading branch information
andreiio committed Oct 15, 2024
2 parents 8689446 + 005bf94 commit f38eade
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 35 deletions.
4 changes: 0 additions & 4 deletions app/Filament/Resources/CatagraphyResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,6 @@ 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 @@ -123,10 +123,6 @@ 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
14 changes: 0 additions & 14 deletions app/Models/Catagraphy.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ class Catagraphy extends Model
'cat_ssa',
'cat_vif',
'is_social_case',
'is_vaccinated_on_schedule',
];

protected $casts = [
Expand All @@ -69,7 +68,6 @@ class Catagraphy extends Model
'has_disabilities' => 'boolean',
'has_health_issues' => 'boolean',
'is_social_case' => 'boolean',
'is_vaccinated_on_schedule' => 'boolean',
];

protected $with = [
Expand Down Expand Up @@ -184,18 +182,6 @@ public function catSoc(): Attribute
return Attribute::make(
get: fn () => match ($this->is_social_case) {
true => 'VCS_01',
false => 'VCS_99',
default => null,
},
)->shouldCache();
}

public function catVcc(): Attribute
{
return Attribute::make(
get: fn () => match ($this->is_vaccinated_on_schedule) {
true => 'VVC_01',
// false => 'VVC_99',
default => null,
},
)->shouldCache();
Expand Down
11 changes: 8 additions & 3 deletions app/Reports/Queries/Child/C20.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,25 @@
namespace App\Reports\Queries\Child;

use App\Models\Beneficiary;
use App\Models\Catagraphy;
use App\Reports\Queries\ReportQuery;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Query\Builder as QueryBuilder;

class C20 extends ReportQuery
{
/**
* Sum beneficiari with Vaccinat conform calendarului (!= VVC_01); Copil 0-1 ani (VCV_01) OR Copil 1-5 ani (VCV_02) OR Copil 5-14 ani (VCV_03).
* Sum beneficiari with Vaccinat conform calendarului (VSC_97); Copil 0-1 ani (VCV_01) OR Copil 1-5 ani (VCV_02) OR Copil 5-14 ani (VCV_03).
*/
public static function query(): Builder
{
return Beneficiary::query()
->whereHasVulnerabilities(function (Builder $query) {
$query->whereJsonDoesntContain('properties', 'VVC_01')
->whereJsonOverlaps('properties', ['VCV_01', 'VCV_02', 'VCV_03']);
$query
->whereJsonOverlaps('properties', ['VCV_01', 'VCV_02', 'VCV_03'])
->whereHasCatagraphyRelation(Catagraphy::class, function (QueryBuilder $query) {
$query->whereJsonContains('properties->attributes->cat_ssa', 'VSC_97');
});
});
}
}
8 changes: 6 additions & 2 deletions app/Reports/Queries/Child/C30.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
namespace App\Reports\Queries\Child;

use App\Models\Beneficiary;
use App\Models\Catagraphy;
use App\Reports\Queries\ReportQuery;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Query\Builder as QueryBuilder;

class C30 extends ReportQuery
{
Expand All @@ -17,8 +19,10 @@ public static function query(): Builder
{
return Beneficiary::query()
->whereHasVulnerabilities(function (Builder $query) {
$query->whereJsonContains('properties', 'VSA_97')
->whereJsonOverlaps('properties', ['VCV_01', 'VCV_02', 'VCV_03']);
$query->whereJsonOverlaps('properties', ['VCV_01', 'VCV_02', 'VCV_03']);
})
->whereHasCatagraphyRelation(Catagraphy::class, function (QueryBuilder $query) {
$query->whereJsonContains('properties->attributes->cat_mf', 'VSA_97');
});
}
}
8 changes: 6 additions & 2 deletions app/Reports/Queries/Pregnant/P03.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
namespace App\Reports\Queries\Pregnant;

use App\Models\Beneficiary;
use App\Models\Catagraphy;
use App\Reports\Queries\ReportQuery;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Query\Builder as QueryBuilder;

class P03 extends ReportQuery
{
Expand All @@ -17,8 +19,10 @@ public static function query(): Builder
{
return Beneficiary::query()
->whereHasVulnerabilities(function (Builder $query) {
$query->whereJsonOverlaps('properties', ['VGR_04', 'VGR_01'])
->whereJsonContains('properties', 'VGR_98');
$query->whereJsonOverlaps('properties', ['VGR_04', 'VGR_01']);
})
->whereHasCatagraphyRelation(Catagraphy::class, function (QueryBuilder $query) {
$query->whereJsonContains('properties->attributes->cat_preg', 'VGR_98');
});
}
}
6 changes: 4 additions & 2 deletions app/Reports/Queries/Pregnant/P09.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ public static function query(): Builder
{
return Beneficiary::query()
->whereHasVulnerabilities(function (Builder $query) {
$query->whereJsonOverlaps('properties', ['VGR_04', 'VGR_01'])
->whereJsonOverlaps('properties', ['STR_02', 'SAI_02', 'SNF_02']);
$query->whereJsonOverlaps('properties', ['VGR_04', 'VGR_01']);
})
->whereHas('interventions', function (Builder $query) {
$query->whereRealizedIndividualServiceWithCode(['STR_02', 'SAI_02', 'SNF_02']);
});
}
}
6 changes: 4 additions & 2 deletions app/Reports/Queries/Pregnant/P10.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ public static function query(): Builder
{
return Beneficiary::query()
->whereHasVulnerabilities(function (Builder $query) {
$query->whereJsonOverlaps('properties', ['VGR_04', 'VGR_01'])
->whereJsonContains('properties', 'SES_13');
$query->whereJsonOverlaps('properties', ['VGR_04', 'VGR_01']);
})
->whereHas('interventions', function (Builder $query) {
$query->whereRealizedIndividualServiceWithCode('SES_13');
});
}
}
Binary file modified database/data/240722-vulnerabilities.xlsx
Binary file not shown.
1 change: 0 additions & 1 deletion database/factories/CatagraphyFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public function definition()
'has_disabilities' => fake()->boolean(),
'has_health_issues' => fake()->boolean(),
'is_social_case' => fake()->boolean(),
'is_vaccinated_on_schedule' => fake()->boolean(),

'cat_age' => fake()->randomElement($this->vulnerabilities->get('AGE')->keys()),
'cat_as' => fake()->randomElement($this->vulnerabilities->get('AS')->keys()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ public function up(): void
{
Schema::table('catagraphies', function (Blueprint $table) {
$table->boolean('is_social_case')->nullable()->after('evaluation_date');
$table->boolean('is_vaccinated_on_schedule')->nullable()->after('cat_ns');
});
}
};

0 comments on commit f38eade

Please sign in to comment.