@php
$hasPtConfig = $hasPtConfig ?? false;
$isExisting = $hasPtConfig;
$patientInfo = $data ?? [];
$napId = $napId ?? ($patientInfo['NAP_ID'] ?? null);
$formatDisplayDate = function ($value) {
if (blank($value)) {
return '';
}
try {
if ($value instanceof \Carbon\CarbonInterface) {
return $value->format('d-m-Y');
}
return \Illuminate\Support\Carbon::parse($value)->format('d-m-Y');
} catch (\Throwable $e) {
return is_string($value) ? $value : '';
}
};
$parseDisplayDate = function ($value) {
if (blank($value)) {
return null;
}
if ($value instanceof \Carbon\CarbonInterface) {
return $value;
}
$raw = trim((string) $value);
try {
if (preg_match('/^\d{1,2}[\/-]\d{1,2}[\/-]\d{4}$/', $raw)) {
$normalized = str_replace('/', '-', $raw);
return \Illuminate\Support\Carbon::createFromFormat('d-m-Y', $normalized);
}
return \Illuminate\Support\Carbon::parse($raw);
} catch (\Throwable $e) {
return null;
}
};
$patientDob = $formatDisplayDate($patientInfo['Date Of Birth'] ?? ($patientInfo['Date of Birth'] ?? ($patientInfo['Date_of_Birth'] ?? ($patientInfo['Dob'] ?? null))));
$autoAddressParts = array_filter([
$patientInfo['Quarter'] ?? null,
$patientInfo['Township'] ?? null,
$patientInfo['Region'] ?? null,
]);
$autoAddress = implode(', ', $autoAddressParts);
$regDate = $formatDisplayDate($patientInfo['Reg Date'] ?? null);
$visits = $visits ?? collect();
$visitTotal = method_exists($visits, 'total') ? $visits->total() : $visits->count();
$visitPageCount = $visits->count();
$visitHasPages = method_exists($visits, 'hasPages') ? $visits->hasPages() : false;
$v = $lastVisit;
$patientAge = old('age', $patientInfo['Agey'] ?? $patientInfo['Age'] ?? $patientInfo['age'] ?? optional($lastVisit)->age);
$patientAgeMonths = old('age_months', $patientInfo['Agem'] ?? null);
if (!$patientAge && $patientDob) {
try {
$dobCarbon = $parseDisplayDate($patientDob);
if ($dobCarbon === null) {
throw new \RuntimeException('Invalid DOB');
}
$patientAge = $dobCarbon->age;
$patientAgeMonths = $dobCarbon->diffInMonths(now()) % 12;
} catch (\Throwable $e) {
$patientAge = null;
}
} elseif ($patientAge && !$patientAgeMonths && $patientDob) {
try {
$dobCarbon = $parseDisplayDate($patientDob);
if ($dobCarbon === null) {
throw new \RuntimeException('Invalid DOB');
}
$patientAgeMonths = $dobCarbon->diffInMonths(now()) % 12;
} catch (\Throwable $e) {
$patientAgeMonths = null;
}
}
$clinicOptions = $clinicOptions ?? [];
$selectedClinicId = $selectedClinicId ?? ($patientInfo['Clinic_ID'] ?? null);
@endphp
Use this Inner ID when correcting PID, NAP ID, or Fuchia ID.
Pending Queue
Loading pending queue…
@if(session('success'))
{{ session('success') }}
@endif
@if(session('info_new_patient'))
{{ session('info_new_patient') }}
@endif
@if(session('info'))
{{ session('info') }}
@endif
@if($errors->any() && !session('suppress_errors'))
Invalid data, please check fields:
@foreach($errors->all() as $message)
- {{ $message }}
@endforeach
@endif
@if(session('highlight_pid'))
Saved! PID {{ session('highlight_pid') }}
@if(session('highlight_name'))
- {{ session('highlight_name') }}
@endif
@endif
@if(session('highlight_inner_id'))
Inner ID: {{ session('highlight_inner_id') }} — share this with data clerks for follow-up searches.
@endif
@php
$duplicateMatches = session('duplicate_matches', []);
$duplicateIdentifier = session('duplicate_identifier');
$hasDuplicateMatches = !empty($duplicateMatches);
@endphp
Duplicate IDs found.
@if($duplicateIdentifier)
{{ strtoupper($duplicateIdentifier['type'] ?? '') }}: {{ $duplicateIdentifier['value'] ?? '' }}
@endif
— select the correct patient row or use Inner ID to fix identifiers.
| Inner ID |
NAP ID |
PID |
Fuchia ID |
Name |
Clinic |
Action |
@foreach($duplicateMatches as $match)
@php
$clinicName = $clinicOptions[$match['clinic_id'] ?? ''] ?? ($match['clinic_id'] ?? '—');
@endphp
| {{ $match['id'] ?? '—' }} |
{{ $match['nap_id'] ?? '—' }} |
{{ $match['pid'] ?? '—' }} |
{{ $match['fuchia_id'] ?? '—' }} |
{{ $match['name'] ?? '—' }} |
{{ $clinicName }} |
Load
|
@endforeach