Add patient SMS/email messaging and fix Meet video visit errors.
Deploy Ladill Care / deploy (push) Successful in 43s

Wire Care to Ladill SMS and Bird management APIs on the patient page, and surface Meet auth/config failures as friendly validation errors instead of a 502 page.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
isaacclad
2026-07-12 14:14:14 +00:00
co-authored by Cursor
parent 0bb19233e2
commit 2568b8a2f0
12 changed files with 505 additions and 2 deletions
+18
View File
@@ -131,6 +131,24 @@ class CareAppointmentMeetTest extends TestCase
$this->assertSame('room-uuid-2', $appointment->meet_room_uuid);
}
public function test_schedule_meet_shows_friendly_error_when_unauthorized(): void
{
Http::fake([
'meet.test/*' => Http::response(['error' => 'Unauthorized.'], 401),
]);
$appointment = $this->createAppointment();
$this->actingAs($this->user)
->from(route('care.appointments.show', $appointment))
->post(route('care.appointments.schedule-meet', $appointment))
->assertRedirect(route('care.appointments.show', $appointment))
->assertSessionHasErrors('meet');
$appointment->refresh();
$this->assertNull($appointment->meet_room_uuid);
}
protected function createAppointment(string $status = Appointment::STATUS_SCHEDULED): Appointment
{
return Appointment::create([
+79 -1
View File
@@ -137,7 +137,85 @@ class CarePatientTest extends TestCase
->get(route('care.patients.show', $patient))
->assertOk()
->assertSee('Efua Boateng')
->assertSee('LC-2026-00001');
->assertSee('LC-2026-00001')
->assertSee('Message patient');
}
public function test_can_send_patient_sms_via_platform_api(): void
{
config([
'sms.platform_api_url' => 'https://ladill.test/api',
'sms.platform_api_key' => 'test-sms-care-key',
'sms.default_sender_id' => 'Ladill',
]);
\Illuminate\Support\Facades\Http::fake([
'ladill.test/api/sms/services*' => \Illuminate\Support\Facades\Http::response([
'data' => [['id' => 9, 'name' => 'Ladill Care']],
]),
'ladill.test/api/sms/messages/send' => \Illuminate\Support\Facades\Http::response([
'success' => true,
'segments' => 1,
]),
]);
$patient = Patient::create([
'uuid' => (string) \Illuminate\Support\Str::uuid(),
'owner_ref' => $this->user->public_id,
'organization_id' => $this->organization->id,
'branch_id' => $this->branch->id,
'patient_number' => 'LC-2026-00002',
'first_name' => 'Kofi',
'last_name' => 'Mensah',
'phone' => '0244111222',
]);
$this->actingAs($this->user)
->post(route('care.patients.sms', $patient), [
'message' => 'Your appointment is tomorrow at 9am.',
])
->assertRedirect()
->assertSessionHas('success');
$this->assertDatabaseHas('care_audit_logs', ['action' => 'patient.sms_sent']);
}
public function test_can_send_patient_email_via_platform_api(): void
{
config([
'smtp.platform_api_url' => 'https://ladill.test/api/smtp',
'smtp.platform_api_key' => 'test-smtp-care-key',
'smtp.from' => 'care@ladill.com',
'smtp.from_name' => 'Ladill Care',
]);
\Illuminate\Support\Facades\Http::fake([
'ladill.test/api/smtp/messages/send' => \Illuminate\Support\Facades\Http::response([
'success' => true,
'message_id' => 'msg-1',
]),
]);
$patient = Patient::create([
'uuid' => (string) \Illuminate\Support\Str::uuid(),
'owner_ref' => $this->user->public_id,
'organization_id' => $this->organization->id,
'branch_id' => $this->branch->id,
'patient_number' => 'LC-2026-00003',
'first_name' => 'Ama',
'last_name' => 'Serwaa',
'email' => 'ama@example.com',
]);
$this->actingAs($this->user)
->post(route('care.patients.email', $patient), [
'subject' => 'Appointment reminder',
'body' => 'Please arrive 15 minutes early.',
])
->assertRedirect()
->assertSessionHas('success');
$this->assertDatabaseHas('care_audit_logs', ['action' => 'patient.email_sent']);
}
public function test_api_can_list_patients(): void