Files
streamline-emr/docker/streamline-src/app/Console/Commands/SendAppointmentRemaindersCommand.php
T
alec.turner a424394109 Build modified streamline images
The official image from streamline does not currently work for the arm64
platform. As a temporary measure, the source code and docker build scripts
have been lifted from the official images and are used to build locally.

Some additional modifications are made to reduce overall image size, these
are documented in docker/README.md
2024-03-10 16:17:50 -07:00

58 lines
1.6 KiB
PHP
Executable File

<?php
namespace Streamline\Console\Commands;
use Carbon\Carbon;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Streamline\Http\Controllers\SMSController;
class SendAppointmentRemaindersCommand extends Command {
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'appointment:remainders';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Send sms alerts to remind patients of appointments a day before';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct() {
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle() {
$tomorrow_start = Carbon::now()->startOfDay()->addDay();
$tomorrow_end = Carbon::now()->endOfDay()->addDay();
$appointments = DB::table('patient_appointments')
->whereBetween('appointment_date', [$tomorrow_start, $tomorrow_end])
->get();
foreach ($appointments as $appointment) {
if (is_sms_enabled()) {
// send sms alert to the patient
$sms = "This is a reminder that your appointment at " . get_name(1, 'id', 'name', 'hospital_information') .
" is scheduled for tomorrow the " . streamline_date($appointment->appointment_date) . " at " . $appointment->appointment_time;
(new SMSController)->send_appointments_alert($appointment->patient_id, $sms);
}
}
}
}