mirror of
https://gitlab.com/signalytic/client-external/streamline/streamline-emr.git
synced 2026-09-13 11:41:31 +00:00
Build modified streamline images
The official image from streamline does not currently work for the arm64 platform. As a temporary measure, the source code and docker build scripts have been lifted from the official images and are used to build locally. Some additional modifications are made to reduce overall image size, these are documented in docker/README.md
This commit is contained in:
+54
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Patients\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Streamline\Models\Alert;
|
||||
use Streamline\Models\Patient;
|
||||
|
||||
class AlertsController extends Controller {
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
}
|
||||
|
||||
/* Add a new patient alert i.e used by the alerts modal in the header */
|
||||
public function store_patient_alerts(Request $request) {
|
||||
$alert = new Alert;
|
||||
$alert->patient_id = $request->alert_patient_id;
|
||||
$alert->alerts = $request->patient_alerts;
|
||||
$alert->created_by = auth()->user()->id;
|
||||
$alert->save();
|
||||
return $alert;
|
||||
}
|
||||
|
||||
public function view_alerts() {
|
||||
$patient_id = session()->get('patient_id');
|
||||
$patient = Patient::find($patient_id);
|
||||
|
||||
$alerts = Alert::where('patient_id', $patient_id)->get();
|
||||
|
||||
return view('patients::alerts.view_alerts', compact('alerts', 'patient'));
|
||||
}
|
||||
|
||||
public function edit_alert($id) {
|
||||
$alert = Alert::where(['id' => $id])->first();
|
||||
|
||||
return view('patients::alerts.edit_alert', compact('alert'));
|
||||
}
|
||||
|
||||
public function save_edit_alert(Request $request) {
|
||||
$alert = Alert::find($request->id);
|
||||
$alert->alerts = $request->name;
|
||||
$alert->save();
|
||||
|
||||
flash("Alert has been saved")->success();
|
||||
return redirect('/alerts/view_alerts/');
|
||||
}
|
||||
|
||||
public function delete_alert($id) {
|
||||
$alert = Alert::find($id);
|
||||
$alert->delete();
|
||||
flash("Alert has been deleted.")->success();
|
||||
return redirect('/alerts/view_alerts/');
|
||||
}
|
||||
}
|
||||
+127
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Patients\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Streamline\Models\Allergy;
|
||||
use Streamline\Models\Patient;
|
||||
use Streamline\Models\DrugCategory;
|
||||
use Streamline\Models\PatientDocument;
|
||||
use Streamline\Models\Alert;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class AllergiesController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$patient_id = session()->get('patient_id');
|
||||
$patient = Patient::find($patient_id);
|
||||
$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");
|
||||
$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');
|
||||
$districts = DB::table('districts')->pluck('name', 'id');
|
||||
$counties = DB::table('counties')->pluck('name', 'id');
|
||||
$subcounties = DB::table('subcounties')->pluck('name', 'id');
|
||||
$parishes = DB::table('parishes')->pluck('name', 'id');
|
||||
$villages = DB::table('villages')->pluck('name', 'id');
|
||||
$drug_categories = DrugCategory::orderBy('name', 'asc')->get();
|
||||
$documents = PatientDocument::where('patient_id', $patient_id)->orderBy('created_at', 'desc')->take(2)->get();
|
||||
$known_patient_alerts = Alert::where('patient_id', $patient_id)->orderBy('created_at', 'desc')->take(2)->get();
|
||||
$known_patient_allergies = Allergy::where('patient_id', $patient_id)->orderBy('created_at', 'desc')->get();
|
||||
$drug_categories_array = DB::table('drug_categories')->pluck('name', 'id');
|
||||
$drug_categories = DrugCategory::orderBy('name', 'asc')->get();
|
||||
return view('patients::allergies.index',compact('patient','known_patient_allergies','drug_categories_array','categories','drug_categories','relationships', 'occupations', 'patient_categories', 'diagnoses', 'categories', 'marital_statuses', 'districts', 'counties', 'subcounties', 'parishes', 'villages', 'drug_categories', 'documents', 'known_patient_alerts'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/*
|
||||
* Add allergic drugs to a particular patient
|
||||
*/
|
||||
public function store_patient_allergies(Request $request)
|
||||
{
|
||||
$patient_id = $request->allergy_patient_id;
|
||||
$patient_allergies_array = $request->patient_allergies;
|
||||
$allergies_string = implode(',', $patient_allergies_array);
|
||||
|
||||
$existing_allergy = Allergy::where(['patient_id' => $patient_id])->first();
|
||||
$allergy = is_null($existing_allergy) ? new Allergy : $existing_allergy;
|
||||
$allergy->patient_id = $patient_id;
|
||||
$allergy->names = $allergies_string;
|
||||
$save_allergy = is_null($existing_allergy) ? $allergy->save() : $allergy->update(); /* if new patient allergy then insert else update the db table*/
|
||||
return $request->all();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Patients\Http\Controllers;
|
||||
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
|
||||
class Controller extends BaseController
|
||||
{
|
||||
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
|
||||
}
|
||||
@@ -0,0 +1,245 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Patients\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Streamline\Models\TriageNutrition;
|
||||
|
||||
class NutritionController extends Controller {
|
||||
|
||||
public function get_nutrition_status(Request $request): string {
|
||||
$age_diff_months = round($request->age_diff_months);
|
||||
$weight = $request->weight;
|
||||
$height = $request->height * 100;
|
||||
$bmi = $request->bmi;
|
||||
$gender = $request->gender;
|
||||
$patient_id = $request->patient_id;
|
||||
$episode_id = $request->episode_id;
|
||||
$muac = $request->muac;
|
||||
$oedema = $request->oedema;
|
||||
$reference_age = NULL;
|
||||
$reference_bmi = NULL;
|
||||
$reference_height = NULL;
|
||||
$reference_weight = NULL;
|
||||
$texts_array = ["Normal" => 1, "Risk of overweight" => 2, "MAM" => 3,
|
||||
"SAM without oedema" => 4, "SAM with oedema" => 5];
|
||||
|
||||
if (!is_null($request->weight) && !is_null($request->height) && !is_null($request->bmi)) {
|
||||
if ($age_diff_months > 5 && $age_diff_months < 60) {
|
||||
if ($gender == 2){
|
||||
$data = file(base_path('public/uploads/nutrition_csv_lookup/female_6_60.csv'));
|
||||
} else {
|
||||
$data = file(base_path('public/uploads/nutrition_csv_lookup/male_6_60.csv'));
|
||||
}
|
||||
|
||||
$formatted_data = [];
|
||||
$lengths = [];
|
||||
|
||||
foreach($data as $item) {
|
||||
$split_item = explode(',', $item);
|
||||
$lengths[] = +$split_item[0];
|
||||
$formatted_data[+$split_item[0]] = [+$split_item[1], +$split_item[2], +$split_item[3], +$split_item[4], +str_replace(["\r", "\n"], "", $split_item[5])];
|
||||
}
|
||||
|
||||
$reference_height = get_closest_element_in_array($lengths, $height);
|
||||
$reference_weight = get_closest_element_in_array($formatted_data[$reference_height], $weight);
|
||||
$weight_key = array_search($reference_weight, $formatted_data[$reference_height]);
|
||||
|
||||
if ($weight_key == 0) {
|
||||
$text = "SAM without oedema";
|
||||
$reason = "Weight for height < -3 SD";
|
||||
$text_color = "red";
|
||||
} elseif ($weight_key == 1) {
|
||||
$text = "MAM";
|
||||
$reason = "Weight for height between -3 SD and -2 SD";
|
||||
$text_color = "darkorange";
|
||||
} elseif ($weight_key == 2 || $weight_key == 3) {
|
||||
$text = "Normal";
|
||||
$reason = "Weight for height between -2 SD and 2 SD";
|
||||
$text_color = "black";
|
||||
} else {
|
||||
$text = "Risk of overweight";
|
||||
$reason = "Weight for height > 2 SD";
|
||||
$text_color = "black";
|
||||
}
|
||||
} elseif ($age_diff_months > 59 && $age_diff_months < 228) {
|
||||
if ($age_diff_months < 120) {
|
||||
if ($gender == 2){
|
||||
$data = file(base_path('public/uploads/nutrition_csv_lookup/female_60_120.csv'));
|
||||
} else {
|
||||
$data = file(base_path('public/uploads/nutrition_csv_lookup/male_60_120.csv'));
|
||||
}
|
||||
} else {
|
||||
if ($gender == 2){
|
||||
$data = file(base_path('public/uploads/nutrition_csv_lookup/female_120_228.csv'));
|
||||
} else {
|
||||
$data = file(base_path('public/uploads/nutrition_csv_lookup/male_120_228.csv'));
|
||||
}
|
||||
}
|
||||
|
||||
$formatted_data = [];
|
||||
$ages_in_months = [];
|
||||
|
||||
foreach($data as $item) {
|
||||
$split_item = explode(',', $item);
|
||||
$ages_in_months[] = +$split_item[0];
|
||||
$formatted_data[+$split_item[0]] = [+$split_item[1], +$split_item[2], +$split_item[3], +$split_item[4], +str_replace(["\r", "\n"], "", $split_item[5])];
|
||||
}
|
||||
|
||||
$reference_age = get_closest_element_in_array($ages_in_months, $age_diff_months);
|
||||
$reference_bmi = get_closest_element_in_array($formatted_data[$reference_age], $bmi);
|
||||
$bmi_key = array_search($reference_bmi, $formatted_data[$reference_age]);
|
||||
|
||||
if ($bmi_key == 0) {
|
||||
$text = "SAM without oedema";
|
||||
$reason = "BMI < -3 SD";
|
||||
$text_color = "red";
|
||||
} elseif ($bmi_key == 1) {
|
||||
$text = "MAM";
|
||||
$reason = "BMI between -3 SD and -2 SD";
|
||||
$text_color = "darkorange";
|
||||
} elseif ($bmi_key == 2 || $bmi_key == 3) {
|
||||
$text = "Normal";
|
||||
$reason = "BMI between -2 SD and 1 SD";
|
||||
$text_color = "black";
|
||||
} else {
|
||||
$text = "Risk of overweight";
|
||||
$reason = "BMI > 1 SD";
|
||||
$text_color = "black";
|
||||
}
|
||||
} elseif ($age_diff_months > 227 && $age_diff_months < 1200) {
|
||||
if ($bmi < 16) {
|
||||
$text = "SAM without oedema";
|
||||
$reason = "BMI < 16";
|
||||
$text_color = "red";
|
||||
} elseif ($bmi > 15.9 && $bmi < 17) {
|
||||
$text = "MAM";
|
||||
$reason = "BMI between 16 and 17";
|
||||
$text_color = "darkorange";
|
||||
} elseif ($bmi > 16.9 && $bmi < 25) {
|
||||
$text = "Normal";
|
||||
$reason = "BMI between 17 and 25";
|
||||
$text_color = "black";
|
||||
} else {
|
||||
$text = "Risk of overweight";
|
||||
$reason = "BMI ≥ 25";
|
||||
$text_color = "black";
|
||||
}
|
||||
} else {
|
||||
return "0";
|
||||
}
|
||||
} else {
|
||||
$text = "Normal";
|
||||
$reason = "Normal";
|
||||
$text_color = 'black';
|
||||
}
|
||||
|
||||
// check for oedema status
|
||||
if ($oedema == 1) {
|
||||
$oedema = "Yes";
|
||||
$oedema_text = "SAM with oedema";
|
||||
$oedema_reason = "Oedema of both feet";
|
||||
$oedema_text_color = "red";
|
||||
} else {
|
||||
$oedema = "No";
|
||||
$oedema_text = "Normal";
|
||||
$oedema_reason = "";
|
||||
$oedema_text_color = "black";
|
||||
}
|
||||
|
||||
// check if oedema has a higher category
|
||||
if (($texts_array[$oedema_text] > $texts_array[$text])) {
|
||||
$text = $oedema_text;
|
||||
$reason = $oedema_reason;
|
||||
$text_color = $oedema_text_color;
|
||||
}
|
||||
|
||||
if ($age_diff_months < 1.59 && $muac < 11.0) {
|
||||
$muac_text = "SAM without oedema";
|
||||
$muac_reason = "MUAC below 11.0";
|
||||
$muac_text_color = 'red';
|
||||
} else if(between($age_diff_months, 1.6, 5) && $muac < 11.5) {
|
||||
$muac_text = "SAM without oedema";
|
||||
$muac_reason = "MUAC below 11.5";
|
||||
$muac_text_color = 'red';
|
||||
} else if(between($age_diff_months, 6, 59) && between($muac, 11.5, 12.4)) {
|
||||
$muac_text = "MAM";
|
||||
$muac_reason = "MUAC between 11.5 and 12.4";
|
||||
$muac_text_color = 'darkorange';
|
||||
} else if(between($age_diff_months, 6, 59) && $muac < 11.5) {
|
||||
$muac_text = "SAM without oedema";
|
||||
$muac_reason = "MUAC below 11.5";
|
||||
$muac_text_color = 'red';
|
||||
} else if(between($age_diff_months, 60, 119) && between($muac, 13.5, 14.4)) {
|
||||
$muac_text = "MAM";
|
||||
$muac_reason = "MUAC between 13.5 and 14.4";
|
||||
$muac_text_color = 'darkorange';
|
||||
} else if(between($age_diff_months, 60, 119) && $muac < 13.5) {
|
||||
$muac_text = "SAM without oedema";
|
||||
$muac_reason = "MUAC below 13.5";
|
||||
$muac_text_color = 'red';
|
||||
} else if(between($age_diff_months, 120, 179) && between($muac, 16.0, 18.4)) {
|
||||
$muac_text = "MAM";
|
||||
$muac_reason = "MUAC between 16.0 and 18.4";
|
||||
$muac_text_color = 'darkorange';
|
||||
} else if(between($age_diff_months, 120, 179) && $muac < 16.0) {
|
||||
$muac_text = "SAM without oedema";
|
||||
$muac_reason = "MUAC below 16.0";
|
||||
$muac_text_color = 'red';
|
||||
} else if(between($age_diff_months, 180, 215) && between($muac, 18.5, 20.9)) {
|
||||
$muac_text = "MAM";
|
||||
$muac_reason = "MUAC between 18.5 and 21.0";
|
||||
$muac_text_color = 'darkorange';
|
||||
} else if(between($age_diff_months, 180, 215) && $muac < 18.5) {
|
||||
$muac_text = "SAM without oedema";
|
||||
$muac_reason = "MUAC below 18.5";
|
||||
$muac_text_color = 'red';
|
||||
} else if($age_diff_months > 215 && between($muac, 19.0, 21.9)) {
|
||||
$muac_text = "MAM";
|
||||
$muac_reason = "MUAC between 19.0 and 21.9";
|
||||
$muac_text_color = 'darkorange';
|
||||
} else if($age_diff_months > 215 && $muac < 19.0) {
|
||||
$muac_text = "SAM without oedema";
|
||||
$muac_reason = "MUAC below 19.0";
|
||||
$muac_text_color = 'red';
|
||||
} else {
|
||||
$muac_text = "Normal";
|
||||
$muac_reason = "Normal";
|
||||
$muac_text_color = 'black';
|
||||
}
|
||||
|
||||
if (($texts_array[$muac_text] > $texts_array[$text])) {
|
||||
$text = $muac_text;
|
||||
$reason = $muac_reason;
|
||||
$text_color = $muac_text_color;
|
||||
}
|
||||
|
||||
// save data to the nutrition table
|
||||
$nutrition = TriageNutrition::where(['patient_id' => $patient_id, 'episode_id' => $episode_id])->first();
|
||||
|
||||
if (!$nutrition) {
|
||||
$nutrition = new TriageNutrition();
|
||||
}
|
||||
|
||||
$nutrition->patient_id = $patient_id;
|
||||
$nutrition->episode_id = $episode_id;
|
||||
$nutrition->age_diff_months = $age_diff_months;
|
||||
$nutrition->weight = $weight;
|
||||
$nutrition->height = $height;
|
||||
$nutrition->bmi = $bmi;
|
||||
$nutrition->muac = $muac;
|
||||
$nutrition->oedema = $oedema;
|
||||
$nutrition->gender = $gender;
|
||||
$nutrition->reference_height = $reference_height;
|
||||
$nutrition->reference_weight = $reference_weight;
|
||||
$nutrition->text = $text;
|
||||
$nutrition->reason = $reason;
|
||||
$nutrition->reference_age = $reference_age;
|
||||
$nutrition->reference_bmi = $reference_bmi;
|
||||
$nutrition->updated_at = now();
|
||||
|
||||
$nutrition->save();
|
||||
|
||||
return $text . "&&&&" . $reason . "&&&&" . $text_color;
|
||||
}
|
||||
}
|
||||
+2258
File diff suppressed because it is too large
Load Diff
+242
@@ -0,0 +1,242 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Patients\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Streamline\Models\Alert;
|
||||
use Streamline\Models\Allergy;
|
||||
use Streamline\Models\DrugCategory;
|
||||
use Streamline\Models\PatientDocument;
|
||||
use Streamline\Models\Patient;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
||||
class PatientDocumentController extends Controller {
|
||||
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
}
|
||||
|
||||
public function index() {
|
||||
$patient_id = session()->get('patient_id');
|
||||
|
||||
$patient_episodes = \Illuminate\Support\Facades\DB::table('patient_episodes')
|
||||
->where(['patient_id' => $patient_id])
|
||||
->orderBy('id', 'desc')
|
||||
->get();
|
||||
$patient = Patient::where(['id' => $patient_id])->first();
|
||||
|
||||
$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");
|
||||
$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');
|
||||
$districts = DB::table('districts')->pluck('name', 'id');
|
||||
$counties = DB::table('counties')->pluck('name', 'id');
|
||||
$subcounties = DB::table('subcounties')->pluck('name', 'id');
|
||||
$parishes = DB::table('parishes')->pluck('name', 'id');
|
||||
$villages = DB::table('villages')->pluck('name', 'id');
|
||||
$drug_categories = DrugCategory::orderBy('name', 'asc')->get();
|
||||
$documents = PatientDocument::where('patient_id', $patient_id)->orderBy('created_at', 'desc')->get();
|
||||
$known_patient_allergies = Allergy::where('patient_id', $patient_id)->orderBy('created_at', 'desc')->take(2)->get();
|
||||
$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');
|
||||
return view('patients::patient_documents.index', compact('patient', 'clinics', 'relationships', 'occupations', 'patient_categories', 'diagnoses', 'patient_episodes', 'categories', 'marital_statuses', 'districts', 'counties', 'subcounties', 'parishes', 'villages', 'drug_categories', 'documents', 'known_patient_allergies', 'known_patient_alerts', 'drug_categories_array'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create() {
|
||||
$patient_id = session()->get('patient_id');
|
||||
$episode_id = session()->get('episode_id');
|
||||
$patient = Patient::find($patient_id);
|
||||
$categories = DB::table('patient_categories')->where('available', 1)->pluck("name", "id");
|
||||
$drug_categories = DB::table('drug_categories')->get();
|
||||
$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");
|
||||
$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');
|
||||
$districts = DB::table('districts')->pluck('name', 'id');
|
||||
$counties = DB::table('counties')->pluck('name', 'id');
|
||||
$subcounties = DB::table('subcounties')->pluck('name', 'id');
|
||||
$parishes = DB::table('parishes')->pluck('name', 'id');
|
||||
$villages = DB::table('villages')->pluck('name', 'id');
|
||||
$documents = PatientDocument::where('patient_id', $patient_id)->orderBy('created_at', 'desc')->get();
|
||||
$drug_categories = DB::table('drug_categories')->orderBy('name', 'asc')->get();
|
||||
//allergies and alerts
|
||||
$known_patient_allergies = \Streamline\Models\Allergy::where('patient_id', $patient_id)->orderBy('created_at', 'desc')->take(2)->get();
|
||||
$known_patient_alerts = \Streamline\Models\Alert::where('patient_id', $patient_id)->orderBy('created_at', 'desc')->take(2)->get();
|
||||
$drug_categories_array = DB::table('drug_categories')->pluck('name', 'id');
|
||||
return view('patients::patient_documents.create', compact('patient', 'clinics', 'relationships', 'occupations', 'patient_categories', 'diagnoses', 'categories', 'marital_statuses', 'districts', 'counties', 'subcounties', 'parishes', 'villages', 'drug_categories', 'episode_id', 'documents', 'drug_categories_array', 'drug_categories', 'known_patient_allergies', 'known_patient_alerts'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request) {
|
||||
$validator = Validator::make($request->all(), [
|
||||
'documenttitle' => 'required',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
$string = "";
|
||||
foreach ($validator->errors()->getMessages() as $item) {
|
||||
$string .= "{$item[0]}<br>";
|
||||
}
|
||||
return back()->withErrors($validator)->withInput();
|
||||
} else {
|
||||
$patient_document = new PatientDocument;
|
||||
$patient_document->patient_id = session()->get('patient_id');
|
||||
$patient_document->episode_id = session()->get('episode_id');
|
||||
$patient_document->title = $request->documenttitle;
|
||||
$patient_document->description = $request->description;
|
||||
if ($request->file('document')->isValid()) {
|
||||
$file = $request->file('document');
|
||||
$store = public_path() . '/uploads/patient-documents/';
|
||||
$file_name = $file->getClientOriginalName();
|
||||
$file->move($store, $file_name);
|
||||
$patient_document->path = public_path() . '/uploads/patient-documents/' . $file_name;
|
||||
}
|
||||
$patient_document->date_taken = \Carbon\Carbon::createFromFormat('d/m/Y', $request->documentdate)->toDateString();
|
||||
$patient_document->created_by = auth()->user()->id;
|
||||
$patient_document->úpdated_by = auth()->user()->id;
|
||||
$patient_document->save();
|
||||
flash("document has been added.")->success();
|
||||
return redirect('/patient_episodes');
|
||||
}
|
||||
}
|
||||
|
||||
public function modal_store(Request $request) {
|
||||
$validator = Validator::make($request->all(), [
|
||||
'documenttitle' => 'required',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
$string = "";
|
||||
foreach ($validator->errors()->getMessages() as $item) {
|
||||
$string .= "{$item[0]}<br>";
|
||||
}
|
||||
return back()->withErrors($validator)->withInput();
|
||||
} else {
|
||||
$patient_document = new PatientDocument;
|
||||
$patient_document->patient_id = session()->get('patient_id');
|
||||
$patient_document->episode_id = session()->get('episode_id');
|
||||
$patient_document->title = $request->documenttitle;
|
||||
$patient_document->description = $request->description;
|
||||
if ($request->file('document')->isValid()) {
|
||||
$file = $request->file('document');
|
||||
$store = public_path() . '/uploads/patient-documents/';
|
||||
$file_name = $file->getClientOriginalName();
|
||||
$file->move($store, $file_name);
|
||||
$patient_document->path = public_path() . '/uploads/patient-documents/' . $file_name;
|
||||
}
|
||||
$patient_document->date_taken = \Carbon\Carbon::createFromFormat('d/m/Y', $request->documentdate)->toDateString();
|
||||
$patient_document->created_by = auth()->user()->id;
|
||||
$patient_document->úpdated_by = auth()->user()->id;
|
||||
$patient_document->save();
|
||||
flash("document has been added.")->success();
|
||||
return redirect('/consultation/route');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show($id) {
|
||||
$document = PatientDocument::find($id);
|
||||
if (substr($document->path, 0, 25) === "../uploads/patient_upload") {
|
||||
$document_path_cleaned = str_replace("../uploads/patient_uploads", "/var/www/html/uploads/patient-documents", $document->path);
|
||||
} else {
|
||||
$document_path_cleaned = $document->path;
|
||||
}
|
||||
|
||||
$ext = pathinfo($document->path, PATHINFO_EXTENSION);
|
||||
|
||||
if ($ext == "pdf") {
|
||||
|
||||
return response()->file($document_path_cleaned, ['Content-Type' => 'application/pdf']);
|
||||
|
||||
} elseif ($ext == 'doc') {
|
||||
return response()->file($document_path_cleaned, [
|
||||
'Content-Type' => 'application/msword'
|
||||
]);
|
||||
} elseif ($ext == 'docx') {
|
||||
return response()->file($document_path_cleaned, [
|
||||
'Content-Type' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
|
||||
]);
|
||||
} elseif ($ext == 'xls') {
|
||||
return response()->file($document_path_cleaned, [
|
||||
'Content-Type' => 'application/vnd.ms-excel'
|
||||
]);
|
||||
} elseif ($ext == 'xlsx') {
|
||||
return response()->file($document_path_cleaned, [
|
||||
'Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
||||
]);
|
||||
} elseif ($ext == 'txt') {
|
||||
return response()->file($document_path_cleaned, [
|
||||
'Content-Type' => 'application/octet-stream'
|
||||
]);
|
||||
} elseif ($ext == 'png' || $ext == 'jpg' || $ext == 'JPG' || $ext == 'jpeg') {
|
||||
return response()->file($document_path_cleaned, [
|
||||
'Content-Type' => 'image/jpeg'
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit($id) {
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id) {
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($id) {
|
||||
$document = PatientDocument::find($id);
|
||||
if ($document->delete()):
|
||||
flash("document has been deleted.")->error();
|
||||
return redirect('/patient_documents/');
|
||||
endif;
|
||||
}
|
||||
|
||||
/*
|
||||
* put the episode id in the session before creating the document
|
||||
*/
|
||||
|
||||
public function set_episode_id($id) {
|
||||
session()->put(['episode_id' => $id]);
|
||||
}
|
||||
|
||||
}
|
||||
+1535
File diff suppressed because it is too large
Load Diff
Executable
+229
@@ -0,0 +1,229 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Patients\Http\Controllers;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Streamline\Models\Clinic;
|
||||
use Streamline\Models\PatientEpisode;
|
||||
use Streamline\Models\InpatientInfo;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Streamline\Models\Consultation;
|
||||
|
||||
class PatientFlowMonitoringController extends Controller {
|
||||
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('permission:patient-flow-monitoring');
|
||||
}
|
||||
|
||||
public function index(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;
|
||||
$order_by = $request->order_by ?? 1;
|
||||
|
||||
if (!isset($clinic_id) && !isset($search_by)){
|
||||
$clinic_id = session()->get('clinic_id');
|
||||
$search_by = session()->get('search_by');
|
||||
$reg_date = session()->get('reg_date');
|
||||
$start_date = session()->get('start_date');
|
||||
$end_date = session()->get('end_date');
|
||||
$order_by = session()->get('order_by');
|
||||
} else {
|
||||
session()->put('clinic_id', $clinic_id);
|
||||
session()->put('search_by', $search_by);
|
||||
session()->put('reg_date', $reg_date);
|
||||
session()->put('start_date', $start_date);
|
||||
session()->put('end_date', $end_date);
|
||||
session()->put('order_by', $order_by);
|
||||
}
|
||||
|
||||
$filters = [];
|
||||
|
||||
if($search_by === 0){
|
||||
// last 24 hours
|
||||
$last_day = Carbon::now()->subDay();
|
||||
|
||||
array_push($filters, ['patient_episodes.created_at', '>', $last_day]);
|
||||
$date_search = "Last 24 hours";
|
||||
} elseif($search_by == 1){
|
||||
// custom date
|
||||
$start_date_search = Carbon::parse($reg_date)->startOfDay()->toDateTimeString();;
|
||||
$end_date_search = Carbon::parse($reg_date)->endOfDay()->toDateTimeString();;
|
||||
|
||||
array_push($filters, ['patient_episodes.created_at', '>', $start_date_search]);
|
||||
array_push($filters, ['patient_episodes.created_at', '<', $end_date_search]);
|
||||
$date_search = streamline_date($start_date_search);
|
||||
} elseif($search_by == 2){
|
||||
// custom date range
|
||||
$start_date_search = Carbon::parse($start_date)->startOfDay()->toDateTimeString();;
|
||||
$end_date_search = Carbon::parse($end_date)->endOfDay()->toDateTimeString();;
|
||||
|
||||
array_push($filters, ['patient_episodes.created_at', '>', $start_date_search]);
|
||||
array_push($filters, ['patient_episodes.created_at', '<', $end_date_search]);
|
||||
$date_search = streamline_date($start_date_search) . " to " . streamline_date($end_date_search);
|
||||
} else {
|
||||
// Today
|
||||
$today = Carbon::today()->toDateTimeString();
|
||||
|
||||
array_push($filters, ['patient_episodes.created_at', '>=', $today]);
|
||||
$date_search = "Today";
|
||||
}
|
||||
|
||||
switch (get_select_clinic_order_type()) {
|
||||
case 0:
|
||||
if ($order_by == 0) {
|
||||
$order_by_text = "patient_episodes.id";
|
||||
} else {
|
||||
$order_by_text = "triage.severe_grade desc, patient_episodes.id";
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if ($order_by == 0) {
|
||||
$order_by_text = "patient_episodes.id desc";
|
||||
} else {
|
||||
$order_by_text = "triage.severe_grade desc, patient_episodes.id desc";
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
default:
|
||||
if ($order_by == 0) {
|
||||
$order_by_text = "consultations.completed, patient_episodes.id";
|
||||
} else {
|
||||
$order_by_text = "consultations.completed, triage.severe_grade desc, patient_episodes.id";
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if($clinic_id == 0){
|
||||
$patient_episodes = DB::table('patient_episodes')
|
||||
->whereNull('patient_episodes.deleted_at')
|
||||
->leftJoin('consultations', 'patient_episodes.id', '=', 'consultations.episode_id')
|
||||
->leftJoin('ante_natal_clinic_followups as a', 'patient_episodes.id', '=', 'a.episode_id')
|
||||
->leftJoin('triage', 'patient_episodes.id', '=', 'triage.episode_id')
|
||||
->select('patient_episodes.*', 'consultations.primary_diagnosis','consultations.outcome_id','consultations.completed','consultations.created_by as consultation_created_by','consultations.updated_by as consultation_updated_by','consultations.consultation_done_by', 'a.primary_diagnosis as antenatal_primary_diagnosis','a.outcome_id as antenatal_outcome_id','a.completion_status as antenatal_completed','a.created_by as antenatal_created_by','a.updated_by as antenatal_updated_by', 'triage.id as episode_triage_id', 'triage.severe_grade', 'triage.clinic_allocation')
|
||||
->where($filters)
|
||||
->orderByRaw($order_by_text)
|
||||
->paginate(200);
|
||||
$clinic_name = "OPD";
|
||||
} else {
|
||||
$patient_episodes = DB::table('patient_episodes')
|
||||
->whereNull('patient_episodes.deleted_at')
|
||||
->leftJoin('consultations', 'patient_episodes.id', '=', 'consultations.episode_id')
|
||||
->leftJoin('ante_natal_clinic_followups as a', 'patient_episodes.id', '=', 'a.episode_id')
|
||||
->leftJoin('triage', 'patient_episodes.id', '=', 'triage.episode_id')
|
||||
->where(['patient_episodes.clinic_id' => $clinic_id])->where($filters)
|
||||
->orderByRaw($order_by_text)
|
||||
->select('patient_episodes.*', 'consultations.primary_diagnosis','consultations.outcome_id','consultations.completed','consultations.created_by as consultation_created_by','consultations.updated_by as consultation_updated_by','consultations.consultation_done_by', 'a.primary_diagnosis as antenatal_primary_diagnosis','a.outcome_id as antenatal_outcome_id','a.completion_status as antenatal_completed','a.created_by as antenatal_created_by','a.updated_by as antenatal_updated_by','triage.id as episode_triage_id', 'triage.severe_grade', 'triage.clinic_allocation')
|
||||
->paginate(200);
|
||||
$clinic_name = get_name($clinic_id, 'id', 'name', 'clinics');
|
||||
}
|
||||
|
||||
$patient_categories = DB::table("patient_categories")->whereNull('deleted_at')->pluck("name", "id");
|
||||
|
||||
$clinics = DB::table("clinics")->whereNull("deleted_at")->orderBy("name")->pluck("name", "id")->toArray();
|
||||
$clinics = [0 => 'OPD'] + $clinics;
|
||||
$clinics = ['' => '- select -'] + $clinics;
|
||||
|
||||
$wards = DB::table('wards')->where('available', 1)->whereNull('deleted_at')->pluck("name", "id")->prepend('- select -', '');
|
||||
|
||||
return view('patients::patient_flow_monitoring.index', compact('patient_episodes', 'clinics', 'patient_categories','clinic_name','search_by', 'date_search', 'wards'));
|
||||
}
|
||||
|
||||
public function patient_route($episode_id, $route){
|
||||
|
||||
$episode = PatientEpisode::find($episode_id);
|
||||
$patient_id = $episode->patient_id;
|
||||
|
||||
// set up session
|
||||
session()->put(['patient_id' => $patient_id]);
|
||||
session()->put(['episode_id' => $episode_id]);
|
||||
|
||||
if($route == 'triage'){
|
||||
$url = '/triage';
|
||||
} elseif ($route == 'consultation'){
|
||||
$url = '/consultation/route';
|
||||
} elseif ($route == 'create_anaesthetics'){
|
||||
$url = '/anaesthetics/create';
|
||||
} elseif ($route == 'create_surgery'){
|
||||
$url = '/theatre_surgery/create';
|
||||
} elseif ($route == 'anaesthetics_history'){
|
||||
$url = '/anaesthetics/history';
|
||||
} elseif ($route == 'surgery_index'){
|
||||
$url = '/theatre_surgery';
|
||||
} elseif ($route == 'treatment') {
|
||||
$url = '/prescriptions/create';
|
||||
} elseif ($route == 'anc_registration_button'){
|
||||
$url = '/ante_natal_clinic/create';
|
||||
} elseif ($route == 'anc_followup_button'){
|
||||
$url = '/ante_natal_clinic_follow_up/create';
|
||||
} elseif ($route == 'investigation') {
|
||||
$url = '/investigations/investigations_review';
|
||||
} elseif ($route == 'triage_without_etat') {
|
||||
$url = '/triage/create_without_etat';
|
||||
} elseif ($route == 'consultation_with_notes') {
|
||||
$url = '/consultation/create_with_notes';
|
||||
} elseif ($route == 'view_patient_history') {
|
||||
$url = '/patient_episodes/';
|
||||
}
|
||||
|
||||
return response()->json($url);
|
||||
}
|
||||
|
||||
public function inpatient_admission(Request $request)
|
||||
{
|
||||
$episode = PatientEpisode::find($request->admission_episode_id);
|
||||
$patient_id = $episode->patient_id;
|
||||
$ward_id = $request->admission_ward_id;
|
||||
$admitted_on = $request->ward_admission_date;
|
||||
|
||||
try {
|
||||
$episode_id = $episode->id;
|
||||
session()->put(['episode_id' => $episode_id]);
|
||||
session()->put(['patient_id' => $patient_id]);
|
||||
|
||||
$consultation = Consultation::where(['patient_id' => $patient_id, 'episode_id' => $episode_id])->first();
|
||||
if ($consultation) {
|
||||
$consultation->outcome_id = get_name("Admitted", "name", "id", "outcomes");
|
||||
$consultation->ward_id = $ward_id;
|
||||
$consultation->admitted_on = $admitted_on;
|
||||
$consultation->save();
|
||||
}
|
||||
|
||||
// Admit patient in ward
|
||||
$existing_inpatient = InpatientInfo::where(['episode_id' => $episode_id])->first();
|
||||
if ($existing_inpatient) {
|
||||
$ward_id = $existing_inpatient->ward_id;
|
||||
$ward_name = get_name($ward_id, "id", "name", "wards");
|
||||
|
||||
flash("Patient ".get_name($patient_id, "id", "number", "patients")." already admitted for in admitted in ".$ward_name. ". You can use the ward transfer option incase you want to transfer to another ward")->error();
|
||||
} else {
|
||||
$inpatient = is_null($existing_inpatient) ? new InpatientInfo : $existing_inpatient;
|
||||
$inpatient = new InpatientInfo;
|
||||
$inpatient->patient_id = $patient_id;
|
||||
$inpatient->episode_id = $episode_id;
|
||||
$inpatient->admitted_on = $admitted_on;
|
||||
$inpatient->ward_id = $ward_id;
|
||||
$inpatient->created_by = auth()->user()->id;
|
||||
$inpatient->created_at = Carbon::now();
|
||||
$inpatient->save();
|
||||
|
||||
$ward_name = get_name($ward_id, "id", "name", "wards");
|
||||
|
||||
flash("Patient ".get_name($patient_id, "id", "number", "patients")." 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+309
@@ -0,0 +1,309 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Patients\Http\Controllers;
|
||||
|
||||
use Barryvdh\Snappy\Facades\SnappyPdf;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Streamline\Models\HospitalInformation;
|
||||
use Streamline\Models\VhtContact;
|
||||
|
||||
class PostDischargeRiskController extends Controller {
|
||||
|
||||
public function view_scores(Request $request) {
|
||||
if (isset($request->start_date)){
|
||||
$start_date = Carbon::parse($request->start_date)->startOfDay();
|
||||
$end_date = Carbon::parse($request->end_date)->endOfDay();
|
||||
} else {
|
||||
$start_date = Carbon::now()->startOfDay();
|
||||
$end_date = Carbon::now()->endOfDay();
|
||||
}
|
||||
|
||||
$risk_scores = DB::table('discharge_mortality_risk')
|
||||
->whereNotNull('post_discharge_mortality_risk')
|
||||
->whereNotNull('inpatient_id')
|
||||
->where('child_with_proven_infection', 1)
|
||||
->whereBetween('created_at', [$start_date, $end_date])
|
||||
->get(['id', 'patient_id', 'gender', 'date_of_birth', 'post_discharge_mortality_risk',
|
||||
'updated_at', 'is_vht_alerted', 'inpatient_id', 'child_with_proven_infection']);
|
||||
|
||||
$search_text = "From " . streamline_date($start_date) . " to " . streamline_date($end_date);
|
||||
|
||||
return view('patients::post_discharge_risk.view_scores', compact('risk_scores', 'search_text'));
|
||||
}
|
||||
|
||||
public function vht_discharge_forms(Request $request) {
|
||||
//
|
||||
}
|
||||
|
||||
public function print_vht_discharge_forms($discharge_risk_score_id) {
|
||||
$hospital_info = HospitalInformation::find(1);
|
||||
|
||||
$discharge_risk_score = DB::table('discharge_mortality_risk')
|
||||
->where('id', $discharge_risk_score_id)
|
||||
->first();
|
||||
|
||||
$patient_id = $discharge_risk_score->patient_id;
|
||||
|
||||
if ($discharge_risk_score->inpatient_id) {
|
||||
$admission_date = streamline_date(get_name($discharge_risk_score->inpatient_id, 'id', 'admitted_on', 'inpatient_info'));
|
||||
$discharge_date = streamline_date(get_name($discharge_risk_score->inpatient_id, 'id', 'discharged_on', 'inpatient_info'));
|
||||
$diagnosis_id = get_name($discharge_risk_score->inpatient_id, 'id', 'primary_diagnosis', 'inpatient_info');
|
||||
$discharge_diagnosis = get_name($diagnosis_id, 'id', 'name', 'diagnoses');
|
||||
$main_symptom = explode(",", get_name($discharge_risk_score->episode_id, 'episode_id', 'symptoms', 'triage'))[0] ?? "";
|
||||
} else {
|
||||
$admission_date = "";
|
||||
$discharge_date = "";
|
||||
$discharge_diagnosis = "";
|
||||
$main_symptom = "";
|
||||
}
|
||||
|
||||
// get the dates for when the follow ups where scheduled
|
||||
$scheduled_followups = DB::table('phone_followup_patients')
|
||||
->where('discharge_mortality_risk_id', $discharge_risk_score_id)
|
||||
->get();
|
||||
|
||||
$vht_name = "";
|
||||
$vht_contact = "";
|
||||
|
||||
if (count($scheduled_followups) > 0) {
|
||||
$first_followup_date = streamline_date($scheduled_followups[0]->follow_up_date);
|
||||
$second_followup_date = streamline_date($scheduled_followups[1]->follow_up_date);
|
||||
$third_followup_date = streamline_date($scheduled_followups[2]->follow_up_date);
|
||||
$vht_name = get_name($scheduled_followups[2]->vht_id, 'id', 'name', 'vht_contacts');
|
||||
$vht_contact = get_name($scheduled_followups[2]->vht_id, 'id', 'contact', 'vht_contacts');
|
||||
} else {
|
||||
$first_followup_date = "";
|
||||
$second_followup_date = "";
|
||||
$third_followup_date = "";
|
||||
}
|
||||
|
||||
$data = [
|
||||
'hospital_info' => $hospital_info,
|
||||
'admission_date' => $admission_date,
|
||||
'discharge_date' => $discharge_date,
|
||||
'patient_id' => $patient_id,
|
||||
'discharge_risk_score' => $discharge_risk_score,
|
||||
'first_followup_date' => $first_followup_date,
|
||||
'second_followup_date' => $second_followup_date,
|
||||
'third_followup_date' => $third_followup_date,
|
||||
'vht_name' => $vht_name,
|
||||
'vht_contact' => $vht_contact,
|
||||
'discharge_diagnosis' => $discharge_diagnosis,
|
||||
'main_symptom' => $main_symptom,
|
||||
];
|
||||
|
||||
$pdf = SnappyPDF::loadView('patients::post_discharge_risk/print_vht_discharge_forms', $data)
|
||||
->setPaper('a4')
|
||||
->setOption('margin-bottom', 10)
|
||||
->setOption('footer-html', '<i>Stre@mline</i>');
|
||||
|
||||
|
||||
return $pdf->inline('VHT Discharge Form' . date(" d-m-y h:ia") . '.pdf');
|
||||
}
|
||||
|
||||
public function assign_vht($discharge_id) {
|
||||
//$vhts = DB::table('vht_contacts')->get();
|
||||
$post_discharge = DB::table('discharge_mortality_risk')->find($discharge_id);
|
||||
$patient = DB::table('patients')->find($post_discharge->patient_id);
|
||||
|
||||
return view('patients::post_discharge_risk.assign_vht', compact('patient', 'discharge_id'));
|
||||
}
|
||||
|
||||
public function search_vht_by_name_village(Request $request) {
|
||||
$data = [];
|
||||
|
||||
if ($request->has('q')) {
|
||||
$search = $request->q;
|
||||
$data = DB::table('vht_contacts')->select("id", "parish_name", "village_name", "name")
|
||||
->orWhere('village_name', 'LIKE', "%$search%")
|
||||
->orWhere('name', 'LIKE', "%$search%")
|
||||
->get();
|
||||
}
|
||||
|
||||
return response()->json($data);
|
||||
}
|
||||
|
||||
public function get_info_about_vht($vht_id) {
|
||||
$data = DB::table('vht_contacts')->find($vht_id);
|
||||
|
||||
return $data->name . " (" . $data->contact . ")" . "&&" . $data->facility . "&&" . $data->parish_name . "&&" . $data->village_name;
|
||||
}
|
||||
|
||||
public function save_assign_vht(Request $request) {
|
||||
$discharge_id = $request->discharge_id;
|
||||
|
||||
// get the discharge info
|
||||
$post_discharge = DB::table('discharge_mortality_risk')->find($request->discharge_id);
|
||||
|
||||
$patient_id = $post_discharge->patient_id;
|
||||
|
||||
$inpatient_id = get_name($request->discharge_id, 'id', 'inpatient_id', 'discharge_mortality_risk');
|
||||
|
||||
$inpatient_info = DB::table('inpatient_info')
|
||||
->where('id', $inpatient_id)
|
||||
->first();
|
||||
|
||||
// vht contact info
|
||||
$vht = DB::table('vht_contacts')->find($request->vht_id);
|
||||
|
||||
$discharge_date = new Carbon(get_patient_discharge_date($inpatient_id));
|
||||
$first_followup_date = $discharge_date->copy()->addDays(2);
|
||||
$second_followup_date = $discharge_date->copy()->addDays(7);
|
||||
$third_followup_date = $discharge_date->copy()->addDays(14);
|
||||
|
||||
if ($vht) {
|
||||
// send the message
|
||||
DB::table('phone_followup_patients')
|
||||
->insert(['patient_id' => $patient_id, 'created_at' => date('Y-m-d H:i:s'), 'vht_id' => $vht->id,
|
||||
'episode_id' => $inpatient_info->episode_id, 'inpatient_id' => $inpatient_info->id, 'discharge_mortality_risk_id' => $discharge_id,
|
||||
'follow_up_date' => $first_followup_date, 'discharge_date' => get_patient_discharge_date($inpatient_id)]);
|
||||
|
||||
DB::table('phone_followup_patients')
|
||||
->insert(['patient_id' => $patient_id, 'created_at' => date('Y-m-d H:i:s'), 'vht_id' => $vht->id,
|
||||
'episode_id' => $inpatient_info->episode_id, 'inpatient_id' => $inpatient_info->id, 'discharge_mortality_risk_id' => $discharge_id,
|
||||
'follow_up_date' => $second_followup_date, 'discharge_date' => get_patient_discharge_date($inpatient_id)]);
|
||||
|
||||
DB::table('phone_followup_patients')
|
||||
->insert(['patient_id' => $patient_id, 'created_at' => date('Y-m-d H:i:s'), 'vht_id' => $vht->id,
|
||||
'episode_id' => $inpatient_info->episode_id, 'inpatient_id' => $inpatient_info->id, 'discharge_mortality_risk_id' => $discharge_id,
|
||||
'follow_up_date' => $third_followup_date, 'discharge_date' => get_patient_discharge_date($inpatient_id)]);
|
||||
|
||||
$patient = DB::table('patients')->where('id', $patient_id)->first();
|
||||
|
||||
$message = "Dear VHT,\nA child from your area was discharged today. Please complete 3 follow-up visits to assess recovery.\n\nDetails:\n";
|
||||
$message .= "Child: " . $patient->first_name . " " . $patient->last_name . ",";
|
||||
$message .= " " . ($patient->gender == 1) ? "Boy" : "Girl" . ",";
|
||||
$message .= " " . get_patients_age($patient->date_of_birth) . " years,";
|
||||
$message .= " " . get_name($patient->village_id, 'id', 'name', 'villages') . "\n";
|
||||
|
||||
$message .= "From: Kisiizi Hospital\n";
|
||||
|
||||
if ($patient->parent_id) {
|
||||
$message .= "Parent: " . get_full_name($patient->parent_id, 'id', 'first_name', 'last_name', 'patients') . ", " . get_name($patient->parent_id, 'id', 'phone', 'patients') . "\n";
|
||||
} elseif ($patient->hospital_contact) {
|
||||
$message .= "Parent: " . $patient->hospital_contact_name . ", " . $patient->hospital_contact . "\n";
|
||||
} elseif ($patient->next_of_kin) {
|
||||
$message .= "Parent: " . $patient->next_of_kin . ", " . $patient->phone_of_next_of_kin . "\n";
|
||||
}
|
||||
|
||||
$number = "+256" . $vht->contact;
|
||||
|
||||
$message .= "Follow-ups: " . $first_followup_date->format('D j M') . ", " . $second_followup_date->format('D j M') . ", " . $third_followup_date->format('D j M') . "";
|
||||
|
||||
send_sms($number, $message);
|
||||
|
||||
DB::table('discharge_mortality_risk')
|
||||
->where('id', $discharge_id)
|
||||
->update(['is_vht_alerted' => 1]);
|
||||
|
||||
send_data_to_redcap($discharge_id);
|
||||
|
||||
flash("VHT has been assigned and an SMS message has been sent to them")->success();
|
||||
|
||||
return redirect('/post_discharge_risk/view_scores');
|
||||
} else {
|
||||
flash("No VHT was found for the patient")->error();
|
||||
return redirect('/post_discharge_risk/view_scores');
|
||||
}
|
||||
}
|
||||
|
||||
public function retry_sending_message($discharge_risk_score_id) {
|
||||
$discharge_id = $discharge_risk_score_id;
|
||||
|
||||
// get the discharge info
|
||||
$post_discharge = DB::table('discharge_mortality_risk')->find($discharge_id);
|
||||
|
||||
$patient_id = $post_discharge->patient_id;
|
||||
|
||||
$inpatient_id = get_name($discharge_id, 'id', 'inpatient_id', 'discharge_mortality_risk');
|
||||
|
||||
$inpatient_info = DB::table('inpatient_info')
|
||||
->where('id', $inpatient_id)
|
||||
->first();
|
||||
|
||||
$vht = DB::table('vht_contacts')
|
||||
->where('village', get_name($patient_id, 'id', 'village_id', 'patients'))
|
||||
->orWhere('village', get_name(get_name($patient_id, 'id', 'village_id', 'patients'), 'id', 'name', 'villages'))
|
||||
->first();
|
||||
|
||||
$discharge_date = new Carbon(get_patient_discharge_date($inpatient_id));
|
||||
$first_followup_date = $discharge_date->copy()->addDays(2);
|
||||
$second_followup_date = $discharge_date->copy()->addDays(7);
|
||||
$third_followup_date = $discharge_date->copy()->addDays(14);
|
||||
|
||||
if ($vht) {
|
||||
// send the message
|
||||
DB::table('phone_followup_patients')
|
||||
->insert(['patient_id' => $patient_id, 'created_at' => date('Y-m-d H:i:s'), 'vht_id' => $vht->id,
|
||||
'episode_id' => $inpatient_info->episode_id, 'inpatient_id' => $inpatient_info->id, 'discharge_mortality_risk_id' => $discharge_id,
|
||||
'follow_up_date' => $first_followup_date, 'discharge_date' => get_patient_discharge_date($inpatient_id)]);
|
||||
|
||||
DB::table('phone_followup_patients')
|
||||
->insert(['patient_id' => $patient_id, 'created_at' => date('Y-m-d H:i:s'), 'vht_id' => $vht->id,
|
||||
'episode_id' => $inpatient_info->episode_id, 'inpatient_id' => $inpatient_info->id, 'discharge_mortality_risk_id' => $discharge_id,
|
||||
'follow_up_date' => $second_followup_date, 'discharge_date' => get_patient_discharge_date($inpatient_id)]);
|
||||
|
||||
DB::table('phone_followup_patients')
|
||||
->insert(['patient_id' => $patient_id, 'created_at' => date('Y-m-d H:i:s'), 'vht_id' => $vht->id,
|
||||
'episode_id' => $inpatient_info->episode_id, 'inpatient_id' => $inpatient_info->id, 'discharge_mortality_risk_id' => $discharge_id,
|
||||
'follow_up_date' => $third_followup_date, 'discharge_date' => get_patient_discharge_date($inpatient_id)]);
|
||||
|
||||
$patient = DB::table('patients')->where('id', $patient_id)->first();
|
||||
|
||||
$message = "Dear VHT,\nA child from your area was discharged today. Please complete 3 follow-up visits to assess recovery.\n\nDetails:\n";
|
||||
$message .= "Child: " . $patient->first_name . " " . $patient->last_name . ",";
|
||||
$message .= " " . ($patient->gender == 1) ? "Boy" : "Girl" . ",";
|
||||
$message .= " " . get_patients_age($patient->date_of_birth) . " years,";
|
||||
$message .= " " . get_name($patient->village_id, 'id', 'name', 'villages') . "\n";
|
||||
|
||||
$message .= "From: Kisiizi Hospital\n";
|
||||
|
||||
if ($patient->parent_id) {
|
||||
$message .= "Parent: " . get_full_name($patient->parent_id, 'id', 'first_name', 'last_name', 'patients') . ", " . get_name($patient->parent_id, 'id', 'phone', 'patients') . "\n";
|
||||
} elseif ($patient->hospital_contact) {
|
||||
$message .= "Parent: " . $patient->hospital_contact_name . ", " . $patient->hospital_contact . "\n";
|
||||
} elseif ($patient->next_of_kin) {
|
||||
$message .= "Parent: " . $patient->next_of_kin . ", " . $patient->phone_of_next_of_kin . "\n";
|
||||
}
|
||||
|
||||
$number = "+256" . $vht->contact;
|
||||
|
||||
$message .= "Follow-ups: " . $first_followup_date->format('D j M') . ", " . $second_followup_date->format('D j M') . ", " . $third_followup_date->format('D j M') . "";
|
||||
|
||||
send_sms($number, $message);
|
||||
|
||||
DB::table('discharge_mortality_risk')
|
||||
->where('id', $discharge_id)
|
||||
->update(['is_vht_alerted' => 1]);
|
||||
|
||||
send_data_to_redcap($discharge_risk_score_id);
|
||||
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public function view_follow_up_patients(Request $request) {
|
||||
if (isset($request->start_date)){
|
||||
$start_date = Carbon::parse($request->start_date)->startOfDay();
|
||||
$end_date = Carbon::parse($request->end_date)->endOfDay();
|
||||
} else {
|
||||
$start_date = Carbon::now()->startOfDay();
|
||||
$end_date = Carbon::now()->endOfDay();
|
||||
}
|
||||
|
||||
$risk_scores = DB::table('discharge_mortality_risk')
|
||||
->whereNotNull('post_discharge_mortality_risk')
|
||||
->whereNotNull('inpatient_id')
|
||||
->where('child_with_proven_infection', 1)
|
||||
->whereBetween('created_at', [$start_date, $end_date])
|
||||
->get();
|
||||
|
||||
$search_text = "From " . streamline_date($start_date) . " to " . streamline_date($end_date);
|
||||
|
||||
return view('patients::post_discharge_risk.view_follow_up_patients', compact('risk_scores', 'search_text'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user