Files
alec.turner a424394109 Build modified streamline images
The official image from streamline does not currently work for the arm64
platform. As a temporary measure, the source code and docker build scripts
have been lifted from the official images and are used to build locally.

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

128 lines
4.3 KiB
PHP
Executable File

<?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();
}
}