mirror of
https://gitlab.com/signalytic/client-external/streamline/streamline-emr.git
synced 2026-09-12 03:01:32 +00:00
resolved conflicts
This commit is contained in:
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\ClinicalData\Services\Clinics;
|
||||
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Streamline\Models\Clinic;
|
||||
|
||||
class ClinicsService implements ClinicsServiceInterface
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function getClinicById($id): ?Clinic
|
||||
{
|
||||
return Clinic::where(['id' => $id])->first();
|
||||
}
|
||||
|
||||
public function createClinic($name, $clinic_type = null, $available = 1): ?Clinic
|
||||
{
|
||||
$clinic = new Clinic;
|
||||
|
||||
$clinic->name = $name;
|
||||
$clinic->available = $available;
|
||||
$clinic->slug = $clinic_type ?? 'general';
|
||||
$clinic->created_by = Auth::id();
|
||||
$clinic->updated_by = Auth::id();
|
||||
|
||||
try {
|
||||
$clinic->save();
|
||||
return $clinic;
|
||||
} catch (\Exception $e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public function editClinic($id, $name, $available, $clinic_type = null): ?Clinic
|
||||
{
|
||||
$clinic = $this->getClinicById($id);
|
||||
$clinic->name = $name;
|
||||
$clinic->available = $available;
|
||||
$clinic->slug = $clinic_type ?? 'general';
|
||||
|
||||
try {
|
||||
$clinic->save();
|
||||
return $clinic;
|
||||
} catch (\Exception $e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public function deactivateClinic(int $id): bool
|
||||
{
|
||||
$clinic = $this->getClinicById($id);
|
||||
|
||||
try {
|
||||
$clinic->delete();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function activateClinic($clinicId): array
|
||||
{
|
||||
$clinic= Clinic::withTrashed()->find($clinicId);
|
||||
|
||||
if($clinic->restore()){
|
||||
return [true, "Clinic has been activated"];
|
||||
} else {
|
||||
return [false, ""];
|
||||
}
|
||||
}
|
||||
|
||||
public function getClinicTypes(): array{
|
||||
return [
|
||||
'ante_natal' => 'ANTE-NATAL Clinic', 'art' => 'A.R.T Clinic',
|
||||
'diabetes' => 'Diabetes Clinic', 'mental_health' => 'Mental Health Clinic',
|
||||
'maternity' => 'Maternity Clinic', 'general' => 'General', 'eye' => 'Eye Clinic',
|
||||
];
|
||||
}
|
||||
|
||||
public function getClinicsSeeder(): array{
|
||||
return [
|
||||
['name' => 'ANTE-NATAL Clinic', 'slug' => 'ante_natal'],
|
||||
['name' => 'A.R.T Clinic', 'slug' => 'art'],
|
||||
['name' => 'Dental Clinic', 'slug' => 'general'],
|
||||
['name' => 'Diabetes Clinic', 'slug' => 'diabetes'],
|
||||
['name' => 'Paediatric Clinic', 'slug' => 'general'],
|
||||
['name' => 'Psychiatry Clinic', 'slug' => 'mental_health'],
|
||||
['name' => 'TB Clinic', 'slug' => 'general'],
|
||||
['name' => 'Accident & Emergency Clinic', 'slug' => 'general'],
|
||||
['name' => 'General Adult Clinic', 'slug' => 'general'],
|
||||
['name' => 'Maternity Clinic', 'slug' => 'maternity'],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\ClinicalData\Services\Clinics;
|
||||
|
||||
use Streamline\Models\Clinic;
|
||||
|
||||
interface ClinicsServiceInterface
|
||||
{
|
||||
|
||||
public function __construct();
|
||||
|
||||
public function getClinicById($id): ?Clinic;
|
||||
|
||||
public function createClinic($name, $clinic_type = null, $available = 1): ?Clinic;
|
||||
|
||||
public function editClinic($id, $name, $available, $clinic_type = null): ?Clinic;
|
||||
|
||||
public function deactivateClinic(int $id): bool;
|
||||
|
||||
public function activateClinic($clinicId): array;
|
||||
|
||||
public function getClinicTypes(): array;
|
||||
|
||||
public function getClinicsSeeder(): array;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\ClinicalData\Services\Drugs;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Streamline\Models\DrugForm;
|
||||
|
||||
class DrugFormsService
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public function pluckAvailableDrugForms(string $valueColumn): Collection
|
||||
{
|
||||
return DB::table('drug_forms')->whereNull('deleted_at')
|
||||
->pluck($valueColumn, 'id');
|
||||
}
|
||||
|
||||
public function pluckAvailableDrugFormsModels(): DrugForm
|
||||
{
|
||||
return DrugForm::pluck('name', 'id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\ClinicalData\Services\Drugs;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Streamline\Models\DrugRoute;
|
||||
|
||||
class DrugRoutesService
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public function pluckAvailableDrugRoutes(string $valueColumn): Collection
|
||||
{
|
||||
return DB::table('drug_routes')->whereNull('deleted_at')
|
||||
->where('available', 1)
|
||||
->pluck($valueColumn, 'id');
|
||||
}
|
||||
|
||||
public function pluckAvailableDrugRoutesModels(): DrugRoute
|
||||
{
|
||||
return DrugRoute::where('available', 1)
|
||||
->pluck('name', 'id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\ClinicalData\Services\Drugs;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Streamline\Models\DrugUnit;
|
||||
|
||||
class DrugUnitsService
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public function pluckAvailableDrugUnits(string $valueColumn): Collection
|
||||
{
|
||||
return DB::table('drug_units')->whereNull('deleted_at')
|
||||
->pluck($valueColumn, 'id');
|
||||
}
|
||||
|
||||
public function pluckAvailableDrugUnitsModels(): DrugUnit
|
||||
{
|
||||
return DrugUnit::pluck('name', 'id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\ClinicalData\Services\Drugs;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Streamline\Models\Drug;
|
||||
|
||||
class DrugsService
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public function pluckAvailableDrugs(string $valueColumn): Collection
|
||||
{
|
||||
return DB::table('drugs')->whereNull('deleted_at')
|
||||
->where('available', 1)
|
||||
->pluck($valueColumn, 'id');
|
||||
}
|
||||
|
||||
public function pluckAvailableDrugsModels(): Drug
|
||||
{
|
||||
return Drug::where('available', 1)
|
||||
->pluck('name', 'id');
|
||||
}
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\ClinicalData\Services\Investigations;
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class InvestigationsService
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public function getInvestigationCategoriesBySuper(): array
|
||||
{
|
||||
return DB::table('investigation_categories')
|
||||
->pluck('super_category_id', 'id')->toArray();
|
||||
}
|
||||
|
||||
public function getInvestigationSuperCategories(): array
|
||||
{
|
||||
return DB::table('investigation_super_categories')
|
||||
->pluck('name', 'id')->toArray();
|
||||
}
|
||||
|
||||
public function getInvestigationsByName(): array
|
||||
{
|
||||
return DB::table('investigations')
|
||||
->pluck('name', 'id')->toArray();
|
||||
}
|
||||
|
||||
public function getInvestigationsByCategory(): array
|
||||
{
|
||||
return DB::table('investigations')
|
||||
->pluck('category', 'id')->toArray();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user