modified assests
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Console\Commands;
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
use App\Models\Laboratory;
|
use App\Models\Organization;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
@@ -41,7 +41,7 @@ class DisableLabAccess extends Command
|
|||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
try{
|
try{
|
||||||
$labs = Laboratory::query()->where('record_status_id', 1)
|
$labs = Organization::query()->where('record_status_id', 1)
|
||||||
->whereRaw("DATEDIFF(end_date, CURDATE())<=-7")
|
->whereRaw("DATEDIFF(end_date, CURDATE())<=-7")
|
||||||
->update(['record_status_id' => 0]);
|
->update(['record_status_id' => 0]);
|
||||||
Log::channel('jobs')->info($labs);
|
Log::channel('jobs')->info($labs);
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Console\Commands;
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
use App\Models\Laboratory;
|
use App\Models\Organization;
|
||||||
use App\Models\Publication;
|
use App\Models\Publication;
|
||||||
use App\Models\PublicationReceiver;
|
use App\Models\PublicationReceiver;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
@@ -43,7 +43,7 @@ class NotifyExpireLab extends Command
|
|||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
try{
|
try{
|
||||||
$labs = Laboratory::query()->where('record_status_id', 1)
|
$labs = Organization::query()->where('record_status_id', 1)
|
||||||
->whereNotNull('end_date')
|
->whereNotNull('end_date')
|
||||||
->whereRaw("DATEDIFF(end_date, CURDATE())=7")->get();
|
->whereRaw("DATEDIFF(end_date, CURDATE())=7")->get();
|
||||||
|
|
||||||
@@ -65,7 +65,7 @@ class NotifyExpireLab extends Command
|
|||||||
|
|
||||||
PublicationReceiver::query()->create([
|
PublicationReceiver::query()->create([
|
||||||
'publication_id' => $publication->id,
|
'publication_id' => $publication->id,
|
||||||
'lab_id' => $lab->id,
|
'organization_id' => $lab->id,
|
||||||
'created_by' => 1
|
'created_by' => 1
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ class Helpers
|
|||||||
INNER JOIN publication_receivers pr
|
INNER JOIN publication_receivers pr
|
||||||
ON pr.publication_id = p.id
|
ON pr.publication_id = p.id
|
||||||
WHERE DATE(NOW()) BETWEEN start_date AND end_date AND p.record_status_id = 1
|
WHERE DATE(NOW()) BETWEEN start_date AND end_date AND p.record_status_id = 1
|
||||||
AND pr.lab_id = " . Session::get('base_lab_id'));
|
AND pr.organization_id = " . Session::get('base_organization_id'));
|
||||||
return $publication;
|
return $publication;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,101 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
|
||||||
use App\Enums\RecordStatusEnum;
|
|
||||||
use App\Http\Controllers\Helper\GlobalController;
|
|
||||||
use App\Http\Requests\TestSampleCreateRequest;
|
|
||||||
use App\Http\Resources\AntibioticResource;
|
|
||||||
use App\Models\Antibiotic;
|
|
||||||
use App\Models\BaseModel;
|
|
||||||
use App\Models\Organism;
|
|
||||||
use App\Models\PatientType;
|
|
||||||
use App\Models\SampleType;
|
|
||||||
use App\Models\Test;
|
|
||||||
use App\Models\TestNormalValue;
|
|
||||||
use App\Models\TestSample;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Illuminate\Support\Facades\Auth;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
use Illuminate\Support\Facades\Session;
|
|
||||||
|
|
||||||
class AntibioticController extends Controller
|
|
||||||
{
|
|
||||||
|
|
||||||
protected $model;
|
|
||||||
protected $baseLabId;
|
|
||||||
protected $labs;
|
|
||||||
protected $departments;
|
|
||||||
|
|
||||||
public function __construct(Antibiotic $antibioticModel){
|
|
||||||
$this->model = $antibioticModel;
|
|
||||||
$this->baseLabId = Session::get('base_lab_id');
|
|
||||||
$this->base = Session::get('base_lab');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function index(Request $request){
|
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['view_antibiotic'])) return redirect(url('my-profile'));
|
|
||||||
$antibiotics = $this->model::with(['lab'])->where(BaseModel::RECORD_STATUS_FIELD, RecordStatusEnum::ACTIVE)
|
|
||||||
->when(!empty($request->kword), function ($antibiotics) use($request){
|
|
||||||
$antibiotics->whereRaw("replace(name_en, ' ','') like '%".str_replace(" ","",$request->kword)."%'");
|
|
||||||
})->orderBy(BaseModel::CREATED_AT_FIELD,'desc')->paginate(config('labis.pagination.perpage', 10));
|
|
||||||
return view('antibiotic', ['antibiotics' => AntibioticResource::collection($antibiotics)]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function save(Request $request){
|
|
||||||
try{
|
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['create_antibiotic'])) return false;
|
|
||||||
$validator = \Validator::make($request->all(), ['name_en' => 'required']);
|
|
||||||
if ($validator->fails()) return response()->json(['success' => false, 'message' => __('antibiotic.create_fail'), 'errors' => $validator->errors()->all()]);
|
|
||||||
$antibiotic = $this->model::query()->create([ 'name_en' => $request->name_en, 'weight' => $request->weight]);
|
|
||||||
return response()->json(['success' => true, 'message' => __('antibiotic.create_success'), 'data' => [$antibiotic]]);
|
|
||||||
} catch (\Exception $e){
|
|
||||||
return response()->json(['success' => false, 'message' => __('antibiotic.create_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function update(Request $request){
|
|
||||||
try{
|
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['update_antibiotic'])) return false;
|
|
||||||
$validator = \Validator::make($request->all(), ['name_en' => 'required']);
|
|
||||||
if ($validator->fails()) return response()->json(['success' => false, 'message' => __('antibiotic.update_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
$data = array(
|
|
||||||
'name_en' => $request->name_en,
|
|
||||||
'weight' => $request->weight
|
|
||||||
);
|
|
||||||
$this->model::query()->where('id', $request->uid)->update($data);
|
|
||||||
return response()->json(['success' => true, 'message' => __('antibiotic.update_success')]);
|
|
||||||
} catch (\Exception $e){
|
|
||||||
return response()->json(['success' => false, 'message' => __('antibiotic.update_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function get(Request $request){
|
|
||||||
try{
|
|
||||||
$antibiotic = $this->model::query()->find($request->uid);
|
|
||||||
return response()->json(['success' => true, 'message' => __('antibiotic.get_success'), 'data' => new AntibioticResource($antibiotic)]);
|
|
||||||
} catch (\Exception $e){
|
|
||||||
return response()->json(['success' => false, 'message' => __('antibiotic.get_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function delete(Request $request){
|
|
||||||
try{
|
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['delete_antibiotic'])) return false;
|
|
||||||
$this->model::query()->where('id', $request->uid)->update(array('record_status_id'=> RecordStatusEnum::DELETE));
|
|
||||||
return response()->json(['success' => true, 'message' => __('antibiotic.delete_success')]);
|
|
||||||
} catch (\Exception $e){
|
|
||||||
return response()->json(['success' => false, 'message' => __('antibiotic.delete_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function restore(Request $request){
|
|
||||||
try{
|
|
||||||
$this->model::query()->where('id', $request->uid)->update(array('record_status_id'=> RecordStatusEnum::ACTIVE));
|
|
||||||
return response()->json(['success' => true, 'message' => __('antibiotic.restore_success')]);
|
|
||||||
} catch (\Exception $e){
|
|
||||||
return response()->json(['success' => false, 'message' => __('antibiotic.restore_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -41,7 +41,7 @@ class SampleResultController extends Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return response()->json(['success' => true, 'message' => __('Laboratory result already pushed!')]);
|
return response()->json(['success' => true, 'message' => __('Organization result already pushed!')]);
|
||||||
} catch (\Exception $e){
|
} catch (\Exception $e){
|
||||||
return response()->json(['success' => false, 'message' => __('Failed while pushing laboratory result!'), 'errors' => $e->getMessage()]);
|
return response()->json(['success' => false, 'message' => __('Failed while pushing laboratory result!'), 'errors' => $e->getMessage()]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,117 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
|
||||||
use App\Enums\RecordStatusEnum;
|
|
||||||
use App\Http\Controllers\Helper\GlobalController;
|
|
||||||
use App\Models\Appointment;
|
|
||||||
use App\Models\BaseModel;
|
|
||||||
use App\Models\ConceptCode;
|
|
||||||
use App\Models\Patient;
|
|
||||||
use App\Models\Physician;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Illuminate\Support\Facades\Auth;
|
|
||||||
use Illuminate\Support\Facades\Session;
|
|
||||||
use Carbon\Carbon;
|
|
||||||
|
|
||||||
class AppointmentController extends Controller
|
|
||||||
{
|
|
||||||
|
|
||||||
protected $model;
|
|
||||||
protected $patientModel;
|
|
||||||
protected $baseLabId;
|
|
||||||
|
|
||||||
protected $physicianModel;
|
|
||||||
|
|
||||||
public function __construct(){
|
|
||||||
$this->model = new Appointment();
|
|
||||||
$this->patientModel = new Patient();
|
|
||||||
$this->physicianModel = new Physician();
|
|
||||||
$this->baseLabId = Session::get('base_lab_id');
|
|
||||||
$this->base = Session::get('base_lab');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function index(Request $request){
|
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['view_appointment'])) return redirect(url('my-profile'));
|
|
||||||
$conceptCodes = $this->model::query()->where([BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->groupBy('appointment_type')->get('appointment_type');
|
|
||||||
$patients = $this->patientModel::query()->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => BaseModel::RECORD_STATUS_ACTIVE])->limit(20)->get();
|
|
||||||
$physicians = $this->physicianModel::query()->where([BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE, 'lab_id' => $this->baseLabId])->orderBy('name_en', 'ASC')->get();
|
|
||||||
$appointments = $this->model::with(['patient', 'doctor'])->where(BaseModel::RECORD_STATUS_FIELD, BaseModel::RECORD_STATUS_ACTIVE)
|
|
||||||
->where('lab_id', $this->baseLabId)
|
|
||||||
->when(!empty($request->appointment_type), function ($query) use($request){
|
|
||||||
$query->where('appointment_type', $request->appointment_type);
|
|
||||||
})->when(!empty($request->appointment_date), function ($query) use($request) {
|
|
||||||
$query->whereDate('appointment_date', date('Y-m-d', strtotime($request->appointment_date)));
|
|
||||||
})->orderBy('appointment_date','desc')->paginate(config('labis.pagination.perpage', 10));
|
|
||||||
return view('appointment', ['appointments' => $appointments, 'conceptCodes' => $conceptCodes, 'patients' => $patients, 'patient_id' => 0, 'physicians' => $physicians]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function store(Request $request){
|
|
||||||
try{
|
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['create_appointment'])) return false;
|
|
||||||
$validator = \Validator::make($request->all(), ['patient_id' => 'required', 'appointment_date' => 'required', 'appointment_type' => 'required']);
|
|
||||||
if ($validator->fails()) return response()->json(['success' => false, 'message' => __('appointment.create_fail'), 'errors' => $validator->errors()->all()]);
|
|
||||||
|
|
||||||
$app=new Appointment();
|
|
||||||
$app->patient_id=$request->patient_id;
|
|
||||||
$app->appointment_date=date('Y-m-d H:i:s', strtotime($request->appointment_date));
|
|
||||||
$app->appointment_type=$request->appointment_type;
|
|
||||||
$app->description=$request->description;
|
|
||||||
$app->doctor_id=$request->doctor_id;
|
|
||||||
$app->lab_id=$this->baseLabId;
|
|
||||||
$app->save();
|
|
||||||
return response()->json(['success' => true, 'message' => __('appointment.create_success')]);
|
|
||||||
} catch (\Exception $e){
|
|
||||||
return response()->json(['success' => false, 'message' => __('appointment.create_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function update(Request $request){
|
|
||||||
try {
|
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['update_appointment'])) return false;
|
|
||||||
$validator = \Validator::make($request->all(), ['patient_id' => 'required', 'appointment_date' => 'required', 'appointment_type' => 'required']);
|
|
||||||
if ($validator->fails()) return response()->json(['success' => false, 'message' => __('appointment.update_fail'), 'errors' => $validator->errors()->all()]);
|
|
||||||
$app=Appointment::find($request->uid);
|
|
||||||
$app->appointment_date=date('Y-m-d H:i:s', strtotime($request->appointment_date));
|
|
||||||
$app->appointment_type=$request->appointment_type;
|
|
||||||
$app->description=$request->description;
|
|
||||||
$app->doctor_id=$request->doctor_id;
|
|
||||||
$app->lab_id=$this->baseLabId;
|
|
||||||
$app->save();
|
|
||||||
return response()->json(['success' => true, 'message' => __('appointment.update_success')]);
|
|
||||||
} catch (\Exception $e){
|
|
||||||
return response()->json(['success' => false, 'message' => __('appointment.update_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function get(Request $request){
|
|
||||||
try{
|
|
||||||
$test = $this->model::query()->where(['lab_id' => $this->baseLabId, 'id' => $request->uid])->get()->first();
|
|
||||||
return response()->json(['success' => true, 'message' => __('appointment.get_success'), 'data' => $test]);
|
|
||||||
} catch (\Exception $e){
|
|
||||||
return response()->json(['success' => false, 'message' => __('appointment.get_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function delete(Request $request){
|
|
||||||
try{
|
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['delete_appointment'])) return false;
|
|
||||||
$this->model::query()->where(['id' => $request->uid, 'lab_id' => $this->baseLabId])->update(array(BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::DELETE));
|
|
||||||
return response()->json(['success' => true, 'message' => __('appointment.delete_success')]);
|
|
||||||
} catch (\Exception $e){
|
|
||||||
return response()->json(['success' => false, 'message' => __('appointment.delete_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getAlertNofication(){
|
|
||||||
try{
|
|
||||||
$appointments = $this->model::with(['patient:id,name_en,phone_number', 'doctor:id,name_en'])->where(BaseModel::RECORD_STATUS_FIELD, RecordStatusEnum::ACTIVE)
|
|
||||||
->where('lab_id', $this->baseLabId)
|
|
||||||
->whereBetween('appointment_date', [Carbon::today(), Carbon::today()->addDays(2)])->orderBy('appointment_date','desc')->get();
|
|
||||||
$count = $appointments->count();
|
|
||||||
return response()->json(['success' => true, 'message' => __('appointment.get_success'), 'data' => $appointments, 'count' => $count]);
|
|
||||||
} catch (\Exception $e){
|
|
||||||
return response()->json(['success' => false, 'message' => __('appointment.get_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -39,7 +39,7 @@ class AuthenticatedSessionController extends Controller
|
|||||||
->log('User Login');
|
->log('User Login');
|
||||||
|
|
||||||
$request->session()->regenerate();
|
$request->session()->regenerate();
|
||||||
if (!$request->session()->has('base_lab_id')) {
|
if (!$request->session()->has('base_organization_id')) {
|
||||||
return redirect()->route('base');
|
return redirect()->route('base');
|
||||||
}
|
}
|
||||||
return redirect()->intended(RouteServiceProvider::HOME);
|
return redirect()->intended(RouteServiceProvider::HOME);
|
||||||
|
|||||||
@@ -3,16 +3,12 @@
|
|||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
use App\Enums\RecordStatusEnum;
|
use App\Enums\RecordStatusEnum;
|
||||||
use App\Enums\UtilEnum;
|
use App\Enums\UtilEnum;
|
||||||
use App\Models\AgeGroup;
|
|
||||||
use App\Models\Department;
|
|
||||||
use App\Models\PatientType;
|
|
||||||
use App\Models\Role;
|
use App\Models\Role;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Models\UserLabCover;
|
use App\Models\UserOrganization;
|
||||||
use App\Models\WardTransaction;
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use App\Models\Laboratory;
|
use App\Models\Organization;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Illuminate\Support\Facades\Hash;
|
use Illuminate\Support\Facades\Hash;
|
||||||
use Illuminate\Support\Facades\Redis;
|
use Illuminate\Support\Facades\Redis;
|
||||||
@@ -20,52 +16,55 @@ use Illuminate\Support\Facades\Redis;
|
|||||||
class BaseController extends Controller
|
class BaseController extends Controller
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
function getLabs(){
|
function getLabs(){
|
||||||
return parent::getAccessAbleLabs();
|
return parent::getAccessAbleLabs();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function index(Request $request){
|
public function index(Request $request){
|
||||||
$labs = Laboratory::query()->where('record_status_id', RecordStatusEnum::ACTIVE)
|
$organizations = Organization::query()->where('record_status_id', RecordStatusEnum::ACTIVE)
|
||||||
->whereIn('id', $this->getLabs()->pluck('id')->toArray())
|
->whereIn('id', $this->getLabs()->pluck('id')->toArray())
|
||||||
->orderBy('created_at','desc')->get();
|
->orderBy('created_at','desc')->get();
|
||||||
|
|
||||||
$request->session()->put('base_lab_coverages', $labs->pluck('name_en')->toArray());
|
$request->session()->put('base_organization_coverages', $organizations->pluck('name_en')->toArray());
|
||||||
|
|
||||||
// check it only one base default assign base session, else redirect to base view
|
// check it only one base default assign base session, else redirect to base view
|
||||||
if(count($labs)==1){
|
if(count($organizations)==1){
|
||||||
$request->session()->put('base_lab_id', $labs->first()->id);
|
$request->session()->put('base_organization_id', $organizations->first()->id);
|
||||||
$request->session()->put('base_lab_name', $labs->first()->name_en);
|
$request->session()->put('base_organization_name', $organizations->first()->name_en);
|
||||||
$request->session()->put('base_lab', $labs[0]->toArray());
|
$request->session()->put('base_organization', $organizations[0]->toArray());
|
||||||
if ($request->session()->has('base_lab_id')) {
|
if ($request->session()->has('base_organization_id')) {
|
||||||
return redirect('/dashboard');
|
return redirect('/dashboard');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return view('base', ['labs' => $labs]);
|
return view('base', ['organizations' => $organizations]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function forget(Request $request){
|
public function forget(Request $request){
|
||||||
if ($request->session()->has('base_lab_id')) {
|
if ($request->session()->has('base_organization_id')) {
|
||||||
$request->session()->forget('base_lab_id');
|
$request->session()->forget('base_organization_id');
|
||||||
$request->session()->forget('base_lab_name');
|
$request->session()->forget('base_organization_name');
|
||||||
$request->session()->forget('base_lab');
|
$request->session()->forget('base_organization');
|
||||||
$request->session()->forget('base_lab');
|
$request->session()->forget('base_organization_coverages');
|
||||||
$request->session()->forget('base_lab_coverages');
|
|
||||||
return redirect()->route('base');
|
return redirect()->route('base');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function store(Request $request){
|
public function store(Request $request){
|
||||||
$validator = \Validator::make($request->all(), [ 'lab_id' => 'required']);
|
$validator = \Validator::make($request->all(), [ 'organization_id' => 'required']);
|
||||||
if ($validator->fails())
|
if ($validator->fails())
|
||||||
{
|
{
|
||||||
session()->flash('error', 'Invalid credentials');
|
session()->flash('error', 'Invalid credentials');
|
||||||
return redirect()->route('base');
|
return redirect()->route('base');
|
||||||
}
|
}
|
||||||
$lab = Laboratory::query()->find($request->lab_id);
|
$organization = Organization::query()->find($request->organization_id);
|
||||||
$request->session()->put('base_lab_id', $request->lab_id);
|
$request->session()->put('base_organization_id', $request->organization_id);
|
||||||
$request->session()->put('base_lab_name', $lab->name_en);
|
$request->session()->put('base_organization_name', $organization->name_en);
|
||||||
$request->session()->put('base_lab', $lab->toArray());
|
$request->session()->put('base_organization', $organization->toArray());
|
||||||
if (!$request->session()->has('base_lab_id')) {
|
if (!$request->session()->has('base_organization_id')) {
|
||||||
return redirect()->route('base');
|
return redirect()->route('base');
|
||||||
}
|
}
|
||||||
return redirect('/dashboard');
|
return redirect('/dashboard');
|
||||||
|
|||||||
@@ -1,112 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
|
||||||
use App\Enums\RecordStatusEnum;
|
|
||||||
use App\Http\Controllers\Helper\GlobalController;
|
|
||||||
use App\Http\Requests\TestSampleCreateRequest;
|
|
||||||
use App\Models\BaseModel;
|
|
||||||
use App\Models\Comment;
|
|
||||||
use App\Models\Department;
|
|
||||||
use App\Models\Organism;
|
|
||||||
use App\Models\PatientType;
|
|
||||||
use App\Models\Quantity;
|
|
||||||
use App\Models\SampleType;
|
|
||||||
use App\Models\Test;
|
|
||||||
use App\Models\TestNormalValue;
|
|
||||||
use App\Models\TestSample;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Illuminate\Support\Facades\Auth;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
use Illuminate\Support\Facades\Session;
|
|
||||||
|
|
||||||
class CommentController extends Controller
|
|
||||||
{
|
|
||||||
|
|
||||||
protected $model;
|
|
||||||
protected $baseLabId;
|
|
||||||
protected $labs;
|
|
||||||
protected $department;
|
|
||||||
|
|
||||||
public function __construct(Comment $comment, Department $department){
|
|
||||||
$this->model = $comment;
|
|
||||||
$this->department = $department;
|
|
||||||
$this->baseLabId = Session::get('base_lab_id');
|
|
||||||
$this->base = Session::get('base_lab');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function index(Request $request){
|
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['view_comment'])) return redirect(url('my-profile'));
|
|
||||||
$departments = $this->department::query()->where(['lab_id' => Session::get('base_lab_id'), BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->orderBy('name_en','asc')->get();
|
|
||||||
$recordStatusCondition = Auth::id()==1 ? [RecordStatusEnum::DELETE, RecordStatusEnum::ACTIVE] : [RecordStatusEnum::ACTIVE];
|
|
||||||
$comments = $this->model::with(['sample_type','sample_type.department'])->whereIn(BaseModel::RECORD_STATUS_FIELD, $recordStatusCondition)
|
|
||||||
->where('lab_id', $this->baseLabId)
|
|
||||||
->when(!empty($request->kword), function ($comments) use($request){
|
|
||||||
$comments->whereRaw("replace(comment_desc, ' ','') like '%".str_replace(" ","",$request->kword)."%'");
|
|
||||||
})->orderBy(BaseModel::CREATED_AT_FIELD,'desc')->paginate(config('labis.pagination.perpage', 10));
|
|
||||||
return view('comment', ['comments' => $comments, 'departments' => $departments]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function save(Request $request){
|
|
||||||
try{
|
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['create_comment'])) return false;
|
|
||||||
$validator = \Validator::make($request->all(), ['comment_desc' => 'required', 'sample_type_id' => 'required']);
|
|
||||||
if ($validator->fails()) return response()->json(['success' => false, 'message' => __('comment.create_fail'), 'errors' => $validator->errors()->all()]);
|
|
||||||
foreach ($request->sample_type_id as $sample_type) {
|
|
||||||
$comment = $this->model::query()->create([
|
|
||||||
'comment_desc' => $request->comment_desc,
|
|
||||||
'sample_type_id' => $sample_type,
|
|
||||||
'lab_id' => $this->baseLabId
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
return response()->json(['success' => true, 'message' => __('comment.create_success')]);
|
|
||||||
} catch (\Exception $e){
|
|
||||||
return response()->json(['success' => false, 'message' => __('comment.create_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function update(Request $request){
|
|
||||||
try {
|
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['update_comment'])) return false;
|
|
||||||
$validator = \Validator::make($request->all(), ['comment_desc' => 'required', 'sample_type_id' => 'required']);
|
|
||||||
if ($validator->fails()) return response()->json(['success' => false, 'message' => __('comment.update_fail'), 'errors' => $validator->errors()->all()]);
|
|
||||||
$data = array(
|
|
||||||
'comment_desc' => $request->comment_desc,
|
|
||||||
'sample_type_id' => $request->sample_type_id
|
|
||||||
);
|
|
||||||
$this->model::query()->where('id', $request->uid)->update($data);
|
|
||||||
return response()->json(['success' => true, 'message' => __('comment.update_success')]);
|
|
||||||
} catch (\Exception $e){
|
|
||||||
return response()->json(['success' => false, 'message' => __('comment.update_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function get(Request $request){
|
|
||||||
try{
|
|
||||||
$test = $this->model::with('sample_type')->find($request->uid);
|
|
||||||
return response()->json(['success' => true, 'message' => __('comment.get_success'), 'data' => $test]);
|
|
||||||
} catch (\Exception $e){
|
|
||||||
return response()->json(['success' => false, 'message' => __('comment.get_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function delete(Request $request){
|
|
||||||
try{
|
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['delete_comment'])) return false;
|
|
||||||
$this->model::query()->where('id', $request->uid)->update(array(BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::DELETE));
|
|
||||||
return response()->json(['success' => true, 'message' => __('comment.delete_success')]);
|
|
||||||
} catch (\Exception $e){
|
|
||||||
return response()->json(['success' => false, 'message' => __('comment.delete_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function restore(Request $request){
|
|
||||||
try{
|
|
||||||
$this->model::query()->where('id', $request->uid)->update(array(BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE));
|
|
||||||
return response()->json(['success' => true, 'message' => __('comment.restore_success')]);
|
|
||||||
} catch (\Exception $e){
|
|
||||||
return response()->json(['success' => false, 'message' => __('comment.restore_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -6,9 +6,9 @@ use App\Enums\RecordStatusEnum;
|
|||||||
use App\Models\BaseModel;
|
use App\Models\BaseModel;
|
||||||
use App\Models\Commune;
|
use App\Models\Commune;
|
||||||
use App\Models\District;
|
use App\Models\District;
|
||||||
use App\Models\Laboratory;
|
use App\Models\Organization;
|
||||||
use App\Models\Province;
|
use App\Models\Province;
|
||||||
use App\Models\UserLabCover;
|
use App\Models\UserOrganization;
|
||||||
use App\Models\Village;
|
use App\Models\Village;
|
||||||
use Illuminate\Support\Facades\App;
|
use Illuminate\Support\Facades\App;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
@@ -18,12 +18,12 @@ abstract class Controller
|
|||||||
{
|
{
|
||||||
function getAccessAbleLabs(){
|
function getAccessAbleLabs(){
|
||||||
$recordStatusCondition = Auth::id()==1 ? [RecordStatusEnum::DELETE, RecordStatusEnum::ACTIVE] : [RecordStatusEnum::ACTIVE];
|
$recordStatusCondition = Auth::id()==1 ? [RecordStatusEnum::DELETE, RecordStatusEnum::ACTIVE] : [RecordStatusEnum::ACTIVE];
|
||||||
$labs = Laboratory::query()->whereIn(BaseModel::RECORD_STATUS_FIELD, $recordStatusCondition)->get();
|
$organizations = Organization::query()->whereIn(BaseModel::RECORD_STATUS_FIELD, $recordStatusCondition)->get();
|
||||||
if(Auth::id()!=1){
|
if(Auth::id()!=1){
|
||||||
$labIds = UserLabCover::query()->where('user_id', Auth::id())->where(BaseModel::RECORD_STATUS_FIELD, RecordStatusEnum::ACTIVE)->pluck('lab_id')->toArray();
|
$organizationId = UserOrganization::query()->where('user_id', Auth::id())->where(BaseModel::RECORD_STATUS_FIELD, RecordStatusEnum::ACTIVE)->pluck('organization_id')->toArray();
|
||||||
$labs = $labs->whereIn('id', $labIds);
|
$organizations = $organizations->whereIn('id', $organizationId);
|
||||||
}
|
}
|
||||||
return $labs;
|
return $organizations;
|
||||||
}
|
}
|
||||||
|
|
||||||
function province(){
|
function province(){
|
||||||
@@ -52,33 +52,10 @@ abstract class Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function location(){
|
public function location(){
|
||||||
// discount_type = [1 => '%', 2 => 'USD']
|
return Organization::query()->find(Session::get('base_organization_id'))->only([
|
||||||
return Laboratory::query()->find(Session::get('base_lab_id'))->only([
|
'id',
|
||||||
'name_en',
|
'name_en',
|
||||||
'name_kh',
|
'name_kh'
|
||||||
'short_name',
|
|
||||||
'sample_number',
|
|
||||||
'patient_code',
|
|
||||||
'verify_label',
|
|
||||||
'technician_label',
|
|
||||||
'discount_type',
|
|
||||||
'logo',
|
|
||||||
'address_kh',
|
|
||||||
'address_en',
|
|
||||||
'phone_number',
|
|
||||||
'email',
|
|
||||||
'shareable_lab_result',
|
|
||||||
'result_header_id',
|
|
||||||
'show_result_footer',
|
|
||||||
'abnormal_result_font_weight',
|
|
||||||
'abnormal_text_color',
|
|
||||||
'exchange_rate',
|
|
||||||
'lab_category_id',
|
|
||||||
'currency',
|
|
||||||
'is_hide_inv_discount',
|
|
||||||
'is_hide_comission_percentage',
|
|
||||||
'invoice_template_id',
|
|
||||||
'alternative_logo'
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
use App\Enums\RecordStatusEnum;
|
use App\Enums\RecordStatusEnum;
|
||||||
use App\Models\BaseModel;
|
use App\Models\BaseModel;
|
||||||
use App\Models\Invoice;
|
|
||||||
use App\Models\Sample;
|
use App\Models\Sample;
|
||||||
|
|
||||||
use App\Http\Controllers\Helper\GlobalController;
|
use App\Http\Controllers\Helper\GlobalController;
|
||||||
@@ -16,14 +15,13 @@ class DashboardController extends Controller
|
|||||||
{
|
{
|
||||||
protected $sampleModel;
|
protected $sampleModel;
|
||||||
protected $invoiceModel;
|
protected $invoiceModel;
|
||||||
private $baseLabId;
|
private $baseOrganizationId;
|
||||||
protected $base;
|
protected $base;
|
||||||
|
|
||||||
public function __construct(Sample $sampleModel, Invoice $invoiceModel){
|
public function __construct(Sample $sampleModel){
|
||||||
$this->sampleModel = $sampleModel;
|
$this->sampleModel = $sampleModel;
|
||||||
$this->invoiceModel = $invoiceModel;
|
$this->baseOrganizationId = Session::get('base_organization_id');
|
||||||
$this->baseLabId = Session::get('base_lab_id');
|
$this->base = Session::get('base_organization');
|
||||||
$this->base = Session::get('base_lab');
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,7 +51,7 @@ class DashboardController extends Controller
|
|||||||
//income
|
//income
|
||||||
$todayIncome = $this->getTodayIncome();
|
$todayIncome = $this->getTodayIncome();
|
||||||
$todayIncome+=$this->getDailyReportV2(date('Y-m-d'), date('Y-m-d'));
|
$todayIncome+=$this->getDailyReportV2(date('Y-m-d'), date('Y-m-d'));
|
||||||
$yesterdayIncome = $this->invoiceModel::query()->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
$yesterdayIncome = $this->invoiceModel::query()->where(['organization_id' => $this->baseOrganizationId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
||||||
->whereDate('invoice_date', date('Y-m-d', strtotime('-1 day')))->sum('gross_total');
|
->whereDate('invoice_date', date('Y-m-d', strtotime('-1 day')))->sum('gross_total');
|
||||||
$yesterdayIncome+=$this->getDailyReportV2(date('Y-m-d', strtotime('-1 day')), date('Y-m-d', strtotime('-1 day')));
|
$yesterdayIncome+=$this->getDailyReportV2(date('Y-m-d', strtotime('-1 day')), date('Y-m-d', strtotime('-1 day')));
|
||||||
if($yesterdayIncome>0){
|
if($yesterdayIncome>0){
|
||||||
@@ -114,9 +112,9 @@ class DashboardController extends Controller
|
|||||||
$displaySampleResult = $monlthlySample;
|
$displaySampleResult = $monlthlySample;
|
||||||
|
|
||||||
} elseif ($q->dt == 'this_year'){
|
} elseif ($q->dt == 'this_year'){
|
||||||
$yearSamples = $this->sampleModel::query()->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
$yearSamples = $this->sampleModel::query()->where(['organization_id' => $this->baseOrganizationId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
||||||
->whereYear('admission_date', date('Y'))->count();
|
->whereYear('admission_date', date('Y'))->count();
|
||||||
$last_yearSample = $this->sampleModel::query()->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
$last_yearSample = $this->sampleModel::query()->where(['organization_id' => $this->baseOrganizationId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
||||||
->whereYear('admission_date', (date('Y')-1))->count();
|
->whereYear('admission_date', (date('Y')-1))->count();
|
||||||
if($last_yearSample>0){
|
if($last_yearSample>0){
|
||||||
$growthSample = (($yearSamples - $last_yearSample) / $last_yearSample);
|
$growthSample = (($yearSamples - $last_yearSample) / $last_yearSample);
|
||||||
@@ -167,7 +165,7 @@ class DashboardController extends Controller
|
|||||||
else{
|
else{
|
||||||
$todayIncome = $this->getTodayIncome();
|
$todayIncome = $this->getTodayIncome();
|
||||||
$todayIncome+=$this->getDailyReportV2(date('Y-m-d'), date('Y-m-d'));
|
$todayIncome+=$this->getDailyReportV2(date('Y-m-d'), date('Y-m-d'));
|
||||||
$yesterdayIncome = $this->invoiceModel::query()->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
$yesterdayIncome = $this->invoiceModel::query()->where(['organization_id' => $this->baseOrganizationId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
||||||
->whereDate('invoice_date', date('Y-m-d', strtotime('-1 day')))->sum('gross_total');
|
->whereDate('invoice_date', date('Y-m-d', strtotime('-1 day')))->sum('gross_total');
|
||||||
$yesterdayIncome+=$this->getDailyReportV2(date('Y-m-d', strtotime('-1 day')), date('Y-m-d', strtotime('-1 day')));
|
$yesterdayIncome+=$this->getDailyReportV2(date('Y-m-d', strtotime('-1 day')), date('Y-m-d', strtotime('-1 day')));
|
||||||
if($yesterdayIncome>0){
|
if($yesterdayIncome>0){
|
||||||
@@ -261,36 +259,36 @@ class DashboardController extends Controller
|
|||||||
//get total sample count for dashboard by lab id
|
//get total sample count for dashboard by lab id
|
||||||
|
|
||||||
function getTotalRejectedSampleCount(){
|
function getTotalRejectedSampleCount(){
|
||||||
return $this->sampleModel::query()->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->where('sample_condition', 0)->count();
|
return $this->sampleModel::query()->where(['organization_id' => $this->baseOrganizationId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->where('sample_condition', 0)->count();
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTodayRejectedSamples(){
|
function getTodayRejectedSamples(){
|
||||||
return $this->sampleModel::query()->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->where('sample_condition', 0)
|
return $this->sampleModel::query()->where(['organization_id' => $this->baseOrganizationId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->where('sample_condition', 0)
|
||||||
->whereDate('admission_date', date('Y-m-d'))->get();
|
->whereDate('admission_date', date('Y-m-d'))->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
function getYesterdayRejectedSamples(){
|
function getYesterdayRejectedSamples(){
|
||||||
return $this->sampleModel::query()->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->where('sample_condition', 0)
|
return $this->sampleModel::query()->where(['organization_id' => $this->baseOrganizationId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->where('sample_condition', 0)
|
||||||
->whereDate('admission_date', date('Y-m-d', strtotime('-1 day')))->get();
|
->whereDate('admission_date', date('Y-m-d', strtotime('-1 day')))->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
function getThisMonthRejectedSamples(){
|
function getThisMonthRejectedSamples(){
|
||||||
return $this->sampleModel::query()->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->where('sample_condition', 0)
|
return $this->sampleModel::query()->where(['organization_id' => $this->baseOrganizationId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->where('sample_condition', 0)
|
||||||
->whereBetween('admission_date', [date('Y-m-01 00:00:00'), date('Y-m-t 23:59:59')])->get();
|
->whereBetween('admission_date', [date('Y-m-01 00:00:00'), date('Y-m-t 23:59:59')])->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPreviousMonthRejectedSamples(){
|
function getPreviousMonthRejectedSamples(){
|
||||||
return $this->sampleModel::query()->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->where('sample_condition', 0)
|
return $this->sampleModel::query()->where(['organization_id' => $this->baseOrganizationId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->where('sample_condition', 0)
|
||||||
->whereBetween('admission_date', [date("Y-m-d 00:00:00", strtotime("first day of previous month")), date("Y-m-d 23:59:59", strtotime("last day of previous month"))])->get();
|
->whereBetween('admission_date', [date("Y-m-d 00:00:00", strtotime("first day of previous month")), date("Y-m-d 23:59:59", strtotime("last day of previous month"))])->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
function getThisYearRejectedSamples(){
|
function getThisYearRejectedSamples(){
|
||||||
return $this->sampleModel::query()->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->where('sample_condition', 0)
|
return $this->sampleModel::query()->where(['organization_id' => $this->baseOrganizationId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->where('sample_condition', 0)
|
||||||
->whereYear('admission_date', date('Y'))->get();
|
->whereYear('admission_date', date('Y'))->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
function getLastYearRejectedSamples(){
|
function getLastYearRejectedSamples(){
|
||||||
return $this->sampleModel::query()->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->where('sample_condition', 0)
|
return $this->sampleModel::query()->where(['organization_id' => $this->baseOrganizationId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->where('sample_condition', 0)
|
||||||
->whereYear('admission_date', (date('Y')-1))->get();
|
->whereYear('admission_date', (date('Y')-1))->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -299,109 +297,109 @@ class DashboardController extends Controller
|
|||||||
|
|
||||||
|
|
||||||
function getTotalSampleCount(){
|
function getTotalSampleCount(){
|
||||||
return $this->sampleModel::query()->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->count();
|
return $this->sampleModel::query()->where(['organization_id' => $this->baseOrganizationId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->count();
|
||||||
}
|
}
|
||||||
|
|
||||||
//get yesterday sample count for dashboard by lab id
|
//get yesterday sample count for dashboard by lab id
|
||||||
|
|
||||||
function getYesterdaySampleCount(){
|
function getYesterdaySampleCount(){
|
||||||
return $this->sampleModel::query()->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
return $this->sampleModel::query()->where(['organization_id' => $this->baseOrganizationId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
||||||
->whereDate('admission_date', date('Y-m-d', strtotime('-1 day')))->count();
|
->whereDate('admission_date', date('Y-m-d', strtotime('-1 day')))->count();
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTodaySamples(){
|
function getTodaySamples(){
|
||||||
return $this->sampleModel::query()->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
return $this->sampleModel::query()->where(['organization_id' => $this->baseOrganizationId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
||||||
->whereDate('admission_date', date('Y-m-d'))->get();
|
->whereDate('admission_date', date('Y-m-d'))->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
function getThisMonthSamples(){
|
function getThisMonthSamples(){
|
||||||
return $this->sampleModel::query()->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
return $this->sampleModel::query()->where(['organization_id' => $this->baseOrganizationId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
||||||
->whereBetween('admission_date', [date('Y-m-01 00:00:00'), date('Y-m-t 23:59:59')])->get();
|
->whereBetween('admission_date', [date('Y-m-01 00:00:00'), date('Y-m-t 23:59:59')])->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPreviousMonthSamples(){
|
function getPreviousMonthSamples(){
|
||||||
return $this->sampleModel::with(['patient'])->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
return $this->sampleModel::with(['patient'])->where(['organization_id' => $this->baseOrganizationId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
||||||
->whereBetween('admission_date', [date("Y-m-d 00:00:00", strtotime("first day of previous month")), date("Y-m-d 23:59:59", strtotime("last day of previous month"))])->get();
|
->whereBetween('admission_date', [date("Y-m-d 00:00:00", strtotime("first day of previous month")), date("Y-m-d 23:59:59", strtotime("last day of previous month"))])->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
function getLastYearAverage(){
|
function getLastYearAverage(){
|
||||||
return $this->sampleModel::with(['patient'])->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
return $this->sampleModel::with(['patient'])->where(['organization_id' => $this->baseOrganizationId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
||||||
->whereBetween('admission_date', [date('Y-01-01 00:00:00', strtotime('-1 year')), date('Y-12-31 23:59:59', strtotime('-1 year'))])->count();
|
->whereBetween('admission_date', [date('Y-01-01 00:00:00', strtotime('-1 year')), date('Y-12-31 23:59:59', strtotime('-1 year'))])->count();
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTodayIncome(){
|
function getTodayIncome(){
|
||||||
return $this->invoiceModel::query()->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
return $this->invoiceModel::query()->where(['organization_id' => $this->baseOrganizationId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
||||||
->whereDate('invoice_date', date('Y-m-d'))->sum('gross_total');
|
->whereDate('invoice_date', date('Y-m-d'))->sum('gross_total');
|
||||||
}
|
}
|
||||||
|
|
||||||
function getThisMonthIncome(){
|
function getThisMonthIncome(){
|
||||||
return $this->invoiceModel::query()->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
return $this->invoiceModel::query()->where(['organization_id' => $this->baseOrganizationId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
||||||
->whereBetween('invoice_date', [date('Y-m-01 00:00:00'), date('Y-m-t 23:59:59')])->sum('gross_total');
|
->whereBetween('invoice_date', [date('Y-m-01 00:00:00'), date('Y-m-t 23:59:59')])->sum('gross_total');
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPreviousMonthIncome(){
|
function getPreviousMonthIncome(){
|
||||||
return $this->invoiceModel::query()->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
return $this->invoiceModel::query()->where(['organization_id' => $this->baseOrganizationId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
||||||
->whereBetween('invoice_date', [date("Y-m-d 00:00:00", strtotime("first day of previous month")), date("Y-m-d 23:59:59", strtotime("last day of previous month"))])->sum('gross_total');
|
->whereBetween('invoice_date', [date("Y-m-d 00:00:00", strtotime("first day of previous month")), date("Y-m-d 23:59:59", strtotime("last day of previous month"))])->sum('gross_total');
|
||||||
}
|
}
|
||||||
|
|
||||||
function getLastYearIncome(){
|
function getLastYearIncome(){
|
||||||
return $this->invoiceModel::query()->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
return $this->invoiceModel::query()->where(['organization_id' => $this->baseOrganizationId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
||||||
->whereBetween('invoice_date', [date('Y-01-01 00:00:00', strtotime('-1 year')), date('Y-12-31 23:59:59', strtotime('-1 year'))])->sum('gross_total');
|
->whereBetween('invoice_date', [date('Y-01-01 00:00:00', strtotime('-1 year')), date('Y-12-31 23:59:59', strtotime('-1 year'))])->sum('gross_total');
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTotalIncome(){
|
function getTotalIncome(){
|
||||||
return $this->invoiceModel::query()->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->sum('gross_total');
|
return $this->invoiceModel::query()->where(['organization_id' => $this->baseOrganizationId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->sum('gross_total');
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTotalPatient(){
|
function getTotalPatient(){
|
||||||
return $this->sampleModel::query()->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->distinct('patient_id')->count('patient_id');
|
return $this->sampleModel::query()->where(['organization_id' => $this->baseOrganizationId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->distinct('patient_id')->count('patient_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTodayPatient(){
|
function getTodayPatient(){
|
||||||
return $this->sampleModel::query()->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
return $this->sampleModel::query()->where(['organization_id' => $this->baseOrganizationId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
||||||
->whereDate('admission_date', date('Y-m-d'))->distinct('patient_id')->count('patient_id');
|
->whereDate('admission_date', date('Y-m-d'))->distinct('patient_id')->count('patient_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
function getYesterdayPatient(){
|
function getYesterdayPatient(){
|
||||||
return $this->sampleModel::query()->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
return $this->sampleModel::query()->where(['organization_id' => $this->baseOrganizationId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
||||||
->whereDate('admission_date', date('Y-m-d', strtotime('-1 day')))->distinct('patient_id')->count('patient_id');
|
->whereDate('admission_date', date('Y-m-d', strtotime('-1 day')))->distinct('patient_id')->count('patient_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
function getThisMonthPatient(){
|
function getThisMonthPatient(){
|
||||||
return $this->sampleModel::query()->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
return $this->sampleModel::query()->where(['organization_id' => $this->baseOrganizationId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
||||||
->whereBetween('admission_date', [date('Y-m-01 00:00:00'), date('Y-m-t 23:59:59')])->distinct('patient_id')->count('patient_id');
|
->whereBetween('admission_date', [date('Y-m-01 00:00:00'), date('Y-m-t 23:59:59')])->distinct('patient_id')->count('patient_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPreviousMonthPatient(){
|
function getPreviousMonthPatient(){
|
||||||
return $this->sampleModel::with(['patient'])->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
return $this->sampleModel::with(['patient'])->where(['organization_id' => $this->baseOrganizationId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
||||||
->whereBetween('admission_date', [date("Y-m-d 00:00:00", strtotime("first day of previous month")), date("Y-m-d 23:59:59", strtotime("last day of previous month"))])->distinct('patient_id')->count('patient_id');
|
->whereBetween('admission_date', [date("Y-m-d 00:00:00", strtotime("first day of previous month")), date("Y-m-d 23:59:59", strtotime("last day of previous month"))])->distinct('patient_id')->count('patient_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
function getLastYearPatient(){
|
function getLastYearPatient(){
|
||||||
return $this->sampleModel::with(['patient'])->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
return $this->sampleModel::with(['patient'])->where(['organization_id' => $this->baseOrganizationId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
||||||
->whereBetween('admission_date', [date('Y-01-01 00:00:00', strtotime('-1 year')), date('Y-12-31 23:59:59', strtotime('-1 year'))])->distinct('patient_id')->count('patient_id');
|
->whereBetween('admission_date', [date('Y-01-01 00:00:00', strtotime('-1 year')), date('Y-12-31 23:59:59', strtotime('-1 year'))])->distinct('patient_id')->count('patient_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
function getThisYearPatient(){
|
function getThisYearPatient(){
|
||||||
return $this->sampleModel::with(['patient'])->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
return $this->sampleModel::with(['patient'])->where(['organization_id' => $this->baseOrganizationId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
||||||
->whereBetween('admission_date', [date('Y-01-01 00:00:00'), date('Y-12-31 23:59:59')])->distinct('patient_id')->count('patient_id');
|
->whereBetween('admission_date', [date('Y-01-01 00:00:00'), date('Y-12-31 23:59:59')])->distinct('patient_id')->count('patient_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTotalInvoice(){
|
function getTotalInvoice(){
|
||||||
return $this->invoiceModel::query()->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->count();
|
return $this->invoiceModel::query()->where(['organization_id' => $this->baseOrganizationId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->count();
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTotalPaidInvoice(){
|
function getTotalPaidInvoice(){
|
||||||
return $this->invoiceModel::query()->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->where('balance', 0)->count();
|
return $this->invoiceModel::query()->where(['organization_id' => $this->baseOrganizationId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->where('balance', 0)->count();
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTotalUnpaidInvoice(){
|
function getTotalUnpaidInvoice(){
|
||||||
return $this->invoiceModel::query()->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->where('balance', '>', 0)->count();
|
return $this->invoiceModel::query()->where(['organization_id' => $this->baseOrganizationId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->where('balance', '>', 0)->count();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function getSampleSourceChart($period = 2){
|
function getSampleSourceChart($period = 2){
|
||||||
$samplePeriodCondition = " and s.lab_id = ".$this->baseLabId;
|
$samplePeriodCondition = " and s.organization_id = ".$this->baseOrganizationId;
|
||||||
if($period == 1) $samplePeriodCondition.= " and date(s.admission_date)='".date('Y-m-d')."'"; // today
|
if($period == 1) $samplePeriodCondition.= " and date(s.admission_date)='".date('Y-m-d')."'"; // today
|
||||||
if($period == 2) $samplePeriodCondition.= " and s.admission_date BETWEEN '".date('Y-m-01 00:00:00')."' AND '".date('Y-m-t 23:59:59')."'"; // this month
|
if($period == 2) $samplePeriodCondition.= " and s.admission_date BETWEEN '".date('Y-m-01 00:00:00')."' AND '".date('Y-m-t 23:59:59')."'"; // this month
|
||||||
if($period == 3) $samplePeriodCondition.= " and s.admission_date BETWEEN '".date('Y-01-01 23:59:59')."' AND '".date('Y-12-31 23:59:59')."'"; // this year
|
if($period == 3) $samplePeriodCondition.= " and s.admission_date BETWEEN '".date('Y-01-01 23:59:59')."' AND '".date('Y-12-31 23:59:59')."'"; // this year
|
||||||
@@ -422,7 +420,7 @@ class DashboardController extends Controller
|
|||||||
) sample
|
) sample
|
||||||
ON sample.sample_source_id = ss.`id`
|
ON sample.sample_source_id = ss.`id`
|
||||||
WHERE ss.`record_status_id` = 1
|
WHERE ss.`record_status_id` = 1
|
||||||
AND ss.`lab_id` = ".$this->baseLabId."
|
AND ss.`organization_id` = ".$this->baseOrganizationId."
|
||||||
");
|
");
|
||||||
$sampleSourceDataArray = [];
|
$sampleSourceDataArray = [];
|
||||||
foreach ($sampleSourceData as $data){
|
foreach ($sampleSourceData as $data){
|
||||||
@@ -458,7 +456,7 @@ class DashboardController extends Controller
|
|||||||
FROM samples s
|
FROM samples s
|
||||||
WHERE YEAR(s.`admission_date`) between ".$fromYear." and ".$toYear."
|
WHERE YEAR(s.`admission_date`) between ".$fromYear." and ".$toYear."
|
||||||
AND s.`record_status_id` = 1
|
AND s.`record_status_id` = 1
|
||||||
AND s.`lab_id` = ".$this->baseLabId."
|
AND s.`organization_id` = ".$this->baseOrganizationId."
|
||||||
GROUP BY MONTH(s.`admission_date`), YEAR(s.`admission_date`) ");
|
GROUP BY MONTH(s.`admission_date`), YEAR(s.`admission_date`) ");
|
||||||
return $sampleByYear;
|
return $sampleByYear;
|
||||||
}
|
}
|
||||||
@@ -482,14 +480,14 @@ class DashboardController extends Controller
|
|||||||
sum(r.bank_repayment_amount) as total_bank_paid,
|
sum(r.bank_repayment_amount) as total_bank_paid,
|
||||||
0 as total_owe
|
0 as total_owe
|
||||||
from repayments r
|
from repayments r
|
||||||
inner join invoices inv on inv.id = r.invoice_id and r.lab_id = inv.lab_id and inv.record_status_id = 1
|
inner join invoices inv on inv.id = r.invoice_id and r.organization_id = inv.organization_id and inv.record_status_id = 1
|
||||||
inner join samples s on s.`id` = inv.`sample_id` and s.`lab_id` = inv.`lab_id` and s.`record_status_id` = 1
|
inner join samples s on s.`id` = inv.`sample_id` and s.`organization_id` = inv.`organization_id` and s.`record_status_id` = 1
|
||||||
inner join patients p on p.`id` = s.`patient_id` and p.`lab_id` = s.`lab_id`
|
inner join patients p on p.`id` = s.`patient_id` and p.`organization_id` = s.`organization_id`
|
||||||
INNER JOIN sample_sources ss ON ss.id = s.`sample_source_id` AND ss.`lab_id` = s.`lab_id`
|
INNER JOIN sample_sources ss ON ss.id = s.`sample_source_id` AND ss.`organization_id` = s.`organization_id`
|
||||||
INNER JOIN physicians ps ON ps.`id` = s.`physician_id`
|
INNER JOIN physicians ps ON ps.`id` = s.`physician_id`
|
||||||
where r.`record_status_id` = 1
|
where r.`record_status_id` = 1
|
||||||
AND DATE(r.repayment_date) BETWEEN '".date('Y-m-d', strtotime($startDate))."' AND '".date('Y-m-d', strtotime($endDate))."'
|
AND DATE(r.repayment_date) BETWEEN '".date('Y-m-d', strtotime($startDate))."' AND '".date('Y-m-d', strtotime($endDate))."'
|
||||||
and r.lab_id= ".$this->baseLabId."
|
and r.organization_id= ".$this->baseOrganizationId."
|
||||||
group by r.`repayment_date`,
|
group by r.`repayment_date`,
|
||||||
ss.`name_en`,
|
ss.`name_en`,
|
||||||
p.`name_en`,
|
p.`name_en`,
|
||||||
@@ -515,14 +513,14 @@ class DashboardController extends Controller
|
|||||||
$current = DB::table('samples')
|
$current = DB::table('samples')
|
||||||
->selectRaw('MONTH(admission_date) as month, COUNT(*) as total')
|
->selectRaw('MONTH(admission_date) as month, COUNT(*) as total')
|
||||||
->whereYear('admission_date', $thisYear)
|
->whereYear('admission_date', $thisYear)
|
||||||
->where('lab_id', $this->baseLabId)
|
->where('organization_id', $this->baseOrganizationId)
|
||||||
->groupBy('month')
|
->groupBy('month')
|
||||||
->pluck('total', 'month');
|
->pluck('total', 'month');
|
||||||
|
|
||||||
$previous = DB::table('samples')
|
$previous = DB::table('samples')
|
||||||
->selectRaw('MONTH(admission_date) as month, COUNT(*) as total')
|
->selectRaw('MONTH(admission_date) as month, COUNT(*) as total')
|
||||||
->whereYear('admission_date', $lastYear)
|
->whereYear('admission_date', $lastYear)
|
||||||
->where('lab_id', $this->baseLabId)
|
->where('organization_id', $this->baseOrganizationId)
|
||||||
->groupBy('month')
|
->groupBy('month')
|
||||||
->pluck('total', 'month');
|
->pluck('total', 'month');
|
||||||
|
|
||||||
@@ -547,14 +545,14 @@ class DashboardController extends Controller
|
|||||||
$current = DB::table('invoices')
|
$current = DB::table('invoices')
|
||||||
->selectRaw('MONTH(invoice_date) as month, SUM(gross_total) as total')
|
->selectRaw('MONTH(invoice_date) as month, SUM(gross_total) as total')
|
||||||
->whereYear('invoice_date', $thisYear)
|
->whereYear('invoice_date', $thisYear)
|
||||||
->where('lab_id', $this->baseLabId)
|
->where('organization_id', $this->baseOrganizationId)
|
||||||
->groupBy('month')
|
->groupBy('month')
|
||||||
->pluck('total', 'month');
|
->pluck('total', 'month');
|
||||||
|
|
||||||
$previous = DB::table('invoices')
|
$previous = DB::table('invoices')
|
||||||
->selectRaw('MONTH(invoice_date) as month, SUM(gross_total) as total')
|
->selectRaw('MONTH(invoice_date) as month, SUM(gross_total) as total')
|
||||||
->whereYear('invoice_date', $lastYear)
|
->whereYear('invoice_date', $lastYear)
|
||||||
->where('lab_id', $this->baseLabId)
|
->where('organization_id', $this->baseOrganizationId)
|
||||||
->groupBy('month')
|
->groupBy('month')
|
||||||
->pluck('total', 'month');
|
->pluck('total', 'month');
|
||||||
|
|
||||||
@@ -585,13 +583,13 @@ class DashboardController extends Controller
|
|||||||
FROM samples s
|
FROM samples s
|
||||||
WHERE s.`record_status_id` = 1
|
WHERE s.`record_status_id` = 1
|
||||||
and year(s.admission_date) = ".$thisYear."
|
and year(s.admission_date) = ".$thisYear."
|
||||||
AND s.lab_id = ".$this->baseLabId."
|
AND s.organization_id = ".$this->baseOrganizationId."
|
||||||
GROUP BY s.`sample_source_id`
|
GROUP BY s.`sample_source_id`
|
||||||
|
|
||||||
) sample
|
) sample
|
||||||
ON sample.sample_source_id = ss.`id`
|
ON sample.sample_source_id = ss.`id`
|
||||||
WHERE ss.`record_status_id` = 1
|
WHERE ss.`record_status_id` = 1
|
||||||
AND ss.`lab_id` = ".$this->baseLabId."
|
AND ss.`organization_id` = ".$this->baseOrganizationId."
|
||||||
ORDER BY total_samples DESC
|
ORDER BY total_samples DESC
|
||||||
LIMIT 10
|
LIMIT 10
|
||||||
");
|
");
|
||||||
@@ -615,13 +613,13 @@ class DashboardController extends Controller
|
|||||||
INNER JOIN departments sd ON sd.id = st.`department_id`
|
INNER JOIN departments sd ON sd.id = st.`department_id`
|
||||||
WHERE s.`record_status_id` = 1
|
WHERE s.`record_status_id` = 1
|
||||||
and year(s.admission_date) = ".$thisYear."
|
and year(s.admission_date) = ".$thisYear."
|
||||||
AND s.lab_id = ".$this->baseLabId."
|
AND s.organization_id = ".$this->baseOrganizationId."
|
||||||
GROUP BY st.`department_id`
|
GROUP BY st.`department_id`
|
||||||
|
|
||||||
) sample
|
) sample
|
||||||
ON sample.department_id = d.`id`
|
ON sample.department_id = d.`id`
|
||||||
WHERE d.`record_status_id` = 1
|
WHERE d.`record_status_id` = 1
|
||||||
AND d.`lab_id` = ".$this->baseLabId."
|
AND d.`organization_id` = ".$this->baseOrganizationId."
|
||||||
ORDER BY d.`name_en`
|
ORDER BY d.`name_en`
|
||||||
");
|
");
|
||||||
return response()->json($samplePanelData);
|
return response()->json($samplePanelData);
|
||||||
|
|||||||
@@ -1,108 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
|
||||||
use App\Enums\RecordStatusEnum;
|
|
||||||
use App\Http\Controllers\Helper\GlobalController;
|
|
||||||
use App\Models\BaseModel;
|
|
||||||
use App\Models\Department;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Illuminate\Support\Facades\Auth;
|
|
||||||
use Illuminate\Support\Facades\Session;
|
|
||||||
|
|
||||||
class DepartmentController extends Controller
|
|
||||||
{
|
|
||||||
protected $model;
|
|
||||||
protected $baseLabId;
|
|
||||||
protected $labs;
|
|
||||||
|
|
||||||
public function __construct(Department $department){
|
|
||||||
$this->model = $department;
|
|
||||||
$this->baseLabId = Session::get('base_lab_id');
|
|
||||||
$this->base = Session::get('base_lab');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function index(Request $request){
|
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['view_department'])) return redirect(url('my-profile'));
|
|
||||||
$standardDepartments = $this->model::query()->where([BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE, 'is_standard' => 1])->get(['id','name_en'])->unique('name_en');
|
|
||||||
$recordStatusCondition = Auth::id()==1 ? [RecordStatusEnum::DELETE, RecordStatusEnum::ACTIVE] : [RecordStatusEnum::ACTIVE];
|
|
||||||
$departments = $this->model::query()->with(['samples'])->whereIn(BaseModel::RECORD_STATUS_FIELD, $recordStatusCondition)
|
|
||||||
->where('lab_id', $this->baseLabId)
|
|
||||||
->when(!empty($request->kword), function ($departments) use($request){
|
|
||||||
$departments->whereRaw("replace(name_en, ' ','') like '%".str_replace(" ","",$request->kword)."%'");
|
|
||||||
})->orderBy('weight','asc')->paginate(config('labis.pagination.perpage', 10));
|
|
||||||
return view('department', ['departments' => $departments, 'labs' => $this->labs, 'standardDepartments' => $standardDepartments]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function save(Request $request){
|
|
||||||
try{
|
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['create_department'])) return false;
|
|
||||||
$validator = \Validator::make($request->all(), ['name_en' => 'required']);
|
|
||||||
if ($validator->fails()){
|
|
||||||
return response()->json(['success' => false, 'message' => __('department.create_fail'), 'errors' => $validator->errors()->all()]);
|
|
||||||
}
|
|
||||||
|
|
||||||
$new = $this->model::query()->firstOrNew(['name_en' => $request->name_en, 'lab_id' => $this->baseLabId]);
|
|
||||||
$new->name_en = $request->name_en;
|
|
||||||
$new->weight = $request->weight;
|
|
||||||
$new->lab_id = $this->baseLabId;
|
|
||||||
$new->created_at = date('Y-m-d H:i:s');
|
|
||||||
$new->created_by = Auth::user()->id;
|
|
||||||
$new->record_status_id = RecordStatusEnum::ACTIVE;
|
|
||||||
$new->save();
|
|
||||||
|
|
||||||
return response()->json(['success' => true, 'message' => __('department.create_success')]);
|
|
||||||
} catch (\Exception $e){
|
|
||||||
return response()->json(['success' => false, 'message' => __('department.create_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function update(Request $request){
|
|
||||||
try{
|
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['update_department'])) return false;
|
|
||||||
$validator = \Validator::make($request->all(), [
|
|
||||||
'name_en' => 'required',
|
|
||||||
'weight' => 'nullable'
|
|
||||||
]);
|
|
||||||
if ($validator->fails()) return response()->json(['success' => false, 'message' => __('department.update_fail'), 'errors' => $validator->errors()->all()]);
|
|
||||||
$data = array(
|
|
||||||
'name_en' => $request->name_en,
|
|
||||||
'updated_at' => date('Y-m-d H:i:s'),
|
|
||||||
'updated_by' => Auth::id()
|
|
||||||
);
|
|
||||||
$this->model::query()->where('id', $request->uid)->update($data);
|
|
||||||
return response()->json(['success' => true, 'message' => __('department.update_success')]);
|
|
||||||
} catch (\Exception $e){
|
|
||||||
return response()->json(['success' => false, 'message' => __('department.update_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function get(Request $request){
|
|
||||||
try{
|
|
||||||
$department = $this->model::query()->find($request->uid);
|
|
||||||
return response()->json(['success' => true, 'message' => __('department.get_success'), 'data' => $department]);
|
|
||||||
} catch (\Exception $e){
|
|
||||||
return response()->json(['success' => false, 'message' => __('department.get_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function delete(Request $request){
|
|
||||||
try{
|
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['delete_department'])) return false;
|
|
||||||
$this->model::query()->where('id', $request->uid)->update(array('record_status_id'=> RecordStatusEnum::DELETE));
|
|
||||||
return response()->json(['success' => true, 'message' => __('department.delete_success')]);
|
|
||||||
} catch (\Exception $e){
|
|
||||||
return response()->json(['success' => false, 'message' => __('department.delete_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function restore(Request $request){
|
|
||||||
try{
|
|
||||||
$this->model::query()->where('id', $request->uid)->update(array('record_status_id'=> RecordStatusEnum::ACTIVE));
|
|
||||||
return response()->json(['success' => true, 'message' => __('department.restore_success')]);
|
|
||||||
} catch (\Exception $e){
|
|
||||||
return response()->json(['success' => false, 'message' => __('department.restore_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,327 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
|
||||||
use App\Enums\RecordStatusEnum;
|
|
||||||
use App\Http\Controllers\Helper\GlobalController;
|
|
||||||
use App\Http\Requests\SampleCreateRequest;
|
|
||||||
use App\Http\Requests\UpdateRequests\SampleUpdateRequest;
|
|
||||||
use App\Http\Resources\SampleResource;
|
|
||||||
use App\Models\BaseModel;
|
|
||||||
use App\Models\Invoice;
|
|
||||||
use App\Models\InvoiceDetail;
|
|
||||||
use App\Models\Patient;
|
|
||||||
use App\Models\Sample;
|
|
||||||
use App\Models\LabConfigure;
|
|
||||||
use App\Models\Physician;
|
|
||||||
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Illuminate\Support\Facades\Auth;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
use Illuminate\Support\Facades\Session;
|
|
||||||
|
|
||||||
class InvoiceController extends Controller
|
|
||||||
{
|
|
||||||
protected $model;
|
|
||||||
protected $sampleModel;
|
|
||||||
protected $patientModel;
|
|
||||||
protected $invoiceDetailModel;
|
|
||||||
protected $baseLabId;
|
|
||||||
protected $labs;
|
|
||||||
protected $base;
|
|
||||||
protected $laboratoryConfigures;
|
|
||||||
protected $physicianModel;
|
|
||||||
|
|
||||||
|
|
||||||
public function __construct(Invoice $invoiceModel, InvoiceDetail $invoiceDetailModel, Sample $sampleModel, Patient $patientModel, Physician $physicianModel){
|
|
||||||
$this->model = $invoiceModel;
|
|
||||||
$this->sampleModel = $sampleModel;
|
|
||||||
$this->invoiceDetailModel = $invoiceDetailModel;
|
|
||||||
$this->patientModel = $patientModel;
|
|
||||||
$this->laboratoryConfigures = new LabConfigure();
|
|
||||||
$this->physicianModel = $physicianModel;
|
|
||||||
|
|
||||||
$this->baseLabId = Session::get('base_lab_id');
|
|
||||||
$this->base = Session::get('base_lab');
|
|
||||||
$this->labs = parent::getAccessAbleLabs();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function index(Request $request){
|
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['view_invoice'])) return redirect(url('my-profile'));
|
|
||||||
$recordStatusConditions = Auth::id()==1 ? [RecordStatusEnum::ACTIVE , RecordStatusEnum::DELETE] : [RecordStatusEnum::ACTIVE];
|
|
||||||
|
|
||||||
$oweInvoices = $this->model::with(['sample.patient'])->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
|
||||||
->where('balance','>', 0)->get();
|
|
||||||
$physicians = $this->physicianModel::query()->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->get();
|
|
||||||
|
|
||||||
$invoices = $this->model::with(['sample','repayments'])
|
|
||||||
->whereIn(BaseModel::RECORD_STATUS_FIELD, $recordStatusConditions)
|
|
||||||
->where('lab_id', $this->baseLabId)
|
|
||||||
->when(!empty($request->from_date) && !empty($request->to_date), function ($inv) use ($request){
|
|
||||||
$inv->whereBetween('invoice_date',[date('Y-m-d',strtotime($request->from_date)), date('Y-m-d',strtotime($request->to_date))]);
|
|
||||||
})
|
|
||||||
->when(isset($request->physician) && !empty($request->physician), function($inv) use ($request){
|
|
||||||
$inv->whereIn('sample_id', $this->sampleModel::query()->where('physician_id', $request->physician)->pluck('id'));
|
|
||||||
})
|
|
||||||
->when(!empty(trim($request->kword)), function ($inv) use($request, $recordStatusConditions){
|
|
||||||
$inv->whereRaw("replace(invoice_code, ' ','') like '%".str_replace(" ","",$request->kword)."%'")
|
|
||||||
->orWhereIn('sample_id', $this->sampleModel::query()
|
|
||||||
->whereIn('patient_id', $this->patientModel::query()
|
|
||||||
->whereRaw("replace(name_en, ' ','') like '%".str_replace(" ","",$request->kword)."%'")
|
|
||||||
->orWhereRaw("replace(phone_number, ' ','') like '%".str_replace(" ","",$request->kword)."%'")
|
|
||||||
->orWhere('patient_uuid','like','%'.$request->kword.'%')->pluck('id')->toArray()
|
|
||||||
)->orwhereRaw("replace(sample_number, ' ','') like '%".str_replace(" ","",$request->kword)."%'")->pluck('id')->toArray()
|
|
||||||
)->where('lab_id', $this->baseLabId)->whereIn(BaseModel::RECORD_STATUS_FIELD, $recordStatusConditions);
|
|
||||||
})->orderBy('invoice_code','desc')->paginate(20);
|
|
||||||
if(Auth::id()==1){
|
|
||||||
//dd($invoices->pluck('repayments'));
|
|
||||||
}
|
|
||||||
return view('v_invoice.invoice', ['invoices' => $invoices, 'labSettings' => (object) $this->location(), 'oweInvoices' => $oweInvoices, 'physicians' => $physicians]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function create($sample_id = null){
|
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['create_invoice'])) return redirect(url('my-profile'));
|
|
||||||
$samples = $this->sampleModel::query()->with('invoice')
|
|
||||||
->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
|
||||||
->whereDoesntHave('invoice')->get();
|
|
||||||
return view('v_invoice.new_invoice', [
|
|
||||||
'samples' => $samples,
|
|
||||||
'sample_id' => $sample_id
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function store(Request $request){
|
|
||||||
DB::beginTransaction();
|
|
||||||
try{
|
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['create_invoice'])) return redirect(url('my-profile'));
|
|
||||||
$invoiceNumber = $this->generateAutoId($request->invoice_date);
|
|
||||||
$is_hide_discount = isset($request->is_hide_discount) ? 1: 0;
|
|
||||||
$requests = collect($request)->merge(['lab_id'=>$this->baseLabId, 'invoice_code' => $invoiceNumber, 'is_hide_discount' => $is_hide_discount, 'exchange_rate' => ((object) $this->location())->exchange_rate])->except(['first_paid_date']);
|
|
||||||
$invoice = $this->model::query()->create($requests->all());
|
|
||||||
$invoiceDetailRequest = collect($request->test_sample_id);
|
|
||||||
$items = $invoiceDetailRequest->map(function ($row, $key) use($request, $invoice) {
|
|
||||||
$invoiceDetailRow = $this->invoiceDetailModel::query()->create([
|
|
||||||
'invoice_id' => $invoice->id,
|
|
||||||
'test_sample_id' => $request->test_sample_id[$key],
|
|
||||||
'discount_type' => $request->item_discount_type[$key],
|
|
||||||
'discount' => $request->item_discount[$key],
|
|
||||||
'test_name' => $request->test_name[$key],
|
|
||||||
'qty' => 1,
|
|
||||||
'unit_price' => $request->unit_price[$key],
|
|
||||||
]);
|
|
||||||
return [];
|
|
||||||
});
|
|
||||||
DB::commit();
|
|
||||||
$request->session()->flash('message','invoice-success');
|
|
||||||
if(isset($request->save_print_invoice) && $request->save_print_invoice=='save_preview_invoice'){
|
|
||||||
return redirect('invoice/edit/'.$invoice->id.'?print');
|
|
||||||
}
|
|
||||||
return redirect()->back();
|
|
||||||
} catch (\Exception $e){
|
|
||||||
DB::rollBack();
|
|
||||||
$request->session()->flash('message','invoice-error');
|
|
||||||
return redirect()->back();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function edit($id){
|
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['view_invoice', 'update_invoice'])) return redirect(url('my-profile'));
|
|
||||||
$invoice = $this->model::query()->with('invoiceDetail.testSample.sample.department','creator','modifier')->where(['lab_id' => $this->baseLabId, 'id' => $id])->first();
|
|
||||||
|
|
||||||
$samples = $this->sampleModel::query()->where('id', $invoice->sample_id)->first();
|
|
||||||
|
|
||||||
$refreshItemItem = $this->refreshItemItem($invoice->sample_id);
|
|
||||||
|
|
||||||
|
|
||||||
$labConfigures = $this->laboratoryConfigures::query()->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->get()->toArray();
|
|
||||||
|
|
||||||
return view('v_invoice.edit_invoice', [
|
|
||||||
'samples' => [$samples],
|
|
||||||
'invoice' => $invoice,
|
|
||||||
'invoice_id' => $id,
|
|
||||||
'sample_id' => $invoice->sample_id,
|
|
||||||
'labSettings' => (object) $this->location(),
|
|
||||||
'refreshItemItem' => $refreshItemItem,
|
|
||||||
'labConfigures' => $labConfigures,
|
|
||||||
'is_need_refresh_invoice' => (count($refreshItemItem) == count($invoice->invoiceDetail)) ? 0 : 1
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function update(Request $invoiceUpdateRequest){
|
|
||||||
DB::beginTransaction();
|
|
||||||
try{
|
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['update_invoice'])) return redirect(url('my-profile'));
|
|
||||||
$is_hide_discount = isset($invoiceUpdateRequest->is_hide_discount) ? 1: 0;
|
|
||||||
$requests = collect($invoiceUpdateRequest)->only(['invoice_note','total','discount','gross_total','deposit' ,'bank_deposit', 'balance','invoice_date','exchange_rate'])->merge(['is_hide_discount' => $is_hide_discount, 'updated_by' => Auth::id(), 'updated_at' => date('Y-m-d H:i:s')]);
|
|
||||||
$invoice = $this->model::query()->where(['id' => $invoiceUpdateRequest->uid, 'lab_id' => $this->baseLabId])->update($requests->all());
|
|
||||||
$invoiceDetailRequest = collect($invoiceUpdateRequest->test_sample_id);
|
|
||||||
$items = $invoiceDetailRequest->map(function ($row, $key) use($invoiceUpdateRequest) {
|
|
||||||
$invDetail = $this->invoiceDetailModel::query()->where(['invoice_id' => $invoiceUpdateRequest->uid, 'test_sample_id' => $invoiceUpdateRequest->test_sample_id[$key]])->first();
|
|
||||||
if (empty($invDetail)) {
|
|
||||||
$invoiceDetailRow = $this->invoiceDetailModel::query()->create([
|
|
||||||
'invoice_id' => $invoiceUpdateRequest->uid,
|
|
||||||
'test_sample_id' => $invoiceUpdateRequest->test_sample_id[$key],
|
|
||||||
'discount_type' => $invoiceUpdateRequest->item_discount_type[$key],
|
|
||||||
'discount' => $invoiceUpdateRequest->item_discount[$key],
|
|
||||||
'test_name' => $invoiceUpdateRequest->test_name[$key],
|
|
||||||
'weight' => $invoiceUpdateRequest->weight[$key],
|
|
||||||
'qty' => 1,
|
|
||||||
'unit_price' => $invoiceUpdateRequest->unit_price[$key],
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
$invoiceDetailRow = $this->invoiceDetailModel::query()->where([
|
|
||||||
'invoice_id' => $invoiceUpdateRequest->uid,
|
|
||||||
'test_sample_id' => $invoiceUpdateRequest->test_sample_id[$key]
|
|
||||||
])->update([
|
|
||||||
'weight' => $invoiceUpdateRequest->weight[$key]
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
return [];
|
|
||||||
});
|
|
||||||
$this->invoiceDetailModel::query()->where('invoice_id', $invoiceUpdateRequest->uid)
|
|
||||||
->whereNotIn('test_sample_id', $invoiceUpdateRequest->test_sample_id)->delete();
|
|
||||||
DB::commit();
|
|
||||||
$invoiceUpdateRequest->session()->flash('message','invoice-success');
|
|
||||||
return redirect()->back();
|
|
||||||
} catch (\Exception $e){
|
|
||||||
DB::rollBack();
|
|
||||||
$invoiceUpdateRequest->session()->flash('message','invoice-error');
|
|
||||||
return redirect()->back();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Perform by ajax function
|
|
||||||
* @param Request $request
|
|
||||||
* @return \Illuminate\Http\JsonResponse
|
|
||||||
*/
|
|
||||||
|
|
||||||
public function delete(Request $request){
|
|
||||||
try{
|
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['delete_invoice'])) return false;
|
|
||||||
$invoice = $this->model::query()->where(['id' => $request->uid, 'lab_id' => $this->baseLabId])->first();
|
|
||||||
$invoice->update(array(BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::DELETE));
|
|
||||||
return response()->json(['success' => true, 'message' => __('invoice.delete_success')]);
|
|
||||||
} catch (\Exception $e){
|
|
||||||
return response()->json(['success' => false, 'message' => __('invoice.delete_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function restore(Request $request){
|
|
||||||
try{
|
|
||||||
$this->model::query()->where('id', $request->uid)->update(array(BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE));
|
|
||||||
return response()->json(['success' => true, 'message' => __('invoice.restore_success')]);
|
|
||||||
} catch (\Exception $e){
|
|
||||||
return response()->json(['success' => false, 'message' => __('invoice.restore_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getSampleTest($sampleId){
|
|
||||||
try{
|
|
||||||
$patientTypes = $this->sampleModel::query()->with([])->where([
|
|
||||||
BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE,
|
|
||||||
'lab_id' => $this->baseLabId
|
|
||||||
])->get();
|
|
||||||
return response()->json(['success'=> true , 'data' => $patientTypes]);
|
|
||||||
} catch (\Exception $e)
|
|
||||||
{
|
|
||||||
return response()->json(['success'=> false , 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function generateAutoId($invoiceDate){
|
|
||||||
$prefix = date('y',strtotime($invoiceDate));
|
|
||||||
$invoiceCount = $this->model::query()->where('lab_id', $this->baseLabId)->whereRaw('year(invoice_date) ="'. date('Y',strtotime($invoiceDate)).'"')->count();
|
|
||||||
return 'I-'.$this->base['short_name'].'-'.$prefix.'-'.(str_pad(($invoiceCount+1),5,'0',STR_PAD_LEFT));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function paid($id){
|
|
||||||
DB::beginTransaction();
|
|
||||||
try{
|
|
||||||
$invoice = $this->model::query()->find($id);
|
|
||||||
$invoice->balance = 0;
|
|
||||||
$invoice->deposit = $invoice->gross_total;
|
|
||||||
$invoice->first_paid_date = date('Y-m-d');
|
|
||||||
$invoice->save();
|
|
||||||
DB::commit();
|
|
||||||
return response()->json(['success' => true, 'message' => __('This invoice already paid')]);
|
|
||||||
} catch (\Exception $e){
|
|
||||||
DB::rollBack();
|
|
||||||
return response()->json(['success' => false, 'message' => __('Failed while trying to paid on invoice'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function refreshItemItem($sampleId){
|
|
||||||
try{
|
|
||||||
$resultItems = DB::select('
|
|
||||||
SELECT
|
|
||||||
d.`id` AS department_id,
|
|
||||||
d.`name_en` AS department_name,
|
|
||||||
d.weight as dweight,
|
|
||||||
st.`id` AS sample_type_id,
|
|
||||||
st.weight as sweight,
|
|
||||||
st.`name_en` AS sample_type,
|
|
||||||
ts.`id` AS test_sample_id,
|
|
||||||
ts.`heading_id` AS parent_id,
|
|
||||||
ts.`field_type`,
|
|
||||||
ts.`usd_price`,
|
|
||||||
ts.group_result,
|
|
||||||
ts.description,
|
|
||||||
t.`id` AS test_id,
|
|
||||||
t.`name_en` AS test_name,
|
|
||||||
tr.id as test_result_id,
|
|
||||||
pct.`commission_type`,
|
|
||||||
ifnull(pct.`commission_rate`, 0.00) as commission_rate,
|
|
||||||
ifnull(pct.`partner_price`, 0.00) as partner_price,
|
|
||||||
ts.weight
|
|
||||||
FROM samples s
|
|
||||||
INNER JOIN test_results tr
|
|
||||||
ON tr.`sample_id` = s.`id`
|
|
||||||
AND s.`lab_id` = tr.`lab_id`
|
|
||||||
INNER JOIN test_samples ts
|
|
||||||
ON ts.id = tr.`test_sample_id`
|
|
||||||
and ts.lab_id = tr.lab_id
|
|
||||||
INNER JOIN tests t
|
|
||||||
ON t.`id` = ts.`test_id`
|
|
||||||
INNER JOIN sample_types st
|
|
||||||
ON st.`id` = ts.`sample_type_id`
|
|
||||||
INNER JOIN departments d
|
|
||||||
ON d.`id` = st.`department_id`
|
|
||||||
LEFT JOIN `physician_commisssion` AS pct
|
|
||||||
ON pct.`test_sample_id` = ts.`id`
|
|
||||||
AND pct.`physician_id` = s.`physician_id`
|
|
||||||
WHERE s.`id` = '.$sampleId.'
|
|
||||||
AND s.`lab_id`= '.$this->baseLabId.'
|
|
||||||
AND tr.`record_status_id` = '.BaseModel::RECORD_STATUS_ACTIVE.'
|
|
||||||
AND LENGTH(ts.group_result)>0
|
|
||||||
AND ts.usd_price>0
|
|
||||||
ORDER BY
|
|
||||||
d.`weight`,
|
|
||||||
st.`weight`,
|
|
||||||
ts.`weight`');
|
|
||||||
$departmentArray = array();
|
|
||||||
foreach ($resultItems as $row){
|
|
||||||
$net_amount = number_format((((!empty($row->commission_type) ? $row->commission_type : ((object) $this->location())->discount_type)) ==2 ? (($row->usd_price - $row->partner_price) - $row->commission_rate) :
|
|
||||||
(($row->usd_price - $row->partner_price) * (1-$row->commission_rate/100))),2);
|
|
||||||
$testItemArray = array(
|
|
||||||
'test_sample_id' => (string)$row->test_sample_id,
|
|
||||||
'test_id' => $row->test_id,
|
|
||||||
'test_name' => $row->test_name,
|
|
||||||
'closed_parent_id' => (string) (int)$row->parent_id,
|
|
||||||
'field_type' => (string) $row->field_type,
|
|
||||||
'usd_price' => $row->usd_price,
|
|
||||||
'group_result' => (string) $row->group_result,
|
|
||||||
'item_discount_type' => (!empty($row->commission_type) ? $row->commission_type : ((object) $this->location())->discount_type),
|
|
||||||
'item_discount_rate' => $row->commission_rate,
|
|
||||||
'item_discount' => $net_amount,
|
|
||||||
'discount_price' => ($row->usd_price - $net_amount)
|
|
||||||
);
|
|
||||||
$departmentArray[] = $testItemArray;
|
|
||||||
}
|
|
||||||
return $departmentArray;
|
|
||||||
} catch (\Exception $e){
|
|
||||||
return $e->getMessage();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,486 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
|
||||||
use App\Enums\RecordStatusEnum;
|
|
||||||
use App\Http\Controllers\Helper\GlobalController;
|
|
||||||
use App\Models\BaseModel;
|
|
||||||
use App\Models\Department;
|
|
||||||
use App\Models\SampleType;
|
|
||||||
use App\Models\TestNormalValue;
|
|
||||||
use App\Models\TestSample;
|
|
||||||
use App\Models\TestSampleOrganism;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use App\Models\Laboratory;
|
|
||||||
use Illuminate\Support\Facades\Auth;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
use Illuminate\Support\Facades\Session;
|
|
||||||
use App\Models\LabConfigure;
|
|
||||||
|
|
||||||
|
|
||||||
class LabController extends Controller
|
|
||||||
{
|
|
||||||
protected $model;
|
|
||||||
protected $baseLabId;
|
|
||||||
protected $testSampleModel;
|
|
||||||
protected $labs;
|
|
||||||
|
|
||||||
public function __construct(Laboratory $model, TestSample $testSampleModel){
|
|
||||||
$this->model = $model;
|
|
||||||
$this->testSampleModel = $testSampleModel;
|
|
||||||
$this->baseLabId = Session::get('base_lab_id');
|
|
||||||
$this->base = Session::get('base_lab');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function index(Request $request){
|
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['system_settings'])) return redirect(url('my-profile'));
|
|
||||||
$lab = $this->model::query()->find($this->baseLabId);
|
|
||||||
return view('laboratory', ['info' => $lab]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function save(Request $request){
|
|
||||||
try {
|
|
||||||
|
|
||||||
$validator = \Validator::make($request->all(), [
|
|
||||||
'lab_name_en' => 'required',
|
|
||||||
'lab_code' => 'required|max:5',
|
|
||||||
'sample_number' => 'required',
|
|
||||||
'patient_code' => 'required',
|
|
||||||
'start_date' => 'required',
|
|
||||||
'end_date' => 'nullable'
|
|
||||||
]);
|
|
||||||
if ($validator->fails()) {
|
|
||||||
return response()->json(['success' => false, 'message' => __('laboratory.create_fail'), 'errors' => $validator->errors()->all()]);
|
|
||||||
}
|
|
||||||
$data = array(
|
|
||||||
'name_en' => $request->lab_name_en,
|
|
||||||
'name_kh' => $request->lab_name_kh,
|
|
||||||
'short_name' => $request->lab_code,
|
|
||||||
'sample_number' => $request->sample_number,
|
|
||||||
'patient_code' => $request->patient_code,
|
|
||||||
'phone_number' => $request->phone_number,
|
|
||||||
'lab_category_id' => $request->lab_category_id,
|
|
||||||
'is_auto_make_invoice' => $request->is_auto_make_invoice,
|
|
||||||
'email' => $request->email,
|
|
||||||
'shareable_lab_result' => isset($request->shareable_lab_result) ? 1 : 0,
|
|
||||||
'allow_external_request' => isset($request->allow_external_request) ? 1 : 0,
|
|
||||||
'is_hide_comission_percentage' => isset($request->is_hide_comission_percentage) ? $request->is_hide_comission_percentage : 0,
|
|
||||||
'is_hide_inv_discount' => 0,
|
|
||||||
'address_en' => $request->address_en,
|
|
||||||
'address_kh' => $request->address_kh,
|
|
||||||
'start_date' => ($request->start_date ? date('Y-m-d H:i:s', strtotime($request->start_date)) : null),
|
|
||||||
'end_date' => ($request->end_date ? date('Y-m-d H:i:s', strtotime($request->end_date)) : null),
|
|
||||||
'created_at' => date('Y-m-d H:i:s'),
|
|
||||||
'created_by' => Auth::id()
|
|
||||||
);
|
|
||||||
$this->model::query()->insert($data);
|
|
||||||
return response()->json(['success' => true, 'message' => __('laboratory.create_success')]);
|
|
||||||
}
|
|
||||||
catch (\Exception $e){
|
|
||||||
return response()->json(['success' => false, 'message' => __('laboratory.create_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function updateInfo(Request $request){
|
|
||||||
try {
|
|
||||||
$validator = \Validator::make($request->all(), [
|
|
||||||
'name_en' => 'required',
|
|
||||||
'name_kh' => 'required',
|
|
||||||
'short_name' => 'required|max:3'
|
|
||||||
]);
|
|
||||||
if ($validator->fails()) return response()->json(['errors' => $validator->errors()->all()]);
|
|
||||||
$data = array(
|
|
||||||
'name_en' => $request->name_en,
|
|
||||||
'name_kh' => $request->name_kh,
|
|
||||||
'short_name' => $request->short_name,
|
|
||||||
'email' => $request->email,
|
|
||||||
'phone_number' => $request->phone_number,
|
|
||||||
'address_en' => $request->address_en,
|
|
||||||
'address_kh' => $request->address_kh,
|
|
||||||
'updated_at' => date('Y-m-d H:i:s'),
|
|
||||||
'updated_by' => Auth::id()
|
|
||||||
);
|
|
||||||
$this->model::query()->where('id', $this->baseLabId)->update($data);
|
|
||||||
return redirect()->back();
|
|
||||||
//return response()->json(['success' => true, 'message' => __('laboratory.update_success')]);
|
|
||||||
} catch (\Exception $e){
|
|
||||||
dd($e);
|
|
||||||
//return redirect()->back();
|
|
||||||
return response()->json(['success' => false, 'message' => __('laboratory.update_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function update(Request $request){
|
|
||||||
try {
|
|
||||||
|
|
||||||
$validator = \Validator::make($request->all(), [
|
|
||||||
'lab_name_en' => 'required',
|
|
||||||
'lab_code' => 'required|max:5',
|
|
||||||
'sample_number' => 'required',
|
|
||||||
'patient_code' => 'required',
|
|
||||||
'start_date' => 'required',
|
|
||||||
'end_date' => 'nullable'
|
|
||||||
]);
|
|
||||||
if ($validator->fails()) return response()->json(['errors' => $validator->errors()->all()]);
|
|
||||||
$data = array(
|
|
||||||
'name_en' => $request->lab_name_en,
|
|
||||||
'name_kh' => $request->lab_name_kh,
|
|
||||||
'short_name' => $request->lab_code,
|
|
||||||
'sample_number' => $request->sample_number,
|
|
||||||
'patient_code' => $request->patient_code,
|
|
||||||
'phone_number' => $request->phone_number,
|
|
||||||
'lab_category_id' => $request->lab_category_id,
|
|
||||||
'is_auto_make_invoice' => $request->is_auto_make_invoice,
|
|
||||||
'email' => $request->email,
|
|
||||||
'shareable_lab_result' => isset($request->shareable_lab_result) ? 1 : 0,
|
|
||||||
'allow_external_request' => isset($request->allow_external_request) ? 1 : 0,
|
|
||||||
'is_hide_comission_percentage' => isset($request->is_hide_comission_percentage) ? $request->is_hide_comission_percentage : 0,
|
|
||||||
'address_en' => $request->address_en,
|
|
||||||
'address_kh' => $request->address_kh,
|
|
||||||
'start_date' => ($request->start_date ? date('Y-m-d H:i:s', strtotime($request->start_date)) : null),
|
|
||||||
'end_date' => ($request->end_date ? date('Y-m-d H:i:s', strtotime($request->end_date)) : null),
|
|
||||||
'updated_at' => date('Y-m-d H:i:s'),
|
|
||||||
'updated_by' => Auth::id()
|
|
||||||
);
|
|
||||||
$this->model::query()->where('id', $request->lab_id)->update($data);
|
|
||||||
return response()->json(['success' => true, 'message' => __('laboratory.update_success')]);
|
|
||||||
} catch (\Exception $e){
|
|
||||||
return response()->json(['success' => false, 'message' => __('laboratory.update_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function get(Request $request){
|
|
||||||
try{
|
|
||||||
$lab_id = $request->lab_id;
|
|
||||||
$lab = $this->model::query()->where('id', $lab_id)->get()->first();
|
|
||||||
return response()->json(['success' => true, 'message' => __('laboratory.get_success'), 'data' => $lab]);
|
|
||||||
} catch (\Exception $e){
|
|
||||||
return response()->json(['success' => false, 'message' => __('laboratory.get_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function delete(Request $request){
|
|
||||||
try{
|
|
||||||
$this->model::query()->where('id', $request->lab_id)->update(array(BaseModel::RECORD_STATUS_FIELD=> RecordStatusEnum::DELETE));
|
|
||||||
return response()->json(['success' => true, 'message' => __('laboratory.delete_success')]);
|
|
||||||
}
|
|
||||||
catch (\Exception $e){
|
|
||||||
return response()->json(['success' => false, 'message' => __('laboratory.delete_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function restore(Request $request){
|
|
||||||
try{
|
|
||||||
$this->model::query()->where('id', $request->lab_id)->update(array(BaseModel::RECORD_STATUS_FIELD=> RecordStatusEnum::ACTIVE));
|
|
||||||
return response()->json(['success' => true, 'message' => __('laboratory.restore_success')]);
|
|
||||||
}
|
|
||||||
catch (\Exception $e){
|
|
||||||
return response()->json(['success' => false, 'message' => __('laboratory.restore_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function profile(){
|
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['update_laboratory_information'])) return redirect(url('my-profile'));
|
|
||||||
$lab = $this->model::query()->find($this->baseLabId);
|
|
||||||
return view('lab_profile', ['info' => $lab]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function labSettingSetters(Request $request){
|
|
||||||
try{
|
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['system_settings'])) return redirect(url('my-profile'));
|
|
||||||
$validator = \Validator::make($request->all(), [
|
|
||||||
'sample_number' => 'required|integer',
|
|
||||||
'patient_code' => 'required|integer',
|
|
||||||
'technician_label' => 'nullable',
|
|
||||||
'discount_type' => 'required|integer'
|
|
||||||
]);
|
|
||||||
if ($validator->fails()){ return response()->json(['errors'=>$validator->errors()->all()]);}
|
|
||||||
$lab = $this->model::query()->where('id', $this->baseLabId)->first();
|
|
||||||
$lab->update(array(
|
|
||||||
'sample_number' => $request->sample_number,
|
|
||||||
'currency' => $request->currency,
|
|
||||||
'patient_code' => $request->patient_code,
|
|
||||||
'technician_label' => $request->technician_label,
|
|
||||||
'discount_type' => $request->discount_type,
|
|
||||||
'phone_number' => $request->phone_number,
|
|
||||||
'email' => $request->email,
|
|
||||||
'exchange_rate' => $request->exchange_rate,
|
|
||||||
//'is_hide_inv_discount' => $request->is_hide_inv_discount,
|
|
||||||
'abnormal_text_color' => $request->abnormal_text_color,
|
|
||||||
'show_result_footer' => $request->show_result_footer,
|
|
||||||
'abnormal_result_font_weight' => $request->abnormal_result_font_weight,
|
|
||||||
'result_header_id' => $request->result_header_id,
|
|
||||||
'is_auto_make_invoice' => $request->is_auto_make_invoice,
|
|
||||||
'invoice_template_id' => $request->invoice_template_id
|
|
||||||
));
|
|
||||||
return response()->json(['success' => true, 'message' => __('laboratory.update_success'), 'data' => $lab]);
|
|
||||||
} catch (\Exception $e)
|
|
||||||
{
|
|
||||||
return response()->json(['success'=> false , 'message' => __('laboratory.update_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function uploadImage(Request $request){
|
|
||||||
try {
|
|
||||||
$image = $request->file('image');
|
|
||||||
$imageName = 'avatar_'.$this->baseLabId.'.' . $image->getClientOriginalExtension();
|
|
||||||
$lab = $this->model::query()->where('id', $this->baseLabId)->first();
|
|
||||||
$lab->update(array('logo' => $imageName));
|
|
||||||
$image->move(public_path('storage/images/avatars/labs'), $imageName);
|
|
||||||
return response()->json(['success' => true, 'message' => __('laboratory.update_success'), 'data' => $lab]);
|
|
||||||
}catch (\Exception $e){
|
|
||||||
return response()->json(['success'=> false , 'message' => __('laboratory.update_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function removeLabLogo(Request $request){
|
|
||||||
try {
|
|
||||||
$lab = $this->model::query()->find($this->baseLabId);
|
|
||||||
if(!empty($lab->logo)) {
|
|
||||||
if (file_exists(public_path('storage/images/avatars/labs/' . $lab->logo))) {
|
|
||||||
unlink(public_path('storage/images/avatars/labs/' . $lab->logo));
|
|
||||||
$lab->logo = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$lab->save();
|
|
||||||
return response()->json(['success' => true, 'message' => __('laboratory.update_success'), 'data' => $lab]);
|
|
||||||
}catch (\Exception $e){
|
|
||||||
return response()->json(['success'=> false , 'message' => __('laboratory.update_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function saveLabConfigure(Request $request){
|
|
||||||
try{
|
|
||||||
$validator = \Validator::make($request->all(), [
|
|
||||||
'attribute_code' => 'required|string',
|
|
||||||
'attribute_value' => 'required|string'
|
|
||||||
]);
|
|
||||||
if ($validator->fails()){ return response()->json(['errors'=>$validator->errors()->all()]);}
|
|
||||||
$labSetting = $this->labConfigureModel::query()->firstOrNew(['atrribute_code' => $request->attribute_code, 'lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD=> RecordStatusEnum::ACTIVE]);
|
|
||||||
$labSetting->assigned_attribute_value = $request->attribute_value;
|
|
||||||
$labSetting->save();
|
|
||||||
return response()->json(['success' => true, 'message' => __('laboratory.update_success'), 'data' => $labSetting]);
|
|
||||||
} catch (\Exception $e)
|
|
||||||
{
|
|
||||||
return response()->json(['success'=> false , 'message' => __('laboratory.update_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function initLabData(){
|
|
||||||
return view('clone_lab',['labs' => $this->labs]);
|
|
||||||
}
|
|
||||||
|
|
||||||
function getLabData($labId){
|
|
||||||
try{
|
|
||||||
$department = Department::query()->with([
|
|
||||||
'samples',
|
|
||||||
'samples.testSamples',
|
|
||||||
'samples.testSamples.testValues',
|
|
||||||
'samples.testSamples.organisms',
|
|
||||||
'samples.testSamples.organisms.antibiotics'
|
|
||||||
])->where(['lab_id' => $labId, BaseModel::RECORD_STATUS_FIELD => 1])->get()->toArray();
|
|
||||||
return response()->json(['success' => true, 'data' => $department]);
|
|
||||||
}
|
|
||||||
catch (\Exception $e){
|
|
||||||
return response()->json(['success'=> false , 'message' => 'Error while retrieving lab data.']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Verify Image */
|
|
||||||
|
|
||||||
public function uploadVerifyImage(Request $request){
|
|
||||||
try {
|
|
||||||
$image = $request->file('image');
|
|
||||||
$imageName = 'verify_label_'.$this->baseLabId.'.' . $image->getClientOriginalExtension();
|
|
||||||
$lab = $this->model::query()->where('id', $this->baseLabId)->first();
|
|
||||||
$lab->update(array('verify_label' => $imageName));
|
|
||||||
$image->move(public_path('storage/images/avatars/labs'), $imageName);
|
|
||||||
return response()->json(['success' => true, 'message' => __('laboratory.update_success'), 'data' => $lab]);
|
|
||||||
}catch (\Exception $e){
|
|
||||||
return response()->json(['success'=> false , 'message' => __('laboratory.update_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function removeVerifyImage(Request $request){
|
|
||||||
try {
|
|
||||||
$lab = $this->model::query()->find($this->baseLabId);
|
|
||||||
if(!empty($lab->verify_label)) {
|
|
||||||
if (file_exists(public_path('storage/images/avatars/labs/' . $lab->verify_label))) {
|
|
||||||
unlink(public_path('storage/images/avatars/labs/' . $lab->verify_label));
|
|
||||||
$lab->verify_label = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$lab->save();
|
|
||||||
return response()->json(['success' => true, 'message' => __('laboratory.update_success'), 'data' => $lab]);
|
|
||||||
}catch (\Exception $e){
|
|
||||||
return response()->json(['success'=> false , 'message' => __('laboratory.update_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateHeading(){
|
|
||||||
$targetLabTestSample = TestSample::query()->where(['lab_id' => 18,'sample_type_id'=>397, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
|
||||||
->where('heading_id','>',0)->get();
|
|
||||||
foreach ($targetLabTestSample as $targetTestSample){
|
|
||||||
dd($targetTestSample);
|
|
||||||
$source = TestSample::query()->where(['id' => $targetTestSample->heading_id, 'lab_id' => 29])->get();//->first();
|
|
||||||
dd($source);
|
|
||||||
$target = TestSample::query()->where(['lab_id' => 18, 'test_id' => $source->test_id , 'sample_type_id' => $targetTestSample->sample_type_id ])->get()->first();
|
|
||||||
|
|
||||||
//TestSample::query()->where(['id' => $targetTestSample->id])->update([ 'heading_id' => $target->id]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public function uploadAlternativeLogo(Request $request){
|
|
||||||
try {
|
|
||||||
$image = $request->file('image');
|
|
||||||
$imageName = 'alternative_logo_'.$this->baseLabId.'.' . $image->getClientOriginalExtension();
|
|
||||||
$lab = $this->model::query()->where('id', $this->baseLabId)->first();
|
|
||||||
$lab->update(array('alternative_logo' => $imageName));
|
|
||||||
$image->move(public_path('storage/images/avatars/labs/alternative_logo'), $imageName);
|
|
||||||
return response()->json(['success' => true, 'message' => __('laboratory.update_success'), 'data' => $lab]);
|
|
||||||
}catch (\Exception $e){
|
|
||||||
return response()->json(['success'=> false , 'message' => __('laboratory.update_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function removeAlternativeLogo(Request $request){
|
|
||||||
try {
|
|
||||||
$lab = $this->model::query()->find($this->baseLabId);
|
|
||||||
if(!empty($lab->alternative_logo)) {
|
|
||||||
if (file_exists(public_path('storage/images/avatars/labs/alternative_logo/' . $lab->alternative_logo))) {
|
|
||||||
unlink(public_path('storage/images/avatars/labs/alternative_logo/' . $lab->alternative_logo));
|
|
||||||
$lab->alternative_logo = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$lab->save();
|
|
||||||
return response()->json(['success' => true, 'message' => __('laboratory.update_success'), 'data' => $lab]);
|
|
||||||
}catch (\Exception $e){
|
|
||||||
return response()->json(['success'=> false , 'message' => __('laboratory.update_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Alternative Verify Signature
|
|
||||||
public function uploadAlterVerifySignature(Request $request){
|
|
||||||
try {
|
|
||||||
$image = $request->file('image');
|
|
||||||
$imageName = 'alter_verify_sign_'.$this->baseLabId.'.' . $image->getClientOriginalExtension();
|
|
||||||
$lab = $this->model::query()->where('id', $this->baseLabId)->first();
|
|
||||||
$lab->update(array('alter_verify_sign' => $imageName));
|
|
||||||
$image->move(public_path('storage/images/avatars/labs'), $imageName);
|
|
||||||
return response()->json(['success' => true, 'message' => __('laboratory.update_success'), 'data' => $lab]);
|
|
||||||
}catch (\Exception $e){
|
|
||||||
return response()->json(['success'=> false , 'message' => __('laboratory.update_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function removeAlterVerifySignature(Request $request){
|
|
||||||
try {
|
|
||||||
$lab = $this->model::query()->find($this->baseLabId);
|
|
||||||
if(!empty($lab->alter_verify_sign)) {
|
|
||||||
if (file_exists(public_path('storage/images/avatars/labs/' . $lab->alter_verify_sign))) {
|
|
||||||
unlink(public_path('storage/images/avatars/labs/' . $lab->alter_verify_sign));
|
|
||||||
$lab->alter_verify_sign = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$lab->save();
|
|
||||||
return response()->json(['success' => true, 'message' => __('laboratory.update_success'), 'data' => $lab]);
|
|
||||||
}catch (\Exception $e){
|
|
||||||
return response()->json(['success'=> false , 'message' => __('laboratory.update_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Alternative Labtech Signature
|
|
||||||
public function uploadAlterLabtechSignature(Request $request){
|
|
||||||
try {
|
|
||||||
$image = $request->file('image');
|
|
||||||
$imageName = 'alter_labtech_sign_'.$this->baseLabId.'.' . $image->getClientOriginalExtension();
|
|
||||||
$lab = $this->model::query()->where('id', $this->baseLabId)->first();
|
|
||||||
$lab->update(array('alter_labtech_sign' => $imageName));
|
|
||||||
$image->move(public_path('storage/images/avatars/labs'), $imageName);
|
|
||||||
return response()->json(['success' => true, 'message' => __('laboratory.update_success'), 'data' => $lab]);
|
|
||||||
}catch (\Exception $e){
|
|
||||||
return response()->json(['success'=> false , 'message' => __('laboratory.update_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function removeAlterLabtechSignature(Request $request){
|
|
||||||
try {
|
|
||||||
$lab = $this->model::query()->find($this->baseLabId);
|
|
||||||
if(!empty($lab->alter_labtech_sign)) {
|
|
||||||
if (file_exists(public_path('storage/images/avatars/labs/' . $lab->alter_labtech_sign))) {
|
|
||||||
unlink(public_path('storage/images/avatars/labs/' . $lab->alter_labtech_sign));
|
|
||||||
$lab->alter_labtech_sign = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$lab->save();
|
|
||||||
return response()->json(['success' => true, 'message' => __('laboratory.update_success'), 'data' => $lab]);
|
|
||||||
}catch (\Exception $e){
|
|
||||||
return response()->json(['success'=> false , 'message' => __('laboratory.update_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** default footer */
|
|
||||||
public function uploadDefaultFooter(Request $request){
|
|
||||||
try {
|
|
||||||
$image = $request->file('image');
|
|
||||||
$imageName = 'default_footer_'.$this->baseLabId.'.' . $image->getClientOriginalExtension();
|
|
||||||
$lab = $this->model::query()->where('id', $this->baseLabId)->first();
|
|
||||||
$lab->update(array('footer' => $imageName));
|
|
||||||
$image->move(public_path('storage/images/avatars/labs/default_footer'), $imageName);
|
|
||||||
return response()->json(['success' => true, 'message' => __('laboratory.update_success'), 'data' => $lab]);
|
|
||||||
}catch (\Exception $e){
|
|
||||||
return response()->json(['success'=> false , 'message' => __('laboratory.update_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function removeDefaultFooter(Request $request){
|
|
||||||
try {
|
|
||||||
$lab = $this->model::query()->find($this->baseLabId);
|
|
||||||
if(!empty($lab->footer)) {
|
|
||||||
if (file_exists(public_path('storage/images/avatars/labs/default_footer/' . $lab->footer))) {
|
|
||||||
unlink(public_path('storage/images/avatars/labs/default_footer/' . $lab->footer));
|
|
||||||
$lab->footer = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$lab->save();
|
|
||||||
return response()->json(['success' => true, 'message' => __('laboratory.update_success'), 'data' => $lab]);
|
|
||||||
}catch (\Exception $e){
|
|
||||||
return response()->json(['success'=> false , 'message' => __('laboratory.update_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* default footer end */
|
|
||||||
|
|
||||||
/** alternative footer */
|
|
||||||
public function uploadAlternativeFooter(Request $request){
|
|
||||||
try {
|
|
||||||
$image = $request->file('image');
|
|
||||||
$imageName = 'alternative_footer_'.$this->baseLabId.'.' . $image->getClientOriginalExtension();
|
|
||||||
$lab = $this->model::query()->where('id', $this->baseLabId)->first();
|
|
||||||
$lab->update(array('alternative_footer' => $imageName));
|
|
||||||
$image->move(public_path('storage/images/avatars/labs/alternative_footer'), $imageName);
|
|
||||||
return response()->json(['success' => true, 'message' => __('laboratory.update_success'), 'data' => $lab]);
|
|
||||||
}catch (\Exception $e){
|
|
||||||
return response()->json(['success'=> false , 'message' => __('laboratory.update_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function removeAlternativeFooter(Request $request){
|
|
||||||
try {
|
|
||||||
$lab = $this->model::query()->find($this->baseLabId);
|
|
||||||
if(!empty($lab->alternative_footer)) {
|
|
||||||
if (file_exists(public_path('storage/images/avatars/labs/alternative_footer/' . $lab->alternative_footer))) {
|
|
||||||
unlink(public_path('storage/images/avatars/labs/alternative_footer/' . $lab->alternative_footer));
|
|
||||||
$lab->alternative_footer = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$lab->save();
|
|
||||||
return response()->json(['success' => true, 'message' => __('laboratory.update_success'), 'data' => $lab]);
|
|
||||||
}catch (\Exception $e){
|
|
||||||
return response()->json(['success'=> false , 'message' => __('laboratory.update_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* alternative footer end */
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -6,11 +6,6 @@ use App\Http\Controllers\Helper\GlobalController;
|
|||||||
use App\Http\Requests\TestSampleCreateRequest;
|
use App\Http\Requests\TestSampleCreateRequest;
|
||||||
use App\Models\BaseModel;
|
use App\Models\BaseModel;
|
||||||
use App\Models\Organism;
|
use App\Models\Organism;
|
||||||
use App\Models\PatientType;
|
|
||||||
use App\Models\SampleType;
|
|
||||||
use App\Models\Test;
|
|
||||||
use App\Models\TestNormalValue;
|
|
||||||
use App\Models\TestSample;
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
@@ -20,19 +15,19 @@ class OrganismController extends Controller
|
|||||||
{
|
{
|
||||||
|
|
||||||
protected $model;
|
protected $model;
|
||||||
protected $baseLabId;
|
protected $baseOrganizationId;
|
||||||
protected $labs;
|
protected $labs;
|
||||||
|
|
||||||
public function __construct(Organism $organism){
|
public function __construct(Organism $organism){
|
||||||
$this->model = $organism;
|
$this->model = $organism;
|
||||||
$this->baseLabId = Session::get('base_lab_id');
|
$this->baseOrganizationId = Session::get('base_organization_id');
|
||||||
$this->base = Session::get('base_lab');
|
$this->base = Session::get('base_organization');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function index(Request $request){
|
public function index(Request $request){
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['view_organism'])) return redirect(url('my-profile'));
|
if(!GlobalController::user_can(Auth::user()->role_id, ['view_organism'])) return redirect(url('my-profile'));
|
||||||
$organisms = $this->model::with(['lab'])->where(BaseModel::RECORD_STATUS_FIELD, RecordStatusEnum::ACTIVE)
|
$organisms = $this->model::with(['lab'])->where(BaseModel::RECORD_STATUS_FIELD, RecordStatusEnum::ACTIVE)
|
||||||
//->where('lab_id', $this->baseLabId)
|
//->where('organization_id', $this->baseOrganizationId)
|
||||||
->when(!empty($request->kword), function ($organisms) use($request){
|
->when(!empty($request->kword), function ($organisms) use($request){
|
||||||
$organisms->whereRaw("replace(name_en, ' ','') like '%".str_replace(" ","",$request->kword)."%'");
|
$organisms->whereRaw("replace(name_en, ' ','') like '%".str_replace(" ","",$request->kword)."%'");
|
||||||
})->orderBy(BaseModel::CREATED_AT_FIELD,'desc')->paginate(config('labis.pagination.perpage', 10));
|
})->orderBy(BaseModel::CREATED_AT_FIELD,'desc')->paginate(config('labis.pagination.perpage', 10));
|
||||||
@@ -48,7 +43,7 @@ class OrganismController extends Controller
|
|||||||
$new->name_en = $request->name_en;
|
$new->name_en = $request->name_en;
|
||||||
$new->weight = $request->weight;
|
$new->weight = $request->weight;
|
||||||
$new->is_bold = $request->is_bold;
|
$new->is_bold = $request->is_bold;
|
||||||
$new->lab_id = $this->baseLabId;
|
$new->organization_id = $this->baseOrganizationId;
|
||||||
$new->created_at = date('Y-m-d H:i:s');
|
$new->created_at = date('Y-m-d H:i:s');
|
||||||
$new->created_by = Auth::id();
|
$new->created_by = Auth::id();
|
||||||
$new->record_status_id = RecordStatusEnum::ACTIVE;
|
$new->record_status_id = RecordStatusEnum::ACTIVE;
|
||||||
|
|||||||
245
app/Http/Controllers/OrganizationController.php
Normal file
245
app/Http/Controllers/OrganizationController.php
Normal file
@@ -0,0 +1,245 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
use App\Enums\RecordStatusEnum;
|
||||||
|
use App\Http\Controllers\Helper\GlobalController;
|
||||||
|
use App\Models\BaseModel;
|
||||||
|
use App\Models\SampleType;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Models\Organization;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use Illuminate\Support\Facades\Session;
|
||||||
|
|
||||||
|
|
||||||
|
class OrganizationController extends Controller
|
||||||
|
{
|
||||||
|
protected $model;
|
||||||
|
protected $baseOrganizationId;
|
||||||
|
protected $labs;
|
||||||
|
|
||||||
|
public function __construct(Organization $model){
|
||||||
|
$this->model = $model;
|
||||||
|
$this->baseOrganizationId = Session::get('base_organization_id');
|
||||||
|
$this->base = Session::get('base_organization');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function index(Request $request){
|
||||||
|
$recordStatusCondition = Auth::id()==1 ? [RecordStatusEnum::DELETE, RecordStatusEnum::ACTIVE] : [RecordStatusEnum::ACTIVE];
|
||||||
|
$labs = $this->model::query()->whereIn(BaseModel::RECORD_STATUS_FIELD, $recordStatusCondition)
|
||||||
|
->when(Auth::id()!=1, function ($labs){
|
||||||
|
$labs->whereIn('id', $this->labs->pluck('id'));
|
||||||
|
})->when(!empty($request->kword), function ($labs) use($request){
|
||||||
|
$labs->whereRaw("replace(name_en, ' ','') like '%".str_replace(" ","",$request->kword)."%'")
|
||||||
|
->orWhereRaw("replace(name_kh, ' ','') like '%".str_replace(" ","",$request->kword)."%'")
|
||||||
|
->orWhere('address_en','like','%'.$request->kword.'%')
|
||||||
|
->orWhere('address_kh','like','%'.$request->kword.'%');
|
||||||
|
})->orderBy(BaseModel::CREATED_AT,'desc')->paginate(config('labis.pagination.perpage', 10));
|
||||||
|
return view('laboratory', ['laboratories' => $labs]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function save(Request $request){
|
||||||
|
try {
|
||||||
|
|
||||||
|
$validator = \Validator::make($request->all(), [
|
||||||
|
'lab_name_en' => 'required',
|
||||||
|
'lab_code' => 'required|max:10',
|
||||||
|
'sample_number' => 'required',
|
||||||
|
'patient_code' => 'required',
|
||||||
|
'start_date' => 'required',
|
||||||
|
'end_date' => 'nullable'
|
||||||
|
]);
|
||||||
|
if ($validator->fails()) {
|
||||||
|
return response()->json(['success' => false, 'message' => __('laboratory.create_fail'), 'errors' => $validator->errors()->all()]);
|
||||||
|
}
|
||||||
|
$data = array(
|
||||||
|
'name_en' => $request->lab_name_en,
|
||||||
|
'name_kh' => $request->lab_name_kh,
|
||||||
|
'code' => $request->lab_code,
|
||||||
|
'phone_number' => $request->phone_number,
|
||||||
|
'email' => $request->email,
|
||||||
|
'address_en' => $request->address_en,
|
||||||
|
'address_kh' => $request->address_kh,
|
||||||
|
'created_at' => date('Y-m-d H:i:s'),
|
||||||
|
'created_by' => Auth::id()
|
||||||
|
);
|
||||||
|
$this->model::query()->insert($data);
|
||||||
|
return response()->json(['success' => true, 'message' => __('laboratory.create_success')]);
|
||||||
|
}
|
||||||
|
catch (\Exception $e){
|
||||||
|
return response()->json(['success' => false, 'message' => __('laboratory.create_fail'), 'errors' => $e->getMessage()]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updateInfo(Request $request){
|
||||||
|
try {
|
||||||
|
$validator = \Validator::make($request->all(), [
|
||||||
|
'name_en' => 'required',
|
||||||
|
'name_kh' => 'required',
|
||||||
|
'short_name' => 'required|max:10'
|
||||||
|
]);
|
||||||
|
if ($validator->fails()) return response()->json(['errors' => $validator->errors()->all()]);
|
||||||
|
$data = array(
|
||||||
|
'name_en' => $request->name_en,
|
||||||
|
'name_kh' => $request->name_kh,
|
||||||
|
'short_name' => $request->short_name,
|
||||||
|
'email' => $request->email,
|
||||||
|
'phone_number' => $request->phone_number,
|
||||||
|
'address_en' => $request->address_en,
|
||||||
|
'address_kh' => $request->address_kh,
|
||||||
|
'updated_at' => date('Y-m-d H:i:s'),
|
||||||
|
'updated_by' => Auth::id()
|
||||||
|
);
|
||||||
|
$this->model::query()->where('id', $this->baseOrganizationId)->update($data);
|
||||||
|
return redirect()->back();
|
||||||
|
//return response()->json(['success' => true, 'message' => __('laboratory.update_success')]);
|
||||||
|
} catch (\Exception $e){
|
||||||
|
dd($e);
|
||||||
|
//return redirect()->back();
|
||||||
|
return response()->json(['success' => false, 'message' => __('laboratory.update_fail'), 'errors' => $e->getMessage()]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(Request $request){
|
||||||
|
try {
|
||||||
|
|
||||||
|
$validator = \Validator::make($request->all(), [
|
||||||
|
'lab_name_en' => 'required',
|
||||||
|
'lab_code' => 'required|max:5',
|
||||||
|
'sample_number' => 'required',
|
||||||
|
'patient_code' => 'required',
|
||||||
|
'start_date' => 'required',
|
||||||
|
'end_date' => 'nullable'
|
||||||
|
]);
|
||||||
|
if ($validator->fails()) return response()->json(['errors' => $validator->errors()->all()]);
|
||||||
|
$data = array(
|
||||||
|
'name_en' => $request->lab_name_en,
|
||||||
|
'name_kh' => $request->lab_name_kh,
|
||||||
|
'short_name' => $request->lab_code,
|
||||||
|
'sample_number' => $request->sample_number,
|
||||||
|
'patient_code' => $request->patient_code,
|
||||||
|
'phone_number' => $request->phone_number,
|
||||||
|
'lab_category_id' => $request->lab_category_id,
|
||||||
|
'is_auto_make_invoice' => $request->is_auto_make_invoice,
|
||||||
|
'email' => $request->email,
|
||||||
|
'shareable_lab_result' => isset($request->shareable_lab_result) ? 1 : 0,
|
||||||
|
'allow_external_request' => isset($request->allow_external_request) ? 1 : 0,
|
||||||
|
'is_hide_comission_percentage' => isset($request->is_hide_comission_percentage) ? $request->is_hide_comission_percentage : 0,
|
||||||
|
'address_en' => $request->address_en,
|
||||||
|
'address_kh' => $request->address_kh,
|
||||||
|
'start_date' => ($request->start_date ? date('Y-m-d H:i:s', strtotime($request->start_date)) : null),
|
||||||
|
'end_date' => ($request->end_date ? date('Y-m-d H:i:s', strtotime($request->end_date)) : null),
|
||||||
|
'updated_at' => date('Y-m-d H:i:s'),
|
||||||
|
'updated_by' => Auth::id()
|
||||||
|
);
|
||||||
|
$this->model::query()->where('id', $request->organization_id)->update($data);
|
||||||
|
return response()->json(['success' => true, 'message' => __('laboratory.update_success')]);
|
||||||
|
} catch (\Exception $e){
|
||||||
|
return response()->json(['success' => false, 'message' => __('laboratory.update_fail'), 'errors' => $e->getMessage()]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get(Request $request){
|
||||||
|
try{
|
||||||
|
$organization_id = $request->organization_id;
|
||||||
|
$lab = $this->model::query()->where('id', $organization_id)->get()->first();
|
||||||
|
return response()->json(['success' => true, 'message' => __('laboratory.get_success'), 'data' => $lab]);
|
||||||
|
} catch (\Exception $e){
|
||||||
|
return response()->json(['success' => false, 'message' => __('laboratory.get_fail'), 'errors' => $e->getMessage()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function delete(Request $request){
|
||||||
|
try{
|
||||||
|
$this->model::query()->where('id', $request->organization_id)->update(array(BaseModel::RECORD_STATUS_FIELD=> RecordStatusEnum::DELETE));
|
||||||
|
return response()->json(['success' => true, 'message' => __('laboratory.delete_success')]);
|
||||||
|
}
|
||||||
|
catch (\Exception $e){
|
||||||
|
return response()->json(['success' => false, 'message' => __('laboratory.delete_fail'), 'errors' => $e->getMessage()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function restore(Request $request){
|
||||||
|
try{
|
||||||
|
$this->model::query()->where('id', $request->organization_id)->update(array(BaseModel::RECORD_STATUS_FIELD=> RecordStatusEnum::ACTIVE));
|
||||||
|
return response()->json(['success' => true, 'message' => __('laboratory.restore_success')]);
|
||||||
|
}
|
||||||
|
catch (\Exception $e){
|
||||||
|
return response()->json(['success' => false, 'message' => __('laboratory.restore_fail'), 'errors' => $e->getMessage()]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function profile(){
|
||||||
|
if(!GlobalController::user_can(Auth::user()->role_id, ['update_laboratory_information'])) return redirect(url('my-profile'));
|
||||||
|
$organization = $this->model::query()->find($this->baseOrganizationId);
|
||||||
|
return view('organization_profile', ['info' => $organization]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function labSettingSetters(Request $request){
|
||||||
|
try{
|
||||||
|
if(!GlobalController::user_can(Auth::user()->role_id, ['system_settings'])) return redirect(url('my-profile'));
|
||||||
|
$validator = \Validator::make($request->all(), [
|
||||||
|
'sample_number' => 'required|integer',
|
||||||
|
'patient_code' => 'required|integer',
|
||||||
|
'technician_label' => 'nullable',
|
||||||
|
'discount_type' => 'required|integer'
|
||||||
|
]);
|
||||||
|
if ($validator->fails()){ return response()->json(['errors'=>$validator->errors()->all()]);}
|
||||||
|
$lab = $this->model::query()->where('id', $this->baseOrganizationId)->first();
|
||||||
|
$lab->update(array(
|
||||||
|
'sample_number' => $request->sample_number,
|
||||||
|
'currency' => $request->currency,
|
||||||
|
'patient_code' => $request->patient_code,
|
||||||
|
'technician_label' => $request->technician_label,
|
||||||
|
'discount_type' => $request->discount_type,
|
||||||
|
'phone_number' => $request->phone_number,
|
||||||
|
'email' => $request->email,
|
||||||
|
'exchange_rate' => $request->exchange_rate,
|
||||||
|
//'is_hide_inv_discount' => $request->is_hide_inv_discount,
|
||||||
|
'abnormal_text_color' => $request->abnormal_text_color,
|
||||||
|
'show_result_footer' => $request->show_result_footer,
|
||||||
|
'abnormal_result_font_weight' => $request->abnormal_result_font_weight,
|
||||||
|
'result_header_id' => $request->result_header_id,
|
||||||
|
'is_auto_make_invoice' => $request->is_auto_make_invoice,
|
||||||
|
'invoice_template_id' => $request->invoice_template_id
|
||||||
|
));
|
||||||
|
return response()->json(['success' => true, 'message' => __('laboratory.update_success'), 'data' => $lab]);
|
||||||
|
} catch (\Exception $e)
|
||||||
|
{
|
||||||
|
return response()->json(['success'=> false , 'message' => __('laboratory.update_fail'), 'errors' => $e->getMessage()]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function uploadImage(Request $request){
|
||||||
|
try {
|
||||||
|
$image = $request->file('image');
|
||||||
|
$imageName = 'avatar_'.$this->baseOrganizationId.'.' . $image->getClientOriginalExtension();
|
||||||
|
$lab = $this->model::query()->where('id', $this->baseOrganizationId)->first();
|
||||||
|
$lab->update(array('logo' => $imageName));
|
||||||
|
$image->move(public_path('storage/images/avatars/labs'), $imageName);
|
||||||
|
return response()->json(['success' => true, 'message' => __('laboratory.update_success'), 'data' => $lab]);
|
||||||
|
}catch (\Exception $e){
|
||||||
|
return response()->json(['success'=> false , 'message' => __('laboratory.update_fail'), 'errors' => $e->getMessage()]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function removeLabLogo(Request $request){
|
||||||
|
try {
|
||||||
|
$lab = $this->model::query()->find($this->baseOrganizationId);
|
||||||
|
if(!empty($lab->logo)) {
|
||||||
|
if (file_exists(public_path('storage/images/avatars/labs/' . $lab->logo))) {
|
||||||
|
unlink(public_path('storage/images/avatars/labs/' . $lab->logo));
|
||||||
|
$lab->logo = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$lab->save();
|
||||||
|
return response()->json(['success' => true, 'message' => __('laboratory.update_success'), 'data' => $lab]);
|
||||||
|
}catch (\Exception $e){
|
||||||
|
return response()->json(['success'=> false , 'message' => __('laboratory.update_fail'), 'errors' => $e->getMessage()]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,239 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
|
||||||
use App\Enums\RecordStatusEnum;
|
|
||||||
use App\Helpers\Helpers;
|
|
||||||
use App\Http\Controllers\Helper\GlobalController;
|
|
||||||
use App\Http\Requests\PatientCreateRequest;
|
|
||||||
use App\Http\Requests\PatientUpdateRequest;
|
|
||||||
use App\Models\BaseModel;
|
|
||||||
use App\Models\Laboratory;
|
|
||||||
use App\Models\Patient;
|
|
||||||
use Illuminate\Support\Facades\Auth;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Illuminate\Support\Facades\Session;
|
|
||||||
|
|
||||||
class PatientController extends Controller
|
|
||||||
{
|
|
||||||
|
|
||||||
protected $model;
|
|
||||||
protected $baseLabId;
|
|
||||||
protected $base;
|
|
||||||
protected $departments;
|
|
||||||
|
|
||||||
public function __construct(Patient $patientModel){
|
|
||||||
$this->model = $patientModel;
|
|
||||||
$this->baseLabId = Session::get('base_lab_id');
|
|
||||||
$this->base = Session::get('base_lab');
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function province(){
|
|
||||||
return parent::province();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function index(Request $request){
|
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['view_patient'])) return redirect(url('my-profile'));
|
|
||||||
$provinces = $this->province();
|
|
||||||
$patients = $this->model::with(['samples'])->where(BaseModel::RECORD_STATUS_FIELD, RecordStatusEnum::ACTIVE)
|
|
||||||
->where('lab_id', $this->baseLabId)
|
|
||||||
->when(!empty(trim($request->kword)), function ($patients) use($request){
|
|
||||||
$patients->whereRaw(
|
|
||||||
"(replace(name_en, ' ', '') LIKE ? OR replace(phone_number, ' ', '') LIKE ? OR replace(patient_uuid, ' ', '') LIKE ? OR replace(khid_number, ' ', '') LIKE ?) and lab_id = ?",
|
|
||||||
[
|
|
||||||
'%' . str_replace(' ', '', $request->kword) . '%',
|
|
||||||
'%' . str_replace(' ', '', $request->kword) . '%',
|
|
||||||
'%' . str_replace(' ', '', $request->kword) . '%',
|
|
||||||
'%' . str_replace(' ', '', $request->kword) . '%',
|
|
||||||
$this->baseLabId
|
|
||||||
]
|
|
||||||
);
|
|
||||||
})->orderBy(BaseModel::CREATED_AT_FIELD,'desc')->paginate(config('labis.pagination.perpage', 10));
|
|
||||||
return view('patient', ['provinces' => $provinces, 'patients' => $patients, 'labSettings' => (object) $this->base]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function save(PatientCreateRequest $patientCreateRequest){
|
|
||||||
DB::beginTransaction();
|
|
||||||
try{
|
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['create_patient'])) return false;
|
|
||||||
$dob = $patientCreateRequest->dob;
|
|
||||||
$datePart = explode("-",$dob);
|
|
||||||
if($datePart[1]>12){
|
|
||||||
$dob = $datePart[1].'-'.$datePart[0].'-'.$datePart[2];
|
|
||||||
}
|
|
||||||
$requests = collect($patientCreateRequest)->merge([
|
|
||||||
'lab_id' => $this->baseLabId,
|
|
||||||
BaseModel::CREATED_AT_FIELD => date('Y-m-d H:i:s'),
|
|
||||||
BaseModel::CREATED_BY_FIELD => Auth::id(),
|
|
||||||
BaseModel::UPDATED_AT_FIELD => NULL,
|
|
||||||
BaseModel::UPDATED_BY_FIELD => NULL,
|
|
||||||
BaseModel::RECORD_STATUS_FIELD => BaseModel::RECORD_STATUS_ACTIVE
|
|
||||||
])->replace(
|
|
||||||
[
|
|
||||||
'dob' => date('Y-m-d', strtotime($dob)),
|
|
||||||
'phone_number' => $patientCreateRequest->phone_number // preg_replace('/ /i', '', trim($patientCreateRequest->phone_number))
|
|
||||||
]);
|
|
||||||
|
|
||||||
if(empty($patientCreateRequest->patient_uuid)) {
|
|
||||||
$patientNumber = $this->generateAutoId(date('Y-m-d'));
|
|
||||||
$requests = $requests->merge(['patient_uuid' => $patientNumber]);
|
|
||||||
}
|
|
||||||
|
|
||||||
$patient = $this->model::query()->create($requests->all());
|
|
||||||
DB::commit();
|
|
||||||
return response()->json(['success'=> true , 'message' => __('patient.create_success') , 'data' => $patient]);
|
|
||||||
} catch (\Exception $e){
|
|
||||||
DB::rollBack();
|
|
||||||
Log::error($e);
|
|
||||||
return response()->json(['success'=> false , 'message' => __('patient.create_fail') , 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function update(PatientUpdateRequest $patientUpdateRequest){
|
|
||||||
DB::beginTransaction();
|
|
||||||
try{
|
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['update_patient'])) return false;
|
|
||||||
$dob = $patientUpdateRequest->dob;
|
|
||||||
$datePart = explode("-",$dob);
|
|
||||||
if($datePart[1]>12){
|
|
||||||
$dob = $datePart[1].'-'.$datePart[0].'-'.$datePart[2];
|
|
||||||
}
|
|
||||||
|
|
||||||
$requests = collect($patientUpdateRequest)->merge([
|
|
||||||
BaseModel::UPDATED_AT_FIELD => date('Y-m-d H:i:s'),
|
|
||||||
BaseModel::UPDATED_BY_FIELD => Auth::id()
|
|
||||||
])->replace([
|
|
||||||
'dob' => date('Y-m-d', strtotime($dob)),
|
|
||||||
'phone_number' => $patientUpdateRequest->phone_number // preg_replace('/ /i', '', trim($patientUpdateRequest->phone_number))
|
|
||||||
])->except(['patient_uuid','uid']);
|
|
||||||
$patient = $this->model::query()->find($patientUpdateRequest->uid)->update($requests->all());
|
|
||||||
DB::commit();
|
|
||||||
return response()->json(['success'=> true , 'message' => __('patient.update_success'), 'data' => array('id' => $patientUpdateRequest->uid) ]);
|
|
||||||
} catch (\Exception $e){
|
|
||||||
DB::rollBack();
|
|
||||||
Log::error($e);
|
|
||||||
return response()->json(['success'=> false , 'message' => __('patient.update_fail'), 'errors' => [$e->getMessage()]]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function get(Request $request){
|
|
||||||
try{
|
|
||||||
$patient = $this->model::query()->find($request->uid);
|
|
||||||
return response()->json(['success'=> true , 'message' => __('patient.get_success') , 'data' => $patient]);
|
|
||||||
}
|
|
||||||
catch (\Exception $e){
|
|
||||||
return response()->json(['success'=> false , __('patient.get_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function delete(Request $request){
|
|
||||||
try{
|
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['delete_patient'])) return false;
|
|
||||||
$patient = $this->model::query()->find($request->uid);
|
|
||||||
$patient->update(array(BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::DELETE));
|
|
||||||
return response()->json(['success'=> true, 'message' => __('patient.delete_success'), 'data' => $patient]);
|
|
||||||
}
|
|
||||||
catch (\Exception $e){
|
|
||||||
return response()->json(['success'=> false, 'message' => __('patient.delete_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function restore(Request $request){
|
|
||||||
try{
|
|
||||||
$patient = $this->model::query()->find($request->uid);
|
|
||||||
$patient->update(array(BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE));
|
|
||||||
return response()->json(['success'=> true, 'message' => __('patient.restore_success'), 'data' => $patient]);
|
|
||||||
}
|
|
||||||
catch (\Exception $e){
|
|
||||||
return response()->json(['success'=> false, 'message' => __('patient.restore_success'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function search(Request $request)
|
|
||||||
{
|
|
||||||
try{
|
|
||||||
$patients = $this->model::query()->where([BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE, 'lab_id' => $this->baseLabId])
|
|
||||||
->when($request->kword!='', function($patients) use ($request) {
|
|
||||||
$patients->whereRaw(
|
|
||||||
"(replace(name_en, ' ', '') LIKE ? OR replace(phone_number, ' ', '') LIKE ? OR replace(patient_uuid, ' ', '') LIKE ? OR replace(khid_number, ' ', '') LIKE ?) and lab_id = ?",
|
|
||||||
[
|
|
||||||
'%' . str_replace(' ', '', $request->kword) . '%',
|
|
||||||
'%' . str_replace(' ', '', $request->kword) . '%',
|
|
||||||
'%' . str_replace(' ', '', $request->kword) . '%',
|
|
||||||
'%' . str_replace(' ', '', $request->kword) . '%',
|
|
||||||
$this->baseLabId
|
|
||||||
]
|
|
||||||
);
|
|
||||||
})->orderBy('name_en','asc')->limit(config('labis.pagination.perpage', 10))->get();
|
|
||||||
return response()->json(['success'=> true, __('patient.get_success'), 'data' => $patients]);
|
|
||||||
}
|
|
||||||
catch (\Exception $e){
|
|
||||||
return response()->json(['success'=> false, __('patient.get_fail'), 'errors' => [$e->getMessage()]]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function patientSearchAjax(Request $request)
|
|
||||||
{
|
|
||||||
try{
|
|
||||||
$provinces = $this->province();
|
|
||||||
$patients = $this->model::query()->where([BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE, 'lab_id' => $this->baseLabId])
|
|
||||||
->when($request->kword!='', function($patients) use ($request) {
|
|
||||||
$patients->whereRaw(
|
|
||||||
"(replace(name_en, ' ', '') LIKE ? OR replace(phone_number, ' ', '') LIKE ? OR replace(patient_uuid, ' ', '') LIKE ? OR replace(khid_number, ' ', '') LIKE ?) and lab_id = ?",
|
|
||||||
[
|
|
||||||
'%' . str_replace(' ', '', $request->kword) . '%',
|
|
||||||
'%' . str_replace(' ', '', $request->kword) . '%',
|
|
||||||
'%' . str_replace(' ', '', $request->kword) . '%',
|
|
||||||
'%' . str_replace(' ', '', $request->kword) . '%',
|
|
||||||
$this->baseLabId
|
|
||||||
]
|
|
||||||
);
|
|
||||||
})->orderBy('name_en','asc')->paginate(config('labis.pagination.perpage', 10));
|
|
||||||
return view('partials.patient_list', ['provinces' => $provinces, 'patients' => $patients, 'labSettings' => (object) $this->base]);
|
|
||||||
}
|
|
||||||
catch (\Exception $e){
|
|
||||||
return response()->json(['success'=> false, __('patient.get_fail'), 'errors' => [$e->getMessage()]]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function generateAutoId($admissionDate){
|
|
||||||
$prefix = date('y',strtotime($admissionDate));
|
|
||||||
$patientCount = $this->model::query()->where('lab_id', $this->baseLabId)->whereRaw('year(created_at) ="'. date('Y',strtotime($admissionDate)).'"')->count();
|
|
||||||
if($this->baseLabId==34) $patientCount = $patientCount+5; // solve problem when delete patient
|
|
||||||
return 'P-'.$this->base['short_name'].'-'.$prefix.'-'.(str_pad(($patientCount+1),5,'0',STR_PAD_LEFT));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public function searchPatientToSelect2(Request $request){
|
|
||||||
$patients = [];
|
|
||||||
if(!empty(trim($request->term))){
|
|
||||||
$patients = $this->model::query()
|
|
||||||
->where([BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE, 'lab_id' => $this->baseLabId])
|
|
||||||
->when(!empty(trim($request->term)), function ($patients) use($request){
|
|
||||||
$patients->whereRaw(
|
|
||||||
"(replace(name_en, ' ', '') LIKE ? OR replace(phone_number, ' ', '') LIKE ? OR replace(patient_uuid, ' ', '') LIKE ? OR replace(khid_number, ' ', '') LIKE ?) and lab_id = ?",
|
|
||||||
[
|
|
||||||
'%' . str_replace(' ', '', $request->term) . '%',
|
|
||||||
'%' . str_replace(' ', '', $request->term) . '%',
|
|
||||||
'%' . str_replace(' ', '', $request->term) . '%',
|
|
||||||
'%' . str_replace(' ', '', $request->term) . '%',
|
|
||||||
$this->baseLabId
|
|
||||||
]
|
|
||||||
);
|
|
||||||
})->limit(20)->orderBy('name_en', 'asc')->get();
|
|
||||||
}
|
|
||||||
$items = [];
|
|
||||||
if(!empty($patients)){
|
|
||||||
$items = $patients->map(function ($item){
|
|
||||||
return array('id'=>$item->id, 'text' => $item->patient_uuid . ' - '.$item->name_en . ((!empty($item->phone_number) ? ' - '.$item->phone_number: '')));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return response()->json(['results' => $items]);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,115 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
|
||||||
use App\Enums\RecordStatusEnum;
|
|
||||||
use App\Http\Controllers\Helper\GlobalController;
|
|
||||||
use App\Http\Requests\PatientTypeCreateRequest;
|
|
||||||
use App\Models\BaseModel;
|
|
||||||
use App\Models\PatientType;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Illuminate\Support\Facades\Auth;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
use Illuminate\Support\Facades\Session;
|
|
||||||
|
|
||||||
class PatientTypeController extends Controller
|
|
||||||
{
|
|
||||||
|
|
||||||
protected $model;
|
|
||||||
protected $baseLabId;
|
|
||||||
protected $labs;
|
|
||||||
|
|
||||||
public function __construct(PatientType $patientType){
|
|
||||||
$this->model = $patientType;
|
|
||||||
$this->baseLabId = Session::get('base_lab_id');
|
|
||||||
$this->base = Session::get('base_lab');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function index(Request $request){
|
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['view_patient_type'])) return redirect(url('my-profile'));
|
|
||||||
$standardPatientTypes = $this->model::query()->where([BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE, 'is_standard' => 1])->get(['id','name_en'])->unique('name_en');
|
|
||||||
$patientTypes = $this->model::query()->where(BaseModel::RECORD_STATUS_FIELD, RecordStatusEnum::ACTIVE)
|
|
||||||
//->where('lab_id', $this->baseLabId)
|
|
||||||
->when(!empty($request->kword), function ($patientTypes) use ($request){
|
|
||||||
$patientTypes->whereRaw("replace(name_en, ' ','') like '%".str_replace(" ","",$request->kword)."%'");
|
|
||||||
})->orderBy(BaseModel::CREATED_AT_FIELD,'desc')->paginate(config('labis.pagination.perpage', 10));
|
|
||||||
return view('patient-type', ['patientTypes' => $patientTypes, 'standardPatientTypes' => $standardPatientTypes]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function save(PatientTypeCreateRequest $request){
|
|
||||||
DB::beginTransaction();
|
|
||||||
try{
|
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['create_patient_type'])) return false;
|
|
||||||
$new = $this->model::query()->firstOrNew(['name_en' => $request->name_en, 'gender' => $request->gender]);
|
|
||||||
$new->name_en = $request->name_en;
|
|
||||||
$new->gender = $request->gender;
|
|
||||||
$new->range_start = $request->age_from;
|
|
||||||
$new->range_start_unit = $request->age_from_unit;
|
|
||||||
$new->range_start_sign = $request->age_from_sign;
|
|
||||||
$new->range_end = $request->age_to;
|
|
||||||
$new->range_end_unit = $request->age_to_unit;
|
|
||||||
$new->range_end_sign = $request->age_to_sign;
|
|
||||||
//$new->lab_id = $this->baseLabId;
|
|
||||||
$new->save();
|
|
||||||
DB::commit();
|
|
||||||
return response()->json(['success' => true, 'message' => __('patient_type.create_success')]);
|
|
||||||
} catch (\Exception $e){
|
|
||||||
DB::rollBack();
|
|
||||||
return response()->json(['success' => false, 'message' => __('patient_type.create_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function update(PatientTypeCreateRequest $request){
|
|
||||||
try{
|
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['update_patient_type'])) return false;
|
|
||||||
$data = array(
|
|
||||||
'name_en' => $request->name_en,
|
|
||||||
'range_start' => $request->age_from,
|
|
||||||
'range_start_unit' => $request->age_from_unit,
|
|
||||||
'gender' => $request->gender,
|
|
||||||
'range_end' => $request->age_to,
|
|
||||||
'range_end_unit' => $request->age_to_unit,
|
|
||||||
//'lab_id' => $this->baseLabId,
|
|
||||||
'updated_at' => date('Y-m-d H:i:s'),
|
|
||||||
'updated_by' => Auth::id()
|
|
||||||
);
|
|
||||||
$this->model::query()->where('id', $request->uid)->update($data);
|
|
||||||
DB::commit();
|
|
||||||
return response()->json(['success' => true, 'message' => __('patient_type.update_success')]);
|
|
||||||
} catch (\Exception $e){
|
|
||||||
DB::rollBack();
|
|
||||||
return response()->json(['success' => false, 'message' => __('patient_type.update_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function get(Request $request){
|
|
||||||
try{
|
|
||||||
$patientType = $this->model::query()->find($request->uid);
|
|
||||||
return response()->json(['success' => true, 'message' => __('patient_type.get_success'), 'data' => $patientType]);
|
|
||||||
} catch (\Exception $e){
|
|
||||||
return response()->json(['success' => false, 'message' => __('patient_type.get_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function delete(Request $request){
|
|
||||||
try{
|
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['delete_patient_type'])) return false;
|
|
||||||
$this->model::query()->where('id', $request->uid)->update(array( BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::DELETE));
|
|
||||||
return response()->json(['success' => true, 'message' => __('patient_type.delete_success')]);
|
|
||||||
} catch (\Exception $e){
|
|
||||||
return response()->json(['success' => false, 'message' => __('patient_type.delete_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function restore(Request $request){
|
|
||||||
try{
|
|
||||||
$this->model::query()->where('id', $request->uid)->update(array( BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE));
|
|
||||||
return response()->json(['success' => true, 'message' => __('patient_type.restore_success')]);
|
|
||||||
} catch (\Exception $e){
|
|
||||||
return response()->json(['success' => false, 'message' => __('patient_type.restore_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,170 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
|
||||||
use App\Enums\RecordStatusEnum;;
|
|
||||||
|
|
||||||
use App\Http\Controllers\Helper\GlobalController;
|
|
||||||
use App\Models\BaseModel;
|
|
||||||
use App\Models\Physician;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Illuminate\Support\Facades\Auth;
|
|
||||||
use Illuminate\Support\Facades\Session;
|
|
||||||
|
|
||||||
class PhysicianController extends Controller
|
|
||||||
{
|
|
||||||
|
|
||||||
protected $baseLabId;
|
|
||||||
protected $labs;
|
|
||||||
private $physician;
|
|
||||||
|
|
||||||
public function __construct(Physician $physician){
|
|
||||||
$this->physician = $physician;
|
|
||||||
$this->baseLabId = Session::get('base_lab_id');
|
|
||||||
$this->base = Session::get('base_lab');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function index(Request $request){
|
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['view_physician'])) return redirect(url('my-profile'));
|
|
||||||
$physicians = $this->physician::with(['lab'])->where('record_status_id', RecordStatusEnum::ACTIVE)
|
|
||||||
->where('lab_id', Session::get('base_lab_id'))
|
|
||||||
->when(!empty($request->kword), function ($physicians) use ($request){
|
|
||||||
$physicians->whereRaw("replace(name_en, ' ','') like '%".str_replace(" ","",$request->kword)."%'");
|
|
||||||
})
|
|
||||||
->orderBy(BaseModel::CREATED_AT,'desc')->paginate(config('labis.pagination.perpage', 10));
|
|
||||||
return view('physician', ['physicians' => $physicians, 'labs' => parent::getAccessAbleLabs()]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function save(Request $request){
|
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['create_physician'])) return redirect(url('my-profile'));
|
|
||||||
$validator = \Validator::make($request->all(), ['name_en' => 'required']);
|
|
||||||
if ($validator->fails()) return response()->json(['errors'=>$validator->errors()->all()]);
|
|
||||||
$imageName = NULL;
|
|
||||||
$footerName = NULL;
|
|
||||||
if($request->image)
|
|
||||||
{
|
|
||||||
request()->validate(['image' => 'image|mimes:jpeg,png,jpg,gif,svg|max:2048']);
|
|
||||||
$imageName = time().'.'.request()->image->getClientOriginalExtension();
|
|
||||||
request()->image->move(public_path('storage/images/physician'), $imageName);
|
|
||||||
}
|
|
||||||
if($request->imageFooter)
|
|
||||||
{
|
|
||||||
request()->validate(['imageFooter' => 'image|mimes:jpeg,png,jpg,gif,svg|max:2048']);
|
|
||||||
$footerName = time().'_footer.'.request()->imageFooter->getClientOriginalExtension();
|
|
||||||
request()->imageFooter->move(public_path('storage/images/physician'), $footerName);
|
|
||||||
}
|
|
||||||
|
|
||||||
$new = $this->physician::query()->firstOrNew(['name_en' => $request->name_en, 'lab_id' => $this->baseLabId]);
|
|
||||||
$new->name_en = $request->name_en;
|
|
||||||
$new->phone = $request->phone;
|
|
||||||
$new->lab_id = $this->baseLabId;
|
|
||||||
$new->logo = $imageName;
|
|
||||||
$new->footer = $footerName;
|
|
||||||
$new->is_default = isset($request->is_default) ? 1 : 0;
|
|
||||||
$new->created_at = date('Y-m-d H:i:s');
|
|
||||||
$new->created_by = Auth::user()->id;
|
|
||||||
$new->record_status_id = RecordStatusEnum::ACTIVE;
|
|
||||||
$new->save();
|
|
||||||
|
|
||||||
$request->session()->flash('msg','Physician has been inserted!');
|
|
||||||
return redirect()->back();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function update(Request $request){
|
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['update_physician'])) return redirect(url('my-profile'));
|
|
||||||
$validator = \Validator::make($request->all(), [
|
|
||||||
'name_en' => 'required'
|
|
||||||
]);
|
|
||||||
if ($validator->fails()) return response()->json(['errors'=>$validator->errors()->all()]);
|
|
||||||
$imageName = NULL;
|
|
||||||
$footerName = NULL;
|
|
||||||
if($request->image)
|
|
||||||
{
|
|
||||||
request()->validate(['image' => 'image|mimes:jpeg,png,jpg,gif,svg|max:2048']);
|
|
||||||
$imageName = time().'.'.request()->image->getClientOriginalExtension();
|
|
||||||
request()->image->move(public_path('storage/images/physician'), $imageName);
|
|
||||||
}
|
|
||||||
if($request->imageFooter)
|
|
||||||
{
|
|
||||||
request()->validate(['imageFooter' => 'image|mimes:jpeg,png,jpg,gif,svg|max:2048']);
|
|
||||||
$footerName = time().'_footer.'.request()->imageFooter->getClientOriginalExtension();
|
|
||||||
request()->imageFooter->move(public_path('storage/images/physician'), $footerName);
|
|
||||||
}
|
|
||||||
$data = array(
|
|
||||||
'name_en' => $request->name_en,
|
|
||||||
'name_kh' => $request->name_kh,
|
|
||||||
'phone' => $request->phone,
|
|
||||||
'is_default' => isset($request->is_default) ? 1: 0,
|
|
||||||
'updated_at' => date('Y-m-d H:i:s'),
|
|
||||||
'updated_by' => Auth::id()
|
|
||||||
);
|
|
||||||
if(!empty($imageName)){$data = array_merge($data, ['logo' => $imageName]);}
|
|
||||||
if(!empty($footerName)){$data = array_merge($data, ['footer' => $footerName]);}
|
|
||||||
$status = $this->physician::query()->where('id', $request->uid)->update($data);
|
|
||||||
$request->session()->flash('msg','Physician has been updated!');
|
|
||||||
return redirect()->back();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function deletePhysicianLogo(Request $request){
|
|
||||||
try{
|
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['update_physician'])) return false;
|
|
||||||
$physician = $this->physician::query()->find($request->uid);
|
|
||||||
if(file_exists(public_path('storage/images/physician/'.$physician->logo))){
|
|
||||||
unlink(public_path('storage/images/physician/'.$physician->logo));
|
|
||||||
$physician->logo = null;
|
|
||||||
}
|
|
||||||
$physician->save();
|
|
||||||
return response()->json(['success'=> true , 'message' => __('physician.delete_photo_success')]);
|
|
||||||
}
|
|
||||||
catch (\Exception $e){
|
|
||||||
return response()->json(['success'=> false , 'message' => __('physician.delete_photo_failed')]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function deletePhysicianFooter(Request $request){
|
|
||||||
try{
|
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['update_physician'])) return false;
|
|
||||||
$physician = $this->physician::query()->find($request->uid);
|
|
||||||
if(file_exists(public_path('storage/images/physician/'.$physician->footer))){
|
|
||||||
unlink(public_path('storage/images/physician/'.$physician->footer));
|
|
||||||
$physician->footer = null;
|
|
||||||
}
|
|
||||||
$physician->save();
|
|
||||||
return response()->json(['success'=> true , 'message' => __('physician.delete_photo_success')]);
|
|
||||||
}
|
|
||||||
catch (\Exception $e){
|
|
||||||
return response()->json(['success'=> false , 'message' => __('physician.delete_photo_failed')]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function get(Request $request){
|
|
||||||
try {
|
|
||||||
$physician = $this->physician::query()->find($request->uid);
|
|
||||||
return response()->json(['success'=> true , 'message' => __('physician.get_success'), 'data' => $physician]);
|
|
||||||
} catch (\Exception $e){
|
|
||||||
return response()->json(['success'=> false , 'message' => __('physician.get_fail')]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function delete(Request $request){
|
|
||||||
try{
|
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['delete_physician'])) return false;
|
|
||||||
$this->physician::query()->where('id', $request->uid)->update(array( BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::DELETE));
|
|
||||||
return response()->json(['success'=> true , 'message' => __('physician.delete_success')]);
|
|
||||||
}
|
|
||||||
catch (\Exception $e){
|
|
||||||
return response()->json(['success'=> false , 'message' => __('physician.delete_fail')]);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function restore(Request $request){
|
|
||||||
try {
|
|
||||||
$this->physician::query()->where('id', $request->uid)->update(array(BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE));
|
|
||||||
return response()->json(['success' => true, 'message' => __('physician.restore_success')]);
|
|
||||||
} catch (\Exception $e){
|
|
||||||
return response()->json(['success' => false, 'message' => __('physician.restore_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -20,8 +20,8 @@ class PublicationController extends Controller
|
|||||||
public function __construct(Publication $publication){
|
public function __construct(Publication $publication){
|
||||||
$this->model = $publication;
|
$this->model = $publication;
|
||||||
$this->publicationReceiverModel = new PublicationReceiver();
|
$this->publicationReceiverModel = new PublicationReceiver();
|
||||||
$this->baseLabId = Session::get('base_lab_id');
|
$this->baseOrganizationId = Session::get('base_organization_id');
|
||||||
$this->base = Session::get('base_lab');
|
$this->base = Session::get('base_organization');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function index(Request $request){
|
public function index(Request $request){
|
||||||
@@ -35,7 +35,7 @@ class PublicationController extends Controller
|
|||||||
|
|
||||||
public function save(Request $request){
|
public function save(Request $request){
|
||||||
try{
|
try{
|
||||||
$validator = \Validator::make($request->all(), ['start_date' => 'required', 'title_en' => 'required','lab_ids' => 'required']);
|
$validator = \Validator::make($request->all(), ['start_date' => 'required', 'title_en' => 'required','organization_ids' => 'required']);
|
||||||
if ($validator->fails()) return response()->json(['success' => false, 'message' => __('comment.create_fail'), 'errors' => $validator->errors()->all()]);
|
if ($validator->fails()) return response()->json(['success' => false, 'message' => __('comment.create_fail'), 'errors' => $validator->errors()->all()]);
|
||||||
|
|
||||||
$publication = $this->model::query()->create([
|
$publication = $this->model::query()->create([
|
||||||
@@ -46,10 +46,10 @@ class PublicationController extends Controller
|
|||||||
'description' => $request->description
|
'description' => $request->description
|
||||||
]);
|
]);
|
||||||
|
|
||||||
foreach ($request->lab_ids as $lab_id){
|
foreach ($request->organization_ids as $organization_id){
|
||||||
$this->publicationReceiverModel::query()->create([
|
$this->publicationReceiverModel::query()->create([
|
||||||
'publication_id' => $publication->id,
|
'publication_id' => $publication->id,
|
||||||
'lab_id' => $lab_id,
|
'organization_id' => $organization_id,
|
||||||
'created_by' => Auth::id()
|
'created_by' => Auth::id()
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@@ -62,7 +62,7 @@ class PublicationController extends Controller
|
|||||||
|
|
||||||
public function update(Request $request){
|
public function update(Request $request){
|
||||||
try {
|
try {
|
||||||
$validator = \Validator::make($request->all(), ['start_date' => 'required', 'title_en' => 'required', 'lab_ids' => 'required']);
|
$validator = \Validator::make($request->all(), ['start_date' => 'required', 'title_en' => 'required', 'organization_ids' => 'required']);
|
||||||
if ($validator->fails()) return response()->json(['success' => false, 'message' => __('comment.update_fail'), 'errors' => $validator->errors()->all()]);
|
if ($validator->fails()) return response()->json(['success' => false, 'message' => __('comment.update_fail'), 'errors' => $validator->errors()->all()]);
|
||||||
$data = array(
|
$data = array(
|
||||||
'title_en' => $request->title_en,
|
'title_en' => $request->title_en,
|
||||||
@@ -73,10 +73,10 @@ class PublicationController extends Controller
|
|||||||
);
|
);
|
||||||
$this->model::query()->where('id', $request->uid)->update($data);
|
$this->model::query()->where('id', $request->uid)->update($data);
|
||||||
$this->publicationReceiverModel::query()->where('publication_id', $request->uid)->delete();
|
$this->publicationReceiverModel::query()->where('publication_id', $request->uid)->delete();
|
||||||
foreach ($request->lab_ids as $lab_id){
|
foreach ($request->organization_ids as $organization_id){
|
||||||
$this->publicationReceiverModel::query()->create([
|
$this->publicationReceiverModel::query()->create([
|
||||||
'publication_id' => $request->uid,
|
'publication_id' => $request->uid,
|
||||||
'lab_id' => $lab_id,
|
'organization_id' => $organization_id,
|
||||||
'created_by' => Auth::id()
|
'created_by' => Auth::id()
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,100 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
|
||||||
use App\Enums\RecordStatusEnum;
|
|
||||||
use App\Http\Controllers\Helper\GlobalController;
|
|
||||||
use App\Http\Requests\TestSampleCreateRequest;
|
|
||||||
use App\Models\BaseModel;
|
|
||||||
use App\Models\Organism;
|
|
||||||
use App\Models\PatientType;
|
|
||||||
use App\Models\Quantity;
|
|
||||||
use App\Models\SampleType;
|
|
||||||
use App\Models\Test;
|
|
||||||
use App\Models\TestNormalValue;
|
|
||||||
use App\Models\TestSample;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Illuminate\Support\Facades\Auth;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
use Illuminate\Support\Facades\Session;
|
|
||||||
|
|
||||||
class QuantityController extends Controller
|
|
||||||
{
|
|
||||||
|
|
||||||
protected $model;
|
|
||||||
protected $baseLabId;
|
|
||||||
protected $labs;
|
|
||||||
protected $departments;
|
|
||||||
|
|
||||||
public function __construct(Quantity $quantity){
|
|
||||||
$this->model = $quantity;
|
|
||||||
$this->baseLabId = Session::get('base_lab_id');
|
|
||||||
$this->base = Session::get('base_lab');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function index(Request $request){
|
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['view_quantity'])) return redirect(url('my-profile'));
|
|
||||||
$quantities = $this->model::with(['lab'])->where(BaseModel::RECORD_STATUS_FIELD, RecordStatusEnum::ACTIVE)
|
|
||||||
->where('lab_id', $this->baseLabId)
|
|
||||||
->when(!empty($request->kword), function ($quantities) use($request){
|
|
||||||
$quantities->whereRaw("replace(quantity_name, ' ','') like '%".str_replace(" ","",$request->kword)."%'");
|
|
||||||
})->orderBy(BaseModel::CREATED_AT_FIELD,'desc')->paginate(config('labis.pagination.perpage', 10));
|
|
||||||
return view('quantity', ['quantities' => $quantities]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function save(Request $request){
|
|
||||||
try{
|
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['create_quantity'])) return false;
|
|
||||||
$validator = \Validator::make($request->all(), ['quantity_name' => 'required']);
|
|
||||||
if ($validator->fails()) return response()->json(['success' => false, 'message' => __('organism.create_fail'), 'errors' =>$validator->errors()->all()]);
|
|
||||||
$new = $this->model::query()->firstOrNew(['quantity_name' => $request->quantity_name]);
|
|
||||||
$new->quantity_name = $request->quantity_name;
|
|
||||||
//$new->lab_id = $this->baseLabId;
|
|
||||||
$new->save();
|
|
||||||
return response()->json(['success' => true, 'message' => __('quantity.create_success'), 'data' => [$new]]);
|
|
||||||
} catch (\Exception $e){
|
|
||||||
return response()->json(['success' => false, 'message' => __('quantity.create_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function update(Request $request){
|
|
||||||
try{
|
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['update_quantity'])) return false;
|
|
||||||
$validator = \Validator::make($request->all(), ['quantity_name' => 'required']);
|
|
||||||
if ($validator->fails()) return response()->json(['success' => false, 'message' => __('organism.update_fail'), 'errors' => $validator->errors()->all()]);
|
|
||||||
$this->model::query()->where('id', $request->uid)->update(array('quantity_name' => $request->quantity_name));
|
|
||||||
return response()->json(['success' => true, 'message' => __('quantity.update_success')]);
|
|
||||||
} catch (\Exception $e){
|
|
||||||
return response()->json(['success' => false, 'message' => __('quantity.update_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function get(Request $request){
|
|
||||||
try{
|
|
||||||
$quantity = $this->model::query()->find($request->uid);
|
|
||||||
return response()->json(['success' => true, 'message' => __('quantity.get_success'), 'data' => $quantity]);
|
|
||||||
} catch (\Exception $e){
|
|
||||||
return response()->json(['success' => false, 'message' => __('quantity.get_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function delete(Request $request){
|
|
||||||
try{
|
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['delete_quantity'])) return false;
|
|
||||||
$this->model::query()->where('id', $request->uid)->update(array(BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::DELETE));
|
|
||||||
return response()->json(['success' => true, 'message' => __('quantity.delete_success')]);
|
|
||||||
} catch (\Exception $e){
|
|
||||||
return response()->json(['success' => false, 'message' => __('quantity.delete_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function restore(Request $request){
|
|
||||||
try{
|
|
||||||
$this->model::query()->where('id', $request->uid)->update(array(BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE));
|
|
||||||
return response()->json(['success' => true, 'message' => __('quantity.restore_success')]);
|
|
||||||
} catch (\Exception $e){
|
|
||||||
return response()->json(['success' => false, 'message' => __('quantity.restore_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,165 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
|
||||||
use App\Enums\RecordStatusEnum;
|
|
||||||
use App\Http\Controllers\Helper\GlobalController;
|
|
||||||
use App\Models\BaseModel;
|
|
||||||
use App\Models\Invoice;
|
|
||||||
use App\Models\Repayment;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Illuminate\Support\Facades\Auth;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
use Illuminate\Support\Facades\Session;
|
|
||||||
|
|
||||||
class RepaymentController extends Controller
|
|
||||||
{
|
|
||||||
protected $model;
|
|
||||||
protected $baseLabId;
|
|
||||||
protected $base;
|
|
||||||
protected $invoiceModel;
|
|
||||||
|
|
||||||
|
|
||||||
public function __construct(){
|
|
||||||
$this->model = new Repayment();
|
|
||||||
$this->invoiceModel = new Invoice();
|
|
||||||
$this->baseLabId = Session::get('base_lab_id');
|
|
||||||
$this->base = Session::get('base_lab');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function index(Request $request){
|
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['view_repayment'])) return redirect(url('my-profile'));
|
|
||||||
$recordStatusConditions = Auth::id()==1 ? [RecordStatusEnum::ACTIVE , RecordStatusEnum::DELETE] : [RecordStatusEnum::ACTIVE];
|
|
||||||
$invoices = $this->invoiceModel::with(['sample.patient'])->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
|
||||||
->where('balance','>', 0)->get();
|
|
||||||
$repayments = $this->model::query()
|
|
||||||
->where(BaseModel::RECORD_STATUS_FIELD, RecordStatusEnum::ACTIVE)
|
|
||||||
->where('lab_id', $this->baseLabId)
|
|
||||||
->when(!empty($request->from_date) && !empty($request->to_date), function ($inv) use ($request){
|
|
||||||
$inv->whereBetween('repayment_date',[date('Y-m-d',strtotime($request->from_date)), date('Y-m-d',strtotime($request->to_date))]);
|
|
||||||
})->when(!empty(trim($request->kword)), function ($inv) use($request, $recordStatusConditions){
|
|
||||||
$inv->whereIn('invoice_id', $this->invoiceModel::query()
|
|
||||||
->whereRaw("replace(invoice_code, ' ','') like '%".str_replace(" ","",$request->kword)."%'")
|
|
||||||
->orWhere('patient_uuid','like','%'.$request->kword.'%')->pluck('id')->toArray()
|
|
||||||
)->where('lab_id', $this->baseLabId)->whereIn(BaseModel::RECORD_STATUS_FIELD, $recordStatusConditions);
|
|
||||||
})->orderBy('repayment_date','desc')->paginate(20);
|
|
||||||
return view('repayment', ['oweInvoices' => $invoices, 'repayments' => $repayments, 'labSettings' => (object) $this->location()]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function store(Request $request){
|
|
||||||
DB::beginTransaction();
|
|
||||||
try{
|
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['create_repayment'])) return false;
|
|
||||||
$data = array(
|
|
||||||
'invoice_id' => $request->invoice_id,
|
|
||||||
'amount_to_pay' => $request->amount_to_pay,
|
|
||||||
'discount' => $request->discount,
|
|
||||||
'amount_after_discount' => $request->amount_after_discount,
|
|
||||||
'discount_type' => $request->discount_type,
|
|
||||||
'cash_repayment_amount' => $request->cash_repayment_amount,
|
|
||||||
'bank_repayment_amount' => $request->bank_repayment_amount,
|
|
||||||
'repayment_date' => date('Y-m-d', strtotime($request->repayment_date)),
|
|
||||||
'payment_method' => $request->payment_method,
|
|
||||||
'bank_name' => $request->bank_name,
|
|
||||||
'transaction_ref' => $request->transaction_ref,
|
|
||||||
'exchange_rate' => $request->exchange_rate,
|
|
||||||
'lab_id' => $this->baseLabId,
|
|
||||||
BaseModel::CREATED_AT => date('Y-m-d H:i:s'),
|
|
||||||
BaseModel::CREATED_BY_FIELD => Auth::id()
|
|
||||||
);
|
|
||||||
$repayment = $this->model::query()->create($data);
|
|
||||||
if($repayment){
|
|
||||||
$invoice = $this->invoiceModel::query()->find($request->invoice_id);
|
|
||||||
$totalRepayment = ($invoice->balance - ($request->cash_repayment_amount + $request->bank_repayment_amount));
|
|
||||||
$invoice->deposit = ($invoice->deposit + $request->cash_repayment_amount);
|
|
||||||
$invoice->bank_deposit = ($invoice->bank_deposit+$request->bank_repayment_amount);
|
|
||||||
$invoice->balance = ($totalRepayment);
|
|
||||||
$invoice->discount = $request->discount;
|
|
||||||
$invoice->save();
|
|
||||||
}
|
|
||||||
else DB::rollBack();
|
|
||||||
DB::commit();
|
|
||||||
return response()->json(['success' => true, 'message' => __('invoice.create_success'), 'data' => $repayment]);
|
|
||||||
} catch (\Exception $e){
|
|
||||||
DB::rollBack();
|
|
||||||
return response()->json(['success' => false, 'message' => $e]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public function update(Request $request){
|
|
||||||
DB::beginTransaction();
|
|
||||||
try{
|
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['update_repayment'])) return false;
|
|
||||||
$data = array(
|
|
||||||
'cash_repayment_amount' => $request->cash_repayment_amount,
|
|
||||||
'bank_repayment_amount' => $request->bank_repayment_amount,
|
|
||||||
'repayment_date' => date('Y-m-d', strtotime($request->repayment_date)),
|
|
||||||
'payment_method' => $request->payment_method,
|
|
||||||
'bank_name' => $request->bank_name,
|
|
||||||
'transaction_ref' => $request->transaction_ref,
|
|
||||||
'exchange_rate' => $request->exchange_rate
|
|
||||||
);
|
|
||||||
|
|
||||||
$prevRepayment = $this->model::query()->find($request->uid);
|
|
||||||
|
|
||||||
$repayment = $this->model::query()->where(['id' => $request->uid, 'lab_id' => $this->baseLabId])->update($data);
|
|
||||||
if($repayment){
|
|
||||||
|
|
||||||
$reviseInvoice = $this->invoiceModel::query()->find($request->invoice_id);
|
|
||||||
$totalRepayment = ($reviseInvoice->balance + $prevRepayment->cash_repayment_amount + $prevRepayment->bank_repayment_amount);
|
|
||||||
$reviseInvoice->deposit = (($reviseInvoice->deposit + $prevRepayment->cash_repayment_amount) - $request->cash_repayment_amount);
|
|
||||||
$reviseInvoice->bank_deposit = (($reviseInvoice->bank_deposit + $prevRepayment->bank_repayment_amount) - $request->bank_repayment_amount);
|
|
||||||
$reviseInvoice->balance = $totalRepayment - ($request->cash_repayment_amount + $request->bank_repayment_amount);
|
|
||||||
$reviseInvoice->save();
|
|
||||||
}
|
|
||||||
else DB::rollBack();
|
|
||||||
DB::commit();
|
|
||||||
return response()->json(['success' => true, 'message' => __('invoice.create_success'), 'data' => $repayment]);
|
|
||||||
} catch (\Exception $e){
|
|
||||||
DB::rollBack();
|
|
||||||
return response()->json(['success' => false, 'message' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Perform by ajax function
|
|
||||||
* @param Request $request
|
|
||||||
* @return \Illuminate\Http\JsonResponse
|
|
||||||
*/
|
|
||||||
|
|
||||||
public function delete(Request $request){
|
|
||||||
try{
|
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['delete_repayment'])) return redirect(url('my-profile'));
|
|
||||||
$repayment = $this->model::query()->where(['id' => $request->uid, 'lab_id' => $this->baseLabId])->get()->first();
|
|
||||||
$reviseInvoice = $this->invoiceModel::query()->find($repayment->invoice_id);
|
|
||||||
$totalRepayment = ($reviseInvoice->balance + $repayment->cash_repayment_amount + $repayment->bank_repayment_amount);
|
|
||||||
$reviseInvoice->deposit = ($reviseInvoice->deposit - $repayment->cash_repayment_amount);
|
|
||||||
$reviseInvoice->bank_deposit = ($reviseInvoice->bank_deposit - $repayment->bank_repayment_amount);
|
|
||||||
$reviseInvoice->balance = $totalRepayment;
|
|
||||||
$reviseInvoice->save();
|
|
||||||
$repayment->update(array(BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::DELETE));
|
|
||||||
return response()->json(['success' => true, 'message' => __('invoice.delete_success')]);
|
|
||||||
} catch (\Exception $e){
|
|
||||||
return response()->json(['success' => false, 'message' => __('invoice.delete_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function get(Request $request){
|
|
||||||
try{
|
|
||||||
$data = $this->model::with(['invoice.sample.patient'])->find($request->uid);
|
|
||||||
return response()->json(['success' => true, 'message' => __('invoice.get_success'), 'data' => $data]);
|
|
||||||
} catch (\Exception $e){
|
|
||||||
return response()->json(['success' => false, 'message' => __('invoice.get_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getInvoice(Request $request){
|
|
||||||
try{
|
|
||||||
$data = $this->invoiceModel::query()->find($request->uid);
|
|
||||||
return response()->json(['success' => true, 'message' => __('invoice.get_success'), 'data' => $data]);
|
|
||||||
} catch (\Exception $e){
|
|
||||||
return response()->json(['success' => false, 'message' => __('invoice.get_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -19,21 +19,21 @@ class RoleController extends Controller
|
|||||||
|
|
||||||
protected $roleModel;
|
protected $roleModel;
|
||||||
protected $roleHasPermission;
|
protected $roleHasPermission;
|
||||||
protected $baseLabId;
|
protected $baseOrganizationId;
|
||||||
protected $labs;
|
protected $labs;
|
||||||
|
|
||||||
public function __construct(RoleHasPermission $roleHasPermission, Role $roleModel){
|
public function __construct(RoleHasPermission $roleHasPermission, Role $roleModel){
|
||||||
$this->roleModel = $roleModel;
|
$this->roleModel = $roleModel;
|
||||||
$this->roleHasPermission = $roleHasPermission;
|
$this->roleHasPermission = $roleHasPermission;
|
||||||
$this->baseLabId = Session::get('base_lab_id');
|
$this->baseOrganizationId = Session::get('base_organization_id');
|
||||||
$this->base = Session::get('base_lab');
|
$this->base = Session::get('base_organization');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function index(Request $request){
|
public function index(Request $request){
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['view_user_role'])) return redirect(url('my-profile'));
|
if(!GlobalController::user_can(Auth::user()->role_id, ['view_user_role'])) return redirect(url('my-profile'));
|
||||||
$recordStatusCondition = Auth::id()==1 ? [RecordStatusEnum::DELETE, RecordStatusEnum::ACTIVE] : [RecordStatusEnum::ACTIVE];
|
$recordStatusCondition = Auth::id()==1 ? [RecordStatusEnum::DELETE, RecordStatusEnum::ACTIVE] : [RecordStatusEnum::ACTIVE];
|
||||||
$roles = $this->roleModel::with('lab')->whereIn(BaseModel::RECORD_STATUS_FIELD, $recordStatusCondition)
|
$roles = $this->roleModel::with('lab')->whereIn(BaseModel::RECORD_STATUS_FIELD, $recordStatusCondition)
|
||||||
->where('lab_id', $this->baseLabId)
|
->where('organization_id', $this->baseOrganizationId)
|
||||||
->whereNotIn('id', [UtilEnum::ADMINISTRATOR_ROLE])
|
->whereNotIn('id', [UtilEnum::ADMINISTRATOR_ROLE])
|
||||||
->when(!empty($request->kword), function ($roles) use($request){
|
->when(!empty($request->kword), function ($roles) use($request){
|
||||||
$roles->whereRaw("replace(name_en, ' ','') like '%".str_replace(" ","",$request->kword)."%'");
|
$roles->whereRaw("replace(name_en, ' ','') like '%".str_replace(" ","",$request->kword)."%'");
|
||||||
@@ -46,7 +46,7 @@ class RoleController extends Controller
|
|||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['create_user_role'])) return false;
|
if(!GlobalController::user_can(Auth::user()->role_id, ['create_user_role'])) return false;
|
||||||
$validator = \Validator::make($request->all(), ['name_en' => 'required']);
|
$validator = \Validator::make($request->all(), ['name_en' => 'required']);
|
||||||
if ($validator->fails()) return response()->json(['success' => false, 'message' => __('system_role.create_fail'), 'errors'=>$validator->errors()->all()]);
|
if ($validator->fails()) return response()->json(['success' => false, 'message' => __('system_role.create_fail'), 'errors'=>$validator->errors()->all()]);
|
||||||
$new = $this->roleModel::query()->create(['name_en' => $request->name_en, 'lab_id' => $this->baseLabId]);
|
$new = $this->roleModel::query()->create(['name_en' => $request->name_en, 'organization_id' => $this->baseOrganizationId]);
|
||||||
return response()->json(['success' => true, 'message' => __('system_role.create_success')]);
|
return response()->json(['success' => true, 'message' => __('system_role.create_success')]);
|
||||||
} catch (\Exception $e){
|
} catch (\Exception $e){
|
||||||
return response()->json(['success' => false, 'message' => __('system_role.create_fail'), 'errors' => $e->getMessage()]);
|
return response()->json(['success' => false, 'message' => __('system_role.create_fail'), 'errors' => $e->getMessage()]);
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ class SampleController extends Controller
|
|||||||
protected $organismResultModel;
|
protected $organismResultModel;
|
||||||
protected $antibioticResultModel;
|
protected $antibioticResultModel;
|
||||||
|
|
||||||
protected $baseLabId;
|
protected $baseOrganizationId;
|
||||||
protected $base;
|
protected $base;
|
||||||
|
|
||||||
protected $invoiceModel;
|
protected $invoiceModel;
|
||||||
@@ -74,8 +74,8 @@ class SampleController extends Controller
|
|||||||
$this->invoiceDetailModel = $invoiceDetailModel;
|
$this->invoiceDetailModel = $invoiceDetailModel;
|
||||||
$this->laboratoryConfigures = $laboratoryConfigures;
|
$this->laboratoryConfigures = $laboratoryConfigures;
|
||||||
|
|
||||||
$this->baseLabId = Session::get('base_lab_id');
|
$this->baseOrganizationId = Session::get('base_organization_id');
|
||||||
$this->base = Session::get('base_lab');
|
$this->base = Session::get('base_organization');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function index(Request $request){
|
public function index(Request $request){
|
||||||
@@ -83,7 +83,7 @@ class SampleController extends Controller
|
|||||||
$recordStatusConditions = Auth::id()==1 ? [RecordStatusEnum::ACTIVE, RecordStatusEnum::DELETE] : [RecordStatusEnum::ACTIVE];
|
$recordStatusConditions = Auth::id()==1 ? [RecordStatusEnum::ACTIVE, RecordStatusEnum::DELETE] : [RecordStatusEnum::ACTIVE];
|
||||||
$samples = $this->model::with(['patient','sample_source'])
|
$samples = $this->model::with(['patient','sample_source'])
|
||||||
->whereIn(BaseModel::RECORD_STATUS_FIELD, $recordStatusConditions)
|
->whereIn(BaseModel::RECORD_STATUS_FIELD, $recordStatusConditions)
|
||||||
->where('lab_id', $this->baseLabId)
|
->where('organization_id', $this->baseOrganizationId)
|
||||||
->when(Auth::user()->role_id == UtilEnum::PHYSICIAN_ROLE, function($sample){
|
->when(Auth::user()->role_id == UtilEnum::PHYSICIAN_ROLE, function($sample){
|
||||||
$sample->where('sample_source_id', Auth::user()->sample_source_id);
|
$sample->where('sample_source_id', Auth::user()->sample_source_id);
|
||||||
})->when(!empty(trim($request->kword)), function ($samples) use($request, $recordStatusConditions){
|
})->when(!empty(trim($request->kword)), function ($samples) use($request, $recordStatusConditions){
|
||||||
@@ -92,7 +92,7 @@ class SampleController extends Controller
|
|||||||
->whereRaw("replace(name_en, ' ','') like '%".str_replace(" ","",$request->kword)."%'")
|
->whereRaw("replace(name_en, ' ','') like '%".str_replace(" ","",$request->kword)."%'")
|
||||||
->orWhereRaw("replace(phone_number, ' ','') like '%".str_replace(" ","",$request->kword)."%'")
|
->orWhereRaw("replace(phone_number, ' ','') like '%".str_replace(" ","",$request->kword)."%'")
|
||||||
->orWhere('patient_uuid','like','%'.$request->kword.'%')->pluck('id')->toArray()
|
->orWhere('patient_uuid','like','%'.$request->kword.'%')->pluck('id')->toArray()
|
||||||
)->where('lab_id', $this->baseLabId)->whereIn(BaseModel::RECORD_STATUS_FIELD, $recordStatusConditions);
|
)->where('organization_id', $this->baseOrganizationId)->whereIn(BaseModel::RECORD_STATUS_FIELD, $recordStatusConditions);
|
||||||
})->when(!empty(trim($request->sample_status)), function ($samples) use($request){
|
})->when(!empty(trim($request->sample_status)), function ($samples) use($request){
|
||||||
$samples->whereIn('id', $this->filterSampleStatus($request->sample_status));
|
$samples->whereIn('id', $this->filterSampleStatus($request->sample_status));
|
||||||
})->when(!empty($request->sample_date) && empty($request->kword) , function ($samples) use($request){
|
})->when(!empty($request->sample_date) && empty($request->kword) , function ($samples) use($request){
|
||||||
@@ -131,10 +131,10 @@ class SampleController extends Controller
|
|||||||
FROM samples s
|
FROM samples s
|
||||||
LEFT JOIN test_results tr
|
LEFT JOIN test_results tr
|
||||||
ON tr.`sample_id` = s.`id`
|
ON tr.`sample_id` = s.`id`
|
||||||
AND s.`lab_id` = tr.`lab_id`
|
AND s.`organization_id` = tr.`organization_id`
|
||||||
LEFT JOIN test_samples ts
|
LEFT JOIN test_samples ts
|
||||||
ON ts.id = tr.`test_sample_id`
|
ON ts.id = tr.`test_sample_id`
|
||||||
AND ts.lab_id = tr.lab_id
|
AND ts.organization_id = tr.organization_id
|
||||||
LEFT JOIN sample_types st
|
LEFT JOIN sample_types st
|
||||||
ON st.id = ts.`sample_type_id`
|
ON st.id = ts.`sample_type_id`
|
||||||
LEFT JOIN(
|
LEFT JOIN(
|
||||||
@@ -144,16 +144,16 @@ class SampleController extends Controller
|
|||||||
FROM samples s
|
FROM samples s
|
||||||
INNER JOIN test_results tr
|
INNER JOIN test_results tr
|
||||||
ON tr.`sample_id` = s.`id`
|
ON tr.`sample_id` = s.`id`
|
||||||
AND s.`lab_id` = tr.`lab_id`
|
AND s.`organization_id` = tr.`organization_id`
|
||||||
INNER JOIN organism_results orgr
|
INNER JOIN organism_results orgr
|
||||||
ON orgr.`test_result_id` = tr.`id`
|
ON orgr.`test_result_id` = tr.`id`
|
||||||
WHERE s.lab_id = '.$this->baseLabId.'
|
WHERE s.organization_id = '.$this->baseOrganizationId.'
|
||||||
AND tr.`record_status_id` = 1
|
AND tr.`record_status_id` = 1
|
||||||
AND orgr.`record_status_id` = 1
|
AND orgr.`record_status_id` = 1
|
||||||
GROUP BY tr.id
|
GROUP BY tr.id
|
||||||
) AS org_result
|
) AS org_result
|
||||||
ON org_result.id = tr.`id`
|
ON org_result.id = tr.`id`
|
||||||
WHERE s.`lab_id` = '.$this->baseLabId.'
|
WHERE s.`organization_id` = '.$this->baseOrganizationId.'
|
||||||
AND s.`record_status_id` = 1
|
AND s.`record_status_id` = 1
|
||||||
AND (tr.`record_status_id` = 1 OR tr.`record_status_id` IS NULL)
|
AND (tr.`record_status_id` = 1 OR tr.`record_status_id` IS NULL)
|
||||||
AND (st.`record_status_id` = 1 OR st.`record_status_id` IS NULL)
|
AND (st.`record_status_id` = 1 OR st.`record_status_id` IS NULL)
|
||||||
@@ -172,13 +172,13 @@ class SampleController extends Controller
|
|||||||
public function create($patient_id = null){
|
public function create($patient_id = null){
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['create_sample'])) return redirect(url('my-profile'));
|
if(!GlobalController::user_can(Auth::user()->role_id, ['create_sample'])) return redirect(url('my-profile'));
|
||||||
$rejectComments = $this->rejectCommentModel::query()->where([BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->orderBy('reject_comment', 'ASC')->get();
|
$rejectComments = $this->rejectCommentModel::query()->where([BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->orderBy('reject_comment', 'ASC')->get();
|
||||||
$physicians = $this->physicianModel::query()->where([BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE, 'lab_id' => $this->baseLabId])->orderBy('name_en', 'ASC')->get();
|
$physicians = $this->physicianModel::query()->where([BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE, 'organization_id' => $this->baseOrganizationId])->orderBy('name_en', 'ASC')->get();
|
||||||
$sampleSources = $this->sampleSourceModel::query()->where([BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE, 'lab_id' => $this->baseLabId])->orderBy('name_en','ASC')->get();
|
$sampleSources = $this->sampleSourceModel::query()->where([BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE, 'organization_id' => $this->baseOrganizationId])->orderBy('name_en','ASC')->get();
|
||||||
$patients = $this->patientModel::query()->where([BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE, 'lab_id' => $this->baseLabId])
|
$patients = $this->patientModel::query()->where([BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE, 'organization_id' => $this->baseOrganizationId])
|
||||||
->when(!empty($patient_id), function ($patients) use ($patient_id){
|
->when(!empty($patient_id), function ($patients) use ($patient_id){
|
||||||
$patients->where(['id' => $patient_id, 'lab_id' => $this->baseLabId ]);
|
$patients->where(['id' => $patient_id, 'organization_id' => $this->baseOrganizationId ]);
|
||||||
})->orderBy(BaseModel::CREATED_AT_FIELD, 'DESC')->limit(30)->get();
|
})->orderBy(BaseModel::CREATED_AT_FIELD, 'DESC')->limit(30)->get();
|
||||||
$testGroups = $this->testGroupModel::with(['testGroupDetails'])->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->orderBy('created_at')->get();
|
$testGroups = $this->testGroupModel::with(['testGroupDetails'])->where(['organization_id' => $this->baseOrganizationId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->orderBy('created_at')->get();
|
||||||
return view('new_sample', [
|
return view('new_sample', [
|
||||||
'labSettings' => (object) $this->base,
|
'labSettings' => (object) $this->base,
|
||||||
'physicians' => $physicians,
|
'physicians' => $physicians,
|
||||||
@@ -194,7 +194,7 @@ class SampleController extends Controller
|
|||||||
public function generateAutoId($admissionDate){
|
public function generateAutoId($admissionDate){
|
||||||
$prefix = date('ymd',strtotime($admissionDate));
|
$prefix = date('ymd',strtotime($admissionDate));
|
||||||
$sample = Sample::query();
|
$sample = Sample::query();
|
||||||
$sampleCount = $sample->where('lab_id', $this->baseLabId)->whereRaw('date(admission_date) ="'. date('Y-m-d',strtotime($admissionDate)).'"')->count();
|
$sampleCount = $sample->where('organization_id', $this->baseOrganizationId)->whereRaw('date(admission_date) ="'. date('Y-m-d',strtotime($admissionDate)).'"')->count();
|
||||||
return 'S-'.$this->base['short_name'].'-'.$prefix.'-'.(str_pad(($sampleCount+1),3,'0',STR_PAD_LEFT));
|
return 'S-'.$this->base['short_name'].'-'.$prefix.'-'.(str_pad(($sampleCount+1),3,'0',STR_PAD_LEFT));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,7 +202,7 @@ class SampleController extends Controller
|
|||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
try{
|
try{
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['create_sample'])) return false;
|
if(!GlobalController::user_can(Auth::user()->role_id, ['create_sample'])) return false;
|
||||||
$request = collect($sampleCreateRequest)->merge(['lab_id'=>$this->baseLabId]);
|
$request = collect($sampleCreateRequest)->merge(['organization_id'=>$this->baseOrganizationId]);
|
||||||
if(empty($sampleCreateRequest->sample_number)) {
|
if(empty($sampleCreateRequest->sample_number)) {
|
||||||
$sampleNumber = $this->generateAutoId($sampleCreateRequest->admission_date);
|
$sampleNumber = $this->generateAutoId($sampleCreateRequest->admission_date);
|
||||||
$request = $request->merge(['sample_number' => $sampleNumber]);
|
$request = $request->merge(['sample_number' => $sampleNumber]);
|
||||||
@@ -242,7 +242,7 @@ class SampleController extends Controller
|
|||||||
public function store1(SampleCreateRequest $sampleCreateRequest){
|
public function store1(SampleCreateRequest $sampleCreateRequest){
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
try{
|
try{
|
||||||
$request = collect($sampleCreateRequest)->merge(['lab_id'=>$this->baseLabId]);
|
$request = collect($sampleCreateRequest)->merge(['organization_id'=>$this->baseOrganizationId]);
|
||||||
if(empty($sampleCreateRequest->sample_number)) {
|
if(empty($sampleCreateRequest->sample_number)) {
|
||||||
$sampleNumber = $this->generateAutoId($sampleCreateRequest->admission_date);
|
$sampleNumber = $this->generateAutoId($sampleCreateRequest->admission_date);
|
||||||
$request = $request->merge(['sample_number' => $sampleNumber]);
|
$request = $request->merge(['sample_number' => $sampleNumber]);
|
||||||
@@ -259,12 +259,12 @@ class SampleController extends Controller
|
|||||||
|
|
||||||
public function edit(Request $request, $id){ // url: base_url/sample/edit/[sample-id]
|
public function edit(Request $request, $id){ // url: base_url/sample/edit/[sample-id]
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['update_sample'])) return redirect(url('my-profile'));
|
if(!GlobalController::user_can(Auth::user()->role_id, ['update_sample'])) return redirect(url('my-profile'));
|
||||||
$sample = $this->model::with(['patient'/*'patient.telegramChatId'*/,'invoice'])->where(['lab_id' => $this->baseLabId,'id' => $id])->first();
|
$sample = $this->model::with(['patient'/*'patient.telegramChatId'*/,'invoice'])->where(['organization_id' => $this->baseOrganizationId,'id' => $id])->first();
|
||||||
$rejectComments = $this->rejectCommentModel::query()->where([BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->orderBy('reject_comment', 'ASC')->get();
|
$rejectComments = $this->rejectCommentModel::query()->where([BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->orderBy('reject_comment', 'ASC')->get();
|
||||||
$physicians = $this->physicianModel::query()->where([BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE, 'lab_id' => $this->baseLabId])->orderBy('name_en', 'ASC')->get();
|
$physicians = $this->physicianModel::query()->where([BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE, 'organization_id' => $this->baseOrganizationId])->orderBy('name_en', 'ASC')->get();
|
||||||
$samplePhysician = $this->physicianModel::query()->where('id', $sample->physician_id)->first();
|
$samplePhysician = $this->physicianModel::query()->where('id', $sample->physician_id)->first();
|
||||||
$sampleSources = $this->sampleSourceModel::query()->where([BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE, 'lab_id' => $this->baseLabId])->orderBy('name_en','ASC')->get();
|
$sampleSources = $this->sampleSourceModel::query()->where([BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE, 'organization_id' => $this->baseOrganizationId])->orderBy('name_en','ASC')->get();
|
||||||
$testGroups = $this->testGroupModel::with(['testGroupDetails'])->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->orderBy('created_at')->get();
|
$testGroups = $this->testGroupModel::with(['testGroupDetails'])->where(['organization_id' => $this->baseOrganizationId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->orderBy('created_at')->get();
|
||||||
|
|
||||||
$now = strtotime($sample->admission_date); // or your date as well
|
$now = strtotime($sample->admission_date); // or your date as well
|
||||||
$your_date = strtotime($sample->patient->dob);
|
$your_date = strtotime($sample->patient->dob);
|
||||||
@@ -277,10 +277,10 @@ class SampleController extends Controller
|
|||||||
|
|
||||||
$prevSample = [];
|
$prevSample = [];
|
||||||
if(isset($_GET['previous_sample'])){
|
if(isset($_GET['previous_sample'])){
|
||||||
$prevSample = $this->model::with(['patient','invoice'])->where(['lab_id' => $this->baseLabId, 'id' => $_GET['previous_sample']])->get();
|
$prevSample = $this->model::with(['patient','invoice'])->where(['organization_id' => $this->baseOrganizationId, 'id' => $_GET['previous_sample']])->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
$labConfigures = $this->laboratoryConfigures::query()->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->get()->toArray();
|
$labConfigures = $this->laboratoryConfigures::query()->where(['organization_id' => $this->baseOrganizationId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->get()->toArray();
|
||||||
|
|
||||||
$resultTemplateId = (collect($labConfigures)->where('atrribute_code', 'RESULT_TEMPLATE')->pluck('assigned_attribute_value')->first());
|
$resultTemplateId = (collect($labConfigures)->where('atrribute_code', 'RESULT_TEMPLATE')->pluck('assigned_attribute_value')->first());
|
||||||
if(!empty($resultTemplateId)){
|
if(!empty($resultTemplateId)){
|
||||||
@@ -314,7 +314,7 @@ class SampleController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getPreviousSample($patientId, $curSampleId){
|
function getPreviousSample($patientId, $curSampleId){
|
||||||
return $this->model::query()->where(['patient_id' => $patientId, 'lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
return $this->model::query()->where(['patient_id' => $patientId, 'organization_id' => $this->baseOrganizationId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
||||||
->where('id','<', $curSampleId)->orderBy('id', 'desc')->get(['id','admission_date', 'sample_number']);
|
->where('id','<', $curSampleId)->orderBy('id', 'desc')->get(['id','admission_date', 'sample_number']);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -328,7 +328,7 @@ class SampleController extends Controller
|
|||||||
try{
|
try{
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['update_sample'])) return redirect(url('my-profile'));
|
if(!GlobalController::user_can(Auth::user()->role_id, ['update_sample'])) return redirect(url('my-profile'));
|
||||||
$request = collect($sampleUpdateRequest)->except(['id','sample_number','patient_id','_token']);
|
$request = collect($sampleUpdateRequest)->except(['id','sample_number','patient_id','_token']);
|
||||||
$patientSample = $this->model::query()->where(['id' => $sampleUpdateRequest->id, 'lab_id' => $this->baseLabId])->first();
|
$patientSample = $this->model::query()->where(['id' => $sampleUpdateRequest->id, 'organization_id' => $this->baseOrganizationId])->first();
|
||||||
$patientSample->update($request->all());
|
$patientSample->update($request->all());
|
||||||
DB::commit();
|
DB::commit();
|
||||||
$sampleUpdateRequest->session()->flash('message','Update success.');
|
$sampleUpdateRequest->session()->flash('message','Update success.');
|
||||||
@@ -348,7 +348,7 @@ class SampleController extends Controller
|
|||||||
public function delete(Request $request){
|
public function delete(Request $request){
|
||||||
try{
|
try{
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['delete_sample'])) return false;
|
if(!GlobalController::user_can(Auth::user()->role_id, ['delete_sample'])) return false;
|
||||||
$patientSample = $this->model::query()->where(['id' => $request->uid, 'lab_id' => $this->baseLabId])->first();
|
$patientSample = $this->model::query()->where(['id' => $request->uid, 'organization_id' => $this->baseOrganizationId])->first();
|
||||||
$patientSample->update(array(BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::DELETE));
|
$patientSample->update(array(BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::DELETE));
|
||||||
return response()->json(['success' => true, 'message' => __('sample.delete_success')]);
|
return response()->json(['success' => true, 'message' => __('sample.delete_success')]);
|
||||||
}
|
}
|
||||||
@@ -359,7 +359,7 @@ class SampleController extends Controller
|
|||||||
|
|
||||||
public function restore(Request $request){
|
public function restore(Request $request){
|
||||||
try{
|
try{
|
||||||
$patientSample = $this->model::query()->where(['id' => $request->uid, 'lab_id' => $this->baseLabId])->first();
|
$patientSample = $this->model::query()->where(['id' => $request->uid, 'organization_id' => $this->baseOrganizationId])->first();
|
||||||
$patientSample->update(array(BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE));
|
$patientSample->update(array(BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE));
|
||||||
return response()->json(['success' => true, 'message' => __('sample.restore_success')]);
|
return response()->json(['success' => true, 'message' => __('sample.restore_success')]);
|
||||||
}
|
}
|
||||||
@@ -371,7 +371,7 @@ class SampleController extends Controller
|
|||||||
public function approve(Request $request){
|
public function approve(Request $request){
|
||||||
try{
|
try{
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['approve_result'])) return false;
|
if(!GlobalController::user_can(Auth::user()->role_id, ['approve_result'])) return false;
|
||||||
$patientSample = $this->model::query()->where(['id' => $request->uid, 'lab_id' => $this->baseLabId])->first();
|
$patientSample = $this->model::query()->where(['id' => $request->uid, 'organization_id' => $this->baseOrganizationId])->first();
|
||||||
$patientSample->update(array('approved_by' => Auth::id(), 'approved_date' => date('Y-m-d H:i:s')));
|
$patientSample->update(array('approved_by' => Auth::id(), 'approved_date' => date('Y-m-d H:i:s')));
|
||||||
return response()->json(['success' => true, 'message' => __('sample.approve_success')]);
|
return response()->json(['success' => true, 'message' => __('sample.approve_success')]);
|
||||||
}
|
}
|
||||||
@@ -388,7 +388,7 @@ class SampleController extends Controller
|
|||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
try{
|
try{
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['create_sample', 'update_sample'])) return false;
|
if(!GlobalController::user_can(Auth::user()->role_id, ['create_sample', 'update_sample'])) return false;
|
||||||
$this->sampleDetailModel::query()->where(['sample_id' => $sampleCreateRequest->sample_id, 'lab_id' => $this->baseLabId])->update(array(BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::DELETE));
|
$this->sampleDetailModel::query()->where(['sample_id' => $sampleCreateRequest->sample_id, 'organization_id' => $this->baseOrganizationId])->update(array(BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::DELETE));
|
||||||
$sampleDetails = collect($sampleCreateRequest->sample_details);
|
$sampleDetails = collect($sampleCreateRequest->sample_details);
|
||||||
$sampleDetails->map(function ($item){
|
$sampleDetails->map(function ($item){
|
||||||
if(!empty($item['sample_description'])){
|
if(!empty($item['sample_description'])){
|
||||||
@@ -398,31 +398,31 @@ class SampleController extends Controller
|
|||||||
'test_date' => date('Y-m-d'),
|
'test_date' => date('Y-m-d'),
|
||||||
'lab_technician_id' => Auth::id(),
|
'lab_technician_id' => Auth::id(),
|
||||||
'sample_descr' => $item['sample_description'],
|
'sample_descr' => $item['sample_description'],
|
||||||
'lab_id' => $this->baseLabId
|
'organization_id' => $this->baseOrganizationId
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
//dd($sampleCreateRequest->sample_tests);
|
//dd($sampleCreateRequest->sample_tests);
|
||||||
if(!empty($sampleCreateRequest->sample_tests)){
|
if(!empty($sampleCreateRequest->sample_tests)){
|
||||||
$this->testResultModel::query()->where(['sample_id' => $sampleCreateRequest->sample_id, 'lab_id' => $this->baseLabId])
|
$this->testResultModel::query()->where(['sample_id' => $sampleCreateRequest->sample_id, 'organization_id' => $this->baseOrganizationId])
|
||||||
->whereNotIn('test_sample_id', $sampleCreateRequest->sample_tests)
|
->whereNotIn('test_sample_id', $sampleCreateRequest->sample_tests)
|
||||||
->delete();
|
->delete();
|
||||||
foreach ($sampleCreateRequest->sample_tests as $test){
|
foreach ($sampleCreateRequest->sample_tests as $test){
|
||||||
$existingTestResult = $this->testResultModel::query()->where([
|
$existingTestResult = $this->testResultModel::query()->where([
|
||||||
'test_sample_id' => $test,
|
'test_sample_id' => $test,
|
||||||
'lab_id' => $this->baseLabId,
|
'organization_id' => $this->baseOrganizationId,
|
||||||
'sample_id' => $sampleCreateRequest->sample_id
|
'sample_id' => $sampleCreateRequest->sample_id
|
||||||
])->get()->toArray();
|
])->get()->toArray();
|
||||||
if(empty($existingTestResult)) {
|
if(empty($existingTestResult)) {
|
||||||
$testResult = $this->testResultModel::query()->create([
|
$testResult = $this->testResultModel::query()->create([
|
||||||
'sample_id' => $sampleCreateRequest->sample_id,
|
'sample_id' => $sampleCreateRequest->sample_id,
|
||||||
'test_sample_id' => $test,
|
'test_sample_id' => $test,
|
||||||
'lab_id' => $this->baseLabId
|
'organization_id' => $this->baseOrganizationId
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
$this->testResultModel::query()->where(['sample_id' => $sampleCreateRequest->sample_id, 'lab_id' => $this->baseLabId])->delete();
|
$this->testResultModel::query()->where(['sample_id' => $sampleCreateRequest->sample_id, 'organization_id' => $this->baseOrganizationId])->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -456,7 +456,7 @@ class SampleController extends Controller
|
|||||||
'bank_deposit' => 0,
|
'bank_deposit' => 0,
|
||||||
'balance' => number_format($grossTotal * ($labSettings->currency==1 ? $labSettings->exchange_rate : 1),2, '.', ''),
|
'balance' => number_format($grossTotal * ($labSettings->currency==1 ? $labSettings->exchange_rate : 1),2, '.', ''),
|
||||||
'invoice_date' => date('Y-m-d', strtotime($sample->admission_date)),
|
'invoice_date' => date('Y-m-d', strtotime($sample->admission_date)),
|
||||||
'lab_id'=>$this->baseLabId,
|
'organization_id'=>$this->baseOrganizationId,
|
||||||
'exchange_rate' => $labSettings->exchange_rate
|
'exchange_rate' => $labSettings->exchange_rate
|
||||||
]);
|
]);
|
||||||
$invoice = $this->invoiceModel::query()->create($invoiceRequest->all());
|
$invoice = $this->invoiceModel::query()->create($invoiceRequest->all());
|
||||||
@@ -524,7 +524,7 @@ class SampleController extends Controller
|
|||||||
$ref_performed_by = collect($request->ref_test_sample_performer);
|
$ref_performed_by = collect($request->ref_test_sample_performer);
|
||||||
$ref_test_sample_comment = collect($request->ref_test_sample_comment);
|
$ref_test_sample_comment = collect($request->ref_test_sample_comment);
|
||||||
$vars = $data->map(function ($val, $key) use($request, $ref_test_sample_id_value, $ref_test_date, $ref_performed_by, $ref_test_sample_comment){
|
$vars = $data->map(function ($val, $key) use($request, $ref_test_sample_id_value, $ref_test_date, $ref_performed_by, $ref_test_sample_comment){
|
||||||
$this->testResultModel::query()->where(['lab_id' => $this->baseLabId, 'sample_id' => $request->sample_id, 'test_sample_id' => $val])->update([
|
$this->testResultModel::query()->where(['organization_id' => $this->baseOrganizationId, 'sample_id' => $request->sample_id, 'test_sample_id' => $val])->update([
|
||||||
'test_result' => @$ref_test_sample_id_value[$key],
|
'test_result' => @$ref_test_sample_id_value[$key],
|
||||||
'test_date' => @$ref_test_date[$key],
|
'test_date' => @$ref_test_date[$key],
|
||||||
'performed_by' => @$ref_performed_by[$key],
|
'performed_by' => @$ref_performed_by[$key],
|
||||||
@@ -540,7 +540,7 @@ class SampleController extends Controller
|
|||||||
//$ref_performed_by = collect($request->ref_test_sample_performer);
|
//$ref_performed_by = collect($request->ref_test_sample_performer);
|
||||||
$ref_test_sample_comment_ = collect($request->ref_test_sample_comment___);
|
$ref_test_sample_comment_ = collect($request->ref_test_sample_comment___);
|
||||||
$vars = $datas->map(function ($val_, $key_) use($request, $ref_test_sample_comment_){
|
$vars = $datas->map(function ($val_, $key_) use($request, $ref_test_sample_comment_){
|
||||||
$this->testResultModel::query()->where(['lab_id' => $this->baseLabId, 'sample_id' => $request->sample_id, 'test_sample_id' => $val_])->update([
|
$this->testResultModel::query()->where(['organization_id' => $this->baseOrganizationId, 'sample_id' => $request->sample_id, 'test_sample_id' => $val_])->update([
|
||||||
//'test_date' => @$ref_test_date[$key],
|
//'test_date' => @$ref_test_date[$key],
|
||||||
//'performed_by' => @$ref_performed_by[$key],
|
//'performed_by' => @$ref_performed_by[$key],
|
||||||
'comment' => $ref_test_sample_comment_[$key_],
|
'comment' => $ref_test_sample_comment_[$key_],
|
||||||
@@ -551,16 +551,16 @@ class SampleController extends Controller
|
|||||||
// set hide test
|
// set hide test
|
||||||
|
|
||||||
if(isset($request->test_samples_to_hide)){
|
if(isset($request->test_samples_to_hide)){
|
||||||
$this->testResultModel::query()->where(['lab_id' => $this->baseLabId, 'sample_id' => $request->sample_id])
|
$this->testResultModel::query()->where(['organization_id' => $this->baseOrganizationId, 'sample_id' => $request->sample_id])
|
||||||
->whereNotIn('test_sample_id', $request->test_samples_to_hide)->update(['is_show' => 1]);
|
->whereNotIn('test_sample_id', $request->test_samples_to_hide)->update(['is_show' => 1]);
|
||||||
|
|
||||||
foreach ($request->test_samples_to_hide as $val){
|
foreach ($request->test_samples_to_hide as $val){
|
||||||
$this->testResultModel::query()->where(['lab_id' => $this->baseLabId, 'sample_id' => $request->sample_id, 'test_sample_id' => $val])->update([
|
$this->testResultModel::query()->where(['organization_id' => $this->baseOrganizationId, 'sample_id' => $request->sample_id, 'test_sample_id' => $val])->update([
|
||||||
'is_show' => 0
|
'is_show' => 0
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
} else{
|
} else{
|
||||||
$this->testResultModel::query()->where(['lab_id' => $this->baseLabId, 'sample_id' => $request->sample_id])->update(['is_show' => 1]);
|
$this->testResultModel::query()->where(['organization_id' => $this->baseOrganizationId, 'sample_id' => $request->sample_id])->update(['is_show' => 1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// organism result
|
// organism result
|
||||||
@@ -575,13 +575,13 @@ class SampleController extends Controller
|
|||||||
|
|
||||||
// change on 08/Sep/2023 to fixed issue save result success but no data affect
|
// change on 08/Sep/2023 to fixed issue save result success but no data affect
|
||||||
//$testResult = $this->testResultModel::query()->where(['test_sample_id' => $org->test_sample_id, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->orderByDesc('id')->limit(1)->first();
|
//$testResult = $this->testResultModel::query()->where(['test_sample_id' => $org->test_sample_id, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->orderByDesc('id')->limit(1)->first();
|
||||||
$testResult = $this->testResultModel::query()->where(['test_sample_id' => $org->test_sample_id, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE, 'lab_id' => $this->baseLabId, 'sample_id' => $request->sample_id])->orderByDesc('id')->limit(1)->first();
|
$testResult = $this->testResultModel::query()->where(['test_sample_id' => $org->test_sample_id, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE, 'organization_id' => $this->baseOrganizationId, 'sample_id' => $request->sample_id])->orderByDesc('id')->limit(1)->first();
|
||||||
|
|
||||||
if(count($organismIds)>0){
|
if(count($organismIds)>0){
|
||||||
$this->organismResultModel::query()->where(['test_result_id' => $testResult->id, 'lab_id' => $this->baseLabId])->whereNotIn('organism_id', $organismIds)->update(['record_status_id' => 0]);
|
$this->organismResultModel::query()->where(['test_result_id' => $testResult->id, 'organization_id' => $this->baseOrganizationId])->whereNotIn('organism_id', $organismIds)->update(['record_status_id' => 0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$organismResult = $this->organismResultModel::query()->where(['test_result_id' => $testResult->id, 'organism_id' => $org->organism_id, BaseModel::RECORD_STATUS_FIELD =>RecordStatusEnum::ACTIVE, 'lab_id' => $this->baseLabId])->first();
|
$organismResult = $this->organismResultModel::query()->where(['test_result_id' => $testResult->id, 'organism_id' => $org->organism_id, BaseModel::RECORD_STATUS_FIELD =>RecordStatusEnum::ACTIVE, 'organization_id' => $this->baseOrganizationId])->first();
|
||||||
//$organismResultId = 0;
|
//$organismResultId = 0;
|
||||||
|
|
||||||
if(!empty($organismResult)){
|
if(!empty($organismResult)){
|
||||||
@@ -597,7 +597,7 @@ class SampleController extends Controller
|
|||||||
'organism_id' => $org->organism_id,
|
'organism_id' => $org->organism_id,
|
||||||
'quantity_id' => (int)$org->quantity_id,
|
'quantity_id' => (int)$org->quantity_id,
|
||||||
'contaminant' => $org->contaminant,
|
'contaminant' => $org->contaminant,
|
||||||
'lab_id' => $this->baseLabId,
|
'organization_id' => $this->baseOrganizationId,
|
||||||
BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE,
|
BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE,
|
||||||
BaseModel::CREATED_AT => date('Y-m-d H:i:s')
|
BaseModel::CREATED_AT => date('Y-m-d H:i:s')
|
||||||
]);
|
]);
|
||||||
@@ -678,10 +678,10 @@ class SampleController extends Controller
|
|||||||
FROM samples s
|
FROM samples s
|
||||||
INNER JOIN test_results tr
|
INNER JOIN test_results tr
|
||||||
ON tr.`sample_id` = s.`id`
|
ON tr.`sample_id` = s.`id`
|
||||||
AND s.`lab_id` = tr.`lab_id`
|
AND s.`organization_id` = tr.`organization_id`
|
||||||
INNER JOIN test_samples ts
|
INNER JOIN test_samples ts
|
||||||
ON ts.id = tr.`test_sample_id`
|
ON ts.id = tr.`test_sample_id`
|
||||||
and ts.lab_id = tr.lab_id
|
and ts.organization_id = tr.organization_id
|
||||||
INNER JOIN tests t
|
INNER JOIN tests t
|
||||||
ON t.`id` = ts.`test_id`
|
ON t.`id` = ts.`test_id`
|
||||||
INNER JOIN sample_types st
|
INNER JOIN sample_types st
|
||||||
@@ -692,7 +692,7 @@ class SampleController extends Controller
|
|||||||
ON pct.`test_sample_id` = ts.`id`
|
ON pct.`test_sample_id` = ts.`id`
|
||||||
AND pct.`physician_id` = s.`physician_id`
|
AND pct.`physician_id` = s.`physician_id`
|
||||||
WHERE s.`id` = '.$sampleId.'
|
WHERE s.`id` = '.$sampleId.'
|
||||||
AND s.`lab_id`= '.$this->baseLabId.'
|
AND s.`organization_id`= '.$this->baseOrganizationId.'
|
||||||
AND tr.`record_status_id` = '.BaseModel::RECORD_STATUS_ACTIVE.'
|
AND tr.`record_status_id` = '.BaseModel::RECORD_STATUS_ACTIVE.'
|
||||||
AND LENGTH(ts.group_result)>0
|
AND LENGTH(ts.group_result)>0
|
||||||
AND ts.usd_price>0
|
AND ts.usd_price>0
|
||||||
@@ -728,7 +728,7 @@ class SampleController extends Controller
|
|||||||
function printRecorder(Request $request){
|
function printRecorder(Request $request){
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
try{
|
try{
|
||||||
$patientSample = $this->model::query()->where(['id' => $request->uid, 'lab_id' => $this->baseLabId])->first();
|
$patientSample = $this->model::query()->where(['id' => $request->uid, 'organization_id' => $this->baseOrganizationId])->first();
|
||||||
if($patientSample->is_printed==0) {
|
if($patientSample->is_printed==0) {
|
||||||
$patientSample->update(
|
$patientSample->update(
|
||||||
[
|
[
|
||||||
@@ -748,7 +748,7 @@ class SampleController extends Controller
|
|||||||
|
|
||||||
public function generateInvoiceId($invoiceDate){
|
public function generateInvoiceId($invoiceDate){
|
||||||
$prefix = date('y',strtotime($invoiceDate));
|
$prefix = date('y',strtotime($invoiceDate));
|
||||||
$invoiceCount = $this->invoiceModel::query()->where('lab_id', $this->baseLabId)->whereRaw('year(invoice_date) ="'. date('Y',strtotime($invoiceDate)).'"')->count();
|
$invoiceCount = $this->invoiceModel::query()->where('organization_id', $this->baseOrganizationId)->whereRaw('year(invoice_date) ="'. date('Y',strtotime($invoiceDate)).'"')->count();
|
||||||
return 'I-'.$this->base['short_name'].'-'.$prefix.'-'.(str_pad(($invoiceCount+1),5,'0',STR_PAD_LEFT));
|
return 'I-'.$this->base['short_name'].'-'.$prefix.'-'.(str_pad(($invoiceCount+1),5,'0',STR_PAD_LEFT));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -758,8 +758,8 @@ class SampleController extends Controller
|
|||||||
// if(Auth::user()->id==1){
|
// if(Auth::user()->id==1){
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
try{
|
try{
|
||||||
$testResult = $this->testResultModel::query()->where(['test_sample_id' => $testSampleId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE, 'lab_id' => $this->baseLabId, 'sample_id' => $sampleId])->orderByDesc('id')->limit(1)->first();
|
$testResult = $this->testResultModel::query()->where(['test_sample_id' => $testSampleId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE, 'organization_id' => $this->baseOrganizationId, 'sample_id' => $sampleId])->orderByDesc('id')->limit(1)->first();
|
||||||
$organismResult = $this->organismResultModel::query()->where(['test_result_id' => $testResult->id, 'organism_id' => $organismId, BaseModel::RECORD_STATUS_FIELD =>RecordStatusEnum::ACTIVE, 'lab_id' => $this->baseLabId])->first();
|
$organismResult = $this->organismResultModel::query()->where(['test_result_id' => $testResult->id, 'organism_id' => $organismId, BaseModel::RECORD_STATUS_FIELD =>RecordStatusEnum::ACTIVE, 'organization_id' => $this->baseOrganizationId])->first();
|
||||||
if(empty($organismResult)){
|
if(empty($organismResult)){
|
||||||
|
|
||||||
$savedOrg = $this->organismResultModel::query()->create([
|
$savedOrg = $this->organismResultModel::query()->create([
|
||||||
@@ -767,7 +767,7 @@ class SampleController extends Controller
|
|||||||
'organism_id' => $organismId,
|
'organism_id' => $organismId,
|
||||||
'quantity_id' => 0,
|
'quantity_id' => 0,
|
||||||
'contaminant' => 0,
|
'contaminant' => 0,
|
||||||
'lab_id' => $this->baseLabId,
|
'organization_id' => $this->baseOrganizationId,
|
||||||
BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE,
|
BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE,
|
||||||
BaseModel::CREATED_AT => date('Y-m-d H:i:s')
|
BaseModel::CREATED_AT => date('Y-m-d H:i:s')
|
||||||
]);
|
]);
|
||||||
@@ -787,10 +787,10 @@ class SampleController extends Controller
|
|||||||
//if(Auth::user()->id==1){
|
//if(Auth::user()->id==1){
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
try{
|
try{
|
||||||
$testResult = $this->testResultModel::query()->where(['test_sample_id' => $testSampleId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE, 'lab_id' => $this->baseLabId, 'sample_id' => $sampleId])->orderByDesc('id')->limit(1)->first();
|
$testResult = $this->testResultModel::query()->where(['test_sample_id' => $testSampleId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE, 'organization_id' => $this->baseOrganizationId, 'sample_id' => $sampleId])->orderByDesc('id')->limit(1)->first();
|
||||||
$organismResult = $this->organismResultModel::query()->where(['test_result_id' => $testResult->id, 'organism_id' => $organismId, BaseModel::RECORD_STATUS_FIELD =>RecordStatusEnum::ACTIVE, 'lab_id' => $this->baseLabId])->first();
|
$organismResult = $this->organismResultModel::query()->where(['test_result_id' => $testResult->id, 'organism_id' => $organismId, BaseModel::RECORD_STATUS_FIELD =>RecordStatusEnum::ACTIVE, 'organization_id' => $this->baseOrganizationId])->first();
|
||||||
if(!empty($organismResult)){
|
if(!empty($organismResult)){
|
||||||
$savedOrg = $this->organismResultModel::query()->where(['test_result_id' => $testResult->id, 'organism_id' => $organismId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE, 'lab_id' => $this->baseLabId])
|
$savedOrg = $this->organismResultModel::query()->where(['test_result_id' => $testResult->id, 'organism_id' => $organismId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE, 'organization_id' => $this->baseOrganizationId])
|
||||||
->update([
|
->update([
|
||||||
'quantity_id' => $qtyId
|
'quantity_id' => $qtyId
|
||||||
]);
|
]);
|
||||||
@@ -865,7 +865,7 @@ class SampleController extends Controller
|
|||||||
|
|
||||||
public function updateSampleResultTemplate(Request $request){
|
public function updateSampleResultTemplate(Request $request){
|
||||||
try{
|
try{
|
||||||
$patientSample = $this->model::query()->where(['id' => $request->uid, 'lab_id' => $this->baseLabId])->first();
|
$patientSample = $this->model::query()->where(['id' => $request->uid, 'organization_id' => $this->baseOrganizationId])->first();
|
||||||
$patientSample->update(['result_template_id' => $request->result_template_id]);
|
$patientSample->update(['result_template_id' => $request->result_template_id]);
|
||||||
return response()->json(['success'=> true , 'message' => 'Sample result template already saved!']);
|
return response()->json(['success'=> true , 'message' => 'Sample result template already saved!']);
|
||||||
} catch (\Exception $e){
|
} catch (\Exception $e){
|
||||||
|
|||||||
@@ -1,106 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
|
||||||
use App\Enums\RecordStatusEnum;
|
|
||||||
use App\Http\Controllers\Helper\GlobalController;
|
|
||||||
use App\Models\BaseModel;
|
|
||||||
use App\Models\SampleSource;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Illuminate\Support\Facades\Auth;
|
|
||||||
use Illuminate\Support\Facades\Session;
|
|
||||||
|
|
||||||
class SampleSourceController extends Controller
|
|
||||||
{
|
|
||||||
|
|
||||||
protected $sampleSourceModel;
|
|
||||||
protected $baseLabId;
|
|
||||||
protected $base;
|
|
||||||
public function __construct(SampleSource $sampleSourceModel){
|
|
||||||
$this->sampleSourceModel = $sampleSourceModel;
|
|
||||||
$this->baseLabId = Session::get('base_lab_id');
|
|
||||||
$this->base = Session::get('base_lab');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function index(Request $request){
|
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['view_sample_source'])) return redirect(url('my-profile'));
|
|
||||||
$sampleSources = $this->sampleSourceModel::with(['lab'])->where(BaseModel::RECORD_STATUS_FIELD, RecordStatusEnum::ACTIVE)
|
|
||||||
->where('lab_id', $this->baseLabId)
|
|
||||||
->when(!empty($request->kword), function ($sampleSources) use($request){
|
|
||||||
$sampleSources->whereRaw("replace(name_en, ' ','') like '%".str_replace(" ","",$request->kword)."%'");
|
|
||||||
})->orderBy(BaseModel::CREATED_AT,'desc')->paginate(config('labis.pagination.perpage', 10));
|
|
||||||
return view('sample_source', ['sampleSources' => $sampleSources, 'labs' => parent::getAccessAbleLabs()]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function save(Request $request){
|
|
||||||
try {
|
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['create_sample_source'])) return false;
|
|
||||||
$validator = \Validator::make($request->all(), [
|
|
||||||
'name_en' => 'required',
|
|
||||||
'name_kh' => 'nullable'
|
|
||||||
]);
|
|
||||||
if ($validator->fails()) return response()->json(['success' => false, 'message' => __('sample_source.create_fail'), 'errors' => $validator->errors()->all()]);
|
|
||||||
|
|
||||||
$new = $this->sampleSourceModel::query()->firstOrNew(['name_en' => $request->name_en, 'lab_id' => $this->baseLabId]);
|
|
||||||
$new->name_en = $request->name_en;
|
|
||||||
$new->is_default = $request->is_default;
|
|
||||||
$new->lab_id = $this->baseLabId;
|
|
||||||
$new->created_at = date('Y-m-d H:i:s');
|
|
||||||
$new->created_by = Auth::id();
|
|
||||||
$new->record_status_id = RecordStatusEnum::ACTIVE;
|
|
||||||
$new->save();
|
|
||||||
|
|
||||||
return response()->json(['success' => true, 'message' => __('sample_source.create_success')]);
|
|
||||||
} catch (\Exception $e){
|
|
||||||
return response()->json(['success' => false, 'message' => __('sample_source.create_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function update(Request $request){
|
|
||||||
try{
|
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['update_sample_source'])) return false;
|
|
||||||
$validator = \Validator::make($request->all(), [ 'name_en' => 'required']);
|
|
||||||
if ($validator->fails()) return response()->json(['success' => false, 'message' => __('sample_source.update_fail'), 'errors' => $validator->errors()->all()]);
|
|
||||||
$data = array(
|
|
||||||
'name_en' => $request->name_en,
|
|
||||||
'name_kh' => $request->name_kh,
|
|
||||||
'is_default' =>$request->is_default,
|
|
||||||
'updated_at' => date('Y-m-d H:i:s'),
|
|
||||||
'updated_by' => Auth::id()
|
|
||||||
);
|
|
||||||
$this->sampleSourceModel::query()->where('id', $request->uid)->update($data);
|
|
||||||
return response()->json(['success' => true, 'message' => __('sample_source.update_success')]);
|
|
||||||
} catch (\Exception $e){
|
|
||||||
return response()->json(['success' => false, 'message' => __('sample_source.update_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function get(Request $request){
|
|
||||||
try{
|
|
||||||
$sampleSource = $this->sampleSourceModel::query()->find($request->uid);
|
|
||||||
return response()->json(['success' => true, 'message' => __('sample_source.get_success'), 'data' => $sampleSource]);
|
|
||||||
} catch (\Exception $e){
|
|
||||||
return response()->json(['success' => false, 'message' => __('sample_source.get_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function delete(Request $request){
|
|
||||||
try{
|
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['delete_sample_source'])) return false;
|
|
||||||
$this->sampleSourceModel::query()->where('id', $request->uid)->update(array( BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::DELETE));
|
|
||||||
return response()->json(['success' => true, 'message' => __('sample_source.delete_success')]);
|
|
||||||
} catch (\Exception $e){
|
|
||||||
return response()->json(['success' => false, 'message' => __('sample_source.delete_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function restore(Request $request){
|
|
||||||
try{
|
|
||||||
$this->sampleSourceModel::query()->where('id', $request->uid)->update(array( BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE));
|
|
||||||
return response()->json(['success' => true, 'message' => __('sample_source.restore_success')]);
|
|
||||||
} catch (\Exception $e){
|
|
||||||
return response()->json(['success' => false, 'message' => __('sample_source.restore_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,133 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
|
||||||
use App\Enums\RecordStatusEnum;
|
|
||||||
use App\Http\Controllers\Helper\GlobalController;
|
|
||||||
use App\Models\BaseModel;
|
|
||||||
use App\Models\Department;
|
|
||||||
use App\Models\SampleType;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Illuminate\Support\Facades\Auth;
|
|
||||||
use Illuminate\Support\Facades\Session;
|
|
||||||
|
|
||||||
class SampleTypeController extends Controller
|
|
||||||
{
|
|
||||||
|
|
||||||
protected $model;
|
|
||||||
protected $departmentModel;
|
|
||||||
protected $sampleTypeModel;
|
|
||||||
|
|
||||||
protected $baseLabId;
|
|
||||||
protected $labs;
|
|
||||||
|
|
||||||
public function __construct(Department $departmentModel,SampleType $sampleTypeModel){
|
|
||||||
$this->departmentModel = $departmentModel;
|
|
||||||
$this->sampleTypeModel = $sampleTypeModel;
|
|
||||||
$this->baseLabId = Session::get('base_lab_id');
|
|
||||||
$this->base = Session::get('base_lab');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function index(Request $request){
|
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['view_sample_type'])) return redirect(url('my-profile'));
|
|
||||||
$standardSampleTypes = $this->sampleTypeModel::query()->where([BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE, 'is_standard' => 1])->get(['id','name_en'])->unique('name_en');
|
|
||||||
$departments = $this->departmentModel::query()->where(BaseModel::RECORD_STATUS_FIELD, RecordStatusEnum::ACTIVE)->where('lab_id', $this->baseLabId)->get();
|
|
||||||
$recordStatusCondition = Auth::id()==1 ? [RecordStatusEnum::DELETE, RecordStatusEnum::ACTIVE] : [RecordStatusEnum::ACTIVE];
|
|
||||||
$sampleTypes = $this->sampleTypeModel::with(['department'=>function($query) {return $query->orderBy('id','ASC');}])->whereIn(BaseModel::RECORD_STATUS_FIELD, $recordStatusCondition)
|
|
||||||
->where('lab_id', $this->baseLabId)
|
|
||||||
->when(!empty($request->kword), function ($sampleTypes) use($request, $recordStatusCondition){
|
|
||||||
$sampleTypes->whereRaw("replace(name_en, ' ','') like '%".str_replace(" ","",$request->kword)."%'")
|
|
||||||
->orWhereIn('department_id', $this->departmentModel::query()
|
|
||||||
->where('lab_id', $this->baseLabId)
|
|
||||||
->whereRaw("replace(name_en, ' ','') like '%".str_replace(" ","",$request->kword)."%'")->pluck('id')->toArray()
|
|
||||||
)->whereIn(BaseModel::RECORD_STATUS_FIELD, $recordStatusCondition);;
|
|
||||||
})->orderBy('weight','ASC')->paginate(config('labis.pagination.perpage', 10));
|
|
||||||
return view('sample-type', ['sampleTypes' => $sampleTypes, 'departments' => $departments, 'standardSampleTypes' => $standardSampleTypes]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function save(Request $request){
|
|
||||||
try {
|
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['create_sample_type'])) return false;
|
|
||||||
$validator = \Validator::make($request->all(), ['name_en' => 'required', 'department_id' => 'required']);
|
|
||||||
if ($validator->fails()) return response()->json(['success' => false, 'message' => __('sample_type.create_fail'), 'errors' => $validator->errors()->all()]);
|
|
||||||
$new = $this->sampleTypeModel::query()->firstOrNew(['name_en' => $request->name_en, 'department_id' => $request->department_id]);
|
|
||||||
$new->name_en = $request->name_en;
|
|
||||||
$new->weight = $request->weight;
|
|
||||||
$new->tube = $request->tube;
|
|
||||||
$new->bg_color = $request->bg_color;
|
|
||||||
$new->color = $request->color;
|
|
||||||
$new->lab_id = $this->baseLabId;
|
|
||||||
$new->department_id = $request->department_id;
|
|
||||||
$new->enter_form_id = $request->enter_form_id;
|
|
||||||
$new->preview_form_id = $request->preview_form_id;
|
|
||||||
$new->description = is_array($request->description) ? json_encode($request->description) : NULL;
|
|
||||||
$new->save();
|
|
||||||
|
|
||||||
return response()->json(['success' => true, 'message' => __('sample_type.create_success')]);
|
|
||||||
} catch (\Exception $e){
|
|
||||||
return response()->json(['success' => false, 'message' => __('sample_type.create_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function update(Request $request){
|
|
||||||
try{
|
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['update_sample_type'])) return false;
|
|
||||||
$validator = \Validator::make($request->all(), ['uid' => 'required', 'name_en' => 'required' /*,'department_ids' => 'required'*/]);
|
|
||||||
if ($validator->fails()) return response()->json(['success' => false, 'message' => __('sample_type.update_fail'), 'errors' => $validator->errors()->all()]);
|
|
||||||
$data = array(
|
|
||||||
'name_en' => $request->name_en,
|
|
||||||
'weight' => $request->weight,
|
|
||||||
'tube' => $request->tube,
|
|
||||||
'bg_color' => $request->bg_color,
|
|
||||||
'color' => $request->color,
|
|
||||||
'department_id' =>$request->department_id,
|
|
||||||
'enter_form_id' => $request->enter_form_id,
|
|
||||||
'preview_form_id' => $request->preview_form_id,
|
|
||||||
'description' => is_array($request->description) ? json_encode($request->description) : NULL
|
|
||||||
);
|
|
||||||
$this->sampleTypeModel::query()->where('id', $request->uid)->update($data);
|
|
||||||
return response()->json(['success' => true, 'message' => __('sample_type.update_success')]);
|
|
||||||
} catch (\Exception $e){
|
|
||||||
return response()->json(['success' => false, 'message' => __('sample_type.update_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function get(Request $request){
|
|
||||||
try{
|
|
||||||
$sampleType = $this->sampleTypeModel::query()->find($request->uid);
|
|
||||||
return response()->json(['success' => true, 'message' => __('sample_type.get_success'), 'data' => $sampleType]);
|
|
||||||
} catch (\Exception $e){
|
|
||||||
return response()->json(['success' => false, 'message' => __('sample_type.get_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function delete(Request $request){
|
|
||||||
try{
|
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['delete_sample_type'])) return false;
|
|
||||||
$this->sampleTypeModel::query()->where('id', $request->uid)->update(array('record_status_id'=> RecordStatusEnum::DELETE));
|
|
||||||
return response()->json(['success' => true, 'message' => __('sample_type.delete_success')]);
|
|
||||||
} catch (\Exception $e){
|
|
||||||
return response()->json(['success' => false, 'message' => __('sample_type.delete_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function restore(Request $request){
|
|
||||||
try{
|
|
||||||
$this->sampleTypeModel::query()->where('id', $request->uid)->update(array('record_status_id'=> RecordStatusEnum::ACTIVE));
|
|
||||||
return response()->json(['success' => true, 'message' => __('sample_type.restore_success')]);
|
|
||||||
} catch (\Exception $e){
|
|
||||||
return response()->json(['success' => false, 'message' => __('sample_type.restore_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getById($id){
|
|
||||||
try{
|
|
||||||
$sampleType = $this->sampleTypeModel::query()->find($id);
|
|
||||||
return response()->json(['success' => true, 'message' => __('sample_type.get_success'), 'data' => $sampleType]);
|
|
||||||
} catch (\Exception $e){
|
|
||||||
return response()->json(['success' => false, 'message' => __('sample_type.get_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -7,7 +7,7 @@ use App\Models\BaseModel;
|
|||||||
use App\Models\Comment;
|
use App\Models\Comment;
|
||||||
use App\Models\Department;
|
use App\Models\Department;
|
||||||
use App\Models\LabConfigure;
|
use App\Models\LabConfigure;
|
||||||
use App\Models\Laboratory;
|
use App\Models\Organization;
|
||||||
use App\Models\Patient;
|
use App\Models\Patient;
|
||||||
use App\Models\Physician;
|
use App\Models\Physician;
|
||||||
use App\Models\SampleSource;
|
use App\Models\SampleSource;
|
||||||
@@ -50,9 +50,9 @@ class ShareController extends Controller
|
|||||||
|
|
||||||
public function index($id){
|
public function index($id){
|
||||||
$sample = Sample::with(['patient','invoice'])->where(['id' => $id])->first();
|
$sample = Sample::with(['patient','invoice'])->where(['id' => $id])->first();
|
||||||
$labSettings = Laboratory::query()->find($sample->lab_id);
|
$labSettings = Organization::query()->find($sample->organization_id);
|
||||||
$samplePhysician = Physician::query()->where('id', $sample->physician_id)->first();
|
$samplePhysician = Physician::query()->where('id', $sample->physician_id)->first();
|
||||||
$labConfigures = $this->laboratoryConfigures::query()->where(['lab_id' => $sample->lab_id, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->get()->toArray();
|
$labConfigures = $this->laboratoryConfigures::query()->where(['organization_id' => $sample->organization_id, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->get()->toArray();
|
||||||
|
|
||||||
|
|
||||||
$preview_form_id = ($labSettings->lab_category_id==0? 1:2);
|
$preview_form_id = ($labSettings->lab_category_id==0? 1:2);
|
||||||
@@ -126,23 +126,23 @@ class ShareController extends Controller
|
|||||||
ifnull(pct.`partner_price`, 0.00) as partner_price,
|
ifnull(pct.`partner_price`, 0.00) as partner_price,
|
||||||
ts.weight,
|
ts.weight,
|
||||||
ts.is_bold,
|
ts.is_bold,
|
||||||
ts.lab_id,
|
ts.organization_id,
|
||||||
tr.test_date,
|
tr.test_date,
|
||||||
tr.comment,
|
tr.comment,
|
||||||
sd.sample_descr
|
sd.sample_descr
|
||||||
|
|
||||||
FROM samples s
|
FROM samples s
|
||||||
INNER JOIN patients p
|
INNER JOIN patients p
|
||||||
ON p.id = s.patient_id AND p.lab_id = s.lab_id
|
ON p.id = s.patient_id AND p.organization_id = s.organization_id
|
||||||
INNER JOIN test_results tr
|
INNER JOIN test_results tr
|
||||||
ON tr.`sample_id` = s.`id`
|
ON tr.`sample_id` = s.`id`
|
||||||
AND s.`lab_id` = tr.`lab_id`
|
AND s.`organization_id` = tr.`organization_id`
|
||||||
INNER JOIN test_samples ts
|
INNER JOIN test_samples ts
|
||||||
ON ts.id = tr.`test_sample_id`
|
ON ts.id = tr.`test_sample_id`
|
||||||
and ts.lab_id = tr.lab_id
|
and ts.organization_id = tr.organization_id
|
||||||
INNER JOIN tests t
|
INNER JOIN tests t
|
||||||
ON t.`id` = ts.`test_id`
|
ON t.`id` = ts.`test_id`
|
||||||
/*AND t.`lab_id` = ts.`lab_id`*/
|
/*AND t.`organization_id` = ts.`organization_id`*/
|
||||||
INNER JOIN sample_types st
|
INNER JOIN sample_types st
|
||||||
ON st.`id` = ts.`sample_type_id`
|
ON st.`id` = ts.`sample_type_id`
|
||||||
INNER JOIN departments d
|
INNER JOIN departments d
|
||||||
@@ -226,7 +226,7 @@ class ShareController extends Controller
|
|||||||
'str_comment' => (string) $row->comment,
|
'str_comment' => (string) $row->comment,
|
||||||
'is_bold' => (int) $row->is_bold,
|
'is_bold' => (int) $row->is_bold,
|
||||||
'ts' => $row->test_result,
|
'ts' => $row->test_result,
|
||||||
'lab_id' => $row->lab_id,
|
'organization_id' => $row->organization_id,
|
||||||
'format' => (int)$row->format
|
'format' => (int)$row->format
|
||||||
);
|
);
|
||||||
//dd($testItemArray);
|
//dd($testItemArray);
|
||||||
@@ -375,7 +375,7 @@ class ShareController extends Controller
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public function startAnonymousSession($hashLabId){
|
public function startAnonymousSession($hashLabId){
|
||||||
$this->base = Laboratory::query()->where(BaseModel::RECORD_STATUS_FIELD, BaseModel::RECORD_STATUS_ACTIVE)
|
$this->base = Organization::query()->where(BaseModel::RECORD_STATUS_FIELD, BaseModel::RECORD_STATUS_ACTIVE)
|
||||||
->where('allow_external_request', 1)
|
->where('allow_external_request', 1)
|
||||||
->whereRaw('MD5(id)="'.$hashLabId.'"')->first();
|
->whereRaw('MD5(id)="'.$hashLabId.'"')->first();
|
||||||
$provinces = Province::where('id','<>', 25)->orderBy('name_kh')->get();
|
$provinces = Province::where('id','<>', 25)->orderBy('name_kh')->get();
|
||||||
@@ -387,8 +387,8 @@ class ShareController extends Controller
|
|||||||
$patients = [];
|
$patients = [];
|
||||||
if(!empty(trim($request->term))){
|
if(!empty(trim($request->term))){
|
||||||
$patients = $this->patientModel::query()
|
$patients = $this->patientModel::query()
|
||||||
->where(['record_status_id' => 1, 'lab_id' => $labId])
|
->where(['record_status_id' => 1, 'organization_id' => $labId])
|
||||||
//->whereRaw('MD5(lab_id)="'.$hashLabId.'"')
|
//->whereRaw('MD5(organization_id)="'.$hashLabId.'"')
|
||||||
->when(!empty(trim($request->term)), function ($patients) use($request){
|
->when(!empty(trim($request->term)), function ($patients) use($request){
|
||||||
$patients->whereRaw("replace(name_en, ' ','') like '%".str_replace(" ","",$request->term)."%'");
|
$patients->whereRaw("replace(name_en, ' ','') like '%".str_replace(" ","",$request->term)."%'");
|
||||||
//->orWhereRaw("replace(phone_number, ' ','') like '%".str_replace(" ","",$request->term)."%'");
|
//->orWhereRaw("replace(phone_number, ' ','') like '%".str_replace(" ","",$request->term)."%'");
|
||||||
@@ -404,7 +404,7 @@ class ShareController extends Controller
|
|||||||
$patients = [];
|
$patients = [];
|
||||||
if(!empty(trim($request->term))){
|
if(!empty(trim($request->term))){
|
||||||
$patients = $this->patientModel::query()
|
$patients = $this->patientModel::query()
|
||||||
->where(['record_status_id' => 1, 'lab_id' => $labId])
|
->where(['record_status_id' => 1, 'organization_id' => $labId])
|
||||||
->when(!empty(trim($request->term)), function ($patients) use($request){
|
->when(!empty(trim($request->term)), function ($patients) use($request){
|
||||||
$patients->whereRaw("replace(phone_number, ' ','') like '%".str_replace(" ","",$request->term)."%'");
|
$patients->whereRaw("replace(phone_number, ' ','') like '%".str_replace(" ","",$request->term)."%'");
|
||||||
})->limit(3)->orderBy('phone_number', 'asc')->get();
|
})->limit(3)->orderBy('phone_number', 'asc')->get();
|
||||||
@@ -438,13 +438,13 @@ class ShareController extends Controller
|
|||||||
'name_en'=> $patient_name
|
'name_en'=> $patient_name
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$patientNumber = $this->generateAutoId(date('Y-m-d'), $request->short_name, $request->lab_id);
|
$patientNumber = $this->generateAutoId(date('Y-m-d'), $request->short_name, $request->organization_id);
|
||||||
$requests = $requests->merge(['patient_uuid' => $patientNumber]);
|
$requests = $requests->merge(['patient_uuid' => $patientNumber]);
|
||||||
$patient = $this->patientModel::query()->create($requests->all());
|
$patient = $this->patientModel::query()->create($requests->all());
|
||||||
DB::commit();
|
DB::commit();
|
||||||
|
|
||||||
$request->session()->put('anonymous_id', $patient->id);
|
$request->session()->put('anonymous_id', $patient->id);
|
||||||
$request->session()->put('base_lab_id', $patient->lab_id);
|
$request->session()->put('base_organization_id', $patient->organization_id);
|
||||||
if ($request->session()->has('anonymous_id')) {
|
if ($request->session()->has('anonymous_id')) {
|
||||||
return redirect(url('customer/'.$hashLabId.'?request-test'));
|
return redirect(url('customer/'.$hashLabId.'?request-test'));
|
||||||
}
|
}
|
||||||
@@ -459,7 +459,7 @@ class ShareController extends Controller
|
|||||||
|
|
||||||
public function generateAutoId($admissionDate, $labShortName, $labId){
|
public function generateAutoId($admissionDate, $labShortName, $labId){
|
||||||
$prefix = date('y',strtotime($admissionDate));
|
$prefix = date('y',strtotime($admissionDate));
|
||||||
$patientCount = $this->patientModel::query()->where('lab_id', $labId)->whereRaw('year(created_at) ="'. date('Y',strtotime($admissionDate)).'"')->count();
|
$patientCount = $this->patientModel::query()->where('organization_id', $labId)->whereRaw('year(created_at) ="'. date('Y',strtotime($admissionDate)).'"')->count();
|
||||||
if($labId==34) $patientCount = $patientCount+5; // solve problem when delete patient
|
if($labId==34) $patientCount = $patientCount+5; // solve problem when delete patient
|
||||||
return 'P-'.$labShortName.'-'.$prefix.'-'.(str_pad(($patientCount+1),5,'0',STR_PAD_LEFT));
|
return 'P-'.$labShortName.'-'.$prefix.'-'.(str_pad(($patientCount+1),5,'0',STR_PAD_LEFT));
|
||||||
}
|
}
|
||||||
@@ -472,7 +472,7 @@ class ShareController extends Controller
|
|||||||
$pattern = '/ /i';
|
$pattern = '/ /i';
|
||||||
$phoneNumber = $request->phone_number;// preg_replace($pattern, '', trim($request->phone_number));
|
$phoneNumber = $request->phone_number;// preg_replace($pattern, '', trim($request->phone_number));
|
||||||
$patient = $this->patientModel::query()->where(BaseModel::RECORD_STATUS_FIELD, BaseModel::RECORD_STATUS_ACTIVE)
|
$patient = $this->patientModel::query()->where(BaseModel::RECORD_STATUS_FIELD, BaseModel::RECORD_STATUS_ACTIVE)
|
||||||
->whereRaw('MD5(lab_id)="'.$hashLabId.'"')
|
->whereRaw('MD5(organization_id)="'.$hashLabId.'"')
|
||||||
->when(!empty($request->phone_number) && empty($request->patient_id), function($patient) use($request){
|
->when(!empty($request->phone_number) && empty($request->patient_id), function($patient) use($request){
|
||||||
$patient->whereRaw("replace(phone_number, ' ','') = '".str_replace(" ","",$request->phone_number)."'");
|
$patient->whereRaw("replace(phone_number, ' ','') = '".str_replace(" ","",$request->phone_number)."'");
|
||||||
})->when(!empty($request->patient_id), function($patient) use($request){
|
})->when(!empty($request->patient_id), function($patient) use($request){
|
||||||
@@ -485,7 +485,7 @@ class ShareController extends Controller
|
|||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$request->session()->put('anonymous_id', $patient->id);
|
$request->session()->put('anonymous_id', $patient->id);
|
||||||
$request->session()->put('base_lab_id', $patient->lab_id);
|
$request->session()->put('base_organization_id', $patient->organization_id);
|
||||||
if ($request->session()->has('anonymous_id')) {
|
if ($request->session()->has('anonymous_id')) {
|
||||||
return redirect(url('customer/'.$hashLabId));
|
return redirect(url('customer/'.$hashLabId));
|
||||||
}
|
}
|
||||||
@@ -495,7 +495,7 @@ class ShareController extends Controller
|
|||||||
public function anonymousLogOut(Request $request, $hashLabId){
|
public function anonymousLogOut(Request $request, $hashLabId){
|
||||||
if ($request->session()->has('anonymous_id')) {
|
if ($request->session()->has('anonymous_id')) {
|
||||||
$request->session()->forget('anonymous_id');
|
$request->session()->forget('anonymous_id');
|
||||||
$request->session()->forget('base_lab_id');
|
$request->session()->forget('base_organization_id');
|
||||||
return redirect(url('anonymous/'.$hashLabId));
|
return redirect(url('anonymous/'.$hashLabId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -507,16 +507,16 @@ class ShareController extends Controller
|
|||||||
}
|
}
|
||||||
$patient = $this->patientModel::query()
|
$patient = $this->patientModel::query()
|
||||||
->where(['id' => $request->session()->get('anonymous_id'), BaseModel::RECORD_STATUS_FIELD => BaseModel::RECORD_STATUS_ACTIVE])
|
->where(['id' => $request->session()->get('anonymous_id'), BaseModel::RECORD_STATUS_FIELD => BaseModel::RECORD_STATUS_ACTIVE])
|
||||||
->whereRaw('MD5(lab_id)="'.$hashLabId.'"')->first();
|
->whereRaw('MD5(organization_id)="'.$hashLabId.'"')->first();
|
||||||
$this->base = Laboratory::query()->where(BaseModel::RECORD_STATUS_FIELD, BaseModel::RECORD_STATUS_ACTIVE)
|
$this->base = Organization::query()->where(BaseModel::RECORD_STATUS_FIELD, BaseModel::RECORD_STATUS_ACTIVE)
|
||||||
->whereRaw('MD5(id)="'.$hashLabId.'"')->first();
|
->whereRaw('MD5(id)="'.$hashLabId.'"')->first();
|
||||||
$samples = $this->sampleModel::query()->where(BaseModel::RECORD_STATUS_FIELD, BaseModel::RECORD_STATUS_ACTIVE)
|
$samples = $this->sampleModel::query()->where(BaseModel::RECORD_STATUS_FIELD, BaseModel::RECORD_STATUS_ACTIVE)
|
||||||
->where('patient_id', $request->session()->get('anonymous_id'))
|
->where('patient_id', $request->session()->get('anonymous_id'))
|
||||||
->whereRaw('MD5(lab_id)="'.$hashLabId.'"')->orderBy(BaseModel::CREATED_AT_FIELD,'desc')->paginate(5);
|
->whereRaw('MD5(organization_id)="'.$hashLabId.'"')->orderBy(BaseModel::CREATED_AT_FIELD,'desc')->paginate(5);
|
||||||
$testGroups = $this->testGroupModel::with(['testGroupDetails'])->where([BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
$testGroups = $this->testGroupModel::with(['testGroupDetails'])->where([BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
||||||
->whereRaw('MD5(lab_id)="'.$hashLabId.'"')->orderBy('created_at')->get();
|
->whereRaw('MD5(organization_id)="'.$hashLabId.'"')->orderBy('created_at')->get();
|
||||||
$physicians = $this->physicianModel::query()->where([BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
$physicians = $this->physicianModel::query()->where([BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
||||||
->whereRaw('MD5(lab_id)="'.$hashLabId.'"')->orderBy('name_en')->get();
|
->whereRaw('MD5(organization_id)="'.$hashLabId.'"')->orderBy('name_en')->get();
|
||||||
return view('shared.patient_profile',
|
return view('shared.patient_profile',
|
||||||
[
|
[
|
||||||
'patient' => $patient,
|
'patient' => $patient,
|
||||||
@@ -537,8 +537,8 @@ class ShareController extends Controller
|
|||||||
return redirect(url('anonymous/'.$hashLabId));
|
return redirect(url('anonymous/'.$hashLabId));
|
||||||
}
|
}
|
||||||
$sample = $this->sampleModel::with(['patient','invoice'])->where(BaseModel::RECORD_STATUS_FIELD, BaseModel::RECORD_STATUS_ACTIVE)
|
$sample = $this->sampleModel::with(['patient','invoice'])->where(BaseModel::RECORD_STATUS_FIELD, BaseModel::RECORD_STATUS_ACTIVE)
|
||||||
->whereRaw('MD5(lab_id)="'.$hashLabId.'" AND MD5(id)="'.$hashSampleId.'"')->first();
|
->whereRaw('MD5(organization_id)="'.$hashLabId.'" AND MD5(id)="'.$hashSampleId.'"')->first();
|
||||||
$this->base = Laboratory::query()->where(BaseModel::RECORD_STATUS_FIELD, BaseModel::RECORD_STATUS_ACTIVE)
|
$this->base = Organization::query()->where(BaseModel::RECORD_STATUS_FIELD, BaseModel::RECORD_STATUS_ACTIVE)
|
||||||
->whereRaw('MD5(id)="'.$hashLabId.'"')->first();
|
->whereRaw('MD5(id)="'.$hashLabId.'"')->first();
|
||||||
$labConfigures = $this->laboratoryConfigures::query()
|
$labConfigures = $this->laboratoryConfigures::query()
|
||||||
->where([BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
->where([BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
||||||
@@ -564,20 +564,20 @@ class ShareController extends Controller
|
|||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
try{
|
try{
|
||||||
$sample = $this->sampleModel::query()->where(BaseModel::RECORD_STATUS_FIELD, BaseModel::RECORD_STATUS_ACTIVE)
|
$sample = $this->sampleModel::query()->where(BaseModel::RECORD_STATUS_FIELD, BaseModel::RECORD_STATUS_ACTIVE)
|
||||||
->whereRaw('MD5(lab_id)="'.$hashLabId.'" AND MD5(id)="'.$hashSampleId.'"')->first();
|
->whereRaw('MD5(organization_id)="'.$hashLabId.'" AND MD5(id)="'.$hashSampleId.'"')->first();
|
||||||
|
|
||||||
$requestedSample = [];
|
$requestedSample = [];
|
||||||
if(!empty($sample)){
|
if(!empty($sample)){
|
||||||
$reSampleArray = array(
|
$reSampleArray = array(
|
||||||
'patient_id' => $sample->patient_id,
|
'patient_id' => $sample->patient_id,
|
||||||
'sample_number' => $this->generateSampleNumber($sample->lab_id, date('Y-m-d H:i:s')),
|
'sample_number' => $this->generateSampleNumber($sample->organization_id, date('Y-m-d H:i:s')),
|
||||||
'admission_date' => date('Y-m-d H:i:s'),
|
'admission_date' => date('Y-m-d H:i:s'),
|
||||||
'sample_source_id' => $sample->sample_source_id,
|
'sample_source_id' => $sample->sample_source_id,
|
||||||
'physician_id' => $sample->physician_id,
|
'physician_id' => $sample->physician_id,
|
||||||
'requested_date' => date('Y-m-d H:i:s'),
|
'requested_date' => date('Y-m-d H:i:s'),
|
||||||
'collected_date' => date('Y-m-d H:i:s'),
|
'collected_date' => date('Y-m-d H:i:s'),
|
||||||
'is_accept_request' => 0,
|
'is_accept_request' => 0,
|
||||||
'lab_id' => $sample->lab_id,
|
'organization_id' => $sample->organization_id,
|
||||||
'created_at' => date('Y-m-d H:i:s'),
|
'created_at' => date('Y-m-d H:i:s'),
|
||||||
'created_by' => $sample->patient_id,
|
'created_by' => $sample->patient_id,
|
||||||
);
|
);
|
||||||
@@ -586,7 +586,7 @@ class ShareController extends Controller
|
|||||||
$previousTests = $this->testResultModel::query()->where([
|
$previousTests = $this->testResultModel::query()->where([
|
||||||
BaseModel::RECORD_STATUS_FIELD => BaseModel::RECORD_STATUS_ACTIVE,
|
BaseModel::RECORD_STATUS_FIELD => BaseModel::RECORD_STATUS_ACTIVE,
|
||||||
'sample_id' => $sample->id,
|
'sample_id' => $sample->id,
|
||||||
'lab_id' => $sample->lab_id
|
'organization_id' => $sample->organization_id
|
||||||
])->get();
|
])->get();
|
||||||
if(!empty($requestedSample) && !empty($previousTests)){
|
if(!empty($requestedSample) && !empty($previousTests)){
|
||||||
$items = [];
|
$items = [];
|
||||||
@@ -597,7 +597,7 @@ class ShareController extends Controller
|
|||||||
'test_result' => NULL,
|
'test_result' => NULL,
|
||||||
'created_at' => date('Y-m-d H:i:s'),
|
'created_at' => date('Y-m-d H:i:s'),
|
||||||
'created_by' => $sample->patient_id,
|
'created_by' => $sample->patient_id,
|
||||||
'lab_id' => $previousItem->lab_id
|
'organization_id' => $previousItem->organization_id
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$this->testResultModel::query()->insert($items);
|
$this->testResultModel::query()->insert($items);
|
||||||
@@ -612,11 +612,11 @@ class ShareController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function generateSampleNumber($labId, $admissionDate){
|
public function generateSampleNumber($labId, $admissionDate){
|
||||||
$this->base = Laboratory::query()->where(BaseModel::RECORD_STATUS_FIELD, BaseModel::RECORD_STATUS_ACTIVE)
|
$this->base = Organization::query()->where(BaseModel::RECORD_STATUS_FIELD, BaseModel::RECORD_STATUS_ACTIVE)
|
||||||
->where('id', $labId)->first();
|
->where('id', $labId)->first();
|
||||||
$prefix = date('ymd',strtotime($admissionDate));
|
$prefix = date('ymd',strtotime($admissionDate));
|
||||||
$sample = Sample::query();
|
$sample = Sample::query();
|
||||||
$sampleCount = $sample->where('lab_id', $labId)->whereRaw('date(admission_date) ="'. date('Y-m-d',strtotime($admissionDate)).'"')->count();
|
$sampleCount = $sample->where('organization_id', $labId)->whereRaw('date(admission_date) ="'. date('Y-m-d',strtotime($admissionDate)).'"')->count();
|
||||||
return 'S-'.$this->base['short_name'].'-'.$prefix.'-'.(str_pad(($sampleCount+1),3,'0',STR_PAD_LEFT));
|
return 'S-'.$this->base['short_name'].'-'.$prefix.'-'.(str_pad(($sampleCount+1),3,'0',STR_PAD_LEFT));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -624,7 +624,7 @@ class ShareController extends Controller
|
|||||||
function getTestItem(Request $request){
|
function getTestItem(Request $request){
|
||||||
try{
|
try{
|
||||||
$departments = $this->departmentModel::with(['samples','samples.testSamples.test','samples.testSamples.childTest'])
|
$departments = $this->departmentModel::with(['samples','samples.testSamples.test','samples.testSamples.childTest'])
|
||||||
->where(['lab_id' => $request->session()->get('base_lab_id'), BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
->where(['organization_id' => $request->session()->get('base_organization_id'), BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
||||||
->orderBy('weight', 'asc')->get();
|
->orderBy('weight', 'asc')->get();
|
||||||
return response()->json(['success'=> true , 'data' => SampleTestResource::collection($departments)]);
|
return response()->json(['success'=> true , 'data' => SampleTestResource::collection($departments)]);
|
||||||
} catch (\Exception $e){
|
} catch (\Exception $e){
|
||||||
@@ -641,11 +641,11 @@ class ShareController extends Controller
|
|||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
try{
|
try{
|
||||||
|
|
||||||
$labId = $sampleCreateRequest->session()->get('base_lab_id');
|
$labId = $sampleCreateRequest->session()->get('base_organization_id');
|
||||||
$patientId = $sampleCreateRequest->session()->get('anonymous_id');
|
$patientId = $sampleCreateRequest->session()->get('anonymous_id');
|
||||||
|
|
||||||
$sampleSourceId = SampleSource::where(['lab_id' => $labId, 'is_default' => 1, 'record_status_id' => 1])->get()->first();
|
$sampleSourceId = SampleSource::where(['organization_id' => $labId, 'is_default' => 1, 'record_status_id' => 1])->get()->first();
|
||||||
//$physicianId = Physician::where(['lab_id' => $labId, 'is_default' => 1, 'record_status_id' => 1])->get()->first();
|
//$physicianId = Physician::where(['organization_id' => $labId, 'is_default' => 1, 'record_status_id' => 1])->get()->first();
|
||||||
|
|
||||||
// create sample first
|
// create sample first
|
||||||
$sampleRequest = array(
|
$sampleRequest = array(
|
||||||
@@ -658,17 +658,17 @@ class ShareController extends Controller
|
|||||||
'received_date' => date('Y-m-d H:i:s'),
|
'received_date' => date('Y-m-d H:i:s'),
|
||||||
'collected_date' => date('Y-m-d H:i:s'),
|
'collected_date' => date('Y-m-d H:i:s'),
|
||||||
'is_accept_request' => 0,
|
'is_accept_request' => 0,
|
||||||
'lab_id' => $labId,
|
'organization_id' => $labId,
|
||||||
'created_at' => date('Y-m-d H:i:s'),
|
'created_at' => date('Y-m-d H:i:s'),
|
||||||
'created_by' => $patientId,
|
'created_by' => $patientId,
|
||||||
);
|
);
|
||||||
|
|
||||||
$requestedSample = $this->sampleModel::query()->create($sampleRequest);
|
$requestedSample = $this->sampleModel::query()->create($sampleRequest);
|
||||||
|
|
||||||
//$this->sampleDetailModel::query()->where(['sample_id' => $requestedSample->id, 'lab_id' => $labId])->update(array(BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::DELETE));
|
//$this->sampleDetailModel::query()->where(['sample_id' => $requestedSample->id, 'organization_id' => $labId])->update(array(BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::DELETE));
|
||||||
if(!empty($requestedSample)) {
|
if(!empty($requestedSample)) {
|
||||||
if (!empty($sampleCreateRequest->sample_tests)) {
|
if (!empty($sampleCreateRequest->sample_tests)) {
|
||||||
/*$this->testResultModel::query()->where(['sample_id' => $requestedSample->id, 'lab_id' => $labId])
|
/*$this->testResultModel::query()->where(['sample_id' => $requestedSample->id, 'organization_id' => $labId])
|
||||||
->whereNotIn('test_sample_id', $sampleCreateRequest->sample_tests)
|
->whereNotIn('test_sample_id', $sampleCreateRequest->sample_tests)
|
||||||
->delete();*/
|
->delete();*/
|
||||||
foreach ($sampleCreateRequest->sample_tests as $test) {
|
foreach ($sampleCreateRequest->sample_tests as $test) {
|
||||||
@@ -677,12 +677,12 @@ class ShareController extends Controller
|
|||||||
'test_sample_id' => $test,
|
'test_sample_id' => $test,
|
||||||
'created_at' => date('Y-m-d H:i:s'),
|
'created_at' => date('Y-m-d H:i:s'),
|
||||||
'created_by' => $patientId,
|
'created_by' => $patientId,
|
||||||
'lab_id' => $labId,
|
'organization_id' => $labId,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*else {
|
/*else {
|
||||||
$this->testResultModel::query()->where(['sample_id' => $sampleCreateRequest->sample_id, 'lab_id' => $this->baseLabId])->delete();
|
$this->testResultModel::query()->where(['sample_id' => $sampleCreateRequest->sample_id, 'organization_id' => $this->baseOrganizationId])->delete();
|
||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -697,7 +697,7 @@ class ShareController extends Controller
|
|||||||
|
|
||||||
public function getTestGroup($id, $labId){
|
public function getTestGroup($id, $labId){
|
||||||
try{
|
try{
|
||||||
$testGroupItems = $this->testGroupDetailModel::query()->where(['test_group_id' => $id, 'lab_id' => $labId, 'record_status_id'=> 1])->get()->pluck('test_sample_id')->toArray();
|
$testGroupItems = $this->testGroupDetailModel::query()->where(['test_group_id' => $id, 'organization_id' => $labId, 'record_status_id'=> 1])->get()->pluck('test_sample_id')->toArray();
|
||||||
return response()->json(['success' => true, 'data' => $testGroupItems]);
|
return response()->json(['success' => true, 'data' => $testGroupItems]);
|
||||||
} catch (\Exception $e)
|
} catch (\Exception $e)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,88 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
|
||||||
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
use Telegram\Bot\Api;
|
|
||||||
use Telegram\Bot\Laravel\Facades\Telegram;
|
|
||||||
|
|
||||||
class TelegramController extends Controller
|
|
||||||
{
|
|
||||||
|
|
||||||
public function handle(Request $request)
|
|
||||||
{
|
|
||||||
try{
|
|
||||||
$telegram = new Api(env('TELEGRAM_BOT_TOKEN'));
|
|
||||||
$update = $telegram->getWebhookUpdate();
|
|
||||||
|
|
||||||
if ($update->getMessage()) {
|
|
||||||
$chatId = $update->getMessage()->getChat()->getId();
|
|
||||||
$text = $update->getMessage()->getText();
|
|
||||||
$patientId = null;
|
|
||||||
$sampleSourceId = null;
|
|
||||||
if ($text && str_starts_with($text, "/start")) {
|
|
||||||
$parts = explode(" ", $text);
|
|
||||||
$individualType = 'patient';
|
|
||||||
if (count($parts) > 1) {
|
|
||||||
$fullText = explode("_", $parts[1]);
|
|
||||||
if(count($fullText) > 1){
|
|
||||||
$sampleSourceId = trim($fullText[1]);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
$patientId = trim($parts[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($patientId) {
|
|
||||||
// Check if patient already registered
|
|
||||||
$exists = DB::table('patient_telegram')
|
|
||||||
->where('patient_id', $patientId)
|
|
||||||
->exists();
|
|
||||||
|
|
||||||
if (!$exists) {
|
|
||||||
DB::table('patient_telegram')->updateOrInsert(
|
|
||||||
['patient_id' => $patientId],
|
|
||||||
['chat_id' => $chatId]
|
|
||||||
);
|
|
||||||
|
|
||||||
$telegram->sendMessage([
|
|
||||||
'chat_id' => $chatId,
|
|
||||||
'text' => "✅ Thank you for joining our bot. You will receive future laboratory results here."
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// for sample source
|
|
||||||
if ($sampleSourceId)
|
|
||||||
{
|
|
||||||
// Check if patient already registered
|
|
||||||
$exist_sample_source = DB::table('sample_source_telegram')
|
|
||||||
->where('sample_source_id', $sampleSourceId)
|
|
||||||
->exists();
|
|
||||||
|
|
||||||
if (!$exist_sample_source) {
|
|
||||||
DB::table('sample_source_telegram')->updateOrInsert(
|
|
||||||
['sample_source_id' => $sampleSourceId],
|
|
||||||
['chat_id' => $chatId]
|
|
||||||
);
|
|
||||||
|
|
||||||
$telegram->sendMessage([
|
|
||||||
'chat_id' => $chatId,
|
|
||||||
'text' => "✅ Thank you for joining our bot. You will receive future laboratory results here."
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return response()->json(['status' => 'ok'], 200);
|
|
||||||
}
|
|
||||||
catch(\Exception $e){
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,487 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
|
||||||
use App\Enums\RecordStatusEnum;
|
|
||||||
use App\Http\Controllers\Helper\GlobalController;
|
|
||||||
use App\Http\Requests\TestSampleCreateRequest;
|
|
||||||
use App\Http\Requests\UpdateRequests\TestSampleUpdateRequest;
|
|
||||||
use App\Http\Resources\TestSampleResource;
|
|
||||||
use App\Models\Antibiotic;
|
|
||||||
use App\Models\BaseModel;
|
|
||||||
use App\Models\Department;
|
|
||||||
use App\Models\Organism;
|
|
||||||
use App\Models\PatientType;
|
|
||||||
use App\Models\Physician;
|
|
||||||
use App\Models\PhysicianCommission;
|
|
||||||
use App\Models\SampleType;
|
|
||||||
use App\Models\Test;
|
|
||||||
use App\Models\TestCategory;
|
|
||||||
use App\Models\TestNormalValue;
|
|
||||||
use App\Models\TestSample;
|
|
||||||
use App\Models\TestSampleOrganism;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Illuminate\Support\Facades\Auth;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
use Illuminate\Support\Facades\Session;
|
|
||||||
|
|
||||||
use App\Models\Laboratory;
|
|
||||||
|
|
||||||
class TestController extends Controller
|
|
||||||
{
|
|
||||||
|
|
||||||
protected $model;
|
|
||||||
protected $departmentModel;
|
|
||||||
protected $sampleTypeModel;
|
|
||||||
protected $patientTypeModel;
|
|
||||||
protected $testModel;
|
|
||||||
protected $organismModel;
|
|
||||||
protected $antibioticModel;
|
|
||||||
protected $testSampleOrganismModel;
|
|
||||||
protected $testSampleOrganismAntibioticModel;
|
|
||||||
protected $testNormalValueModel;
|
|
||||||
protected $physicianModel;
|
|
||||||
protected $physicianCommissionModel;
|
|
||||||
protected $labModel;
|
|
||||||
|
|
||||||
protected $baseLabId;
|
|
||||||
protected $labs;
|
|
||||||
protected $base;
|
|
||||||
protected $testCategoryModel;
|
|
||||||
|
|
||||||
public function __construct(TestSample $testSample, Department $departmentModel, PhysicianCommission $physicianCommissionModel,
|
|
||||||
TestSampleOrganism $testSampleOrganismModel,SampleType $sampleTypeModel,
|
|
||||||
PatientType $patientTypeModel,Test $testModel, Organism $organismModel,
|
|
||||||
Antibiotic $antibioticModel,
|
|
||||||
TestNormalValue $testNormalValueModel, Physician $physicianModel, Laboratory $labModel
|
|
||||||
){
|
|
||||||
$this->model = $testSample;
|
|
||||||
$this->departmentModel = $departmentModel;
|
|
||||||
$this->sampleTypeModel = $sampleTypeModel;
|
|
||||||
$this->patientTypeModel = $patientTypeModel;
|
|
||||||
$this->testModel = $testModel;
|
|
||||||
$this->organismModel = $organismModel;
|
|
||||||
$this->antibioticModel = $antibioticModel;
|
|
||||||
$this->testSampleOrganismModel = $testSampleOrganismModel;
|
|
||||||
$this->testNormalValueModel = $testNormalValueModel;
|
|
||||||
$this->physicianModel = $physicianModel;
|
|
||||||
$this->physicianCommissionModel = $physicianCommissionModel;
|
|
||||||
$this->labModel = $labModel;
|
|
||||||
$this->testCategoryModel = new TestCategory();
|
|
||||||
|
|
||||||
$this->baseLabId = Session::get('base_lab_id');
|
|
||||||
$this->base = Session::get('base_lab');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function index(Request $request){
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function save(Request $request){
|
|
||||||
try{
|
|
||||||
$validator = \Validator::make($request->all(), ['name_en' => 'required']);
|
|
||||||
if ($validator->fails()){ return response()->json(['errors'=>$validator->errors()->all()]);}
|
|
||||||
$test = $this->testModel::query()->create([
|
|
||||||
'name_en' => $request->name_en,
|
|
||||||
'lab_id' => $this->baseLabId,
|
|
||||||
]);
|
|
||||||
return response()->json(['success'=> true , 'data' => [$test]]);
|
|
||||||
} catch (\Exception $e)
|
|
||||||
{
|
|
||||||
return response()->json(['success'=> false , 'errors' => [$e->getMessage()]]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function update(Request $request){
|
|
||||||
try{
|
|
||||||
$validator = \Validator::make($request->all(), ['uid' => 'required', 'name_en' => 'required']);
|
|
||||||
if ($validator->fails()){ return response()->json(['errors'=>$validator->errors()->all()]);}
|
|
||||||
$test = $this->testModel::query()->where(['id' => $request->uid])->first();
|
|
||||||
$test->update(array('name_en' => $request->name_en));
|
|
||||||
return response()->json(['success'=> true , 'data' => [$test]]);
|
|
||||||
} catch (\Exception $e)
|
|
||||||
{
|
|
||||||
return response()->json(['success'=> false , 'errors' => [$e->getMessage()]]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function get(Request $request){
|
|
||||||
try{
|
|
||||||
$test = Test::query()->find($request->uid);
|
|
||||||
return response()->json(['data' => $test]);
|
|
||||||
} catch (\Exception $e)
|
|
||||||
{
|
|
||||||
return response()->json(['success'=> false , 'errors' => [$e->getMessage()]]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function delete(Request $request){
|
|
||||||
$status = $this->testModel::query()->where('id', $request->uid)->update(array(BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::DELETE));
|
|
||||||
return response()->json(['status'=> $status , 'msg' => 'Delete successful']);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function restore(Request $request){
|
|
||||||
$status = $this->testModel::query()->where('id', $request->uid)->update(array(BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE));
|
|
||||||
return response()->json(['status'=> $status , 'msg' => 'Activate successful']);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** TEST SAMPLES
|
|
||||||
* @param Request $request
|
|
||||||
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
|
|
||||||
*/
|
|
||||||
|
|
||||||
public function testSamples(Request $request){
|
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['view_test_sample'])) return redirect(url('my-profile'));
|
|
||||||
$physicians = $this->physicianModel::query()->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->get();
|
|
||||||
$department = $this->departmentModel::query()->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->orderBy('weight','asc')->get();
|
|
||||||
$patientTypes = $this->patientTypeModel::query()->where(BaseModel::RECORD_STATUS_FIELD, RecordStatusEnum::ACTIVE)->get();
|
|
||||||
$testItems = $this->testModel::query()->where(BaseModel::RECORD_STATUS_FIELD, RecordStatusEnum::ACTIVE)->get();
|
|
||||||
$testSampleTable = $this->model::getTableNameByScheme();
|
|
||||||
$sampleTypeTable = $this->sampleTypeModel::getTableNameByScheme();
|
|
||||||
$departmentTable = $this->departmentModel::getTableNameByScheme();
|
|
||||||
$testTable = $this->testModel::getTableNameByScheme();
|
|
||||||
$testSamples = $this->model::query()->select([
|
|
||||||
$departmentTable.'.name_en as department_name',
|
|
||||||
$sampleTypeTable.'.name_en as sample_type_name',
|
|
||||||
$testTable.'.name_en as test_name',
|
|
||||||
$testSampleTable.'.*'
|
|
||||||
])
|
|
||||||
->join($sampleTypeTable, $testSampleTable.'.sample_type_id', '=', $sampleTypeTable.'.id')
|
|
||||||
->join($departmentTable, $sampleTypeTable.'.department_id', '=', $departmentTable.'.id')
|
|
||||||
->join($testTable, $testSampleTable.'.test_id', '=', $testTable.'.id')
|
|
||||||
->where($testSampleTable.'.'.BaseModel::RECORD_STATUS_FIELD, RecordStatusEnum::ACTIVE)
|
|
||||||
->where($testSampleTable.'.lab_id', $this->baseLabId)
|
|
||||||
->where($sampleTypeTable.'.'.BaseModel::RECORD_STATUS_FIELD, RecordStatusEnum::ACTIVE)
|
|
||||||
->when(!empty($request->sample_type), function ($query) use($sampleTypeTable, $request){
|
|
||||||
$query->where($sampleTypeTable.'.id', $request->sample_type);
|
|
||||||
})->when(!empty($request->department), function ($query) use($departmentTable, $request) {
|
|
||||||
$query->where($departmentTable.'.id', $request->department);
|
|
||||||
})->when(!empty($request->kword), function ($query) use($testTable, $testSampleTable, $request){
|
|
||||||
$query->whereRaw( $testTable.".name_en like '%".addslashes($request->kword)."%'")
|
|
||||||
->orWhereRaw($testSampleTable.".code like '%".addslashes($request->kword)."%'");
|
|
||||||
})->when(Auth::id()==1, function ($query) use ($testSampleTable){
|
|
||||||
$query->whereIn($testSampleTable.'.'.BaseModel::RECORD_STATUS_FIELD , [RecordStatusEnum::DELETE, RecordStatusEnum::ACTIVE]);
|
|
||||||
})->orderBy($departmentTable.'.weight')
|
|
||||||
->orderBy($sampleTypeTable.'.weight')
|
|
||||||
->orderBy($testSampleTable.'.weight')
|
|
||||||
->paginate(20);
|
|
||||||
return view('test', ['testSamples' => $testSamples, 'departments' => $department,
|
|
||||||
'testItems' => $testItems, 'patientTypes' => $patientTypes, 'labSetting' => (object) $this->base,
|
|
||||||
'physicians' => $physicians
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function saveTestSample(TestSampleCreateRequest $request){
|
|
||||||
set_time_limit(6000);
|
|
||||||
ini_set('memory_limit', '10240M');
|
|
||||||
DB::beginTransaction();
|
|
||||||
try{
|
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['create_test_sample'])) return false;
|
|
||||||
$testSample = $this->model::query()->create([
|
|
||||||
'sample_type_id' => $request->sample_type_id,
|
|
||||||
'test_id' => $request->test_id,
|
|
||||||
'group_result' => $request->group_result,
|
|
||||||
'category' => NULL,
|
|
||||||
'unit_sign' => $request->unit_sign,
|
|
||||||
'code' => $request->code,
|
|
||||||
'heading_id' => $request->heading_id,
|
|
||||||
'usd_price' => $request->usd_price,
|
|
||||||
'weight' => $request->weight,
|
|
||||||
'field_type' => $request->filed_type_id,
|
|
||||||
'formula' => $request->formula,
|
|
||||||
'format' => $request->format_value,
|
|
||||||
'description' => $request->description,
|
|
||||||
'lab_id' => $this->baseLabId,
|
|
||||||
'is_bold' => $request->is_bold,
|
|
||||||
'autocomplete_bind' => $request->autocomplete_bind
|
|
||||||
]);
|
|
||||||
// reference range
|
|
||||||
if(in_array($request->filed_type_id,[1,4,6])){
|
|
||||||
$data = collect($request->patient_type_ids);
|
|
||||||
$items = $data->map(function ($row, $key) use ($request, $testSample) {
|
|
||||||
if(!empty($request->patient_type_ids[$key]['value'])) {
|
|
||||||
$testNormalValue = $this->testNormalValueModel::query()->create([
|
|
||||||
'test_sample_id' => $testSample->id,
|
|
||||||
'patient_type_id' => $request->patient_type_ids[$key]['value'],
|
|
||||||
'sign' => $request->signs[$key]['value'],
|
|
||||||
'minimum' => is_numeric($request->min_values[$key]['value']) ? $request->min_values[$key]['value'] : null,
|
|
||||||
'maximum' => is_numeric($request->max_values[$key]['value']) ? $request->max_values[$key]['value'] : null,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
return [];
|
|
||||||
});
|
|
||||||
}
|
|
||||||
// organism and antibiotics
|
|
||||||
if(in_array($request->filed_type_id,[2,3]) ){
|
|
||||||
$organismsCollection = collect($request->organisms);
|
|
||||||
foreach ($organismsCollection as $org){
|
|
||||||
$this->testSampleOrganismModel::query()->create([
|
|
||||||
'test_sample_id' => $testSample->id,
|
|
||||||
'is_default' => $org['is_default'],
|
|
||||||
'organism_id' => $org['id'],
|
|
||||||
'lab_id' => $this->baseLabId
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
DB::commit();
|
|
||||||
return response()->json(['success' => true, 'message' => __('test_sample.create_success'), 'data' => [$testSample]]);
|
|
||||||
} catch (\Exception $e){
|
|
||||||
DB::rollBack();
|
|
||||||
return response()->json(['success'=> false, 'message' => __('test_sample.create_fail'), 'errors' => [$e->getMessage()]]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getTestSample(Request $request){
|
|
||||||
$testSample = $this->model::with([
|
|
||||||
'sample',
|
|
||||||
'organisms.organism',
|
|
||||||
'testValues'
|
|
||||||
])->find($request->uid);
|
|
||||||
return response()->json(['success'=> true , 'message' => __('test_sample.get_success'), 'data' => new TestSampleResource($testSample)]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function updateTestSample(TestSampleUpdateRequest $request){
|
|
||||||
|
|
||||||
set_time_limit(6000);
|
|
||||||
ini_set('memory_limit', '10240M');
|
|
||||||
DB::beginTransaction();
|
|
||||||
try{
|
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['update_test_sample'])) return false;
|
|
||||||
$testSample = $this->model::query()->where('id',$request->uid)->first();
|
|
||||||
$testSample->update([
|
|
||||||
'sample_type_id' => $request->sample_type_id,
|
|
||||||
'test_id' => $request->test_id,
|
|
||||||
'group_result' => $request->group_result,
|
|
||||||
'category' => @$request->category,
|
|
||||||
'unit_sign' => $request->unit_sign,
|
|
||||||
'code' => $request->code,
|
|
||||||
'heading_id' => $request->heading_id,
|
|
||||||
'usd_price' => $request->usd_price,
|
|
||||||
'weight' => $request->weight,
|
|
||||||
'field_type' => $request->filed_type_id,
|
|
||||||
'formula' => $request->formula,
|
|
||||||
'format' => $request->format_value,
|
|
||||||
'description' => $request->description,
|
|
||||||
'is_bold' => $request->is_bold,
|
|
||||||
'autocomplete_bind' => $request->autocomplete_bind
|
|
||||||
]);
|
|
||||||
|
|
||||||
$this->testNormalValueModel::query()->where('test_sample_id', $testSample->id)->update([BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::DELETE]);
|
|
||||||
$this->testSampleOrganismModel::query()->where('test_sample_id', $testSample->id)->update([BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::DELETE]);
|
|
||||||
|
|
||||||
// reference range
|
|
||||||
if(in_array($request->filed_type_id,[1,4,6])){
|
|
||||||
$data = collect($request->patient_type_ids);
|
|
||||||
$items = $data->map(function ($row, $key) use ($request, $testSample) {
|
|
||||||
if(!empty($request->patient_type_ids[$key]['value'])) {
|
|
||||||
$testNormalValue = $this->testNormalValueModel::query()->create([
|
|
||||||
'test_sample_id' => $testSample->id,
|
|
||||||
'patient_type_id' => $request->patient_type_ids[$key]['value'],
|
|
||||||
'sign' => $request->signs[$key]['value'],
|
|
||||||
'minimum' => is_numeric($request->min_values[$key]['value']) ? $request->min_values[$key]['value'] : null,
|
|
||||||
'maximum' => is_numeric($request->max_values[$key]['value']) ? $request->max_values[$key]['value'] : null,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
return [];
|
|
||||||
});
|
|
||||||
}
|
|
||||||
// organism and antibiotics
|
|
||||||
if(in_array($request->filed_type_id,[2,3]) ){
|
|
||||||
$organismsCollection = collect($request->organisms);
|
|
||||||
$organisms = $organismsCollection->pluck('id')->unique()->toArray();
|
|
||||||
$this->testSampleOrganismModel::query()->where(['test_sample_id' => $testSample->id])
|
|
||||||
->whereNotIn('organism_id', $organisms)
|
|
||||||
->update([BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::DELETE]);
|
|
||||||
|
|
||||||
foreach ($organismsCollection as $org){
|
|
||||||
$testSampleOrganism = $this->testSampleOrganismModel::query()->create([
|
|
||||||
'test_sample_id' => $testSample->id,
|
|
||||||
'is_default' => $org['is_default'],
|
|
||||||
'organism_id' => $org['id'],
|
|
||||||
'lab_id' => $this->baseLabId
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
DB::commit();
|
|
||||||
return response()->json(['success' => true, 'message' => __('test_sample.update_success'), 'data' => [$testSample]]);
|
|
||||||
} catch (\Exception $e){
|
|
||||||
DB::rollBack();
|
|
||||||
return response()->json(['success' => false, 'message' => __('test_sample.update_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function editTestSampleOrder(Request $request){
|
|
||||||
DB::beginTransaction();
|
|
||||||
try{
|
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['update_test_sample'])) return false;
|
|
||||||
$validator = \Validator::make($request->all(), ['id' => 'required', 'order_number' => 'required']);
|
|
||||||
if ($validator->fails()){ return response()->json(['errors'=>$validator->errors()->all()]);}
|
|
||||||
|
|
||||||
$testSample = $this->model::query()->where([
|
|
||||||
'id' => $request->id,
|
|
||||||
'lab_id' => $this->baseLabId
|
|
||||||
])->first();
|
|
||||||
$testSample->update(['weight' => $request->order_number]);
|
|
||||||
$batchUpdates = $this->model::query()->where([
|
|
||||||
'sample_type_id' => $testSample->sample_type_id,
|
|
||||||
'lab_id' => $this->baseLabId,
|
|
||||||
])->where('weight','>=', $request->order_number)->where('id','<>', $request->id)->update([
|
|
||||||
'weight' => DB::raw('weight + 1')
|
|
||||||
]);
|
|
||||||
DB::commit();
|
|
||||||
return redirect()->back();
|
|
||||||
} catch (\Exception $e){
|
|
||||||
DB::rollBack();
|
|
||||||
return redirect()->back();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function deleteTestSample(Request $request){
|
|
||||||
DB::beginTransaction();
|
|
||||||
try{
|
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['delete_test_sample'])) return false;
|
|
||||||
$this->model::query()->where('id', $request->uid)->update(array(BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::DELETE));
|
|
||||||
$this->testNormalValueModel::query()->where('test_sample_id', $request->uid)->update([BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::DELETE]);
|
|
||||||
$this->testSampleOrganismModel::query()->where('test_sample_id', $request->uid)->update([BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::DELETE]);
|
|
||||||
DB::commit();
|
|
||||||
return response()->json(['success' => true, 'message' => __('test_sample.delete_success')]);
|
|
||||||
}
|
|
||||||
catch (\Exception $e){
|
|
||||||
DB::rollBack();
|
|
||||||
return response()->json(['success' => false, 'message' => __('test_sample.delete_fail')]);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function restoreTestSample(Request $request){
|
|
||||||
DB::beginTransaction();
|
|
||||||
try{
|
|
||||||
$this->model::query()->where('id', $request->uid)->update(array(BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE));
|
|
||||||
$this->testNormalValueModel::query()->where('test_sample_id', $request->uid)->update([BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE]);
|
|
||||||
$this->testSampleOrganismModel::query()->where('test_sample_id', $request->uid)->update([BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE]);
|
|
||||||
DB::commit();
|
|
||||||
return response()->json(['success' => true, 'message' => __('test_sample.restore_success')]);
|
|
||||||
}
|
|
||||||
catch (\Exception $e){
|
|
||||||
DB::rollBack();
|
|
||||||
return response()->json(['success' => false, 'message' => __('test_sample.restore_fail')]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function storePhysicianCommission(Request $request){
|
|
||||||
DB::beginTransaction();
|
|
||||||
try{
|
|
||||||
foreach ($request->physician as $k=>$val){
|
|
||||||
$this->physicianCommissionModel::query()->updateOrCreate([
|
|
||||||
'physician_id' => $request->physician[$k],
|
|
||||||
'test_sample_id' => $request->test_sample_id
|
|
||||||
],[
|
|
||||||
'physician_id' => $request->physician[$k],
|
|
||||||
'test_sample_id' => $request->test_sample_id,
|
|
||||||
'commission_rate' => $request->commission_rate[$k],
|
|
||||||
'partner_price' => $request->pc_price[$k],
|
|
||||||
'commission_type' => $request->commission_type[$k],
|
|
||||||
'lab_id' => $this->baseLabId,
|
|
||||||
BaseModel::CREATED_AT_FIELD => date('Y-m-d H:i:s'),
|
|
||||||
BaseModel::CREATED_BY_FIELD => Auth::id(),
|
|
||||||
BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
DB::commit();
|
|
||||||
return redirect()->back();
|
|
||||||
}
|
|
||||||
catch (\Exception $e){
|
|
||||||
DB::rollBack();
|
|
||||||
return redirect()->back();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setCommissionToAllTest(Request $request){
|
|
||||||
DB::beginTransaction();
|
|
||||||
try{
|
|
||||||
$testSamples = $this->model::query()->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->get();
|
|
||||||
foreach ($testSamples as $testSample){
|
|
||||||
$this->physicianCommissionModel::query()->updateOrCreate([
|
|
||||||
'physician_id' => $request->physician_id,
|
|
||||||
'test_sample_id' => $testSample->id
|
|
||||||
],[
|
|
||||||
'physician_id' => $request->physician_id,
|
|
||||||
'test_sample_id' => $testSample->id,
|
|
||||||
'commission_rate' => $request->commission_rate,
|
|
||||||
'commission_type' => $request->commission_type,
|
|
||||||
'lab_id' => $this->baseLabId,
|
|
||||||
BaseModel::CREATED_AT_FIELD => date('Y-m-d H:i:s'),
|
|
||||||
BaseModel::CREATED_BY_FIELD => Auth::id(),
|
|
||||||
BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
DB::commit();
|
|
||||||
return response()->json(['success'=> true , 'message' => __('test_sample.add_commission_success')]);
|
|
||||||
}
|
|
||||||
catch (\Exception $e){
|
|
||||||
DB::rollBack();
|
|
||||||
return response()->json(['success'=> false , 'message' => __('test_sample.add_commission_fail'), 'errors' => $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*public function cloneTestSampleProperties(Request $request){
|
|
||||||
try {
|
|
||||||
|
|
||||||
$test_sample_id = $request->test_sample_id;
|
|
||||||
$target_lab_id = $request->target_lab_id;
|
|
||||||
$target_sample_type_id = $request->target_sample_type_id;
|
|
||||||
$target_test_sample_id = $request->target_test_sample_id;
|
|
||||||
|
|
||||||
$testSamples = $this->model::with(['testValues','organisms','organisms.antibiotics'])->where('id', $test_sample_id)->get();
|
|
||||||
|
|
||||||
$this->testNormalValueModel::query()->where(['test_sample_id' => $target_test_sample_id])->update([BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::DELETE]);
|
|
||||||
$this->testSampleOrganismModel::query()->where(['test_sample_id' => $target_test_sample_id, 'lab_id' => $target_lab_id])->update([BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::DELETE]);
|
|
||||||
|
|
||||||
foreach ($testSamples as $testSample) {
|
|
||||||
$testValues = isset($testSample->testValues) ? $testSample->testValues : [];
|
|
||||||
|
|
||||||
foreach ($testValues as $testValue) {
|
|
||||||
$testValueData = [
|
|
||||||
'test_sample_id' => $target_test_sample_id,
|
|
||||||
'patient_type_id' => $testValue->patient_type_id,
|
|
||||||
'sign' => $testValue->sign,
|
|
||||||
'minimum' => $testValue->minimum,
|
|
||||||
'maximum' => $testValue->maximum,
|
|
||||||
'created_at' => date('Y-m-d H:i:s'),
|
|
||||||
'created_by' => 1
|
|
||||||
];
|
|
||||||
$insertTestValue = $this->testNormalValueModel::query()->create($testValueData);
|
|
||||||
}
|
|
||||||
$testOrganisms = isset($testSample->organisms) ? $testSample->organisms : [];
|
|
||||||
foreach ($testOrganisms as $testOrganism) {
|
|
||||||
$testOrganismData = [
|
|
||||||
'test_sample_id' => $target_test_sample_id,
|
|
||||||
'organism_id' => $testOrganism->organism_id,
|
|
||||||
'lab_id' => $target_lab_id,
|
|
||||||
'created_at' => date('Y-m-d H:i:s'),
|
|
||||||
'created_by' => 1
|
|
||||||
];
|
|
||||||
$insertTestSampleOrganism = $this->testSampleOrganismModel::query()->create($testOrganismData);
|
|
||||||
$antibiotics = isset($testOrganism->antibiotics) ? $testOrganism->antibiotics : [];
|
|
||||||
foreach ($antibiotics as $antibiotic) {
|
|
||||||
$testOrganismAntibioticData = [
|
|
||||||
'test_sample_organism_id' => $insertTestSampleOrganism->id,
|
|
||||||
'antibiotic_id' => $antibiotic->antibiotic_id,
|
|
||||||
'created_at' => date('Y-m-d H:i:s'),
|
|
||||||
'created_by' => 1
|
|
||||||
];
|
|
||||||
$insertTestOrganismAntibiotic = $this->testSampleOrganismAntibioticModel::query()->create($testOrganismAntibioticData);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (\Exception $e){
|
|
||||||
Log::error($e->getMessage());
|
|
||||||
}
|
|
||||||
return redirect()->back();
|
|
||||||
}*/
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,81 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
|
||||||
use App\Enums\RecordStatusEnum;
|
|
||||||
use App\Http\Controllers\Helper\GlobalController;
|
|
||||||
use App\Models\BaseModel;
|
|
||||||
use App\Models\TestGroup;
|
|
||||||
use App\Models\TestGroupDetail;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Illuminate\Support\Facades\Auth;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
use Illuminate\Support\Facades\Session;
|
|
||||||
|
|
||||||
class TestGroupController extends Controller
|
|
||||||
{
|
|
||||||
|
|
||||||
protected $model;
|
|
||||||
protected $testGroupDetailModel;
|
|
||||||
|
|
||||||
protected $baseLabId;
|
|
||||||
protected $labs;
|
|
||||||
protected $base;
|
|
||||||
|
|
||||||
public function __construct(TestGroup $model, TestGroupDetail $testGroupDetailModel)
|
|
||||||
{
|
|
||||||
$this->model = $model;
|
|
||||||
$this->testGroupDetailModel = $testGroupDetailModel;
|
|
||||||
$this->baseLabId = Session::get('base_lab_id');
|
|
||||||
$this->base = Session::get('base_lab');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function index(Request $request){
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function save(Request $request){
|
|
||||||
DB::beginTransaction();
|
|
||||||
try{
|
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['create_test_group'])) return false;
|
|
||||||
$validator = \Validator::make($request->all(), ['name_en' => 'required','test_sample_ids' => 'required']);
|
|
||||||
if ($validator->fails()){ return response()->json(['errors'=>$validator->errors()->all()]);}
|
|
||||||
$testGroup = $this->model::query()->create(['group_name' => $request->name_en, 'lab_id' => $this->baseLabId]);
|
|
||||||
foreach ($request->test_sample_ids as $v){
|
|
||||||
$this->testGroupDetailModel::query()->create([
|
|
||||||
'test_group_id' => $testGroup->id,
|
|
||||||
'test_sample_id' => $v,
|
|
||||||
'lab_id' => $this->baseLabId
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
DB::commit();
|
|
||||||
return response()->json(['success'=> true , 'data' => [$testGroup]]);
|
|
||||||
} catch (\Exception $e)
|
|
||||||
{
|
|
||||||
DB::rollBack();
|
|
||||||
return response()->json(['success'=> false , 'errors' => [$e->getMessage()]]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function get($id){
|
|
||||||
try{
|
|
||||||
$testGroupItems = $this->testGroupDetailModel::query()->where(['test_group_id' => $id, 'lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD=>RecordStatusEnum::ACTIVE])->get()->pluck('test_sample_id')->toArray();
|
|
||||||
return response()->json(['success' => true, 'data' => $testGroupItems]);
|
|
||||||
} catch (\Exception $e)
|
|
||||||
{
|
|
||||||
return response()->json(['success'=> false , 'errors' => [$e->getMessage()]]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function delete(Request $request){
|
|
||||||
try{
|
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['delete_test_group'])) return false;
|
|
||||||
$this->model::query()->where(['id' => $request->id, 'lab_id' => $this->baseLabId])->update([BaseModel::RECORD_STATUS_FIELD=>RecordStatusEnum::DELETE]);
|
|
||||||
return response()->json(['success' => true, 'message' => 'Test group successfully deleted']);
|
|
||||||
} catch (\Exception $e)
|
|
||||||
{
|
|
||||||
return response()->json(['success'=> false , 'message' => 'Failed while deleting test group. Please try again.', 'errors' => [$e->getMessage()]]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -4,21 +4,13 @@ namespace App\Http\Controllers;
|
|||||||
use App\Enums\RecordStatusEnum;
|
use App\Enums\RecordStatusEnum;
|
||||||
use App\Enums\UtilEnum;
|
use App\Enums\UtilEnum;
|
||||||
use App\Http\Controllers\Helper\GlobalController;
|
use App\Http\Controllers\Helper\GlobalController;
|
||||||
use App\Models\AgeGroup;
|
|
||||||
use App\Models\BaseModel;
|
use App\Models\BaseModel;
|
||||||
use App\Models\Department;
|
|
||||||
use App\Models\PatientType;
|
|
||||||
use App\Models\Role;
|
use App\Models\Role;
|
||||||
use App\Models\SampleSource;
|
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Models\UserLabCover;
|
use App\Models\UserOrganization;
|
||||||
use App\Models\WardTransaction;
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use App\Models\Laboratory;
|
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Illuminate\Support\Facades\Hash;
|
use Illuminate\Support\Facades\Hash;
|
||||||
use Illuminate\Support\Facades\Redis;
|
|
||||||
use Illuminate\Support\Facades\Session;
|
use Illuminate\Support\Facades\Session;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
@@ -27,39 +19,33 @@ class UserController extends Controller
|
|||||||
|
|
||||||
protected $userModel;
|
protected $userModel;
|
||||||
protected $roleModel;
|
protected $roleModel;
|
||||||
protected $userLabCover;
|
protected $userOrganizations;
|
||||||
protected $sampleSourceModel;
|
protected $baseOrganizationId;
|
||||||
protected $baseLabId;
|
protected $organizations;
|
||||||
protected $labs;
|
|
||||||
protected $base;
|
protected $base;
|
||||||
|
|
||||||
public function __construct(User $userModel, Role $roleModel, UserLabCover $userLabCover, SampleSource $sampleSourceModel){
|
public function __construct(User $userModel, Role $roleModel, UserOrganization $userOrganizations){
|
||||||
$this->userModel = $userModel;
|
$this->userModel = $userModel;
|
||||||
$this->roleModel = $roleModel;
|
$this->roleModel = $roleModel;
|
||||||
$this->userLabCover = $userLabCover;
|
$this->userOrganizations = $userOrganizations;
|
||||||
$this->sampleSourceModel = $sampleSourceModel;
|
$this->baseOrganizationId = Session::get('base_organization_id');
|
||||||
$this->baseLabId = Session::get('base_lab_id');
|
$this->base = Session::get('base_organization');
|
||||||
$this->base = Session::get('base_lab');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function index(Request $request){
|
public function index(Request $request){
|
||||||
if(!GlobalController::user_can(Auth::user()->role_id, ['view_user_account'])) return redirect(url('my-profile'));
|
if(!GlobalController::user_can(Auth::user()->role_id, ['view_user_account'])) return redirect(url('my-profile'));
|
||||||
$this->labs = parent::getAccessAbleLabs();
|
$this->organizations = parent::getAccessAbleLabs();
|
||||||
$recordStatusCondition = Auth::id()==1 ? [RecordStatusEnum::DELETE, RecordStatusEnum::ACTIVE] : [RecordStatusEnum::ACTIVE];
|
$recordStatusCondition = Auth::id()==1 ? [RecordStatusEnum::DELETE, RecordStatusEnum::ACTIVE] : [RecordStatusEnum::ACTIVE];
|
||||||
$roles = $this->roleModel::query()->where(BaseModel::RECORD_STATUS_FIELD, RecordStatusEnum::ACTIVE)
|
$roles = $this->roleModel::query()->where(BaseModel::RECORD_STATUS_FIELD, RecordStatusEnum::ACTIVE)
|
||||||
->when(Auth::user()->role_id != UtilEnum::ADMINISTRATOR_ROLE , function ($roles){
|
->when(Auth::user()->role_id != UtilEnum::ADMINISTRATOR_ROLE , function ($roles){
|
||||||
$roles->whereNotIn('id', [UtilEnum::ADMINISTRATOR_ROLE]);
|
$roles->whereNotIn('id', [UtilEnum::ADMINISTRATOR_ROLE]);
|
||||||
})->get();
|
})->get();
|
||||||
|
|
||||||
$sample_sources = $this->sampleSourceModel::query()->where(BaseModel::RECORD_STATUS_FIELD, RecordStatusEnum::ACTIVE)
|
|
||||||
->when(Auth::user()->role_id != UtilEnum::PHYSICIAN_ROLE && Auth::id()!=1 , function ($sampleSource){
|
|
||||||
$sampleSource->where('lab_id', Session::get('base_lab_id'));
|
|
||||||
})->get();
|
|
||||||
|
|
||||||
$users = $this->userModel::with(['role','lab_covers'])->whereIn(BaseModel::RECORD_STATUS_FIELD, $recordStatusCondition)
|
$users = $this->userModel::with(['role','userOrganizations'])->whereIn(BaseModel::RECORD_STATUS_FIELD, $recordStatusCondition)
|
||||||
->when(Auth::id()!=1, function ($users){
|
->when(Auth::id()!=1, function ($users){
|
||||||
$users->whereNotIn('id', [UtilEnum::ADMINISTRATOR_USER])
|
$users->whereNotIn('id', [UtilEnum::ADMINISTRATOR_USER])
|
||||||
->whereIn('id', $this->labs->pluck('userLabCovers')->flatten()->pluck('user_id')->toArray());
|
->whereIn('id', $this->organizations->pluck('organizations')->flatten()->pluck('user_id')->toArray());
|
||||||
})->when(!empty($request->kword), function($users) use ($request) {
|
})->when(!empty($request->kword), function($users) use ($request) {
|
||||||
$keyword = '%' . str_replace(' ', '', $request->kword) . '%';
|
$keyword = '%' . str_replace(' ', '', $request->kword) . '%';
|
||||||
$users->where(function ($q) use ($keyword) {
|
$users->where(function ($q) use ($keyword) {
|
||||||
@@ -68,7 +54,7 @@ class UserController extends Controller
|
|||||||
})->where('id', '!=', UtilEnum::ADMINISTRATOR_USER);
|
})->where('id', '!=', UtilEnum::ADMINISTRATOR_USER);
|
||||||
})
|
})
|
||||||
->orderBy(BaseModel::CREATED_AT,'desc')->paginate(config('labis.pagination.perpage', 10));
|
->orderBy(BaseModel::CREATED_AT,'desc')->paginate(config('labis.pagination.perpage', 10));
|
||||||
return view('user_account', ['users' => $users, 'roles' => $roles, 'labs' => $this->labs, 'sample_sources' => $sample_sources]);
|
return view('user_account', ['users' => $users, 'roles' => $roles, 'organizations' => $this->organizations]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function labUsers(Request $request){
|
public function labUsers(Request $request){
|
||||||
@@ -77,7 +63,7 @@ class UserController extends Controller
|
|||||||
$roles = $this->roleModel::query()->where(BaseModel::RECORD_STATUS_FIELD, RecordStatusEnum::ACTIVE)
|
$roles = $this->roleModel::query()->where(BaseModel::RECORD_STATUS_FIELD, RecordStatusEnum::ACTIVE)
|
||||||
->whereNotIn('id', [UtilEnum::ADMINISTRATOR_ROLE])->get();
|
->whereNotIn('id', [UtilEnum::ADMINISTRATOR_ROLE])->get();
|
||||||
$sample_sources = $this->sampleSourceModel::query()->where(BaseModel::RECORD_STATUS_FIELD, RecordStatusEnum::ACTIVE)
|
$sample_sources = $this->sampleSourceModel::query()->where(BaseModel::RECORD_STATUS_FIELD, RecordStatusEnum::ACTIVE)
|
||||||
->where('lab_id', Session::get('base_lab_id'))->get();
|
->where('organization_id', Session::get('base_organization_id'))->get();
|
||||||
|
|
||||||
$users = $this->userModel::with(['role','lab_covers'])->where(BaseModel::RECORD_STATUS_FIELD, RecordStatusEnum::ACTIVE)
|
$users = $this->userModel::with(['role','lab_covers'])->where(BaseModel::RECORD_STATUS_FIELD, RecordStatusEnum::ACTIVE)
|
||||||
->whereIn('id', $this->labs->pluck('labUsers')->flatten()->pluck('user_id')->toArray())
|
->whereIn('id', $this->labs->pluck('labUsers')->flatten()->pluck('user_id')->toArray())
|
||||||
@@ -112,7 +98,7 @@ class UserController extends Controller
|
|||||||
);
|
);
|
||||||
$user = $this->userModel::query()->create($data);
|
$user = $this->userModel::query()->create($data);
|
||||||
Log::channel('account_creation')->info(array('action' => 'create', 'raw' => $request->all(), 'prepared' => $data));
|
Log::channel('account_creation')->info(array('action' => 'create', 'raw' => $request->all(), 'prepared' => $data));
|
||||||
$requests = new Request(array('uid' => $user->id, 'lab_ids' => [Session::get('base_lab_id')]));
|
$requests = new Request(array('uid' => $user->id, 'organization_ids' => [Session::get('base_organization_id')]));
|
||||||
$this->assignLabs($requests);
|
$this->assignLabs($requests);
|
||||||
return response()->json(['success' => true, 'message' => __('user_account.create_success')]);
|
return response()->json(['success' => true, 'message' => __('user_account.create_success')]);
|
||||||
} catch (\Exception $e){
|
} catch (\Exception $e){
|
||||||
@@ -203,10 +189,10 @@ class UserController extends Controller
|
|||||||
$this->userLabCover::query()->where('user_id', $request->uid)
|
$this->userLabCover::query()->where('user_id', $request->uid)
|
||||||
->update(['end_date' => date('Y-m-d'), BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::DELETE, BaseModel::UPDATED_AT_FIELD => date('Y-m-d H:i:s'), BaseModel::UPDATED_BY_FIELD =>Auth::id()]);
|
->update(['end_date' => date('Y-m-d'), BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::DELETE, BaseModel::UPDATED_AT_FIELD => date('Y-m-d H:i:s'), BaseModel::UPDATED_BY_FIELD =>Auth::id()]);
|
||||||
$data = array();
|
$data = array();
|
||||||
foreach ($request->lab_ids as $lab_id){
|
foreach ($request->organization_ids as $organization_id){
|
||||||
$data[] = array(
|
$data[] = array(
|
||||||
'user_id' => $request->uid,
|
'user_id' => $request->uid,
|
||||||
'lab_id' => $lab_id,
|
'organization_id' => $organization_id,
|
||||||
'start_date' => date('Y-m-d'),
|
'start_date' => date('Y-m-d'),
|
||||||
'created_at' => date('Y-m-d H:i:s'),
|
'created_at' => date('Y-m-d H:i:s'),
|
||||||
'created_by' => Auth::id()
|
'created_by' => Auth::id()
|
||||||
@@ -252,64 +238,47 @@ class UserController extends Controller
|
|||||||
|
|
||||||
public function changePassword(Request $request)
|
public function changePassword(Request $request)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
|
||||||
$request->validate([
|
$request->validate([
|
||||||
'current_password' => 'required|string',
|
'current_password' => 'required|string',
|
||||||
'new_password' => 'required|confirmed|min:8|string'
|
'new_password' => 'required|confirmed|min:8|string'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$auth = Auth::user();
|
$auth = Auth::user();
|
||||||
|
|
||||||
|
// Check current password
|
||||||
|
if (!Hash::check($request->current_password, $auth->password)) {
|
||||||
|
return redirect()->back()->withErrors(['current_password' => __('user_account.invalid_current_password')]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check new password not same as old
|
||||||
|
if ($request->current_password === $request->new_password) {
|
||||||
|
return redirect()->back()->withErrors(['new_password' => __('user_account.new_password_same_old_password')]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update password
|
||||||
|
$user = User::where('id', $auth->id)->update([
|
||||||
|
'password' => Hash::make($request->new_password)
|
||||||
|
]);
|
||||||
|
|
||||||
|
Log::channel('account_creation')->info([
|
||||||
|
'action' => 'change-password',
|
||||||
|
'user_id' => $auth->id
|
||||||
|
]);
|
||||||
|
|
||||||
|
return redirect()->back()->with('success', __('user_account.change_password_success'));
|
||||||
|
|
||||||
// Check current password
|
|
||||||
if (!Hash::check($request->current_password, $auth->password)) {
|
|
||||||
// return response()->json([
|
|
||||||
// 'success' => false,
|
|
||||||
// 'message' => __('user_account.invalid_current_password')
|
|
||||||
// ]);
|
|
||||||
return redirect()->back()->withErrors(['current_password' => __('user_account.invalid_current_password')]);
|
|
||||||
}
|
}
|
||||||
|
catch (\Exception $e) {
|
||||||
// Check new password not same as old
|
return redirect()->back()->withErrors(['error' => __('user_account.change_password_fail') . ': ' . $e->getMessage()]);
|
||||||
if ($request->current_password === $request->new_password) {
|
|
||||||
return redirect()->back()->withErrors(['new_password' => __('user_account.new_password_same_old_password')]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update password
|
|
||||||
$user = User::where('id', $auth->id)->update([
|
|
||||||
'password' => Hash::make($request->new_password)
|
|
||||||
]);
|
|
||||||
|
|
||||||
Log::channel('account_creation')->info([
|
|
||||||
'action' => 'change-password',
|
|
||||||
'user_id' => $auth->id
|
|
||||||
]);
|
|
||||||
|
|
||||||
// return response()->json([
|
|
||||||
// 'success' => true,
|
|
||||||
// 'message' => __('user_account.change_password_success')
|
|
||||||
// //'data' => $user
|
|
||||||
// ]);
|
|
||||||
return redirect()->back()->with('success', __('user_account.change_password_success'));
|
|
||||||
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
|
|
||||||
// return response()->json([
|
|
||||||
// 'success' => false,
|
|
||||||
// 'message' => __('user_account.change_password_fail'),
|
|
||||||
// 'errors' => $e->getMessage()
|
|
||||||
// ]);
|
|
||||||
return redirect()->back()->withErrors(['error' => __('user_account.change_password_fail') . ': ' . $e->getMessage()]);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function my_profile()
|
function my_profile()
|
||||||
{
|
{
|
||||||
$user = $this->userModel::query()->with(['role','lab_covers'])->find(Auth::id());
|
$user = $this->userModel::query()->with(['role','userOrganizations'])->find(Auth::id());
|
||||||
//return response()->json(['success' => true, 'message' => __('user_account.get_success'), 'data' => $user]);
|
|
||||||
return view('my_profiles',[
|
return view('my_profiles',[
|
||||||
// 'labSettings' => (object) $this->base,
|
|
||||||
'users' => $user
|
'users' => $user
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ use App\Models\Sample;
|
|||||||
use App\Models\SampleType;
|
use App\Models\SampleType;
|
||||||
use App\Models\TestSample;
|
use App\Models\TestSample;
|
||||||
use App\Models\TestSampleOrganism;
|
use App\Models\TestSampleOrganism;
|
||||||
use App\Models\UserLabCover;
|
use App\Models\UserOrganization;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@@ -41,11 +41,11 @@ class UtilController extends Controller
|
|||||||
|
|
||||||
protected $testSampleOrganismModel;
|
protected $testSampleOrganismModel;
|
||||||
|
|
||||||
private $baseLabId;
|
private $baseOrganizationId;
|
||||||
protected $base;
|
protected $base;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
Organism $organismModel, Antibiotic $antibioticModel, RejectComment $rejectCommentModel, UserLabCover $labUserModel,
|
Organism $organismModel, Antibiotic $antibioticModel, RejectComment $rejectCommentModel, UserOrganization $labUserModel,
|
||||||
SampleType $sampleTypeModel, Department $departmentModel, TestSample $testSampleModel, Sample $sampleModel,
|
SampleType $sampleTypeModel, Department $departmentModel, TestSample $testSampleModel, Sample $sampleModel,
|
||||||
PatientType $patientTypeModel, TestSampleOrganism $testSampleOrganism
|
PatientType $patientTypeModel, TestSampleOrganism $testSampleOrganism
|
||||||
){
|
){
|
||||||
@@ -61,8 +61,8 @@ class UtilController extends Controller
|
|||||||
|
|
||||||
$this->testSampleOrganismModel = $testSampleOrganism;
|
$this->testSampleOrganismModel = $testSampleOrganism;
|
||||||
|
|
||||||
$this->baseLabId = Session::get('base_lab_id');
|
$this->baseOrganizationId = Session::get('base_organization_id');
|
||||||
$this->base = Session::get('base_lab');
|
$this->base = Session::get('base_organization');
|
||||||
}
|
}
|
||||||
|
|
||||||
function province($responseType = 'object')
|
function province($responseType = 'object')
|
||||||
@@ -118,7 +118,7 @@ class UtilController extends Controller
|
|||||||
|
|
||||||
public function getDepartment(){
|
public function getDepartment(){
|
||||||
try{
|
try{
|
||||||
$department = $this->departmentModel::query()->where([BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE, 'lab_id' => $this->baseLabId])->orderBy('weight','asc')->get();
|
$department = $this->departmentModel::query()->where([BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE, 'organization_id' => $this->baseOrganizationId])->orderBy('weight','asc')->get();
|
||||||
return response()->json(['success'=> true , 'data' => $department]);
|
return response()->json(['success'=> true , 'data' => $department]);
|
||||||
} catch (\Exception $e)
|
} catch (\Exception $e)
|
||||||
{
|
{
|
||||||
@@ -128,7 +128,7 @@ class UtilController extends Controller
|
|||||||
|
|
||||||
public function getDepartmentByLabId($labId){
|
public function getDepartmentByLabId($labId){
|
||||||
try{
|
try{
|
||||||
$department = $this->departmentModel::query()->where([BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE, 'lab_id' => $labId])->orderBy('weight','asc')->get();
|
$department = $this->departmentModel::query()->where([BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE, 'organization_id' => $labId])->orderBy('weight','asc')->get();
|
||||||
return response()->json(['success'=> true , 'data' => $department]);
|
return response()->json(['success'=> true , 'data' => $department]);
|
||||||
} catch (\Exception $e)
|
} catch (\Exception $e)
|
||||||
{
|
{
|
||||||
@@ -172,7 +172,7 @@ class UtilController extends Controller
|
|||||||
$rejectComment = $this->rejectCommentModel::query()->create([
|
$rejectComment = $this->rejectCommentModel::query()->create([
|
||||||
'sample_condition_id' => 3,
|
'sample_condition_id' => 3,
|
||||||
'reject_comment' => $request->name_en,
|
'reject_comment' => $request->name_en,
|
||||||
'lab_id' => $this->baseLabId
|
'organization_id' => $this->baseOrganizationId
|
||||||
]);
|
]);
|
||||||
return response()->json(['success'=> true , 'data' => [$rejectComment]]);
|
return response()->json(['success'=> true , 'data' => [$rejectComment]]);
|
||||||
} catch (\Exception $e)
|
} catch (\Exception $e)
|
||||||
@@ -184,7 +184,7 @@ class UtilController extends Controller
|
|||||||
function getTestItem(){
|
function getTestItem(){
|
||||||
try{
|
try{
|
||||||
$departments = $this->departmentModel::with(['samples','samples.testSamples.test','samples.testSamples.childTest'])
|
$departments = $this->departmentModel::with(['samples','samples.testSamples.test','samples.testSamples.childTest'])
|
||||||
->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
->where(['organization_id' => $this->baseOrganizationId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
||||||
->orderBy('weight', 'asc')->get();
|
->orderBy('weight', 'asc')->get();
|
||||||
return response()->json(['success'=> true , 'data' => SampleTestResource::collection($departments)]);
|
return response()->json(['success'=> true , 'data' => SampleTestResource::collection($departments)]);
|
||||||
} catch (\Exception $e){
|
} catch (\Exception $e){
|
||||||
@@ -193,13 +193,13 @@ class UtilController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getLabUsers(){
|
function getLabUsers(){
|
||||||
return $this->labUserModel::with('user')->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->get();
|
return $this->labUserModel::with('user')->where(['organization_id' => $this->baseOrganizationId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function getTestItemBySampleId($sampleId, $previousId = 0){
|
function getTestItemBySampleId($sampleId, $previousId = 0){
|
||||||
try{
|
try{
|
||||||
$data = $this->sampleModel::with(['entryBy','modifiedBy','sample_tests', 'physician', 'patient','sample_source'])->where(['id' => $sampleId, 'lab_id' => $this->baseLabId])->get()->first();
|
$data = $this->sampleModel::with(['entryBy','modifiedBy','sample_tests', 'physician', 'patient','sample_source'])->where(['id' => $sampleId, 'organization_id' => $this->baseOrganizationId])->get()->first();
|
||||||
$arrData = array();
|
$arrData = array();
|
||||||
$arrData['result_comment'] = [];
|
$arrData['result_comment'] = [];
|
||||||
$arrData['sample'] = array(
|
$arrData['sample'] = array(
|
||||||
@@ -251,17 +251,17 @@ class UtilController extends Controller
|
|||||||
ifnull(prev_r.test_result,"") as prev_result,
|
ifnull(prev_r.test_result,"") as prev_result,
|
||||||
ts.is_bold,
|
ts.is_bold,
|
||||||
ts.autocomplete_bind,
|
ts.autocomplete_bind,
|
||||||
ts.lab_id,
|
ts.organization_id,
|
||||||
sd.sample_descr
|
sd.sample_descr
|
||||||
FROM samples s
|
FROM samples s
|
||||||
INNER JOIN patients p
|
INNER JOIN patients p
|
||||||
ON p.id = s.patient_id AND p.lab_id = s.lab_id
|
ON p.id = s.patient_id AND p.organization_id = s.organization_id
|
||||||
INNER JOIN test_results tr
|
INNER JOIN test_results tr
|
||||||
ON tr.`sample_id` = s.`id`
|
ON tr.`sample_id` = s.`id`
|
||||||
AND s.`lab_id` = tr.`lab_id`
|
AND s.`organization_id` = tr.`organization_id`
|
||||||
INNER JOIN test_samples ts
|
INNER JOIN test_samples ts
|
||||||
ON ts.id = tr.`test_sample_id`
|
ON ts.id = tr.`test_sample_id`
|
||||||
and ts.lab_id = tr.lab_id
|
and ts.organization_id = tr.organization_id
|
||||||
INNER JOIN tests t
|
INNER JOIN tests t
|
||||||
ON t.`id` = ts.`test_id`
|
ON t.`id` = ts.`test_id`
|
||||||
INNER JOIN sample_types st
|
INNER JOIN sample_types st
|
||||||
@@ -282,14 +282,14 @@ class UtilController extends Controller
|
|||||||
INNER JOIN test_results tr
|
INNER JOIN test_results tr
|
||||||
ON tr.`sample_id` = s.`id`
|
ON tr.`sample_id` = s.`id`
|
||||||
WHERE s.id = '.$previousId.'
|
WHERE s.id = '.$previousId.'
|
||||||
AND s.`lab_id` = '.$this->baseLabId.'
|
AND s.`organization_id` = '.$this->baseOrganizationId.'
|
||||||
AND tr.record_status_id = 1
|
AND tr.record_status_id = 1
|
||||||
) prev_r
|
) prev_r
|
||||||
ON prev_r.test_sample_id = tr.`test_sample_id`
|
ON prev_r.test_sample_id = tr.`test_sample_id`
|
||||||
|
|
||||||
WHERE s.`id` = '.$sampleId.'
|
WHERE s.`id` = '.$sampleId.'
|
||||||
AND s.`lab_id`= '.$this->baseLabId.'
|
AND s.`organization_id`= '.$this->baseOrganizationId.'
|
||||||
and ts.lab_id = '.$this->baseLabId.'
|
and ts.organization_id = '.$this->baseOrganizationId.'
|
||||||
AND tr.`record_status_id` = '.BaseModel::RECORD_STATUS_ACTIVE.'
|
AND tr.`record_status_id` = '.BaseModel::RECORD_STATUS_ACTIVE.'
|
||||||
|
|
||||||
ORDER BY
|
ORDER BY
|
||||||
@@ -381,7 +381,7 @@ class UtilController extends Controller
|
|||||||
'is_bold' => (int) $row->is_bold,
|
'is_bold' => (int) $row->is_bold,
|
||||||
'autocomplete_bind' => (int) $row->autocomplete_bind,
|
'autocomplete_bind' => (int) $row->autocomplete_bind,
|
||||||
'ts' => $row->test_result,
|
'ts' => $row->test_result,
|
||||||
'lab_id' => $row->lab_id,
|
'organization_id' => $row->organization_id,
|
||||||
'format' => (int)$row->format
|
'format' => (int)$row->format
|
||||||
);
|
);
|
||||||
$departmentArray[$row->dweight]['samples'][$row->sweight]['tests'][] = $testItemArray;
|
$departmentArray[$row->dweight]['samples'][$row->sweight]['tests'][] = $testItemArray;
|
||||||
@@ -400,7 +400,7 @@ class UtilController extends Controller
|
|||||||
return Comment::query()->select('sample_type_id', 'comment_desc as name')->where(
|
return Comment::query()->select('sample_type_id', 'comment_desc as name')->where(
|
||||||
[
|
[
|
||||||
BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE,
|
BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE,
|
||||||
'lab_id' => $this->baseLabId
|
'organization_id' => $this->baseOrganizationId
|
||||||
])->whereIn('sample_type_id', $sampleTypeIds)->get()->toArray();
|
])->whereIn('sample_type_id', $sampleTypeIds)->get()->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -438,7 +438,7 @@ class UtilController extends Controller
|
|||||||
ogr.id
|
ogr.id
|
||||||
FROM `organism_results` AS ogr
|
FROM `organism_results` AS ogr
|
||||||
INNER JOIN test_results trs
|
INNER JOIN test_results trs
|
||||||
ON trs.id = ogr.test_result_id and ogr.lab_id = trs.lab_id
|
ON trs.id = ogr.test_result_id and ogr.organization_id = trs.organization_id
|
||||||
INNER JOIN `test_sample_organisms` tsr
|
INNER JOIN `test_sample_organisms` tsr
|
||||||
ON tsr.test_sample_id = trs.test_sample_id
|
ON tsr.test_sample_id = trs.test_sample_id
|
||||||
AND tsr.`organism_id` = ogr.`organism_id`
|
AND tsr.`organism_id` = ogr.`organism_id`
|
||||||
@@ -468,7 +468,7 @@ class UtilController extends Controller
|
|||||||
ogr.id
|
ogr.id
|
||||||
FROM `organism_results` AS ogr
|
FROM `organism_results` AS ogr
|
||||||
INNER JOIN test_results trs
|
INNER JOIN test_results trs
|
||||||
ON trs.id = ogr.test_result_id and ogr.lab_id = trs.lab_id
|
ON trs.id = ogr.test_result_id and ogr.organization_id = trs.organization_id
|
||||||
INNER JOIN samples s
|
INNER JOIN samples s
|
||||||
ON s.id = trs.sample_id
|
ON s.id = trs.sample_id
|
||||||
INNER JOIN `test_sample_organisms` tsr
|
INNER JOIN `test_sample_organisms` tsr
|
||||||
@@ -479,7 +479,7 @@ class UtilController extends Controller
|
|||||||
LEFT JOIN `quantities` qt
|
LEFT JOIN `quantities` qt
|
||||||
ON qt.id = ogr.`quantity_id`
|
ON qt.id = ogr.`quantity_id`
|
||||||
WHERE s.id = '.$previousSampleId.'
|
WHERE s.id = '.$previousSampleId.'
|
||||||
AND s.`lab_id` = '.$this->baseLabId.'
|
AND s.`organization_id` = '.$this->baseOrganizationId.'
|
||||||
AND ogr.record_status_id = 1
|
AND ogr.record_status_id = 1
|
||||||
AND trs.record_status_id = 1
|
AND trs.record_status_id = 1
|
||||||
AND tsr.record_status_id = 1');
|
AND tsr.record_status_id = 1');
|
||||||
@@ -490,7 +490,7 @@ class UtilController extends Controller
|
|||||||
return Comment::query()->select('comment_desc as name')->where(
|
return Comment::query()->select('comment_desc as name')->where(
|
||||||
[
|
[
|
||||||
BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE,
|
BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE,
|
||||||
'lab_id' => $this->baseLabId,
|
'organization_id' => $this->baseOrganizationId,
|
||||||
'sample_type_id' => $sampleTypeId
|
'sample_type_id' => $sampleTypeId
|
||||||
])->get();
|
])->get();
|
||||||
}
|
}
|
||||||
@@ -586,7 +586,7 @@ class UtilController extends Controller
|
|||||||
ogr.id
|
ogr.id
|
||||||
FROM `organism_results` AS ogr
|
FROM `organism_results` AS ogr
|
||||||
INNER JOIN test_results trs
|
INNER JOIN test_results trs
|
||||||
ON trs.id = ogr.test_result_id and ogr.lab_id = trs.lab_id
|
ON trs.id = ogr.test_result_id and ogr.organization_id = trs.organization_id
|
||||||
INNER JOIN `test_sample_organisms` tsr
|
INNER JOIN `test_sample_organisms` tsr
|
||||||
ON tsr.test_sample_id = trs.test_sample_id
|
ON tsr.test_sample_id = trs.test_sample_id
|
||||||
AND tsr.`organism_id` = ogr.`organism_id`
|
AND tsr.`organism_id` = ogr.`organism_id`
|
||||||
@@ -637,7 +637,7 @@ class UtilController extends Controller
|
|||||||
try{
|
try{
|
||||||
$headingItems = $this->testSampleModel::with(['test'])
|
$headingItems = $this->testSampleModel::with(['test'])
|
||||||
->where([
|
->where([
|
||||||
'lab_id' => $this->baseLabId,
|
'organization_id' => $this->baseOrganizationId,
|
||||||
BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE
|
BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE
|
||||||
])->when(!empty($sampleTypeId), function ($headingItems) use($sampleTypeId) {
|
])->when(!empty($sampleTypeId), function ($headingItems) use($sampleTypeId) {
|
||||||
$headingItems->where('sample_type_id', $sampleTypeId);
|
$headingItems->where('sample_type_id', $sampleTypeId);
|
||||||
@@ -694,13 +694,13 @@ class UtilController extends Controller
|
|||||||
FROM `physician_commisssion` pc
|
FROM `physician_commisssion` pc
|
||||||
INNER JOIN physicians p
|
INNER JOIN physicians p
|
||||||
ON p.`id` = pc.`physician_id`
|
ON p.`id` = pc.`physician_id`
|
||||||
WHERE p.`lab_id` = '.$this->baseLabId.'
|
WHERE p.`organization_id` = '.$this->baseOrganizationId.'
|
||||||
AND p.`record_status_id` = 1
|
AND p.`record_status_id` = 1
|
||||||
AND pc.test_sample_id = '.$testSampleId.'
|
AND pc.test_sample_id = '.$testSampleId.'
|
||||||
AND pc.`record_status_id` = 1
|
AND pc.`record_status_id` = 1
|
||||||
) comm
|
) comm
|
||||||
ON comm.physician_id = p.`id`
|
ON comm.physician_id = p.`id`
|
||||||
WHERE p.`lab_id` = '.$this->baseLabId.'
|
WHERE p.`organization_id` = '.$this->baseOrganizationId.'
|
||||||
AND p.`record_status_id` = 1
|
AND p.`record_status_id` = 1
|
||||||
');
|
');
|
||||||
$data = array('test_name' => $test->test->name_en, 'physicians' => $testCommissions);
|
$data = array('test_name' => $test->test->name_en, 'physicians' => $testCommissions);
|
||||||
@@ -794,7 +794,7 @@ class UtilController extends Controller
|
|||||||
$test = $this->testSampleModel::with('test')->find($testSampleId);
|
$test = $this->testSampleModel::with('test')->find($testSampleId);
|
||||||
$defVal = count($this->getSelectedOrganismResult($sampleId, $testSampleId)) ==0 ? [-1] : $this->getSelectedOrganismResult($sampleId, $testSampleId);
|
$defVal = count($this->getSelectedOrganismResult($sampleId, $testSampleId)) ==0 ? [-1] : $this->getSelectedOrganismResult($sampleId, $testSampleId);
|
||||||
$testSampleOrganisms = $this->testSampleOrganismModel::with(['organism'])
|
$testSampleOrganisms = $this->testSampleOrganismModel::with(['organism'])
|
||||||
->where(['test_sample_id' => $testSampleId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE, 'lab_id' => $this->baseLabId])
|
->where(['test_sample_id' => $testSampleId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE, 'organization_id' => $this->baseOrganizationId])
|
||||||
->limit(10)->get()->map(function ($data) use ($defVal) {
|
->limit(10)->get()->map(function ($data) use ($defVal) {
|
||||||
$data['selected'] = in_array($data['id'], $defVal) ? 1: 0;
|
$data['selected'] = in_array($data['id'], $defVal) ? 1: 0;
|
||||||
return $data;
|
return $data;
|
||||||
@@ -810,7 +810,7 @@ class UtilController extends Controller
|
|||||||
'id' => $item['id'],
|
'id' => $item['id'],
|
||||||
'test_sample_id' => $item['test_sample_id'],
|
'test_sample_id' => $item['test_sample_id'],
|
||||||
'organism_id' => $item['organism_id'],
|
'organism_id' => $item['organism_id'],
|
||||||
'lab_id' => $item['lab_id'],
|
'organization_id' => $item['organization_id'],
|
||||||
'record_status_id' => $item['record_status_id'],
|
'record_status_id' => $item['record_status_id'],
|
||||||
'selected' => $item['selected'],
|
'selected' => $item['selected'],
|
||||||
'organism' => $item['organism'],
|
'organism' => $item['organism'],
|
||||||
@@ -842,14 +842,14 @@ class UtilController extends Controller
|
|||||||
$test = $this->testSampleModel::with('test')->find($request->test_sample_id);
|
$test = $this->testSampleModel::with('test')->find($request->test_sample_id);
|
||||||
$defVal = count($this->getSelectedOrganismResult($request->sample_id, $request->test_sample_id)) ==0 ? [-1] : $this->getSelectedOrganismResult($request->sample_id, $request->test_sample_id);
|
$defVal = count($this->getSelectedOrganismResult($request->sample_id, $request->test_sample_id)) ==0 ? [-1] : $this->getSelectedOrganismResult($request->sample_id, $request->test_sample_id);
|
||||||
$selectedOrganisms = $this->testSampleOrganismModel::with(['organism','antibiotics.antibioticResult','antibiotics.antibioticItem'])
|
$selectedOrganisms = $this->testSampleOrganismModel::with(['organism','antibiotics.antibioticResult','antibiotics.antibioticItem'])
|
||||||
->where(['test_sample_id' => $request->test_sample_id, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE, 'lab_id' => $this->baseLabId])
|
->where(['test_sample_id' => $request->test_sample_id, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE, 'organization_id' => $this->baseOrganizationId])
|
||||||
->whereIn('id', $defVal)->get()->map(function ($data) {
|
->whereIn('id', $defVal)->get()->map(function ($data) {
|
||||||
$data['selected'] = 1;
|
$data['selected'] = 1;
|
||||||
return $data;
|
return $data;
|
||||||
})->toArray();
|
})->toArray();
|
||||||
|
|
||||||
$testSampleOrganisms = $this->testSampleOrganismModel::with(['organism','antibiotics.antibioticResult','antibiotics.antibioticItem'])
|
$testSampleOrganisms = $this->testSampleOrganismModel::with(['organism','antibiotics.antibioticResult','antibiotics.antibioticItem'])
|
||||||
->where(['test_sample_id' => $request->test_sample_id, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE, 'lab_id' => $this->baseLabId])
|
->where(['test_sample_id' => $request->test_sample_id, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE, 'organization_id' => $this->baseOrganizationId])
|
||||||
->when(!empty(trim($request->name)), function ($testSampleOrganisms) use($request){
|
->when(!empty(trim($request->name)), function ($testSampleOrganisms) use($request){
|
||||||
$testSampleOrganisms->whereIn('organism_id', $this->organismModel::query()->whereRaw("replace(name_en, ' ','') like '%".str_replace(" ","",$request->name)."%'")->pluck('id')->toArray());
|
$testSampleOrganisms->whereIn('organism_id', $this->organismModel::query()->whereRaw("replace(name_en, ' ','') like '%".str_replace(" ","",$request->name)."%'")->pluck('id')->toArray());
|
||||||
})->whereNotIn('id', $defVal)
|
})->whereNotIn('id', $defVal)
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ class VerifyBaseLab
|
|||||||
public function handle(Request $request, Closure $next)
|
public function handle(Request $request, Closure $next)
|
||||||
{
|
{
|
||||||
try{
|
try{
|
||||||
if (!$request->session()->exists('base_lab_id')) {
|
if (!$request->session()->exists('base_organization_id')) {
|
||||||
return redirect('/base');
|
return redirect('/base');
|
||||||
}
|
}
|
||||||
} catch (\Exception $e){
|
} catch (\Exception $e){
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ class AntibioticResource extends JsonResource
|
|||||||
'id' => $this->id,
|
'id' => $this->id,
|
||||||
'name_en' => $this->name_en,
|
'name_en' => $this->name_en,
|
||||||
'weight' => $this->weight,
|
'weight' => $this->weight,
|
||||||
'lab_id' => $this->lab_id,
|
'organization_id' => $this->organization_id,
|
||||||
// 'lab' => LaboratoryResource::collection($this->lab),
|
// 'lab' => LaboratoryResource::collection($this->lab),
|
||||||
'record_status_id' => $this->record_status_id
|
'record_status_id' => $this->record_status_id
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ class TestSampleResource extends JsonResource
|
|||||||
'format' => $this->format,
|
'format' => $this->format,
|
||||||
'formula' => $this->formula,
|
'formula' => $this->formula,
|
||||||
'description' => $this->description,
|
'description' => $this->description,
|
||||||
'lab_id' => $this->lab_id,
|
'organization_id' => $this->organization_id,
|
||||||
'code' => $this->code,
|
'code' => $this->code,
|
||||||
'is_bold' => (int) $this->is_bold,
|
'is_bold' => (int) $this->is_bold,
|
||||||
'autocomplete_bind' => (int) $this->autocomplete_bind
|
'autocomplete_bind' => (int) $this->autocomplete_bind
|
||||||
|
|||||||
@@ -1,29 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Models;
|
|
||||||
use App\Traits\AuditLogTrait;
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
||||||
|
|
||||||
class Antibiotic extends BaseModel
|
|
||||||
{
|
|
||||||
public $timestamps = false;
|
|
||||||
use HasFactory, AuditLogTrait;
|
|
||||||
/**
|
|
||||||
* The table associated with the model.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $fillable = ['name_en','weight', 'lab_id'];
|
|
||||||
|
|
||||||
protected $hidden = ['created_at', 'created_by', 'updated_at', 'updated_by', 'record_status_id'];
|
|
||||||
|
|
||||||
public static function boot()
|
|
||||||
{
|
|
||||||
parent::boot();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function lab(){
|
|
||||||
return $this->belongsTo('App\Models\Laboratory', 'lab_id','id');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Models;
|
|
||||||
use App\Traits\AuditLogTrait;
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
||||||
|
|
||||||
class AntibioticResult extends BaseModel
|
|
||||||
{
|
|
||||||
protected $table = "antibiogram_results";
|
|
||||||
public $timestamps = false;
|
|
||||||
use HasFactory, AuditLogTrait;
|
|
||||||
/**
|
|
||||||
* The table associated with the model.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $fillable = ['organism_result_id','antibiotic_id','disk_diffusion','mic','sensitive','is_hide','created_at','created_by','updated_at','updated_by','record_status_id'];
|
|
||||||
|
|
||||||
public static function boot()
|
|
||||||
{
|
|
||||||
parent::boot();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Models;
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
||||||
use MongoDB\Driver\Session;
|
|
||||||
use App\Traits\AuditLogTrait;
|
|
||||||
|
|
||||||
class Appointment extends BaseModel
|
|
||||||
{
|
|
||||||
protected $table = "appointments";
|
|
||||||
public $timestamps = false;
|
|
||||||
use HasFactory;
|
|
||||||
use AuditLogTrait;
|
|
||||||
/**
|
|
||||||
* The table associated with the model.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $fillable = ['patient_id','appointment_date','appointment_type','doctor_id','description','lab_id','created_at','created_by','updated_at','updated_by','record_status_id'];
|
|
||||||
|
|
||||||
public static function boot()
|
|
||||||
{
|
|
||||||
parent::boot();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function patient(){
|
|
||||||
return $this->belongsTo(Patient::class, 'patient_id', 'id');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function doctor(){
|
|
||||||
return $this->belongsTo(Physician::class, 'doctor_id','id');
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -23,6 +23,8 @@ class BaseModel extends Model
|
|||||||
const CREATED_BY_FIELD = 'created_by';
|
const CREATED_BY_FIELD = 'created_by';
|
||||||
const UPDATED_AT_FIELD = 'updated_at';
|
const UPDATED_AT_FIELD = 'updated_at';
|
||||||
const UPDATED_BY_FIELD = 'updated_by';
|
const UPDATED_BY_FIELD = 'updated_by';
|
||||||
|
const DELETED_AT_FIELD = 'deleted_at';
|
||||||
|
const DELETED_BY_FIELD = 'deleted_by';
|
||||||
|
|
||||||
protected static function boot(){
|
protected static function boot(){
|
||||||
parent::boot();
|
parent::boot();
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Models;
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
||||||
|
|
||||||
class Comment extends BaseModel
|
|
||||||
{
|
|
||||||
public $timestamps = false;
|
|
||||||
use HasFactory;
|
|
||||||
/**
|
|
||||||
* The table associated with the model.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $fillable = ['comment_desc','sample_type_id','lab_id', BaseModel::CREATED_AT_FIELD, BaseModel::CREATED_BY_FIELD, BaseModel::UPDATED_AT_FIELD, BaseModel::UPDATED_BY_FIELD, BaseModel::RECORD_STATUS_FIELD];
|
|
||||||
|
|
||||||
public static function boot()
|
|
||||||
{
|
|
||||||
parent::boot();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function sample_type(){
|
|
||||||
return $this->belongsTo('App\Models\SampleType','sample_type_id', 'id');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Models;
|
|
||||||
use App\Enums\RecordStatusEnum;
|
|
||||||
use App\Models\Traits\HasLocalizedName;
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
||||||
use Illuminate\Support\Facades\Session;
|
|
||||||
|
|
||||||
class Department extends BaseModel
|
|
||||||
{
|
|
||||||
public $timestamps = false;
|
|
||||||
use HasFactory;
|
|
||||||
/**
|
|
||||||
* The table associated with the model.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
use HasLocalizedName;
|
|
||||||
|
|
||||||
|
|
||||||
protected $table='departments';
|
|
||||||
|
|
||||||
protected $fillable = ['name_en', 'weight', 'lab_id'];
|
|
||||||
|
|
||||||
protected $appends = ['name'];
|
|
||||||
|
|
||||||
public static function boot()
|
|
||||||
{
|
|
||||||
parent::boot();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function lab(){
|
|
||||||
return $this->belongsTo('App\Models\Laboratory', 'lab_id','id');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function samples(){
|
|
||||||
return $this->hasMany(SampleType::class, 'department_id')->where(BaseModel::RECORD_STATUS_FIELD, RecordStatusEnum::ACTIVE)->where('lab_id', Session::get('base_lab_id'))
|
|
||||||
->orderBy('weight');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,57 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Models;
|
|
||||||
use App\Enums\RecordStatusEnum;
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
||||||
|
|
||||||
class Invoice extends BaseModel
|
|
||||||
{
|
|
||||||
public $timestamps = false;
|
|
||||||
use HasFactory;
|
|
||||||
/**
|
|
||||||
* The table associated with the model.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $table = 'invoices';
|
|
||||||
|
|
||||||
protected $fillable = ['invoice_code', 'sample_id', 'total', 'discount','discount_type', 'gross_total', 'deposit', 'bank_deposit', 'balance',
|
|
||||||
'pay_type', 'invoice_date', 'invoice_note', 'bank_name', 'transaction_ref', 'lab_id', 'is_hide_discount', 'first_paid_date','exchange_rate', BaseModel::CREATED_AT_FIELD, BaseModel::CREATED_BY_FIELD,
|
|
||||||
BaseModel::UPDATED_AT_FIELD, BaseModel::UPDATED_BY_FIELD, BaseModel::RECORD_STATUS_FIELD
|
|
||||||
];
|
|
||||||
|
|
||||||
protected $hidden = [BaseModel::CREATED_AT_FIELD, BaseModel::CREATED_BY_FIELD, BaseModel::UPDATED_AT_FIELD, BaseModel::UPDATED_BY_FIELD, BaseModel::RECORD_STATUS_FIELD];
|
|
||||||
|
|
||||||
public static function boot()
|
|
||||||
{
|
|
||||||
parent::boot();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function lab(){
|
|
||||||
return $this->belongsTo(Laboratory::class, 'lab_id','id');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function sample(){
|
|
||||||
return $this->belongsTo(Sample::class, 'sample_id','id');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function invoiceDetail(){
|
|
||||||
return $this->hasMany(InvoiceDetail::class, 'invoice_id', 'id')->where(BaseModel::RECORD_STATUS_FIELD, RecordStatusEnum::ACTIVE);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function repayments(){
|
|
||||||
return $this->hasMany(Repayment::class, 'invoice_id', 'id')->where(BaseModel::RECORD_STATUS_FIELD, RecordStatusEnum::ACTIVE);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function creator()
|
|
||||||
{
|
|
||||||
return $this->belongsTo(User::class, 'created_by');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function modifier()
|
|
||||||
{
|
|
||||||
return $this->belongsTo(User::class, 'updated_by');
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Models;
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
||||||
|
|
||||||
class InvoiceDetail extends BaseModel
|
|
||||||
{
|
|
||||||
public $timestamps = false;
|
|
||||||
use HasFactory;
|
|
||||||
/**
|
|
||||||
* The table associated with the model.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $table = 'invoice_details';
|
|
||||||
|
|
||||||
protected $fillable = ['invoice_id', 'test_sample_id', 'test_name', 'weight', 'qty', 'unit_price', 'discount_type', 'discount', BaseModel::CREATED_AT_FIELD, BaseModel::CREATED_BY_FIELD,
|
|
||||||
BaseModel::UPDATED_AT_FIELD, BaseModel::UPDATED_BY_FIELD, BaseModel::RECORD_STATUS_FIELD
|
|
||||||
];
|
|
||||||
|
|
||||||
protected $hidden = [BaseModel::CREATED_AT_FIELD, BaseModel::CREATED_BY_FIELD, BaseModel::UPDATED_AT_FIELD, BaseModel::UPDATED_BY_FIELD, BaseModel::RECORD_STATUS_FIELD];
|
|
||||||
|
|
||||||
public static function boot()
|
|
||||||
{
|
|
||||||
parent::boot();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testSample(){
|
|
||||||
return $this->belongsTo(TestSample::class, 'test_sample_id', 'id');
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Models;
|
|
||||||
use App\Enums\RecordStatusEnum;
|
|
||||||
use App\Models\Traits\HasLocalizedName;
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
||||||
use Illuminate\Support\Facades\Session;
|
|
||||||
use App\Traits\AuditLogTrait;
|
|
||||||
|
|
||||||
class Laboratory extends BaseModel
|
|
||||||
{
|
|
||||||
public $timestamps = false;
|
|
||||||
use HasFactory;
|
|
||||||
use HasLocalizedName;
|
|
||||||
use AuditLogTrait;
|
|
||||||
/**
|
|
||||||
* The table associated with the model.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
|
|
||||||
protected $appends = ['name'];
|
|
||||||
|
|
||||||
protected $primaryKey = 'id';
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
protected $fillable = [
|
|
||||||
'name_en', 'name_kh', 'short_name', 'address_en', 'address_kh', 'sample_number', 'patient_code', 'is_hide_inv_discount',
|
|
||||||
'verify_label', 'technician_label', 'logo', 'discount_type','currency', BaseModel::CREATED_AT_FIELD, 'start_date', 'end_date',
|
|
||||||
'phone_number', 'email', 'shareable_lab_result','allow_external_request','telegrambot','exchange_rate','result_header_id','show_result_footer',
|
|
||||||
'abnormal_result_font_weight','abnormal_text_color','is_hide_comission_percentage','invoice_template_id','alternative_logo','alter_verify_sign','alter_labtech_sign',
|
|
||||||
'alternative_footer', 'footer', 'is_auto_make_invoice',
|
|
||||||
BaseModel::CREATED_BY_FIELD, BaseModel::UPDATED_AT_FIELD, BaseModel::UPDATED_BY_FIELD, BaseModel::RECORD_STATUS_FIELD
|
|
||||||
];
|
|
||||||
|
|
||||||
public static function boot()
|
|
||||||
{
|
|
||||||
parent::boot();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function userLabCovers(){
|
|
||||||
return $this->hasMany('App\Models\UserLabCover', 'lab_id','id')->where('record_status_id', RecordStatusEnum::ACTIVE);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function labUsers(){
|
|
||||||
return $this->hasMany('App\Models\UserLabCover', 'lab_id','id')->where('record_status_id', RecordStatusEnum::ACTIVE)->where('lab_id', Session::get('base_lab_id'));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -13,7 +13,7 @@ class Organism extends BaseModel
|
|||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $fillable = ['name_en', 'weight', 'is_bold', 'lab_id'];
|
protected $fillable = ['name_en', 'weight', 'is_bold', 'organization_id'];
|
||||||
|
|
||||||
public static function boot()
|
public static function boot()
|
||||||
{
|
{
|
||||||
@@ -21,7 +21,7 @@ class Organism extends BaseModel
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function lab(){
|
public function lab(){
|
||||||
return $this->belongsTo('App\Models\Laboratory', 'lab_id','id');
|
return $this->belongsTo('App\Models\Organization', 'organization_id','id');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Models;
|
|
||||||
use App\Enums\RecordStatusEnum;
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
||||||
|
|
||||||
class OrganismResult extends BaseModel
|
|
||||||
{
|
|
||||||
public $timestamps = false;
|
|
||||||
use HasFactory;
|
|
||||||
/**
|
|
||||||
* The table associated with the model.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $fillable = ['organism_id','test_result_id','quantity_id','contaminant','lab_id','created_at','created_by','updated_at','updated_by','record_status_id'];
|
|
||||||
|
|
||||||
public static function boot()
|
|
||||||
{
|
|
||||||
parent::boot();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
47
app/Models/Organization.php
Normal file
47
app/Models/Organization.php
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
use App\Enums\RecordStatusEnum;
|
||||||
|
use App\Models\Traits\HasLocalizedName;
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Support\Facades\Session;
|
||||||
|
use App\Traits\AuditLogTrait;
|
||||||
|
|
||||||
|
class Organization extends BaseModel
|
||||||
|
{
|
||||||
|
public $timestamps = false;
|
||||||
|
use HasFactory;
|
||||||
|
use HasLocalizedName;
|
||||||
|
use AuditLogTrait;
|
||||||
|
/**
|
||||||
|
* The table associated with the model.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
|
||||||
|
protected $appends = ['name'];
|
||||||
|
|
||||||
|
protected $primaryKey = 'id';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'code', 'name_en','name_kh', 'latitude', 'longtitude', 'registered_at', 'village_id',
|
||||||
|
BaseModel::CREATED_BY_FIELD, BaseModel::UPDATED_AT_FIELD, BaseModel::UPDATED_BY_FIELD,
|
||||||
|
BaseModel::DELETED_AT_FIELD, BaseModel::DELETED_BY_FIELD, BaseModel::RECORD_STATUS_FIELD
|
||||||
|
];
|
||||||
|
|
||||||
|
public static function boot()
|
||||||
|
{
|
||||||
|
parent::boot();
|
||||||
|
}
|
||||||
|
|
||||||
|
// public function userLabCovers(){
|
||||||
|
// return $this->hasMany('App\Models\UserOrganization', 'organization_id','id')->where('record_status_id', RecordStatusEnum::ACTIVE);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public function labUsers(){
|
||||||
|
// return $this->hasMany('App\Models\UserOrganization', 'organization_id','id')->where('record_status_id', RecordStatusEnum::ACTIVE)->where('organization_id', Session::get('base_organization_id'));
|
||||||
|
// }
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,74 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Models;
|
|
||||||
use App\Enums\RecordStatusEnum;
|
|
||||||
use DateTime;
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
||||||
use Illuminate\Support\Facades\App;
|
|
||||||
use Illuminate\Support\Facades\Session;
|
|
||||||
use App\Traits\AuditLogTrait;
|
|
||||||
|
|
||||||
class Patient extends BaseModel
|
|
||||||
{
|
|
||||||
public $timestamps = false;
|
|
||||||
use HasFactory;
|
|
||||||
use AuditLogTrait;
|
|
||||||
/**
|
|
||||||
* The table associated with the model.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
|
|
||||||
protected $fillable =
|
|
||||||
[
|
|
||||||
'name_en',
|
|
||||||
'dob',
|
|
||||||
'patient_uuid',
|
|
||||||
'gender',
|
|
||||||
'marital_status',
|
|
||||||
'phone_number',
|
|
||||||
'khid_number',
|
|
||||||
'house_number',
|
|
||||||
'street_number',
|
|
||||||
'province_id',
|
|
||||||
'district_id',
|
|
||||||
'commune_id',
|
|
||||||
'village_id',
|
|
||||||
'lab_id',
|
|
||||||
self::CREATED_AT_FIELD,
|
|
||||||
self::CREATED_BY_FIELD,
|
|
||||||
self::UPDATED_BY_FIELD,
|
|
||||||
BaseModel::RECORD_STATUS_FIELD
|
|
||||||
];
|
|
||||||
|
|
||||||
public static function boot()
|
|
||||||
{
|
|
||||||
parent::boot();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function province(){
|
|
||||||
return $this->belongsTo(Province::class,'province_id','id');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function district(){
|
|
||||||
return $this->belongsTo(District::class,'district_id','id');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function commune(){
|
|
||||||
return $this->belongsTo(Commune::class,'commune_id','id');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function village(){
|
|
||||||
return $this->belongsTo(Village::class,'village_id','id');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function samples(){
|
|
||||||
return $this->hasMany(Sample::class,'patient_id','id')
|
|
||||||
->where([BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE, 'lab_id' => Session::get('base_lab_id')]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function telegramChatId(){
|
|
||||||
return $this->belongsTo(PatientTelegram::class,'id', 'patient_id');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Models;
|
|
||||||
use App\Enums\RecordStatusEnum;
|
|
||||||
use DateTime;
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
||||||
use Illuminate\Support\Facades\App;
|
|
||||||
use Illuminate\Support\Facades\Session;
|
|
||||||
|
|
||||||
class PatientTelegram extends BaseModel
|
|
||||||
{
|
|
||||||
public $timestamps = false;
|
|
||||||
use HasFactory;
|
|
||||||
/**
|
|
||||||
* The table associated with the model.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
|
|
||||||
protected $table = 'patient_telegram';
|
|
||||||
|
|
||||||
protected $fillable =
|
|
||||||
[
|
|
||||||
'patient_id',
|
|
||||||
'chat_id',
|
|
||||||
self::CREATED_AT_FIELD,
|
|
||||||
self::CREATED_BY_FIELD,
|
|
||||||
self::UPDATED_BY_FIELD,
|
|
||||||
BaseModel::RECORD_STATUS_FIELD
|
|
||||||
];
|
|
||||||
|
|
||||||
public static function boot()
|
|
||||||
{
|
|
||||||
parent::boot();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Models;
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
||||||
|
|
||||||
class PatientType extends BaseModel
|
|
||||||
{
|
|
||||||
public $timestamps = false;
|
|
||||||
use HasFactory;
|
|
||||||
/**
|
|
||||||
* The table associated with the model.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
|
|
||||||
protected $fillable = ['name_en', 'range_start', 'range_start_unit','range_en','range_end_unit','lab_id'];
|
|
||||||
|
|
||||||
public static function boot()
|
|
||||||
{
|
|
||||||
parent::boot();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -12,7 +12,7 @@ class Physician extends BaseModel
|
|||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $fillable = ['name_en', 'name_kh','phone','logo','footer','lab_id','is_default'];
|
protected $fillable = ['name_en', 'name_kh','phone','logo','footer','organization_id','is_default'];
|
||||||
|
|
||||||
protected $hidden = ['created_at', 'created_by', 'updated_at', 'updated_by','record_status_id'];
|
protected $hidden = ['created_at', 'created_by', 'updated_at', 'updated_by','record_status_id'];
|
||||||
|
|
||||||
@@ -22,7 +22,7 @@ class Physician extends BaseModel
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function lab(){
|
public function lab(){
|
||||||
return $this->belongsTo('App\Models\Laboratory', 'lab_id','id');
|
return $this->belongsTo('App\Models\Organization', 'organization_id','id');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,32 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Models;
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
||||||
|
|
||||||
class PhysicianCommission extends BaseModel
|
|
||||||
{
|
|
||||||
public $timestamps = false;
|
|
||||||
use HasFactory;
|
|
||||||
/**
|
|
||||||
* The table associated with the model.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $table = 'physician_commisssion';
|
|
||||||
|
|
||||||
protected $primaryKey = 'id';
|
|
||||||
|
|
||||||
protected $fillable = ['physician_id', 'test_sample_id','commission_rate','partner_price','commission_type', 'lab_id', 'created_at', 'created_by', 'updated_at', 'updated_by','record_status_id'];
|
|
||||||
|
|
||||||
protected $hidden = ['created_at', 'created_by', 'updated_at', 'updated_by','record_status_id'];
|
|
||||||
|
|
||||||
public static function boot()
|
|
||||||
{
|
|
||||||
parent::boot();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function lab(){
|
|
||||||
return $this->belongsTo('App\Models\Laboratory', 'lab_id','id');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -14,7 +14,7 @@ class PublicationReceiver extends BaseModel
|
|||||||
*/
|
*/
|
||||||
protected $table = 'publication_receivers';
|
protected $table = 'publication_receivers';
|
||||||
protected $primaryKey = 'id';
|
protected $primaryKey = 'id';
|
||||||
protected $fillable = ['lab_id','publication_id', BaseModel::CREATED_AT_FIELD, BaseModel::CREATED_BY_FIELD, BaseModel::UPDATED_AT_FIELD, BaseModel::UPDATED_BY_FIELD, BaseModel::RECORD_STATUS_FIELD];
|
protected $fillable = ['organization_id','publication_id', BaseModel::CREATED_AT_FIELD, BaseModel::CREATED_BY_FIELD, BaseModel::UPDATED_AT_FIELD, BaseModel::UPDATED_BY_FIELD, BaseModel::RECORD_STATUS_FIELD];
|
||||||
|
|
||||||
public static function boot()
|
public static function boot()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Models;
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
||||||
|
|
||||||
class Quantity extends BaseModel
|
|
||||||
{
|
|
||||||
public $timestamps = false;
|
|
||||||
use HasFactory;
|
|
||||||
/**
|
|
||||||
* The table associated with the model.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $fillable = ['quantity_name','lab_id', BaseModel::CREATED_AT_FIELD, BaseModel::CREATED_BY_FIELD, BaseModel::UPDATED_AT_FIELD, BaseModel::UPDATED_BY_FIELD, BaseModel::RECORD_STATUS_FIELD];
|
|
||||||
|
|
||||||
public static function boot()
|
|
||||||
{
|
|
||||||
parent::boot();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function lab(){
|
|
||||||
return $this->belongsTo('App\Models\Laboratory', 'lab_id','id');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Models;
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
||||||
|
|
||||||
class RejectComment extends BaseModel
|
|
||||||
{
|
|
||||||
public $timestamps = false;
|
|
||||||
use HasFactory;
|
|
||||||
/**
|
|
||||||
* The table associated with the model.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
|
|
||||||
protected $fillable = [
|
|
||||||
'sample_condition_id',
|
|
||||||
'reject_comment',
|
|
||||||
'lab_id',
|
|
||||||
BaseModel::CREATED_AT_FIELD,
|
|
||||||
BaseModel::CREATED_BY_FIELD
|
|
||||||
];
|
|
||||||
|
|
||||||
public static function boot()
|
|
||||||
{
|
|
||||||
parent::boot();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Models;
|
|
||||||
use App\Enums\RecordStatusEnum;
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
||||||
|
|
||||||
class Repayment extends BaseModel
|
|
||||||
{
|
|
||||||
public $timestamps = false;
|
|
||||||
use HasFactory;
|
|
||||||
/**
|
|
||||||
* The table associated with the model.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $table = 'repayments';
|
|
||||||
protected $primaryKey='id';
|
|
||||||
|
|
||||||
protected $fillable = [
|
|
||||||
'invoice_id',
|
|
||||||
'amount_to_pay',
|
|
||||||
'discount',
|
|
||||||
'amount_after_discount',
|
|
||||||
'discount_type',
|
|
||||||
'cash_repayment_amount',
|
|
||||||
'bank_repayment_amount',
|
|
||||||
'repayment_date',
|
|
||||||
'payment_method',
|
|
||||||
'bank_name',
|
|
||||||
'transaction_ref',
|
|
||||||
'notes',
|
|
||||||
'lab_id',
|
|
||||||
'exchange_rate',
|
|
||||||
BaseModel::CREATED_AT_FIELD,
|
|
||||||
BaseModel::CREATED_BY_FIELD,
|
|
||||||
BaseModel::UPDATED_AT_FIELD,
|
|
||||||
BaseModel::UPDATED_BY_FIELD,
|
|
||||||
BaseModel::RECORD_STATUS_FIELD
|
|
||||||
];
|
|
||||||
|
|
||||||
protected $hidden = [
|
|
||||||
'lab_id',
|
|
||||||
BaseModel::CREATED_AT_FIELD,
|
|
||||||
BaseModel::CREATED_BY_FIELD,
|
|
||||||
BaseModel::UPDATED_AT_FIELD,
|
|
||||||
BaseModel::UPDATED_BY_FIELD,
|
|
||||||
BaseModel::RECORD_STATUS_FIELD
|
|
||||||
];
|
|
||||||
|
|
||||||
public static function boot()
|
|
||||||
{
|
|
||||||
parent::boot();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function invoice(){
|
|
||||||
return $this->belongsTo(Invoice::class, 'invoice_id','id');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -18,10 +18,10 @@ class Role extends BaseModel
|
|||||||
parent::boot();
|
parent::boot();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected $fillable = ['name_en', 'lab_id'];
|
protected $fillable = ['name_en', 'organization_id'];
|
||||||
|
|
||||||
public function lab(){
|
public function lab(){
|
||||||
return $this->belongsTo(Laboratory::class, 'lab_id');
|
return $this->belongsTo(Organization::class, 'organization_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ class Sample extends BaseModel
|
|||||||
|
|
||||||
protected $fillable = ['patient_id','admission_date','sample_number','sample_source_id','physician_id',
|
protected $fillable = ['patient_id','admission_date','sample_number','sample_source_id','physician_id',
|
||||||
'sample_condition','reject_comment_id','collected_date','received_date','diagnosis','is_urgent', 'is_printed', 'printed_by','printed_at',
|
'sample_condition','reject_comment_id','collected_date','received_date','diagnosis','is_urgent', 'is_printed', 'printed_by','printed_at',
|
||||||
'approved_by','approved_date', 'requested_date','is_accept_request','lab_id', BaseModel::CREATED_AT_FIELD, BaseModel::CREATED_BY_FIELD,
|
'approved_by','approved_date', 'requested_date','is_accept_request','organization_id', BaseModel::CREATED_AT_FIELD, BaseModel::CREATED_BY_FIELD,
|
||||||
BaseModel::UPDATED_AT_FIELD, BaseModel::UPDATED_BY_FIELD, BaseModel::RECORD_STATUS_FIELD,
|
BaseModel::UPDATED_AT_FIELD, BaseModel::UPDATED_BY_FIELD, BaseModel::RECORD_STATUS_FIELD,
|
||||||
'result_template_id'
|
'result_template_id'
|
||||||
];
|
];
|
||||||
@@ -33,27 +33,13 @@ class Sample extends BaseModel
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function lab(){
|
public function lab(){
|
||||||
return $this->belongsTo(Laboratory::class, 'lab_id','id');
|
return $this->belongsTo(Organization::class, 'organization_id','id');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function patient(){
|
public function patient(){
|
||||||
return $this->belongsTo(Patient::class, 'patient_id','id');
|
return $this->belongsTo(Patient::class, 'patient_id','id');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function sample_source(){
|
|
||||||
return $this->belongsTo(SampleSource::class, 'sample_source_id','id');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function sample_details(){
|
|
||||||
return $this->hasMany(SampleDetail::class, 'sample_id', 'id')
|
|
||||||
->where([BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE, 'lab_id' => Session::get('base_lab_id')]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function sample_tests(){
|
|
||||||
return $this->hasMany(TestResult::class, 'sample_id', 'id')
|
|
||||||
->where([BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE, 'lab_id' => Session::get('base_lab_id')]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function entryBy(){
|
public function entryBy(){
|
||||||
return $this->belongsTo(User::class, 'created_by', 'id');
|
return $this->belongsTo(User::class, 'created_by', 'id');
|
||||||
}
|
}
|
||||||
@@ -66,149 +52,5 @@ class Sample extends BaseModel
|
|||||||
return $this->belongsTo(Physician::class, 'physician_id', 'id');
|
return $this->belongsTo(Physician::class, 'physician_id', 'id');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function invoice(){
|
|
||||||
return $this->belongsTo(Invoice::class, 'id', 'sample_id')->where([BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE, 'lab_id' => Session::get('base_lab_id')]);
|
|
||||||
}
|
|
||||||
|
|
||||||
function getStateAttribute(){
|
|
||||||
$state = '#FF0000';
|
|
||||||
$sampleCondition = $this->sample_condition;
|
|
||||||
$samplePrinted = $this->is_printed;
|
|
||||||
$sampleId = $this->id;
|
|
||||||
|
|
||||||
$resultItemsData = DB::select('
|
|
||||||
SELECT
|
|
||||||
s.id,
|
|
||||||
s.`sample_number`,
|
|
||||||
SUM(IF(ts.`field_type`>0, 1,0)) AS non_heading_tests,
|
|
||||||
SUM(IF(ts.`field_type` IN(1,4) AND tr.test_result IS NOT NULL, 1, 0)) AS done_numeric_tests,
|
|
||||||
SUM(IF(ts.`field_type` IN(2,3) AND org_result.total_org_result>0, 1, 0)) AS done_org_test
|
|
||||||
FROM samples s
|
|
||||||
LEFT JOIN test_results tr
|
|
||||||
ON tr.`sample_id` = s.`id`
|
|
||||||
AND s.`lab_id` = tr.`lab_id`
|
|
||||||
LEFT JOIN test_samples ts
|
|
||||||
ON ts.id = tr.`test_sample_id`
|
|
||||||
AND ts.lab_id = tr.lab_id
|
|
||||||
LEFT JOIN sample_types st
|
|
||||||
ON st.id = ts.`sample_type_id`
|
|
||||||
LEFT JOIN(
|
|
||||||
SELECT
|
|
||||||
tr.`id`,
|
|
||||||
COUNT(*) AS total_org_result
|
|
||||||
FROM samples s
|
|
||||||
INNER JOIN test_results tr
|
|
||||||
ON tr.`sample_id` = s.`id`
|
|
||||||
AND s.`lab_id` = tr.`lab_id`
|
|
||||||
INNER JOIN organism_results orgr
|
|
||||||
ON orgr.`test_result_id` = tr.`id`
|
|
||||||
WHERE s.id = '.$sampleId.'
|
|
||||||
AND tr.`record_status_id` = 1
|
|
||||||
AND orgr.`record_status_id` = 1
|
|
||||||
group by tr.id
|
|
||||||
) AS org_result
|
|
||||||
ON org_result.id = tr.`id`
|
|
||||||
WHERE s.`id` = '.$sampleId.'
|
|
||||||
AND (tr.`record_status_id` = 1 OR tr.`record_status_id` IS NULL)
|
|
||||||
AND (st.`record_status_id` = 1 OR st.`record_status_id` IS NULL)
|
|
||||||
GROUP BY s.`sample_number`, s.id');
|
|
||||||
|
|
||||||
$non_heading_tests = 0;
|
|
||||||
$done_numeric_tests = 0;
|
|
||||||
$done_org_test = 0;
|
|
||||||
foreach ($resultItemsData as $v){
|
|
||||||
$non_heading_tests = $v->non_heading_tests;
|
|
||||||
$done_numeric_tests = $v->done_numeric_tests;
|
|
||||||
$done_org_test = $v->done_org_test;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!is_null($sampleCondition) && $sampleCondition==0) $state = '#FFA500'; // orange for rejected
|
|
||||||
elseif(($sampleCondition!=0 || is_null($sampleCondition)) && $samplePrinted) $state = '#3b86d1'; // blue for printed
|
|
||||||
else {
|
|
||||||
if($non_heading_tests==0) $state = '#FF0000';
|
|
||||||
else if($non_heading_tests>0 && $non_heading_tests == ($done_numeric_tests+$done_org_test)){
|
|
||||||
$state = '#008000'; // Green for fully completed
|
|
||||||
}
|
|
||||||
elseif($non_heading_tests>0 && ($done_numeric_tests+$done_org_test)==0){
|
|
||||||
$state = '#FF0000'; // Red for No result at all
|
|
||||||
}
|
|
||||||
elseif(($done_numeric_tests+$done_org_test)>0 && $non_heading_tests >($done_numeric_tests+$done_org_test)){
|
|
||||||
$state = '#FFFF00'; // Yellow for complete some
|
|
||||||
}
|
|
||||||
else $state = '#FF0000'; //Silver for known state
|
|
||||||
}
|
|
||||||
return $state;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getProgressAttribute(){
|
|
||||||
$state = '#FF0000';
|
|
||||||
$sampleCondition = $this->sample_condition;
|
|
||||||
$samplePrinted = $this->is_printed;
|
|
||||||
$sampleId = $this->id;
|
|
||||||
|
|
||||||
$resultItemsData = DB::select('
|
|
||||||
SELECT
|
|
||||||
s.id,
|
|
||||||
s.`sample_number`,
|
|
||||||
SUM(IF(ts.`field_type`>0, 1,0)) AS non_heading_tests,
|
|
||||||
SUM(IF(ts.`field_type` IN(1,4) AND tr.test_result IS NOT NULL, 1, 0)) AS done_numeric_tests,
|
|
||||||
SUM(IF(ts.`field_type` IN(2,3) AND org_result.total_org_result>0, 1, 0)) AS done_org_test
|
|
||||||
FROM samples s
|
|
||||||
LEFT JOIN test_results tr
|
|
||||||
ON tr.`sample_id` = s.`id`
|
|
||||||
AND s.`lab_id` = tr.`lab_id`
|
|
||||||
LEFT JOIN test_samples ts
|
|
||||||
ON ts.id = tr.`test_sample_id`
|
|
||||||
AND ts.lab_id = tr.lab_id
|
|
||||||
LEFT JOIN sample_types st
|
|
||||||
ON st.id = ts.`sample_type_id`
|
|
||||||
LEFT JOIN(
|
|
||||||
SELECT
|
|
||||||
tr.`id`,
|
|
||||||
COUNT(*) AS total_org_result
|
|
||||||
FROM samples s
|
|
||||||
INNER JOIN test_results tr
|
|
||||||
ON tr.`sample_id` = s.`id`
|
|
||||||
AND s.`lab_id` = tr.`lab_id`
|
|
||||||
INNER JOIN organism_results orgr
|
|
||||||
ON orgr.`test_result_id` = tr.`id`
|
|
||||||
WHERE s.id = '.$sampleId.'
|
|
||||||
AND tr.`record_status_id` = 1
|
|
||||||
AND orgr.`record_status_id` = 1
|
|
||||||
group by tr.id
|
|
||||||
) AS org_result
|
|
||||||
ON org_result.id = tr.`id`
|
|
||||||
WHERE s.`id` = '.$sampleId.'
|
|
||||||
AND (tr.`record_status_id` = 1 OR tr.`record_status_id` IS NULL)
|
|
||||||
AND (st.`record_status_id` = 1 OR st.`record_status_id` IS NULL)
|
|
||||||
GROUP BY s.`sample_number`, s.id');
|
|
||||||
|
|
||||||
$non_heading_tests = 0;
|
|
||||||
$done_numeric_tests = 0;
|
|
||||||
$done_org_test = 0;
|
|
||||||
foreach ($resultItemsData as $v){
|
|
||||||
$non_heading_tests = $v->non_heading_tests;
|
|
||||||
$done_numeric_tests = $v->done_numeric_tests;
|
|
||||||
$done_org_test = $v->done_org_test;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!is_null($sampleCondition) && $sampleCondition==0) $state = __('sample.filter_rejected'); // '#FFA500'; // orange for rejected
|
|
||||||
elseif(($sampleCondition!=0 || is_null($sampleCondition)) && $samplePrinted) $state = __('sample.filter_printed'); // '#3b86d1'; // blue for printed
|
|
||||||
else {
|
|
||||||
if($non_heading_tests==0) $state = __('sample.filter_pending');
|
|
||||||
else if($non_heading_tests>0 && $non_heading_tests == ($done_numeric_tests+$done_org_test)){
|
|
||||||
$state = __('sample.filter_completed'); // '#008000'; // Green for fully completed
|
|
||||||
}
|
|
||||||
elseif($non_heading_tests>0 && ($done_numeric_tests+$done_org_test)==0){
|
|
||||||
$state = __('sample.filter_pending'); //'#FF0000'; // Red for No result at all
|
|
||||||
}
|
|
||||||
elseif(($done_numeric_tests+$done_org_test)>0 && $non_heading_tests >($done_numeric_tests+$done_org_test)){
|
|
||||||
$state = __('sample.filter_processing'); // '#FFFF00'; // Yellow for complete some
|
|
||||||
}
|
|
||||||
else $state = __('sample.filter_pending'); //Silver for known state
|
|
||||||
}
|
|
||||||
return $state;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,35 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Models;
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
||||||
|
|
||||||
class SampleDetail extends BaseModel
|
|
||||||
{
|
|
||||||
public $timestamps = false;
|
|
||||||
use HasFactory;
|
|
||||||
/**
|
|
||||||
* The table associated with the model.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $fillable = [
|
|
||||||
'sample_id',
|
|
||||||
'sample_type_id',
|
|
||||||
'test_date',
|
|
||||||
'lab_technician_id',
|
|
||||||
'sample_comment',
|
|
||||||
'sample_descr',
|
|
||||||
'sample_volume_1',
|
|
||||||
'sample_volume_2',
|
|
||||||
'printed_date',
|
|
||||||
'printed_by',
|
|
||||||
'lab_id'
|
|
||||||
];
|
|
||||||
|
|
||||||
public static function boot()
|
|
||||||
{
|
|
||||||
parent::boot();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Models;
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
||||||
|
|
||||||
class SampleSource extends BaseModel
|
|
||||||
{
|
|
||||||
public $timestamps = false;
|
|
||||||
use HasFactory;
|
|
||||||
/**
|
|
||||||
* The table associated with the model.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $fillable = ['name_en', 'name_kh', 'lab_id','is_default'];
|
|
||||||
|
|
||||||
public static function boot()
|
|
||||||
{
|
|
||||||
parent::boot();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function lab(){
|
|
||||||
return $this->belongsTo('App\Models\Laboratory', 'lab_id','id');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function telegramChatId(){
|
|
||||||
return $this->belongsTo(SampleSourceTelegram::class,'id', 'sample_source_id');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Models;
|
|
||||||
use App\Enums\RecordStatusEnum;
|
|
||||||
use DateTime;
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
||||||
use Illuminate\Support\Facades\App;
|
|
||||||
use Illuminate\Support\Facades\Session;
|
|
||||||
|
|
||||||
class SampleSourceTelegram extends BaseModel
|
|
||||||
{
|
|
||||||
public $timestamps = false;
|
|
||||||
use HasFactory;
|
|
||||||
/**
|
|
||||||
* The table associated with the model.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
|
|
||||||
protected $table = 'sample_source_telegram';
|
|
||||||
|
|
||||||
protected $fillable =
|
|
||||||
[
|
|
||||||
'sample_source_id',
|
|
||||||
'chat_id',
|
|
||||||
self::CREATED_AT_FIELD,
|
|
||||||
self::CREATED_BY_FIELD,
|
|
||||||
self::UPDATED_BY_FIELD,
|
|
||||||
BaseModel::RECORD_STATUS_FIELD
|
|
||||||
];
|
|
||||||
|
|
||||||
public static function boot()
|
|
||||||
{
|
|
||||||
parent::boot();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -17,7 +17,7 @@ class SampleType extends BaseModel
|
|||||||
|
|
||||||
protected $table='sample_types';
|
protected $table='sample_types';
|
||||||
|
|
||||||
protected $fillable = ['name_en', 'weight', 'department_id','tube','description','lab_id','bg_color','color', 'enter_form_id', 'preview_form_id'];
|
protected $fillable = ['name_en', 'weight', 'department_id','tube','description','organization_id','bg_color','color', 'enter_form_id', 'preview_form_id'];
|
||||||
|
|
||||||
public static function boot()
|
public static function boot()
|
||||||
{
|
{
|
||||||
@@ -31,7 +31,7 @@ class SampleType extends BaseModel
|
|||||||
public function testSamples(){
|
public function testSamples(){
|
||||||
return $this->hasMany(TestSample::class, 'sample_type_id')
|
return $this->hasMany(TestSample::class, 'sample_type_id')
|
||||||
->where([BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
->where([BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
||||||
//->where('lab_id', Session::get('base_lab_id'))
|
//->where('organization_id', Session::get('base_organization_id'))
|
||||||
->orderBy('weight');
|
->orderBy('weight');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,43 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Models;
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
||||||
|
|
||||||
class Supplier extends BaseModel
|
|
||||||
{
|
|
||||||
public $timestamps = true;
|
|
||||||
use HasFactory;
|
|
||||||
/**
|
|
||||||
* The table associated with the model.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
|
|
||||||
protected $table = 'suppliers';
|
|
||||||
protected $primaryKey = 'id';
|
|
||||||
|
|
||||||
protected $fillable = [
|
|
||||||
'name_en',
|
|
||||||
'name_kh',
|
|
||||||
'contact_name',
|
|
||||||
'position',
|
|
||||||
'phone_number',
|
|
||||||
'email',
|
|
||||||
'address',
|
|
||||||
'website',
|
|
||||||
'vat_number',
|
|
||||||
'description',
|
|
||||||
'lab_id',
|
|
||||||
'created_at',
|
|
||||||
'created_by',
|
|
||||||
'updated_at',
|
|
||||||
'updated_by',
|
|
||||||
'record_status_id'
|
|
||||||
];
|
|
||||||
|
|
||||||
public static function boot()
|
|
||||||
{
|
|
||||||
parent::boot();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Models;
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
||||||
|
|
||||||
class Test extends BaseModel
|
|
||||||
{
|
|
||||||
public $timestamps = true;
|
|
||||||
use HasFactory;
|
|
||||||
/**
|
|
||||||
* The table associated with the model.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
|
|
||||||
protected $table = 'tests';
|
|
||||||
|
|
||||||
protected $fillable = ['name_en','lab_id','created_at','created_by','record_status_id'];
|
|
||||||
|
|
||||||
public static function boot()
|
|
||||||
{
|
|
||||||
parent::boot();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function lab(){
|
|
||||||
return $this->belongsTo('App\Models\Laboratory', 'lab_id','id');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Models;
|
|
||||||
use App\Enums\RecordStatusEnum;
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
||||||
|
|
||||||
class TestCategory extends BaseModel
|
|
||||||
{
|
|
||||||
public $timestamps = false;
|
|
||||||
use HasFactory;
|
|
||||||
/**
|
|
||||||
* The table associated with the model.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
|
|
||||||
protected $table='test_categories';
|
|
||||||
|
|
||||||
protected $fillable = ['name_en', BaseModel::CREATED_AT_FIELD, BaseModel::CREATED_BY_FIELD, BaseModel::UPDATED_AT_FIELD, BaseModel::UPDATED_BY_FIELD, BaseModel::RECORD_STATUS_FIELD];
|
|
||||||
|
|
||||||
public static function boot()
|
|
||||||
{
|
|
||||||
parent::boot();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Models;
|
|
||||||
use App\Enums\RecordStatusEnum;
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
||||||
|
|
||||||
class TestGroup extends BaseModel
|
|
||||||
{
|
|
||||||
public $timestamps = false;
|
|
||||||
use HasFactory;
|
|
||||||
/**
|
|
||||||
* The table associated with the model.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
|
|
||||||
protected $table='test_groups';
|
|
||||||
|
|
||||||
protected $fillable = ['group_name', 'lab_id', BaseModel::CREATED_AT_FIELD, BaseModel::CREATED_BY_FIELD, BaseModel::UPDATED_AT_FIELD, BaseModel::UPDATED_BY_FIELD, BaseModel::RECORD_STATUS_FIELD];
|
|
||||||
|
|
||||||
public static function boot()
|
|
||||||
{
|
|
||||||
parent::boot();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGroupDetails(){
|
|
||||||
return $this->hasMany(TestGroupDetail::class, 'test_group_id', 'id')->where([BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE]);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Models;
|
|
||||||
use App\Enums\RecordStatusEnum;
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
||||||
|
|
||||||
class TestGroupDetail extends BaseModel
|
|
||||||
{
|
|
||||||
public $timestamps = false;
|
|
||||||
use HasFactory;
|
|
||||||
/**
|
|
||||||
* The table associated with the model.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
|
|
||||||
protected $table='test_group_details';
|
|
||||||
|
|
||||||
protected $fillable = ['test_group_id','test_sample_id', 'lab_id', BaseModel::CREATED_AT_FIELD, BaseModel::CREATED_BY_FIELD, BaseModel::UPDATED_AT_FIELD, BaseModel::UPDATED_BY_FIELD, BaseModel::RECORD_STATUS_FIELD];
|
|
||||||
|
|
||||||
public static function boot()
|
|
||||||
{
|
|
||||||
parent::boot();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Models;
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
||||||
|
|
||||||
class TestNormalValue extends BaseModel
|
|
||||||
{
|
|
||||||
public $timestamps = false;
|
|
||||||
use HasFactory;
|
|
||||||
/**
|
|
||||||
* The table associated with the model.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $fillable = ['test_sample_id','patient_type_id','sign','minimum','maximum',
|
|
||||||
BaseModel::CREATED_AT_FIELD, BaseModel::CREATED_BY_FIELD, BaseModel::UPDATED_AT_FIELD,
|
|
||||||
BaseModel::UPDATED_BY_FIELD, BaseModel::RECORD_STATUS_FIELD
|
|
||||||
];
|
|
||||||
|
|
||||||
public static function boot()
|
|
||||||
{
|
|
||||||
parent::boot();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Models;
|
|
||||||
use App\Enums\RecordStatusEnum;
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
||||||
|
|
||||||
class TestResult extends BaseModel
|
|
||||||
{
|
|
||||||
public $timestamps = false;
|
|
||||||
use HasFactory;
|
|
||||||
/**
|
|
||||||
* The table associated with the model.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
|
|
||||||
//protected $appends = ['usd_price'];
|
|
||||||
|
|
||||||
public static function boot()
|
|
||||||
{
|
|
||||||
parent::boot();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected $fillable = ['sample_id', 'test_sample_id','test_result', 'is_show', 'test_date', 'performed_by', 'lab_id', BaseModel::CREATED_AT_FIELD, BaseModel::CREATED_BY_FIELD];
|
|
||||||
|
|
||||||
function testSample(){
|
|
||||||
return $this->belongsTo(TestSample::class,'test_sample_id','id')->where(BaseModel::RECORD_STATUS_FIELD, RecordStatusEnum::ACTIVE);
|
|
||||||
}
|
|
||||||
|
|
||||||
// function organismResults(){
|
|
||||||
// return $this->hasMany(OrganismResult::class,'test_result_id','id')->where(BaseModel::RECORD_STATUS_FIELD, RecordStatusEnum::ACTIVE);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// function getUsdPriceAttribute(){
|
|
||||||
// return TestSample::query()->find($this->test_sample_id)->first()->usd_price;
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Models;
|
|
||||||
use App\Enums\RecordStatusEnum;
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
||||||
use Illuminate\Support\Facades\Session;
|
|
||||||
|
|
||||||
class TestSample extends BaseModel
|
|
||||||
{
|
|
||||||
public $timestamps = false;
|
|
||||||
use HasFactory;
|
|
||||||
/**
|
|
||||||
* The table associated with the model.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
|
|
||||||
protected $table='test_samples';
|
|
||||||
|
|
||||||
public static function boot()
|
|
||||||
{
|
|
||||||
parent::boot();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected $fillable = ['sample_type_id', 'test_id','heading_id', 'group_result','category', 'code',
|
|
||||||
'unit_sign','usd_price', 'weight', 'lab_id','field_type', 'formula', 'format',
|
|
||||||
'description','is_bold','autocomplete_bind', BaseModel::CREATED_AT_FIELD, BaseModel::CREATED_BY_FIELD];
|
|
||||||
|
|
||||||
public function test(){
|
|
||||||
return $this->belongsTo(Test::class, 'test_id','id');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function sample(){
|
|
||||||
return $this->belongsTo(SampleType::class, 'sample_type_id','id');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function lab(){
|
|
||||||
return $this->belongsTo(Laboratory::class, 'lab_id','id');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function organisms(){
|
|
||||||
return $this->hasMany(TestSampleOrganism::class, 'test_sample_id', 'id')->where(BaseModel::RECORD_STATUS_FIELD, RecordStatusEnum::ACTIVE);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function tests(){
|
|
||||||
return $this->hasMany(self::class, 'heading_id','id')->where([
|
|
||||||
BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE,
|
|
||||||
'lab_id' => Session::get('base_lab_id')
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function childTest(){
|
|
||||||
return $this->hasMany(self::class, 'heading_id','id')->where([
|
|
||||||
BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE,
|
|
||||||
'lab_id' => Session::get('base_lab_id')
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testValues(){
|
|
||||||
return $this->hasMany(TestNormalValue::class, 'test_sample_id', 'id')->where(BaseModel::RECORD_STATUS_FIELD, RecordStatusEnum::ACTIVE);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Models;
|
|
||||||
use App\Enums\RecordStatusEnum;
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
||||||
|
|
||||||
class TestSampleOrganism extends BaseModel
|
|
||||||
{
|
|
||||||
public $timestamps = false;
|
|
||||||
use HasFactory;
|
|
||||||
/**
|
|
||||||
* The table associated with the model.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
|
|
||||||
public static function boot()
|
|
||||||
{
|
|
||||||
parent::boot();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected $fillable = ['test_sample_id','organism_id','is_default', 'lab_id', 'created_at', 'created_by', 'updated_at', 'updated_by', 'record_status_id'];
|
|
||||||
|
|
||||||
protected $hidden = ['created_at', 'created_by', 'updated_at', 'updated_by'];
|
|
||||||
|
|
||||||
public function organism(){
|
|
||||||
return $this->belongsTo('App\Models\Organism', 'organism_id', 'id')->where(BaseModel::RECORD_STATUS_FIELD, RecordStatusEnum::ACTIVE);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -47,8 +47,8 @@ class User extends Authenticatable
|
|||||||
return $this->belongsTo('App\Models\Role', 'role_id','id');
|
return $this->belongsTo('App\Models\Role', 'role_id','id');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function lab_covers(){
|
public function userOrganizations(){
|
||||||
return $this->hasMany('App\Models\UserLabCover', 'user_id','id')->where('record_status_id', RecordStatusEnum::ACTIVE );
|
return $this->hasMany('App\Models\UserOrganization', 'user_id','id')->where('record_status_id', RecordStatusEnum::ACTIVE );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,11 +7,12 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|||||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
use Illuminate\Notifications\Notifiable;
|
use Illuminate\Notifications\Notifiable;
|
||||||
|
|
||||||
class UserLabCover extends Authenticatable
|
class UserOrganization extends Authenticatable
|
||||||
{
|
{
|
||||||
|
protected $table = 'user_organizations';
|
||||||
|
|
||||||
public function lab(){
|
public function organization(){
|
||||||
return $this->belongsTo('App\Models\Laboratory', 'lab_id','id');
|
return $this->belongsTo('App\Models\Organization', 'organization_id','id');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function user(){
|
public function user(){
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
return [
|
|
||||||
'table_title' => 'Antibiotics',
|
|
||||||
'search_placeholder' => 'Antibiotic name...',
|
|
||||||
'table_no' => 'No.',
|
|
||||||
'table_name' => 'Name',
|
|
||||||
'table_status' => 'Status',
|
|
||||||
'table_action' => 'Actions',
|
|
||||||
'form_add_tittle' => 'New Antibiotic',
|
|
||||||
'form_name' => 'Antibiotic',
|
|
||||||
'form_sort' => 'Sort-Order',
|
|
||||||
'form_edit_tittle' => 'Edit Antibiotic',
|
|
||||||
|
|
||||||
'create_success' => 'Antibiotic has been created!',
|
|
||||||
'create_fail' => 'An error occur while trying to create antibiotic record. Please try again.',
|
|
||||||
'update_success' => 'Antibiotic record has been updated!',
|
|
||||||
'update_fail' => 'An error occur while trying to update antibiotic record. Please try again.',
|
|
||||||
'delete_success' => 'Antibiotic record has been deleted!',
|
|
||||||
'delete_fail' => 'An error occur while trying to delete antibiotic record. Please try again.',
|
|
||||||
'restore_success' => 'Antibiotic record has been restored!',
|
|
||||||
'restore_fail' => 'An error occur while trying to restore antibiotic record. Please try again.',
|
|
||||||
'get_success' => 'Antibiotic record has been retrieved!',
|
|
||||||
'get_fail' => 'An error occur while trying to retrieve antibiotic record. Please try again.'
|
|
||||||
|
|
||||||
];
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
return [
|
|
||||||
'type' => 'Appointment Type',
|
|
||||||
'date' => 'Appointment Date',
|
|
||||||
'duration' => 'Duration (days)',
|
|
||||||
'patient' => 'Patient',
|
|
||||||
'description' => 'Description',
|
|
||||||
'doctor' => 'Doctor',
|
|
||||||
'create_success' =>'Appointment record has been saved.',
|
|
||||||
'create_fail' =>'Failed while saving Appointment record.',
|
|
||||||
'update_success' =>'Appointment record has been updated.',
|
|
||||||
'update_fail' =>'Failed while updating Appointment record.',
|
|
||||||
'delete_success' =>'Appointment record has been deleted.',
|
|
||||||
'delete_fail' =>'Failed while deleting Appointment record.',
|
|
||||||
];
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
return [
|
|
||||||
'table_title' => 'Comments',
|
|
||||||
'search_placeholder' => 'Comment name..',
|
|
||||||
'table_no' => 'No.',
|
|
||||||
'table_name' => 'Comment',
|
|
||||||
'table_department' => 'Ward',
|
|
||||||
'table_sample_type' => 'Sample Type',
|
|
||||||
'table_status' => 'Status',
|
|
||||||
'table_action' => 'Actions',
|
|
||||||
'form_add_tittle' => 'New Comment',
|
|
||||||
'form_name' => 'Comment',
|
|
||||||
'form_sample_type' => 'Sample Type',
|
|
||||||
'form_department' => 'Ward',
|
|
||||||
'form_edit_tittle' => 'Edit Comment',
|
|
||||||
|
|
||||||
'create_success' => 'Comment has been created!',
|
|
||||||
'create_fail' => 'An error occur while trying to create comment record. Please try again.',
|
|
||||||
'update_success' => 'Comment record has been updated!',
|
|
||||||
'update_fail' => 'An error occur while trying to update comment record. Please try again.',
|
|
||||||
'delete_success' => 'Comment record has been deleted!',
|
|
||||||
'delete_fail' => 'An error occur while trying to delete comment record. Please try again.',
|
|
||||||
'restore_success' => 'Comment record has been restored!',
|
|
||||||
'restore_fail' => 'An error occur while trying to restore comment record. Please try again.',
|
|
||||||
'get_success' => 'Comment record has been retrieved!',
|
|
||||||
'get_fail' => 'An error occur while trying to retrieve comment record. Please try again.'
|
|
||||||
|
|
||||||
];
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
return [
|
|
||||||
'table_title' => 'Departments',
|
|
||||||
'search_placeholder' => 'Department name...',
|
|
||||||
'table_no' => 'No',
|
|
||||||
'table_name' => 'Department Name',
|
|
||||||
'table_sample_type' => 'Sample Type',
|
|
||||||
'table_status' => 'Status',
|
|
||||||
'table_action' => 'Actions',
|
|
||||||
'form_add_tittle' => 'New Department',
|
|
||||||
'form_name' => 'Name',
|
|
||||||
'form_sort' => 'Sort-Order',
|
|
||||||
'form_laboratory' => 'Laboratory',
|
|
||||||
'form_select_all_lab' => 'Select All Labs',
|
|
||||||
'form_edit_tittle' => 'Edit Department',
|
|
||||||
|
|
||||||
'create_success' => 'Department has been created!',
|
|
||||||
'create_fail' => 'An error occur while trying to create department record. Please try again.',
|
|
||||||
'update_success' => 'Department record has been updated!',
|
|
||||||
'update_fail' => 'An error occur while trying to update department record. Please try again.',
|
|
||||||
'delete_success' => 'Department record has been deleted!',
|
|
||||||
'delete_fail' => 'An error occur while trying to delete department record. Please try again.',
|
|
||||||
'restore_success' => 'Department record has been restored!',
|
|
||||||
'restore_fail' => 'An error occur while trying to restore department record. Please try again.',
|
|
||||||
'get_success' => 'Department record has been retrieved!',
|
|
||||||
'get_fail' => 'An error occur while trying to retrieve department record. Please try again.'
|
|
||||||
|
|
||||||
];
|
|
||||||
@@ -65,9 +65,7 @@ return [
|
|||||||
'manage_user_accounts' => 'Manage User Accounts',
|
'manage_user_accounts' => 'Manage User Accounts',
|
||||||
'manage_user_roles' => 'Manage User Roles',
|
'manage_user_roles' => 'Manage User Roles',
|
||||||
|
|
||||||
'manage_user_accounts' => 'Manage User Accounts',
|
'laboratory_settings' => 'Manage Laboratories',
|
||||||
'manage_user_roles' => 'Manage User Roles',
|
|
||||||
'laboratory_settings' => 'System Settings',
|
|
||||||
'activity_logs' => 'Activity Logs',
|
'activity_logs' => 'Activity Logs',
|
||||||
'appointment' => 'Appointment',
|
'appointment' => 'Appointment',
|
||||||
'billing' => 'Billing & Payments',
|
'billing' => 'Billing & Payments',
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
return [
|
|
||||||
|
|
||||||
// Supplier
|
|
||||||
'sp_table_title' => 'Supplier',
|
|
||||||
'sp_create_success' => 'Supplier has been created!',
|
|
||||||
'sp_create_fail' => 'An error occur while trying to create supplier record. Please try again.',
|
|
||||||
'sp_update_success' => 'Supplier record has been updated!',
|
|
||||||
'sp_update_fail' => 'An error occur while trying to update supplier record. Please try again.',
|
|
||||||
'sp_delete_success' => 'Supplier record has been deleted!',
|
|
||||||
'sp_delete_fail' => 'An error occur while trying to delete supplier record. Please try again.',
|
|
||||||
'sp_restore_success' => 'Supplier record has been restored!',
|
|
||||||
'sp_restore_fail' => 'An error occur while trying to restore supplier record. Please try again.',
|
|
||||||
'sp_get_success' => 'Supplier record has been retrieved!',
|
|
||||||
'sp_get_fail' => 'An error occur while trying to retrieve supplier record. Please try again.',
|
|
||||||
|
|
||||||
];
|
|
||||||
@@ -1,85 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
return [
|
|
||||||
'table_title' => 'Invoices',
|
|
||||||
'table_date_filter' => 'Invoice Date Between',
|
|
||||||
'table_textable_filter' => 'Or Search by',
|
|
||||||
'table_textable_filter_placeholder' => 'Inovice code, sample number, patient code, or phone number',
|
|
||||||
'btn_quick_report' => 'Quick Invoice Report',
|
|
||||||
'dialy_report' => 'Daily Invoice Report',
|
|
||||||
'monthly_invoice_report' => 'Monthly Invoice Report',
|
|
||||||
'yearly_invoice_report' => 'Yearly Invoice Report',
|
|
||||||
'table_no' => 'No.',
|
|
||||||
'table_invoice_code' => 'Invoice No.',
|
|
||||||
'table_sample_number' => 'Sample No',
|
|
||||||
'table_patient_name' => 'Patient Name',
|
|
||||||
'table_invoice_date' => 'Invoice Date',
|
|
||||||
'table_total_cost' => 'Sub Total',
|
|
||||||
'table_discount' => 'Discount',
|
|
||||||
'table_net_cost' => 'Total ($)',
|
|
||||||
'table_net_cost_riel' => 'Total (Riel)',
|
|
||||||
'table_paid' => 'Paid Amount',
|
|
||||||
'table_owe' => 'Owe Amount',
|
|
||||||
'table_status' => 'Status',
|
|
||||||
'table_action' => 'Actions',
|
|
||||||
'form_new_title' => 'New Invoice',
|
|
||||||
'form_edit_title'=> 'Edit Invoice',
|
|
||||||
'form_patient' => 'Patient',
|
|
||||||
'form_invoice_number' => 'Invoice No',
|
|
||||||
'form_invoice_date' => 'Invoice Date',
|
|
||||||
'form_description' => 'Description',
|
|
||||||
'form_qty' => 'Qty',
|
|
||||||
'form_unit_price' => 'Unit Price',
|
|
||||||
'form_total_amount' => 'Total Amount',
|
|
||||||
'form_discount' => 'Discount',
|
|
||||||
'form_net_amount' => 'Net Amount',
|
|
||||||
'form_paid_amount' => 'Paid Amount',
|
|
||||||
'form_paid_date' => 'Paid Date',
|
|
||||||
'form_owe_amount' => 'Owe Amount',
|
|
||||||
'form_btn_save' => 'Save Invoice',
|
|
||||||
'form_btn_generate_invoice' => 'Generate Invoice',
|
|
||||||
|
|
||||||
'invoice_report_filter' => 'Invoice Report Filters',
|
|
||||||
'report_type' => 'Report Type',
|
|
||||||
'report_filter' => 'Report Filter',
|
|
||||||
'view_report' => 'View Report',
|
|
||||||
'daily' => 'Daily',
|
|
||||||
'monthly' => 'Monthly',
|
|
||||||
'yearly' => 'Yearly',
|
|
||||||
|
|
||||||
'received_date' => 'Received Date',
|
|
||||||
|
|
||||||
'paid_by' => 'Customer',
|
|
||||||
|
|
||||||
'received_by' => 'Cashier',
|
|
||||||
|
|
||||||
'tittle' => 'Laboratory Invoice',
|
|
||||||
|
|
||||||
'print' => 'Print',
|
|
||||||
|
|
||||||
'create_success' => 'Invoice has been created!',
|
|
||||||
'create_fail' => 'An error occur while trying to create invoice record. Please try again.',
|
|
||||||
'update_success' => 'Invoice record has been updated!',
|
|
||||||
'update_fail' => 'An error occur while trying to update invoice record. Please try again.',
|
|
||||||
'delete_success' => 'Invoice record has been deleted!',
|
|
||||||
'delete_fail' => 'An error occur while trying to delete invoice record. Please try again.',
|
|
||||||
'restore_success' => 'Invoice record has been restored!',
|
|
||||||
'restore_fail' => 'An error occur while trying to restore invoice record. Please try again.',
|
|
||||||
'get_success' => 'Invoice record has been retrieved!',
|
|
||||||
'get_fail' => 'An error occur while trying to retrieve invoice record. Please try again.',
|
|
||||||
'form_btn_save_preview' => 'Save & Preview Invoice',
|
|
||||||
|
|
||||||
'pay_type' => 'Pay Type',
|
|
||||||
'bank_name' => 'Bank Name',
|
|
||||||
'transaction_no' => 'Transaction No',
|
|
||||||
'cash_paid' => 'Cash Pay',
|
|
||||||
'bank_paid' => 'Bank Pay',
|
|
||||||
|
|
||||||
'exchange_rate' => 'Exchange Rate',
|
|
||||||
'hide_discount' => 'Hide Discount',
|
|
||||||
'refresh_item' => 'Check for items update',
|
|
||||||
'repayment' => 'Repayment',
|
|
||||||
'repayment_date' => 'Repayment Date'
|
|
||||||
|
|
||||||
|
|
||||||
];
|
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'table_title' => 'Laboratory',
|
'table_title' => 'Organization',
|
||||||
'search_placeholder' => 'Laboratory name, address...',
|
'search_placeholder' => 'Organization name, address...',
|
||||||
'table_no' => 'No.',
|
'table_no' => 'No.',
|
||||||
'table_name_kh' => 'Name Khmer',
|
'table_name_kh' => 'Name Khmer',
|
||||||
'table_name_en' => 'Name Latin',
|
'table_name_en' => 'Name Latin',
|
||||||
@@ -11,41 +11,41 @@ return [
|
|||||||
'table_labs' => 'Labs',
|
'table_labs' => 'Labs',
|
||||||
'table_status' => 'Status',
|
'table_status' => 'Status',
|
||||||
'table_action' => 'Actions',
|
'table_action' => 'Actions',
|
||||||
'form_add_tittle' => 'New Laboratory',
|
'form_add_tittle' => 'New Organization',
|
||||||
'form_name' => 'Full-Name',
|
'form_name' => 'Full-Name',
|
||||||
'form_login_email' => 'Login-Email',
|
'form_login_email' => 'Login-Email',
|
||||||
'form_ismnager' => 'Lab Manager',
|
'form_ismnager' => 'Lab Manager',
|
||||||
'form_edit_tittle' => 'Edit Laboratory Information',
|
'form_edit_tittle' => 'Edit Organization Information',
|
||||||
'form_system_role' => 'System-Role',
|
'form_system_role' => 'System-Role',
|
||||||
'form_lab_cover' => 'Laboratory Coverage',
|
'form_lab_cover' => 'Organization Coverage',
|
||||||
'form_laboratory' => 'Laboratory',
|
'form_laboratory' => 'Organization',
|
||||||
'form_select_all_lab' => 'Select All Labs',
|
'form_select_all_lab' => 'Select All Labs',
|
||||||
'form_password' => 'Password',
|
'form_password' => 'Password',
|
||||||
'form_address_en' => 'Address-En',
|
'form_address_en' => 'Address-En',
|
||||||
'form_address_kh' => 'Address-KH',
|
'form_address_kh' => 'Address-KH',
|
||||||
|
|
||||||
'create_success' => 'Laboratory has been created!',
|
'create_success' => 'Organization has been created!',
|
||||||
'create_fail' => 'An error occur while trying to create laboratory record. Please try again.',
|
'create_fail' => 'An error occur while trying to create laboratory record. Please try again.',
|
||||||
'update_success' => 'Laboratory record has been updated!',
|
'update_success' => 'Organization record has been updated!',
|
||||||
'update_fail' => 'An error occur while trying to update laboratory record. Please try again.',
|
'update_fail' => 'An error occur while trying to update laboratory record. Please try again.',
|
||||||
'delete_success' => 'Laboratory record has been deleted!',
|
'delete_success' => 'Organization record has been deleted!',
|
||||||
'delete_fail' => 'An error occur while trying to delete laboratory record. Please try again.',
|
'delete_fail' => 'An error occur while trying to delete laboratory record. Please try again.',
|
||||||
'restore_success' => 'Laboratory record has been restored!',
|
'restore_success' => 'Organization record has been restored!',
|
||||||
'restore_fail' => 'An error occur while trying to restore laboratory record. Please try again.',
|
'restore_fail' => 'An error occur while trying to restore laboratory record. Please try again.',
|
||||||
'get_success' => 'Laboratory record has been retrieved!',
|
'get_success' => 'Organization record has been retrieved!',
|
||||||
'get_fail' => 'An error occur while trying to retrieve laboratory record. Please try again.',
|
'get_fail' => 'An error occur while trying to retrieve laboratory record. Please try again.',
|
||||||
|
|
||||||
'clone_lab' => 'Clone Laboratory',
|
'clone_lab' => 'Clone Organization',
|
||||||
'source_lab' => 'Source Laboratory',
|
'source_lab' => 'Source Organization',
|
||||||
'target_lab' => 'New Laboratory',
|
'target_lab' => 'New Organization',
|
||||||
|
|
||||||
'start_clone' => 'Clone',
|
'start_clone' => 'Clone',
|
||||||
|
|
||||||
'phone' => 'Phone Number',
|
'phone' => 'Phone Number',
|
||||||
'info' => 'Laboratory Information',
|
'info' => 'Organization Information',
|
||||||
'license' => 'License Agreement',
|
'license' => 'License Agreement',
|
||||||
'start_date' => 'Start Date',
|
'start_date' => 'Start Date',
|
||||||
'expiry_date' => 'Date of Expiry',
|
'expiry_date' => 'Date of Expiry',
|
||||||
'change_base' => 'Change Laboratory'
|
'change_base' => 'Change Organization'
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
return [
|
return [
|
||||||
"laboratory" => "Laboratory",
|
"laboratory" => "Organization",
|
||||||
"forget_password" => "Forget password",
|
"forget_password" => "Forget password",
|
||||||
"sign_in" => "Sign in",
|
"sign_in" => "Sign in",
|
||||||
"keep_me_sign_in" => "Keep me signed in",
|
"keep_me_sign_in" => "Keep me signed in",
|
||||||
@@ -30,10 +30,10 @@
|
|||||||
"result_config" => "Result Config",
|
"result_config" => "Result Config",
|
||||||
"user_account" => "User Account",
|
"user_account" => "User Account",
|
||||||
"copyright" => "Copyright © 2022 LABONAK. All rights reserved.",
|
"copyright" => "Copyright © 2022 LABONAK. All rights reserved.",
|
||||||
"lis" => "Laboratory Information System",
|
"lis" => "Organization Information System",
|
||||||
"new_laboratory" => "New Laboratory",
|
"new_laboratory" => "New Organization",
|
||||||
"lab_name_en" => "Laboratory Name (English)",
|
"lab_name_en" => "Organization Name (English)",
|
||||||
"lab_name_kh" => "Laboratory Name (Khmer)",
|
"lab_name_kh" => "Organization Name (Khmer)",
|
||||||
"lab_short_name" => "Short name",
|
"lab_short_name" => "Short name",
|
||||||
"address_en" => "Address (English)",
|
"address_en" => "Address (English)",
|
||||||
"address_kh" => "Address (Khmer)",
|
"address_kh" => "Address (Khmer)",
|
||||||
|
|||||||
@@ -1,230 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
return [
|
|
||||||
'new_consultation'=>'New Consultation',
|
|
||||||
'admission_date'=>'Admission Date',
|
|
||||||
'admission_ward'=>'Admission Ward',
|
|
||||||
'doctor'=>'Doctor',
|
|
||||||
'physical_examinations'=>'Physical Examinations',
|
|
||||||
'histories'=>'Histories',
|
|
||||||
'investigations_&_procedures'=>'Investigations & Procedures',
|
|
||||||
'medications'=>'Medications',
|
|
||||||
'documents'=>'Documents',
|
|
||||||
'bills'=>'Bills',
|
|
||||||
'chief_complaint'=>'Chief Complaint',
|
|
||||||
'vital_sign'=>'Vital Sign',
|
|
||||||
'body_temperature(celsius)'=>'Body Temperature(Celsius)',
|
|
||||||
'temperature'=>'Temperature',
|
|
||||||
'pulse'=>'Pulse',
|
|
||||||
'spo2'=>'SpO2',
|
|
||||||
'respiration_rate'=>'Respiration Rate',
|
|
||||||
'biometrics'=>'Biometrics',
|
|
||||||
'weight(kg)'=>'weight(Kg)',
|
|
||||||
'height(cm)'=>'Height(cm)',
|
|
||||||
'bmi(clac)'=>'BMI(Clac)',
|
|
||||||
'diagnosis'=>'Diagnosis',
|
|
||||||
'initial_diagnosis'=>'Initial Diagnosis',
|
|
||||||
'final_diagnosis'=>'Final Diagnosis',
|
|
||||||
'save'=>'Save',
|
|
||||||
'vaccination_history'=>'Vaccination History',
|
|
||||||
'allergies'=>'Allergies',
|
|
||||||
'allergen_category'=>'Allergen Category',
|
|
||||||
'allergen'=>'Allergen',
|
|
||||||
'drug_allergy'=>'Drug Allergy',
|
|
||||||
'food_allergy'=>'Food Allergy',
|
|
||||||
'insect_allergy'=>'Insect Allergy',
|
|
||||||
'environment_allergy'=>'Environment Allergy',
|
|
||||||
'others'=>'Others',
|
|
||||||
'current_medication'=>'Current Medication',
|
|
||||||
'past_medical_surgical_history'=>'Past Medical Surgical',
|
|
||||||
'family_history'=>'Family History',
|
|
||||||
'laboratory'=>'Laboratory',
|
|
||||||
'request_for_laboratory_test'=>'Request for Laboratory Test',
|
|
||||||
'request_imagery'=>'Request Imagery',
|
|
||||||
'imagery_type'=>'Imagery Type',
|
|
||||||
'imagery_service'=>'Imagery Service',
|
|
||||||
'medical_item_group'=>'Medical Item Group',
|
|
||||||
'medical_item'=>'Medical Item',
|
|
||||||
'route'=>'Route',
|
|
||||||
'form'=>'Form',
|
|
||||||
'morning'=>'Morning',
|
|
||||||
'noon'=>'Noon',
|
|
||||||
'afternoon'=>'Afternoon',
|
|
||||||
'evening'=>'Evening',
|
|
||||||
'midnight'=>'Midnight',
|
|
||||||
'duration'=>'Duration',
|
|
||||||
'instruction'=>'Instruction',
|
|
||||||
'view_all'=>'View All',
|
|
||||||
'pending'=>'Pending',
|
|
||||||
'discharged'=>'Discharged',
|
|
||||||
'visit_number'=>'Visit Number',
|
|
||||||
'save_&_generate_invoice'=>'Save & Generate Invoice',
|
|
||||||
'hid'=>'HID',
|
|
||||||
'patient_name'=>'Patient Name',
|
|
||||||
'gender'=>'Gender',
|
|
||||||
'age'=>'Age',
|
|
||||||
'date_of_birth'=>'Date of Birth',
|
|
||||||
'visit_date'=>'Visit Date',
|
|
||||||
'visit_no.'=>'Visit No.',
|
|
||||||
'refer_from'=>'Refer From',
|
|
||||||
'refer_to'=>'Refer To',
|
|
||||||
'visit_histories'=>'Visit Histories',
|
|
||||||
'life_styles'=>'Life Styles',
|
|
||||||
'alcohol'=>'Alcohol',
|
|
||||||
'smoking'=>'Smoking',
|
|
||||||
'drug'=>'Drug',
|
|
||||||
'no'=>'No',
|
|
||||||
'yes'=>'Yes',
|
|
||||||
'new_invoice'=>'New Invoice',
|
|
||||||
'upload_document'=>'Upload Document',
|
|
||||||
'consultation' => 'Consultations',
|
|
||||||
'medicine_name' => 'Medicine Name',
|
|
||||||
'view_requested' => 'View Requests',
|
|
||||||
'consultations' => 'Consultations',
|
|
||||||
'imagery' => 'Imagery',
|
|
||||||
'possible_result' => 'Possible Result',
|
|
||||||
'imagery_list' => 'Imagery List',
|
|
||||||
'pharmacy' => 'Pharmacy',
|
|
||||||
'prescriptions' => 'Medication',
|
|
||||||
'medicine_instruction' => 'Medicine Instruction',
|
|
||||||
'exam_date' => 'Exam Date',
|
|
||||||
'technique' => 'Technique',
|
|
||||||
'id' => 'ID',
|
|
||||||
'add_result_of' => 'Add Result of ',
|
|
||||||
'attach_photo' => 'Attach Photo ',
|
|
||||||
'short_name' => 'Code',
|
|
||||||
'name' => 'Name in English',
|
|
||||||
'name_kh' => 'Name in Khmer',
|
|
||||||
'standard_result' => 'Standard Result',
|
|
||||||
'default_select' => 'Default Select',
|
|
||||||
'wards' => 'Wards',
|
|
||||||
'ward' => 'Ward',
|
|
||||||
'doctors' => 'Doctors',
|
|
||||||
'base_manager' => 'Base Manager',
|
|
||||||
'hospital_services' => 'Hospital Services',
|
|
||||||
'hospital_service' => 'Hospital Service',
|
|
||||||
'service_type' => 'Service Type',
|
|
||||||
'name_latin' => 'Name-Latin',
|
|
||||||
'name_local' => 'Name-Local',
|
|
||||||
|
|
||||||
'visit' => 'Patient',
|
|
||||||
'type_service_code_or_name' => 'Type service code or name...',
|
|
||||||
'total' => 'Total',
|
|
||||||
'action' => 'Action',
|
|
||||||
'stock_in' => 'Stock In',
|
|
||||||
'stock_out' => 'Stock Out',
|
|
||||||
'inventory_report' => 'Inventory Report',
|
|
||||||
'item' => 'item',
|
|
||||||
'supplier' => 'Supplier',
|
|
||||||
'item_group' => 'Item Group',
|
|
||||||
'item_unit' => 'Item Unit',
|
|
||||||
'grn_number' => 'GRN-Number',
|
|
||||||
'po_number' => 'PO-Number',
|
|
||||||
'received_date' => 'Received Date',
|
|
||||||
'total_amount' => 'Total Amount',
|
|
||||||
'grn_num_or_supplier' => 'GRN-Number or supplier name...',
|
|
||||||
'unit_price' => 'Unit Price',
|
|
||||||
'quantity' => 'Quantity',
|
|
||||||
'expiry_date' => 'Expiry Date',
|
|
||||||
|
|
||||||
'gin_number' => 'GIN-Number',
|
|
||||||
'issued_date' => 'Issued Date',
|
|
||||||
'report_type' => 'Report Type',
|
|
||||||
'inventory_on_hand' => 'Inventory on hand',
|
|
||||||
'expire_report' => 'Inventory on hand',
|
|
||||||
'report_date' => 'Report Date',
|
|
||||||
|
|
||||||
'item_name' => 'Item Name',
|
|
||||||
'on_hand' => 'On Hand',
|
|
||||||
'last_stock_in' => 'Last Stock In',
|
|
||||||
'last_stock_out' => 'Last Stock Out',
|
|
||||||
'stock_in_date' => 'Stock In Date',
|
|
||||||
'expire_date' => 'Expire Date',
|
|
||||||
'_month' => '# Month',
|
|
||||||
|
|
||||||
'code' => 'Code',
|
|
||||||
'sale_price' => 'Sale Price',
|
|
||||||
'description' => 'Description',
|
|
||||||
'is_vaccination' => 'Is Vaccination',
|
|
||||||
'vat_number' => 'VAT Number',
|
|
||||||
'supplier_name' => 'Supplier Name',
|
|
||||||
'contact_person' => 'Contact Person',
|
|
||||||
'position' => 'Position',
|
|
||||||
'phone' => 'Phone Number',
|
|
||||||
'email' => 'Email',
|
|
||||||
'address' => 'Address',
|
|
||||||
'packaged_item' => 'Packaged Item',
|
|
||||||
|
|
||||||
'medical_record' => 'Medical Record',
|
|
||||||
|
|
||||||
'concept_code' => 'Concept Code',
|
|
||||||
|
|
||||||
'class' => 'Class',
|
|
||||||
'sub_class' => 'Sub Class',
|
|
||||||
'create_success' => 'Record has been created',
|
|
||||||
'create_fail' => 'Failed while creating a record',
|
|
||||||
'update_success' => 'Record has been updated',
|
|
||||||
'update_fail' => 'Failed while updating a record',
|
|
||||||
'get_success' => 'Record has been fetched',
|
|
||||||
'get_fail' => 'Failed while fetching a record',
|
|
||||||
'delete_success' => 'Record has been deleted',
|
|
||||||
'delete_fail' => 'Failed while deleting a record',
|
|
||||||
'restore_success' => 'Record has been restored',
|
|
||||||
'restore_fail' => 'Failed while restoring a record',
|
|
||||||
'evaluation' => 'Evaluation',
|
|
||||||
'evaluation_summary' => 'Evaluation Summary',
|
|
||||||
'queues' => 'Queues',
|
|
||||||
'queue_no' => 'Queue-No',
|
|
||||||
'save_to_queue' => 'Add Queue',
|
|
||||||
'systolic' => 'Systolic',
|
|
||||||
'diastolic' => 'Diastolic',
|
|
||||||
'glucose' => 'Glucose',
|
|
||||||
|
|
||||||
'onset_date' => 'Onset Date',
|
|
||||||
'clinical_feature' => 'Clinical Feature',
|
|
||||||
'sign' => 'Sign',
|
|
||||||
'general_appearance' => 'General Appearance',
|
|
||||||
'status' => 'Status',
|
|
||||||
'other' => 'Other',
|
|
||||||
'ent' => 'ENT (ORL)',
|
|
||||||
'ears' => 'Ears',
|
|
||||||
'nose' => 'Noses',
|
|
||||||
'throat' => 'Throat',
|
|
||||||
'cardio_system' => 'Cardiovascular System',
|
|
||||||
'heart_sound' => 'Heart Sound',
|
|
||||||
'cardio_refill_time' => 'Capillary Refill Time',
|
|
||||||
'resp_system' => 'Respiratory System',
|
|
||||||
'inspection' => 'Inspection',
|
|
||||||
'percussion' => 'Percussion',
|
|
||||||
'auscultation' => 'Auscultation',
|
|
||||||
'palpation' => 'Palpation',
|
|
||||||
'uro_system' => 'Urogenital System',
|
|
||||||
'skin' => 'Skin & Extremities',
|
|
||||||
'edema' => 'Edema',
|
|
||||||
'wounds' => 'Wounds',
|
|
||||||
'rash' => 'Rash',
|
|
||||||
'nervous_system' => 'Central Nervous System',
|
|
||||||
'neurological' => 'Neurological',
|
|
||||||
'mental_status' => 'Mental Status',
|
|
||||||
'eyes' => 'Eyes',
|
|
||||||
'verbal' => 'Verbal',
|
|
||||||
'motion' => 'Motion',
|
|
||||||
'mental_total' => 'Total',
|
|
||||||
'specify' => 'Specify',
|
|
||||||
'gastro_system' => 'Gastro-Intestinal System',
|
|
||||||
'speech' => 'Speech',
|
|
||||||
'mood' => 'Mood and affect',
|
|
||||||
'thought' => 'Thought',
|
|
||||||
'insight' => 'Insight & Judgement',
|
|
||||||
'consciousness' => 'Consciousness',
|
|
||||||
'abdomen' => 'Abdomen',
|
|
||||||
'perception' => 'Perception',
|
|
||||||
'coma' => 'Glasgow coma scale',
|
|
||||||
'print_consult_form' => 'Print Consultation Form',
|
|
||||||
'document_title' => 'Document Title',
|
|
||||||
'file_name' => 'File name',
|
|
||||||
'file_type' => 'File type',
|
|
||||||
'past_medical_history' => 'Past Medical History'
|
|
||||||
|
|
||||||
|
|
||||||
];
|
|
||||||
@@ -1,77 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
return [
|
|
||||||
'table_title' => 'Patients',
|
|
||||||
'search_placeholdolder' => 'Patient name, phone ..',
|
|
||||||
'table_no' => 'No',
|
|
||||||
'table_code' => 'Code',
|
|
||||||
'table_name' => 'Name',
|
|
||||||
'table_sex' => 'Sex',
|
|
||||||
'table_phon' => 'Phone',
|
|
||||||
'table_have_sample' => 'Have Sample',
|
|
||||||
'table_status' => 'Status',
|
|
||||||
'table_action' => 'Actions',
|
|
||||||
'form_add_title' => 'New Patient',
|
|
||||||
'form_edit_title' => 'Edit Patient',
|
|
||||||
'form_code' => 'Patient Code',
|
|
||||||
'form_name' => 'Patient Name',
|
|
||||||
'form_dob' => 'Dob or Age',
|
|
||||||
'form_age' => 'Age',
|
|
||||||
'form_gender' => 'Gender',
|
|
||||||
'form_sex_male' => 'Male',
|
|
||||||
'form_sex_female' => 'Female',
|
|
||||||
'form_sex_other' => 'Other',
|
|
||||||
'form_khid' => 'KH-ID Number',
|
|
||||||
'form_phone' => 'Phone Number',
|
|
||||||
'form_house' => 'House Number',
|
|
||||||
'form_street' => 'Street Number',
|
|
||||||
'form_province' => 'Province',
|
|
||||||
'form_district' => 'District',
|
|
||||||
'form_commune' => 'Commune',
|
|
||||||
'form_village' => 'Village',
|
|
||||||
'form_alt_generate_puuid' => 'Auto Generate Patient Code',
|
|
||||||
|
|
||||||
'create_success' => 'Patient has been created!',
|
|
||||||
'create_fail' => 'An error occur while trying to create patient record. Please try again.',
|
|
||||||
'update_success' => 'Patient record has been updated!',
|
|
||||||
'update_fail' => 'An error occur while trying to update patient record. Please try again.',
|
|
||||||
'delete_success' => 'Patient record has been deleted!',
|
|
||||||
'delete_fail' => 'An error occur while trying to delete patient record. Please try again.',
|
|
||||||
'restore_success' => 'Patient record has been restored!',
|
|
||||||
'restore_fail' => 'An error occur while trying to restore patient record. Please try again.',
|
|
||||||
'get_success' => 'Patient record has been retrieved!',
|
|
||||||
'get_fail' => 'An error occur while trying to retrieve patient record. Please try again.',
|
|
||||||
|
|
||||||
'basic_information' => 'Basic Information',
|
|
||||||
'identifiers' => 'Identifiers',
|
|
||||||
'contact_detail' => 'Contact Details',
|
|
||||||
'medical_history' => 'Medical Histories',
|
|
||||||
'first_name' => 'Surname',
|
|
||||||
'last_name' => 'Given Name',
|
|
||||||
'dob' => 'Date of Birth',
|
|
||||||
'marital_status' => 'Marital Status',
|
|
||||||
'single' => 'Single',
|
|
||||||
'married' => 'Married',
|
|
||||||
'other' => 'Others',
|
|
||||||
'are_in_num' => 'Or Age in year, month, and day.',
|
|
||||||
'blood_group' => 'Blood Group',
|
|
||||||
'khid' => 'Khmer ID Card',
|
|
||||||
'passport' => 'Passport',
|
|
||||||
'nhid' => 'National Health ID',
|
|
||||||
'create_new' => 'Create New Patient',
|
|
||||||
'street' => 'Street',
|
|
||||||
'house_no' => 'House Number',
|
|
||||||
'email' => 'E-mail',
|
|
||||||
'allergy' => 'Allergies',
|
|
||||||
'chronic_disease' => 'Chronic Diseases',
|
|
||||||
'past_surgery' => 'Past Surgeries',
|
|
||||||
'family_history' => 'Family Medical History',
|
|
||||||
'vaccination_history' => 'Vaccination Histories',
|
|
||||||
'save_patient' => 'Save Patient',
|
|
||||||
'save_consult' => 'Consultation',
|
|
||||||
'save_queue' => 'Add Queue',
|
|
||||||
'cancel' => 'Cancel',
|
|
||||||
'sample' => 'Samples'
|
|
||||||
|
|
||||||
|
|
||||||
];
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
return [
|
|
||||||
'table_title' => 'Patient Type',
|
|
||||||
'search_placeholder' => 'Patient type name...',
|
|
||||||
'table_no' => 'No',
|
|
||||||
'table_name' => 'Name',
|
|
||||||
'table_gender' => 'Gender',
|
|
||||||
'table_age_from' => 'Age From',
|
|
||||||
'table_age_to' => 'Age To',
|
|
||||||
'table_status' => 'Status',
|
|
||||||
'table_action' => 'Actions',
|
|
||||||
'form_add_tittle' => 'New Patient Type',
|
|
||||||
'form_name' => 'Name',
|
|
||||||
'form_max_age' => 'Max-Age',
|
|
||||||
'form_min_age' => 'Min-Age',
|
|
||||||
'form_edit_tittle' => 'Edit Patient Type',
|
|
||||||
'form_input_day' => 'days',
|
|
||||||
'form_input_month' => 'months',
|
|
||||||
'form_input_year' => 'years',
|
|
||||||
|
|
||||||
'create_success' => 'Patient Type has been created!',
|
|
||||||
'create_fail' => 'An error occur while trying to create patient type record. Please try again.',
|
|
||||||
'update_success' => 'Patient Type record has been updated!',
|
|
||||||
'update_fail' => 'An error occur while trying to update patient type record. Please try again.',
|
|
||||||
'delete_success' => 'Patient Type record has been deleted!',
|
|
||||||
'delete_fail' => 'An error occur while trying to delete patient type record. Please try again.',
|
|
||||||
'restore_success' => 'Patient Type record has been restored!',
|
|
||||||
'restore_fail' => 'An error occur while trying to restore patient type record. Please try again.',
|
|
||||||
'get_success' => 'Patient Type record has been retrieved!',
|
|
||||||
'get_fail' => 'An error occur while trying to retrieve patient type record. Please try again.'
|
|
||||||
|
|
||||||
];
|
|
||||||
@@ -22,7 +22,7 @@ return [
|
|||||||
'generate_doctor_report' => 'Generate Doctor Report',
|
'generate_doctor_report' => 'Generate Doctor Report',
|
||||||
'generate_summary_report' => 'Generate Summary Report',
|
'generate_summary_report' => 'Generate Summary Report',
|
||||||
'view_dashboard' => 'View Dashboard',
|
'view_dashboard' => 'View Dashboard',
|
||||||
'update_laboratory_information' => 'Update Laboratory Information',
|
'update_laboratory_information' => 'Update Organization Information',
|
||||||
'view_department' => 'View Department',
|
'view_department' => 'View Department',
|
||||||
'create_department' => 'Create Department',
|
'create_department' => 'Create Department',
|
||||||
'update_department' => 'Update Department',
|
'update_department' => 'Update Department',
|
||||||
|
|||||||
@@ -1,33 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
return [
|
|
||||||
'table_title' => 'Physicians',
|
|
||||||
'search_placeholder' => 'Physician name...',
|
|
||||||
'table_no' => 'No',
|
|
||||||
'table_name' => 'Name',
|
|
||||||
'table_logo' => 'Logo',
|
|
||||||
'table_status' => 'Status',
|
|
||||||
'table_action' => 'Actions',
|
|
||||||
'form_add_tittle' => 'New Physician',
|
|
||||||
'form_name' => 'Name',
|
|
||||||
'form_logo_upload' => 'Upload',
|
|
||||||
'form_logo' => 'Header',
|
|
||||||
'form_edit_tittle' => 'Edit Physician',
|
|
||||||
'confirm_delete_photo' => 'Are you sure want to delete physician logo?',
|
|
||||||
'ok_delete' => 'Yes, Delete',
|
|
||||||
'cancel_delete' => 'No, Cancel',
|
|
||||||
'confirm_delete' => 'Are you sure want to delete physician data?',
|
|
||||||
'delete_photo_success' => 'Physician photo deleted successful',
|
|
||||||
'delete_photo_failed' => 'Physician photo delete failed',
|
|
||||||
|
|
||||||
'delete_success' => 'Physician record has been deleted!',
|
|
||||||
'delete_failed' => 'An error occur while trying to delete physician record. Please try again.',
|
|
||||||
|
|
||||||
'restore_success' => 'Physician record has been restored!',
|
|
||||||
'restore_fail' => 'An error occur while trying to restore physician record. Please try again.',
|
|
||||||
|
|
||||||
'form_footer' => 'Footer',
|
|
||||||
'default_select' => 'Make default'
|
|
||||||
|
|
||||||
|
|
||||||
];
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
return [
|
|
||||||
'table_title' => 'Quantities',
|
|
||||||
'search_placeholder' => 'Quantity name...',
|
|
||||||
'table_no' => 'No.',
|
|
||||||
'table_name' => 'Name',
|
|
||||||
'table_status' => 'Status',
|
|
||||||
'table_action' => 'Actions',
|
|
||||||
'form_add_tittle' => 'New Quantity',
|
|
||||||
'form_name' => 'Quantity',
|
|
||||||
'form_sort' => 'Sort-Order',
|
|
||||||
'form_edit_tittle' => 'Edit Quantity',
|
|
||||||
|
|
||||||
'create_success' => 'Quantity has been created!',
|
|
||||||
'create_fail' => 'An error occur while trying to create quantity record. Please try again.',
|
|
||||||
'update_success' => 'Quantity record has been updated!',
|
|
||||||
'update_fail' => 'An error occur while trying to update quantity record. Please try again.',
|
|
||||||
'delete_success' => 'Quantity record has been deleted!',
|
|
||||||
'delete_fail' => 'An error occur while trying to delete quantity record. Please try again.',
|
|
||||||
'restore_success' => 'Quantity record has been restored!',
|
|
||||||
'restore_fail' => 'An error occur while trying to restore quantity record. Please try again.',
|
|
||||||
'get_success' => 'Quantity record has been retrieved!',
|
|
||||||
'get_fail' => 'An error occur while trying to retrieve quantity record. Please try again.'
|
|
||||||
|
|
||||||
];
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
<?php
|
|
||||||
return [
|
|
||||||
'summary_rpt_tittle' => 'Summary Report',
|
|
||||||
'summary_rpt_fd_filter' => 'Invoice Date From',
|
|
||||||
'summary_rpt_td_filter' => 'Invoice Date End',
|
|
||||||
'btn_view' => 'View Report',
|
|
||||||
'btn_action' => 'Actions',
|
|
||||||
'btn_action_print' => 'Print',
|
|
||||||
'btn_action_export' => 'Download Excel',
|
|
||||||
'summary_report_section_by_test' => 'Summary Report by Test Type',
|
|
||||||
'summary_report_section_by_sample_source' => 'Summary Report by Sample Source',
|
|
||||||
'summary_rpt_test_type' => 'Test Type',
|
|
||||||
'summary_male_patient' => 'Male Patient',
|
|
||||||
'summary_female_patient' => 'Female Patient',
|
|
||||||
'summary_total_patient' => 'Total Patient',
|
|
||||||
'summary_clinic_name' => 'Sample Source',
|
|
||||||
'doctor_date_range_filter' => 'Invoice Date Range',
|
|
||||||
'doctor_sample_source_filter' => 'Sample Source',
|
|
||||||
'doctor_physician_filter' => 'Provider',
|
|
||||||
'doctor_exam' => 'Exam',
|
|
||||||
'doctor_net_amount' => 'Net Amount',
|
|
||||||
'summary_total_sample'=>'Total Sample',
|
|
||||||
'summary_report_section_by_category'=>'Summary Report by Category',
|
|
||||||
'summary_report_section_by_date'=>'Summary Report by Date',
|
|
||||||
'summary_report_section_by_labtech'=>'Summary Report By Lab',
|
|
||||||
'financial_report'=>'Financial Report',
|
|
||||||
'summary_category_name'=>'Category',
|
|
||||||
'total' => 'Total'
|
|
||||||
|
|
||||||
];
|
|
||||||
@@ -1,113 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
return [
|
|
||||||
|
|
||||||
'table_title' => 'Samples',
|
|
||||||
'table_no' => 'No',
|
|
||||||
'table_patient_code' => 'Patient Code',
|
|
||||||
'table_patient_name' => 'Patient Name',
|
|
||||||
'table_sample_number' => 'Sample No',
|
|
||||||
'table_collected_date' => 'Request Date',
|
|
||||||
'table_received_date' => 'Received Date',
|
|
||||||
'table_sample_source' => 'Sample Source',
|
|
||||||
'table_status' => 'Status',
|
|
||||||
'table_action' => 'Actions',
|
|
||||||
'form_add_title' => 'New Sample',
|
|
||||||
'form_patient' => 'Patient',
|
|
||||||
'form_sample_number' => 'Sample No',
|
|
||||||
'form_sample_source' => 'Sample Source',
|
|
||||||
'form_requester' => 'Requested By',
|
|
||||||
'form_collected_date' => 'Request Date',
|
|
||||||
'form_received_date' => 'Received Date',
|
|
||||||
'form_admission_date' => 'Admission Date',
|
|
||||||
'form_diagnisis' => 'Diagnosis',
|
|
||||||
'form_sample_condition' => 'Sample Condition',
|
|
||||||
'form_reject_reason' => 'Reject Reason',
|
|
||||||
'form_is_urgent' => 'Is Urgent',
|
|
||||||
'form_btn_save_assign_test' => 'Save & Assign Test',
|
|
||||||
'form_patient_info_title' => 'Patient Information',
|
|
||||||
'form_patient_code' => 'Code',
|
|
||||||
'form_patient_name' => 'Name',
|
|
||||||
'form_patient_gender' => 'Sex',
|
|
||||||
'form_patient_age' => 'Age',
|
|
||||||
'form_patient_mobile' => 'Mobile',
|
|
||||||
'form_patient_address' => 'Address',
|
|
||||||
'form_edit_title' => 'Edit Sample',
|
|
||||||
'form_btn_update' => 'Update',
|
|
||||||
'form_btn_assign_test' => 'Assign Test',
|
|
||||||
'form_btn_add_result' => 'Add Result',
|
|
||||||
'form_btn_preview_result' => 'Preview Result',
|
|
||||||
'from_btn_remove' => 'Remove',
|
|
||||||
'form_btn_new_sample' => 'New Sample',
|
|
||||||
'assign_test_modal_title' => 'Assign Test',
|
|
||||||
'assign_test_save_template' => 'Save Template',
|
|
||||||
'assign_test_make_invoice' => 'Make Invoice',
|
|
||||||
'assign_test_total_fee_text' => 'Total Payment',
|
|
||||||
'assign_test_total_test' => 'Total Tests',
|
|
||||||
'assign_test_btn_save' => 'Save',
|
|
||||||
'assign_test_btn_save_add_result' => 'Save & Add Result',
|
|
||||||
'assign_test_btn_cancel' => 'Cancel',
|
|
||||||
'add_result_title' => 'Add Result',
|
|
||||||
'sample_entry_by' => 'Sample Entry By',
|
|
||||||
'sample_modify_by' => 'Modified By',
|
|
||||||
'add_result_test' => 'Test Name',
|
|
||||||
'add_result_result' => 'Result',
|
|
||||||
'add_result_unit_sign' => 'Unit Sign',
|
|
||||||
'add_result_ref_range' => 'Ref. Range',
|
|
||||||
'add_result_test_date' => 'Test Date',
|
|
||||||
'add_result_performed_by' => 'Performed By',
|
|
||||||
'add_result_hide' => 'Hide',
|
|
||||||
'add_result_btn_edit_test' => 'Edit Test',
|
|
||||||
'add_result_btn_save' => 'Save',
|
|
||||||
'add_result_btn_save_preview' => 'Save & Preview',
|
|
||||||
'add_result_btn_cancel' => 'Cancel',
|
|
||||||
'print_title' => 'Laboratory Result',
|
|
||||||
'btn_print' => 'Print',
|
|
||||||
'btn_approve' => 'Approve',
|
|
||||||
'last_test_date' => 'Last test date',
|
|
||||||
'verify_by' => 'Verify by',
|
|
||||||
'report_date' => 'Report date',
|
|
||||||
'lab_technician' => 'Lab. Technician',
|
|
||||||
|
|
||||||
'search_placeholder' => 'Patient name or phone..',
|
|
||||||
|
|
||||||
'condition_good' => 'Good',
|
|
||||||
'condition_reject' => 'Rejected',
|
|
||||||
'condition_acceptable' => 'Acceptable',
|
|
||||||
|
|
||||||
'requested_date' => 'Request Date',
|
|
||||||
|
|
||||||
'year' => ' y',
|
|
||||||
'month' => ' m',
|
|
||||||
'day' => ' d',
|
|
||||||
'sex_m' => ' M',
|
|
||||||
'sex_f' => ' F',
|
|
||||||
'physician_name' => 'Provider Name',
|
|
||||||
|
|
||||||
'create_success' => 'Sample has been created!',
|
|
||||||
'create_fail' => 'An error occur while trying to create sample record. Please try again.',
|
|
||||||
'update_success' => 'Sample record has been updated!',
|
|
||||||
'update_fail' => 'An error occur while trying to update sample record. Please try again.',
|
|
||||||
'delete_success' => 'Sample record has been deleted!',
|
|
||||||
'delete_fail' => 'An error occur while trying to delete sample record. Please try again.',
|
|
||||||
'restore_success' => 'Sample record has been restored!',
|
|
||||||
'restore_fail' => 'An error occur while trying to restore sample record. Please try again.',
|
|
||||||
'get_success' => 'Sample record has been retrieved!',
|
|
||||||
'get_fail' => 'An error occur while trying to retrieve sample record. Please try again.',
|
|
||||||
|
|
||||||
'approve_success' => 'Sample has been approved!',
|
|
||||||
'approve_fail' => 'An error occur while trying to approve the sample. Please try again.',
|
|
||||||
|
|
||||||
|
|
||||||
'filter_all' => 'Show All',
|
|
||||||
'filter_rejected' => 'Rejected',
|
|
||||||
'filter_pending' => 'Pending',
|
|
||||||
'filter_processing' => 'Processing',
|
|
||||||
'filter_completed' => 'Completed',
|
|
||||||
'filter_printed' => 'Printed',
|
|
||||||
'clear_selection' => 'Uncheck all tests',
|
|
||||||
'print_label' => 'Print Label',
|
|
||||||
'previous_result' => 'Previous Result',
|
|
||||||
'sample_status' => ' Status '
|
|
||||||
|
|
||||||
];
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
return [
|
|
||||||
'table_title' => 'Sample Sources',
|
|
||||||
'search_placeholder' => 'Sample source name...',
|
|
||||||
'table_no' => 'No',
|
|
||||||
'table_name_latin' => 'Name-Latin',
|
|
||||||
'table_name_khmer' => 'Name-Khmer',
|
|
||||||
'table_status' => 'Status',
|
|
||||||
'table_action' => 'Actions',
|
|
||||||
'form_add_tittle' => 'New Sample Source',
|
|
||||||
'form_name' => 'Name',
|
|
||||||
'form_sort' => 'Sort-Order',
|
|
||||||
'form_edit_tittle' => 'Edit Sample Source',
|
|
||||||
|
|
||||||
'create_success' => 'Sample source has been created!',
|
|
||||||
'create_fail' => 'An error occur while trying to create sample source record. Please try again.',
|
|
||||||
'update_success' => 'Sample source record has been updated!',
|
|
||||||
'update_fail' => 'An error occur while trying to update sample source record. Please try again.',
|
|
||||||
'delete_success' => 'Sample source record has been deleted!',
|
|
||||||
'delete_fail' => 'An error occur while trying to delete sample source record. Please try again.',
|
|
||||||
'restore_success' => 'Sample source record has been restored!',
|
|
||||||
'restore_fail' => 'An error occur while trying to restore sample source record. Please try again.',
|
|
||||||
'get_success' => 'Sample source record has been retrieved!',
|
|
||||||
'get_fail' => 'An error occur while trying to retrieve sample source record. Please try again.'
|
|
||||||
|
|
||||||
];
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
return [
|
|
||||||
'table_title' => 'Sample Types',
|
|
||||||
'search_placeholder' => 'Sample type name...',
|
|
||||||
'table_no' => 'No',
|
|
||||||
'table_name' => 'Name',
|
|
||||||
'table_department' => 'Department Name',
|
|
||||||
'table_sample_type' => 'Sample Type',
|
|
||||||
'table_description' => 'Description',
|
|
||||||
'table_status' => 'Status',
|
|
||||||
'table_action' => 'Actions',
|
|
||||||
'form_add_tittle' => 'New Sample Type',
|
|
||||||
'form_name' => 'Name',
|
|
||||||
'form_sort' => 'Sort-Order',
|
|
||||||
'form_department' => 'Ward',
|
|
||||||
'form_select_all_department' => 'Select All Departments',
|
|
||||||
'form_edit_tittle' => 'Edit Sample Type',
|
|
||||||
'form_sample_description' => 'Sample Type',
|
|
||||||
|
|
||||||
'tube' => 'Type of Tube',
|
|
||||||
|
|
||||||
'create_success' => 'Sample type has been created!',
|
|
||||||
'create_fail' => 'An error occur while trying to create sample type record. Please try again.',
|
|
||||||
'update_success' => 'Sample type record has been updated!',
|
|
||||||
'update_fail' => 'An error occur while trying to update sample type record. Please try again.',
|
|
||||||
'delete_success' => 'Sample type record has been deleted!',
|
|
||||||
'delete_fail' => 'An error occur while trying to delete sample type record. Please try again.',
|
|
||||||
'restore_success' => 'Sample type record has been restored!',
|
|
||||||
'restore_fail' => 'An error occur while trying to restore sample type record. Please try again.',
|
|
||||||
'get_success' => 'Sample type record has been retrieved!',
|
|
||||||
'get_fail' => 'An error occur while trying to retrieve sample type record. Please try again.'
|
|
||||||
|
|
||||||
];
|
|
||||||
@@ -28,7 +28,7 @@ return [
|
|||||||
'system_role' => 'System Roles',
|
'system_role' => 'System Roles',
|
||||||
'change_lab' => 'Change Lab',
|
'change_lab' => 'Change Lab',
|
||||||
'logout' => 'Logout',
|
'logout' => 'Logout',
|
||||||
'clone_lab' => 'Clone Laboratory',
|
'clone_lab' => 'Clone Organization',
|
||||||
'medicines' => 'Logistics',
|
'medicines' => 'Logistics',
|
||||||
'supplier' => 'Supplier',
|
'supplier' => 'Supplier',
|
||||||
'medicine_group' => 'Item Group',
|
'medicine_group' => 'Item Group',
|
||||||
|
|||||||
@@ -1,68 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
return [
|
|
||||||
'table_title' => 'Tests',
|
|
||||||
'search_placeholder' => 'Department, sample type, or test name...',
|
|
||||||
'table_no' => 'No',
|
|
||||||
'table_name' => 'Test Name',
|
|
||||||
'table_department' => 'Ward',
|
|
||||||
'table_sample_type' => 'Sample Type',
|
|
||||||
'table_sign' => 'Sign',
|
|
||||||
'table_group_result' => 'Group Result',
|
|
||||||
'table_field_type' => 'Field Type',
|
|
||||||
'table_price' => 'Price',
|
|
||||||
'table_sort' => 'Sort-Order',
|
|
||||||
'table_btn_pc' => 'Provider Commission',
|
|
||||||
'pc_physician' => 'Provider',
|
|
||||||
'pc_rate' => 'Commission Rate',
|
|
||||||
'pc_btn_apply_all_test' => 'Apply to all tests',
|
|
||||||
'table_status' => 'Status',
|
|
||||||
'table_action' => 'Actions',
|
|
||||||
'form_add_tittle' => 'New Test Sample',
|
|
||||||
'form_test_name' => 'Test Name',
|
|
||||||
'form_unit_sign' => 'Unit Sign',
|
|
||||||
'form_field_type' => 'Field Type',
|
|
||||||
'form_edit_tittle' => 'Edit Test Sample',
|
|
||||||
'form_description' => 'Description',
|
|
||||||
'form_format' => 'Format',
|
|
||||||
'form_ref_range' => 'Reference Range',
|
|
||||||
'form_ref_min' => 'Min-Value',
|
|
||||||
'form_ref_sign' => 'Sign',
|
|
||||||
'form_ref_max' => 'Max-Value',
|
|
||||||
'form_ref_patient_type' => 'Patient Type',
|
|
||||||
'form_organism' => 'Organisim & Antibiotic',
|
|
||||||
'organism_input_placeholder' => 'Organism name',
|
|
||||||
'antibiotic_inut_placeholder' => 'Antibiotic name',
|
|
||||||
'form_organism_selected' => 'Selected',
|
|
||||||
'form_formula' => 'Formula',
|
|
||||||
'formula_equation' => 'Equation',
|
|
||||||
|
|
||||||
'btn_apply_to_all_tests' => 'Apply to all tests',
|
|
||||||
'code' => 'Code',
|
|
||||||
|
|
||||||
'create_success' => 'Test sample has been created!',
|
|
||||||
'create_fail' => 'An error occur while trying to create test sample record. Please try again.',
|
|
||||||
'update_success' => 'Test sample record has been updated!',
|
|
||||||
'update_fail' => 'An error occur while trying to update test sample record. Please try again.',
|
|
||||||
'delete_success' => 'Test sample record has been deleted!',
|
|
||||||
'delete_fail' => 'An error occur while trying to delete test sample record. Please try again.',
|
|
||||||
'restore_success' => 'Test sample record has been restored!',
|
|
||||||
'restore_fail' => 'An error occur while trying to restore test sample record. Please try again.',
|
|
||||||
'get_success' => 'Test sample record has been retrieved!',
|
|
||||||
'get_fail' => 'An error occur while trying to retrieve test sample record. Please try again.',
|
|
||||||
|
|
||||||
'add_commission_success' => 'Commission record has been added!',
|
|
||||||
'add_commission_fail' => 'An error occur while trying to add commission record. Please try again.',
|
|
||||||
'select_organism' => 'Selected Organisms',
|
|
||||||
'result_highlight_with_bold_text' => 'Highlight with Bold Text on Result Page',
|
|
||||||
'auto_suggest_results' => 'Auto Suggest Result',
|
|
||||||
|
|
||||||
'numeric' => 'Numeric',
|
|
||||||
'calculate' => 'Calculate',
|
|
||||||
'single' => 'Single Selection',
|
|
||||||
'multiple' => 'Multiple Selection',
|
|
||||||
'text' => 'Long Text',
|
|
||||||
'attachment' => 'Attachment',
|
|
||||||
'heading' => 'Heading'
|
|
||||||
|
|
||||||
];
|
|
||||||
@@ -18,8 +18,8 @@ return [
|
|||||||
'non_of_above' => 'Others',
|
'non_of_above' => 'Others',
|
||||||
'form_edit_tittle' => 'Edit User Account',
|
'form_edit_tittle' => 'Edit User Account',
|
||||||
'form_system_role' => 'System-Role',
|
'form_system_role' => 'System-Role',
|
||||||
'form_lab_cover' => 'Laboratory Coverage',
|
'form_lab_cover' => 'Organization Coverage',
|
||||||
'form_laboratory' => 'Laboratory',
|
'form_laboratory' => 'Organization',
|
||||||
'form_select_all_lab' => 'Select All Labs',
|
'form_select_all_lab' => 'Select All Labs',
|
||||||
'form_password' => 'Password',
|
'form_password' => 'Password',
|
||||||
'form_character' => 'characters',
|
'form_character' => 'characters',
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
return [
|
|
||||||
|
|
||||||
'date' =>'Date',
|
|
||||||
'next_visit' =>'Next Visit',
|
|
||||||
'name' =>'Vaccine Name',
|
|
||||||
'unit_price' =>'Unit Price',
|
|
||||||
'qty' =>'Quantity',
|
|
||||||
'subtotal' =>'Sub Total',
|
|
||||||
'new_title' =>'New Vaccination',
|
|
||||||
'btn_save' =>'Save',
|
|
||||||
'create_success' =>'Vaccination record has been saved.',
|
|
||||||
'create_fail' =>'Failed while saving vaccination record.',
|
|
||||||
'update_success' =>'Vaccination record has been updated.',
|
|
||||||
'update_fail' =>'Failed while updating vaccination record.',
|
|
||||||
'delete_success' =>'Vaccination record has been deleted.',
|
|
||||||
'delete_fail' =>'Failed while deleting vaccination record.',
|
|
||||||
'restore_success' =>'Vaccination record has been restored.',
|
|
||||||
'restore_fail' =>'Failed while restoring vaccination record.',
|
|
||||||
'list_title' =>'Vaccinations',
|
|
||||||
'invoice_title' =>'Vaccination Invoice',
|
|
||||||
'edit_title' =>'Edit Vaccination',
|
|
||||||
|
|
||||||
|
|
||||||
];
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
return [
|
|
||||||
'table_title' => 'តារាងឱសថប្រឆាំងមេរោគ',
|
|
||||||
'search_placeholder' => 'ឈ្មោះឱសថប្រឆាំងមេរោគ',
|
|
||||||
'table_no' => 'ល.រ',
|
|
||||||
'table_name' => 'ឈ្មោះ',
|
|
||||||
'table_status' => 'ស្ថានភាព',
|
|
||||||
'table_action' => 'ប្រតិបត្តិការ',
|
|
||||||
'form_add_tittle' => 'បង្កើតអង់ទីប៊ីយោទិកថ្មី',
|
|
||||||
'form_name' => 'ឱសថប្រឆាំងមេរោគ',
|
|
||||||
'form_sort' => 'លេខរៀង',
|
|
||||||
'form_edit_tittle' => 'កែប្រែព័ត៌មានឱសថប្រឆាំងមេរោគ',
|
|
||||||
|
|
||||||
'create_success' => 'ឈ្មោះឱសថប្រឆាំងមេរោគថ្មីបង្កើតបានសម្រេច។',
|
|
||||||
'create_fail' => 'មិនអាចបង្កើតឈ្មោះឱសថប្រឆាំងមេរោគថ្មីបានទេ។ សូមសាកល្បងម្តងទៀត',
|
|
||||||
'update_success' => 'ព័ត៌មានឈ្មោះឱសថប្រឆាំងមេរោគកែប្រែបានសម្រេច។ ',
|
|
||||||
'update_fail' => 'មិនអាចកែប្រែព័ត៌មានឈ្មោះឱសថប្រឆាំងមេរោគបានទេ។ សូមសាកល្បងម្តងទៀត',
|
|
||||||
'delete_success' => 'ព័ត៌មានឈ្មោះឱសថប្រឆាំងមេរោគលុបចេញពីប្រព័ន្ធបានសម្រេច។',
|
|
||||||
'delete_fail' => 'មិនអាចលុបព័ត៌មានឈ្មោះឱសថប្រឆាំងមេរោគចេញពីប្រព័ន្ធបានទេ។ សូមសាកល្បងម្តងទៀត',
|
|
||||||
'restore_success' => 'ព័ត៌មានឈ្មោះឱសថប្រឆាំងមេរោគស្តារបានសម្រេច។',
|
|
||||||
'restore_fail' => 'មិនអាចស្តារព័ត៌មានឈ្មោះឱសថប្រឆាំងមេរោគបានទេ។ សូមសាកល្បងម្តងទៀត',
|
|
||||||
'get_success' => 'ព័ត៌មានឈ្មោះឱសថប្រឆាំងមេរោគទាញយកបានសម្រេច។',
|
|
||||||
'get_fail' => 'មិនអាចទាញយកព័ត៌មានឈ្មោះឱសថប្រឆាំងមេរោគបានទេ។ សូមសាកល្បងម្តងទៀត'
|
|
||||||
|
|
||||||
];
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
return [
|
|
||||||
'type' => 'ប្រភេទណាត់ជួប',
|
|
||||||
'date' => 'ថ្ងៃណាត់ជួប',
|
|
||||||
'duration' => 'រយៈពេលជាថ្ងៃ',
|
|
||||||
'patient' => 'អ្នកជំងឺ',
|
|
||||||
'description' => 'បរិយាយ',
|
|
||||||
'doctor' => 'គ្រូពេទ្យ',
|
|
||||||
'create_success' => 'ការណាត់ជួបថ្មីបង្កើតបានសម្រេច។',
|
|
||||||
'create_fail' => 'មិនអាចបង្កើតការណាត់ជួបថ្មីបានទេ។ សូមសាកល្បងម្តងទៀត',
|
|
||||||
'update_success' => 'ព័ត៌មានការណាត់ជួបកែប្រែបានសម្រេច។ ',
|
|
||||||
'update_fail' => 'មិនអាចកែប្រែព័ត៌មានការណាត់ជួបបានទេ។ សូមសាកល្បងម្តងទៀត',
|
|
||||||
'delete_success' => 'ព័ត៌មានការណាត់ជួបលុបចេញពីប្រព័ន្ធបានសម្រេច។',
|
|
||||||
'delete_fail' => 'មិនអាចលុបព័ត៌មានការណាត់ជួបចេញពីប្រព័ន្ធបានទេ។ សូមសាកល្បងម្តងទៀត',
|
|
||||||
'restore_success' => 'ព័ត៌មានការណាត់ជួបស្តារបានសម្រេច។',
|
|
||||||
'restore_fail' => 'មិនអាចស្តារព័ត៌មានការណាត់ជួបបានទេ។ សូមសាកល្បងម្តងទៀត',
|
|
||||||
'get_success' => 'ព័ត៌មានការណាត់ជួបទាញយកបានសម្រេច។',
|
|
||||||
'get_fail' => 'មិនអាចទាញយកព័ត៌មានការណាត់ជួបបានទេ។ សូមសាកល្បងម្តងទៀត'
|
|
||||||
];
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
return [
|
|
||||||
'table_title' => 'តារាងមតិយោបល់',
|
|
||||||
'search_placeholder' => 'ឈ្មោះមតិយោបល់..',
|
|
||||||
'table_no' => 'ល.រ',
|
|
||||||
'table_name' => 'មតិយោបល់',
|
|
||||||
'table_department' => 'ផ្នែកមន្ទីរពិសោធន៌',
|
|
||||||
'table_sample_type' => 'ប្រភេទសំណាក',
|
|
||||||
'table_status' => 'ស្ថានភាព',
|
|
||||||
'table_action' => 'ប្រតិបត្តិការ',
|
|
||||||
'form_add_tittle' => 'យោបល់ថ្មី',
|
|
||||||
'form_name' => 'ទម្រង់មតិយោបល់',
|
|
||||||
'form_sample_type' => 'ប្រភេទសំណាក',
|
|
||||||
'form_department' => 'ផ្នែកមន្ទីរពិសោធន៌',
|
|
||||||
'form_edit_tittle' => 'កែប្រែយោបល់',
|
|
||||||
|
|
||||||
'create_success' => 'មតិយោបល់ថ្មីបង្កើតបានសម្រេច។',
|
|
||||||
'create_fail' => 'មិនអាចបង្កើតមតិយោបល់ថ្មីបានទេ។ សូមសាកល្បងម្តងទៀត',
|
|
||||||
'update_success' => 'ព័ត៌មានមតិយោបល់កែប្រែបានសម្រេច។ ',
|
|
||||||
'update_fail' => 'មិនអាចកែប្រែព័ត៌មានមតិយោបល់បានទេ។ សូមសាកល្បងម្តងទៀត',
|
|
||||||
'delete_success' => 'ព័ត៌មានមតិយោបល់លុបចេញពីប្រព័ន្ធបានសម្រេច។',
|
|
||||||
'delete_fail' => 'មិនអាចលុបព័ត៌មានមតិយោបល់ចេញពីប្រព័ន្ធបានទេ។ សូមសាកល្បងម្តងទៀត',
|
|
||||||
'restore_success' => 'ព័ត៌មានមតិយោបល់ស្តារបានសម្រេច។',
|
|
||||||
'restore_fail' => 'មិនអាចស្តារព័ត៌មានមតិយោបល់បានទេ។ សូមសាកល្បងម្តងទៀត',
|
|
||||||
'get_success' => 'ព័ត៌មានមតិយោបល់ទាញយកបានសម្រេច។',
|
|
||||||
'get_fail' => 'មិនអាចទាញយកព័ត៌មានមតិយោបល់បានទេ។ សូមសាកល្បងម្តងទៀត'
|
|
||||||
|
|
||||||
];
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user