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:
+171
@@ -0,0 +1,171 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\ClinicalData\Http\Controllers;
|
||||
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Http\Request;
|
||||
use Streamline\Http\Controllers\Auth;
|
||||
use Streamline\Http\Controllers\Controller;
|
||||
use Streamline\Models\PatientRegistrationField;
|
||||
|
||||
class PatientRegistrationFieldController extends Controller
|
||||
{
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('permission:list-patient-registration-fields', ['only' => ['index', 'select']]);
|
||||
$this->middleware('permission:create-patient-registration-field', ['only' => ['create', 'store']]);
|
||||
$this->middleware('permission:edit-patient-registration-field', ['only' => ['edit', 'update']]);
|
||||
$this->middleware('permission:delete-patient-registration-field', ['only' => ['destroy', 'inactive', 'activate']]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$patient_registration_fields = PatientRegistrationField::orderBy('name', 'asc')->paginate(50);
|
||||
|
||||
return view('clinical_data::patient_registration_fields.index', compact('patient_registration_fields'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return view('clinical_data::patient_registration_fields.create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
request()->validate([
|
||||
'name' => 'required|string|max:255|unique:patient_registration_fields',
|
||||
'compulsory'=> 'required|in:1,0'
|
||||
]);
|
||||
|
||||
$patient_registration_field = new PatientRegistrationField();
|
||||
$patient_registration_field->name = $request->name;
|
||||
$patient_registration_field->compulsory = $request->compulsory;
|
||||
$patient_registration_field->options = ($request->options_or_range == '2')? implode(',', $request->options):null;
|
||||
$patient_registration_field->created_by = Auth::id();
|
||||
|
||||
try {
|
||||
$patient_registration_field->save();
|
||||
flash($request->name . " Patient registration field has been saved")->success();
|
||||
return redirect("/patient_registration_fields/");
|
||||
} catch (QueryException $e) {
|
||||
flash("An error occurred")->error();
|
||||
return back()->withInput();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
$patient_registration_field = PatientRegistrationField::findOrFail($id);
|
||||
return view('clinical_data::patient_registration_fields.edit', compact('patient_registration_field'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
request()->validate([
|
||||
'name' => 'required|string|max:255|unique:patient_registration_fields,name,'.$id,
|
||||
'compulsory'=> 'required|in:1,0'
|
||||
]);
|
||||
|
||||
$patient_registration_field = PatientRegistrationField::find($id);
|
||||
$patient_registration_field->name = $request->name;
|
||||
$patient_registration_field->compulsory = $request->compulsory;
|
||||
$patient_registration_field->options = ($request->options_or_range == '2')? implode(',', $request->options):null;
|
||||
$patient_registration_field->updated_by = Auth::id();
|
||||
try {
|
||||
$patient_registration_field->save();
|
||||
flash($request->name . " Patient registration field has been updated")->success();
|
||||
return redirect("/patient_registration_fields/");
|
||||
} catch (QueryException $e) {
|
||||
flash("An error occurred")->error();
|
||||
return back()->withInput();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
$patient_registration_field = PatientRegistrationField::findOrFail($id);
|
||||
|
||||
if ($patient_registration_field->delete()) {
|
||||
flash("Patient Registration Field has been deleted.")->success();
|
||||
return redirect('/patient_registration_fields/');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the inactive resources.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function inactive()
|
||||
{
|
||||
$patient_registration_fields = PatientRegistrationField::onlyTrashed()->orderBy('created_at', 'desc')->paginate(50);
|
||||
|
||||
return view('clinical_data::patient_registration_fields.inactive', compact('patient_registration_fields'));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Activate the specified resource in storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function activate($id)
|
||||
{
|
||||
$patient_registration_field = PatientRegistrationField::onlyTrashed()->findOrFail($id);
|
||||
|
||||
if ($patient_registration_field->restore()) {
|
||||
flash("Patient Registration Field has been activated.")->success();
|
||||
return redirect('/patient_registration_fields/');
|
||||
} else {
|
||||
flash()->error("Patient Registration Field hasn't been activated.");
|
||||
return redirect()->route('patient_registration_fields.inactive');
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user