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:
2024-03-10 16:17:50 -07:00
parent 2ffc3c408a
commit a424394109
13506 changed files with 1860172 additions and 6 deletions
@@ -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]);
}
}