feat: add lab tests, patient file management, and prescription improvements
This commit is contained in:
@@ -301,6 +301,53 @@ public function deletePatientMessages(string $phoneNumber, string $surgeryDate):
|
||||
}
|
||||
}
|
||||
|
||||
public static function cancelAppointmentMessages(string $phoneNumber, string $localSurgeryDate): void
|
||||
{
|
||||
try {
|
||||
$apiKey = \App\Models\OsurgInitial::val('sms_api_key', config('sms.api_key'));
|
||||
$apiUrl = \App\Models\OsurgInitial::val('sms_api_url', config('sms.api_url'));
|
||||
$localDate = \Carbon\Carbon::parse($localSurgeryDate)->format('Y-m-d');
|
||||
|
||||
$grouped = Http::timeout(10)
|
||||
->withHeader('X-API-Key', $apiKey)
|
||||
->get($apiUrl . '/sms-logs-grouped', [
|
||||
'phoneNumber' => $phoneNumber,
|
||||
'limit' => 200,
|
||||
])
|
||||
->json('data') ?? [];
|
||||
|
||||
$serverSurgeryDate = null;
|
||||
foreach ($grouped as $group) {
|
||||
if (($group['phone_number'] ?? '') !== $phoneNumber) {
|
||||
continue;
|
||||
}
|
||||
$groupDate = $group['surgery_date'] ?? '';
|
||||
if (! $groupDate) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
if (\Carbon\Carbon::parse($groupDate)->format('Y-m-d') === $localDate) {
|
||||
$serverSurgeryDate = $groupDate;
|
||||
break;
|
||||
}
|
||||
} catch (\Throwable) {}
|
||||
}
|
||||
|
||||
if (! $serverSurgeryDate) {
|
||||
return;
|
||||
}
|
||||
|
||||
Http::timeout(10)
|
||||
->withHeader('X-API-Key', $apiKey)
|
||||
->asJson()
|
||||
->post($apiUrl . '/sms-logs/delete-patient', [
|
||||
'phoneNumber' => $phoneNumber,
|
||||
'surgeryDate' => $serverSurgeryDate,
|
||||
]);
|
||||
} catch (\Throwable) {
|
||||
}
|
||||
}
|
||||
|
||||
public function toJalali(?string $dateStr, string $format = 'Y/m/d H:i'): string
|
||||
{
|
||||
if (! $dateStr) {
|
||||
|
||||
Reference in New Issue
Block a user