Skip to content

Commit

Permalink
update cetak bpjs kontrol kunjungan
Browse files Browse the repository at this point in the history
  • Loading branch information
HidayatLahabu committed Jan 9, 2025
1 parent 9ca1e31 commit 593e0e0
Show file tree
Hide file tree
Showing 15 changed files with 732 additions and 18 deletions.
45 changes: 45 additions & 0 deletions app/Http/Controllers/Bpjs/BatalControlController.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,49 @@ public function filterByTime($filter)
'text' => $text,
]);
}

public function print(Request $request)
{
// Validasi input
$request->validate([
'dari_tanggal' => 'required|date',
'sampai_tanggal' => 'required|date|after_or_equal:dari_tanggal',
]);

// Ambil nilai input
$dariTanggal = $request->input('dari_tanggal');
$sampaiTanggal = $request->input('sampai_tanggal');
$dariTanggal = Carbon::parse($dariTanggal)->format('Y-m-d H:i:s');
$sampaiTanggal = Carbon::parse($sampaiTanggal)->endOfDay()->format('Y-m-d H:i:s');

$query = DB::connection('mysql6')->table('bpjs.rencana_kontrol as rekon')
->select(
'peserta.noKartu',
'rekon.noSurat',
'rekon.tglRencanaKontrol',
'peserta.nama as namaPasien',
'pasien.NORM as norm',
'poli.nama as ruangan',
'dpjp.nama as namaDokter'
)
->leftJoin('monitoring_rencana_kontrol as monitor', 'monitor.noSuratKontrol', '=', 'rekon.noSurat')
->leftJoin('bpjs.dpjp as dpjp', 'dpjp.kode', '=', 'rekon.kodeDokter')
->leftJoin('bpjs.poli as poli', 'poli.kode', '=', 'rekon.poliKontrol')
->leftJoin('bpjs.kunjungan as kunjunganBpjs', 'kunjunganBpjs.noSEP', '=', 'rekon.nomor')
->leftJoin('bpjs.peserta as peserta', 'peserta.noKartu', '=', 'kunjunganBpjs.noKartu')
->leftJoin('master.kartu_asuransi_pasien as asuransi', 'asuransi.NOMOR', '=', 'peserta.noKartu')
->leftJoin('master.pasien as pasien', 'pasien.NORM', '=', 'asuransi.NORM')
->whereNull('monitor.noSuratKontrol')
->whereBetween('rekon.tglRencanaKontrol', [$dariTanggal, $sampaiTanggal])
->orderByDesc('rekon.tglRencanaKontrol')
->orderBy('peserta.nama')
->get();

// Kirim data ke frontend menggunakan Inertia
return inertia("Bpjs/BatalKontrol/Print", [
'data' => $query,
'dariTanggal' => $dariTanggal,
'sampaiTanggal' => $sampaiTanggal,
]);
}
}
41 changes: 40 additions & 1 deletion app/Http/Controllers/Bpjs/MonitoringRekonController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

namespace App\Http\Controllers\Bpjs;

use Carbon\Carbon;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use App\Http\Controllers\Controller;
use App\Models\BpjsMonitorRekonModel;
use Illuminate\Http\Request;

class MonitoringRekonController extends Controller
{
Expand Down Expand Up @@ -144,4 +146,41 @@ public function detail($id)
'detail' => $query,
]);
}

public function print(Request $request)
{
// Validasi input
$request->validate([
'dari_tanggal' => 'required|date',
'sampai_tanggal' => 'required|date|after_or_equal:dari_tanggal',
]);

// Ambil nilai input
$dariTanggal = $request->input('dari_tanggal');
$sampaiTanggal = $request->input('sampai_tanggal');
$dariTanggal = Carbon::parse($dariTanggal)->format('Y-m-d H:i:s');
$sampaiTanggal = Carbon::parse($sampaiTanggal)->endOfDay()->format('Y-m-d H:i:s');

$query = DB::connection('mysql6')->table('bpjs.monitoring_rencana_kontrol as monitoring')
->select(
'monitoring.noSuratKontrol',
'monitoring.tglRencanaKontrol as tanggal',
'monitoring.noKartu',
'monitoring.nama as namaPasien',
'monitoring.namaPoliAsal',
'monitoring.namaDokter',
)
->leftJoin('bpjs.poli as poli', 'poli.kode', '=', 'monitoring.poliTujuan')
->whereBetween('monitoring.tglRencanaKontrol', [$dariTanggal, $sampaiTanggal])
->orderBy('monitoring.tglRencanaKontrol')
->orderBy('monitoring.nama')
->get();

// Kirim data ke frontend menggunakan Inertia
return inertia("Bpjs/Monitoring/Print", [
'data' => $query,
'dariTanggal' => $dariTanggal,
'sampaiTanggal' => $sampaiTanggal,
]);
}
}
77 changes: 72 additions & 5 deletions app/Http/Controllers/Bpjs/RencanaKontrolController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Http\Controllers\Bpjs;

