Перевод на DDD
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Patient\Actions;
|
||||
|
||||
use App\Domain\Patient\Contracts\PatientRepositoryInterface;
|
||||
use App\Domain\Patient\DTO\PatientData;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
readonly class GetDepartmentJournalPatientAction
|
||||
{
|
||||
public function __construct(
|
||||
private PatientRepositoryInterface $patientRepository
|
||||
) {}
|
||||
|
||||
public function execute(int $departmentId): ?Collection
|
||||
{
|
||||
$patients = $this->patientRepository->getCurrentByDepartmentId($departmentId);
|
||||
|
||||
if ($patients && $patients->count() > 0) {
|
||||
return $patients->map(fn ($patient) => PatientData::fromMis($patient));
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
11
app/Domain/Patient/Contracts/PatientRepositoryInterface.php
Normal file
11
app/Domain/Patient/Contracts/PatientRepositoryInterface.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Patient\Contracts;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
interface PatientRepositoryInterface
|
||||
{
|
||||
public function getCurrentByDepartmentId(int $departmentId): ?Collection;
|
||||
public function getById(int $patientId);
|
||||
}
|
||||
69
app/Domain/Patient/DTO/PatientData.php
Normal file
69
app/Domain/Patient/DTO/PatientData.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Patient\DTO;
|
||||
|
||||
class PatientData
|
||||
{
|
||||
public function __construct(
|
||||
public int $medicalHistoryId,
|
||||
public int $migrationPatientId,
|
||||
public int $extractMigrationPatientId,
|
||||
public int $diagnosisId,
|
||||
public int $attendingDoctorId,
|
||||
public int $bedActionId,
|
||||
public string $lastName,
|
||||
public string $firstName,
|
||||
public string $middleName,
|
||||
public string $birthDate,
|
||||
public string $recipientDate,
|
||||
public string $extractDate,
|
||||
public string $migrationIngoingDate,
|
||||
public string $migrationOutDate,
|
||||
public int $migrationBranchId,
|
||||
public string $departmentName,
|
||||
) { }
|
||||
|
||||
public function toArray(): array
|
||||
{
|
||||
return [
|
||||
'medicalHistoryId' => $this->medicalHistoryId,
|
||||
'migrationPatientId' => $this->migrationPatientId,
|
||||
'extractMigrationPatientId' => $this->extractMigrationPatientId,
|
||||
'diagnosisId' => $this->diagnosisId,
|
||||
'attendingDoctorId' => $this->attendingDoctorId,
|
||||
'bedActionId' => $this->bedActionId,
|
||||
'lastName' => $this->lastName,
|
||||
'firstName' => $this->firstName,
|
||||
'middleName' => $this->middleName,
|
||||
'birthDate' => $this->birthDate,
|
||||
'recipientDate' => $this->recipientDate,
|
||||
'extractDate' => $this->extractDate,
|
||||
'migrationIngoingDate' => $this->migrationIngoingDate,
|
||||
'migrationOutDate' => $this->migrationOutDate,
|
||||
'migrationBranchId' => $this->migrationBranchId,
|
||||
'departmentName' => $this->departmentName,
|
||||
];
|
||||
}
|
||||
|
||||
public static function fromMis(array $data): self
|
||||
{
|
||||
return new self(
|
||||
$data['rf_MedicalHistoryID'],
|
||||
$data['rf_MigrationPatientID'],
|
||||
$data['rf_ExtractMigrationPatientID'],
|
||||
$data['rf_DiagnosisID'],
|
||||
$data['rf_AttendingDoctorID'],
|
||||
$data['rf_BedActionID'],
|
||||
$data['FAMILY'],
|
||||
$data['Name'],
|
||||
$data['OT'],
|
||||
$data['BD'],
|
||||
$data['DateRecipient'],
|
||||
$data['DateExtract'],
|
||||
$data['DateIngoing'],
|
||||
$data['DateOut'],
|
||||
$data['rf_StationarBranchID'],
|
||||
$data['DepartmentNAME'],
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user