mirror of
https://gitlab.com/signalytic/client-external/streamline/streamline-emr.git
synced 2026-09-11 18:51:31 +00:00
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
132 lines
3.9 KiB
PHP
Executable File
132 lines
3.9 KiB
PHP
Executable File
<?php
|
|
|
|
namespace Streamline\Http\Controllers;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Streamline\Models\BloodDonation;
|
|
use Streamline\Models\User;
|
|
use Carbon\Carbon;
|
|
use DB;
|
|
|
|
class BloodDonationsController extends Controller {
|
|
|
|
public function __construct() {
|
|
$this->middleware('auth');
|
|
$this->middleware('permission:find-a-donor', ['only' => ['index']]);
|
|
}
|
|
|
|
/**
|
|
* Display a listing of the resource.
|
|
*
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function index() {
|
|
$willing_donors = User::where(['willing_to_donate' => 1])->orderBy('blood_group_id', 'asc')->get();
|
|
$blood_groups = DB::table('blood_groups')
|
|
// ->where('active', 1)
|
|
->pluck("name", "id")
|
|
->prepend('- Select -', '');
|
|
return view('blood_donations.index', compact('willing_donors', 'blood_groups'));
|
|
}
|
|
|
|
/*
|
|
* Show the donors of selected blood group
|
|
*/
|
|
|
|
public function select_blood_group(Request $request) {
|
|
$willing_donors = User::where(['blood_group_id' => $request->blood_group_id, 'willing_to_donate' => 1])->orderBy('blood_group_id', 'asc')->get();
|
|
$blood_groups = DB::table('blood_groups')
|
|
// ->where('active', 1)
|
|
->pluck("name", "id")
|
|
->prepend('- Select -', '');
|
|
return view('blood_donations.index', compact('willing_donors', 'blood_groups'));
|
|
}
|
|
|
|
/**
|
|
* Show the form for creating a new resource.
|
|
*
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function create() {
|
|
$donor_id = session()->get('donor_id');
|
|
$donor = User::find($donor_id);
|
|
return view('blood_donations.create', compact('donor'));
|
|
}
|
|
|
|
/*
|
|
* put the donor_id(same as $user->id) into a session then redirect to $this->create() function
|
|
*/
|
|
|
|
public function create_donation(Request $request) {
|
|
$selected_donor_id = $request->donor_id;
|
|
$donor_id = session()->put(['donor_id' => $selected_donor_id]);
|
|
return redirect('blood_donations/create');
|
|
}
|
|
|
|
/**
|
|
* Store a newly created resource in storage.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function store(Request $request) {
|
|
$donation_date = Carbon::createFromFormat('d/m/Y', $request->donation_date)->toDateString();
|
|
$donor_id = $request->donor_id;
|
|
|
|
$new_blood_donation = new BloodDonation;
|
|
$new_blood_donation->donor_id = $donor_id;
|
|
$new_blood_donation->last_donation_date = $donation_date;
|
|
$new_blood_donation->created_by = auth()->user()->id;
|
|
if ($new_blood_donation->save()) {
|
|
flash('New blood donation has been succesfully recorded')->success();
|
|
return redirect('blood_donations');
|
|
}
|
|
flash('error occured. Contact system admiin')->error();
|
|
return redirect()->back()->withInput();
|
|
}
|
|
|
|
/**
|
|
* Display the specified resource.
|
|
*
|
|
* @param int $id
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function show($id) {
|
|
$donor = User::find($id);
|
|
$blood_donations = BloodDonation::where('donor_id', $id)->orderBy('last_donation_date', 'desc')->get();
|
|
return view('blood_donations.show', compact('donor', 'blood_donations'));
|
|
}
|
|
|
|
/**
|
|
* 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) {
|
|
//
|
|
}
|
|
|
|
}
|