use Carbon\Carbon;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use App\Http\Controllers\Controller;
Expand All @@ -16,17 +17,29 @@ public function index()
// Start building the query using the query builder
$query = DB::connection('mysql6')->table('bpjs.rencana_kontrol as rekon')
->select(
'pasien.NORM as norm',
'peserta.nama as namaPasien',
'rekon.noSurat',
'rekon.nomor as noSep',
'rekon.tglRencanaKontrol as tanggal',
'poli.nama as poliTujuan',
'pasien.NORM as norm',
'peserta.nama'
'dpjp.nama as namaDokter',
'pasienBpjs.nama as pasienNama',
)
->leftJoin('bpjs.kunjungan as kunjungan', 'kunjungan.noSEP', '=', 'rekon.nomor')
->leftJoin('bpjs.poli as poli', 'poli.kode', '=', 'rekon.poliKontrol')
->leftJoin('bpjs.dpjp as dpjp', 'dpjp.kode', '=', 'rekon.kodeDokter')
->leftJoin('bpjs.peserta as peserta', 'peserta.noKartu', '=', 'kunjungan.noKartu')
->leftJoin('master.kartu_identitas_pasien as pasien', 'pasien.NOMOR', '=', 'peserta.nik');
->leftJoin('bpjs.peserta as pasienBpjs', 'pasienBpjs.noKartu', '=', 'rekon.nomor')
->leftJoin('master.kartu_identitas_pasien as pasien', 'pasien.NOMOR', '=', 'peserta.nik')
->groupBy(
'rekon.noSurat',
'pasien.NORM',
'peserta.nama',
'rekon.tglRencanaKontrol',
'poli.nama',
'dpjp.nama',
'pasienBpjs.nama'
);

// Add search filter if provided
if ($searchSubject) {
Expand All @@ -39,7 +52,9 @@ public function index()
}

// Paginate the results
$data = $query->orderByDesc('rekon.tglRencanaKontrol')->paginate(10)->appends(request()->query());
$data = $query
->orderByDesc('rekon.tglRencanaKontrol')
->paginate(10)->appends(request()->query());

// Convert data to array
$dataArray = $data->toArray();
Expand Down Expand Up @@ -157,4 +172,56 @@ public function filterByTime($filter)
'text' => $text,
]);
}

public function print(Request $request)
{
// Validasi input
$request->validate([
'dari_tanggal' => 'required|date',
'sampai_tanggal' => 'required|date|after_or_equal:dari_tanggal',
]);

// Ambil nilai input
$dariTanggal = $request->input('dari_tanggal');
$sampaiTanggal = $request->input('sampai_tanggal');
$dariTanggal = Carbon::parse($dariTanggal)->format('Y-m-d H:i:s');
$sampaiTanggal = Carbon::parse($sampaiTanggal)->endOfDay()->format('Y-m-d H:i:s');

$query = DB::connection('mysql6')->table('bpjs.rencana_kontrol as rekon')
->select(
'pasien.NORM as norm',
'peserta.nama as namaPasien',
'rekon.noSurat',
'rekon.tglRencanaKontrol as tanggal',
'poli.nama as poliTujuan',
'dpjp.nama as namaDokter',
'pasienBpjs.nama as pasienNama',
)
->leftJoin('bpjs.kunjungan as kunjungan', 'kunjungan.noSEP', '=', 'rekon.nomor')
->leftJoin('bpjs.poli as poli', 'poli.kode', '=', 'rekon.poliKontrol')
->leftJoin('bpjs.dpjp as dpjp', 'dpjp.kode', '=', 'rekon.kodeDokter')
->leftJoin('bpjs.peserta as peserta', 'peserta.noKartu', '=', 'kunjungan.noKartu')
->leftJoin('bpjs.peserta as pasienBpjs', 'pasienBpjs.noKartu', '=', 'rekon.nomor')
->leftJoin('master.kartu_identitas_pasien as pasien', 'pasien.NOMOR', '=', 'peserta.nik')
->whereBetween('rekon.tglRencanaKontrol', [$dariTanggal, $sampaiTanggal])
->groupBy(
'rekon.noSurat',
'pasien.NORM',
'peserta.nama',
'rekon.tglRencanaKontrol',
'poli.nama',
'dpjp.nama',
'pasienBpjs.nama'
)
->orderBy('peserta.nama')
->orderBy('pasienBpjs.nama')
->get();

// Kirim data ke frontend menggunakan Inertia
return inertia("Bpjs/Rekon/Print", [
'data' => $query,
'dariTanggal' => $dariTanggal,
'sampaiTanggal' => $sampaiTanggal,
]);
}
}
9 changes: 8 additions & 1 deletion resources/js/Components/NavigationMaster.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ export default function NavigationMaster() {
route().current('referensi.index') ||
route().current('ruangan.index') ||
route().current('tindakan.index') ||
route().current('tindakanRuangan.index');
route().current('tindakanRuangan.index') ||
route().current('register');
};

