modified assests
This commit is contained in:
@@ -20,7 +20,7 @@ use App\Models\Sample;
|
||||
use App\Models\SampleType;
|
||||
use App\Models\TestSample;
|
||||
use App\Models\TestSampleOrganism;
|
||||
use App\Models\UserLabCover;
|
||||
use App\Models\UserOrganization;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -41,11 +41,11 @@ class UtilController extends Controller
|
||||
|
||||
protected $testSampleOrganismModel;
|
||||
|
||||
private $baseLabId;
|
||||
private $baseOrganizationId;
|
||||
protected $base;
|
||||
|
||||
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,
|
||||
PatientType $patientTypeModel, TestSampleOrganism $testSampleOrganism
|
||||
){
|
||||
@@ -61,8 +61,8 @@ class UtilController extends Controller
|
||||
|
||||
$this->testSampleOrganismModel = $testSampleOrganism;
|
||||
|
||||
$this->baseLabId = Session::get('base_lab_id');
|
||||
$this->base = Session::get('base_lab');
|
||||
$this->baseOrganizationId = Session::get('base_organization_id');
|
||||
$this->base = Session::get('base_organization');
|
||||
}
|
||||
|
||||
function province($responseType = 'object')
|
||||
@@ -118,7 +118,7 @@ class UtilController extends Controller
|
||||
|
||||
public function getDepartment(){
|
||||
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]);
|
||||
} catch (\Exception $e)
|
||||
{
|
||||
@@ -128,7 +128,7 @@ class UtilController extends Controller
|
||||
|
||||
public function getDepartmentByLabId($labId){
|
||||
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]);
|
||||
} catch (\Exception $e)
|
||||
{
|
||||
@@ -172,7 +172,7 @@ class UtilController extends Controller
|
||||
$rejectComment = $this->rejectCommentModel::query()->create([
|
||||
'sample_condition_id' => 3,
|
||||
'reject_comment' => $request->name_en,
|
||||
'lab_id' => $this->baseLabId
|
||||
'organization_id' => $this->baseOrganizationId
|
||||
]);
|
||||
return response()->json(['success'=> true , 'data' => [$rejectComment]]);
|
||||
} catch (\Exception $e)
|
||||
@@ -184,7 +184,7 @@ class UtilController extends Controller
|
||||
function getTestItem(){
|
||||
try{
|
||||
$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();
|
||||
return response()->json(['success'=> true , 'data' => SampleTestResource::collection($departments)]);
|
||||
} catch (\Exception $e){
|
||||
@@ -193,13 +193,13 @@ class UtilController extends Controller
|
||||
}
|
||||
|
||||
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){
|
||||
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['result_comment'] = [];
|
||||
$arrData['sample'] = array(
|
||||
@@ -251,17 +251,17 @@ class UtilController extends Controller
|
||||
ifnull(prev_r.test_result,"") as prev_result,
|
||||
ts.is_bold,
|
||||
ts.autocomplete_bind,
|
||||
ts.lab_id,
|
||||
ts.organization_id,
|
||||
sd.sample_descr
|
||||
FROM samples s
|
||||
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
|
||||
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
|
||||
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
|
||||
ON t.`id` = ts.`test_id`
|
||||
INNER JOIN sample_types st
|
||||
@@ -282,14 +282,14 @@ class UtilController extends Controller
|
||||
INNER JOIN test_results tr
|
||||
ON tr.`sample_id` = s.`id`
|
||||
WHERE s.id = '.$previousId.'
|
||||
AND s.`lab_id` = '.$this->baseLabId.'
|
||||
AND s.`organization_id` = '.$this->baseOrganizationId.'
|
||||
AND tr.record_status_id = 1
|
||||
) prev_r
|
||||
ON prev_r.test_sample_id = tr.`test_sample_id`
|
||||
|
||||
WHERE s.`id` = '.$sampleId.'
|
||||
AND s.`lab_id`= '.$this->baseLabId.'
|
||||
and ts.lab_id = '.$this->baseLabId.'
|
||||
AND s.`organization_id`= '.$this->baseOrganizationId.'
|
||||
and ts.organization_id = '.$this->baseOrganizationId.'
|
||||
AND tr.`record_status_id` = '.BaseModel::RECORD_STATUS_ACTIVE.'
|
||||
|
||||
ORDER BY
|
||||
@@ -381,7 +381,7 @@ class UtilController extends Controller
|
||||
'is_bold' => (int) $row->is_bold,
|
||||
'autocomplete_bind' => (int) $row->autocomplete_bind,
|
||||
'ts' => $row->test_result,
|
||||
'lab_id' => $row->lab_id,
|
||||
'organization_id' => $row->organization_id,
|
||||
'format' => (int)$row->format
|
||||
);
|
||||
$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(
|
||||
[
|
||||
BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE,
|
||||
'lab_id' => $this->baseLabId
|
||||
'organization_id' => $this->baseOrganizationId
|
||||
])->whereIn('sample_type_id', $sampleTypeIds)->get()->toArray();
|
||||
}
|
||||
|
||||
@@ -438,7 +438,7 @@ class UtilController extends Controller
|
||||
ogr.id
|
||||
FROM `organism_results` AS ogr
|
||||
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
|
||||
ON tsr.test_sample_id = trs.test_sample_id
|
||||
AND tsr.`organism_id` = ogr.`organism_id`
|
||||
@@ -468,7 +468,7 @@ class UtilController extends Controller
|
||||
ogr.id
|
||||
FROM `organism_results` AS ogr
|
||||
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
|
||||
ON s.id = trs.sample_id
|
||||
INNER JOIN `test_sample_organisms` tsr
|
||||
@@ -479,7 +479,7 @@ class UtilController extends Controller
|
||||
LEFT JOIN `quantities` qt
|
||||
ON qt.id = ogr.`quantity_id`
|
||||
WHERE s.id = '.$previousSampleId.'
|
||||
AND s.`lab_id` = '.$this->baseLabId.'
|
||||
AND s.`organization_id` = '.$this->baseOrganizationId.'
|
||||
AND ogr.record_status_id = 1
|
||||
AND trs.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(
|
||||
[
|
||||
BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE,
|
||||
'lab_id' => $this->baseLabId,
|
||||
'organization_id' => $this->baseOrganizationId,
|
||||
'sample_type_id' => $sampleTypeId
|
||||
])->get();
|
||||
}
|
||||
@@ -586,7 +586,7 @@ class UtilController extends Controller
|
||||
ogr.id
|
||||
FROM `organism_results` AS ogr
|
||||
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
|
||||
ON tsr.test_sample_id = trs.test_sample_id
|
||||
AND tsr.`organism_id` = ogr.`organism_id`
|
||||
@@ -637,7 +637,7 @@ class UtilController extends Controller
|
||||
try{
|
||||
$headingItems = $this->testSampleModel::with(['test'])
|
||||
->where([
|
||||
'lab_id' => $this->baseLabId,
|
||||
'organization_id' => $this->baseOrganizationId,
|
||||
BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE
|
||||
])->when(!empty($sampleTypeId), function ($headingItems) use($sampleTypeId) {
|
||||
$headingItems->where('sample_type_id', $sampleTypeId);
|
||||
@@ -694,13 +694,13 @@ class UtilController extends Controller
|
||||
FROM `physician_commisssion` pc
|
||||
INNER JOIN physicians p
|
||||
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 pc.test_sample_id = '.$testSampleId.'
|
||||
AND pc.`record_status_id` = 1
|
||||
) comm
|
||||
ON comm.physician_id = p.`id`
|
||||
WHERE p.`lab_id` = '.$this->baseLabId.'
|
||||
WHERE p.`organization_id` = '.$this->baseOrganizationId.'
|
||||
AND p.`record_status_id` = 1
|
||||
');
|
||||
$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);
|
||||
$defVal = count($this->getSelectedOrganismResult($sampleId, $testSampleId)) ==0 ? [-1] : $this->getSelectedOrganismResult($sampleId, $testSampleId);
|
||||
$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) {
|
||||
$data['selected'] = in_array($data['id'], $defVal) ? 1: 0;
|
||||
return $data;
|
||||
@@ -810,7 +810,7 @@ class UtilController extends Controller
|
||||
'id' => $item['id'],
|
||||
'test_sample_id' => $item['test_sample_id'],
|
||||
'organism_id' => $item['organism_id'],
|
||||
'lab_id' => $item['lab_id'],
|
||||
'organization_id' => $item['organization_id'],
|
||||
'record_status_id' => $item['record_status_id'],
|
||||
'selected' => $item['selected'],
|
||||
'organism' => $item['organism'],
|
||||
@@ -842,14 +842,14 @@ class UtilController extends Controller
|
||||
$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);
|
||||
$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) {
|
||||
$data['selected'] = 1;
|
||||
return $data;
|
||||
})->toArray();
|
||||
|
||||
$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){
|
||||
$testSampleOrganisms->whereIn('organism_id', $this->organismModel::query()->whereRaw("replace(name_en, ' ','') like '%".str_replace(" ","",$request->name)."%'")->pluck('id')->toArray());
|
||||
})->whereNotIn('id', $defVal)
|
||||
|
||||
Reference in New Issue
Block a user