Перевод на DDD
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Infrastructure\Database\Repositories\Patient;
|
||||
|
||||
use App\Domain\Patient\Contracts\PatientRepositoryInterface;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class PatientRepository implements PatientRepositoryInterface
|
||||
{
|
||||
private const TABLE = 'stt_LastJournalHistoryEntry';
|
||||
private const TTL = 300;
|
||||
private const TTL_KEY = 'mis:journal:';
|
||||
private const JOURNAL_SELECT = [
|
||||
'lj.LastJournalHistoryEntryID', 'lj.rf_MedicalHistoryID', 'lj.rf_MigrationPatientID',
|
||||
'lj.rf_ExtractMigrationPatientId', 'lj.rf_DiagnosID', 'lj.rf_AttendingDoctorID',
|
||||
'lj.rf_BedActionID', 'mh.MedicalHistoryID', 'mh.FAMILY', 'mh.Name', 'mh.OT', 'mh.BD', 'mh.DateRecipient',
|
||||
'mh.DateExtract', 'mp.DateIngoing', 'mp.DateOut', 'mp.rf_StationarBranchID', 'd.DepartmentNAME'
|
||||
];
|
||||
|
||||
public function getCurrentByDepartmentId(int $departmentId): ?\Illuminate\Support\Collection
|
||||
{
|
||||
$query = DB::connection('mis')->table('stt_LastJournalHistoryEntry as lj')
|
||||
->join('stt_MedicalHistory as mh', 'mh.MedicalHistoryID', '=', 'lj.rf_MedicalHistoryID')
|
||||
->join('stt_MigrationPatient as mp', 'mp.MigrationPatientID', '=', 'lj.rf_MigrationPatientID')
|
||||
->leftJoin('stt_StationarBranch as sb', 'sb.StationarBranchID', '=', 'mp.rf_StationarBranchID')
|
||||
->leftJoin('oms_Department as d', 'd.DepartmentID', '=', 'sb.rf_DepartmentID')
|
||||
->select($this::JOURNAL_SELECT)
|
||||
->where('lj.rf_ExtractMigrationPatientId', '=', 0)
|
||||
->where('d.DepartmentID', '=', $departmentId)
|
||||
->orderBy('mh.DateRecipient');
|
||||
|
||||
$results = Cache::remember($this::TTL_KEY . $departmentId, $this::TTL, function () use ($query) {
|
||||
return $query->get();
|
||||
});
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
public function getById(int $patientId)
|
||||
{
|
||||
// TODO: Implement getById() method.
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user