mirror of
https://gitlab.com/signalytic/client-external/streamline/streamline-emr.git
synced 2026-09-11 18:51:31 +00:00
updated streamline-setup v2
This commit is contained in:
+207
-98
@@ -25,6 +25,11 @@ use Streamline\Models\CardioEchoResult;
|
||||
use Barryvdh\Snappy\Facades\SnappyPdf;
|
||||
use Streamline\Models\Investigation;
|
||||
use Streamline\Models\Outcome;
|
||||
use Streamline\Models\PrioritySign;
|
||||
use Streamline\Models\EmergencySign;
|
||||
use Streamline\Models\WardInpatientDetailedNote;
|
||||
use Streamline\Models\MessageBoard;
|
||||
use Illuminate\Database\QueryException;
|
||||
|
||||
class ConsultationController extends Controller
|
||||
{
|
||||
@@ -49,7 +54,8 @@ class ConsultationController extends Controller
|
||||
|
||||
if (!session()->has('patient_id') || !session()->has('episode_id')) :
|
||||
flash('Patient is not selected')->error();
|
||||
return view('home');
|
||||
$messages = MessageBoard::orderBy('created_at', 'desc')->paginate(3);
|
||||
return view('home', compact('messages'));
|
||||
endif;
|
||||
|
||||
$clinics = Clinic::orderBy('name')->pluck("name", "id")->toArray();
|
||||
@@ -285,7 +291,8 @@ class ConsultationController extends Controller
|
||||
|
||||
if (!session()->has('patient_id') || !session()->has('episode_id')) :
|
||||
flash('Patient is not selected')->error();
|
||||
return view('home');
|
||||
$messages = MessageBoard::orderBy('created_at', 'desc')->paginate(3);
|
||||
return view('home', compact('messages'));
|
||||
endif;
|
||||
|
||||
$consultation = new Consultation;
|
||||
@@ -493,7 +500,17 @@ class ConsultationController extends Controller
|
||||
}
|
||||
|
||||
$episode = PatientEpisode::find($episode_id);
|
||||
|
||||
if(!empty($request->investigation_and_management_plan_comments) || !empty($request->clinic_examination_comments) || !empty($request->history_comments)){
|
||||
$notes = new WardInpatientDetailedNote;
|
||||
$notes->patient_id = $patient_id;
|
||||
$notes->episode_id = $episode_id;
|
||||
$notes->ward_id = 0;
|
||||
$notes->investigation_and_management_plan_comments = $request->investigation_and_management_plan_comments?? null;
|
||||
$notes->clinic_examination_comments = $request->clinic_examination_comments?? null;
|
||||
$notes->history_comments = $request->history_comments;
|
||||
$notes->created_by = Auth::user()->id;
|
||||
$notes->save();
|
||||
}
|
||||
|
||||
// Handle the buttons on the consultation page
|
||||
switch ($request->get('submit-btn')):
|
||||
@@ -595,8 +612,9 @@ class ConsultationController extends Controller
|
||||
|
||||
if (session()->get('consultation_with_notes') == 1) {
|
||||
$consultation_with_notes = true;
|
||||
$consultation_notes = WardInpatientDetailedNote::where(['patient_id' => $patient->id, 'episode_id' => $episode->id, 'ward_id' => 0])->latest()->get();
|
||||
} else {
|
||||
$consultation_with_notes = false;
|
||||
$consultation_with_notes = false; $consultation_notes = '';
|
||||
}
|
||||
|
||||
$is_mental_health_clinic = false;
|
||||
@@ -657,7 +675,7 @@ class ConsultationController extends Controller
|
||||
/* ========end of varibales added to cater for review episodes ========*/
|
||||
|
||||
$cardio_echo = CardioEchoResult::where('episode_id', $consultation->episode_id)->first();
|
||||
|
||||
$users = DB::table('users')->pluck(DB::raw("CONCAT(first_name,' ',last_name) AS name"), 'id');
|
||||
return view('patients::consultations.show', compact(
|
||||
'consultation',
|
||||
'patient',
|
||||
@@ -688,7 +706,9 @@ class ConsultationController extends Controller
|
||||
'parent_episode_ordered_sundries',
|
||||
'parent_episode_ordered_investigations',
|
||||
'parent_episode_investigation_results',
|
||||
'cardio_echo'
|
||||
'cardio_echo',
|
||||
'consultation_notes',
|
||||
'users'
|
||||
));
|
||||
}
|
||||
|
||||
@@ -705,7 +725,7 @@ class ConsultationController extends Controller
|
||||
|
||||
$clinics = Clinic::orderBy('name')->pluck("name", "id")->toArray();
|
||||
$clinics = ['0' => "Don't assign clinic"] + $clinics;
|
||||
$users = User::orderBy('first_name')->select("id", "first_name", "last_name")->get();
|
||||
$users = User::pluck(DB::raw("CONCAT(first_name,' ',last_name) AS name"), 'id');
|
||||
|
||||
//Patient, Triage and Episode
|
||||
$patient = Patient::where('id', $consultation->patient_id)->first();
|
||||
@@ -714,10 +734,13 @@ class ConsultationController extends Controller
|
||||
|
||||
if (session()->get('consultation_with_notes') == 1) {
|
||||
$consultation_with_notes = true;
|
||||
$all_notes = WardInpatientDetailedNote::where(['patient_id' => $patient->id, 'episode_id' => $episode->id, 'ward_id' => 0])->latest()->get();
|
||||
$consultation_notes = $all_notes->take(5);
|
||||
$notes = $all_notes->skip(5);
|
||||
$view_notes = $notes->all();
|
||||
} else {
|
||||
$consultation_with_notes = false;
|
||||
}
|
||||
|
||||
$consultation_with_notes = false; $consultation_notes = $view_notes ='';
|
||||
}
|
||||
$is_mental_health_clinic = false;
|
||||
// fetch the clinic id and determine if this is a mental health consultation
|
||||
$clinic_slug = get_name($episode->clinic_id, "id", "slug", "clinics");
|
||||
@@ -918,7 +941,9 @@ class ConsultationController extends Controller
|
||||
'users_array',
|
||||
'is_mental_health_clinic',
|
||||
'hmis_categories',
|
||||
'cardio_echo'
|
||||
'cardio_echo',
|
||||
'consultation_notes',
|
||||
'view_notes'
|
||||
));
|
||||
}
|
||||
|
||||
@@ -927,7 +952,8 @@ class ConsultationController extends Controller
|
||||
|
||||
if (!session()->has('patient_id') || !session()->has('episode_id')) :
|
||||
flash('Patient is not selected')->error();
|
||||
return view('home');
|
||||
$messages = MessageBoard::orderBy('created_at', 'desc')->paginate(3);
|
||||
return view('home', compact('messages'));
|
||||
endif;
|
||||
|
||||
$consultation = Consultation::find($id);
|
||||
@@ -1131,6 +1157,26 @@ class ConsultationController extends Controller
|
||||
$mental_health_consultation->update();
|
||||
}
|
||||
|
||||
if(!empty($request->investigation_and_management_plan_comments) || !empty($request->clinic_examination_comments) || !empty($request->history_comments)){
|
||||
$notes = new WardInpatientDetailedNote;
|
||||
$notes->patient_id = $patient_id;
|
||||
$notes->episode_id = $episode_id;
|
||||
$notes->ward_id = 0;
|
||||
$notes->investigation_and_management_plan_comments = $request->investigation_and_management_plan_comments?? null;
|
||||
$notes->clinic_examination_comments = $request->clinic_examination_comments?? null;
|
||||
$notes->history_comments = $request->history_comments?? null;
|
||||
$notes->created_by = Auth::user()->id;
|
||||
$notes->save();
|
||||
}
|
||||
if(!empty($request->deleted_notes)){
|
||||
foreach($request->deleted_notes as $note){
|
||||
if(!empty($note)) {
|
||||
$notes = WardInpatientDetailedNote::find($note);
|
||||
$notes->delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch ($request->get('submit-btn')):
|
||||
case 'investigation':
|
||||
$consultation->save();
|
||||
@@ -1292,10 +1338,8 @@ class ConsultationController extends Controller
|
||||
$diagnosis->save();
|
||||
return $diagnosis->id;
|
||||
} catch (QueryException $e) {
|
||||
$errorCode = $e->errorInfo[1];
|
||||
if ($errorCode == 1062) { //error code for duplicate entry to a unique field
|
||||
return response()->json(['error' => $e]);
|
||||
}
|
||||
flash("An error occurred")->error();
|
||||
return back()->withInput();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1319,20 +1363,20 @@ class ConsultationController extends Controller
|
||||
$hospitalInfo = DB::table('hospital_information')->find(1);
|
||||
|
||||
$consultation = Consultation::where(['patient_id' => $patient_id, 'episode_id' => $episode_id])->orderBy('created_at', 'desc')->first();
|
||||
|
||||
$triage = Triage::where(['patient_id' => $patient_id, 'episode_id' => $episode_id])->first();
|
||||
$patient_discount = \Streamline\Models\PatientDiscount::where(['patient_category' => $patient->category_id])->select("discount", "pay_later")->first();
|
||||
|
||||
if (!is_null($patient_discount)) {
|
||||
$patient_discount->toArray();
|
||||
}
|
||||
$treatments = Treatment::where(['patient_id' => $patient_id, 'episode_id' => $episode_id])->get();
|
||||
$all_diagnoses = DB::table('diagnoses')->pluck("name", "id");
|
||||
|
||||
/* ====== start work on investigations */
|
||||
// prep the inpatient investigation arrays and counters
|
||||
$opd_investigations = [];
|
||||
$opd_investigations_position = [];
|
||||
$opd_investigations_date = [];
|
||||
$ward_investigations = [];
|
||||
$ward_investigations_position = [];
|
||||
$ward_investigations_date = [];
|
||||
|
||||
// get all investigations ordered in this episode
|
||||
@@ -1342,22 +1386,6 @@ class ConsultationController extends Controller
|
||||
$investigation_results_order_ids = InvestigationResults::pluck('order_id', 'id')->toArray();
|
||||
|
||||
foreach ($ordered_investigations as $investigation) {
|
||||
if (isset($ward_investigations['id'])) {
|
||||
$ward_investigations_position[] = count($ward_investigations['id']);
|
||||
} else {
|
||||
$ward_investigations_position[] = 0;
|
||||
}
|
||||
|
||||
if (isset($opd_investigations['id'])) {
|
||||
$opd_investigations_position[] = count($opd_investigations['id']);
|
||||
} else {
|
||||
$opd_investigations_position[] = 0;
|
||||
}
|
||||
|
||||
$ward_investigations_date[] = "Ordered on " . streamline_date_time($investigation->created_at) . " by " .
|
||||
get_full_name($investigation->created_by, 'id', 'first_name', 'last_name', 'users');
|
||||
$opd_investigations_date[] = streamline_date_time($investigation->created_at);
|
||||
|
||||
$investigation_ids = explode(",", $investigation->investigation_id);
|
||||
$inpatient_status = explode(",", $investigation->for_inpatient);
|
||||
|
||||
@@ -1377,61 +1405,81 @@ class ConsultationController extends Controller
|
||||
|
||||
if ($results->all_authenticated == 1) {
|
||||
for ($i = 0; $i < count($inpatient_status); $i++) {
|
||||
if (isset($inpatient_status[$i]) && $inpatient_status[$i] == 0) {
|
||||
$result = Investigation::withTrashed()->find($investigation_ids[$i]);
|
||||
$opd_investigations['id'][] = $result->id;
|
||||
$opd_investigations['name'][] = $result->name;
|
||||
$opd_investigations['type'][] = $result->type;
|
||||
$opd_investigations['slug'][] = $result->slug;
|
||||
$opd_investigations['value'][] = $investigation_results[$i];
|
||||
$opd_investigations['comment'][] = $investigation_comments[$i];
|
||||
if ($inpatient_status[$i] == 0) {
|
||||
if (isset($investigation_ids[$i]) && $investigation_ids[$i] != "") {
|
||||
$result = Investigation::where('id', $investigation_ids[$i])->first();
|
||||
$opd_investigations['name'][] = $result->name;
|
||||
$opd_investigations['value'][] = $investigation_results[$i];
|
||||
$opd_investigations['comment'][] = $investigation_comments[$i];
|
||||
|
||||
if($result->range_type == 1) {
|
||||
$opd_investigations['normal_ranges'][] = get_dynamic_normal_range($result->id, get_patient_age_group($patient_id), get_name($patient_id, 'id', 'gender', 'patients'));
|
||||
} else {
|
||||
$opd_investigations['normal_ranges'][] = $result->normal_ranges;
|
||||
}
|
||||
|
||||
$opd_investigations['type'][] = $result->type;
|
||||
}
|
||||
} else {
|
||||
$result = Investigation::withTrashed()->find($investigation_ids[$i]);
|
||||
$ward_investigations['id'][] = $result->id;
|
||||
$ward_investigations['name'][] = $result->name;
|
||||
$ward_investigations['type'][] = $result->type;
|
||||
$ward_investigations['slug'][] = $result->slug;
|
||||
$ward_investigations['value'][] = isset($investigation_results[$i]) ? $investigation_results[$i] : "";
|
||||
$ward_investigations['comment'][] = isset($investigation_comments[$i]) ? $investigation_comments[$i] : "";
|
||||
if (isset($investigation_ids[$i]) && $investigation_ids[$i] != "") {
|
||||
$result = Investigation::where('id', $investigation_ids[$i])->first();
|
||||
$ward_investigations['name'][] = $result->name;
|
||||
$ward_investigations['value'][] = $investigation_results[$i];
|
||||
$ward_investigations['comment'][] = $investigation_comments[$i];
|
||||
$ward_investigations['type'][] = $result->type;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for ($i = 0; $i < count($inpatient_status); $i++) {
|
||||
|
||||
$investigation = \Streamline\Models\Investigation::withTrashed()->find($investigation_ids[$i]);
|
||||
|
||||
if (isset($investigation_per_valid[$i]) && $investigation_per_valid[$i] == 1) {
|
||||
if ($investigation_per_valid[$i] == 1) {
|
||||
// this investigation is authenticated
|
||||
if (isset($inpatient_status[$i]) && $inpatient_status[$i] == 0) {
|
||||
$opd_investigations['id'][] = $investigation->id;
|
||||
$opd_investigations['name'][] = $investigation->name;
|
||||
$opd_investigations['type'][] = $investigation->type;
|
||||
$opd_investigations['slug'][] = $investigation->slug;
|
||||
$opd_investigations['value'][] = $investigation_results[$i];
|
||||
$opd_investigations['comment'][] = $investigation_comments[$i];
|
||||
if ($inpatient_status[$i] == 0) {
|
||||
if (isset($investigation_ids[$i]) && $investigation_ids[$i] != "") {
|
||||
$result = Investigation::where('id', $investigation_ids[$i])->first();
|
||||
$opd_investigations['name'][] = $result->name;
|
||||
$opd_investigations['value'][] = $investigation_results[$i];
|
||||
|
||||
if($result->range_type == 1) {
|
||||
$opd_investigations['normal_ranges'][] = get_dynamic_normal_range($result->id, get_patient_age_group($patient_id), get_name($patient_id, 'id', 'gender', 'patients'));
|
||||
} else {
|
||||
$opd_investigations['normal_ranges'][] = $result->normal_ranges;
|
||||
}
|
||||
|
||||
$opd_investigations['comment'][] = $investigation_comments[$i];
|
||||
$opd_investigations['type'][] = $result->type;
|
||||
}
|
||||
} else {
|
||||
$ward_investigations['id'][] = $investigation->id;
|
||||
$ward_investigations['name'][] = $investigation->name;
|
||||
$ward_investigations['type'][] = $investigation->type;
|
||||
$ward_investigations['slug'][] = $investigation->slug;
|
||||
$ward_investigations['value'][] = $investigation_results[$i];
|
||||
$ward_investigations['comment'][] = $investigation_comments[$i];
|
||||
if (isset($investigation_ids[$i]) && $investigation_ids[$i] != "") {
|
||||
$result = Investigation::where('id', $investigation_ids[$i])->first();
|
||||
$ward_investigations['name'][] = $result->name;
|
||||
$ward_investigations['value'][] = $investigation_results[$i];
|
||||
$ward_investigations['comment'][] = $investigation_comments[$i];
|
||||
$ward_investigations['type'][] = $result->type;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (isset($investigation_per_valid[$i]) && $inpatient_status[$i] == 0) {
|
||||
$opd_investigations['id'][] = $investigation->id;
|
||||
$opd_investigations['name'][] = $investigation->name;
|
||||
$opd_investigations['type'][] = $investigation->type;
|
||||
$opd_investigations['slug'][] = $investigation->slug;
|
||||
$opd_investigations['value'][] = "Pending";
|
||||
$opd_investigations['comment'][] = "Pending";
|
||||
if ($inpatient_status[$i] == 0) {
|
||||
if (isset($investigation_ids[$i]) && $investigation_ids[$i] != "") {
|
||||
$result = Investigation::where('id', $investigation_ids[$i])->first();
|
||||
$opd_investigations['name'][] = $result->name;
|
||||
$opd_investigations['value'][] = "Pending";
|
||||
|
||||
if($result->range_type == 1) {
|
||||
$opd_investigations['normal_ranges'][] = get_dynamic_normal_range($result->id, get_patient_age_group($patient_id), get_name($patient_id, 'id', 'gender', 'patients'));
|
||||
} else {
|
||||
$opd_investigations['normal_ranges'][] = $result->normal_ranges;
|
||||
}
|
||||
|
||||
$opd_investigations['comment'][] = "Pending";
|
||||
}
|
||||
} else {
|
||||
$ward_investigations['id'][] = $investigation->id;
|
||||
$ward_investigations['name'][] = $investigation->name;
|
||||
$ward_investigations['type'][] = $investigation->type;
|
||||
$ward_investigations['slug'][] = $investigation->slug;
|
||||
$ward_investigations['value'][] = "Pending";
|
||||
$ward_investigations['comment'][] = "Pending";
|
||||
if (isset($investigation_ids[$i]) && $investigation_ids[$i] != "") {
|
||||
$result = Investigation::where('id', $investigation_ids[$i])->first();
|
||||
$ward_investigations['name'][] = $result->name;
|
||||
$ward_investigations['value'][] = "Pending";
|
||||
$ward_investigations['comment'][] = "Pending";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1439,27 +1487,58 @@ class ConsultationController extends Controller
|
||||
}
|
||||
} else {
|
||||
for ($i = 0; $i < count($inpatient_status); $i++) {
|
||||
if (isset($inpatient_status[$i]) && $inpatient_status[$i] == 0) {
|
||||
$result = Investigation::withTrashed()->find($investigation_ids[$i]);
|
||||
$opd_investigations['id'][] = $result->id;
|
||||
$opd_investigations['name'][] = $result->name;
|
||||
$opd_investigations['type'][] = $result->type;
|
||||
$opd_investigations['slug'][] = $result->slug;
|
||||
$opd_investigations['value'][] = "Pending";
|
||||
$opd_investigations['comment'][] = "Pending";
|
||||
if ($inpatient_status[$i] == 0) {
|
||||
if (isset($investigation_ids[$i]) && $investigation_ids[$i] != "") {
|
||||
$result = Investigation::where('id', $investigation_ids[$i])->first();
|
||||
$opd_investigations['name'][] = $result->name;
|
||||
$opd_investigations['value'][] = "Pending";
|
||||
|
||||
if($result->range_type == 1) {
|
||||
$opd_investigations['normal_ranges'][] = get_dynamic_normal_range($result->id, get_patient_age_group($patient_id), get_name($patient_id, 'id', 'gender', 'patients'));
|
||||
} else {
|
||||
$opd_investigations['normal_ranges'][] = $result->normal_ranges;
|
||||
}
|
||||
|
||||
$opd_investigations['comment'][] = "Pending";
|
||||
}
|
||||
} else {
|
||||
$result = Investigation::withTrashed()->find($investigation_ids[$i]);
|
||||
$ward_investigations['id'][] = $result->id;
|
||||
$ward_investigations['name'][] = $result->name;
|
||||
$ward_investigations['type'][] = $result->type;
|
||||
$ward_investigations['slug'][] = $result->slug;
|
||||
$ward_investigations['value'][] = "Pending";
|
||||
$ward_investigations['comment'][] = "Pending";
|
||||
if (isset($investigation_ids[$i]) && $investigation_ids[$i] != "") {
|
||||
$result = Investigation::where('id', $investigation_ids[$i])->first();
|
||||
$ward_investigations['name'][] = $result->name;
|
||||
$ward_investigations['value'][] = "Pending";
|
||||
$ward_investigations['comment'][] = "Pending";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/* ====== end work on investigations */
|
||||
$ordered_procedures = OrderedProcedure::where(['patient_id' => $patient_id, 'episode_id' => $episode_id])->get();
|
||||
$procedures = DB::table('procedures')->where('available', 1)->pluck("name", "id");
|
||||
$cons_notes = WardInpatientDetailedNote::where(['patient_id' => $patient_id, 'episode_id' => $episode_id, 'ward_id' => 0])->latest()->get(['investigation_and_management_plan_comments', 'clinic_examination_comments', 'history_comments', 'created_by']);
|
||||
$priority_signs = $emergent_signs =[];
|
||||
$dateBorn = Carbon::parse($patient->date_of_birth);
|
||||
$years = $dateBorn->diffInYears();
|
||||
if(between($years, 0, 12) && !empty($triage)) {
|
||||
$priority_signs_records = PrioritySign::where('triage_id', $triage->id)->first();
|
||||
|
||||
if ($priority_signs_records) {
|
||||
$priority_signs = unserialize($priority_signs_records->signs);
|
||||
}
|
||||
|
||||
$emergency_signs = EmergencySign::where('triage_id', $triage->id)->first();
|
||||
|
||||
if (!empty($emergency_signs)) {
|
||||
$airway = unserialize($emergency_signs->airway);
|
||||
$circulation = unserialize($emergency_signs->circulation);
|
||||
$neurological = unserialize($emergency_signs->neurological);
|
||||
$dehydration = unserialize($emergency_signs->dehydration);
|
||||
$emergencySigns= array_merge($airway,$circulation, $dehydration,$neurological);
|
||||
foreach($emergencySigns as $key => $sign) if($sign == 'Yes') $emergent_signs[] = $key;
|
||||
}
|
||||
}
|
||||
// get all symptoms
|
||||
$symptoms = DB::table('symptoms')->where('available', 1)->pluck("name", "id");
|
||||
|
||||
$data = [
|
||||
'patient' => $patient,
|
||||
@@ -1469,12 +1548,20 @@ class ConsultationController extends Controller
|
||||
'patient_discount' => $patient_discount,
|
||||
'ward_investigations' => $ward_investigations,
|
||||
'opd_investigations' => $opd_investigations,
|
||||
'opd_investigations_position' => $opd_investigations_position,
|
||||
'ward_investigations_position' => $ward_investigations_position,
|
||||
'ordered_procedures' => $ordered_procedures,
|
||||
'procedures' => $procedures,
|
||||
'treatments' => $treatments,
|
||||
'all_diagnoses' => $all_diagnoses,
|
||||
'cons_notes' => $cons_notes,
|
||||
'triage' => $triage,
|
||||
'years' => $years,
|
||||
'symptoms' => $symptoms,
|
||||
'priority_signs' => $priority_signs,
|
||||
'emergent_signs' => $emergent_signs,
|
||||
'opd_investigations_date' => $opd_investigations_date,
|
||||
'ward_investigations_date' => $ward_investigations_date
|
||||
];
|
||||
|
||||
// return view('patients::consultations/referral_notes_print', $data);
|
||||
$pdf = SnappyPDF::loadView('patients::consultations/referral_notes_print', $data)
|
||||
->setOrientation('portrait')
|
||||
->setOption('margin-bottom', 7)
|
||||
@@ -1493,4 +1580,26 @@ class ConsultationController extends Controller
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
public function delete_consultation_clinical_notes($id)
|
||||
{
|
||||
$ward_doctor_notes = WardInpatientDetailedNote::find($id);
|
||||
$ward_doctor_notes->delete();
|
||||
|
||||
flash('Notes have been deleted')->success();
|
||||
return redirect('in_patient_sheet');
|
||||
}
|
||||
|
||||
public function update_consultation_clinical_notes(Request $request)
|
||||
{
|
||||
$consultation_clinical_notes = WardInpatientDetailedNote::find($request->id);
|
||||
$consultation_clinical_notes->history_comments = $request->history_comments?? null;
|
||||
$consultation_clinical_notes->investigation_and_management_plan_comments = $request->investigation_and_management_plan_comments?? null;
|
||||
$consultation_clinical_notes->clinic_examination_comments = $request->clinic_examination_comments?? null;
|
||||
$consultation_clinical_notes->updated_by = Auth::user()->id;
|
||||
|
||||
if($consultation_clinical_notes->save()) return $consultation_clinical_notes->id;
|
||||
else return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+415
@@ -0,0 +1,415 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Patients\Http\Controllers;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Streamline\Http\Controllers\SMSController;
|
||||
use Streamline\Models\Clinic;
|
||||
use Streamline\Models\PatientAppointment;
|
||||
use Streamline\Models\PatientEpisode;
|
||||
use Streamline\Models\User;
|
||||
|
||||
class PatientAppointmentsController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public function follow_up()
|
||||
{
|
||||
$follow_ups = PatientAppointment::where('is_confirmed', 1)->get();
|
||||
|
||||
$calender_dates = [];
|
||||
$count = 0;
|
||||
|
||||
foreach ($follow_ups as $follow_up) {
|
||||
$patient_name = get_full_name($follow_up->patient_id, 'id', 'first_name', 'last_name', 'patients');
|
||||
$calender_dates[$count] = ["title" => $patient_name, "start" => $follow_up->appointment_date . "T" . $follow_up->appointment_time];
|
||||
$count++;
|
||||
}
|
||||
|
||||
$clinics = Clinic::orderBy('name')->pluck("name", "id")->toArray();
|
||||
$clinics = ['0' => 'All Clinics'] + $clinics;
|
||||
|
||||
$users = User::orderBy('first_name')->select("id", "first_name", "last_name")->get();
|
||||
|
||||
$users_array = [];
|
||||
$users_collection = DB::table('users')->orderBy("first_name", "asc")->select("id")->get()->toArray();
|
||||
foreach ($users_collection as $value) {
|
||||
$user = User::find($value->id);
|
||||
if (!is_null($user)) {
|
||||
if ($user->hasRole('Doctors') || $user->hasRole('Doctor')) {
|
||||
//use this join query instead of the commented out query to cater for execution speed (N+1)
|
||||
$consultation_records = DB::table('services')
|
||||
->join('staff_payment_configurations', 'staff_payment_configurations.item_id', '=', 'services.id')
|
||||
->where('services.item_type', 'Consultation')
|
||||
->where('staff_payment_configurations.user_id', $value->id)
|
||||
->where('staff_payment_configurations.item_category', 3)
|
||||
->orderBy('staff_payment_configurations.created_at', 'asc')
|
||||
->select('services.*')
|
||||
->get();
|
||||
|
||||
foreach ($consultation_records as $record) {
|
||||
$users_consultation_fee = $record->non_insured_price;
|
||||
//concatnate the service_record_id with the users id to form the key for the array
|
||||
$users_array[$record->id . "__" . $value->id] = get_full_name($value->id, 'id', 'first_name', 'last_name', 'users') . " (Consultation Fee: " . ugandan_shillings($users_consultation_fee) . ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$users_array = ['' => '- select -'] + $users_array;
|
||||
$special_clinics = DB::table('clinics')->where('available', 1)->whereNull('deleted_at')->orderBy('name', 'asc')->pluck("name", "id")->prepend('- select -', '');
|
||||
|
||||
return view('patients::patients.follow_up', compact('calender_dates', 'clinics', 'users', 'users_array', 'special_clinics'));
|
||||
}
|
||||
|
||||
public function follow_up_fetch_patients(Request $request)
|
||||
{
|
||||
$selected_date = $request->selected_date;
|
||||
|
||||
if ($request->user_id != 0) {
|
||||
$follow_ups = PatientAppointment::where(['appointment_date' => $selected_date])->where(['incharge_id' => $request->user_id])->get();
|
||||
} else {
|
||||
$follow_ups = PatientAppointment::where(['appointment_date' => $selected_date])->get();
|
||||
}
|
||||
|
||||
$code = "";
|
||||
|
||||
if ($follow_ups->count() > 0) {
|
||||
foreach ($follow_ups as $follow_up) {
|
||||
|
||||
if ($request->clinic_id != -1) {
|
||||
if ($follow_up->clinic_allocation != $request->clinic_id) {
|
||||
// skip current loop
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$code .= "<tr>";
|
||||
$code .= "<td>";
|
||||
$code .= get_full_name($follow_up->patient_id, 'id', 'first_name', 'last_name', 'patients') . " (" . get_name($follow_up->patient_id, 'id', 'number', 'patients') . ")";
|
||||
$code .= "</td>";
|
||||
$code .= "<td>";
|
||||
$code .= ($follow_up->clinic_allocation == 0) ? "No clinic specified" : get_name($follow_up->clinic_allocation, 'id', 'name', 'clinics');
|
||||
$code .= "</td>";
|
||||
$code .= "<td>";
|
||||
$code .= ($follow_up->incharge_id == 0) ? "No incharge specified" : get_full_name($follow_up->incharge_id, 'id', 'first_name', 'last_name', 'users');
|
||||
$code .= "</td>";
|
||||
$code .= "<td>";
|
||||
$code .= $follow_up->appointment_time;
|
||||
$code .= "</td>";
|
||||
$code .= "<td>";
|
||||
$code .= "Phone Number: " . get_name($follow_up->patient_id, 'id', 'phone', 'patients') . " Email: " . get_name($follow_up->patient_id, 'id', 'email', 'patients');
|
||||
$code .= "</td>";
|
||||
$code .= "<td>";
|
||||
$code .= is_null($follow_up->comments) ? 'N/A' : $follow_up->comments;
|
||||
$code .= "</td>";
|
||||
$code .= "<td>";
|
||||
if ($follow_up->appointment_fulfilled == 1) {
|
||||
$code .= "<label class='label label-success'>Appointment Completed</label>";
|
||||
} else if ($follow_up->appointment_fulfilled == 2) {
|
||||
$code .= "<label class='label label-danger'>Appointment Cancelled</label>";
|
||||
} else {
|
||||
$code .= "<a class='btn btn-success btn-rounded' onclick='displayAppointmentActions(" . $follow_up->patient_id . "," . $follow_up->id . ")'>Actions</a>";
|
||||
}
|
||||
$code .= "</td>";
|
||||
$code .= "</tr>";
|
||||
}
|
||||
} else {
|
||||
$code .= "<tr><td colspan='8'><h4 class='text-center'>No patient appointments available for this date</h4></td></tr>";
|
||||
}
|
||||
|
||||
// check if the code is empty for when clinics selected are not available
|
||||
if ($code == '') {
|
||||
$code .= "<tr><td colspan='8'><h4 class='text-center'>No patient appointments available for this date</h4></td></tr>";
|
||||
}
|
||||
|
||||
return $code;
|
||||
}
|
||||
|
||||
public function create_appointment()
|
||||
{
|
||||
$clinics = Clinic::orderBy('name')->pluck("name", "id")->toArray();
|
||||
$clinics = ['0' => "Don't assign clinic"] + $clinics;
|
||||
|
||||
$users = User::orderBy('first_name')->select("id", "first_name", "last_name")->get();
|
||||
|
||||
return view('patients::patients.create_appointment', compact('clinics', 'users'));
|
||||
}
|
||||
|
||||
public function save_appointment(Request $request)
|
||||
{
|
||||
$appointment = new PatientAppointment();
|
||||
|
||||
if (is_null($request->in_charge)) {
|
||||
$in_charge = 0;
|
||||
} else {
|
||||
$in_charge = $request->in_charge;
|
||||
}
|
||||
|
||||
if (is_null($request->clinic_allocation)) {
|
||||
$clinic_allocation = 0;
|
||||
} else {
|
||||
$clinic_allocation = $request->clinic_allocation;
|
||||
}
|
||||
|
||||
$appointment->patient_id = $request->patient_id;
|
||||
$appointment->incharge_id = $in_charge;
|
||||
$appointment->clinic_allocation = $clinic_allocation;
|
||||
$appointment->episode_id = 0;
|
||||
$appointment->appointment_date = Carbon::parse($request->appointment_date)->format('Y-m-d');
|
||||
$appointment->appointment_time = $request->appointment_time;
|
||||
$appointment->comments = $request->comments;
|
||||
$appointment->created_from = "Patient Appointments";
|
||||
$appointment->created_by = Auth::user()->id;
|
||||
$appointment->updated_by = Auth::user()->id;
|
||||
|
||||
if ($appointment->save()) {
|
||||
flash("Patient appointment has been saved")->success();
|
||||
return redirect("/patients/follow_up");
|
||||
} else {
|
||||
flash("An error occurred!")->error();
|
||||
return back()->withInput();
|
||||
}
|
||||
}
|
||||
|
||||
public function complete_appointment($id)
|
||||
{
|
||||
$appointment = PatientAppointment::find($id);
|
||||
|
||||
$patient_id = $appointment->patient_id;
|
||||
|
||||
// reassign the appointment_fulfilled to 1
|
||||
$appointment->appointment_fulfilled = 1;
|
||||
$appointment->updated_by = Auth::user()->id;
|
||||
|
||||
if ($appointment->save()) {
|
||||
$episode = new PatientEpisode;
|
||||
$episode->patient_id = $appointment->patient_id;
|
||||
$episode->parent_episode_id = $appointment->episode_id == 0 ? null : $appointment->episode_id; //the original episode_id
|
||||
$episode->created_by = auth()->user()->id;
|
||||
$episode->updated_by = auth()->user()->id;
|
||||
//put this patient_id into session
|
||||
session()->put('patient_id', $patient_id);
|
||||
|
||||
try {
|
||||
$episode->save();
|
||||
flash("A new episode has been saved")->success();
|
||||
|
||||
//if the parent episode was an ANC visit then create a copy of previous anc registration and attach it to this episode
|
||||
$previous_anc_visit = \Streamline\Models\AnteNatalClinicFollowup::where(['patient_id' => $episode->patient_id, 'episode_id' => $episode->parent_episode_id])->first();
|
||||
if ($previous_anc_visit) {
|
||||
create_anc_registration_record_from_previous_visit($patient_id, $episode->parent_episode_id, $episode->id);
|
||||
//allocate to ANC clinic straight away
|
||||
$anc_clinic_id = get_name('ante_natal', 'slug', 'id', 'clinics');
|
||||
$episode->clinic_id = $anc_clinic_id;
|
||||
$episode->update();
|
||||
}
|
||||
|
||||
// check where the function was called from and return there
|
||||
if (isset($request->is_from_finance)) {
|
||||
// return to finance home
|
||||
return redirect('/patient_finance/home');
|
||||
} else {
|
||||
// return to normal patient home
|
||||
return redirect('/patient_episodes/');
|
||||
}
|
||||
} catch (QueryException $e) {
|
||||
flash("An error occurred")->error();
|
||||
return back()->withInput();
|
||||
}
|
||||
} else {
|
||||
flash("An error occurred!")->error();
|
||||
return back()->withInput();
|
||||
}
|
||||
}
|
||||
|
||||
public function cancel_patient_appointment($id)
|
||||
{
|
||||
$appointment = PatientAppointment::find($id);
|
||||
|
||||
// reassign the appointment_fulfilled to 2, indicating cancelled
|
||||
$appointment->appointment_fulfilled = 2;
|
||||
$appointment->updated_by = Auth::user()->id;
|
||||
|
||||
if ($appointment->save()) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public function reschedule_appointment($id)
|
||||
{
|
||||
$appointment = PatientAppointment::find($id);
|
||||
$clinics = Clinic::orderBy('name')->pluck("name", "id")->toArray();
|
||||
$clinics = ['0' => "Don't assign clinic"] + $clinics;
|
||||
|
||||
$users = User::orderBy('first_name')->select("id", "first_name", "last_name")->get();
|
||||
|
||||
return view('patients::patients.reschedule_appointment', compact('appointment', 'clinics', 'users'));
|
||||
}
|
||||
|
||||
public function save_rescheduled_appointment(Request $request)
|
||||
{
|
||||
$appointment = PatientAppointment::find($request->appointment_id);
|
||||
|
||||
if (is_null($request->in_charge)) {
|
||||
$in_charge = 0;
|
||||
} else {
|
||||
$in_charge = $request->in_charge;
|
||||
}
|
||||
|
||||
if (is_null($request->clinic_allocation)) {
|
||||
$clinic_allocation = 0;
|
||||
} else {
|
||||
$clinic_allocation = $request->clinic_allocation;
|
||||
}
|
||||
|
||||
$appointment->incharge_id = $in_charge;
|
||||
$appointment->clinic_allocation = $clinic_allocation;
|
||||
$appointment->appointment_date = Carbon::parse($request->appointment_date)->format('Y-m-d');
|
||||
$appointment->appointment_time = $request->appointment_time;
|
||||
$appointment->comments = $request->comments;
|
||||
$appointment->updated_by = Auth::user()->id;
|
||||
|
||||
if ($appointment->save()) {
|
||||
flash("Patient appointment has been rescheduled successfully")->success();
|
||||
return redirect("/patients/follow_up");
|
||||
} else {
|
||||
flash("An error occurred!")->error();
|
||||
return back()->withInput();
|
||||
}
|
||||
}
|
||||
|
||||
public function appointment_requests()
|
||||
{
|
||||
$appointments = PatientAppointment::where('is_confirmed', 0)
|
||||
->whereNotIn('appointment_fulfilled', [2])
|
||||
->where('appointment_date', '>', date('Y-m-d'))
|
||||
->get();
|
||||
|
||||
return view('patients::patients.appointment_requests', compact('appointments'));
|
||||
}
|
||||
|
||||
public function confirm_appointment($id)
|
||||
{
|
||||
$appointment = PatientAppointment::find($id);
|
||||
$clinics = Clinic::orderBy('name')->pluck("name", "id")->toArray();
|
||||
$clinics = ['0' => "Don't assign clinic"] + $clinics;
|
||||
|
||||
$users = User::orderBy('first_name')->select("id", "first_name", "last_name")->get();
|
||||
|
||||
return view('patients::patients.confirm_appointment', compact('appointment', 'clinics', 'users'));
|
||||
}
|
||||
|
||||
public function save_confirmed_appointment(Request $request)
|
||||
{
|
||||
$appointment = PatientAppointment::find($request->appointment_id);
|
||||
|
||||
if (is_null($request->in_charge)) {
|
||||
$in_charge = 0;
|
||||
} else {
|
||||
$in_charge = $request->in_charge;
|
||||
}
|
||||
|
||||
if (is_null($request->clinic_allocation)) {
|
||||
$clinic_allocation = 0;
|
||||
} else {
|
||||
$clinic_allocation = $request->clinic_allocation;
|
||||
}
|
||||
|
||||
$appointment->incharge_id = $in_charge;
|
||||
$appointment->clinic_allocation = $clinic_allocation;
|
||||
$appointment->appointment_date = Carbon::parse($request->appointment_date)->format('Y-m-d');
|
||||
$appointment->appointment_time = $request->appointment_time;
|
||||
$appointment->comments = $request->comments;
|
||||
$appointment->is_confirmed = 1;
|
||||
$appointment->updated_by = auth()->id();
|
||||
|
||||
if ($appointment->save()) {
|
||||
if (is_sms_enabled()) {
|
||||
// send sms alert to the patient
|
||||
$sms = "Your appointment at " . get_name(1, 'id', 'name', 'hospital_information') .
|
||||
" has been confirmed for the " . streamline_date($appointment->appointment_date) . " at " . $appointment->appointment_time;
|
||||
|
||||
(new SMSController)->send_appointments_alert($appointment->patient_id, $sms);
|
||||
}
|
||||
|
||||
flash("Patient appointment has been confirmed")->success();
|
||||
return redirect("/patients/appointment_requests");
|
||||
} else {
|
||||
flash("An error occurred!")->error();
|
||||
return back()->withInput();
|
||||
}
|
||||
}
|
||||
|
||||
public function patient_appointments_report(Request $request)
|
||||
{
|
||||
$clinic_id = $request->clinic_id;
|
||||
$search_by = $request->search_by;
|
||||
$reg_date = $request->reg_date;
|
||||
$start_date = $request->start_date;
|
||||
$end_date = $request->end_date;
|
||||
//dd($request->all());
|
||||
$clinics = Clinic::where('available', 1)->pluck('name', 'id')->prepend(['' => 'All clinics']);
|
||||
|
||||
$today = Carbon::now()->toDateString();
|
||||
|
||||
$filters = [];
|
||||
$clinic_name = Clinic::where('id', $clinic_id)->pluck('name')->first();
|
||||
|
||||
if ($search_by == 0) {
|
||||
array_push($filters, ['appointment_date', '<', $today]);
|
||||
} elseif ($search_by == 1) {
|
||||
// custom date
|
||||
$start_date_search = Carbon::parse($reg_date)->toDateString();
|
||||
array_push($filters, ['appointment_date', '=', $start_date_search]);
|
||||
} elseif ($search_by == 2) {
|
||||
// custom date range
|
||||
$start_date_search = Carbon::parse($start_date)->toDateString();
|
||||
$end_date_search = Carbon::parse($end_date)->toDateString();
|
||||
|
||||
array_push($filters, ['appointment_date', '>', $start_date_search]);
|
||||
array_push($filters, ['appointment_date', '<', $end_date_search]);
|
||||
} else {
|
||||
array_push($filters, ['appointment_date', '<', $today]);
|
||||
}
|
||||
|
||||
if ($clinic_id == 0 || is_null($clinic_id)) {
|
||||
if ($request->appointment_outcome != 'all') {
|
||||
$patient_appointments = PatientAppointment::where($filters)->where(['appointment_fulfilled' => $request->appointment_outcome])->orderBy('appointment_date', 'desc')->paginate(500);
|
||||
} else {
|
||||
$patient_appointments = PatientAppointment::where($filters)->orderBy('appointment_date', 'desc')->paginate(500);
|
||||
}
|
||||
} else {
|
||||
if ($request->appointment_outcome != 'all') {
|
||||
$patient_appointments = PatientAppointment::where(['clinic_allocation' => $clinic_id])->where(['appointment_fulfilled' => $request->appointment_outcome])->where($filters)->orderBy('appointment_date', 'desc')->paginate(400);
|
||||
} else {
|
||||
$patient_appointments = PatientAppointment::where(['clinic_allocation' => $clinic_id])->where($filters)->orderBy('appointment_date', 'desc')->paginate(400);
|
||||
}
|
||||
}
|
||||
|
||||
return view('patients::patients.appointments_report', compact('clinics', 'patient_appointments'));
|
||||
}
|
||||
|
||||
public function store_appointment_comment(Request $request)
|
||||
{
|
||||
$appointment_id = $request->set_appointment_id;
|
||||
$appointment_comment = $request->appointment_comment;
|
||||
|
||||
$appointment = PatientAppointment::find($appointment_id);
|
||||
$appointment->action_comment = $appointment_comment;
|
||||
$appointment->action_comment_by = Auth::user()->id;
|
||||
|
||||
if ($appointment->save()) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
+210
-147
@@ -43,6 +43,13 @@ use Streamline\Models\User;
|
||||
use Streamline\Models\Consultation;
|
||||
use Streamline\Models\OrderedSundry;
|
||||
use Streamline\Models\Services;
|
||||
use Streamline\Models\WardInpatientDetailedNote;
|
||||
use Streamline\Models\GeneralSettings;
|
||||
use Streamline\Models\DischargeMortalityRisk;
|
||||
use Barryvdh\DomPDF\Facade\Pdf as DomPDF;
|
||||
|
||||
|
||||
|
||||
|
||||
class PatientEpisodeController extends Controller
|
||||
{
|
||||
@@ -71,7 +78,7 @@ class PatientEpisodeController extends Controller
|
||||
$categories = DB::table('patient_categories')->where('available', 1)->pluck("name", "id");
|
||||
$marital_statuses = DB::table('marital_statuses')->pluck("name", "id");
|
||||
$diagnoses = DB::table('diagnoses')->where('available', 1)->pluck("name", "id");
|
||||
$clinics = DB::table('clinics')->pluck("name", "id")->prepend('- select -', '');;
|
||||
$clinics = DB::table('clinics')->pluck("name", "id")->prepend('- select -', '');
|
||||
$relationships = DB::table('family_relations')->pluck('name', 'id');
|
||||
$occupations = DB::table('occupations')->pluck('name', 'id');
|
||||
$patient_categories = DB::table('patient_categories')->where('available', 1)->pluck('name', 'id');
|
||||
@@ -86,7 +93,7 @@ class PatientEpisodeController extends Controller
|
||||
$known_patient_alerts = Alert::where('patient_id', $patient_id)->orderBy('created_at', 'desc')->take(2)->get();
|
||||
$drug_categories_array = DB::table('drug_categories')->pluck('name', 'id');
|
||||
//$special_clinics = DB::table('clinics')->where('slug', '!=', 'general')->pluck("name", "id")->prepend('GENERAL OPD', 'general_opd')->prepend('- select -', '');
|
||||
$special_clinics = DB::table('clinics')->where('available', 1)->whereNull('deleted_at')->pluck("name", "id")->prepend('- select -', '');
|
||||
$special_clinics = DB::table('clinics')->where('available', 1)->whereNull('deleted_at')->orderBy('name', 'asc')->pluck("name", "id")->prepend('- select -', '');
|
||||
$wards = DB::table('wards')->where('available', 1)->whereNull('deleted_at')->pluck("name", "id")->prepend('- select -', '');
|
||||
$users_collection = DB::table('users')->orderBy("first_name", "asc")->select("id")->get()->toArray();
|
||||
$users_array = [];
|
||||
@@ -209,11 +216,8 @@ class PatientEpisodeController extends Controller
|
||||
return redirect('/patient_episodes/');
|
||||
}
|
||||
} catch (QueryException $e) {
|
||||
$errorCode = $e->errorInfo[1];
|
||||
if ($errorCode == 1062) { //error code for duplicate entry to a unique field
|
||||
flash("This episode already exists!")->error();
|
||||
return back()->withInput();
|
||||
}
|
||||
flash("An error occurred")->error();
|
||||
return back()->withInput();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -238,7 +242,6 @@ class PatientEpisodeController extends Controller
|
||||
*/
|
||||
public function route_patient_episode(Request $request)
|
||||
{
|
||||
|
||||
//set session for episode_id
|
||||
session()->put('episode_id', $request->episode_id);
|
||||
$is_patient_allowed_to_do_consultation = $this->is_patient_allowed_to_have_consultation(session()->get('patient_id'), $request->episode_id);
|
||||
@@ -315,7 +318,7 @@ class PatientEpisodeController extends Controller
|
||||
case 'base_refraction_exam':
|
||||
return redirect('/eye_clinic/base_exam_refraction');
|
||||
case 'eye_glasses':
|
||||
return redirect('/eye_glasses/order');
|
||||
return redirect('/opticals/order');
|
||||
case 'treatment_sheet':
|
||||
session()->put(['treatment_sheet_route' => 'patient_home']);
|
||||
return redirect('treatment_sheet/view');
|
||||
@@ -447,7 +450,7 @@ class PatientEpisodeController extends Controller
|
||||
$service_order->updated_by = auth()->user()->id;
|
||||
$service_order->save();
|
||||
|
||||
$episode->consultation_id = $consultation->id;
|
||||
$episode->consultation_id = $consultation_record->id;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -520,11 +523,8 @@ class PatientEpisodeController extends Controller
|
||||
|
||||
return redirect('/patient_episodes/');
|
||||
} catch (QueryException $e) {
|
||||
$errorCode = $e->errorInfo[1];
|
||||
if ($errorCode == 1062) { //error code for duplicate entry to a unique field
|
||||
flash("This episode already exists!")->error();
|
||||
return back()->withInput();
|
||||
}
|
||||
flash("An error occurred")->error();
|
||||
return back()->withInput();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -560,11 +560,8 @@ class PatientEpisodeController extends Controller
|
||||
flash("Patient admitted in " . $ward_name)->success();
|
||||
return redirect('/patient_episodes/');
|
||||
} catch (QueryException $e) {
|
||||
$errorCode = $e->errorInfo[1];
|
||||
if ($errorCode == 1062) { //error code for duplicate entry to a unique field
|
||||
flash("This episode already exists!")->error();
|
||||
return back()->withInput();
|
||||
}
|
||||
flash("An error occurred")->error();
|
||||
return back()->withInput();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -749,11 +746,8 @@ class PatientEpisodeController extends Controller
|
||||
|
||||
return redirect('/patient_episodes/');
|
||||
} catch (QueryException $e) {
|
||||
$errorCode = $e->errorInfo[1];
|
||||
if ($errorCode == 1062) { //error code for duplicate entry to a unique field
|
||||
flash("This episode already exists!")->error();
|
||||
return back()->withInput();
|
||||
}
|
||||
flash("An error occurred")->error();
|
||||
return back()->withInput();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -775,17 +769,18 @@ class PatientEpisodeController extends Controller
|
||||
flash("Episode has started")->success();
|
||||
return redirect('/investigations/investigations_review');
|
||||
} catch (QueryException $e) {
|
||||
$errorCode = $e->errorInfo[1];
|
||||
if ($errorCode == 1062) { //error code for duplicate entry to a unique field
|
||||
flash("This episode already exists!")->error();
|
||||
return back()->withInput();
|
||||
}
|
||||
flash("An error occurred")->error();
|
||||
return back()->withInput();
|
||||
}
|
||||
}
|
||||
|
||||
public function episode_summary($episode_id)
|
||||
{
|
||||
$patient_id = session()->get('patient_id');
|
||||
$general_settings = json_decode(GeneralSettings::find(1)->data, true);
|
||||
$episode_summary_content_setting = $general_settings['episode_summary_content'] ?? '';
|
||||
|
||||
|
||||
|
||||
if(is_eye_module_enabled() && is_patient_in_eye_clinic($episode_id)) {
|
||||
$main_exam = EyeClinicMainExam::where(['patient_id' => $patient_id, 'episode_id' => $episode_id])->first();
|
||||
@@ -813,10 +808,35 @@ class PatientEpisodeController extends Controller
|
||||
$sundries_results = Sundry::select('id', 'name')->get();
|
||||
/* Patient File : It should show Diagnosis, Prescriptions, Lab results, Procedures */
|
||||
$consultation = Consultation::where(['patient_id' => $patient_id, 'episode_id' => $episode_id])->first();
|
||||
$treatments = Treatment::where(["patient_id" => $patient_id, "episode_id" => $episode_id])->get(); //fetch treatment the way Douglas fetches it in printing the treatment receipt
|
||||
$ordered_procedures = OrderedProcedure::where(['patient_id' => $patient_id, 'episode_id' => $episode_id])->get();
|
||||
$ordered_sundries = OrderedSundry::where(['patient_id' => $patient_id, 'episode_id' => $episode_id])->get();
|
||||
$ordered_services = OrderedService::where(['patient_id' => $patient_id, 'episode_id' => $episode_id])->get();
|
||||
|
||||
$treatments = null;
|
||||
if (is_array($episode_summary_content_setting) && in_array(10, $episode_summary_content_setting ?? '') ){
|
||||
$treatments = Treatment::where(["patient_id" => $patient_id, "episode_id" => $episode_id])->get();
|
||||
|
||||
}
|
||||
|
||||
|
||||
$ordered_procedures = null;
|
||||
|
||||
|
||||
if (is_array($episode_summary_content_setting) && in_array(4, $episode_summary_content_setting ?? '') ){
|
||||
$ordered_procedures = OrderedProcedure::where(['patient_id' => $patient_id, 'episode_id' => $episode_id])->get();
|
||||
|
||||
}
|
||||
|
||||
|
||||
$ordered_sundries = null;
|
||||
if (is_array($episode_summary_content_setting) && in_array(8, $episode_summary_content_setting ?? '') ){
|
||||
$ordered_sundries = OrderedSundry::where(['patient_id' => $patient_id, 'episode_id' => $episode_id])->get();
|
||||
}
|
||||
|
||||
|
||||
$ordered_services = null;
|
||||
if (is_array($episode_summary_content_setting) && in_array(6, $episode_summary_content_setting ?? '') ){
|
||||
$ordered_services = OrderedService::where(['patient_id' => $patient_id, 'episode_id' => $episode_id])->get();
|
||||
}
|
||||
|
||||
|
||||
$inpatient_infos = InpatientInfo::where(['patient_id' => $patient_id, 'episode_id' => $episode_id])->get();
|
||||
$antenatal_data = DB::table('ante_natal_clinic_followups')->where(['patient_id' => $patient_id, 'episode_id' => $episode_id])->first();
|
||||
|
||||
@@ -833,67 +853,47 @@ class PatientEpisodeController extends Controller
|
||||
|
||||
//triage details
|
||||
$triage = null;
|
||||
if ($episode && $episode->triage_id) {
|
||||
$triage = \Streamline\Models\Triage::where(['id' => $episode->triage_id])->first();
|
||||
}
|
||||
if (is_array($episode_summary_content_setting) && in_array(3, $episode_summary_content_setting ?? '') ){
|
||||
if ($episode && $episode->triage_id) {
|
||||
$triage = \Streamline\Models\Triage::where(['id' => $episode->triage_id])->first();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// get all symptoms
|
||||
$symptoms = DB::table('symptoms')->where('available', 1)->pluck("name", "id");
|
||||
$symptoms = '';
|
||||
if (is_array($episode_summary_content_setting) && in_array(5, $episode_summary_content_setting ?? '') ){
|
||||
$symptoms = DB::table('symptoms')->where('available', 1)->pluck("name", "id");
|
||||
}
|
||||
|
||||
|
||||
foreach ($ordered_investigations as $investigation) {
|
||||
$investigation_ids = explode(",", $investigation->investigation_id);
|
||||
$inpatient_status = explode(",", $investigation->for_inpatient);
|
||||
// investigations setting check
|
||||
if (is_array($episode_summary_content_setting) && in_array(2, $episode_summary_content_setting ?? '') ){
|
||||
foreach ($ordered_investigations as $investigation) {
|
||||
$investigation_ids = explode(",", $investigation->investigation_id);
|
||||
$inpatient_status = explode(",", $investigation->for_inpatient);
|
||||
|
||||
// check if results are available for this investigation
|
||||
if (in_array($investigation->id, $investigation_results_order_ids)) {
|
||||
// get the key if available
|
||||
$key = array_search($investigation->id, $investigation_results_order_ids);
|
||||
// check if results are available for this investigation
|
||||
if (in_array($investigation->id, $investigation_results_order_ids)) {
|
||||
// get the key if available
|
||||
$key = array_search($investigation->id, $investigation_results_order_ids);
|
||||
|
||||
// get the results object
|
||||
$results = InvestigationResults::find($key);
|
||||
// get the results object
|
||||
$results = InvestigationResults::find($key);
|
||||
|
||||
// exclude obstetric u/s results
|
||||
if ($results->result_type != "Ultrasound_Obstetric") {
|
||||
$investigation_results = explode(",", $results->value);
|
||||
$investigation_per_valid = explode(",", $results->per_investigation);
|
||||
$investigation_comments = explode(",", $results->comment);
|
||||
// exclude obstetric u/s results
|
||||
if ($results->result_type != "Ultrasound_Obstetric") {
|
||||
$investigation_results = explode(",", $results->value);
|
||||
$investigation_per_valid = explode(",", $results->per_investigation);
|
||||
$investigation_comments = explode(",", $results->comment);
|
||||
|
||||
if ($results->all_authenticated == 1) {
|
||||
for ($i = 0; $i < count($inpatient_status); $i++) {
|
||||
if ($inpatient_status[$i] == 0) {
|
||||
if (isset($investigation_ids[$i]) && $investigation_ids[$i] != "") {
|
||||
$result = Investigation::where('id', $investigation_ids[$i])->first();
|
||||
$opd_investigations['name'][] = $result->name;
|
||||
$opd_investigations['value'][] = $investigation_results[$i];
|
||||
$opd_investigations['comment'][] = $investigation_comments[$i];
|
||||
|
||||
if($result->range_type == 1) {
|
||||
$opd_investigations['normal_ranges'][] = get_dynamic_normal_range($result->id, get_patient_age_group($patient_id), get_name($patient_id, 'id', 'gender', 'patients'));
|
||||
} else {
|
||||
$opd_investigations['normal_ranges'][] = $result->normal_ranges;
|
||||
}
|
||||
|
||||
$opd_investigations['type'][] = $result->type;
|
||||
}
|
||||
} else {
|
||||
if (isset($investigation_ids[$i]) && $investigation_ids[$i] != "") {
|
||||
$result = Investigation::where('id', $investigation_ids[$i])->first();
|
||||
$ward_investigations['name'][] = $result->name;
|
||||
$ward_investigations['value'][] = $investigation_results[$i];
|
||||
$ward_investigations['comment'][] = $investigation_comments[$i];
|
||||
$ward_investigations['type'][] = $result->type;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for ($i = 0; $i < count($inpatient_status); $i++) {
|
||||
if ($investigation_per_valid[$i] == 1) {
|
||||
// this investigation is authenticated
|
||||
if ($results->all_authenticated == 1) {
|
||||
for ($i = 0; $i < count($inpatient_status); $i++) {
|
||||
if ($inpatient_status[$i] == 0) {
|
||||
if (isset($investigation_ids[$i]) && $investigation_ids[$i] != "") {
|
||||
$result = Investigation::where('id', $investigation_ids[$i])->first();
|
||||
$opd_investigations['name'][] = $result->name;
|
||||
$opd_investigations['value'][] = $investigation_results[$i];
|
||||
$opd_investigations['comment'][] = $investigation_comments[$i];
|
||||
|
||||
if($result->range_type == 1) {
|
||||
$opd_investigations['normal_ranges'][] = get_dynamic_normal_range($result->id, get_patient_age_group($patient_id), get_name($patient_id, 'id', 'gender', 'patients'));
|
||||
@@ -901,7 +901,6 @@ class PatientEpisodeController extends Controller
|
||||
$opd_investigations['normal_ranges'][] = $result->normal_ranges;
|
||||
}
|
||||
|
||||
$opd_investigations['comment'][] = $investigation_comments[$i];
|
||||
$opd_investigations['type'][] = $result->type;
|
||||
}
|
||||
} else {
|
||||
@@ -913,69 +912,117 @@ class PatientEpisodeController extends Controller
|
||||
$ward_investigations['type'][] = $result->type;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ($inpatient_status[$i] == 0) {
|
||||
if (isset($investigation_ids[$i]) && $investigation_ids[$i] != "") {
|
||||
$result = Investigation::where('id', $investigation_ids[$i])->first();
|
||||
$opd_investigations['name'][] = $result->name;
|
||||
$opd_investigations['value'][] = "Pending";
|
||||
}
|
||||
} else {
|
||||
for ($i = 0; $i < count($inpatient_status); $i++) {
|
||||
if ($investigation_per_valid[$i] == 1) {
|
||||
// this investigation is authenticated
|
||||
if ($inpatient_status[$i] == 0) {
|
||||
if (isset($investigation_ids[$i]) && $investigation_ids[$i] != "") {
|
||||
$result = Investigation::where('id', $investigation_ids[$i])->first();
|
||||
$opd_investigations['name'][] = $result->name;
|
||||
$opd_investigations['value'][] = $investigation_results[$i];
|
||||
|
||||
if($result->range_type == 1) {
|
||||
$opd_investigations['normal_ranges'][] = get_dynamic_normal_range($result->id, get_patient_age_group($patient_id), get_name($patient_id, 'id', 'gender', 'patients'));
|
||||
} else {
|
||||
$opd_investigations['normal_ranges'][] = $result->normal_ranges;
|
||||
if($result->range_type == 1) {
|
||||
$opd_investigations['normal_ranges'][] = get_dynamic_normal_range($result->id, get_patient_age_group($patient_id), get_name($patient_id, 'id', 'gender', 'patients'));
|
||||
} else {
|
||||
$opd_investigations['normal_ranges'][] = $result->normal_ranges;
|
||||
}
|
||||
|
||||
$opd_investigations['comment'][] = $investigation_comments[$i];
|
||||
$opd_investigations['type'][] = $result->type;
|
||||
}
|
||||
} else {
|
||||
if (isset($investigation_ids[$i]) && $investigation_ids[$i] != "") {
|
||||
$result = Investigation::where('id', $investigation_ids[$i])->first();
|
||||
$ward_investigations['name'][] = $result->name;
|
||||
$ward_investigations['value'][] = $investigation_results[$i];
|
||||
$ward_investigations['comment'][] = $investigation_comments[$i];
|
||||
$ward_investigations['type'][] = $result->type;
|
||||
}
|
||||
|
||||
$opd_investigations['comment'][] = "Pending";
|
||||
}
|
||||
} else {
|
||||
if (isset($investigation_ids[$i]) && $investigation_ids[$i] != "") {
|
||||
$result = Investigation::where('id', $investigation_ids[$i])->first();
|
||||
$ward_investigations['name'][] = $result->name;
|
||||
$ward_investigations['value'][] = "Pending";
|
||||
$ward_investigations['comment'][] = "Pending";
|
||||
if ($inpatient_status[$i] == 0) {
|
||||
if (isset($investigation_ids[$i]) && $investigation_ids[$i] != "") {
|
||||
$result = Investigation::where('id', $investigation_ids[$i])->first();
|
||||
$opd_investigations['name'][] = $result->name;
|
||||
$opd_investigations['value'][] = "Pending";
|
||||
|
||||
if($result->range_type == 1) {
|
||||
$opd_investigations['normal_ranges'][] = get_dynamic_normal_range($result->id, get_patient_age_group($patient_id), get_name($patient_id, 'id', 'gender', 'patients'));
|
||||
} else {
|
||||
$opd_investigations['normal_ranges'][] = $result->normal_ranges;
|
||||
}
|
||||
|
||||
$opd_investigations['comment'][] = "Pending";
|
||||
}
|
||||
} else {
|
||||
if (isset($investigation_ids[$i]) && $investigation_ids[$i] != "") {
|
||||
$result = Investigation::where('id', $investigation_ids[$i])->first();
|
||||
$ward_investigations['name'][] = $result->name;
|
||||
$ward_investigations['value'][] = "Pending";
|
||||
$ward_investigations['comment'][] = "Pending";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for ($i = 0; $i < count($inpatient_status); $i++) {
|
||||
if ($inpatient_status[$i] == 0) {
|
||||
if (isset($investigation_ids[$i]) && $investigation_ids[$i] != "") {
|
||||
$result = Investigation::where('id', $investigation_ids[$i])->first();
|
||||
$opd_investigations['name'][] = $result->name;
|
||||
$opd_investigations['value'][] = "Pending";
|
||||
} else {
|
||||
for ($i = 0; $i < count($inpatient_status); $i++) {
|
||||
if ($inpatient_status[$i] == 0) {
|
||||
if (isset($investigation_ids[$i]) && $investigation_ids[$i] != "") {
|
||||
$result = Investigation::where('id', $investigation_ids[$i])->first();
|
||||
$opd_investigations['name'][] = $result->name;
|
||||
$opd_investigations['value'][] = "Pending";
|
||||
|
||||
if($result->range_type == 1) {
|
||||
$opd_investigations['normal_ranges'][] = get_dynamic_normal_range($result->id, get_patient_age_group($patient_id), get_name($patient_id, 'id', 'gender', 'patients'));
|
||||
} else {
|
||||
$opd_investigations['normal_ranges'][] = $result->normal_ranges;
|
||||
if($result->range_type == 1) {
|
||||
$opd_investigations['normal_ranges'][] = get_dynamic_normal_range($result->id, get_patient_age_group($patient_id), get_name($patient_id, 'id', 'gender', 'patients'));
|
||||
} else {
|
||||
$opd_investigations['normal_ranges'][] = $result->normal_ranges;
|
||||
}
|
||||
|
||||
$opd_investigations['comment'][] = "Pending";
|
||||
}
|
||||
} else {
|
||||
if (isset($investigation_ids[$i]) && $investigation_ids[$i] != "") {
|
||||
$result = Investigation::where('id', $investigation_ids[$i])->first();
|
||||
$ward_investigations['name'][] = $result->name;
|
||||
$ward_investigations['value'][] = "Pending";
|
||||
$ward_investigations['comment'][] = "Pending";
|
||||
}
|
||||
|
||||
$opd_investigations['comment'][] = "Pending";
|
||||
}
|
||||
} else {
|
||||
if (isset($investigation_ids[$i]) && $investigation_ids[$i] != "") {
|
||||
$result = Investigation::where('id', $investigation_ids[$i])->first();
|
||||
$ward_investigations['name'][] = $result->name;
|
||||
$ward_investigations['value'][] = "Pending";
|
||||
$ward_investigations['comment'][] = "Pending";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$discharge_mortality_risk = null;
|
||||
$priority_signs_records = null;
|
||||
$emergency_signs = null;
|
||||
$emergencySigns = null;
|
||||
|
||||
if(between($years, 0, 12)) {
|
||||
$priority_signs_records = PrioritySign::where('triage_id', $episode->triage_id)->first();
|
||||
|
||||
|
||||
if (is_array($episode_summary_content_setting) && in_array(9, $episode_summary_content_setting ?? '') ){
|
||||
$priority_signs_records = PrioritySign::where('triage_id', $episode->triage_id)->first();
|
||||
|
||||
}
|
||||
|
||||
if ($priority_signs_records) {
|
||||
$priority_signs = unserialize($priority_signs_records->signs);
|
||||
}
|
||||
|
||||
$emergency_signs = EmergencySign::where('triage_id', $episode->triage_id)->first();
|
||||
|
||||
|
||||
if (is_array($episode_summary_content_setting) && in_array(11, $episode_summary_content_setting ?? '') ){
|
||||
$emergency_signs = EmergencySign::where('triage_id', $episode->triage_id)->first();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (!empty($emergency_signs)) {
|
||||
$airway = unserialize($emergency_signs->airway);
|
||||
$circulation = unserialize($emergency_signs->circulation);
|
||||
@@ -983,10 +1030,22 @@ class PatientEpisodeController extends Controller
|
||||
$dehydration = unserialize($emergency_signs->dehydration);
|
||||
$emergencySigns= array_merge($airway,$circulation, $dehydration,$neurological);
|
||||
foreach($emergencySigns as $key => $sign) if($sign == 'Yes') $emergent_signs[] = $key;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (is_array($episode_summary_content_setting) && in_array(13, $episode_summary_content_setting ?? '') ){
|
||||
$discharge_mortality_risk = DischargeMortalityRisk::where(['patient_id' => $patient_id, 'episode_id' => $episode_id])->first();
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
$cons_notes = [];
|
||||
if (is_array($episode_summary_content_setting) && in_array(12, $episode_summary_content_setting ?? '') ){
|
||||
$cons_notes = WardInpatientDetailedNote::where(['patient_id' => $patient_id, 'episode_id' => $episode_id, 'ward_id' => 0])->latest()->get(['investigation_and_management_plan_comments', 'clinic_examination_comments', 'history_comments', 'created_by','created_at']);
|
||||
}
|
||||
|
||||
$data = [
|
||||
'main_exam' => $main_exam,
|
||||
@@ -1016,9 +1075,15 @@ class PatientEpisodeController extends Controller
|
||||
'triage' =>$triage,
|
||||
'priority_signs' => $priority_signs,
|
||||
'emergent_signs'=> $emergent_signs,
|
||||
'years'=>$years
|
||||
'discharge_mortality_risk' => $discharge_mortality_risk,
|
||||
'cons_notes' => $cons_notes,
|
||||
'years'=>$years,
|
||||
'episode_summary_content_setting' => $episode_summary_content_setting,
|
||||
];
|
||||
|
||||
|
||||
// return view('patients::patient_episodes/episode_summary', $data);
|
||||
|
||||
$pdf = SnappyPDF::loadView('patients::patient_episodes/episode_summary', $data)
|
||||
->setOrientation('portrait')
|
||||
->setOption('margin-bottom', 7)
|
||||
@@ -1198,16 +1263,9 @@ class PatientEpisodeController extends Controller
|
||||
return redirect('/patient_episodes/');
|
||||
}
|
||||
} catch (QueryException $e) {
|
||||
$errorCode = $e->errorInfo[1];
|
||||
if ($errorCode == 1062) { //error code for duplicate entry to a unique field
|
||||
flash("This episode already exists!")->error();
|
||||
return back()->withInput();
|
||||
}
|
||||
flash("An error occurred")->error();
|
||||
return back()->withInput();
|
||||
}
|
||||
/*================= end of creation of new episode on starting an appointment =================*/
|
||||
|
||||
flash("Patient follow up completed successfully")->success();
|
||||
return redirect('/patient_episodes/set_patient_id/' . $patient_id);
|
||||
} else {
|
||||
flash("An error occurred!")->error();
|
||||
return back()->withInput();
|
||||
@@ -1241,7 +1299,7 @@ class PatientEpisodeController extends Controller
|
||||
|
||||
$diagnoses = DB::table('diagnoses')->where('available', 1)->pluck("name", "id");
|
||||
$clinics = DB::table('clinics')->pluck("name", "id")->prepend('- select -', '');
|
||||
$special_clinics = DB::table('clinics')->where('available', 1)->whereNull('deleted_at')->pluck("name", "id")->prepend('- select -', '');
|
||||
$special_clinics = DB::table('clinics')->where('available', 1)->whereNull('deleted_at')->orderBy('name', 'asc')->pluck("name", "id")->prepend('- select -', '');
|
||||
$wards = DB::table('wards')->where('available', 1)->pluck("name", "id")->prepend('- select -', '');
|
||||
$users_collection = DB::table('users')->orderBy("first_name", "asc")->select("id")->get()->toArray();
|
||||
$users_array = [];
|
||||
@@ -1595,7 +1653,9 @@ class PatientEpisodeController extends Controller
|
||||
$ordered_sundry->episode_id = $episode_id_to_keep;
|
||||
$ordered_sundry->update();
|
||||
}
|
||||
$tables = ['ward_inpatient_sheet_nurse_comments', 'ward_inpatient_detailed_notes', 'ward_dispensing_per_charts', 'patient_documents', 'patient_one_off_discounts', 'triage_nutrition', 'triage_news', 'surgeries', 'sundries_deposits', 'smart_triage', 'patient_refunds', 'patient_account_consumptions', 'patient_appointments', 'phone_followup_patients', 'point_of_sale_records', 'procedure_deposits', 'cancel_patient_transactions', 'central_billing_deposits', 'chronic_patients', 'chi_deposits', 'debtors', 'debt_plan', 'dependants_consumptions', 'family_account_consumptions', 'inpatient_attendant_passes', 'inpatient_ward_discounts', 'inpatient_sheet_audits', 'maternity_delivery_records', 'maternity_inpatients', 'mental_health_consultation', 'ordered_investigations', 'ordered_procedures'];
|
||||
|
||||
// TODO Refactor this merge to be in a separate controller and remove repeated table throughs by using one-to-many relationships
|
||||
$tables = ['ward_inpatient_sheet_nurse_comments', 'ward_inpatient_detailed_notes', 'patient_documents', 'patient_one_off_discounts', 'triage_nutrition', 'triage_news', 'surgeries', 'sundries_deposits', 'smart_triage', 'patient_refunds', 'patient_account_consumptions', 'patient_appointments', 'phone_followup_patients', 'point_of_sale_records', 'procedure_deposits', 'cancel_patient_transactions', 'central_billing_deposits', 'chronic_patients', 'chi_deposits', 'debtors', 'debt_plan', 'dependants_consumptions', 'family_account_consumptions', 'inpatient_attendant_passes', 'inpatient_ward_discounts', 'inpatient_sheet_audits', 'maternity_delivery_records', 'maternity_inpatients', 'mental_health_consultation', 'ordered_investigations', 'ordered_procedures'];
|
||||
foreach ($tables as $table) {
|
||||
$episodes = DB::table($table)->where('episode_id', $episode_id_to_delete)->get();
|
||||
foreach ($episodes as $episode) DB::table($table)->where('id', $episode->id)->update(['episode_id' => $episode_id_to_keep]);
|
||||
@@ -1616,12 +1676,15 @@ class PatientEpisodeController extends Controller
|
||||
|
||||
public function check_clinical_consultation_payment(Request $request)
|
||||
{
|
||||
$service_deposit = \Streamline\Models\ServiceDeposit::where('episode_id', $request->episode_id)->first();
|
||||
if ($service_deposit) {
|
||||
return "paid";
|
||||
}
|
||||
|
||||
return "unpaid";
|
||||
$is_patient_allowed_to_do_consultation = $this->is_patient_allowed_to_have_consultation($request->patient_id, $request->episode_id);
|
||||
if ($is_patient_allowed_to_do_consultation) {
|
||||
if($request->action == 'consultation_with_notes') session()->put('consultation_with_notes', 1);
|
||||
else session()->put('consultation_with_notes', 0);
|
||||
session()->put(['patient_id' => $request->patient_id]);
|
||||
session()->put(['episode_id' => $request->episode_id]);
|
||||
return response()->json('/consultation/route');
|
||||
}
|
||||
else return response()->json("unpaid");
|
||||
}
|
||||
|
||||
public function is_patient_allowed_to_have_consultation($patient_id, $episode_id)
|
||||
|
||||
+14
-7
@@ -5,6 +5,7 @@ namespace Modules\Patients\Http\Controllers;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\View\View;
|
||||
use Streamline\Models\Clinic;
|
||||
use Streamline\Models\PatientEpisode;
|
||||
use Streamline\Models\InpatientInfo;
|
||||
@@ -18,7 +19,8 @@ class PatientFlowMonitoringController extends Controller {
|
||||
$this->middleware('permission:patient-flow-monitoring');
|
||||
}
|
||||
|
||||
public function index(Request $request){
|
||||
public function index(Request $request): View
|
||||
{
|
||||
$clinic_id = $request->clinic_id;
|
||||
$search_by = $request->search_by;
|
||||
$reg_date = $request->reg_date;
|
||||
@@ -42,11 +44,13 @@ class PatientFlowMonitoringController extends Controller {
|
||||
session()->put('order_by', $order_by);
|
||||
}
|
||||
|
||||
if($search_by === 0){
|
||||
// last 24 hours
|
||||
|
||||
|
||||
|
||||
if($search_by == 3){
|
||||
//yesterday
|
||||
$start_date_search = Carbon::yesterday()->startOfDay()->toDateTimeString();
|
||||
$end_date_search = Carbon::yesterday()->endOfDay()->toDateTimeString();
|
||||
|
||||
$date_search = "Yesterday";
|
||||
} elseif($search_by == 1){
|
||||
// custom date
|
||||
@@ -70,14 +74,14 @@ class PatientFlowMonitoringController extends Controller {
|
||||
|
||||
switch (get_select_clinic_order_type()) {
|
||||
case 0:
|
||||
if ($order_by == 0) {
|
||||
if ($order_by == 1) {
|
||||
$order_by_text = "patient_episodes.id";
|
||||
} else {
|
||||
$order_by_text = "triage.severe_grade desc, patient_episodes.id";
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if ($order_by == 0) {
|
||||
if ($order_by == 1) {
|
||||
$order_by_text = "patient_episodes.id desc";
|
||||
} else {
|
||||
$order_by_text = "triage.severe_grade desc, patient_episodes.id desc";
|
||||
@@ -85,7 +89,7 @@ class PatientFlowMonitoringController extends Controller {
|
||||
break;
|
||||
case 2:
|
||||
default:
|
||||
if ($order_by == 0) {
|
||||
if ($order_by == 1) {
|
||||
$order_by_text = "consultations.completed, patient_episodes.id";
|
||||
} else {
|
||||
$order_by_text = "consultations.completed, triage.severe_grade desc, patient_episodes.id";
|
||||
@@ -94,6 +98,7 @@ class PatientFlowMonitoringController extends Controller {
|
||||
}
|
||||
|
||||
if($clinic_id == 0){
|
||||
//opd
|
||||
$patient_episodes = DB::table('patient_episodes')
|
||||
->whereNull('patient_episodes.deleted_at')
|
||||
->leftJoin('consultations', 'patient_episodes.id', '=', 'consultations.episode_id')
|
||||
@@ -105,6 +110,7 @@ class PatientFlowMonitoringController extends Controller {
|
||||
->paginate(200);
|
||||
$clinic_name = "OPD";
|
||||
} else {
|
||||
//other clinics
|
||||
$patient_episodes = DB::table('patient_episodes')
|
||||
->whereNull('patient_episodes.deleted_at')
|
||||
->leftJoin('consultations', 'patient_episodes.id', '=', 'consultations.episode_id')
|
||||
@@ -128,6 +134,7 @@ class PatientFlowMonitoringController extends Controller {
|
||||
|
||||
$wards = DB::table('wards')->where('available', 1)->whereNull('deleted_at')->pluck("name", "id")->prepend('- select -', '');
|
||||
|
||||
// dd($date_search);
|
||||
return view('patients::patient_flow_monitoring.index', compact('patient_episodes', 'clinics', 'patient_categories','clinic_name','search_by', 'date_search', 'wards', 'diagnoses'));
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ use Illuminate\Database\QueryException;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Redirect;
|
||||
use Streamline\Models\Drug;
|
||||
use Streamline\Models\EyeGlasses;
|
||||
use Streamline\Models\HospitalInformation;
|
||||
@@ -21,9 +22,14 @@ use Streamline\Models\ReferralHospital;
|
||||
use Streamline\Models\Sundry;
|
||||
use Streamline\Models\Services;
|
||||
use Streamline\Models\Treatment;
|
||||
use Streamline\Services\ItemsStockService;
|
||||
|
||||
class PointOfSaleController extends Controller {
|
||||
|
||||
public function __construct(protected ItemsStockService $itemStockService)
|
||||
{
|
||||
}
|
||||
|
||||
public function index(Request $request){
|
||||
$search_text = "";
|
||||
|
||||
@@ -68,7 +74,8 @@ class PointOfSaleController extends Controller {
|
||||
return view('patients::point_of_sale.order_items', compact('drugs', 'eye_glasses', 'sundries', 'referral_hospitals', 'services'));
|
||||
}
|
||||
|
||||
public function confirm_items(Request $request){
|
||||
public function confirm_items(Request $request)
|
||||
{
|
||||
$pre_ordered_eye_glasses = [];
|
||||
$manual_patient_prescriptions = [];
|
||||
$automatic_patient_prescriptions = [];
|
||||
@@ -87,8 +94,8 @@ class PointOfSaleController extends Controller {
|
||||
$episode = new PatientEpisode;
|
||||
$episode->patient_id = $patient_id;
|
||||
$episode->paid_over = "pos";
|
||||
$episode->created_by = Auth::user()->id;
|
||||
$episode->updated_by = Auth::user()->id;
|
||||
$episode->created_by = Auth::id();
|
||||
$episode->updated_by = Auth::id();
|
||||
$episode->save();
|
||||
flash('A new episode for patient with patient number ' . $patient_number . ' has been initiated.');
|
||||
|
||||
@@ -106,7 +113,7 @@ class PointOfSaleController extends Controller {
|
||||
$patient->phone = $request->phone_number ?? "";
|
||||
$patient->referred_from = $request->referral_hospital ?? 1;
|
||||
$patient->category_id = 1;
|
||||
$patient->created_by = Auth::user()->id;
|
||||
$patient->created_by = Auth::id();
|
||||
$patient->gender = $request->gender ?? 2;
|
||||
|
||||
if (is_null($request->date_of_birth)) {
|
||||
@@ -133,8 +140,8 @@ class PointOfSaleController extends Controller {
|
||||
$episode->patient_id = $patient_id;
|
||||
$episode->clinic_id = get_default_hospital_clinic();
|
||||
$episode->paid_over = "pos";
|
||||
$episode->created_by = Auth::user()->id;
|
||||
$episode->updated_by = Auth::user()->id;
|
||||
$episode->created_by = Auth::id();
|
||||
$episode->updated_by = Auth::id();
|
||||
|
||||
try {
|
||||
$episode->save();
|
||||
@@ -148,16 +155,39 @@ class PointOfSaleController extends Controller {
|
||||
|
||||
if ($request->selected_eye_glasses) {
|
||||
$pre_ordered_eye_glasses = EyeGlasses::whereIn('id', $request->selected_eye_glasses)->get();
|
||||
if (stock_levels_to_consider() == 0) {//getting total stock for optical from both stores and pharmacy
|
||||
foreach($pre_ordered_eye_glasses as $eye) {$eye->total_stock = $this->itemStockService->getItemAllQuantityByTotal($eye->id, 7);}
|
||||
} else{//getting total stock for opticals from pharmacy
|
||||
foreach($pre_ordered_eye_glasses as $eye) {$eye->total_stock = $this->itemStockService->getItemQuantity('pharmacy_stock',$eye->id, 7);}
|
||||
}
|
||||
|
||||
}
|
||||
if ($request->selected_drugs) {
|
||||
if($request->manual_drug_select == 1){
|
||||
$manual_patient_prescriptions = Drug::whereIn('id', $request->selected_drugs)->get();
|
||||
if (stock_levels_to_consider() == 0) {//getting total stock for drugs from both stores and pharmacy
|
||||
foreach($manual_patient_prescriptions as $drug) {$drug->total_stock = $this->itemStockService->getItemAllQuantityByTotal($drug->id, 1);}
|
||||
} else {//getting total stock for drugs from pharmacy
|
||||
foreach($manual_patient_prescriptions as $drug) {$drug->total_stock = $this->itemStockService->getItemQuantity('pharmacy_stock',$drug->id, 1);}
|
||||
}
|
||||
|
||||
}else if($request->automatic_drug_select == 1){
|
||||
$automatic_patient_prescriptions = Drug::whereIn('id', $request->selected_drugs)->get();
|
||||
if (stock_levels_to_consider() == 0) {//getting total stock for drugs from both stores and pharmacy
|
||||
foreach($automatic_patient_prescriptions as $drug) {$drug->total_stock = $this->itemStockService->getItemAllQuantityByTotal($drug->id, 1);}
|
||||
} else{//getting total stock for optical from pharmacy
|
||||
foreach($automatic_patient_prescriptions as $drug) {$drug->total_stock = $this->itemStockService->getItemQuantity('pharmacy_stock',$drug->id, 1);}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($request->selected_sundries) {
|
||||
$pre_ordered_sundries = Sundry::whereIn('id', $request->selected_sundries)->get();
|
||||
if (stock_levels_to_consider() == 0) {//getting total stock for sundry from both stores and pharmacy
|
||||
foreach($pre_ordered_sundries as $sundry) {$sundry->total_stock = $this->itemStockService->getItemAllQuantityByTotal($sundry->id, 2);}
|
||||
} else{//getting total stock for optical from pharmacy
|
||||
foreach($pre_ordered_sundries as $sundry) {$sundry->total_stock = $this->itemStockService->getItemQuantity('pharmacy_stock',$sundry->id, 2);}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ($request->selected_services) {
|
||||
@@ -171,6 +201,11 @@ class PointOfSaleController extends Controller {
|
||||
}
|
||||
|
||||
public function confirm_pricing(Request $request){
|
||||
$order_sundries_id = NULL;
|
||||
$treatment_id = NULL;
|
||||
$order_optical_id = NULL;
|
||||
$order_service_id = NULL;
|
||||
|
||||
if($request->treatment_item){
|
||||
$treatment = new Treatment;
|
||||
$treatment->patient_id = $request->patient_id;
|
||||
@@ -219,26 +254,25 @@ class PointOfSaleController extends Controller {
|
||||
$treatment->durations = implode(',', $time_duration);
|
||||
$treatment->quantities_dispensed = implode(',', $request->treatment_quantity);
|
||||
$treatment->dispense_status = 0;
|
||||
$treatment->is_pos = 1;
|
||||
$treatment->created_by = Auth::id();
|
||||
$treatment->save();
|
||||
|
||||
$request->treatment_id = DB::table('treatments')->where('episode_id', $request->episode_id)->where('patient_id', $request->patient_id)->latest()->pluck('id')->first();
|
||||
$treatment_id = $treatment->id;
|
||||
}
|
||||
|
||||
$eye_glass_ids = $request->eye_glass_item;
|
||||
$eye_glass_quantity = $request->eye_glass_quantity;
|
||||
|
||||
if($request->eye_glass_item){
|
||||
for ($i=0; $i < count($eye_glass_ids) ; $i++) {
|
||||
$new_ordered_eye_glasses = new OrderedEyeGlasses;
|
||||
$new_ordered_eye_glasses->patient_id = $request->patient_id;
|
||||
$new_ordered_eye_glasses->episode_id = $request->episode_id;
|
||||
$new_ordered_eye_glasses->eye_glasses_id = $eye_glass_ids[$i];
|
||||
$new_ordered_eye_glasses->quantity = $eye_glass_quantity[$i];
|
||||
$new_ordered_eye_glasses->payment_status = 0; //0 by default to mean not paid
|
||||
$new_ordered_eye_glasses->created_by = auth()->user()->id;
|
||||
$new_ordered_eye_glasses->save();
|
||||
}
|
||||
$new_ordered_eye_glasses = new OrderedEyeGlasses;
|
||||
$new_ordered_eye_glasses->patient_id = $request->patient_id;
|
||||
$new_ordered_eye_glasses->episode_id = $request->episode_id;
|
||||
$new_ordered_eye_glasses->eye_glasses_id = implode(",", $request->eye_glass_item);
|
||||
$new_ordered_eye_glasses->quantity = implode(",", $request->eye_glass_quantity);
|
||||
$new_ordered_eye_glasses->payment_status = 0; //0 by default to mean not paid
|
||||
$new_ordered_eye_glasses->created_by = auth()->id();
|
||||
$new_ordered_eye_glasses->is_pos = 1;
|
||||
$new_ordered_eye_glasses->save();
|
||||
|
||||
$order_optical_id = $new_ordered_eye_glasses->id;
|
||||
}
|
||||
|
||||
if($request->pos_sundry_ids){
|
||||
@@ -247,8 +281,11 @@ class PointOfSaleController extends Controller {
|
||||
$new_ordered_sundries->episode_id = $request->episode_id;
|
||||
$new_ordered_sundries->sundries_id = implode(",", $request->pos_sundry_ids);
|
||||
$new_ordered_sundries->quantity = implode(",", $request->sundry_quantity);
|
||||
$new_ordered_sundries->created_by = auth()->user()->id;
|
||||
$new_ordered_sundries->created_by = auth()->id();
|
||||
$new_ordered_sundries->is_pos = 1;
|
||||
$new_ordered_sundries->save();
|
||||
|
||||
$order_sundries_id = $new_ordered_sundries->id;
|
||||
}
|
||||
|
||||
if ($request->service_id && $request->service_id[0] != null) {
|
||||
@@ -259,16 +296,16 @@ class PointOfSaleController extends Controller {
|
||||
$new_ordered_service->quantity = implode(",", $request->quantity);
|
||||
$new_ordered_service->performed = 0;
|
||||
$new_ordered_service->performed_id = 0;
|
||||
$new_ordered_service->created_by = auth()->user()->id;
|
||||
$new_ordered_service->created_by = auth()->id();
|
||||
$new_ordered_service->is_pos = 1;
|
||||
$new_ordered_service->save();
|
||||
}
|
||||
|
||||
$request->ordered_sundry_ids = OrderedSundry::where('episode_id', $request->episode_id)->where('patient_id', $request->patient_id)
|
||||
->whereDate('created_at', Carbon::today()->toDateString())->pluck('id')->toArray();
|
||||
$order_service_id = $new_ordered_service->id;
|
||||
}
|
||||
|
||||
$treatment_item = $treatment_quantity = $treatment_subtotal = [];
|
||||
// save for treatment
|
||||
if($request->treatment_id){
|
||||
if($request->treatment_item){
|
||||
$treatment_item = $request->treatment_item;
|
||||
$treatment_quantity = $request->treatment_quantity;
|
||||
$treatment_subtotal = $request->treatment_subtotal;
|
||||
@@ -277,7 +314,7 @@ class PointOfSaleController extends Controller {
|
||||
$eye_glasses_prices_array = $eye_glasses_quantity_array = $eye_glasses_ids_array = [];
|
||||
// save for eye_glasses arrays
|
||||
if($request->eye_glass_item){
|
||||
$eye_glasses_prices_array = $request->eye_glass_amount;
|
||||
$eye_glasses_prices_array = $request->eye_glass_subtotal;
|
||||
$eye_glasses_quantity_array = $request->eye_glass_quantity;
|
||||
$eye_glasses_ids_array = $request->eye_glass_item;
|
||||
}
|
||||
@@ -306,19 +343,19 @@ class PointOfSaleController extends Controller {
|
||||
$pos_record->episode_id = $request->episode_id;
|
||||
$pos_record->treatments = count($treatment_item) > 0 ? json_encode([
|
||||
"ids" => $treatment_item, "quantity" => $treatment_quantity,
|
||||
"subtotal" => $treatment_subtotal
|
||||
"subtotal" => $treatment_subtotal, "order_id" => $treatment_id
|
||||
]) : NULL;
|
||||
$pos_record->eye_glasses = count($eye_glasses_ids_array) > 0 ? json_encode([
|
||||
"ids" => $eye_glasses_ids_array, "quantity" => $eye_glasses_quantity_array,
|
||||
"subtotal" => $eye_glasses_prices_array
|
||||
"subtotal" => $eye_glasses_prices_array, "order_id" => $order_optical_id
|
||||
]) : NULL;
|
||||
$pos_record->sundries = count($sundry_item) > 0 ? json_encode([
|
||||
"ids" => $sundry_item, "quantity" => $sundry_quantity,
|
||||
"subtotal" => $sundry_subtotal
|
||||
"subtotal" => $sundry_subtotal, "order_id" => $order_sundries_id
|
||||
]) : NULL;
|
||||
$pos_record->services = count($service_ids_array) > 0 ? json_encode([
|
||||
"ids" => $service_ids_array, "quantity" => $service_quantity_array,
|
||||
"subtotal" => $service_prices_array
|
||||
"subtotal" => $service_prices_array, "order_id" => $order_service_id
|
||||
]) : NULL;
|
||||
$pos_record->created_by = Auth::id();
|
||||
$pos_record->save();
|
||||
@@ -327,8 +364,7 @@ class PointOfSaleController extends Controller {
|
||||
}
|
||||
|
||||
public function add_referral(Request $request) {
|
||||
|
||||
$logged_in_user_id = Auth::user()->id;
|
||||
$logged_in_user_id = Auth::id();
|
||||
$referral_hospital = new ReferralHospital;
|
||||
$referral_hospital->name = $request->name;
|
||||
$referral_hospital->created_by = $logged_in_user_id;
|
||||
@@ -356,6 +392,7 @@ class PointOfSaleController extends Controller {
|
||||
$patient = Patient::find($record->patient_id);
|
||||
$receipt_date = $record->created_at;
|
||||
$receipt_reprint_date = date('Y-m-d h:i:s');
|
||||
$first_printed_by = $record->created_by;
|
||||
|
||||
$treatments_array = json_decode($record->treatments, true);
|
||||
$sundries_array = json_decode($record->sundries, true);
|
||||
@@ -365,19 +402,24 @@ class PointOfSaleController extends Controller {
|
||||
$treatment_item = $treatments_array ? $treatments_array["ids"] : [];
|
||||
$treatment_quantity = $treatments_array ? $treatments_array["quantity"] : [];
|
||||
$treatment_subtotal = $treatments_array ? $treatments_array["subtotal"] : [];
|
||||
$treatment_number = $treatments_array ? ($treatments_array["order_id"] ?? 0) : [];
|
||||
$eye_glasses_ids_array = $eye_glasses_array ? $eye_glasses_array["ids"] : [];
|
||||
$eye_glasses_quantity_array = $eye_glasses_array ? $eye_glasses_array["quantity"] : [];
|
||||
$eye_glasses_prices_array = $eye_glasses_array ? $eye_glasses_array["subtotal"] : [];
|
||||
$eye_glasses_number = $eye_glasses_array ? ($eye_glasses_array["order_id"] ?? 0) : [];
|
||||
$sundry_item = $sundries_array ? $sundries_array["ids"] : [];
|
||||
$sundry_quantity = $sundries_array ? $sundries_array["quantity"] : [];
|
||||
$sundry_subtotal = $sundries_array ? $sundries_array["subtotal"] : [];
|
||||
$sundry_number = $sundries_array ? ($sundries_array["order_id"] ?? 0) : [];
|
||||
$service_ids_array = $services_array ? $services_array["ids"] : [];
|
||||
$service_quantity_array = $services_array ? $services_array["quantity"] : [];
|
||||
$service_prices_array = $services_array ? $services_array["subtotal"] : [];
|
||||
$service_number = $services_array ? ($services_array["order_id"] ?? 0) : [];
|
||||
|
||||
return view('patients::point_of_sale.receipt', compact('treatment_item', 'treatment_quantity', 'treatment_subtotal',
|
||||
'eye_glasses_prices_array', 'eye_glasses_quantity_array', 'eye_glasses_ids_array', 'hospital_information', 'patient', 'receipt_date',
|
||||
'sundry_item','sundry_quantity','sundry_subtotal', 'service_ids_array', 'service_prices_array', 'service_quantity_array', 'receipt_reprint_date'));
|
||||
'eye_glasses_prices_array', 'eye_glasses_quantity_array', 'eye_glasses_ids_array', 'hospital_information', 'patient', 'receipt_date', 'first_printed_by',
|
||||
'sundry_item','sundry_quantity','sundry_subtotal', 'service_ids_array', 'service_prices_array', 'service_quantity_array', 'receipt_reprint_date',
|
||||
'eye_glasses_number', 'treatment_number', 'sundry_number', 'service_number'));
|
||||
} else {
|
||||
// set up the redirect link for html
|
||||
session()->put('print_pos_pdf', 1);
|
||||
@@ -418,15 +460,19 @@ class PointOfSaleController extends Controller {
|
||||
$treatment_item = $treatments_array ? $treatments_array["ids"] : [];
|
||||
$treatment_quantity = $treatments_array ? $treatments_array["quantity"] : [];
|
||||
$treatment_subtotal = $treatments_array ? $treatments_array["subtotal"] : [];
|
||||
$treatment_number = $treatments_array ? ($treatments_array["order_id"] ?? 0) : [];
|
||||
$eye_glasses_ids_array = $eye_glasses_array ? $eye_glasses_array["ids"] : [];
|
||||
$eye_glasses_quantity_array = $eye_glasses_array ? $eye_glasses_array["quantity"] : [];
|
||||
$eye_glasses_prices_array = $eye_glasses_array ? $eye_glasses_array["subtotal"] : [];
|
||||
$eye_glasses_number = $eye_glasses_array ? ($eye_glasses_array["order_id"] ?? 0) : [];
|
||||
$sundry_item = $sundries_array ? $sundries_array["ids"] : [];
|
||||
$sundry_quantity = $sundries_array ? $sundries_array["quantity"] : [];
|
||||
$sundry_subtotal = $sundries_array ? $sundries_array["subtotal"] : [];
|
||||
$sundry_number = $sundries_array ? ($sundries_array["order_id"] ?? 0) : [];
|
||||
$service_ids_array = $services_array ? $services_array["ids"] : [];
|
||||
$service_quantity_array = $services_array ? $services_array["quantity"] : [];
|
||||
$service_prices_array = $services_array ? $services_array["subtotal"] : [];
|
||||
$service_number = $services_array ? ($services_array["order_id"] ?? 0) : [];
|
||||
|
||||
$data = [
|
||||
"patient" => $patient, "receipt_date" => $receipt_date, "receipt_reprint_date" => $receipt_reprint_date, "hospital_information" => $hospital_information,
|
||||
@@ -434,6 +480,7 @@ class PointOfSaleController extends Controller {
|
||||
"eye_glasses_ids_array" => $eye_glasses_ids_array, "eye_glasses_quantity_array" => $eye_glasses_quantity_array, "eye_glasses_prices_array" => $eye_glasses_prices_array,
|
||||
"sundry_item" => $sundry_item, "sundry_quantity" => $sundry_quantity, "sundry_subtotal" => $sundry_subtotal,
|
||||
"service_ids_array" => $service_ids_array, "service_quantity_array" => $service_quantity_array, "service_prices_array" => $service_prices_array,
|
||||
"treatment_number" => $treatment_number, "eye_glasses_number" => $eye_glasses_number, "sundry_number" => $sundry_number, "service_number" => $service_number,
|
||||
];
|
||||
|
||||
$pdf = SnappyPDF::loadView('patients::point_of_sale.print_pos_pdf', $data)
|
||||
|
||||
@@ -470,11 +470,8 @@ class TriageController extends Controller
|
||||
|
||||
return redirect("/patient_episodes");
|
||||
} catch (QueryException $e) {
|
||||
$errorCode = $e->errorInfo[1];
|
||||
if ($errorCode == 1062) { //error code for duplicate entry to a unique field
|
||||
flash("Triage already exists!")->error();
|
||||
return back()->withInput();
|
||||
}
|
||||
flash("An error occurred")->error();
|
||||
return back()->withInput();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -540,10 +537,9 @@ class TriageController extends Controller
|
||||
|
||||
$age_diff_months = Carbon::parse($patient->date_of_birth)->diffInMonths(Carbon::now());
|
||||
$triage_hiv = HivGenderBaseViolence::where('triage_id', $triage->id)->first();
|
||||
$triage_gbv = GenderBasedViolence::where('triage_id', $triage->id)->first();
|
||||
|
||||
return view('patients::triage.show', compact('triage', 'patient_episode', 'patient', 'clinics', 'referral_hospitals', 'symptoms', 'categories', 'family_planning_methods', 'triage_hiv',
|
||||
'episode_id', 'years', 'airway', 'circulation', 'neurological', 'dehydration', 'discharge_mortality', 'age_diff_months', 'priority_signs', 'nutrition', 'triage_without_etat', 'triage_gbv'));
|
||||
'episode_id', 'years', 'airway', 'circulation', 'neurological', 'dehydration', 'discharge_mortality', 'age_diff_months', 'priority_signs', 'nutrition', 'triage_without_etat'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -666,7 +662,6 @@ class TriageController extends Controller
|
||||
|
||||
$age_diff_months = $dob->diffInMonths(Carbon::now());
|
||||
$triage_hiv = HivGenderBaseViolence::where('triage_id', $triage->id)->first();
|
||||
$triage_gbv = GenderBasedViolence::where('triage_id', $triage->id)->first();
|
||||
|
||||
return view('patients::triage.edit', compact(
|
||||
'episode_id',
|
||||
@@ -691,7 +686,6 @@ class TriageController extends Controller
|
||||
'symptoms_periods',
|
||||
'age_diff_months',
|
||||
'triage_hiv',
|
||||
'triage_gbv'
|
||||
));
|
||||
}
|
||||
|
||||
@@ -959,13 +953,13 @@ class TriageController extends Controller
|
||||
|
||||
$result = DB::table('symptoms')->where('id', $request->symptom_id)->first();
|
||||
|
||||
if ($result->prompts) {
|
||||
if (!empty($result->prompts)) {
|
||||
$prompt = $result->prompts;
|
||||
} else {
|
||||
$prompt = "No prompt available";
|
||||
}
|
||||
|
||||
if ($result->reference_link && !empty($result->reference_link) && $result->reference_link != "-") {
|
||||
if (!empty($result->reference_link) && !empty($result->reference_link) && $result->reference_link != "-") {
|
||||
//some links just have "-"
|
||||
$ref_text = '<a style="color: blue;" href="' . $result->reference_link . '" target="_blank">' . $result->reference_text . '</a>';
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user