return (
Expand Down Expand Up @@ -112,6 +113,12 @@ export default function NavigationMaster() {
>
Tindakan Ruangan
</NavLink>
<Link
href={route('register')}
className="bg-blue-500 text-white py-2 px-4 rounded hover:bg-blue-600"
>
Register
</Link>
</div>
)}
</div>
Expand Down
101 changes: 101 additions & 0 deletions resources/js/Pages/Bpjs/BatalKontrol/Cetak.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import React, { useEffect } from "react";
import { useForm } from "@inertiajs/react";
import InputLabel from "@/Components/InputLabel";
import TextInput from "@/Components/TextInput";

export default function Cetak() {

const { data, setData } = useForm({
dari_tanggal: '',
sampai_tanggal: ''
});

useEffect(() => {
const currentDate = new Date();
const currentYear = currentDate.getFullYear();
const currentMonth = (currentDate.getMonth() + 1).toString().padStart(2, '0');
const firstDayOfMonth = `${currentYear}-${currentMonth}-01`;
const formattedCurrentDate = currentDate.toISOString().split("T")[0];

setData(prevData => ({
...prevData,
dari_tanggal: firstDayOfMonth,
sampai_tanggal: formattedCurrentDate
}));
}, []);

const onJenisPenjaminChange = (selectedOption) => {
setData(prevData => ({ ...prevData, jenisPenjamin: selectedOption.value }));
};

const onJenisKunjunganChange = (selectedOption) => {
setData(prevData => ({ ...prevData, jenisKunjungan: selectedOption.value }));
};

const onSubmit = (e) => {
e.preventDefault();

// Filter out empty values
const filteredData = Object.fromEntries(Object.entries(data).filter(([_, v]) => v !== ''));

const queryString = new URLSearchParams(filteredData).toString();
window.open(route("batalKontrol.print") + "?" + queryString, "_blank");
};

return (
<div className="pt-2">
<div className="max-w-8xl mx-auto sm:px-6 lg:px-5">
<div className="bg-white dark:bg-indigo-950 overflow-hidden shadow-sm sm:rounded-lg">
<form
onSubmit={onSubmit}
className="p-4 sm-8 bg-white dark:bg-indigo-950 shadow sm:rounded-lg"
>
<h1 className="uppercase text-center font-bold text-2xl pt-2 text-white">Cetak Batal Kontrol</h1>

<div className="mt-4 flex space-x-4">
<div className="flex-1">
<InputLabel
htmlFor="dari_tanggal"
value="Dari Tanggal"
/>
<TextInput
type="date"
id="dari_tanggal"
name="dari_tanggal"
className="mt-1 block w-full"
value={data.dari_tanggal}
onChange={(e) => setData(prevData => ({ ...prevData, dari_tanggal: e.target.value }))}
/>
</div>

<div className="flex-1">
<InputLabel
htmlFor="sampai_tanggal"
value="Sampai Tanggal"
/>
<TextInput
type="date"
id="sampai_tanggal"
name="sampai_tanggal"
className="mt-1 block w-full"
value={data.sampai_tanggal}
onChange={(e) => setData(prevData => ({ ...prevData, sampai_tanggal: e.target.value }))}
/>
</div>
</div>

<div className="flex justify-between items-center mt-4">
<button
className="bg-red-500 py-1 px-3 text-gray-200 rounded shadow transition-all hover:bg-red-700 ml-auto"
type="submit"
>
Cetak
</button>
</div>
</form>
</div>
</div>
</div>
)
}

5 changes: 5 additions & 0 deletions resources/js/Pages/Bpjs/BatalKontrol/Index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import TableHeader from "@/Components/TableHeader";
import TableHeaderCell from "@/Components/TableHeaderCell";
import TableRow from "@/Components/TableRow";
import TableCell from "@/Components/TableCell";
import Cetak from './Cetak';

export default function Index({ auth, dataTable, header, text, totalCount, queryParams = {} }) {

Expand Down Expand Up @@ -115,6 +116,10 @@ export default function Index({ auth, dataTable, header, text, totalCount, query
</div>
</div>
</div>
<div className="w-full">
<Cetak
/>
</div>
</AuthenticatedLayout>
);
}
Loading

0 comments on commit 593e0e0

Please sign in to comment.