Правка выдачи карт

This commit is contained in:
brusnitsyn
2025-12-26 14:29:55 +09:00
parent a5209f45c8
commit 329304076d
4 changed files with 25 additions and 24 deletions

View File

@@ -5,6 +5,7 @@ namespace App\Http\Controllers;
use App\Http\Resources\ArchiveHistoryResource;
use App\Http\Resources\ArchiveInfoResource;
use App\Http\Resources\PatientInfoResource;
use App\Http\Resources\SI\SttMedicalHistoryResource;
use App\Models\ArchiveInfo;
use App\Models\SI\SttMedicalHistory as SiSttMedicalHistory;
use App\Models\Mis\SttMedicalHistory as MisSttMedicalHistory;
@@ -18,17 +19,11 @@ class MedicalHistoryController extends Controller
$viewType = $request->get('view_type', 'mis');
$patientId = $request->get('patient_id');
$archiveInfo = ArchiveInfo::whereId($id)->first()->load('status');
if ($viewType == 'foxpro') $patient = $archiveInfo->foxproHistory;
else $patient = $archiveInfo->misHistory;
if ($viewType == 'foxpro') $patient = SiSttMedicalHistory::where('keykarta', $id)->first();
else $patient = MisSttMedicalHistory::where('MedicalHistoryID', $id)->first();
$archiveJournal = $patient->archiveHistory ? ArchiveHistoryResource::collection($patient->archiveHistory) : null;
// dd($archiveInfo);
if (!empty($archiveInfo)) {
$archiveInfo = ArchiveInfoResource::make($archiveInfo)->toArray(request());
} else {
$archiveInfo = null;
}
$archiveInfo = $patient->archiveInfo ? $patient->archiveInfo : null;
$patientInfo = [
'historyable_type' => $viewType == 'foxpro' ? SiSttMedicalHistory::class : MisSttMedicalHistory::class,

View File

@@ -21,7 +21,6 @@ class ArchiveInfoResource extends JsonResource
'status' => $this->status,
'foxpro_num' => $this->foxpro_num,
'mis_num' => $this->mis_num,
'type' => $this->historyType()
];
}
}

View File

@@ -25,14 +25,20 @@ class SttMedicalHistoryResource extends JsonResource
$name = $this->resource['name'] ?? '';
$ot = $this->resource['ot'] ?? '';
$misCardNumber = $this->resource['mis_card_number'];
$foxproCardNumber = $this->resource['foxpro_card_number'];
$hasDividerCardNumber = isset($misCardNumber) && isset($foxproCardNumber);
$cardNumber = $hasDividerCardNumber ? "$misCardNumber / $foxproCardNumber" : $misCardNumber ?? $foxproCardNumber;
// Для временных записей (не в архиве) используем данные из MIS
if ($isTemporary) {
// Данные из stt_medicalhistory (не в архиве)
$fullName = trim("{$family} {$name} {$ot}");
$birthDate = $this->resource['birth_date'] ?? null;
$dateExtract = $this->resource['date_extract'] ?? null;
$dateRecipient = null; // Для MIS записей не в архиве может не быть
$cardNumber = $this->resource['card_number'] ?? null;
$dateRecipient = $this->resource['date_recipient'] ?? null;
$archiveNum = null;
$postIn = null;
$status = $this->resource['status_text'] ?? 'Не в архиве';
@@ -40,19 +46,11 @@ class SttMedicalHistoryResource extends JsonResource
// Данные из archive_infos (в архиве)
$fullName = trim("{$family} {$name} {$ot}");
$birthDate = $this->resource['birth_date'] ?? null;
// Для архивных записей date_extract может быть из MIS или FoxPro
$dateExtract = $this->resource['date_extract'] ?? null;
// Для MIS записей в архиве
if ($historyType === 'mis') {
$dateRecipient = $this->resource['date_recipient'] ?? null;
} else {
// Для FoxPro записей в архиве
$dateRecipient = $this->resource['mpostdate'] ?? null;
}
$dateRecipient = $this->resource['date_recipient'] ?? null;
$cardNumber = $this->resource['card_number'] ?? null;
$archiveNum = $this->resource['archive_num'] ?? null;
$postIn = $this->resource['post_in'] ?? null;
$status = $this->resource['status_text'] ?? 'Неизвестно';
@@ -64,8 +62,10 @@ class SttMedicalHistoryResource extends JsonResource
$formattedDateExtract = $dateExtract ? Carbon::parse($dateExtract)->format('d.m.Y') : null;
$formattedPostIn = $postIn ? Carbon::parse($postIn)->format('d.m.Y') : null;
$id = $historyType === 'mis' ? $this->resource['mis_history_id'] : $this->resource['foxpro_history_id'];
return [
'id' => $this->resource['id'],
'id' => $id,
'history_type' => $historyType,
'in_archive' => $isFromArchive,
'is_temporary' => $isTemporary,