update
This commit is contained in:
@@ -7,7 +7,12 @@ namespace Modules\Internal\Http\Controllers\Api;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Helpers\Helper;
|
||||
use App\Models\OLDLMS\DoctorRating;
|
||||
use Box\Spout\Writer\Common\Creator\WriterEntityFactory;
|
||||
use Box\Spout\Writer\Common\Creator\Style\StyleBuilder;
|
||||
use Box\Spout\Common\Entity\Style\CellAlignment;
|
||||
|
||||
class DoctorRatingController extends Controller
|
||||
{
|
||||
@@ -22,7 +27,7 @@ class DoctorRatingController extends Controller
|
||||
if ($id !== null) {
|
||||
$query->where('nID', $id);
|
||||
}
|
||||
|
||||
|
||||
$doctorRatings = $query->with([
|
||||
'user' => function ($query) {
|
||||
$query->select('nID', 'sFirstName'); // Select only necessary columns
|
||||
@@ -30,7 +35,7 @@ class DoctorRatingController extends Controller
|
||||
])
|
||||
->select('nIDUser', 'nIDDokter', 'nRating', 'sNotes', 'dCreateOn')
|
||||
->get();
|
||||
|
||||
|
||||
|
||||
// $prescriptions->toArray();
|
||||
// dd($prescriptions);
|
||||
@@ -39,9 +44,178 @@ class DoctorRatingController extends Controller
|
||||
// return response()->json(Helper::paginateResources(LivechatResource::collection($livechat)));
|
||||
}
|
||||
|
||||
public function getData(Request $request)
|
||||
{
|
||||
$limit = $request->has('per_page') ? $request->input('per_page') : 50;
|
||||
$results = DB::connection('oldlms')->table('tx_dokter_rating')
|
||||
->leftJoin('tm_users', 'tx_dokter_rating.nIDUser', '=', 'tm_users.nID')
|
||||
->leftJoin('tm_dokter', 'tx_dokter_rating.nIDDokter', '=', 'tm_dokter.nID')
|
||||
->when($request->input('search'), function ($query, $search) {
|
||||
$query->where(function ($query) use ($search) {
|
||||
$query->orWhere('tm_users.sFirstname', 'like', "%" . $search . "%");
|
||||
$query->orWhere('tx_dokter_rating.sNotes', 'like', "%" . $search . "%");
|
||||
});
|
||||
})
|
||||
->when($request->has('orderBy'), function ($query) use ($request) {
|
||||
$orderBy = $request->orderBy;
|
||||
$direction = $request->order ?? 'asc';
|
||||
|
||||
$query->orderBy($orderBy, $direction);
|
||||
})
|
||||
->when($request->input('start_date') , function ($query, $start_date) {
|
||||
$query->where(function ($query) use ($start_date) {
|
||||
$query->where('tx_dokter_rating.dCreateOn', '>=', $start_date. ' 00:00:00');
|
||||
});
|
||||
})
|
||||
->when($request->input('end_date') , function ($query, $end_date) {
|
||||
$query->where(function ($query) use ($end_date) {
|
||||
$query->where('tx_dokter_rating.dCreateOn', '<=', $end_date. ' 23:59:59');
|
||||
});
|
||||
})
|
||||
// ->when($request->input('provider') , function ($query, $provider) {
|
||||
// $query->where(function ($query) use ($provider) {
|
||||
// $query->where('request_logs.organization_id', '=', $provider);
|
||||
// });
|
||||
// })
|
||||
// ->where('files.fileable_type', '=', 'App\Models\RequestLog')
|
||||
// ->where('request_logs.final_log', '=', '1')
|
||||
// ->where('request_logs.status_final_log', '=', 'approved')
|
||||
->select(
|
||||
DB::connection('oldlms')->raw("CONCAT(tm_users.sFirstName, ' ', IFNULL(tm_users.sMiddleName, ''), ' ', IFNULL(tm_users.sLastName, '')) as nama_peserta"),
|
||||
'tx_dokter_rating.nRating as rating',
|
||||
'tx_dokter_rating.sNotes',
|
||||
'tx_dokter_rating.dCreateOn',
|
||||
DB::connection('oldlms')->raw("
|
||||
(SELECT CONCAT(tm_users.sFirstName, ' ', IFNULL(tm_users.sMiddleName, ''), ' ', IFNULL(tm_users.sLastName, '')) FROM tm_users WHERE tm_users.nID = tm_dokter.nIDUser LIMIT 1) AS nama_dokter
|
||||
")
|
||||
)
|
||||
->paginate($limit);
|
||||
|
||||
|
||||
|
||||
return response()->json(Helper::paginateResources($results));
|
||||
}
|
||||
|
||||
public function export(Request $request)
|
||||
{
|
||||
$start_date = $request->input('start_date') ? $request->input('start_date') : 'all';
|
||||
$end_date = $request->input('end_date') ? $request->input('end_date') : 'all';
|
||||
$writer = WriterEntityFactory::createXLSXWriter();
|
||||
$writer->openToFile(public_path('files/Report-Data-Rating-Dokter-'.$start_date.'-'.$end_date.'.xlsx'));
|
||||
$header = [
|
||||
'No',
|
||||
'Nama Peserta',
|
||||
'Nama Dokter',
|
||||
'Rating',
|
||||
'Review',
|
||||
'Tanggal Konsultasi',
|
||||
];
|
||||
$style = (new StyleBuilder())
|
||||
->setFontBold()
|
||||
// ->setFontSize(15)
|
||||
// ->setFontColor(Color::BLUE)
|
||||
// ->setShouldWrapText()
|
||||
->setCellAlignment(CellAlignment::LEFT)
|
||||
// ->setBackgroundColor(Color::YELLOW)
|
||||
->build();
|
||||
|
||||
$headerRow = WriterEntityFactory::createRowFromArray($header, $style);
|
||||
$writer->addRow($headerRow);
|
||||
// ============================
|
||||
$results = DB::connection('oldlms')->table('tx_dokter_rating')
|
||||
->leftJoin('tm_users', 'tx_dokter_rating.nIDUser', '=', 'tm_users.nID')
|
||||
->leftJoin('tm_dokter', 'tx_dokter_rating.nIDDokter', '=', 'tm_dokter.nID')
|
||||
->when($request->input('search'), function ($query, $search) {
|
||||
$query->where(function ($query) use ($search) {
|
||||
$query->orWhere('tm_users.sFirstname', 'like', "%" . $search . "%");
|
||||
$query->orWhere('tx_dokter_rating.sNotes', 'like', "%" . $search . "%");
|
||||
});
|
||||
})
|
||||
->when($request->has('orderBy'), function ($query) use ($request) {
|
||||
$orderBy = $request->orderBy;
|
||||
$direction = $request->order ?? 'asc';
|
||||
|
||||
$query->orderBy($orderBy, $direction);
|
||||
})
|
||||
->when($request->input('start_date') , function ($query, $start_date) {
|
||||
$query->where(function ($query) use ($start_date) {
|
||||
$query->where('tx_dokter_rating.dCreateOn', '>=', $start_date. ' 00:00:00');
|
||||
});
|
||||
})
|
||||
->when($request->input('end_date') , function ($query, $end_date) {
|
||||
$query->where(function ($query) use ($end_date) {
|
||||
$query->where('tx_dokter_rating.dCreateOn', '<=', $end_date. ' 23:59:59');
|
||||
});
|
||||
})
|
||||
// ->when($request->input('provider') , function ($query, $provider) {
|
||||
// $query->where(function ($query) use ($provider) {
|
||||
// $query->where('request_logs.organization_id', '=', $provider);
|
||||
// });
|
||||
// })
|
||||
// ->where('files.fileable_type', '=', 'App\Models\RequestLog')
|
||||
// ->where('request_logs.final_log', '=', '1')
|
||||
// ->where('request_logs.status_final_log', '=', 'approved')
|
||||
->select(
|
||||
DB::connection('oldlms')->raw("CONCAT(tm_users.sFirstName, ' ', IFNULL(tm_users.sMiddleName, ''), ' ', IFNULL(tm_users.sLastName, '')) as nama_peserta"),
|
||||
'tx_dokter_rating.nRating',
|
||||
'tx_dokter_rating.sNotes',
|
||||
'tx_dokter_rating.dCreateOn',
|
||||
DB::connection('oldlms')->raw("
|
||||
(SELECT CONCAT(tm_users.sFirstName, ' ', IFNULL(tm_users.sMiddleName, ''), ' ', IFNULL(tm_users.sLastName, '')) FROM tm_users WHERE tm_users.nID = tm_dokter.nIDUser LIMIT 1) AS nama_dokter
|
||||
")
|
||||
)
|
||||
->get();
|
||||
$no=0;
|
||||
foreach($results as $item)
|
||||
{
|
||||
$no++;
|
||||
$rowData = [
|
||||
$no,
|
||||
$item->nama_peserta,
|
||||
$item->nama_dokter,
|
||||
$item->nRating,
|
||||
$item->sNotes,
|
||||
$item->dCreateOn,
|
||||
];
|
||||
$style = (new StyleBuilder())
|
||||
//->setFontBold()
|
||||
// ->setFontSize(15)
|
||||
// ->setFontColor(Color::BLUE)
|
||||
// ->setShouldWrapText()
|
||||
->setCellAlignment(CellAlignment::LEFT)
|
||||
// ->setBackgroundColor(Color::YELLOW)
|
||||
->build();
|
||||
$row = WriterEntityFactory::createRowFromArray($rowData, $style);
|
||||
$writer->addRow($row);
|
||||
}
|
||||
$footer = [
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
''
|
||||
];
|
||||
$style = (new StyleBuilder())
|
||||
->setFontBold()
|
||||
// ->setFontSize(15)
|
||||
// ->setFontColor(Color::BLUE)
|
||||
// ->setShouldWrapText()
|
||||
->setCellAlignment(CellAlignment::LEFT)
|
||||
// ->setBackgroundColor(Color::YELLOW)
|
||||
->build();
|
||||
|
||||
$footerRow = WriterEntityFactory::createRowFromArray($footer, $style);
|
||||
$writer->addRow($footerRow);
|
||||
|
||||
$writer->close();
|
||||
|
||||
return Helper::responseJson([
|
||||
'file_name' => 'Report-Data-Rating-Dokter-'. $start_date.'-'.$end_date,
|
||||
"file_url" => url('files/Report-Data-Rating-Dokter-'. $start_date.'-'.$end_date.'.xlsx')
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
* @return Renderable
|
||||
|
||||
@@ -27,17 +27,21 @@ class DrugController extends Controller
|
||||
}
|
||||
|
||||
public function drugList(Request $request){
|
||||
|
||||
$drugs = Drug::query()
|
||||
->where([
|
||||
'atc_code' => 'lms', // ini untuk menggunakan list obat yang baru
|
||||
'atc_code' => $request->provider, // ini untuk menggunakan list obat yang baru
|
||||
])
|
||||
->get();
|
||||
|
||||
$manipulatedDrugs = $drugs->map(function ($drug) {
|
||||
// Contoh manipulasi, tambahkan atau ubah properti sesuai kebutuhan
|
||||
return [
|
||||
'value' => $drug->id, // Ganti dengan properti yang sesuai dari model Icd
|
||||
'label' => $drug->name, // Ganti dengan properti yang sesuai dari model Icd
|
||||
'value' => $drug->id,
|
||||
'label' => $drug->name,
|
||||
'code' => $drug->code,
|
||||
'price' => $drug->price,
|
||||
'unit' => $drug->unit,
|
||||
];
|
||||
});
|
||||
return Helper::responseJson(data: $manipulatedDrugs);
|
||||
@@ -152,6 +156,7 @@ class DrugController extends Controller
|
||||
$importedRows = 0;
|
||||
$failedRows = [];
|
||||
|
||||
|
||||
foreach ($processedData as $row) {
|
||||
try {
|
||||
Drug::updateOrCreate([
|
||||
@@ -169,11 +174,13 @@ class DrugController extends Controller
|
||||
'type' => $row['type'],
|
||||
'dosage' => $row['dosage'],
|
||||
'remark' => $row['remark'],
|
||||
'price' => $row['price'],
|
||||
// 'price' => $row['price'],
|
||||
'unit' => $row['unit'],
|
||||
]
|
||||
);
|
||||
$importedRows++;
|
||||
} catch (\Exception $e) {
|
||||
dd($e);
|
||||
$failedRows[] = $row;
|
||||
}
|
||||
}
|
||||
|
||||
192
Modules/Internal/Http/Controllers/Api/KatalogDokterController.php
Executable file
192
Modules/Internal/Http/Controllers/Api/KatalogDokterController.php
Executable file
@@ -0,0 +1,192 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Internal\Http\Controllers\Api;
|
||||
|
||||
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Helpers\Helper;
|
||||
use App\Models\OLDLMS\DoctorRating;
|
||||
use Box\Spout\Writer\Common\Creator\WriterEntityFactory;
|
||||
use Box\Spout\Writer\Common\Creator\Style\StyleBuilder;
|
||||
use Box\Spout\Common\Entity\Style\CellAlignment;
|
||||
|
||||
class KatalogDokterController extends Controller
|
||||
{
|
||||
public function getData(Request $request)
|
||||
{
|
||||
$limit = $request->has('per_page') ? $request->input('per_page') : 50;
|
||||
$results = DB::connection('oldlms')->table('tm_dokter')
|
||||
->leftJoin('tm_users', 'tm_dokter.nIDUser', '=', 'tm_users.nID')
|
||||
->leftJoin('tx_jadwal_dokter', 'tm_dokter.nID', '=', 'tx_jadwal_dokter.nIDDokter')
|
||||
->leftJoin('tm_users_education', 'tm_dokter.nIDUser', '=', 'tm_users_education.nIDUser')
|
||||
->leftJoin('tm_healthcare', 'tx_jadwal_dokter.nIDHealthCare', '=', 'tm_healthcare.nID')
|
||||
->when($request->input('search'), function ($query, $search) {
|
||||
$query->where(function ($query) use ($search) {
|
||||
$query->orWhere('tm_users.sFirstname', 'like', "%" . $search . "%");
|
||||
$query->orWhere('tm_dokter.sSTR', 'like', "%" . $search . "%");
|
||||
$query->orWhere('tm_healthcare.sHealthCare', 'like', "%" . $search . "%");
|
||||
});
|
||||
})
|
||||
->when($request->has('orderBy'), function ($query) use ($request) {
|
||||
$orderBy = $request->orderBy;
|
||||
$direction = $request->order ?? 'asc';
|
||||
|
||||
$query->orderBy($orderBy, $direction);
|
||||
})
|
||||
->when($request->input('start_date') , function ($query, $start_date) {
|
||||
$query->where(function ($query) use ($start_date) {
|
||||
$query->where('tm_dokter.dSTRExpireDate', '>=', $start_date. ' 00:00:00');
|
||||
});
|
||||
})
|
||||
->when($request->input('end_date') , function ($query, $end_date) {
|
||||
$query->where(function ($query) use ($end_date) {
|
||||
$query->where('tm_dokter.dSTRExpireDate', '<=', $end_date. ' 23:59:59');
|
||||
});
|
||||
})
|
||||
// ->when($request->input('provider') , function ($query, $provider) {
|
||||
// $query->where(function ($query) use ($provider) {
|
||||
// $query->where('request_logs.organization_id', '=', $provider);
|
||||
// });
|
||||
// })
|
||||
// ->where('files.fileable_type', '=', 'App\Models\RequestLog')
|
||||
// ->where('request_logs.final_log', '=', '1')
|
||||
// ->where('request_logs.status_final_log', '=', 'approved')
|
||||
->select(
|
||||
DB::connection('oldlms')->raw("CONCAT(tm_users.sFirstName, ' ', IFNULL(tm_users.sMiddleName, ''), ' ', IFNULL(tm_users.sLastName, '')) as nama_dokter"),
|
||||
'tm_users_education.sUniversitas as lulusan',
|
||||
'tm_dokter.sSTR as str',
|
||||
'tx_jadwal_dokter.sSIP as sip',
|
||||
'tm_healthcare.sHealthCare as tempat_praktek',
|
||||
)
|
||||
->paginate($limit);
|
||||
|
||||
|
||||
|
||||
return response()->json(Helper::paginateResources($results));
|
||||
}
|
||||
|
||||
public function export(Request $request)
|
||||
{
|
||||
$start_date = $request->input('start_date') ? $request->input('start_date') : 'all';
|
||||
$end_date = $request->input('end_date') ? $request->input('end_date') : 'all';
|
||||
$writer = WriterEntityFactory::createXLSXWriter();
|
||||
$writer->openToFile(public_path('files/Report-Data-Katalog-Dokter-'.$start_date.'-'.$end_date.'.xlsx'));
|
||||
$header = [
|
||||
'No',
|
||||
'Nama Dokter',
|
||||
'Lulusan',
|
||||
'STR',
|
||||
'SIP',
|
||||
'Tempat Praktek',
|
||||
];
|
||||
$style = (new StyleBuilder())
|
||||
->setFontBold()
|
||||
// ->setFontSize(15)
|
||||
// ->setFontColor(Color::BLUE)
|
||||
// ->setShouldWrapText()
|
||||
->setCellAlignment(CellAlignment::LEFT)
|
||||
// ->setBackgroundColor(Color::YELLOW)
|
||||
->build();
|
||||
|
||||
$headerRow = WriterEntityFactory::createRowFromArray($header, $style);
|
||||
$writer->addRow($headerRow);
|
||||
// ============================
|
||||
$results = DB::connection('oldlms')->table('tm_dokter')
|
||||
->leftJoin('tm_users', 'tm_dokter.nIDUser', '=', 'tm_users.nID')
|
||||
->leftJoin('tx_jadwal_dokter', 'tm_dokter.nID', '=', 'tx_jadwal_dokter.nIDDokter')
|
||||
->leftJoin('tm_users_education', 'tm_dokter.nIDUser', '=', 'tm_users_education.nIDUser')
|
||||
->leftJoin('tm_healthcare', 'tx_jadwal_dokter.nIDHealthCare', '=', 'tm_healthcare.nID')
|
||||
->when($request->input('search'), function ($query, $search) {
|
||||
$query->where(function ($query) use ($search) {
|
||||
$query->orWhere('tm_users.sFirstname', 'like', "%" . $search . "%");
|
||||
$query->orWhere('tm_dokter.sSTR', 'like', "%" . $search . "%");
|
||||
$query->orWhere('tm_healthcare.sHealthCare', 'like', "%" . $search . "%");
|
||||
});
|
||||
})
|
||||
->when($request->has('orderBy'), function ($query) use ($request) {
|
||||
$orderBy = $request->orderBy;
|
||||
$direction = $request->order ?? 'asc';
|
||||
|
||||
$query->orderBy($orderBy, $direction);
|
||||
})
|
||||
->when($request->input('start_date') , function ($query, $start_date) {
|
||||
$query->where(function ($query) use ($start_date) {
|
||||
$query->where('tm_dokter.dSTRExpireDate', '>=', $start_date. ' 00:00:00');
|
||||
});
|
||||
})
|
||||
->when($request->input('end_date') , function ($query, $end_date) {
|
||||
$query->where(function ($query) use ($end_date) {
|
||||
$query->where('tm_dokter.dSTRExpireDate', '<=', $end_date. ' 23:59:59');
|
||||
});
|
||||
})
|
||||
// ->when($request->input('provider') , function ($query, $provider) {
|
||||
// $query->where(function ($query) use ($provider) {
|
||||
// $query->where('request_logs.organization_id', '=', $provider);
|
||||
// });
|
||||
// })
|
||||
// ->where('files.fileable_type', '=', 'App\Models\RequestLog')
|
||||
// ->where('request_logs.final_log', '=', '1')
|
||||
// ->where('request_logs.status_final_log', '=', 'approved')
|
||||
->select(
|
||||
DB::connection('oldlms')->raw("CONCAT(tm_users.sFirstName, ' ', IFNULL(tm_users.sMiddleName, ''), ' ', IFNULL(tm_users.sLastName, '')) as nama_dokter"),
|
||||
'tm_users_education.sUniversitas as lulusan',
|
||||
'tm_dokter.sSTR as str',
|
||||
'tx_jadwal_dokter.sSIP as sip',
|
||||
'tm_healthcare.sHealthCare as tempat_praktek',
|
||||
)
|
||||
->get();
|
||||
$no=0;
|
||||
foreach($results as $item)
|
||||
{
|
||||
$no++;
|
||||
$rowData = [
|
||||
$no,
|
||||
$item->nama_dokter,
|
||||
$item->lulusan,
|
||||
$item->str,
|
||||
$item->sip,
|
||||
$item->tempat_praktek,
|
||||
];
|
||||
$style = (new StyleBuilder())
|
||||
//->setFontBold()
|
||||
// ->setFontSize(15)
|
||||
// ->setFontColor(Color::BLUE)
|
||||
// ->setShouldWrapText()
|
||||
->setCellAlignment(CellAlignment::LEFT)
|
||||
// ->setBackgroundColor(Color::YELLOW)
|
||||
->build();
|
||||
$row = WriterEntityFactory::createRowFromArray($rowData, $style);
|
||||
$writer->addRow($row);
|
||||
}
|
||||
$footer = [
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
''
|
||||
];
|
||||
$style = (new StyleBuilder())
|
||||
->setFontBold()
|
||||
// ->setFontSize(15)
|
||||
// ->setFontColor(Color::BLUE)
|
||||
// ->setShouldWrapText()
|
||||
->setCellAlignment(CellAlignment::LEFT)
|
||||
// ->setBackgroundColor(Color::YELLOW)
|
||||
->build();
|
||||
|
||||
$footerRow = WriterEntityFactory::createRowFromArray($footer, $style);
|
||||
$writer->addRow($footerRow);
|
||||
|
||||
$writer->close();
|
||||
|
||||
return Helper::responseJson([
|
||||
'file_name' => 'Report-Data-Katalog-Dokter-'. $start_date.'-'.$end_date,
|
||||
"file_url" => url('files/Report-Data-Katalog-Dokter-'. $start_date.'-'.$end_date.'.xlsx')
|
||||
]);
|
||||
}
|
||||
}
|
||||
270
Modules/Internal/Http/Controllers/Api/Linksehat/HealthRecordController.php
Executable file
270
Modules/Internal/Http/Controllers/Api/Linksehat/HealthRecordController.php
Executable file
@@ -0,0 +1,270 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Internal\Http\Controllers\Api\Linksehat;
|
||||
|
||||
use App\Helpers\Helper;
|
||||
use App\Models\OLDLMS\Livechat;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Modules\Internal\Transformers\ReportPhrResource;
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Box\Spout\Reader\Common\Creator\ReaderEntityFactory;
|
||||
use Box\Spout\Writer\Common\Creator\WriterEntityFactory;
|
||||
|
||||
class HealthRecordController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
* @return Renderable
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
// return $request->toArray();
|
||||
$livechat = Livechat::query()
|
||||
->with([ 'user', 'doctor', 'doctor.user', 'doctor.user.detail', 'doctor.speciality', 'appointment', 'healthCare', 'summary']);
|
||||
|
||||
if ($request->has('search')) {
|
||||
$search = $request->search;
|
||||
$livechat->where(function ($query) use ($search) {
|
||||
$query->where('nID', $search)
|
||||
->orWhereHas('user', function ($detail) use ($search) {
|
||||
$detail->where('sFirstName', 'LIKE', '%' . $search . '%')
|
||||
->orWhere('sLastName', 'LIKE', '%' . $search . '%');
|
||||
})
|
||||
->orWhereHas('healthCare', function ($detail) use ($search) {
|
||||
$detail->where('sHealthCare', 'LIKE', '%' . $search . '%');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (($request->has('livechat_start') || $request->has('livechat_end'))
|
||||
&& !empty($request->livechat_start)
|
||||
&& !empty($request->livechat_end)
|
||||
) {
|
||||
|
||||
|
||||
$livechat = $livechat->where(function($q) use ($request) {
|
||||
$q->where('dCreateOn', '>=', $request->livechat_start)
|
||||
->where('dCreateOn', '<=', $request->livechat_end);
|
||||
});
|
||||
}
|
||||
|
||||
if ($request->has('healthcare_id') && !empty($request->healthcare_id)) {
|
||||
$livechat->where('nIDHealthCare', $request->healthcare_id);
|
||||
}
|
||||
|
||||
$livechats = $livechat->orderBy('dUpdateOn', 'DESC')
|
||||
->paginate();
|
||||
|
||||
return Helper::responseJson(Helper::paginateResources(ReportPhrResource::collection($livechats)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
* @return Renderable
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return view('internal::create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
* @param Request $request
|
||||
* @return Renderable
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
return view('internal::show');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
return view('internal::edit');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
* @param Request $request
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
// Function to determine if a string is serialized
|
||||
private function is_serialized($string) {
|
||||
// Check if string is empty
|
||||
if (empty($string)) {
|
||||
return false;
|
||||
}
|
||||
// Check for common serialized string patterns
|
||||
return ($string == 'b:0;' || @unserialize($string) !== false);
|
||||
}
|
||||
|
||||
// Function to determine if a string is JSON
|
||||
private function is_json($string) {
|
||||
// Check if string is empty
|
||||
if (empty($string)) {
|
||||
return false;
|
||||
}
|
||||
// Decode JSON and check for errors
|
||||
json_decode($string);
|
||||
return (json_last_error() == JSON_ERROR_NONE);
|
||||
}
|
||||
|
||||
// Function to safely process the plan
|
||||
private function processPlan($sPlan) {
|
||||
// Check if the string is serialized
|
||||
if ($this->is_serialized($sPlan)) {
|
||||
$unserializedPlan = @unserialize($sPlan);
|
||||
if ($unserializedPlan !== false || $sPlan === 'b:0;') {
|
||||
return $unserializedPlan;
|
||||
}
|
||||
}
|
||||
// Check if the string is JSON
|
||||
elseif ($this->is_json($sPlan)) {
|
||||
$jsonPlan = json_decode($sPlan, true);
|
||||
if (json_last_error() == JSON_ERROR_NONE) {
|
||||
return $jsonPlan;
|
||||
}
|
||||
}
|
||||
// Treat as plain text if not serialized or JSON
|
||||
return $sPlan;
|
||||
}
|
||||
|
||||
public function generateExcel(Request $request){
|
||||
Helper::setCustomPHPIniSettings();
|
||||
|
||||
$file_name = 'Data Report Riwayat Rekam Medis';
|
||||
// Membuat penulis entitas Spout
|
||||
$writer = WriterEntityFactory::createXLSXWriter();
|
||||
// Membuka penulis untuk menulis ke file
|
||||
$writer->openToFile(public_path('files/Report-Riwayat-Rekam-Medis.xlsx'));
|
||||
$headerArray = [
|
||||
'Healthcare',
|
||||
'Patient',
|
||||
'Doctor',
|
||||
'Speciality',
|
||||
'Date',
|
||||
'Keluhan (Subjective)',
|
||||
'Pemerikasan Fisik Online (Objective)',
|
||||
'Diagnosa (Assessment)',
|
||||
'Tata Laksana (Plan)',
|
||||
];
|
||||
// Sheet 1
|
||||
$writer->getCurrentSheet()->setName('Data');
|
||||
$headers_map_to_table_fields = $headerArray;
|
||||
$headerRow = WriterEntityFactory::createRowFromArray($headers_map_to_table_fields);
|
||||
$writer->addRow($headerRow);
|
||||
$livechats = Livechat::query()
|
||||
->with([ 'user', 'doctor', 'doctor.user', 'doctor.user.detail', 'doctor.speciality', 'appointment', 'healthCare', 'summary']);
|
||||
|
||||
if ($request->has('search')) {
|
||||
$search = $request->search;
|
||||
$livechats->where(function ($query) use ($search) {
|
||||
$query->where('nID', $search)
|
||||
->orWhereHas('user', function ($detail) use ($search) {
|
||||
$detail->where('sFirstName', 'LIKE', '%' . $search . '%')
|
||||
->orWhere('sLastName', 'LIKE', '%' . $search . '%');
|
||||
})
|
||||
->orWhereHas('healthCare', function ($detail) use ($search) {
|
||||
$detail->where('sHealthCare', 'LIKE', '%' . $search . '%');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (($request->has('livechat_start') || $request->has('livechat_end'))
|
||||
&& !empty($request->livechat_start)
|
||||
&& !empty($request->livechat_end)
|
||||
) {
|
||||
$livechats = $livechats->where(function($q) use ($request) {
|
||||
$q->where('dCreateOn', '>=', $request->livechat_start)
|
||||
->where('dCreateOn', '<=', $request->livechat_end);
|
||||
});
|
||||
}
|
||||
|
||||
$livechats = $livechats->get();
|
||||
|
||||
if ($livechats){
|
||||
foreach ($livechats as $index => $row) {
|
||||
$doctor_name = '-';
|
||||
if ($row->doctor && $row->doctor->user && $row->doctor->user->detail) {
|
||||
$doctor_name = $row->doctor->user->detail->sTitlePrefix . ' ' . $row->doctor->user->fullname;
|
||||
}
|
||||
$speciality = $row->doctor->speciality->sSpesialis ?? '-';
|
||||
// Check if $row->summary and $row->summary->sPlan are set and not null
|
||||
if (isset($row->summary) && isset($row->summary->sPlan)) {
|
||||
$plan = $this->processPlan($row->summary->sPlan);
|
||||
|
||||
if (is_array($plan)) {
|
||||
// Mengubah array menjadi string dengan format yang diinginkan
|
||||
$plans = implode(', ', array_map(function($item) {
|
||||
return !empty($item['note']) ? $item['note'] : '-';
|
||||
}, $plan));
|
||||
} else {
|
||||
// Jika $plan bukan array, set $plans menjadi tanda '-'
|
||||
$plans = '-';
|
||||
}
|
||||
} else {
|
||||
// If $row->summary or $row->summary->sPlan are not set, set $plans to '-'
|
||||
$plans = '-';
|
||||
}
|
||||
|
||||
$rowData = [
|
||||
$row->healthCare ? $row->healthCare->sHealthCare : '-',
|
||||
$row->user ? $row->user->sFirstName : '-',
|
||||
$doctor_name,
|
||||
$speciality,
|
||||
$row->summary ? Carbon::parse($row->dCreateOn)->format('Y-m-d H:i:s') : '-',
|
||||
$row->summary ? $row->summary->sSubjective : '-',
|
||||
$row->summary ? $row->summary->sObjective : '-',
|
||||
$row->summary ? $row->summary->sAssessment : '-',
|
||||
// is_array($plan) ? implode(', ', $plan[0]) : $plan, // Handle arrays from unserialized or JSON data
|
||||
$row->summary ? $plans : '-',
|
||||
];
|
||||
|
||||
// Create a row from the array and add it to the writer
|
||||
$rowEntity = WriterEntityFactory::createRowFromArray($rowData);
|
||||
$writer->addRow($rowEntity);
|
||||
}
|
||||
}
|
||||
$writer->close();
|
||||
return Helper::responseJson([
|
||||
'file_name' => "Data Riwayat Log " . date('Y-m-d h:i:s'),
|
||||
"file_url" => url('files/Report-Riwayat-Rekam-Medis.xlsx')
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,240 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Internal\Http\Controllers\Api\Linksehat;
|
||||
|
||||
use App\Helpers\Helper;
|
||||
use App\Models\OLDLMS\Prescription;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Modules\Internal\Transformers\ReportPrescriptionResource;
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Box\Spout\Reader\Common\Creator\ReaderEntityFactory;
|
||||
use Box\Spout\Writer\Common\Creator\WriterEntityFactory;
|
||||
|
||||
class PrescriptionController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
* @return Renderable
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
// return $request->toArray();
|
||||
$prescription = Prescription::query()
|
||||
->with(['livechat', 'user', 'items']);
|
||||
if ($request->has('search')) {
|
||||
$search = $request->search;
|
||||
$prescription->where(function ($query) use ($search) {
|
||||
$query->where('sDokterName', 'LIKE', '%' . $search . "%")
|
||||
->orWhere('sKodeResep', 'LIKE', '%' . $search . "%");
|
||||
});
|
||||
}
|
||||
|
||||
if (($request->has('prescription_start') || $request->has('prescription_end'))
|
||||
&& !empty($request->prescription_start)
|
||||
&& !empty($request->prescription_end)
|
||||
) {
|
||||
|
||||
|
||||
$prescription = $prescription->where(function($q) use ($request) {
|
||||
$q->where('dTanggalResep', '>=', $request->prescription_start)
|
||||
->where('dTanggalResep', '<=', $request->prescription_end);
|
||||
});
|
||||
}
|
||||
|
||||
$prescriptions = $prescription->orderBy('dUpdateOn', 'DESC')
|
||||
->paginate();
|
||||
|
||||
return Helper::responseJson(Helper::paginateResources(ReportPrescriptionResource::collection($prescriptions)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
* @return Renderable
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return view('internal::create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
* @param Request $request
|
||||
* @return Renderable
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
return view('internal::show');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
return view('internal::edit');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
* @param Request $request
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
// Function to determine if a string is serialized
|
||||
private function is_serialized($string) {
|
||||
return ($string == 'b:0;' || @unserialize($string) !== false);
|
||||
}
|
||||
|
||||
// Function to determine if a string is JSON
|
||||
private function is_json($string) {
|
||||
json_decode($string);
|
||||
return (json_last_error() == JSON_ERROR_NONE);
|
||||
}
|
||||
|
||||
// Function to safely process the plan
|
||||
private function processPlan($sPlan) {
|
||||
if ($this->is_serialized($sPlan)) {
|
||||
$unserializedPlan = @unserialize($sPlan);
|
||||
if ($unserializedPlan !== false || $sPlan === 'b:0;') {
|
||||
return $unserializedPlan;
|
||||
}
|
||||
} elseif ($this->is_json($sPlan)) {
|
||||
$jsonPlan = json_decode($sPlan, true);
|
||||
if (json_last_error() == JSON_ERROR_NONE) {
|
||||
return $jsonPlan;
|
||||
}
|
||||
}
|
||||
return $sPlan; // Treat as plain text if not serialized or JSON
|
||||
}
|
||||
|
||||
public function generateExcel(Request $request)
|
||||
{
|
||||
Helper::setCustomPHPIniSettings();
|
||||
|
||||
$file_name = 'Data Report Resep Online';
|
||||
// Membuat penulis entitas Spout
|
||||
$writer = WriterEntityFactory::createXLSXWriter();
|
||||
// Membuka penulis untuk menulis ke file
|
||||
$writer->openToFile(public_path('files/Report-Resep-Online.xlsx'));
|
||||
|
||||
$headerArray = [
|
||||
'No',
|
||||
'Prescription Code',
|
||||
'Date Consultation',
|
||||
'Patient',
|
||||
'Doctor',
|
||||
'Jenis Obat (Drugs)',
|
||||
'Jumlah Obat (QTY)',
|
||||
'Cara Minum Obat',
|
||||
];
|
||||
|
||||
// Sheet 1
|
||||
$writer->getCurrentSheet()->setName('Data');
|
||||
$headerRow = WriterEntityFactory::createRowFromArray($headerArray);
|
||||
$writer->addRow($headerRow);
|
||||
|
||||
// Query prescription data
|
||||
$prescriptionQuery = Prescription::query()
|
||||
->with(['livechat', 'user', 'items']);
|
||||
|
||||
if ($request->has('search')) {
|
||||
$search = $request->search;
|
||||
$prescriptionQuery->where(function ($query) use ($search) {
|
||||
$query->where('sDokterName', 'LIKE', '%' . $search . '%')
|
||||
->orWhere('sKodeResep', 'LIKE', '%' . $search . '%');
|
||||
});
|
||||
}
|
||||
|
||||
if ($request->has('prescription_start') && $request->has('prescription_end') &&
|
||||
!empty($request->prescription_start) && !empty($request->prescription_end)) {
|
||||
$prescriptionQuery->whereBetween('dTanggalResep', [$request->prescription_start, $request->prescription_end]);
|
||||
}
|
||||
|
||||
$prescriptions = $prescriptionQuery->get();
|
||||
|
||||
if ($prescriptions->isNotEmpty()) {
|
||||
$no = 1;
|
||||
foreach ($prescriptions as $index => $row) {
|
||||
if ($row->items->isNotEmpty()) {
|
||||
$rowData = [
|
||||
$no++,
|
||||
$row->sKodeResep ?? '-',
|
||||
$row->dTanggalResep ? Carbon::parse($row->dTanggalResep)->format('Y-m-d') : '-',
|
||||
$row->user->name ?? '-',
|
||||
$row->sDokterName ?? '-',
|
||||
];
|
||||
|
||||
// Create a row from the array and add it to the writer
|
||||
$rowEntity = WriterEntityFactory::createRowFromArray($rowData);
|
||||
$writer->addRow($rowEntity);
|
||||
foreach ($row->items as $item) {
|
||||
$rowSubData = [
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
$item->sItemName ?? '-',
|
||||
$item->nQty ?? '-',
|
||||
$item->sSigna ?? '-'
|
||||
];
|
||||
$subData = WriterEntityFactory::createRowFromArray($rowSubData);
|
||||
$writer->addRow($subData);
|
||||
}
|
||||
} else {
|
||||
$rowData = [
|
||||
$no++,
|
||||
$row->sKodeResep ?? '-',
|
||||
$row->dTanggalResep ? Carbon::parse($row->dTanggalResep)->format('Y-m-d') : '-',
|
||||
$row->user->name ?? '-',
|
||||
$row->sDokterName ?? '-',
|
||||
];
|
||||
// Create a row from the array and add it to the writer
|
||||
$rowEntity = WriterEntityFactory::createRowFromArray($rowData);
|
||||
$writer->addRow($rowEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$writer->close();
|
||||
|
||||
return Helper::responseJson([
|
||||
'file_name' => "Data Resep Online " . date('Y-m-d h:i:s'),
|
||||
'file_url' => url('files/Report-Resep-Online.xlsx')
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,243 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Internal\Http\Controllers\Api\Linksehat;
|
||||
|
||||
use App\Helpers\Helper;
|
||||
use App\Models\OLDLMS\Rujukan;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Modules\Internal\Transformers\ReportRujukanResource;
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Box\Spout\Reader\Common\Creator\ReaderEntityFactory;
|
||||
use Box\Spout\Writer\Common\Creator\WriterEntityFactory;
|
||||
|
||||
class RujukanController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
* @return Renderable
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
// return $request->toArray();
|
||||
$rujukan = Rujukan::query()
|
||||
->with(['livechat', 'livechat.user']);
|
||||
|
||||
if ($request->has('search')) {
|
||||
$search = $request->search;
|
||||
$rujukan->where(function ($query) use ($search) {
|
||||
$query->where('nID', $search)
|
||||
->orWhereHas('user', function ($detail) use ($search) {
|
||||
$detail->where('sFirstName', 'LIKE', '%' . $search . '%')
|
||||
->orWhere('sLastName', 'LIKE', '%' . $search . '%');
|
||||
})
|
||||
->orWhereHas('healthCare', function ($detail) use ($search) {
|
||||
$detail->where('sHealthCare', 'LIKE', '%' . $search . '%');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (($request->has('rujukan_start') || $request->has('rujukan_end'))
|
||||
&& !empty($request->rujukan_start)
|
||||
&& !empty($request->rujukan_end)
|
||||
) {
|
||||
|
||||
|
||||
$rujukan = $rujukan->where(function($q) use ($request) {
|
||||
$q->where('dCreateOn', '>=', $request->rujukan_start)
|
||||
->where('dCreateOn', '<=', $request->rujukan_end);
|
||||
});
|
||||
}
|
||||
|
||||
if ($request->has('healthcare_id') && !empty($request->healthcare_id)) {
|
||||
$rujukan->where('nIDHealthCare', $request->healthcare_id);
|
||||
}
|
||||
|
||||
$rujukans = $rujukan->orderBy('dUpdateOn', 'DESC')
|
||||
->paginate();
|
||||
|
||||
return Helper::responseJson(Helper::paginateResources(ReportRujukanResource::collection($rujukans)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
* @return Renderable
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return view('internal::create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
* @param Request $request
|
||||
* @return Renderable
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
return view('internal::show');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
return view('internal::edit');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
* @param Request $request
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
// Function to determine if a string is serialized
|
||||
private function is_serialized($string) {
|
||||
return ($string == 'b:0;' || @unserialize($string) !== false);
|
||||
}
|
||||
|
||||
// Function to determine if a string is JSON
|
||||
private function is_json($string) {
|
||||
json_decode($string);
|
||||
return (json_last_error() == JSON_ERROR_NONE);
|
||||
}
|
||||
|
||||
// Function to safely process the plan
|
||||
private function processPlan($sPlan) {
|
||||
if ($this->is_serialized($sPlan)) {
|
||||
$unserializedPlan = @unserialize($sPlan);
|
||||
if ($unserializedPlan !== false || $sPlan === 'b:0;') {
|
||||
return $unserializedPlan;
|
||||
}
|
||||
} elseif ($this->is_json($sPlan)) {
|
||||
$jsonPlan = json_decode($sPlan, true);
|
||||
if (json_last_error() == JSON_ERROR_NONE) {
|
||||
return $jsonPlan;
|
||||
}
|
||||
}
|
||||
return $sPlan; // Treat as plain text if not serialized or JSON
|
||||
}
|
||||
|
||||
public function generateExcel(Request $request){
|
||||
Helper::setCustomPHPIniSettings();
|
||||
|
||||
$file_name = 'Data Report Riwayat Rekam Medis';
|
||||
// Membuat penulis entitas Spout
|
||||
$writer = WriterEntityFactory::createXLSXWriter();
|
||||
// Membuka penulis untuk menulis ke file
|
||||
$writer->openToFile(public_path('files/Report-Riwayat-Rekam-Medis.xlsx'));
|
||||
$headerArray = [
|
||||
'Healthcare',
|
||||
'Patient',
|
||||
'Doctor',
|
||||
'Speciality',
|
||||
'Date',
|
||||
'Keluhan (Subjective)',
|
||||
'Pemerikasan Fisik Online (Objective)',
|
||||
'Diagnosa (Assessment)',
|
||||
'Tata Laksana (Plan)',
|
||||
];
|
||||
// Sheet 1
|
||||
$writer->getCurrentSheet()->setName('Data');
|
||||
$headers_map_to_table_fields = $headerArray;
|
||||
$headerRow = WriterEntityFactory::createRowFromArray($headers_map_to_table_fields);
|
||||
$writer->addRow($headerRow);
|
||||
$rujukans = Livechat::query()
|
||||
->with([ 'user', 'doctor', 'doctor.user', 'doctor.user.detail', 'doctor.speciality', 'appointment', 'healthCare', 'summary']);
|
||||
|
||||
if ($request->has('search')) {
|
||||
$search = $request->search;
|
||||
$rujukans->where(function ($query) use ($search) {
|
||||
$query->where('nID', $search)
|
||||
->orWhereHas('user', function ($detail) use ($search) {
|
||||
$detail->where('sFirstName', 'LIKE', '%' . $search . '%')
|
||||
->orWhere('sLastName', 'LIKE', '%' . $search . '%');
|
||||
})
|
||||
->orWhereHas('healthCare', function ($detail) use ($search) {
|
||||
$detail->where('sHealthCare', 'LIKE', '%' . $search . '%');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (($request->has('rujukan_start') || $request->has('rujukan_end'))
|
||||
&& !empty($request->rujukan_start)
|
||||
&& !empty($request->rujukan_end)
|
||||
) {
|
||||
$rujukans = $rujukans->where(function($q) use ($request) {
|
||||
$q->where('dCreateOn', '>=', $request->rujukan_start)
|
||||
->where('dCreateOn', '<=', $request->rujukan_end);
|
||||
});
|
||||
}
|
||||
|
||||
$rujukans = $rujukans->get();
|
||||
|
||||
if ($rujukans){
|
||||
foreach ($rujukans as $index => $row) {
|
||||
$doctor_name = '-';
|
||||
if ($row->doctor && $row->doctor->user && $row->doctor->user->detail) {
|
||||
$doctor_name = $row->doctor->user->detail->sTitlePrefix . ' ' . $row->doctor->user->fullname;
|
||||
}
|
||||
$speciality = $row->doctor->speciality->sSpesialis ?? '-';
|
||||
// Process the plan
|
||||
$plan = '-';
|
||||
if ($row->summary && $row->summary->sPlan) {
|
||||
$plan = $this->processPlan($row->summary->sPlan);
|
||||
}
|
||||
|
||||
$rowData = [
|
||||
$row->healthCare ? $row->healthCare->sHealthCare : '-',
|
||||
$row->user ? $row->user->sFirstName : '-',
|
||||
$doctor_name,
|
||||
$speciality,
|
||||
$row->summary ? Carbon::parse($row->dCreateOn)->format('Y-m-d H:i:s') : '-',
|
||||
$row->summary ? $row->summary->sSubjective : '-',
|
||||
$row->summary ? $row->summary->sObjective : '-',
|
||||
$row->summary ? $row->summary->sAssessment : '-',
|
||||
is_array($plan) ? implode(', ', $plan) : $plan, // Handle arrays from unserialized or JSON data
|
||||
];
|
||||
|
||||
// Create a row from the array and add it to the writer
|
||||
$rowEntity = WriterEntityFactory::createRowFromArray($rowData);
|
||||
$writer->addRow($rowEntity);
|
||||
}
|
||||
}
|
||||
$writer->close();
|
||||
return Helper::responseJson([
|
||||
'file_name' => "Data Riwayat Log " . date('Y-m-d h:i:s'),
|
||||
"file_url" => url('files/Report-Riwayat-Rekam-Medis.xlsx')
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -109,12 +109,11 @@ class RequestLogController extends Controller
|
||||
'member_id' => 'required',
|
||||
'service_code' => 'required',
|
||||
]);
|
||||
|
||||
if ($request->member_id){
|
||||
try {
|
||||
$code = !empty($this->getNextCode($request)) ? $this->getNextCode($request) : null;
|
||||
|
||||
$member = Member::find($request->member_id);
|
||||
|
||||
$memberValid = false;
|
||||
if ($member){
|
||||
if (($member->members_effective_date <= date('Y-m-d')) &&
|
||||
@@ -203,9 +202,13 @@ class RequestLogController extends Controller
|
||||
return Helper::responseJson(data: RequestLogShowResource::make($claimRequest));
|
||||
}
|
||||
|
||||
public function diagnosis(){
|
||||
public function diagnosis(Request $request){
|
||||
$icds = Icd::query()
|
||||
->get();
|
||||
->when($request->search, function ($q, $search) {
|
||||
$q->where('code', 'LIKE', "%".$search."%");
|
||||
$q->orWhere('name', 'LIKE', "%".$search."%");
|
||||
})
|
||||
->paginate();
|
||||
|
||||
$manipulatedIcds = $icds->map(function ($icd) {
|
||||
// Contoh manipulasi, tambahkan atau ubah properti sesuai kebutuhan
|
||||
@@ -447,9 +450,17 @@ class RequestLogController extends Controller
|
||||
$requestLog->discharge_date = $request->discharge_date;
|
||||
}
|
||||
if (!empty($request->icdCodes)) {
|
||||
$diagnosis = implode(',', $request->icdCodes);
|
||||
$data = [];
|
||||
if (count($request->icdCodes)>0){
|
||||
foreach($request->icdCodes as $code){
|
||||
array_push($data, $code['value']);
|
||||
}
|
||||
}
|
||||
$diagnosis = implode(',', $data);
|
||||
|
||||
$requestLog->diagnosis = $diagnosis;
|
||||
} else {
|
||||
$requestLog->diagnosis = '';
|
||||
}
|
||||
if (!empty($request->status)) {
|
||||
$requestLog->status_final_log = $status;
|
||||
@@ -698,8 +709,8 @@ class RequestLogController extends Controller
|
||||
]);
|
||||
|
||||
if ($affectedRows === 0) {
|
||||
$row['code_error'] = '500';
|
||||
$row['error'] = 'Gagal update karena data sudah ada ';
|
||||
$row['code_error'] = '200';
|
||||
$row['error'] = 'Tidak ada data yang diedit';
|
||||
$result_rows[] = $row;
|
||||
$failedRows[] = $row;
|
||||
} else {
|
||||
@@ -1038,12 +1049,12 @@ class RequestLogController extends Controller
|
||||
// $last_number = RequestLog::max('code');
|
||||
// $next_number = empty($last_number) ? 1 : ((int) explode('-', $last_number)[2] + 1);
|
||||
// return self::makeCode($next_number);
|
||||
|
||||
$source = $request->source == 'client-portal' ? 'C' : 'H';
|
||||
$organization = Organization::where(['id' => $request->organization_id, 'type' => 'hospital'])->first('code');
|
||||
$provideCode = $organization ? $organization->code : '';
|
||||
$member = Member::with('currentCorporate')->where(['id' => $request->member_id])->first();
|
||||
|
||||
$member = Member::with(['currentCorporate','currentPolicy' ])->where(['id' => $request->member_id])->first();
|
||||
|
||||
|
||||
$data = [
|
||||
'source' => $source,
|
||||
'provideCode' => $provideCode,
|
||||
@@ -1052,11 +1063,12 @@ class RequestLogController extends Controller
|
||||
'member_code' => $member->member_id,
|
||||
];
|
||||
|
||||
|
||||
|
||||
$last_numeric_code = RequestLog::select(DB::raw('MAX(CAST(SUBSTRING_INDEX(code, ".", -1) AS SIGNED)) as max_numeric_code'))
|
||||
->whereRaw('SUBSTRING_INDEX(code, ".", -1) REGEXP "^[0-9]+$"')
|
||||
->value('max_numeric_code');
|
||||
// $next_number = 1;
|
||||
|
||||
if ($last_numeric_code) {
|
||||
// // Jika ada kode sebelumnya, pecah kode dan tambahkan 1 ke angka terakhir
|
||||
// $parts = explode('-', $last_code);
|
||||
@@ -1155,4 +1167,10 @@ class RequestLogController extends Controller
|
||||
// Jika file tidak ditemukan di penyimpanan, kirim respons JSON gagal
|
||||
return Helper::responseJson(data: $request->toArray(), message: 'File deletion failed');
|
||||
}
|
||||
|
||||
public function cekphp(){
|
||||
phpinfo();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -22,6 +22,11 @@ class UserManagementController extends Controller
|
||||
$search = $request->get('search');
|
||||
$query->where('name', 'like', "%{$search}%");
|
||||
}
|
||||
if($request->has('guard_name'))
|
||||
{
|
||||
$guard_name = $request->get('guard_name');
|
||||
$query->where('guard_name', '=', $guard_name);
|
||||
}
|
||||
$userRole = $query->paginate(10);
|
||||
return Helper::paginateResources($userRole);
|
||||
}
|
||||
@@ -133,6 +138,13 @@ class UserManagementController extends Controller
|
||||
$search = $request->get('search');
|
||||
$userAccess->where('name', 'like', "%{$search}%");
|
||||
}
|
||||
if($request->has('guard_name'))
|
||||
{
|
||||
$guard_name = $request->get('guard_name');
|
||||
$userAccess->whereHas('role', function ($query) use ($guard_name) {
|
||||
$query->where('guard_name', $guard_name);
|
||||
});
|
||||
}
|
||||
$userAccess = $userAccess->paginate(10);
|
||||
return Helper::paginateResources($userAccess);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user