mirror of
https://gitlab.com/signalytic/client-external/streamline/streamline-emr.git
synced 2026-09-11 18:51:31 +00:00
67 lines
2.6 KiB
PHP
Executable File
67 lines
2.6 KiB
PHP
Executable File
<?php
|
|
|
|
namespace Modules\Pharmacy\Http\Controllers;
|
|
|
|
use Carbon\Carbon;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Streamline\Models\Patient;
|
|
use Streamline\Models\PatientDispensing;
|
|
use Streamline\Models\PrescriptionError;
|
|
use Streamline\Models\Treatment;
|
|
|
|
class PrescriptionErrorsController extends Controller {
|
|
|
|
public function index(Request $request) {
|
|
if (isset($request->start_date)){
|
|
$start_date = Carbon::createFromFormat('d/m/Y', $request->start_date)->toDateString();
|
|
$end_date = Carbon::createFromFormat('d/m/Y', $request->end_date)->toDateString();
|
|
} else {
|
|
$start_date = Carbon::now()->startOfDay()->toDateTimeString();
|
|
$end_date = Carbon::now()->endOfDay()->toDateTimeString();
|
|
}
|
|
|
|
$prescription_errors = DB::table('prescription_errors')->orderBy('created_at', 'desc')
|
|
->whereBetween('created_at', [$start_date, $end_date])
|
|
->paginate(1000);
|
|
|
|
$search_text = "Searching between " . streamline_date($start_date) . " and " . streamline_date($end_date);
|
|
|
|
return view('pharmacy::prescription_errors.index', compact('prescription_errors', 'search_text'));
|
|
}
|
|
|
|
public function view_prescription_error_details($id){
|
|
$prescription_error = PrescriptionError::find($id);
|
|
|
|
if (!$prescription_error){
|
|
return back()->withInput();
|
|
}
|
|
|
|
$altered_drugs_array = array(
|
|
"drugs" => $prescription_error->previous_drugs,
|
|
"dose" => $prescription_error->previous_doses,
|
|
"drug_frequency" => $prescription_error->previous_frequencies,
|
|
"instructions" => $prescription_error->previous_instruction,
|
|
"duration" => $prescription_error->previous_durations,
|
|
"quantity_dispensed" => $prescription_error->previous_quantities_dispensed,
|
|
);
|
|
|
|
$prescribed_drugs = Treatment::find($prescription_error->treatment_id);
|
|
|
|
if (!$prescribed_drugs){
|
|
return back()->withInput();
|
|
}
|
|
|
|
$prescribed_drugs_array = array(
|
|
"drugs" => $prescribed_drugs->drugs,
|
|
"dose" => $prescribed_drugs->doses,
|
|
"drug_frequency" => $prescribed_drugs->frequencies,
|
|
"instructions" => $prescribed_drugs->instruction,
|
|
"duration" => $prescribed_drugs->durations,
|
|
"quantity_dispensed" => $prescribed_drugs->quantities_dispensed,
|
|
);
|
|
|
|
return view('pharmacy::prescription_errors.view_prescription_error_details', compact('prescription_error', 'prescribed_drugs_array', 'altered_drugs_array'));
|
|
}
|
|
}
|