ubah ke docker mode

This commit is contained in:
servdal
2025-07-16 07:36:13 +07:00
parent 6871d14f94
commit 9471bf22f5
15161 changed files with 112 additions and 0 deletions

No files matched your search

@@ -0,0 +1,34 @@
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Services\AstmMessageService;
use App\DataListiner;
class ProcessAstmMessages extends Command
{
protected $signature = 'astm:process-messages';
protected $description = 'Process pending ASTM messages';
private $astmMessageService;
public function __construct(AstmMessageService $astmMessageService)
{
parent::__construct();
$this->astmMessageService = $astmMessageService;
}
public function handle()
{
// Ambil data dari DataListener
$dataListener = DataListiner::whereNull('processed')->get();
if ($dataListener) {
$jumlah = count($dataListener);
$pesan = $this->astmMessageService->processAstmMessages($dataListener);
$this->info($jumlah.' Message processed '.$pesan.' at '.date('Y-m-d H:i:s'));
} else {
$this->info('Skipped Proses at '.date('Y-m-d H:i:s'));
}
}
}
@@ -0,0 +1,61 @@
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use GuzzleHttp\Client;
use App\Models\TestResult;
use App\Pasien;
class SyncLabResults extends Command
{
// Nama dan deskripsi command
protected $signature = 'lab:sync-results';
protected $description = 'Sync lab results from external instruments';
public function __construct()
{
parent::__construct();
}
public function handle()
{
// Instance Guzzle client
$client = new Client();
// URL endpoint API dari alat (ganti dengan URL alat kamu)
$url = 'https://api.examplelab.com/results';
// Contoh request ke API alat untuk mengambil hasil tes
try {
$response = $client->request('GET', $url, [
'headers' => [
'Authorization' => 'Bearer your_api_token', // Jika alat memerlukan token API
'Accept' => 'application/json'
]
]);
// Parsing data JSON yang diterima dari API
$data = json_decode($response->getBody()->getContents(), true);
// Menyimpan hasil tes ke database
foreach ($data as $result) {
// Mencari pasien berdasarkan ID
$patient = Pasien::find($result['patient_id']);
if ($patient) {
TestResult::create([
'patient_id' => $patient->id,
'test_id' => $result['test_id'],
'result_value' => $result['result_value'],
'result_status' => $result['status'],
'timestamp' => $result['timestamp']
]);
}
}
$this->info('Lab results synchronized successfully.');
} catch (\Exception $e) {
$this->error('Error syncing lab results: ' . $e->getMessage());
}
}
}
@@ -0,0 +1,62 @@
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Storage;
class SyncLabResultsFTP extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'app:sync-lab-results-f-t-p';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description';
/**
* Execute the console command.
*/
public function handle()
{
// Mengakses file di FTP server
$ftpDisk = Storage::disk('ftp'); // Pastikan konfigurasi FTP ada di config/filesystems.php
// Mendapatkan daftar file di FTP server
$files = $ftpDisk->files('results'); // Misalnya folder 'results'
foreach ($files as $file) {
// Mengambil file dari FTP dan membaca isinya
$fileContents = $ftpDisk->get($file);
// Proses konten file (misalnya parsing CSV atau XML)
$this->processFileContents($fileContents);
}
$this->info('Lab results synchronized from FTP.');
}
protected function processFileContents($contents)
{
// Misalnya, jika konten dalam format CSV
$rows = str_getcsv($contents, "\n");
foreach ($rows as $row) {
$data = str_getcsv($row);
// Menyimpan hasil tes ke database
TestResult::create([
'patient_id' => $data[0], // Misal, data pasien ada di kolom pertama
'test_id' => $data[1], // Misal, data tes ada di kolom kedua
'result_value' => $data[2],// Nilai hasil tes ada di kolom ketiga
'timestamp' => now(),
]);
}
}
}
@@ -0,0 +1,54 @@
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
class SyncLabResultsSerial extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'app:sync-lab-results-serial';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description';
/**
* Execute the console command.
*/
public function handle()
{
$host = '192.168.1.100'; // IP alat
$port = 4000; // Port alat
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
socket_connect($socket, $host, $port);
$response = socket_read($socket, 1024);
// Proses response dari alat
$this->processSocketData($response);
socket_close($socket);
}
protected function processSocketData($data)
{
// Proses data yang diterima (misalnya parsing atau format hasil tes)
$testResult = json_decode($data, true);
// Simpan hasil tes ke database
TestResult::create([
'patient_id' => $testResult['patient_id'],
'test_id' => $testResult['test_id'],
'result_value' => $testResult['result_value'],
'timestamp' => $testResult['timestamp']
]);
}
}
+31
View File
@@ -0,0 +1,31 @@
<?php
namespace App\Console;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
/**
* Define the application's command schedule.
*/
protected function schedule(Schedule $schedule): void
{
// $schedule->command('inspire')->hourly();
//$schedule->command('lab:sync-results')->everyThirtyMinutes();
//$schedule->command('app:sync-lab-results-f-t-p')->everyThirtyMinutes();
//$schedule->command('app:sync-lab-results-serial')->everyThirtyMinutes();
$schedule->command('astm:process-messages')->everyFiveMinutes();
}
/**
* Register the commands for the application.
*/
protected function commands(): void
{
$this->load(__DIR__.'/Commands');
require base_path('routes/console.php');
}
}
+14
View File
@@ -0,0 +1,14 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class DataListiner extends Model
{
protected $connection = 'mysqllistener';
protected $table = "lis_phoenix";
public $timestamps = false;
protected $guarded = [];
}
+19
View File
@@ -0,0 +1,19 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Dokter extends Model
{
protected $table = "dokter";
protected $fillable = [
'id',
'nama',
'jk',
'tgl_lahir',
'kota',
'alamat',
'poli_id'
];
}
+35
View File
@@ -0,0 +1,35 @@
<?php
namespace App\Events;
use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
class DesaUpdated implements ShouldBroadcast
{
use Dispatchable, InteractsWithSockets, SerializesModels;
public $message;
public function __construct($message)
{
$this->message = $message;
}
/**
* Get the channels the event should broadcast on.
*
* @return array<int, \Illuminate\Broadcasting\Channel>
*/
public function broadcastOn(): array
{
return ['my-channel'];
}
public function broadcastAs() {
return 'my-event';
}
}
+31
View File
@@ -0,0 +1,31 @@
<?php
namespace App\Exceptions;
use Illuminate\Support\Facades\Log;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Throwable;
class Handler extends ExceptionHandler
{
/**
* The list of the inputs that are never flashed to the session on validation exceptions.
*
* @var array<int, string>
*/
protected $dontFlash = [
'current_password',
'password',
'password_confirmation',
];
/**
* Register the exception handling callbacks for the application.
*/
public function register(): void
{
$this->reportable(function (Throwable $e) {
//
});
}
}
+13
View File
@@ -0,0 +1,13 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Filefoto extends Model
{
protected $table = "db_file";
protected $fillable = [
'nofoto','namafile','jenisfile','judul'
];
}
+13
View File
@@ -0,0 +1,13 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Filetemp extends Model
{
protected $table = "temp";
protected $fillable = [
'tanggal', 'nomor', 'nama', 'usia', 'l', 'p', 'foto', 'ruang', 'keterangan', 'poli', 'jkn', 'umum', 'tag', 'gcu', 'cito', 'daftar', 'status'
];
}
@@ -0,0 +1,139 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\User;
use App\Pegawai;
use App\Periksa;
use App\ResultSample;
use Session;
use Auth;
use Validator;
class AuthController extends Controller
{
public function login() {
$data = [];
$previlage = Session('previlage');
if ($previlage == '' OR $previlage === null) {
$getdomain = url()->current();
$data['getdomain'] = $getdomain;
return view('login', $data);
} else {
return redirect('/');
}
}
public function authenticate(Request $request) {
$validator = Validator::make($request->all(), [
'username' => 'required',
'password' => 'required',
]);
if($validator->fails()) {
Session::flash('message', 'Username dan Password Harus diisi');
return back();
} else {
$username = $request->username;
$password = $request->password;
$firebaseid = $request->firebaseid;
if (is_null($firebaseid)){ $firebaseid = ''; }
$auth = Auth::attempt([
'username' => $username,
'password' => $password
]);
if(!$auth) {
$cekada = User::whereNotNull('username')->count();
if ($cekada == 0){
User::create([
'nama' => 'Administrator',
'username' => 'admin',
'password' => bcrypt('semangat'),
'previlage' => 'developer'
]);
}
Session::flash('message', 'Username atau password anda salah');
return back();
}
$user = Auth::user();
$photo = $user->getPhoto->xfile ?? '/doctor.png';
if ($firebaseid != ''){
User::where('username', $request->username)->update([
'firebase' => $firebaseid
]);
}
Session::put('id', $user->id);
Session::put('nama', $user->nama);
Session::put('username', $user->username);
Session::put('previlage', $user->previlage);
Session::put('photo', $photo);
Session::save();
User::where('id', $user->id)->update([
'active_status' => 1,
]);
return redirect('/');
}
}
public function cekandroid($firebaseid){
$cekperiksa = Periksa::all();
if (!empty($cekperiksa)){
$tahun = date('y');
$getdata = ResultSample::where('accession_number', 'LIKE', $tahun.'.%')->get();
foreach($getdata as $rows){
$norm = $rows->patient_id;
$nama2 = $rows->patient_name_last;
$nama1 = $rows->patient_name_first;
$nama = $nama1.' '.$nama2;
$alamat = $rows->address_street;
$nofoto = $rows->accession_number;
Pasien::updateOrCreate(
[
'norm' => $norm,
],
[
'nama' => $nama,
'jk' => $jk,
'tgl_lahir' => $tgllahir,
'kota' => config('global.subdomainapps'),
'telpon' => $telpon,
'alamat' => $alamat,
'nik' => $nik,
'bpjs' => $bpjs,
]
);
}
}
$cekuser = User::where('firebase', $firebaseid)->count();
if ($cekuser != 0){
$user = User::where('firebase', $firebaseid)->first();
$photo = $user->getPhoto->xfile ?? '/doctor.png';
Session::put('id', $user->id);
Session::put('nama', $user->nama);
Session::put('username', $user->username);
Session::put('previlage', $user->previlage);
Session::put('photo', $photo);
Session::save();
User::where('id', $user->id)->update([
'active_status' => 1,
]);
return redirect('/');
} else {
Session::flash('message', 'Firebase ID Not Saved, Please Login');
Session::flash('status', $firebaseid);
return redirect('/login');
}
}
public function logout(Request $request) {
Auth::logout();
$request->session()->regenerate();
$request->session()->flush();
session()->flush();
return redirect('/');
}
}
File diff suppressed because it is too large Load diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,264 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use App\Poli;
use App\Periksa;
use App\Dokter;
use App\Ruangan;
use App\Subjawaban;
use App\Jawaban;
use App\Pasien;
use App\User;
use App\Jadwalperiksa;
use Carbon\Carbon;
use DateTime;
use Session;
class ListController extends Controller
{
public function index() {
if (Session::get('previlage') == ''){
return redirect('/login');
} else {
$polis = Poli::all();
$ruangans = Ruangan::all();
$dokters = Dokter::all();
$answers = Jawaban::all();
$details = Subjawaban::all();
$ruangpolis = Ruangan::groupBy('poli')->select('poli')->get();
$data = [];
$i = 0;
foreach ($ruangpolis as $ruangpoli) {
$j = 0;
$ruangpoli = $ruangpoli->poli;
$rooms = Ruangan::where('poli', $ruangpoli)->get();
foreach ($rooms as $room) {
$data['ruangans'][$i][$j]['id'] = $room->id;
$data['ruangans'][$i][$j]['ruangan'] = $room->ruangan;
$j++;
}
$i++;
}
$x = 0;
foreach ($ruangpolis as $ruangpoli) {
$data['ruangpolis'][$x] = $ruangpoli->poli;
$x++;
}
$data['polis'] = $polis;
$data['dokters'] = $dokters;
$data['answers'] = $answers;
$data['details'] = $details;
return view('admin.list', $data);
}
}
public function getList(Request $request) {
$jenis = $request->input('jenis');
$mulai = $request->input('mulai');
$akhir = $request->input('akhir');
$lokasi = $request->input('poli');
$valcari = $request->input('valcari');
$master = $request->input('master');
if ($jenis == 'verificationppds'){
$valcari = $request->input('poli');
}
$total = 0;
$data = $this->getDataBasedOnMaster($master, $jenis, $mulai, $akhir, $valcari);
if (!empty($data)){
$dataArray = $data->get()->toArray();
$total = count($dataArray);
$arraylist = array_map(function ($list) use ($master) {
$tgl = $list['tgllahirpasien'];
$poli_id = $list['poli_id'];
$foto = $list['foto'];
$baca = $list['baca'];
$export = $list['export'];
$nofoto = $list['nofoto'];
$noregister = $list['noregister'];
$usia = $list['usia'];
$urgensi = $list['urgensi'];
$reques = $list['reques'];
$ruangan = $list['ruangan'];
$daftar = $list['daftar'];
$status = $list['status'];
$asalpasien = $list['asalpasien'];
$dokter_id = $list['dokter_id'];
$ppdssenior = $list['ppdssenior'];
$middleppds = $list['middleppds'];
$ppdsjunior = $list['ppdsjunior'];
$middleppds2= $list['ppdsmiddle2'];
$ppdsjunior2= $list['ppdsjunior2'];
$pasiedin = $list['pasien_id'];
$keterangan = $list['keterangan'];
$kesimpulan = $list['kesimpulan'];
$verifikasi = $list['verifikasi'];
$nama = $list['nmpasien'];
$jk = $list['jkpasien'];
$telpon = $list['tlppasien'];
$alamat = $list['alamatpasien'];
$tgllahir = $list['tgllahirpasien'];
$ktp = $list['ktp'];
$bpjs = $list['bpjs'];
$nmpendaftar= $list['pendaftar'];
if ($nmpendaftar == 'supervisor' OR $nmpendaftar == 'admin' OR $nmpendaftar == 'analis' OR $nmpendaftar == 'ppds' OR $nmpendaftar == 'developer'){
$nmpendaftar = $list['nmpendaftar'];
} else {
$nmpendaftar = 'SIMRS';
}
$from = $verifikasi ? \Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $verifikasi) : null;
$to = $verifikasi ? \Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $verifikasi)->toString() : '';
if ($from && $from->isValid()) {
$durasi = $verifikasi ? \Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $verifikasi)->diffForHumans($from) : 'On Progress';
} else {
$durasi = 'On Progress';
}
if ($middleppds2 != 0){
$ppdsas = 'Middle';
$otherppds = $list['nmppdsmiddle2'];
} else {
$ppdsas = 'Junior';
$otherppds = $ppdsjunior2;
$otherppds = $list['nmppdsjunior2'];
}
$arrdaftar = explode(" ", $daftar);
$tgldaftar = $arrdaftar[0];
$jamdaftar = $arrdaftar[1];
$daftar = $tgldaftar;
$tglfoto = $foto ?: date("Y-m-d H:i:s");
$datatampilan = $this->setStatusStyles($status, $nofoto, $noregister, $nama, $telpon, $jk, $usia, $urgensi, $reques, $ruangan, $daftar, $asalpasien);
return [
'asalpasien' => $list['asalpasien'],
'tlsnofoto' => $datatampilan['nofoto'],
'tlsnoregister' => $datatampilan['noregister'],
'tlsnama' => $datatampilan['nama'],
'tlsjk' => $datatampilan['jk'],
'tlsusia' => $datatampilan['usia'],
'tlsurgensi' => ($list['urgensi'] == 'CITO') ? '<span style="background-color: red;">C I T O</span>' : $datatampilan['urgensi'],
'tlsreques' => $datatampilan['reques'],
'tlsruangan' => $list['ruangan'],
'tlsdaftar' => $datatampilan['daftar'],
'tlsstatus' => $datatampilan['status'],
'id' => $list['id'],
'nofoto' => $nofoto,
'noregister' => $noregister,
'nama' => $nama,
'jk' => $jk,
'usia' => $usia,
'urgensi' => $urgensi,
'poli' => $reques,
'idpasien' => $pasiedin,
'ruangan' => $ruangan,
'daftar' => $list['daftar'],
'daftartgl' => $daftar,
'daftarjam' => $jamdaftar,
'status' => $status,
'dokter' => $master != 'kiriman' ? $list['nmdokter'] : '',
'ppds1' => $master != 'kiriman' ? $list['nmppdssenior'] : '',
'ppds2' => $master != 'kiriman' ? $list['nmmiddleppds'] : '',
'ppds3' => $master != 'kiriman' ? $list['nmppdsjunior'] : '',
'keterangan' => $keterangan,
'kesimpulan' => $kesimpulan,
'noloket' => $list['noloket'],
'idruangan' => $list['ruangan_id'],
'iddokter' => $list['dokter_id'],
'ppdssenior' => $list['ppdssenior'],
'middleppds' => $list['middleppds'],
'ppdsjunior' => $list['ppdsjunior'],
'diagnosa' => $list['diagnosa'],
'diagnosa2' => $list['diagnosa2'],
'kd_spesimen' => $list['kd_spesimen'],
'nm_spesimen' => $list['nm_spesimen'],
'berat' => $list['berat'],
'klinis' => $list['klinis'],
'klinisi' => $list['klinisi'],
'filefoto' => $list['filefoto'],
'dlp' => $list['dlp'],
'analis' => $list['analis'],
'excutor' => $list['excutor'],
'modality' => $list['modality'],
'viewfoto' => $list['foto'],
'tglfoto' => $tglfoto,
'nmppdssenior' => $list['nmppdssenior'],
'nmmiddleppds' => $list['nmmiddleppds'],
'nmppdsjunior' => $list['nmppdsjunior'],
'nmppdsmiddle2' => $list['nmppdsmiddle2'],
'nmppdsjunior2' => $list['nmppdsjunior2'],
'nmanalis' => $list['nmanalis'],
'nmexcutor' => $list['nmexcutor'],
'telpon' => $list['tlppasien'],
'asuransi' => $list['asuransi'],
'tgllahir' => $list['tgllahirpasien'],
'alamat' => $list['alamatpasien'],
'poli_id' => $list['poli_id'],
'nmpendaftar' => $nmpendaftar,
'timestamp1' => $from ? $from->toString() : null,
'timestamp2' => $to,
'durasi' => $durasi,
'ppdsas' => $ppdsas,
'otherppds' => $otherppds,
'ktp' => $ktp,
'bpjs' => $bpjs,
];
}, $dataArray);
}
$response = [
'message' => 'List Laporan',
'data' => $arraylist,
'total' => $total
];
return response()->json($response, 200);
}
public function listDetail(Request $request) {
$id = $request->input('id');
$periksa = DB::table('periksa')->where('id', $id)->first();
echo json_encode($periksa);
}
public function delete(Request $request) {
$id = $request->input('val01');
$alasan = $request->input('val02');
$tabel = $request->input('val03');
if ($alasan == ''){
return response()->json(['icon' => 'error', 'warna' => '#bf441d', 'status' => 'Gagal', 'message' => 'Mohon isi semua form']);
return back();
} else {
if ($tabel == 'aktif'){
$alasan = 'Dibatalkan dengan alasan '.$alasan;
$input = Periksa::where('id', $id)->update([
'noloket' => null,
'status' => $alasan
]);
$pesan = 'Order Expertise Canceled';
} else if ($tabel == 'arsip'){
$total = 0;
$input = Periksa::whereIn('id', $id)->update([
'status'=> 'Arsip'
]);
if ($input){
$total++;
}
$pesan = 'Expertise Archieved '.$total;
} else {
$alasan = 'Dibatalkan dengan alasan '.$alasan;
$input = Jadwalperiksa::where('id', $id)->update([
'noloket' => null,
'status' => $alasan
]);
$pesan = 'Schedulling Canceled';
}
if ($input){
return response()->json(['icon' => 'success', 'warna' => '#5ba035', 'status' => 'Sukses', 'message' => $pesan]);
return back();
}else {
return response()->json(['icon' => 'error', 'warna' => '#bf441d', 'status' => 'Gagal', 'message' => 'System Down, please try again in a few years...']);
return back();
}
}
}
}
File diff suppressed because it is too large Load diff
@@ -0,0 +1,225 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use App\Filetemp;
use App\User;
use App\Periksa;
use App\Pasien;
use GuzzleHttp\Client;
use Validator;
use DateTime;
use Carbon\Carbon;
use Session;
class PasienController extends Controller
{
public function index() {
if (Session::get('previlage') == ''){
return redirect('/login');
} else {
$data = [];
return view('admin.pasien', $data);
}
}
public function store(Request $request) {
$validator = Validator::make($request->all(), [
'nama' => 'required',
'jk' => 'required',
'tgl_lahir' => 'required',
'kota' => 'required',
'alamat' => 'required',
'telpon' => 'required'
]);
$old_date = $request->input('tgl_lahir');
$date = date("Y-m-d", strtotime($old_date));
if($validator->fails()) {
return response()->json(['status' => 'error', 'message' => 'Please fill input field or fill with right input']);
} else {
$norm = $request->input('norm');
$norm = strtoupper($norm);
Pasien::create([
'norm' => $norm,
'nama' => $request->input('nama'),
'jk' => $request->input('jk'),
'tgl_lahir' => $date,
'telpon' => $request->input('telpon'),
'kota' => $request->input('kota'),
'alamat' => $request->input('alamat')
]);
Session::flash('message', 'Data berhasil disimpan');
Session::flash('alert-class', 'alert-success');
return back();
}
}
public function getPasien(Request $request) {
$id = $request->input('id');
$result = DB::table('pasien')->where('id', $id)->first();
$tgllahir = $result->tgl_lahir;
$arrtgl = explode('-', $tgllahir);
$yy = $arrtgl[0];
$mm = $arrtgl[1];
$dd = $arrtgl[2];
$tgllahir = $dd.'-'.$mm.'-'.$yy;
$arrayfnk[] = array(
'telpon' => $result->telpon,
'nama' => $result->nama,
'tgl_lahir' => $result->tgl_lahir,
'alamat' => $result->alamat,
'id' => $result->id,
'norm' => $result->norm,
'jk' => $result->jk,
'kota' => $result->kota,
'nik' => $result->nik,
'bpjs' => $result->bpjs,
);
echo json_encode($arrayfnk);
}
public function getPatienalllist(Request $request) {
$data = Pasien::all();
echo json_encode($data);
}
public function getPasienbynorm(Request $request) {
$norm = $request->input('id');
$getdatalokal = Pasien::where('norm', $norm)->first();
if (isset($getdatalokal->nama)){
$tgl_lahir = $getdatalokal->tgl_lahir;
$arrdate = explode('-', $tgl_lahir);
$yy = $arrdate[0];
$mm = $arrdate[1];
$dd = $arrdate[2];
$tgl_lahir = $dd.'-'.$mm.'-'.$yy;
return response()->json([
'id' => $getdatalokal->id,
'norm' => $getdatalokal->norm,
'telpon' => $getdatalokal->telpon,
'nama' => $getdatalokal->nama,
'tgl_lahir' => $getdatalokal->tgl_lahir,
'jk' => $getdatalokal->jk,
'alamat' => $getdatalokal->alamat,
'kota' => $getdatalokal->kota,
'nik' => $getdatalokal->nik,
'bpjs' => $getdatalokal->bpjs,
]);
} else {
try {
$client = new Client();
$res = $client->request('GET', 'http://10.10.123.51:8000/mr/'.$norm);
$response_data = json_decode($res->getBody()->getContents());
if (isset($response_data[0])) {
$hasil = $response_data[0];
$nama = $hasil->Nama;
$alamat = $hasil->Alamat;
$telpon = $hasil->Telp;
$kota = $hasil->Kota;
$kelamin = $hasil->JenisKelamin;
$tgllahir = $hasil->tanggal_lahir;
$nik = $hasil->nik;
$bpjs = $hasil->bpjs;
if ($kelamin == 'WANITA'){
$kelamin = 'P';
} else { $kelamin = 'L'; }
return response()->json([
'id' => 'new',
'norm' => $norm,
'telpon' => $telpon,
'nama' => $nama,
'tgl_lahir' => $tgllahir,
'jk' => $kelamin,
'alamat' => $alamat,
'kota' => $kota,
'nik' => $nik,
'bpjs' => $bpjs,
]);
} else {
return response()->json([
'id' => '',
'telpon' => '000000000',
'norm' => $norm,
'nama' => '',
'tgl_lahir' => date("d-m-Y"),
'jk' => 'L',
'alamat' => 'Malang',
'kota' => 'Malang',
'nik' => '',
'bpjs' => '',
]);
}
}catch (Exception $e) {
return response()->json([
'id' => '',
'telpon' => '000000000',
'norm' => $norm,
'nama' => '',
'tgl_lahir' => date("d-m-Y"),
'jk' => 'L',
'alamat' => $e->getMessage(),
'kota' => 'Malang',
'nik' => '',
'bpjs' => '',
]);
}
}
}
public function update(Request $request) {
$validator = Validator::make($request->all(), [
'nama' => 'required',
'jk' => 'required',
'tgl_lahir' => 'required',
'kota' => 'required',
'telpon' => 'required',
'alamat' => 'required'
]);
if($validator->fails()) {
return response()->json(['status' => 'error', 'message' => 'Please fill input field or fill with right input']);
} else {
$id = $request->input('id_pasien');
$old_date = $request->input('tgl_lahir');
$date = date("Y-m-d", strtotime($old_date));
$norm = $request->input('norm');
$norm = strtoupper($norm);
$siapa = Session('nama');
$kapan = date('Y-m-d H:i:s');
$keterangan = 'Diupdate Oleh '.$siapa.' Pada '.$kapan;
try {
Pasien::updateOrCreate(
[
'norm' => $norm,
],
[
'nama' => $request->input('nama'),
'jk' => $request->input('jk'),
'tgl_lahir' => $date,
'telpon' => $request->input('telpon'),
'kota' => $request->input('kota'),
'alamat' => $request->input('alamat'),
'keterangan' => $keterangan
]
);
Session::flash('message', 'Data berhasil disimpan');
Session::flash('alert-class', 'alert-success');
return back();
} catch (\Exception $e) {
Session::flash('message', $e->getMessage());
Session::flash('alert-class', 'alert-succdangeress');
return back();
}
}
}
public function delete(Request $request) {
$id = $request->pasien_id;
$pasien = Pasien::find($id);
$hapus = $pasien->delete();
if ($hapus) {
return response()->json(['icon' => 'success', 'warna' => '#5ba035', 'status' => 'Success', 'message' => 'Data Deleted..!!!']);
return back();
} else {
return response()->json(['icon' => 'error', 'warna' => '#bf441d', 'status' => 'Error.!!', 'message' => 'System Down, please try again in a few years....']);
return back();
}
}
}
@@ -0,0 +1,576 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use App\Poli;
use App\Ruangan;
use App\Organisms;
use App\XFiles;
use App\SIMBHPJenis;
use App\SIMBHPReport;
use App\User;
use Validator;
use Session;
class PoliController extends Controller
{
public function index() {
if (Session::get('previlage') == ''){
return redirect('/login');
} else {
$data = [];
$data['polis'] = Poli::all();
$data['ruangans'] = Ruangan::all();
return view('admin.poli', $data);
}
}
public function viewGudangIndex() {
if (Session::get('previlage') == ''){
return redirect('/login');
} else {
$tasks = [];
$homebase = url("/");
$sekarang = date("Y-m-d");
$pegawais = User::select('id', 'nama', 'previlage')->orderBy('nama', 'ASC')->get();
$cdatane = SIMBHPJenis::all();
$cjenis = count($cdatane);
if ($cjenis == 0){
$tasks['jjenis'][0]['jenis'] = 'Belum Ada Jenis Barang';
$tasks['jjenis'][0]['satuan'] = '';
} else {
$i = 0;
foreach($cdatane as $rdata){
$tasks['jjenis'][$i]['jenis'] = $rdata->jenis;
$tasks['jjenis'][$i]['satuan'] = $rdata->satuan;
$i++;
}
}
$getdebet = SIMBHPReport::select(DB::raw('SUM(pemasukan) as pemasukan'))->groupBy('marking')->first();
if (isset($getdebet->pemasukan)){
$totpemasukan = $getdebet->pemasukan;
} else { $totpemasukan = 0 ;}
$getkredit = SIMBHPReport::select(DB::raw('SUM(pengeluaran) as pengeluaran'))->groupBy('marking')->first();
if (isset($getkredit->pengeluaran)){
$totpepengeluaran = $getkredit->pengeluaran;
} else { $totpepengeluaran = 0 ;}
$tasks['masuk'] = $totpemasukan;
$tasks['keluar'] = $totpepengeluaran;
$tasks['pegawai'] = $pegawais;
$tasks['tahunne'] = date("Y");
$tasks['tanggal'] = $sekarang;
$tasks['sidebar'] = 'simbhp';
$previlage = Session('previlage');
return view('admin.gudang', $tasks);
}
}
public function storePoli(Request $request) {
$validator = Validator::make($request->all(), [
'poli' => 'required',
'poli' => 'required',
'modaliti' => 'required'
]);
if($validator->fails()) {
return response()->json(['status' => 'error', 'message' => 'Please fill input field or fill with right input']);
} else {
$poli = $request->input('poli');
$subpoli = $request->input('subpoli');
$subsubpoli = $request->input('subsubpoli');
$modaliti = $request->input('modaliti');
Poli::create([
'poli' => $request->input('poli'),
'subpoli' => $request->input('subpoli'),
'subsubpoli'=> $request->input('subsubpoli'),
'modaliti' => $request->input('modaliti'),
'modaliti2' => $request->input('modaliti2')
]);
$tulis = 'Data '.$poli.' '.$subpoli.' '.$subsubpoli.' Saved..!!';
return response()->json(['status' => 'success', 'message' => $tulis]);
}
}
public function getListPoli() {
$results = Poli::orderBy('subpoli', 'ASC')->get();
echo json_encode($results);
}
public function updatePoli(Request $request) {
$validator = Validator::make($request->all(), [
'id' => 'required',
'poli' => 'required',
'subpoli' => 'required',
'modaliti' => 'required'
]);
if($validator->fails()) {
return response()->json(['status' => 'error', 'message' => 'Please fill input field or fill with right input']);
} else {
$id = $request->input('id');
$poli = $request->input('poli');
$subpoli = $request->input('subpoli');
$subsubpoli = $request->input('subsubpoli');
Poli::where('id', $id)->update([
'poli' => $poli,
'subpoli' => $subpoli,
'subsubpoli'=> $subsubpoli,
'modaliti' => $request->input('modaliti'),
'modaliti2' => $request->input('modaliti2')
]);
$tulis = 'Data '.$poli.' '.$subpoli.' '.$subsubpoli.' Updated..!!';
return response()->json(['status' => 'success', 'message' => $tulis]);
}
}
public function deletePoli(Request $request) {
$id = $request->id;
$poli = Poli::find($id);
$poli->delete();
return back();
}
public function storeRuangan(Request $request) {
$validator = Validator::make($request->all(), [
'poli' => 'required',
'ruangan' => 'required'
]);
if($validator->fails()) {
return response()->json(['status' => 'error', 'message' => 'Please fill input field or fill with right input']);
} else {
Ruangan::create([
'poli' => $request->input('poli'),
'ruangan' => $request->input('ruangan')
]);
Session::flash('message', 'Data berhasil disimpan');
Session::flash('alert-class', 'alert-success');
return back();
}
}
public function getListRuangan(Request $request) {
$results = Ruangan::all();
echo json_encode($results);
}
public function updateRuangan(Request $request) {
$validator = Validator::make($request->all(), [
'id' => 'required',
'poli' => 'required',
'ruangan' => 'required'
]);
if($validator->fails()) {
return response()->json(['status' => 'error', 'message' => 'Please fill input field or fill with right input']);
} else {
$id = $request->input('id');
Ruangan::where('id', $id)->update([
'poli' => $request->input('poli'),
'ruangan' => $request->input('ruangan')
]);
}
}
public function deleteRuangan(Request $request) {
$id = $request->id;
$ruangan = Ruangan::find($id);
$ruangan->delete();
return back();
}
public function jsonRekapbhp() {
$tahun = date("Y");
$thnlalu = $tahun - 1;
$totale = 0;
$arraysurat = [];
$getdata = SIMBHPJenis::all();
if (!empty($getdata)){
foreach($getdata as $hasil){
$jenis = $hasil->kodejenis;
$satuan = $hasil->satuan;
$tlsjenis = $hasil->jenis;;
$getdebet = SIMBHPReport::select(DB::raw('SUM(pemasukan) as pemasukan'))->where('jenis', $tlsjenis)->groupBy('jenis')->first();
if (isset($getdebet->pemasukan)){
$totpemasukan = $getdebet->pemasukan;
} else { $totpemasukan = 0 ;}
$getkredit = SIMBHPReport::select(DB::raw('SUM(pengeluaran) as pengeluaran'))->where('jenis', $tlsjenis)->groupBy('jenis')->first();
if (isset($getkredit->pengeluaran)){
$totpepengeluaran = $getkredit->pengeluaran;
} else { $totpepengeluaran = 0 ;}
$saldoakhir = $totpemasukan - $totpepengeluaran;
$arraysurat[] = array(
'id' => $hasil->id,
'satuan' => $satuan,
'jenis' => $jenis,
'tlsjenis' => $tlsjenis,
'saldo' => number_format( $saldoakhir , 0 , '.' , ',' ),
);
}
}
echo json_encode($arraysurat);
}
public function jsonReportbhp(Request $request) {
$bulan = $request->input('val01');
$tahun = $request->input('val02');
$hasil = [];
if ($tahun == 'ALL'){
$bulan = date("m");
$tahun = date("Y");
$getdata = SIMBHPReport::where('bulan', $bulan)->where('tahun', $tahun)->orderBy('id', 'DESC')->get();
} else {
if ($bulan == 'ALL'){
$getdata = SIMBHPReport::where('tahun', $tahun)->orderBy('id', 'DESC')->get();
} else {
$getdata = SIMBHPReport::where('bulan', $bulan)->where('tahun', $tahun)->orderBy('id', 'DESC')->get();
}
}
foreach($getdata as $rdata){
$dd = $rdata->tanggal;
$mm = $rdata->bulan;
$yy = $rdata->tahun;
$pengeluaran= $rdata->pengeluaran;
$pemasukan = $rdata->pemasukan;
if ($mm < 10){
$tgllengkap = $dd.'-0'.$mm.'-'.$yy;
} else {
$tgllengkap = $dd.'-'.$mm.'-'.$yy;
}
if ($pengeluaran == '' OR $pengeluaran == 0) {$total = $pemasukan;}
else { $total = $pengeluaran; }
$hasil[] = array(
'id' => $rdata->id,
'tanggal' => $rdata->tanggal,
'bulan' => $rdata->bulan,
'tahun' => $rdata->tahun,
'deskripsi' => $rdata->deskripsi,
'pemasukan' => number_format( $pemasukan , 0 , '.' , ',' ),
'pengeluaran' => number_format( $pengeluaran , 0 , '.' , ',' ),
'jenis' => $rdata->jenis,
'keterangan' => $rdata->keterangan,
'tgllengkap' => $tgllengkap,
'total' => $total,
);
}
echo json_encode($hasil);
}
public function jsonReportbhpPaginated(Request $request) {
$tanggal = $request->input('tanggal');
$deskripsi = $request->input('deskripsi');
$kategori = $request->input('kategori');
$lm = 10;
$limit = ($request->input('limit') == null ? $lm : $request->input('limit'));
$order = ($request->input('order') == null ? 'id desc' : $request->input('order'));
$data = new SIMBHPReport;
if ($kategori != null AND $kategori != '') $data = $data->where('jenis', $kategori);
if ($tanggal != null AND $tanggal != '') $data = $data->where('created_at', 'LIKE', '%'.$tanggal.'%');
if ($deskripsi != null AND $deskripsi != '') $data = $data->where('deskripsi', 'LIKE', '%'.$deskripsi.'%');
$data = $data->orderByRaw($order)->paginate($limit);
$hasil = [];
$totaldata = $data->total();
$debet = 0;
$kredit = 0;
if (!empty($data)){
foreach($data as $rdata){
$dd = $rdata->tanggal;
$mm = $rdata->bulan;
$yy = $rdata->tahun;
$pengeluaran = $rdata->pengeluaran;
$pemasukan = $rdata->pemasukan;
$deskripsi = $rdata->deskripsi;
$jenis = $rdata->jenis;
$debet = $debet + $pemasukan;
$kredit = $kredit + $pengeluaran;
$cekjenis = SIMBHPJenis::where('kodejenis', $jenis)->first();
if (isset($cekjenis->id)){
$kodejenis = $cekjenis->kodejenis;
$jenis = $cekjenis->jenis;
$satuan = $cekjenis->satuan;
} else {
$kodejenis = $jenis;
$jenis = '';
$satuan = '';
}
if ($jenis != ''){
$deskripsi = '<strong>'.$jenis.'</strong><br />'.$deskripsi;
}
if ($mm < 10){
$tgllengkap = $yy.'-0'.$mm.'-'.$dd;
} else {
$tgllengkap = $yy.'-'.$mm.'-'.$dd;
}
if ($pengeluaran == '' OR $pengeluaran == 0) {
$total = $pemasukan;
$jentrans = 'PEMASUKAN';
}
else {
$total = $pengeluaran;
$jentrans = 'PENGELUARAN';
}
$hasil[] = array(
'id' => $rdata->id,
'tanggal' => $rdata->tanggal,
'bulan' => $rdata->bulan,
'tahun' => $rdata->tahun,
'tlsdeskripsi' => $deskripsi,
'deskripsi' => $rdata->deskripsi,
'pemasukan' => number_format( $pemasukan , 0 , '.' , ',' ),
'pengeluaran' => number_format( $pengeluaran , 0 , '.' , ',' ),
'jenis' => $kodejenis,
'keterangan' => $rdata->keterangan,
'tgllengkap' => $tgllengkap,
'created_at' => $rdata->created_at,
'nominal' => $total.' '.$satuan,
'jentrans' => $jentrans,
);
}
}
$response = [
'message' => 'List Data',
'data' => $hasil,
'totaldata' => $totaldata
];
return response()->json($response, 200);
}
public function exAddbarang(Request $request) {
$deskripsi = $request->input('set01');
$pos = $request->input('set02');
$tanggal = $request->input('set03');
$jumlah = $request->input('set04');
$jenis = $request->input('set05');
$postujuan = $request->input('set06');
$alasan = $request->input('set07');
$nama = Session('nama');
if ($tanggal == '' OR is_null($tanggal)){
$tanggal = date("d-m-Y");
}
$total = (int)str_replace(',','',$jumlah);
if ($jenis == 'jenis'){ $jumlah = '-';}
if ($deskripsi != '' and $pos != '' and $tanggal != '' and $jumlah != '' and $jenis != ''){
if ($jenis == 'jenis'){
$jenis = $request->input('set02');
$satuan = $request->input('set03');
$idne = $request->input('set04');
$kodejenis = preg_replace('/\s+/', '', $jenis);
if ($idne == 'new' OR $idne == ''){
$ceksudah = SIMBHPJenis::where('kodejenis', $kodejenis)->where('satuan', $satuan)->count();
if ($ceksudah != 0){
return response()->json(['icon' => 'error', 'warna' => '#bf441d', 'status' => 'Gagal', 'message' => $jenis.' Sudah Ada, Silahkan Masukkan Jenis Barang Lain']);
return back();
} else {
$input = SIMBHPJenis::create([
'kodejenis' => $kodejenis,
'jenis' => $jenis,
'satuan' => $satuan,
]);
if ($input){
return response()->json(['status' => 'Success', 'message' => 'Data '.$jenis.' Sukses Ditambahkan']);
return back();
} else {
return response()->json(['icon' => 'error', 'warna' => '#bf441d', 'status' => 'Gagal', 'message' => $jenis.' Gagal di masukkan, silahkan ulangi beberapa saat lagi']);
return back();
}
}
} else {
$ceksudah = SIMBHPJenis::where('id', '!=', $idne)->where('kodejenis', $kodejenis)->where('satuan', $satuan)->count();
if ($ceksudah != 0){
return response()->json(['icon' => 'error', 'warna' => '#bf441d', 'status' => 'Gagal', 'message' => $jenis.' Sudah Ada, Silahkan Masukkan Jenis Barang Lain']);
return back();
} else {
$input = SIMBHPJenis::where('id', $idne)->update([
'kodejenis' => $kodejenis,
'jenis' => $jenis,
'satuan' => $satuan,
]);
if ($input){
return response()->json(['status' => 'Success', 'message' => 'Data '.$jenis.' Sukses Diupdate']);
return back();
} else {
return response()->json(['icon' => 'error', 'warna' => '#bf441d', 'status' => 'Gagal', 'message' => $jenis.' Gagal di masukkan, silahkan ulangi beberapa saat lagi']);
return back();
}
}
}
} else {
$ahrf = explode("-", $tanggal);
$tahun = $ahrf[0];
if(isset($ahrf[1])){
$wulan = (int)$ahrf[1];
} else { $wulan = date("m"); $wulan = (int)$wulan; }
if(isset($ahrf[2])){
$dino = (int)$ahrf[2];
} else { $dino = date("d"); }
if ($jenis == 'pemasukan'){
$bayar = SIMBHPReport::create([
'tanggal' => $dino,
'bulan' => $wulan,
'tahun' => $tahun,
'deskripsi' => $deskripsi,
'pemasukan' => $total,
'pengeluaran' => null,
'jenis' => $pos,
'keterangan' => '',
'marking' => '',
]);
} else if ($jenis == 'pengeluaran'){
$getnama = User::where('id', $deskripsi)->first();
$nama = $getnama->nama ?? 'Unkown';
$deskripsi = 'Diterima oleh '.$nama;
$getdebet = SIMBHPReport::select(DB::raw('SUM(pemasukan) as pemasukan'))->where('jenis', $pos)->groupBy('jenis')->first();
if (isset($getdebet->pemasukan)){
$totpemasukan = $getdebet->pemasukan;
} else { $totpemasukan = 0 ;}
$getkredit = SIMBHPReport::select(DB::raw('SUM(pengeluaran) as pengeluaran'))->where('jenis', $pos)->groupBy('jenis')->first();
if (isset($getkredit->pengeluaran)){
$totpepengeluaran = $getkredit->pengeluaran;
} else { $totpepengeluaran = 0 ;}
$totpepengeluaran = $totpepengeluaran + $total;
if ($totpepengeluaran > $totpemasukan){
return response()->json(['icon' => 'error', 'warna' => '#bf441d', 'status' => 'Gagal', 'message' => 'Nominal Melebihi Stok']);
return back();
} else {
$bayar = SIMBHPReport::create([
'tanggal' => $dino,
'bulan' => $wulan,
'tahun' => $tahun,
'deskripsi' => $deskripsi,
'pemasukan' => null,
'pengeluaran' => $total,
'jenis' => $pos,
'keterangan' => '',
'marking' => '',
]);
}
} else if ($jenis == 'editor'){
if ($alasan == ''){
return response()->json(['icon' => 'error', 'warna' => '#bf441d', 'status' => 'Gagal', 'message' => 'Alasan Perubahan Data Wajib Di Isi!!!']);
return back();
} else {
$getdebet = SIMBHPReport::select(DB::raw('SUM(pemasukan) as pemasukan'))->where('jenis', $pos)->groupBy('jenis')->first();
if (isset($getdebet->pemasukan)){
$totpemasukan = $getdebet->pemasukan;
} else { $totpemasukan = 0 ;}
$getkredit = SIMBHPReport::select(DB::raw('SUM(pengeluaran) as pengeluaran'))->where('jenis', $pos)->groupBy('jenis')->first();
if (isset($getkredit->pengeluaran)){
$totpepengeluaran = $getkredit->pengeluaran;
} else { $totpepengeluaran = 0 ;}
$totpepengeluaran = $totpepengeluaran + $total;
$rdatalama = SIMBHPReport::where('id', $postujuan)->first();
$ldeskripsi = $rdatalama->deskripsi;
$lpemasukan = $rdatalama->pemasukan;
$lpengeluaran = $rdatalama->pengeluaran;
$ljenis = $rdatalama->jenis;
$marking = $rdatalama->marking;
if ($lpengeluaran == '' OR $lpengeluaran == 0) {
$ltotal = number_format( $lpemasukan , 0 , '.' , ',' );
if ($marking != ''){
SIMBHPReport::where('marking', $marking)->whereNotIn('id', [$postujuan])->update([
'tanggal' => $dino,
'bulan' => $wulan,
'tahun' => $tahun,
'pengeluaran' => $total
]);
}
$bayar = SIMBHPReport::where('id', $postujuan)->update([
'tanggal' => $dino,
'bulan' => $wulan,
'tahun' => $tahun,
'deskripsi' => $deskripsi,
'jenis' => $pos,
'pemasukan' => $total,
'keterangan' => $alasan,
'updated_at' => date("Y-m-d H:i:s")
]);
} else {
$totpepengeluaran = $totpepengeluaran + $total;
if ($totpepengeluaran > $totpemasukan){
return response()->json(['icon' => 'error', 'warna' => '#bf441d', 'status' => 'Gagal', 'message' => 'Nominal Melebihi Stok']);
return back();
} else {
$ltotal = number_format( $lpengeluaran , 0 , '.' , ',' );
if ($marking != ''){
SIMBHPReport::where('marking', $marking)->whereNotIn('id', [$postujuan])->update([
'tanggal' => $dino,
'bulan' => $wulan,
'tahun' => $tahun,
'pemasukan' => $total
]);
}
$bayar = SIMBHPReport::where('id', $postujuan)->update([
'tanggal' => $dino,
'bulan' => $wulan,
'tahun' => $tahun,
'deskripsi' => $deskripsi,
'jenis' => $pos,
'pengeluaran' => $total,
'keterangan' => $alasan,
'updated_at' => date("Y-m-d H:i:s")
]);
}
}
$baris1 = '<table class="table table-bordered table-striped"><tr><td colspan=2><p align=center><b>Data Lama</b></p></td><td colspan=2><p align=center><b>Data Perubahan</b></p></td></tr>';
$baris2 = '<tr><td>Deskripsi</td><td>'.$ldeskripsi.'</td><td><font color=red>Diubah Menjadi</font></td><td>'.$deskripsi.'</td></tr>';
$baris3 = '<tr><td>Jenis</td><td>'.$ljenis.'</td><td><font color=red>Diubah Menjadi</font></td><td>'.$pos.'</td></tr>';
$baris4 = '<tr><td>Total</td><td>'.$ltotal.'</td><td><font color=red>Diubah Menjadi</font></td><td>'.$jumlah.'</td></tr>';
$baris5 = '<tr><td><b>Dengan Alasan</b></td><td colspan=3>'.$alasan.'</td</tr>';
$baris6 = '<tr><td><b>Eksekutor</b></td><td colspan=3>'.Session('nama').'</td</tr></table>';
$perubahan = $baris1.$baris2.$baris3.$baris4.$baris5.$baris6;
Xfiles::create([
'xmarking' => 'SIMBHP-'.$postujuan.'-'.time(),
'xtabel' => 'History SIMBHP',
'xjenis' => '',
'xfile' => $perubahan
]);
}
} else {
if ($alasan == ''){
return response()->json(['icon' => 'error', 'warna' => '#bf441d', 'status' => 'Gagal', 'message' => 'Alasan Perubahan Data Wajib Di Isi!!!']);
return back();
}
else {
$rdatalama = SIMBHPReport::where('id', $postujuan)->first();
$ldeskripsi = $rdatalama->deskripsi;
$lpemasukan = $rdatalama->pemasukan;
$lpengeluaran = $rdatalama->pengeluaran;
$ljenis = $rdatalama->jenis;
$marking = $rdatalama->marking;
if ($lpengeluaran == '' or $lpengeluaran == 0) {
$ltotal = number_format( $lpemasukan , 0 , '.' , ',' );
} else {
$ltotal = number_format( $lpengeluaran , 0 , '.' , ',' );
}
$baris1 = '<table class="table table-bordered table-striped"><tr><td colspan=2><p align=center><b>Data Lama</b></p></td><td colspan=2><p align=center><b>Data Perubahan</b></p></td></tr>';
$baris2 = '<tr><td>Deskripsi</td><td>'.$ldeskripsi.'</td><td colspan=2><font color=red>DIHAPUS</font></td></tr>';
$baris3 = '<tr><td>Jenis</td><td>'.$ljenis.'</td><td colspan=2><font color=red>DIHAPUS</font></td></tr>';
$baris4 = '<tr><td>Total</td><td>'.$ltotal.'</td><td colspan=2><font color=red>DIHAPUS</font></td></tr>';
$baris5 = '<tr><td><b>Dengan Alasan</b></td><td colspan=3>'.$alasan.'</td</tr>';
$baris6 = '<tr><td><b>Eksekutor</b></td><td colspan=3>'.Session('nama').'</td</tr></table>';
$perubahan = $baris1.$baris2.$baris3.$baris4.$baris5.$baris6;
Xfiles::create([
'xmarking' => 'SIMBHP-'.$postujuan.'-'.time(),
'xtabel' => 'History SIMBHP',
'xjenis' => '',
'xfile' => $perubahan
]);
if ($marking != ''){
$bayar = SIMBHPReport::where('marking', $marking)->delete();
} else {
$bayar = SIMBHPReport::where('id', $postujuan)->delete();
}
}
}
if ($bayar){
return response()->json(['status' => 'Success', 'message' => 'Transaksi '.$jenis.' Sukses Dilaksanakan']);
return back();
} else {
return response()->json(['icon' => 'error', 'warna' => '#bf441d', 'status' => 'Gagal', 'message' => 'Update Gagal, Pastikan Data Yang anda Isi Sudah Sesuai']);
return back();
}
}
}
else {
return response()->json(['icon' => 'error', 'warna' => '#bf441d', 'status' => 'Gagal', 'message' => 'Pastikan Formnya Anda Isi dengan Lengkap']);
return back();
}
}
}
@@ -0,0 +1,446 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use App\Poli;
use App\Logbook;
use App\User;
use App\Periksa;
use App\Dokter;
use App\Pasien;
use App\Jadwalperiksa;
use App\Riwayat;
use App\RekapAntibiotik;
use DateTime;
use Carbon\Carbon;
use Session;
class ReportController extends Controller
{
public function index() {
if (Session::get('previlage') == ''){
return redirect('/login');
} else {
return view('admin.report');
}
}
public function rekapPeriksa(Request $request) {
set_time_limit(0);
$bulan = $request->input('bulan');
$tahun = $request->input('tahun');
if ($bulan == 'ALL' OR $bulan == 'Pick Month') {
$orderbydate = Periksa::selectRaw('SUM(id) as jumlah, DATE(daftar) as day')->whereYear('daftar', $tahun)->groupBy(DB::raw('daftar'))->orderBy('daftar', 'ASC')->get();
$bulan = '';
} else {
$tglcari = $tahun . '-' . str_pad($bulan, 2, '0', STR_PAD_LEFT);
$orderbydate = Periksa::selectRaw('SUM(id) as jumlah, DATE(daftar) as day')->where('day', 'LIKE', '%' . $tglcari . '%')->groupBy(DB::raw('daftar'))->orderBy('daftar', 'ASC')->get();
$bulanNames = [
'01' => 'BULAN JANUARI',
'02' => 'BULAN FEBRUARI',
'03' => 'BULAN MARET',
'04' => 'BULAN APRIL',
'05' => 'BULAN MEI',
'06' => 'BULAN JUNI',
'07' => 'BULAN JULI',
'08' => 'BULAN AGUSTUS',
'09' => 'BULAN SEPTEMBER',
'10' => 'BULAN OKTOBER',
'11' => 'BULAN NOVEMBER',
'12' => 'BULAN DESEMBER',
];
$bulan = $bulanNames[$bulan] ?? $bulan;
}
$data = [];
$data['bulan'] = $bulan;
$data['tahun'] = $tahun;
$data['orderbydate']= $orderbydate;
$generatetabel = view('cetak.rekap_periksa_table', $data)->render();
echo $generatetabel;
}
protected static function getPasienData($result) {
return [
'nama' => $result->nmpasien,
'tgl' => $result->tgllahirpasien,
'jk' => $result->jkpasien,
];
}
protected static function updateTotals($totals, $asuransi, $urgensi, $jk) {
if ($jk == 'L') {
$totals['m']++;
} else {
$totals['f']++;
}
if ($asuransi == 'JKN') {
$totals['jkn']++;
} elseif ($asuransi == 'Umum') {
$totals['umum']++;
} elseif ($asuransi == 'TAG') {
$totals['tag']++;
} elseif ($asuransi == 'GCU') {
$totals['gcu']++;
} elseif ($asuransi == 'Billing') {
$totals['bill']++;
} else {
$totals['swasta']++;
}
if ($urgensi == 'Elective') {
$totals['electiv']++;
} else {
$totals['cito']++;
}
return $totals;
}
protected static function mapResultToArray($result) {
$nmpasien = $result->nmpasien;
$tgl = $result->tgllahirpasien;
$jk = $result->jkpasien;
$jenis = $result->reques;
$tlppasien = $result->tlppasien;
$nofoto = $result->nofoto;
$verifikasi = $result->verifikasi;
$tanggal = $result->daftar;
$tanggalfoto = $result->foto;
$asuransi = $result->asuransi;
$urgensi = $result->urgensi;
$from = \Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $result->daftar);
if (is_null($verifikasi)){
$verifikasi = '';
$to = '';
$durasi = 'On Progress';
} else {
$to = \Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $verifikasi);
$durasi = $to->diffForHumans($from);
}
$arrayttllhr = explode("-", $tgl);
if (isset($arrayttllhr[2])){
$yy = $arrayttllhr[0];
$mm = $arrayttllhr[1];
$dd = $arrayttllhr[2];
$tgllahir = $dd.'-'.$mm.'-'.$yy;
} else { $tgllahir = $tgl; }
$arrayttl = explode(" ", $tanggal);
$tanggal = $arrayttl[0];
if ($jk == 'L') {
$l = '1';
$p = '';
} else {
$l = '';
$p = '1';
}
if ($asuransi == 'JKN') {
$jkn = '1';
$umm = '';
$swasta = '';
$gcu = '';
$tag = '';
$bill = '';
} else if ($asuransi == 'Umum') {
$jkn = '';
$umm = '1';
$swasta = '';
$gcu = '';
$tag = '';
$bill = '';
} else if ($asuransi == 'TAG') {
$jkn = '';
$umm = '';
$swasta = '';
$gcu = '';
$bill = '';
$tag = '1';
} else if ($asuransi == 'GCU') {
$jkn = '';
$umm = '';
$swasta = '';
$gcu = '1';
$tag = '';
$bill = '';
} else if ($asuransi == 'Billing') {
$jkn = '';
$umm = '';
$swasta = '';
$gcu = '';
$bill = '1';
$tag = '';
} else {
$jkn = '';
$umm = '';
$swasta = '1';
$gcu = '';
$tag = '';
$bill = '';
}
if ($urgensi == 'Elective') {
$ele = '1';
$cito = '';
} else {
$ele = '';
$cito = '1';
}
$getjennofoto = explode("-", $nofoto);
$jenis = $getjennofoto[0].' '.$jenis;
return [
'id' => $result->id,
'filefoto' => '<a href="' . url('/') . '/hasil/' . $result->nofoto . '" target="_blank">' . $result->nofoto . '</a>',
'l' => $l,
'p' => $p,
'jenis' => $jenis,
'jkn' => $jkn,
'umm' => $umm,
'gcu' => $gcu,
'tag' => $tag,
'swasta' => $swasta,
'billing' => $bill,
'ele' => $ele,
'cito' => $cito,
'asuransi' => $asuransi,
'nofoto' => $result->nofoto,
'noregister' => $result->noregister,
'nmpasien' => $nmpasien,
'usia' => $result->usia,
'kesimpulan' => $result->kesimpulan,
'ruangan' => $result->ruangan,
'daftar' => $result->daftar,
'created_at' => $result->created_at,
'nmdokter' => $result->nmdokter,
'nmppdssenior' => $result->nmppdssenior,
'nmmiddleppds' => $result->nmmiddleppds,
'nmppdsjunior' => $result->nmppdsjunior,
'nmppdsmiddle2' => $result->nmppdsmiddle2,
'nmppdsjunior2' => $result->nmppdsjunior2,
'diagnosa2' => $result->diagnosa2,
'nmanalis' => $result->nmanalis,
'nmexcutor' => $result->nmexcutor,
'alamatpasien' => $result->alamatpasien,
'tgllahirpasien'=> $tgl,
'jkpasien' => $jk,
'tlppasien' => $tlppasien,
'modality' => $result->modality,
'dlp' => $result->dlp,
'kd_spesimen' => $result->kd_spesimen,
'nm_spesimen' => $result->nm_spesimen,
'status' => $result->status,
'asalpasien' => $result->asalpasien,
'nmrs' => $result->nmrs,
'berat' => $result->berat,
'klinisi' => $result->klinisi,
'klinis' => $result->klinis,
'telpon' => $tlppasien,
'verifikasi' => $result->verifikasi,
'noloket' => $result->noloket,
'foto' => $result->foto,
'export' => $result->export,
'nmdrafter' => $result->nmdrafter,
'tgldraft' => $result->tgldraft,
'baca' => $result->baca,
'nmpembaca' => $result->nmpembaca,
'tgladendum' => $result->tgladendum,
'nmadendum' => $result->nmadendum,
'durasi' => $durasi,
];
}
protected static function getTotalRow($totals) {
return [
'id' => '',
'filefoto' => '',
'noregister'=> '',
'nama' => '<strong>Total</strong>',
'l' => $totals['m'],
'p' => $totals['f'],
'jkn' => $totals['jkn'],
'umm' => $totals['umum'],
'gcu' => $totals['gcu'],
'tag' => $totals['tag'],
'swasta' => $totals['swasta'],
'billing' => $totals['bill'],
'ele' => $totals['electiv'],
'cito' => $totals['cito'],
];
}
public function report(Request $request) {
$bulan = $request->input('bulan');
$tahun = $request->input('tahun');
$homebase = url("/");
$arraylist = [];
$limit = $request->input('limit') ?? 500;
$page = $request->input('pagenum') ?? 1;
$order = $request->input('order') ?? 'id desc';
$filterscount = $request->input('filterscount') ?? 0;
if ($bulan === 'pertanggal' || $bulan === 'terjadwal') {
$results = DB::table($bulan === 'terjadwal' ? 'jadwalperiksan' : 'periksa')->when($bulan === 'terjadwal', function ($query) use ($tahun) {
return $query->whereNull('jadwalperiksan.status')
->where('jadwalperiksan.daftar', 'LIKE', "%$tahun%");
}, function ($query) use ($tahun) {
return $query->where('periksa.daftar', 'LIKE', "$tahun%");
})->get();
$totals = ['m' => 0, 'f' => 0, 'jkn' => 0, 'umum' => 0, 'tag' => 0, 'gcu' => 0, 'bill' => 0, 'swasta' => 0, 'electiv' => 0, 'cito' => 0];
foreach ($results as $result) {
$asuransi = $result->asuransi;
$urgensi = $result->urgensi;
$totals = self::updateTotals($totals, $asuransi, $urgensi, $result->jkpasien);
$arraylist[] = self::mapResultToArray($result);
}
if ($bulan === 'pertanggal') {
$arraylist[] = self::getTotalRow($totals);
}
echo json_encode($arraylist);
} else {
if ($bulan == 'ALL' || $bulan == 'Pick Month') {
$results = DB::table('periksa')->where('daftar', 'LIKE', $tahun.'%')->get();
} else {
$tglcari = $tahun.'-'.$bulan;
$results = DB::table('periksa')->where('daftar', 'LIKE', $tglcari.'%')->get();
}
$totals = ['m' => 0, 'f' => 0, 'jkn' => 0, 'umum' => 0, 'tag' => 0, 'gcu' => 0, 'bill' => 0, 'swasta' => 0, 'electiv' => 0, 'cito' => 0];
foreach ($results as $result) {
$asuransi = $result->asuransi;
$urgensi = $result->urgensi;
$totals = self::updateTotals($totals, $asuransi, $urgensi, $result->jkpasien);
$arraylist[] = self::mapResultToArray($result);
}
$arraylist[] = self::getTotalRow($totals);
echo json_encode($arraylist);
}
}
public function genRekapAntibiotik(Request $request) {
$data = [];
$bulan = $request->input('bulan');
$tahun = $request->input('tahun');
if ($tahun == '' OR is_null($tahun)){
$getarray = explode('?', $bulan);
$bulan = $getarray[0] ?? date('m');
$tahun = $getarray[1] ?? date('Y');
$bulan = str_replace('bulan=', '', $bulan);
$tahun = str_replace('tahun=', '', $tahun);
}
if ($bulan == '' OR $bulan == 'ALL' OR $bulan == 'Pick Month') {
$orderbydate = Periksa::whereYear('daftar', $tahun)->get();
$jsonantibiotik = RekapAntibiotik::whereIn('orderid', $orderbydate->pluck('id'))->get()->groupBy('orderid');
} else {
$orderbydate = Periksa::whereMonth('daftar', $bulan)->whereYear('daftar', $tahun)->get();
$jsonantibiotik = RekapAntibiotik::whereIn('orderid', $orderbydate->pluck('id'))->get()->groupBy('orderid');
}
return view('admin.rekapantibiotik', compact('orderbydate', 'jsonantibiotik', 'bulan', 'tahun'));
}
public function genGlassReport(Request $request) {
$data = [];
$bulan = $request->input('bulan');
$tahun = $request->input('tahun');
if ($tahun == '' OR is_null($tahun)){
$getarray = explode('?', $bulan);
$bulan = $getarray[0] ?? date('m');
$tahun = $getarray[1] ?? date('Y');
$bulan = str_replace('bulan=', '', $bulan);
$tahun = str_replace('tahun=', '', $tahun);
}
if ($bulan == '' OR $bulan == 'ALL' OR $bulan == 'Pick Month') {
$orderbydate = Periksa::whereYear('daftar', $tahun)->get();
$jsonantibiotik = array(
'Oxacillin-OX',
'Cefoxitin-FOX',
'Benzylpenicillin-P',
'Ampicillin-AM',
'Azithromycin-AZM',
'Erythromycin-ERY',
'Cefazolin-CZO',
'Cefepime-FEP',
'Cefixime-CFM',
'Cefotaxime-CTX',
'Cefuroxime-CXM',
'Ceftazidime-CAZ',
'Ceftriaxone-CRO',
'Ceftazidime/Avibactam-CZA',
'Piperacilin/Tazobactam-TZP',
'Ampicillin/Sulbactam-SAM',
'Amoxicillin/Clavulanate-AMC',
'Cefoperazon/Sulbactam-SCF',
'Aztreonam-ATM',
'Ceftaroline-CPT',
'Ciprofloxacin-CIP',
'Levofloxacin-LEV',
'Moxifloxacin-MFX',
'Clindamycin-CLI',
'Colistin-CS', //tidak ada
'Tetracyclin-TCY',
'Tigecycline-TGC', //double
'Gentamicin-GM',
'Amikacin-AN',
'Meropenem-MEM',
'Imipenem-IPM',
'Doripenem-DOR',
'Ertapenem-ETP',
'Minocycline-MNO',
'Doxycycline-DOX',
'Spectinomycin-SPT',
'Tigecycline-TGC', //sama-ini
'Trimethoprim/Sulfamethoxazole-SXT',
'Fosfomycin-FOS',
'Vancomycin-VAN',
'Linezolid-LNZ',
'Fluconazole', //tidak ada
'Voriconazole', //tidak ada
'Caspofungin', //tidak ada
'Micafungin', //tidak ada
'Amphotericin B', //tidak ada
'Flucytosine' //tidak ada
);
} else {
$orderbydate = Periksa::whereMonth('daftar', $bulan)->whereYear('daftar', $tahun)->get();
$jsonantibiotik = array(
'Oxacillin-OX',
'Cefoxitin-FOX',
'Benzylpenicillin-P',
'Ampicillin-AM',
'Azithromycin-AZM',
'Erythromycin-ERY',
'Cefazolin-CZO',
'Cefepime-FEP',
'Cefixime-CFM',
'Cefotaxime-CTX',
'Cefuroxime-CXM',
'Ceftazidime-CAZ',
'Ceftriaxone-CRO',
'Ceftazidime/Avibactam-CZA',
'Piperacilin/Tazobactam-TZP',
'Ampicillin/Sulbactam-SAM',
'Amoxicillin/Clavulanate-AMC',
'Cefoperazon/Sulbactam-SCF',
'Aztreonam-ATM',
'Ceftaroline-CPT',
'Ciprofloxacin-CIP',
'Levofloxacin-LEV',
'Moxifloxacin-MFX',
'Clindamycin-CLI',
'Colistin-CS',
'Tetracyclin-TCY',
'Tigecycline-TGC',
'Gentamicin-GM',
'Amikacin-AN',
'Meropenem-MEM',
'Imipenem-IPM',
'Doripenem-DOR',
'Ertapenem-ETP',
'Minocycline-MNO',
'Doxycycline-DOX',
'Spectinomycin-SPT',
'Tigecycline-TGC',
'Trimethoprim/Sulfamethoxazole-SXT',
'Fosfomycin-FOS',
'Vancomycin-VAN',
'Linezolid-LNZ',
'Fluconazole',
'Voriconazole',
'Caspofungin',
'Micafungin',
'Amphotericin B',
'Flucytosine'
);
}
return view('admin.glassreport', compact('orderbydate', 'jsonantibiotik', 'bulan', 'tahun'));
}
}
+263
View File
@@ -0,0 +1,263 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Support\Facades\DB;
use Defuse\Crypto\Crypto;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\File;
use App\Models\User;
use Mail;
use QrCode;
use PDFCREATOR;
define( 'API_ACCESS_SEND', 'AAAA6YBXh1k:APA91bFL0q7QAXQGohXMpTwHco79f13C8PFk1Oo8kKhg1JerOulT9-37dxyP8X5ibABI0NuQ4ZsVxKQKCt7HuR7lUdJJuB-hTVnBmOUIBYfBlHb-Lcp6aGkj4erfF7J__A5hufXjF8Vt' );
class SendMail extends Controller
{
protected static $pass = 'S1v3pY0uB3e';
protected static function enkrip($string){
return Crypto::encryptWithPassword($string,self::$pass);
}
public static function dekrip($enc){
try{
return Crypto::decryptWithPassword($enc,self::$pass);
}catch (\Exception $e){
return false;
}
}
public static function kirim($to_name,$to_email,$forget=false){
$date=date('YmdHis');
$cekdata = User::where('email', $to_email)->orderBy('id', 'DESC')->first();
if (isset($cekdata->id)){
if($forget){
$string_enc = $to_email.'|'.$date.'|FOR';
$url = url('/verifikasiemail').'?key='.self::enkrip($string_enc);
$subject = 'Ubah Password ('.$cekdata->fakpanjang.')';
$subjectmail = 'Ubah Password';
$note = 'Anda telah melakukan permohonan ubah password. Silahkan klik link berikut untuk melanjutkan proses.';
DB::table('password_resets')->insert([
'email' => $to_email,
'token' => self::enkrip($string_enc),
'created_at'=> date("Y-m-d H:i:s")
]);
}else{
$string_enc = $to_email.'|'.$date.'|VER';
$url = url('/verifikasiemail').'?key='.self::enkrip($string_enc);
$subject = 'Verifikasi Email ('.$cekdata->fakpanjang.')';
$subjectmail = 'Verifikasi Email';
$note = 'Email anda telah terdaftar di Aplikasi ('.$cekdata->fakpanjang.') Email ini dapat digunakan jika anda lupa password. Selanjutnya dimohon Bapak/Ibu membuat password untuk login ke aplikasi dengan cara Klik Tombol di bawah ini.';
}
$data = array(
'nama_lengkap' => $to_name,
'fakultas' => $cekdata->fakpanjang,
'url_verifikasi' => $url,
'forget' => $forget,
'subject' => $subjectmail,
'note' => $note,
);
if ($to_email != '[email protected]'){
Mail::send('mail/user', $data, function($message) use ($to_name, $to_email, $subject) {
$message->to($to_email, $to_name)->subject($subject);
$message->from('[email protected]','Mail Admin');
});
}
}
}
public static function kirimUser($to_name,$to_email,$to_username,$password,$ubahpass=false){
$date=date('YmdHis');
$cekdata = User::where('email', $to_email)->first();
if (isset($cekdata->id)){
if($ubahpass){
$subject = 'Password User Diubah ('.$cekdata->fakpanjang.')';
$note = 'Password anda telah diubah oleh admin dengan password berikut:';
}else{
$subject = 'User Didaftarkan ('.$cekdata->fakpanjang.')';
$note = 'Email anda telah terdaftar di Aplikasi ('.$cekdata->fakpanjang.'). Email ini dapat digunakan jika anda lupa password. Untuk login silahkan akses dengan user <b>'.$to_username.'</b> atau email ini dan dengan password berikut:';
}
$data = array(
'nama_lengkap' => $to_name,
'password' => $password,
'subject' => $subject,
'note' => $note,
);
if ($to_email != '[email protected]'){
Mail::send('mail/useradmin', $data, function($message) use ($to_name, $to_email, $subject) {
$message->to($to_email, $to_name)->subject($subject);
$message->from('[email protected]','Mail Admin');
});
}
}
}
public static function notif($to_name,$to_email,$subject,$note){
$data = array(
'nama_lengkap' => $to_name,
'subject' => $subject,
'note' => $note,
);
if ($to_email != '[email protected]'){
Mail::send('mail/notif', $data, function($message) use ($to_name, $to_email, $subject) {
$message->to($to_email, $to_name)->subject($subject);
$message->from('[email protected]','Mail Admin');
});
}
$jtokencari = User::where('email', $to_email)->whereNotNull('firebaseid')->get();
if (!empty($jtokencari)){
foreach ( $jtokencari as $rtokencari ){
$firebaseid = $rtokencari->firebase;
$msg = array (
'message' => $subject,
'title' => Session('namaapps01'),
'subtitle' => Session('fakpanjang'),
'tickerText'=> 'Notification Centre',
'image' => '',
'vibrate' => 1,
'sound' => 1,
'largeIcon' => 'large_icon',
'smallIcon' => 'small_icon'
);
$fields = array
(
'to' => $firebaseid,
'priority' => 'high',
'notification' => [
"title" => Session('namaapps01'),
"sound" => "default",
"body" => $subject
],
'data' => $msg
);
$headers = array
(
'Authorization: key=' . API_ACCESS_SEND,
'Content-Type: application/json'
);
$url = 'https://fcm.googleapis.com/fcm/send';
$ch = curl_init();
// Set the url, number of POST vars, POST data
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Disabling SSL Certificate support temporarly
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 );
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
// Execute post
$result = curl_exec($ch);
curl_close($ch);
}
}
}
public static function mobilenotif($to_name,$to_email,$subject,$note){
$pesan = '';
$tuliskirim = $note;
if ($to_name == 'all'){
$getppds = User::where('previlage', $to_email)->whereNotNull('firebase')->get();
if (!empty($getppds)){
foreach($getppds as $rowsppds){
$firebaseid = $rowsppds->firebase;
$msg = array (
'message' => $tuliskirim,
'title' => 'LIS',
'subtitle' => 'Laboratory Information System',
'tickerText'=> 'Pasien Terkirim ke PACS',
'image' => '',
'vibrate' => 1,
'sound' => 1,
'largeIcon' => 'large_icon',
'smallIcon' => 'small_icon'
);
$fields = array
(
'to' => $firebaseid,
'priority' => 'high',
'notification' => [
"title" => 'LIS-RSSA Notification Control',
"sound" => "default",
"body" => $tuliskirim
],
'data' => $msg
);
$headers = array
(
'Authorization: key=' . API_ACCESS_KEY,
'Content-Type: application/json'
);
$url = 'https://fcm.googleapis.com/fcm/send';
$ch = curl_init();
// Set the url, number of POST vars, POST data
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Disabling SSL Certificate support temporarly
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 );
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
// Execute post
$result = curl_exec($ch);
curl_close($ch);
$pesan = $pesan.'<br />Notif To : '.$rowsppds->nama;
}
}
} else {
$msg = array (
'message' => $tuliskirim,
'title' => 'LIS',
'subtitle' => 'Laboratory Information System',
'tickerText'=> 'Adendum Saved',
'image' => '',
'vibrate' => 1,
'sound' => 1,
'largeIcon' => 'large_icon',
'smallIcon' => 'small_icon'
);
$fields = array
(
'to' => $to_email,
'priority' => 'high',
'notification' => [
"title" => 'LIS-RSSA Notification Control',
"sound" => "default",
"body" => $tuliskirim
],
'data' => $msg
);
$headers = array
(
'Authorization: key=' . API_ACCESS_KEY,
'Content-Type: application/json'
);
$url = 'https://fcm.googleapis.com/fcm/send';
$ch = curl_init();
// Set the url, number of POST vars, POST data
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Disabling SSL Certificate support temporarly
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 );
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
// Execute post
$result = curl_exec($ch);
curl_close($ch);
}
return $pesan;
}
}
@@ -0,0 +1,336 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Storage;
use App\Jawaban;
use App\Subjawaban;
use App\SiraB;
use App\Organisms;
use Validator;
use Picqer\Barcode\BarcodeGeneratorPNG;
use Session;
class TemplateController extends Controller
{
public function index() {
if (Session::get('previlage') == ''){
return redirect('/login');
} else {
$data = [];
$getsirab = Organisms::whereNotIn('kelompok', ['biakankultur', 'mikroorganisme', 'listkodespesimen'])->select('kelompok')->groupBy('kelompok')->orderBy('kelompok', 'ASC')->get();
$data['parameters'] = $getsirab;
return view('admin.template', $data);
}
}
public function viewSIRAb() {
$previlage = Session('previlage');
if ($previlage == 'developer' OR $previlage == 'supervisor') {
$data = [];
return view('admin.sirab', $data);
} else {
$data = [];
$data['kalimatheader'] = 'Access Denied';
$data['kalimatbody'] = 'Laman khusus SPV';
return view('errors.error', $data);
}
}
public function backup() {
$previlage = Session('previlage');
if ($previlage == 'developer' OR $previlage == 'supervisor') {
$data = [];
$data['alldata'] = Storage::allFiles('/usr/share/nginx/html/rispacs/public/backupdata');
return view('backup', $data);
} else {
$data = [];
$data['kalimatheader'] = 'Access Denied';
$data['kalimatbody'] = 'Laman khusus SPV';
return view('errors.error', $data);
}
}
public function getListJawaban() {
$results = DB::table('jawaban')->get();
$arraylist = [];
$arraylist[]= array(
'id' => 'new',
'jawaban' => '<span class="badge badge-primary">Add New</span>'
);
foreach ($results as $result) {
$arraylist[] = array(
'id' => $result->id,
'jawaban' => $result->jawaban,
);
}
echo json_encode($arraylist);
}
public function updateJawaban(Request $request) {
$validator = Validator::make($request->all(), [
'val01' => 'required',
'val02' => 'required'
]);
if($validator->fails()) {
return response()->json(['status' => 'error', 'message' => 'Please fill input field or fill with right input']);
} else {
$id = $request->input('val02');
if ($id != 'new'){
Jawaban::where('id', $id)->update(['jawaban' => $request->input('val01')]);
}
else {
Jawaban::create(['jawaban' => $request->input('val01')]);
}
return response()->json(['status' => 'Success !!', 'message' => 'Category Saved..!!']);
}
}
public function deleteJawaban(Request $request) {
try {
$id = $request->id;
if ($id == 'sirab'){
$data = SiraB::find($request->idsirab);
} else if ($id == 'mikroorganisme'){
$data = Organisms::find($request->idsirab);
} else {
$data = Jawaban::find($id);
}
$data->delete();
if ($data){
return response()->json(['icon' => 'success', 'warna' => '#5ba035', 'status' => 'Success', 'message' => 'Deleted']);
return back();
} else {
return response()->json(['icon' => 'error', 'warna' => '#bf441d', 'status' => 'Failed', 'message' => 'Unkown Error']);
return back();
}
} catch (\Exception $e) {
return response()->json(['icon' => 'error', 'warna' => '#bf441d', 'status' => 'Failed', 'message' => $e->getMessage()]);
return back();
}
}
public function getListSubjawaban(Request $request) {
$idkat = $request->input('val01');
$kategori = $request->input('val02');
if ($idkat == 'new') {
$arraylist = [];
$arraylist[]= array(
'id' => 'gakboleh',
'kategori' => '-',
'judul' => '<span class="badge badge-danger">Please Select Category First</span>',
'isine' => '-',
'kesimpulan'=> '-'
);
} else {
$arraylist = [];
$arraylist[]= array(
'id' => 'new',
'kategori' => '-',
'judul' => '<span class="badge badge-custom">Add New Expertise Themplate</span>',
'isine' => '-',
'kesimpulan'=> '-'
);
$results = Subjawaban::where('kategori', $idkat)->get();
foreach ($results as $result) {
$isine = $result->subjawaban;
$kesimpulan = $result->kesimpulan;
$isine = $isine.' '.$kesimpulan;
$arraylist[] = array(
'id' => $result->id,
'kategori' => $kategori,
'judul' => $result->judul,
'isine' => $isine,
'kesimpulan'=> ''
);
}
}
echo json_encode($arraylist);
}
public function updateSubjawaban(Request $request) {
$validator = Validator::make($request->all(), [
'val01' => 'required',
'val02' => 'required',
'val03' => 'required',
'val04' => 'required'
]);
if($validator->fails()) {
return response()->json(['status' => 'Error !!', 'message' => 'Please fill input field or fill with right input']);
} else {
$id = $request->input('val02');
if ($id != 'new'){
Subjawaban::where('id', $id)->update([
'judul' => $request->input('val03'),
'subjawaban'=> $request->input('val04'),
'kesimpulan'=> ''
]);
}
else {
Subjawaban::create([
'kategori' => $request->input('val01'),
'judul' => $request->input('val03'),
'subjawaban'=> $request->input('val04'),
'kesimpulan'=> ''
]);
}
return response()->json(['status' => 'Success !!', 'message' => 'Template Saved..!!']);
}
}
public function deleteSubjawaban(Request $request) {
$id = $request->id;
$subjawaban = Subjawaban::find($id);
$subjawaban->delete();
return back();
}
public function showImage($imageName){
// Menentukan path gambar di storage
$filePath = public_path("{$imageName}");
// Cek apakah file ada
if (!file_exists($filePath)) {
abort(404); // Jika file tidak ditemukan, tampilkan error 404
}
// Ambil konten file gambar
$imageContent = file_get_contents($filePath);
// Tentukan MIME type untuk gambar PNG
$mimeType = mime_content_type($filePath);
// Kirim gambar sebagai response dengan header untuk mencegah cache
return response($imageContent, 200)
->header('Content-Type', $mimeType) // Tentukan MIME type gambar
->header('Cache-Control', 'no-store, no-cache, must-revalidate') // Tidak cache di browser
->header('Pragma', 'no-cache') // Tidak menggunakan cache pada browser lama
->header('Expires', '0'); // Jangan pernah kadaluarsa
}
public function exUploadKOP(Request $request) {
if($request->hasFile('file')) {
$ImageExt = $request->file('file')->getClientOriginalExtension();
$file_tmp = $request->file('file');
$data = file_get_contents($file_tmp);
if ($ImageExt == 'png'){
try {
$unggah = Storage::disk('langsungpublic')->put('kopsurat.png', $data);
if ($unggah){
return response()->json(['icon' => 'success', 'warna' => '#5ba035', 'status' => 'Success', 'message' => 'Pictures Saved, please refresh to apply the change']);
return back();
} else {
return response()->json(['icon' => 'error', 'warna' => '#bf441d', 'status' => 'Failed', 'message' => 'Unkown Error']);
return back();
}
} catch (\Exception $e) {
return response()->json(['icon' => 'error', 'warna' => '#bf441d', 'status' => 'Failed', 'message' => $e->getMessage()]);
return back();
}
} else {
return response()->json(['icon' => 'error', 'warna' => '#bf441d', 'status' => 'Failed', 'message' => 'Only Accept PNG File']);
return back();
}
} else {
return response()->json(['icon' => 'error', 'warna' => '#bf441d', 'status' => 'Failed', 'message' => 'No File Selected']);
return back();
}
}
public function showBarcode($nofoto){
$generator = new BarcodeGeneratorPNG();
$barcodeImage = $generator->getBarcode($nofoto, $generator::TYPE_CODE_128);
return response($barcodeImage, 200)->header('Content-Type', 'image/png');
}
public function exSIRAb(Request $request) {
try {
$id = $request->id;
$tabel = $request->tabel;
$pesan = 'Unkown Error';
if ($tabel == 'Organisme'){
if ($id == 'new'){
$ceksudah = Organisms::where('name', $request->name)->where('category', $request->category)->where('kelompok', $request->kelompok)->count();
if ($ceksudah == 0){
$data = new Organisms;
$inputData = $request->except(['id', 'tabel', '_token']);
$data->fill($inputData);
$data->save();
} else {
$pesan = $request->name.' ('.$request->category.') Sudah ada, Mohon ubah Data sebelum simpan kembali';
}
} else {
$ceksudah = Organisms::where('id', '!=', $id)->where('name', $request->name)->where('category', $request->category)->where('kelompok', $request->kelompok)->count();
if ($ceksudah == 0){
$data = Organisms::find($id);
$inputData = $request->except(['id', 'tabel', '_token']);
$data->update($inputData);
} else {
$pesan = $request->name.' ('.$request->category.') Sudah ada, Mohon ubah Data sebelum simpan kembali';
}
}
if ($data){
return response()->json(['icon' => 'success', 'warna' => '#5ba035', 'status' => 'Success', 'message' => 'Saved']);
return back();
} else {
return response()->json(['icon' => 'error', 'warna' => '#bf441d', 'status' => 'Failed', 'message' => 'Unkown Error']);
return back();
}
} else if ($tabel == 'Parameter'){
$getdatalama = Organisms::where('kelompok', $request->kelompok)->first();
$category = $getdatalama->category ?? $request->kelompok;
if ($id == 'new'){
$ceksudah = Organisms::where('name', $request->name)->where('category', $category)->where('kelompok', $request->kelompok)->count();
if ($ceksudah == 0){
$data = Organisms::create([
'name' => $request->name,
'category' => $category,
'kelompok' => $request->kelompok
]);
} else {
$pesan = $request->name.' ('.$request->category.') Sudah ada, Mohon ubah Data sebelum simpan kembali';
}
} else {
$ceksudah = Organisms::where('id', '!=', $id)->where('name', $request->name)->where('category', $category)->where('kelompok', $request->kelompok)->count();
if ($ceksudah == 0){
$data = Organisms::where('id', $id)->update([
'name' => $request->name,
'category' => $category,
'kelompok' => $request->kelompok
]);
} else {
$pesan = $request->name.' ('.$request->category.') Sudah ada, Mohon ubah Data sebelum simpan kembali';
}
}
if ($data){
return response()->json(['icon' => 'success', 'warna' => '#5ba035', 'status' => 'Success', 'message' => 'Saved']);
return back();
} else {
return response()->json(['icon' => 'error', 'warna' => '#bf441d', 'status' => 'Failed', 'message' => 'Unkown Error']);
return back();
}
} else {
if ($id == 'new'){
$data = new SiraB;
$inputData = $request->except(['id', 'tabel', '_token']);
$data->fill($inputData);
$data->save();
} else {
$data = SiraB::find($id);
$inputData = $request->except(['id', 'tabel', '_token']);
$data->update($inputData);
}
if ($data){
return response()->json(['icon' => 'success', 'warna' => '#5ba035', 'status' => 'Success', 'message' => 'Saved']);
return back();
} else {
return response()->json(['icon' => 'error', 'warna' => '#bf441d', 'status' => 'Failed', 'message' => 'Unkown Error']);
return back();
}
}
} catch (\Exception $e) {
return response()->json(['icon' => 'error', 'warna' => '#bf441d', 'status' => 'Failed', 'message' => $e->getMessage()]);
return back();
}
}
}
@@ -0,0 +1,299 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use App\User;
use App\Setting;
use App\Dokter;
use App\Worklist;
use App\XFiles;
use Validator;
use Session;
class UserController extends Controller
{
public function index() {
$cekkelompok= Session('previlage');
if (Session::get('previlage') == ''){
return redirect('/login');
} else {
if ($cekkelompok == 'supervisor' OR $cekkelompok == 'admin' OR $cekkelompok == 'developer'){
$users = User::all();
} else {
$users = User::where('previlage', $cekkelompok)->get();
}
$getsetting = Setting::where('id', '1')->first();
$data = [];
$data['users'] = $users;
$data['pacsaddr'] = $getsetting->pacs ?? '';
$data['zfpaddr'] = $getsetting->zfp ?? '';
$data['port'] = $getsetting->port ?? '';
$data['portzfp'] = $getsetting->portzfp ?? '';
$data['username'] = $getsetting->username ?? '';
$data['password'] = $getsetting->password ?? '';
return view('admin.user', $data);
}
}
public function exSetting(Request $request) {
$validator = Validator::make($request->all(), [
'val01' => 'required',
'val02' => 'required',
'val03' => 'required',
'val04' => 'required',
'val05' => 'required',
'val06' => 'required',
]);
if($validator->fails()) {
return response()->json(['status' => 'error', 'message' => 'Please fill input field or fill with right input']);
} else {
$update = Setting::where('id', '1')->update([
'pacs' => $request->input('val01'),
'zfp' => $request->input('val02'),
'port' => $request->input('val03'),
'portzfp' => $request->input('val06'),
'username' => $request->input('val04'),
'password' => $request->input('val05')
]);
if ($update) {
return response()->json(['icon' => 'success', 'warna' => '#5ba035', 'status' => 'Success', 'message' => 'Setting Saved..!!!']);
return back();
}
else {
return response()->json(['icon' => 'error', 'warna' => '#bf441d', 'status' => 'Error.!!', 'message' => 'System Down, please try again in a few years....']);
return back();
}
}
}
public function exSettingworklist(Request $request) {
$idne = $request->input('val01');
if ($idne == 'delete'){
$delete = Worklist::where('id', $request->input('val02'))->delete();
if ($delete) {
return response()->json(['icon' => 'success', 'warna' => '#5ba035', 'status' => 'Success', 'message' => 'Worklist Deleted..!!!']);
return back();
}
else {
return response()->json(['icon' => 'error', 'warna' => '#bf441d', 'status' => 'Error.!!', 'message' => 'System Down, please try again in a few years....']);
return back();
}
} else {
$validator = Validator::make($request->all(), [
'val01' => 'required',
'val02' => 'required',
'val03' => 'required',
'val04' => 'required',
'val05' => 'required',
]);
if($validator->fails()) {
return response()->json(['icon' => 'error', 'warna' => '#bf441d', 'status' => 'Error.!!', 'message' => 'Please fill input field or fill with right input']);
} else {
if ($idne == 'new'){
$input = Worklist::create([
'aetitle' => $request->input('val05'),
'portnumber' => $request->input('val04'),
'ipaddress' => $request->input('val02'),
'location' => $request->input('val03'),
'modaliti' => $request->input('val06')
]);
} else {
$input = Worklist::where('id', $idne)->update([
'aetitle' => $request->input('val05'),
'portnumber' => $request->input('val04'),
'ipaddress' => $request->input('val02'),
'location' => $request->input('val03'),
'modaliti' => $request->input('val06')
]);
}
if ($input) {
return response()->json(['icon' => 'success', 'warna' => '#5ba035', 'status' => 'Success', 'message' => 'Worklist Saved..!!!']);
return back();
}
else {
return response()->json(['icon' => 'error', 'warna' => '#bf441d', 'status' => 'Error.!!', 'message' => 'System Down, please try again in a few years....']);
return back();
}
}
}
}
public function exTtd(Request $request) {
$iduser = Session('id');
$marking = Session('username').'-Photo-'.$iduser;
$update = XFiles::updateOrCreate(
[
'xmarking' => $marking,
],
[
'xjenis' => 'Tandatangan',
'xtabel' => Session('username'),
'xfile' => $request->input('val01')
]
);
if ($update) {
User::where('id', $iduser)->update([
'tandatangan' => $marking,
]);
return response()->json(['icon' => 'success', 'warna' => '#5ba035', 'status' => 'Success', 'message' => 'Signature Saved..!!!']);
return back();
}
else {
return response()->json(['icon' => 'error', 'warna' => '#bf441d', 'status' => 'Error.!!', 'message' => 'System Down, please try again in a few years....']);
return back();
}
}
public function store(Request $request) {
$validator = Validator::make($request->all(), [
'nama' => 'required',
'username' => 'required',
'password' => 'required',
'previlage' => 'required',
]);
if($validator->fails()) {
Session::flash('message', 'Please fill input field or fill with right input');
Session::flash('alert-class', 'alert-danger');
return back();
} else {
$username = $request->input('username');
$previlage = $request->input('previlage');
$nama = $request->input('nama');
$cekuser = User::where('username', $username)->count();
if ($cekuser == 0){
if ($previlage == 'supervisor' OR $previlage == 'developer'){
$iduser = User::insertGetId([
'nama' => $request->input('nama'),
'username' => $request->input('username'),
'password' => bcrypt($request->input('password')),
'previlage' => $request->input('previlage')
]);
Dokter::create([
'id' => $iduser,
'nama' => $request->input('nama'),
'kota' => config('global.kota'),
'alamat' => config('global.addressapps')
]);
} else {
$user = User::create([
'nama' => $request->input('nama'),
'username' => $request->input('username'),
'password' => bcrypt($request->input('password')),
'previlage' => $request->input('previlage')
]);
}
Session::flash('message', 'Username for '.$nama.' Saved');
Session::flash('alert-class', 'alert-success');
return back();
} else {
Session::flash('message', 'Username already used, please use another username');
Session::flash('alert-class', 'alert-danger');
return back();
}
}
}
public function getUser(Request $request) {
$id = $request->input('id');
$result = User::where('id', $id)->first();
echo json_encode($result);
}
public function getWorklist() {
$arrworklist = [];
$getworklist = Worklist::orderBy('location', 'ASC')->get();
foreach ($getworklist as $rowida) {
$arrworklist[] = array(
'id' => $rowida->id,
'aetitle' => $rowida->aetitle,
'portnumber' => $rowida->portnumber,
'ipaddress' => $rowida->ipaddress,
'location' => $rowida->location,
'modaliti' => $rowida->modaliti,
);
}
echo json_encode($arrworklist);
}
public function update(Request $request) {
$validator = Validator::make($request->all(), [
'nama' => 'required',
'username' => 'required',
'previlage' => 'required'
]);
if($validator->fails()) {
return response()->json(['status' => 'error', 'message' => 'Please fill input field or fill with right input']);
} else {
$id = $request->input('id_user');
$password = $request->input('password');
if ($password == ''){
$update = User::where('id', $id)->update([
'nama' => $request->input('nama'),
'username' => $request->input('username'),
'previlage' => $request->input('previlage')
]);
} else {
$update = User::where('id', $id)->update([
'nama' => $request->input('nama'),
'username' => $request->input('username'),
'password' => bcrypt($request->input('password')),
'previlage' => $request->input('previlage')
]);
}
if ($update){
Session::flash('message', 'Updated');
Session::flash('alert-class', 'alert-success');
return back();
} else {
Session::flash('message', 'Update Failed, Please Try Again in a few year');
Session::flash('alert-class', 'alert-success');
return back();
}
}
}
public function updateFoto(Request $request) {
$iduser = Session('id');
$marking = Session('username').'-Photo-'.$iduser;
if($request->hasFile('file')) {
$ImageExt = $request->file('file')->getClientOriginalExtension();
$file_tmp = $request->file('file');
$data = file_get_contents($file_tmp);
$photo = 'data:image/' . $ImageExt . ';base64,' . base64_encode($data);
$iduser = Session('id');
$update = XFiles::updateOrCreate(
[
'xmarking' => $marking,
],
[
'xtabel' => Session('username'),
'xjenis' => 'Photo',
'xfile' => $photo
]
);
if ($update) {
User::where('id', $iduser)->update([
'photo' => $marking,
]);
return response()->json(['icon' => 'success', 'warna' => '#5ba035', 'status' => 'Success', 'message' => 'Photo Profile Saved, please relogin to apply the change']);
return back();
}
else {
return response()->json(['icon' => 'error', 'warna' => '#bf441d', 'status' => 'Error.!!', 'message' => 'System Down, please try again in a few years....']);
return back();
}
} else {
return response()->json(['icon' => 'error', 'warna' => '#bf441d', 'status' => 'Error.!!', 'message' => 'No File Selected']);
return back();
}
}
public function delete(Request $request) {
$id = $request->user_id;
$user = User::find($id);
XFiles::where('xtabel', $user->username)->delete();
$user->delete();
return back();
}
}
@@ -0,0 +1,82 @@
<?php
namespace App\Http\Controllers;
use Ratchet\MessageComponentInterface;
use Ratchet\ConnectionInterface;
use App\Iseng;
class WebSocketController extends Controller implements MessageComponentInterface{
private $connections = [];
/**
* When a new connection is opened it will be passed to this method
* @param ConnectionInterface $conn The socket/connection that just connected to your application
* @throws \Exception
*/
function onOpen(ConnectionInterface $conn){
$this->connections[$conn->resourceId] = compact('conn') + ['user_id' => null];
}
/**
* This is called before or after a socket is closed (depends on how it's closed). SendMessage to $conn will not result in an error if it has already been closed.
* @param ConnectionInterface $conn The socket/connection that is closing/closed
* @throws \Exception
*/
function onClose(ConnectionInterface $conn){
$disconnectedId = $conn->resourceId;
unset($this->connections[$disconnectedId]);
foreach($this->connections as &$connection)
$connection['conn']->send(json_encode([
'offline_user' => $disconnectedId,
'from_user_id' => 'server control',
'from_resource_id' => null
]));
}
/**
* If there is an error with one of the sockets, or somewhere in the application where an Exception is thrown,
* the Exception is sent back down the stack, handled by the Server and bubbled back up the application through this method
* @param ConnectionInterface $conn
* @param \Exception $e
* @throws \Exception
*/
function onError(ConnectionInterface $conn, \Exception $e){
$userId = $this->connections[$conn->resourceId]['user_id'];
echo "An error has occurred with user $userId: {$e->getMessage()}\n";
unset($this->connections[$conn->resourceId]);
$conn->close();
}
/**
* Triggered when a client sends data through the socket
* @param \Ratchet\ConnectionInterface $conn The socket/connection that sent the message to your application
* @param string $msg The message received
* @throws \Exception
*/
function onMessage(ConnectionInterface $conn, $msg){
$msg = json_decode($msg, true);
$konten = $msg['content'];
Iseng::insert([
'msg' => $konten
]);
// if(is_null($this->connections[$conn->resourceId]['user_id'])){
// $this->connections[$conn->resourceId]['user_id'] = $msg;
// $onlineUsers = [];
// foreach($this->connections as $resourceId => &$connection){
// $connection['conn']->send(json_encode([$conn->resourceId => $msg]));
// if($conn->resourceId != $resourceId)
// $onlineUsers[$resourceId] = $connection['user_id'];
// }
// $conn->send(json_encode(['online_users' => $onlineUsers]));
// } else{
// $fromUserId = $this->connections[$conn->resourceId]['user_id'];
// $msg = json_decode($msg, true);
// $this->connections[$msg['to']]['conn']->send(json_encode([
// 'msg' => $msg['content'],
// 'from_user_id' => $fromUserId,
// 'from_resource_id' => $conn->resourceId
// ]));
// }
}
}
+69
View File
@@ -0,0 +1,69 @@
<?php
namespace App\Http;
use Illuminate\Foundation\Http\Kernel as HttpKernel;
class Kernel extends HttpKernel
{
/**
* The application's global HTTP middleware stack.
*
* These middleware are run during every request to your application.
*
* @var array<int, class-string|string>
*/
protected $middleware = [
// \App\Http\Middleware\TrustHosts::class,
\App\Http\Middleware\TrustProxies::class,
\Illuminate\Http\Middleware\HandleCors::class,
\App\Http\Middleware\PreventRequestsDuringMaintenance::class,
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
\App\Http\Middleware\TrimStrings::class,
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
];
/**
* The application's route middleware groups.
*
* @var array<string, array<int, class-string|string>>
*/
protected $middlewareGroups = [
'web' => [
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class,
],
'api' => [
// \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
\Illuminate\Routing\Middleware\ThrottleRequests::class.':api',
\Illuminate\Routing\Middleware\SubstituteBindings::class,
],
];
/**
* The application's middleware aliases.
*
* Aliases may be used instead of class names to conveniently assign middleware to routes and groups.
*
* @var array<string, class-string|string>
*/
protected $middlewareAliases = [
'project.ipg' => \App\Http\Middleware\Login::class,
'auth' => \App\Http\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class,
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
'can' => \Illuminate\Auth\Middleware\Authorize::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
'precognitive' => \Illuminate\Foundation\Http\Middleware\HandlePrecognitiveRequests::class,
'signed' => \App\Http\Middleware\ValidateSignature::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
];
}
@@ -0,0 +1,17 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Auth\Middleware\Authenticate as Middleware;
use Illuminate\Http\Request;
class Authenticate extends Middleware
{
/**
* Get the path the user should be redirected to when they are not authenticated.
*/
protected function redirectTo(Request $request): ?string
{
return $request->expectsJson() ? null : route('login');
}
}
@@ -0,0 +1,17 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;
class EncryptCookies extends Middleware
{
/**
* The names of the cookies that should not be encrypted.
*
* @var array<int, string>
*/
protected $except = [
//
];
}
+41
View File
@@ -0,0 +1,41 @@
<?php
namespace App\Http\Middleware;
use Closure;
use Carbon\Carbon;
class Login
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$response = $next($request);
return $response;
}
public function terminate($request, $response)
{
if (! \Auth::check())
return;
$user = \Auth::user();
if (!$user->session_id) {
$user->session_id = \Session::getId();
$user->last_activity = Carbon::now();
$user->save();
}
else {
$last_session = \Session::getHandler()->read($user->session_id);
}
}
}
@@ -0,0 +1,17 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance as Middleware;
class PreventRequestsDuringMaintenance extends Middleware
{
/**
* The URIs that should be reachable while maintenance mode is enabled.
*
* @var array<int, string>
*/
protected $except = [
//
];
}
@@ -0,0 +1,30 @@
<?php
namespace App\Http\Middleware;
use App\Providers\RouteServiceProvider;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Symfony\Component\HttpFoundation\Response;
class RedirectIfAuthenticated
{
/**
* Handle an incoming request.
*
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
*/
public function handle(Request $request, Closure $next, string ...$guards): Response
{
$guards = empty($guards) ? [null] : $guards;
foreach ($guards as $guard) {
if (Auth::guard($guard)->check()) {
return redirect(RouteServiceProvider::HOME);
}
}
return $next($request);
}
}
@@ -0,0 +1,19 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware;
class TrimStrings extends Middleware
{
/**
* The names of the attributes that should not be trimmed.
*
* @var array<int, string>
*/
protected $except = [
'current_password',
'password',
'password_confirmation',
];
}
+20
View File
@@ -0,0 +1,20 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Http\Middleware\TrustHosts as Middleware;
class TrustHosts extends Middleware
{
/**
* Get the host patterns that should be trusted.
*
* @return array<int, string|null>
*/
public function hosts(): array
{
return [
$this->allSubdomainsOfApplicationUrl(),
];
}
}
@@ -0,0 +1,28 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Http\Middleware\TrustProxies as Middleware;
use Illuminate\Http\Request;
class TrustProxies extends Middleware
{
/**
* The trusted proxies for this application.
*
* @var array<int, string>|string|null
*/
protected $proxies;
/**
* The headers that should be used to detect proxies.
*
* @var int
*/
protected $headers =
Request::HEADER_X_FORWARDED_FOR |
Request::HEADER_X_FORWARDED_HOST |
Request::HEADER_X_FORWARDED_PORT |
Request::HEADER_X_FORWARDED_PROTO |
Request::HEADER_X_FORWARDED_AWS_ELB;
}
@@ -0,0 +1,22 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Routing\Middleware\ValidateSignature as Middleware;
class ValidateSignature extends Middleware
{
/**
* The names of the query string parameters that should be ignored.
*
* @var array<int, string>
*/
protected $except = [
// 'fbclid',
// 'utm_campaign',
// 'utm_content',
// 'utm_medium',
// 'utm_source',
// 'utm_term',
];
}
@@ -0,0 +1,17 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
class VerifyCsrfToken extends Middleware
{
/**
* The URIs that should be excluded from CSRF verification.
*
* @var array<int, string>
*/
protected $except = [
'registerpasien', 'registerjson', 'ekstrakhasil', 'prosesbatal', 'cekaksess'
];
}
+4
View File
@@ -0,0 +1,4 @@
<?php namespace App; use Illuminate\Database\Eloquent\Model; class Iseng extends Model { protected $table = "tabeliseng"; public $timestamps = false;
protected $fillable = [
'msg' ];
}
+13
View File
@@ -0,0 +1,13 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Jadwalperiksa extends Model
{
protected $table = "jadwalperiksan";
protected $fillable = [
'id','mulai', 'akhir', 'nofoto', 'noregister', 'asalpasien', 'nmrs', 'pasien_id', 'reques', 'usia', 'berat', 'ruangan_id', 'ruangan', 'dokter_id', 'ppdssenior', 'middleppds', 'ppdsjunior', 'radiografer', 'excutor', 'klinisi', 'klinis', 'poli_id', 'keterangan', 'kesimpulan', 'asuransi', 'urgensi', 'diagnosa', 'modality', 'kilovolt', 'mas', 'dlp', 'daftar', 'foto', 'baca', 'verifikasi', 'export', 'filefoto', 'status',
];
}
+13
View File
@@ -0,0 +1,13 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Jawaban extends Model
{
protected $table = "jawaban";
protected $fillable = [
'jawaban'
];
}
+11
View File
@@ -0,0 +1,11 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class KomponenJawaban extends Model
{
protected $table = "db_komponenjawaban";
protected $guarded = [];
}
+13
View File
@@ -0,0 +1,13 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Logbook extends Model
{
protected $table = "db_logbooklist";
protected $fillable = [
'id', 'kelompok', 'kode', 'kepanjangan', 'kuota', 'target', 'kuota2', 'target2', 'kuota3', 'target3'
];
}
+11
View File
@@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Chatify\Traits\UUID;
class ChFavorite extends Model
{
use UUID;
}
+11
View File
@@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Chatify\Traits\UUID;
class ChMessage extends Model
{
use UUID;
}
+37
View File
@@ -0,0 +1,37 @@
<?php
namespace App\Models;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
{
use Notifiable;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'nama', 'username', 'password', 'previlage', 'tandatangan', 'photo', 'firebase'
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password'
];
public function getPhoto()
{
return $this->hasOne('App\XFiles','xmarking','photo');
}
public function getTandatangan()
{
return $this->hasOne('App\XFiles','xmarking','tandatangan');
}
}
+11
View File
@@ -0,0 +1,11 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Organisms extends Model
{
protected $table = "organisms";
protected $guarded = [];
}
+20
View File
@@ -0,0 +1,20 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Pasien extends Model
{
protected $table = "pasien";
protected $fillable = [
'norm',
'nama',
'jk',
'tgl_lahir',
'kota',
'telpon',
'alamat',
'keterangan'
];
}
+28
View File
@@ -0,0 +1,28 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
class PatientSample extends Model
{
use HasFactory;
protected $table = "resultraw";
protected $fillable = [
'vendor',
'version',
'patient_id',
'patient_name',
'sample_code',
'barcode',
'test_type',
'inst_result',
'collection_time',
'report_time',
'test_id',
'start_time',
'end_time',
];
}
+15
View File
@@ -0,0 +1,15 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class PendaftaranOnListiner extends Model
{
protected $connection = 'mysqllistener';
protected $primaryKey = "rnoreg";
protected $table = "paslab";
public $timestamps = false;
protected $guarded = [];
}
+55
View File
@@ -0,0 +1,55 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Periksa extends Model
{
protected $table = "periksa";
protected $guarded = [];
public function getMiddlePpdskedua()
{
return $this->hasOne('App\Models\User','id','middleppds2');
}
public function getJuniorPpdskedua()
{
return $this->hasOne('App\Models\User','id','ppdsjunior2');
}
public function getNmRadiografer()
{
return $this->hasOne('App\Models\User','id','radiografer');
}
public function getNmExcutor()
{
return $this->hasOne('App\Models\User','id','excutor');
}
public function getNmDokter()
{
return $this->hasOne('App\Models\User','id','dokter_id');
}
public function getNmPPDSSenior()
{
return $this->hasOne('App\Models\User','id','ppdssenior');
}
public function getPasien()
{
return $this->hasOne('App\Pasien','id','pasien_id');
}
public function getPoli()
{
return $this->hasOne('App\Poli','id','poli_id');
}
public function getRuangan()
{
return $this->hasOne('App\Ruangan','id','ruangan_id');
}
public function getTandatangan()
{
return $this->hasOne('App\XFiles','xmarking','tandatangan');
}
public function getLogbook()
{
return $this->hasOne('App\Logbook','id','diagnosa');
}
}
+11
View File
@@ -0,0 +1,11 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class PeriksaSYNC extends Model
{
protected $table = "db_syncinsitu";
protected $guarded = [];
}
+11
View File
@@ -0,0 +1,11 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class PeriksaTest extends Model
{
protected $table = "periksa_testing";
protected $guarded = [];
}
+17
View File
@@ -0,0 +1,17 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Poli extends Model
{
protected $table = "poli";
protected $fillable = [
'poli',
'subpoli',
'subsubpoli',
'modaliti',
'modaliti2',
];
}
@@ -0,0 +1,24 @@
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*/
public function register(): void
{
//
}
/**
* Bootstrap any application services.
*/
public function boot(): void
{
//
}
}
@@ -0,0 +1,26 @@
<?php
namespace App\Providers;
// use Illuminate\Support\Facades\Gate;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
class AuthServiceProvider extends ServiceProvider
{
/**
* The model to policy mappings for the application.
*
* @var array<class-string, class-string>
*/
protected $policies = [
//
];
/**
* Register any authentication / authorization services.
*/
public function boot(): void
{
//
}
}
@@ -0,0 +1,19 @@
<?php
namespace App\Providers;
use Illuminate\Support\Facades\Broadcast;
use Illuminate\Support\ServiceProvider;
class BroadcastServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*/
public function boot(): void
{
Broadcast::routes();
require base_path('routes/channels.php');
}
}
@@ -0,0 +1,38 @@
<?php
namespace App\Providers;
use Illuminate\Auth\Events\Registered;
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Event;
class EventServiceProvider extends ServiceProvider
{
/**
* The event to listener mappings for the application.
*
* @var array<class-string, array<int, class-string>>
*/
protected $listen = [
Registered::class => [
SendEmailVerificationNotification::class,
],
];
/**
* Register any events for your application.
*/
public function boot(): void
{
//
}
/**
* Determine if events and listeners should be automatically discovered.
*/
public function shouldDiscoverEvents(): bool
{
return false;
}
}
@@ -0,0 +1,42 @@
<?php
namespace App\Providers;
use Illuminate\Cache\RateLimiting\Limit;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Support\Facades\Route;
class RouteServiceProvider extends ServiceProvider
{
/**
* The path to your application's "home" route.
*
* Typically, users are redirected here after authentication.
*
* @var string
*/
public const HOME = '/home';
/**
* Define your route model bindings, pattern filters, and other route configuration.
*/
public function boot(): void
{
resolve(\Illuminate\Routing\UrlGenerator::class)->forceScheme('https');
parent::boot();
RateLimiter::for('api', function (Request $request) {
return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());
});
$this->routes(function () {
Route::middleware('api')
->prefix('api')
->group(base_path('routes/api.php'));
Route::middleware('web')
->group(base_path('routes/web.php'));
});
}
}
+11
View File
@@ -0,0 +1,11 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class RekapAntibiotik extends Model
{
protected $table = "rekapantibiotik";
protected $guarded = [];
}
+11
View File
@@ -0,0 +1,11 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Rekaplogbook extends Model
{
protected $table = "db_rekapppds";
protected $guarded = [];
}
+14
View File
@@ -0,0 +1,14 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class ResultSample extends Model
{
protected $table = "resultraw";
protected $guarded = [];
protected $casts = [
'additional_result' => 'array'
];
}
+13
View File
@@ -0,0 +1,13 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Riwayat extends Model
{
protected $table = "riwayatjawaban";
protected $fillable = [
'id', 'nofoto', 'jawaban', 'inputor', 'keterangan', 'verifikasi', 'created_at'
];
}
+14
View File
@@ -0,0 +1,14 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Ruangan extends Model
{
protected $table = "ruangan";
protected $fillable = [
'poli',
'ruangan'
];
}
+11
View File
@@ -0,0 +1,11 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class SIMBHPJenis extends Model
{
protected $table = "simbhpjenis";
protected $guarded = [];
}
+11
View File
@@ -0,0 +1,11 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class SIMBHPReport extends Model
{
protected $table = "simbhpreport";
protected $guarded = [];
}
+555
View File
@@ -0,0 +1,555 @@
<?php
namespace App\Services;
use Carbon\Carbon;
use App\ResultSample;
use Illuminate\Support\Facades\Log;
use Exception;
use App\DataListiner;
// Proses untuk Growth and Detection Result
function processGrowthDetectionResult($rawData){
// Format: R|1| ^ ^ ^GND_MGIT^430100001234|INST_POSITIVE ^87| ...
$resultData = explode('|', $rawData);
return [
'test_type' => 'Growth/Detection',
'accession_number' => $resultData[2],
'status' => $resultData[3], // Positif atau Negatif
'completion_time' => $resultData[7]
];
}
// Proses untuk Isolate Result
function processIsolateResult($rawData){
$resultData = explode('|', $rawData);
return [
'test_type' => 'Isolate',
'isolate_result' => $resultData[3],
'antibiotic' => $resultData[4],
'value' => $resultData[5],
'status' => $resultData[6],
'completion_time' => $resultData[10]
];
}
// Proses untuk Other Test Result
function processOtherResult($rawData){
// Format: R|1| ^ ^ ^OTHER^Seq123|Complete| ...
$resultData = explode('|', $rawData);
return [
'test_type' => 'Other',
'sequence_number' => $resultData[3],
'result' => $resultData[4],
'description' => $resultData[5],
'completion_time' => $resultData[6]
];
}
class AstmMessageService
{
/**
* Membersihkan string dari karakter non-printable
*/
private function cleanString($string)
{
return preg_replace('/[^\P{C}\n]+/u', '', $string);
}
/**
* Parsing data berdasarkan format yang diberikan
*/
private function parseResultData($rawData, $format)
{
$resultData = explode('|', $rawData);
$parsedData = [];
foreach ($format as $key => $index) {
$parsedData[$key] = $resultData[$index] ?? null;
}
return $parsedData;
}
/**
* Proses hasil AST Record
*/
public function processAstResult($rawData)
{
$format = [
'test_type' => 0,
'accession_number' => 2,
'antibiotic' => 3,
'susceptibility' => 4,
'value' => 5,
'status' => 6,
'completion_time' => 10
];
return $this->parseResultData($rawData, $format);
}
/**
* Proses hasil ID Record
*/
public function processIdResult($rawData)
{
$format = [
'test_type' => 0,
'accession_number' => 2,
'organism_name' => 3,
'status' => 6,
'completion_time' => 10
];
return $this->parseResultData($rawData, $format);
}
public function createHeader($senderName, $versionNumber)
{
$messageDateTime = Carbon::now()->format('YmdHis');
return "H|{$senderName}|{$versionNumber}|{$messageDateTime}";
}
// Fungsi untuk membuat Patient Record (P)
public function createPatientRecord($patient)
{
// Extract fields from $patient array, adjust field positions based on mapping
return "P|{$patient['id']}|{$patient['last_name']}|{$patient['first_name']}|{$patient['middle_name']}|{$patient['suffix']}|{$patient['dob']}|{$patient['sex']}|{$patient['address']}||{$patient['phone']}|{$patient['admitting_physician']}";
}
// Fungsi untuk membuat Order Record (O)
public function createOrderRecord($order)
{
// Order fields based on mapping (Accession Number, Test ID, etc.)
return "O|{$order['accession_number']}|{$order['isolate_number']}|{$order['organism']}|{$order['exclude_isolate']}|{$order['priority']}|{$order['collection_date_time']}|{$order['collected_by']}|{$order['received_by']}|{$order['specimen_action_code']}|{$order['isolate_source_test']}|{$order['isolate_source_test_start_time']}|{$order['receipt_date_time']}|{$order['specimen_type']}|{$order['body_site']}|{$order['ordering_physician']}|{$order['ordering_physician_phone']}|{$order['ordering_physician_fax']}|{$order['ordering_physician_pager']}|{$order['specimen_user_field_1']}|{$order['specimen_user_field_2']}|{$order['specimen_user_field_3']}|{$order['specimen_user_field_4']}|{$order['specimen_user_field_5']}|{$order['finalized_date_time']}|{$order['specimen_reimbursement_value']}|{$order['test_reimbursement_value']}|{$order['isolate_classification']}"; }
public function createTerminatorRecord($order)
{
// Order fields based on mapping (Accession Number, Test ID, etc.)
return "L|1|N";
}
// Fungsi untuk membuat pesan lengkap (header + patient + order)
public function createMessage($senderName, $versionNumber, $patient, $order)
{
$header = $this->createHeader($senderName, $versionNumber);
$patientRecord = $this->createPatientRecord($patient);
$orderRecord = $this->createOrderRecord($order);
$terimatorRecord= $this->createTerminatorRecord($order);
return implode("\n", [$header, $patientRecord, $orderRecord, $terimatorRecord]);
}
/**
* Proses data ASTM Response
*/
public function processAstmResponse($response, $alat) {
// Bersihkan data
$astmData = $this->cleanString($response);
// Validasi awal: response tidak kosong
if (empty($astmData)) {
Log::error("ASTM data kosong atau tidak valid.");
}
$headerData = [];
$patientData = [];
$orderData = [];
$resultData = [];
$instrumenDT = [];
$mltrData = [];
$isolate = null;
$accession_number = null;
$segments = explode("\n", $astmData);
foreach ($segments as $rsegmen){
$cekdata = explode('|', $rsegmen);
$datapertama = $cekdata[0];
$cleankode = preg_replace("/[^a-zA-Z]/", "", $datapertama);
if ($cleankode == 'H'){
$headerData = array_merge([$cleankode], array_slice($cekdata, 1));
}
if ($cleankode == 'P'){
$patientData = array_merge([$cleankode], array_slice($cekdata, 1));
}
if ($cleankode == 'O'){
$orderData = array_merge([$cleankode], array_slice($cekdata, 1));
}
if ($cleankode == 'R'){
$resultData = array_merge([$cleankode], array_slice($cekdata, 1));
}
if ($cleankode == 'I'){
$instrumenDT = array_merge([$cleankode], array_slice($cekdata, 1));
}
if ($cleankode == 'mtrsl'){
$mltrData = array_merge([$cleankode], array_slice($cekdata, 1));
}
}
if (!empty($patientData) && !empty($headerData)) {
$resultSample = new ResultSample();
$noregister = $patientData[4] ?? null;
$resultSample->sender_name = $alat;
$resultSample->version_number = $headerData[11] ?? $patientData[12] ?? null;
$resultSample->message_datetime = $resultData[13] ?? null; // '20241130152734'
// Patient Record (Segment P)
$resultSample->patient_id = $patientData[4] ?? null; // '11607396'
$resultSample->patient_name_last = $patientData[6] ?? null; // 'ZAKIYATUN'
$resultSample->patient_name_first = $patientData[7] ?? null; // 'O'
$resultSample->patient_name_middle = $patientData[8] ?? null;
$resultSample->patient_name_suffix = $patientData[9] ?? null;
$resultSample->patient_name_title = $patientData[10] ?? null;
$resultSample->patient_dob = $resultData[11] ?? null; // '19800101'
$resultSample->patient_sex = $patientData[12] ?? null; // 'F'
$resultSample->address_street = $patientData[13] ?? null; // 'Street ABC'
$resultSample->address_city = $patientData[14] ?? null;
$resultSample->address_state = $patientData[15] ?? null;
$resultSample->address_zip = $patientData[16] ?? null;
$resultSample->address_country = $patientData[17] ?? null;
$resultSample->patient_phone = $patientData[18] ?? null; // '081234567890'
// Order Record (Segment O)
$resultSample->accession_number = $orderData[4] ?? null; // '12345'
$resultSample->isolate_number = $orderData[5] ?? null; // '67890'
$resultSample->organism = $orderData[6] ?? null; // 'E. coli'
$resultSample->exclude_isolate_from_statistics = $isolate; // 'false'
$resultSample->test_id = $orderData[8] ?? null; // 'Test123'
// Result Record (Segment R)
$resultSample->result_type_code = $resultData[4] ?? null; // 'S'
$resultSample->antibiotic = $resultData[5] ?? null; // 'Amoxicillin'
$resultSample->antibiotic_concentration = $resultData[6] ?? null; // '100mg'
$resultSample->antibiotic_concentration_units = $resultData[7] ?? null; // 'mg'
$resultSample->test_status = $resultData[8] ?? null; // 'Completed'
$resultSample->result_data = json_encode(array_slice($resultData, 9)); // Additional data (if any)
$resultSample->preliminary_final_status = $resultData[13] ?? null;
$resultSample->test_start_datetime = $resultData[14] ?? null;
$resultSample->result_status_datetime = $resultData[15] ?? null;
$resultSample->test_complete_datetime = $resultData[16] ?? null;
// Periksa apakah data duplikat berdasarkan accession_number
//if (ResultSample::where('accession_number', $resultSample->accession_number)->exists()) {
// return response()->json(['message' => 'Data sudah ada.'], 409);
//}
// Simpan ke database
if ($noregister){
Log::info("Data berhasil disimpan:", $resultSample->toArray());
$resultSample->save();
}
return response()->json(['message' => 'Data berhasil diproses dan disimpan.']);
} else {
if (!empty($mltrData)){
Log::info("Trying parser MTRSL :", $mltrData);
$parsedData = [];
$parsedData['antibiotics'] = [];
$antibiotic = '';
$resistance = '';
$value = '';
$interpretation = '';
$mulaikirim = 0;
$resultSample = new ResultSample();
foreach ($mltrData as $index => $field) {
if ($field == 'ra'){
if ($antibiotic != ''){
$parsedData['antibiotics'][] = [
'antibiotic' => $antibiotic, // Antibiotik
'resistance' => $resistance, // Hasil Resistansi
'value' => $value, // Nilai
'interpretation'=> $interpretation // Interpretasi
];
$antibiotic = '';
$resistance = '';
$value = '';
$interpretation = '';
} else {
$mulaikirim = 1;
}
} else {
if ($mulaikirim == 1){
$antibiotic = substr($field, 2);
$mulaikirim++;
} else if ($mulaikirim == 2){
$resistance = substr($field, 2);
$mulaikirim++;
} else if ($mulaikirim == 3){
$value = substr($field, 2);
$mulaikirim++;
} else if ($mulaikirim == 4){
$interpretation = substr($field, 2);
$mulaikirim++;
} else {
$field = substr($field, 2);
switch ($index) {
case 0:
$resultSample->sender_name = $alat;
break;
case 1:
$resultSample->version_number = $field; // iiV2
break;
case 2:
$resultSample->isolate_number = $field; // is000015F278BD
break;
case 4:
$resultSample->patient_id = $field; // pi12009427
break;
case 5:
$patientNames = explode(',', $field ?? null);
if (count($patientNames) > 0) {
$resultSample->patient_name_last = trim($patientNames[0]); // Last name
}
if (count($patientNames) > 1) {
$resultSample->patient_name_first = trim($patientNames[1]); // First name
}
if (count($patientNames) > 2) {
$resultSample->patient_name_middle = trim($patientNames[2]); // Middle name
}
break;
case 6:
$resultSample->address_street = $field; // plMANINJAU
break;
case 12:
try {
$resultSample->message_datetime = Carbon::parse($field)->format('Y-m-d') ?? null;
}catch (Exception $e) {
$resultSample->message_datetime = date('Y-m-d');
}
break;
case 13:
try {
$resultSample->test_complete_datetime = Carbon::parse($field)->format('Y-m-d') ?? null;
}catch (Exception $e) {
$resultSample->test_complete_datetime = date('Y-m-d');
}
break;
case 14:
$resultSample->accession_number = substr($field, 6); // ci30112024.26859
break;
case 23:
$resultSample->organism = $field; // o2Staphylococcus haemolyticus
break;
}
}
}
}
//$resultSample->specimen_type = $parsedData['specimen_type'] ?? null; // Could be inferred
//$resultSample->test_id = $parsedData['test_id'] ?? null;
// Result Record
$resultSample->additional_result = json_encode($parsedData['antibiotics']);
// Menyimpan data yang sudah diparse
$resultSample->save();
Log::info("Data MTRL Berhasil di Parse dan di simpan ", $resultSample->toArray());
return response()->json(['message' => 'Data berhasil diproses dan disimpan.']);
} else {
$headerData = explode("|", $response);
if (isset($headerData[3])){
$accnumber = $headerData[47] ?? null;
$noregister = $headerData[16] ?? null;
$nama = $headerData[18] ?? null;
$urgensi = $headerData[50] ?? null; //A Critical R Normal
$iddokter = $headerData[33] ?? null;
$test_start_datetime = $headerData[52] ?? null;
$result_status_datetime = $headerData[59] ?? null;
$specimen_type = $headerData[60] ?? null;
$resulttype = $headerData[34] ?? null;
$resultstatus = $headerData[63] ?? null;
$preliminary = $headerData[40] ?? null; //P
$test_complete_datetime = $headerData[44] ?? null;
$tesid = $headerData[62] ?? null;
$alamat = $headerData[23] ?? null;
$instrumen = $resultData[2] ?? null;
$body_site = '';
$tengah = '';
$depan = '';
$akhir = '';
$suffix = '';
$title = '';
$concentration_unit = '';
$kode = '';
$antibiotic = '';
$city = '';
$state = '';
$zipcode = '';
$country = '';
if ($resulttype){
$getdataresult = explode('^', $resulttype);
$kode = $getdataresult[3] ?? '';
$concentration_unit = $getdataresult[4] ?? '';
}
if ($specimen_type){
$getdata = explode('\n', $specimen_type);
$specimen_type = $getdata[0];
$body_site = $getdata[1] ?? '';
}
if ($tesid){
$gettgl = explode('^', $tesid);
$tesid = $gettgl[3] ?? null;
}
if ($instrumen){
$gettgl = explode('^', $instrumen);
$instrumen = $gettgl[0];
$media_assay_type = $gettgl[1] ?? null;
$protocol_length = $gettgl[2] ?? null;
$instrument_number = $gettgl[3] ?? null;
$instrument_location = $gettgl[4] ?? null;
$protocol_name = $gettgl[5] ?? null;
} else {
$media_assay_type = null;
$protocol_length = null;
$instrument_number = null;
$instrument_location = null;
$protocol_name = null;
}
if ($isolate == '' OR $isolate == '0' OR is_null($isolate)){
$isolate = false;
} else { $isolate = true; }
if ($test_complete_datetime){
$test_complete_datetime = substr($test_complete_datetime, 0, 14);
//$test_complete_datetime = Carbon::parse($test_complete_datetime)->format('Y-m-d H:i:s');
}
if ($result_status_datetime){
$result_status_datetime = substr($result_status_datetime, 0, 14);
//$result_status_datetime = Carbon::parse($result_status_datetime)->format('Y-m-d H:i:s');
}
if ($test_start_datetime){
$test_start_datetime = substr($test_start_datetime, 0, 14);
//$test_start_datetime = Carbon::parse($test_start_datetime)->format('Y-m-d H:i:s');
}
if ($nama){
$getnama = explode('\015', $nama);
$nama = $getnama[0];
$getnama = explode('\n', $nama);
$nama = $getnama[0];
$akhir = $getnama[1] ?? '';
$depan = $getnama[2] ?? '';
$tengah = $getnama[3] ?? '';
$suffix = $getnama[4] ?? '';
$title = $getnama[5] ?? '';
$nama = $nama.$akhir;
}
if ($alamat){
$getnama = explode('^', $alamat);
$alamat = $getnama[0];
$city = $getnama[1] ?? '';
$state = $getnama[2] ?? '';
$zipcode = $getnama[3] ?? '';
$country = $getnama[4] ?? '';
}
if ($test_start_datetime == ''){ $test_start_datetime = null; }
if ($result_status_datetime == ''){ $result_status_datetime = null; }
if ($test_complete_datetime == ''){ $test_complete_datetime = null; }
$resultSample->sender_name = $headerData[4] ?? 'Unkown';
$resultSample->version_number = $headerData[12] ?? 'V0.0';
$resultSample->message_datetime = $test_start_datetime;
// Patient Record (Segment P)
$resultSample->patient_id = $noregister; // '11607396'
$resultSample->patient_name_last = $nama; // 'ZAKIYATUN'
$resultSample->patient_name_first = $depan; // 'O'
$resultSample->patient_name_middle = $tengah;
$resultSample->patient_name_suffix = $suffix;
$resultSample->patient_name_title = $title;
$resultSample->patient_dob = $headerData[20] ?? null;
$resultSample->patient_sex = $headerData[21] ?? null;
$resultSample->address_street = $alamat;
$resultSample->address_city = $city;
$resultSample->address_state = $state;
$resultSample->address_zip = $zipcode;
$resultSample->address_country = $country;
$resultSample->patient_phone = $headerData[25] ?? null;
$resultSample->admitting_physician = $headerData[27] ?? null;
$resultSample->patient_diagnosis = $headerData[33] ?? null;
$resultSample->patient_therapy = json_encode($headerData);
$resultSample->admit_datetime = null;
$resultSample->room_number = $headerData[46] ?? '00001';
$resultSample->hospital_service = $headerData[45] ?? 'RSSA Malang';
$resultSample->hospital_client = $orderData[4] ?? 'Lab Mikro';
// Order Record (Segment O)
$resultSample->accession_number = $accnumber; // '12345'
$resultSample->isolate_number = $orderData[5] ?? null; // '67890'
$resultSample->organism = $orderData[6] ?? null; // 'E. coli'
$resultSample->exclude_isolate_from_statistics = $isolate; // 'false'
$resultSample->specimen_type = $specimen_type;
$resultSample->body_site = $body_site;
$resultSample->test_id = $tesid; // 'Test123'
$resultSample->urgensi = $urgensi; //A Critical R Normal
// Result Record (Segment R)
$resultSample->result_type_code = $kode;
$resultSample->antibiotic = $antibiotic;
$resultSample->antibiotic_concentration = $concentration_unit; // '100mg'
$resultSample->antibiotic_concentration_units = $concentration_unit; // 'mg'
$resultSample->test_status = $resultstatus; // 'Completed'
$resultSample->result_data = json_encode($orderData); // Additional data (if any)
$resultSample->preliminary_final_status = $preliminary;
$resultSample->test_start_datetime = $test_start_datetime;
$resultSample->result_status_datetime = $result_status_datetime;
$resultSample->test_complete_datetime = $test_complete_datetime;
$resultSample->instrument_type = $instrumen;
$resultSample->media_assay_type = $media_assay_type;
$resultSample->protocol_length = $protocol_length;
$resultSample->instrument_number = $instrument_number;
$resultSample->instrument_location = $instrument_location;
$resultSample->protocol_name = $protocol_name;
$resultSample->additional_result = json_encode($resultData);
if ($noregister){
$resultSample->save();
Log::info("Data ASTM Berhasil di Parse dan di simpan ", $resultSample->toArray());
return response()->json(['message' => 'Data berhasil diproses dan disimpan.']);
}
} else {
Log::debug("Abaikan Data Berikut ". json_encode($headerData));
}
}
}
}
/**
* Proses data ASTM Response
*/
public function processAstmMessages($dataListener) {
foreach ($dataListener as $data) {
try {
// Ambil pesan ASTM dari kolom 'message' atau yang relevan
$response = $data->rawdt;
if ($data->alat == 'BD Mikro 1'){
if ($data->no_id != ''){
$rnmpas = $data->rnmpas;
$getnama = explode('|', $rnmpas);
$resultSample = new ResultSample();
$resultSample->sender_name = $data->alat;
$resultSample->message_datetime = $data->tgl_data;
$resultSample->version_number = 'V1.0';
$resultSample->patient_id = $data->urut;
$resultSample->patient_name_last= $getnama[0];
$resultSample->accession_number = $data->no_id;
$resultSample->test_status = $data->organisme;
$resultSample->save();
DataListiner::where('urut', $data->urut)->update([
'processed' => 1
]);
Log::info("Data ASTM BD ", $resultSample->toArray());
} else {
DataListiner::where('urut', $data->urut)->update([
'processed' => 9
]);
}
} else {
// Lakukan parsing menggunakan method/fungsi yang sudah dibuat
$result = $this->processAstmResponse($response, $data->alat);
// Jika berhasil, tandai data sudah diproses
if ($result) {
DataListiner::where('urut', $data->urut)->update([
'processed' => 1
]);
} else {
Log::debug($result);
}
}
} catch (\Exception $e) {
Log::critical($e->getMessage());
}
}
}
}
@@ -0,0 +1,88 @@
<?php
namespace App\Services;
use App\Models\Result;
class ResultProcessingService
{
// Proses untuk AST Result
public function processAstResult($rawData)
{
// Format: R|1| ^ ^ ^AST_MGIT^439400005678^P^0.5^ug/ml| INST_COMPLETE^105^^S| ...
// Parse raw data menjadi array atau objek
$resultData = explode('|', $rawData);
return [
'test_type' => 'AST',
'accession_number' => $resultData[2],
'antibiotic' => $resultData[3], // Seperti 'AST_MGIT'
'susceptibility' => $resultData[4], // Seperti 'P' atau 'R'
'value' => $resultData[5],
'status' => $resultData[6],
'completion_time' => $resultData[10]
];
}
// Proses untuk ID Result
public function processIdResult($rawData)
{
// Format: R|1| ^ ^ ^ID^Seq123|Complete^MYCBTUB^45678^RM_VRE| ...
$resultData = explode('|', $rawData);
return [
'test_type' => 'ID',
'sequence_number' => $resultData[3],
'result' => $resultData[4], // Status 'Complete'
'organism' => $resultData[5], // Organism name
'resistance_marker' => $resultData[6], // Resistance marker info
'completion_time' => $resultData[8]
];
}
// Proses untuk Growth and Detection Result
public function processGrowthDetectionResult($rawData)
{
// Format: R|1| ^ ^ ^GND_MGIT^430100001234|INST_POSITIVE ^87| ...
$resultData = explode('|', $rawData);
return [
'test_type' => 'Growth/Detection',
'accession_number' => $resultData[2],
'status' => $resultData[3], // Positif atau Negatif
'completion_time' => $resultData[7]
];
}
// Proses untuk Isolate Result
public function processIsolateResult($rawData)
{
// Format: R|1| ^^^AST^^P^100.0^ug/mL| ^^R^R^^MGIT_960_AST92| ...
$resultData = explode('|', $rawData);
return [
'test_type' => 'Isolate',
'isolate_result' => $resultData[3],
'antibiotic' => $resultData[4],
'value' => $resultData[5],
'status' => $resultData[6],
'completion_time' => $resultData[10]
];
}
// Proses untuk Other Test Result
public function processOtherResult($rawData)
{
// Format: R|1| ^ ^ ^OTHER^Seq123|Complete| ...
$resultData = explode('|', $rawData);
return [
'test_type' => 'Other',
'sequence_number' => $resultData[3],
'result' => $resultData[4],
'description' => $resultData[5],
'completion_time' => $resultData[6]
];
}
}
@@ -0,0 +1,26 @@
<?php
namespace App\Services;
use Carbon\Carbon;
use Fawno\PhpSerial\SerialDio;
use Fawno\PhpSerial\SerialConfig;
class SerialCommunicationService
{
public function sendMessageDevice1($message, $port = 'COM2')
{
$config = new SerialConfig();
$config->setBaudRate(9600);
$config->setParity(0);
$config->setDataBits(8);
$config->setStopBits(1);
$config->setFlowControl(0);
$serial = new SerialDio($port, $config);
$serial->open('r+b');
$serial->setBlocking(0);
$serial->setTimeout(0, 0);
$serial->send($message);
$pesan = $serial->read();
$serial->close();
return $pesan;
}
}
+18
View File
@@ -0,0 +1,18 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Setting extends Model
{
protected $table = "setting";
protected $fillable = [
'pacs',
'zfp',
'port',
'portzfp',
'username',
'password',
];
}
+11
View File
@@ -0,0 +1,11 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class SiraB extends Model
{
protected $table = "sirab";
protected $guarded = [];
}
+16
View File
@@ -0,0 +1,16 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Subjawaban extends Model
{
protected $table = "subjawaban";
protected $fillable = [
'kategori',
'judul',
'subjawaban',
'kesimpulan'
];
}
+37
View File
@@ -0,0 +1,37 @@
<?php
namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
{
use Notifiable;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'nama', 'username', 'password', 'previlage', 'tandatangan', 'photo', 'firebase'
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password'
];
public function getPhoto()
{
return $this->hasOne('App\XFiles','xmarking','photo');
}
public function getTandatangan()
{
return $this->hasOne('App\XFiles','xmarking','tandatangan');
}
}
+13
View File
@@ -0,0 +1,13 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Worklist extends Model
{
protected $table = "worklist";
protected $fillable = [
'aetitle', 'portnumber', 'ipaddress', 'location', 'modaliti'
];
}
+14
View File
@@ -0,0 +1,14 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class XFiles extends Model
{
protected $table = "x_files";
protected $primaryKey = "xid";
public $timestamps = false;
protected $guarded = [];
}