modified: .gitignore

This commit is contained in:
brusnitsyn
2026-04-21 10:08:14 +09:00
parent 0e8b6f61b4
commit 2041ab54ea
74 changed files with 7533 additions and 1544 deletions

View File

@@ -2,7 +2,7 @@
namespace App\Http\Resources\Mis;
use App\Models\MisSurgicalOperation;
use App\Data\UnifiedPatientData;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
use Illuminate\Support\Carbon;
@@ -17,9 +17,33 @@ class FormattedPatientResource extends JsonResource
*/
public function toArray(Request $request): array
{
if ($this->resource instanceof UnifiedPatientData) {
$age = $this->formatAge($this->age);
return [
'id' => $this->id,
'patient_uid' => $this->patientUid,
'source_type' => $this->sourceType,
'department_patient_id' => $this->departmentPatientId,
'medical_history_id' => $this->medicalHistoryId,
'mkb' => $this->mkb,
'operations' => $this->operations,
'fullname' => $this->fullname,
'age' => $age,
'birth_date' => $this->birthDate ? Carbon::parse($this->birthDate)->format('d.m.Y') : null,
'patient_kind' => $this->patientKind,
'admitted_at' => $this->admittedAt ? Carbon::parse($this->admittedAt)->format('d.m.Y H:i') : null,
'outcome_type' => $this->outcomeType,
'outcome_date' => $this->outcomeDate,
'comment' => $this->comment,
'is_recipient_today' => $this->isRecipientToday,
'is_manual' => $this->isManual,
'can_manage_manual' => $this->canManageManual,
];
}
return [
'id' => $this->MedicalHistoryID,
'num' => $this->num,
'mkb' => [
'ds' => $this->outcomeMigration->first()->mainDiagnosis?->mkb?->DS,
'name' => $this->outcomeMigration->first()->mainDiagnosis?->mkb?->NAME
@@ -31,10 +55,41 @@ class FormattedPatientResource extends JsonResource
];
}),
'fullname' => Str::ucwords(Str::lower("$this->FAMILY $this->Name $this->OT")),
'age' => Carbon::parse($this->BD)->diff(Carbon::now())->format('%y'),
'age' => $this->formatAge(Carbon::parse($this->BD)->diffInYears(Carbon::now(), false)),
'birth_date' => Carbon::parse($this->BD)->format('d.m.Y'),
'admitted_at' => $this->DateRecipient ? Carbon::parse($this->DateRecipient)->format('d.m.Y H:i') : null,
'outcome_type' => $this->when($this->outcome_type, $this->outcome_type),
'comment' => $this->when($this->comment, $this->comment)
'outcome_date' => $this->when($this->outcome_date, $this->outcome_date),
'comment' => $this->when($this->comment, $this->comment),
'is_recipient_today' => (bool) ($this->is_recipient_today ?? false),
'is_manual' => false,
'can_manage_manual' => false,
];
}
private function formatAge($value): ?string
{
if ($value === null || $value === '') {
return null;
}
$age = abs((int) $value);
$suffix = $this->ageSuffix($age);
return "{$age} {$suffix}";
}
private function ageSuffix(int $age): string
{
$mod100 = $age % 100;
if ($mod100 >= 11 && $mod100 <= 14) {
return 'лет';
}
return match ($age % 10) {
1 => 'год',
2, 3, 4 => 'года',
default => 'лет',
};
}
}