Skip to content

Commit

Permalink
✨ Feat: Enhance SITB handling in SitbController and ClaimDataParser, …
Browse files Browse the repository at this point in the history
…add validation rules in SetKlaimDataRequest
  • Loading branch information
halimkun committed Dec 21, 2024
1 parent 6f25157 commit 9c957d2
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 10 deletions.
50 changes: 47 additions & 3 deletions src/Controllers/SitbController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

namespace Halim\EKlaim\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
use App\Http\Controllers\Controller;
use Halim\EKlaim\Builders\BodyBuilder;
use Halim\EKlaim\Services\EklaimService;
use Illuminate\Http\Request;

class SitbController extends Controller
{
Expand All @@ -22,16 +23,59 @@ public function validateSitb(Request $request)
'nomor_register_sitb' => $request->nomor_register_sitb,
]);

return EklaimService::send(BodyBuilder::prepared());
try {
$res = EklaimService::send(BodyBuilder::prepared());

if ($res->getStatusCode() != 200) {
$res = $res->getData();
throw new \Exception($res->metadata->message);
}

$res = $res->getData();
if (!$res->response->validation) {
throw new \Exception($res->response->status . " - " . $res->response->detail);
}

return $res;
} catch (\Exception $e) {
return response()->json([
'message' => $e->getMessage()
], 500);
}
}

public function inValidateSitb($sep)
{
// RE-EDIT FIRST
BodyBuilder::setMetadata('reedit_claim');
BodyBuilder::setData(["nomor_sep" => $sep]);

EklaimService::send(BodyBuilder::prepared())->then(function ($response) use ($sep) {
Log::channel(config('eklaim.log_channel'))->info("RE-EDIT FROM SITB", [
"sep" => $sep,
"response" => $response,
]);
});

// SITB INVALIDATE
BodyBuilder::setMetadata('sitb_invalidate');
BodyBuilder::setData([
'nomor_sep' => $sep
]);

return EklaimService::send(BodyBuilder::prepared());
try {
$res = EklaimService::send(BodyBuilder::prepared());

if ($res->getStatusCode() != 200) {
$res = $res->getData();
throw new \Exception($res->metadata->message);
}

return $res->getData();
} catch (\Exception $e) {
return response()->json([
'message' => $e->getMessage()
], 500);
}
}
}
28 changes: 27 additions & 1 deletion src/Helpers/ClaimDataParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,28 @@ public static function parse(Request $request)
self::handleTarifRsData($request, $data);
self::handlePelayananDarahData($request, $data);
self::handlePersalinanData($request, $data);
self::handleSitbData($request, $data);

return $data;
}

/**
* Menangani data SITB yang diperlukan.
*
* @param Request $request
* @param array $data
* @return void
*/
public static function handleSitbData(Request $request, array &$data)
{
$sitbFields = ['jkn_sitb_noreg'];
foreach ($sitbFields as $field) {
if ($request->has($field)) {
$data[$field] = $request->input($field);
}
}
}

/**
* Memproses data optional dari request dan menyimpannya dalam array data.
*
Expand All @@ -51,7 +69,15 @@ protected static function parseOptionalData(Request $request, array &$data)
'terapi_konvalesen',
'tarif_poli_eks',
'nama_dokter',
'kode_tarif'
'kode_tarif',

'pemulasaraan_jenazah',
'kantong_jenazah',
'peti_jenazah',
'plastik_erat',
'desinfektan_jenazah',
'mobil_jenazah',
'desinfektan_mobil_jenazah'
];

foreach ($optionalFields as $field) {
Expand Down
16 changes: 10 additions & 6 deletions src/Http/Requests/SetKlaimDataRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ public function authorize()
public function rules()
{
return [
"coder_nik" => "numeric|digits:16", // mandatory
"coder_nik" => "numeric|digits:16", // mandatory

"tgl_masuk" => "date",
"tgl_pulang" => "date",
"cara_masuk" => "in:gp,hosp-trans,mp,outp,inp,emd,born,nursing,psych,rehab,other",
"jenis_rawat" => "numeric|in:1,2,3", // 1: Rawat Inap, 2: Rawat Jalan, 3: Rawat IGD
"jenis_rawat" => "numeric|in:1,2,3", // 1: Rawat Inap, 2: Rawat Jalan, 3: Rawat IGD
"kelas_rawat" => "numeric|in:1,2,3",

"adl_sub_acute" => "numeric|between:12,60",
Expand All @@ -35,18 +35,18 @@ public function rules()
"stop_dttm" => "date",
// ==== / end ventilator

"add_payment_pct" => "numeric",
"upgrade_class_ind" => "numeric|in:0,1",
"upgrade_class_class" => "in:kelas_1,kelas_2,vip,vvip",
"upgrade_class_los" => "numeric",
"add_payment_pct" => "numeric",
"upgrade_class_payor" => "in:1,2,3",
"upgrade_class_payor" => "in:1,2,3", // 1: Peserta, 2: Pemberi Kerja, 3: Asuransi Tambahan

"birth_weight" => "numeric",

"sistole" => "numeric",
"diastole" => "numeric",

"discharge_status" => "nullable|in:1,2,3,4,5", // 1: Atas persetujuan dokter, 2: Dirujuk, 3: Atas permintaan sendiri, 4: Meninggal, 5: Lain-lain
"discharge_status" => "nullable|in:1,2,3,4,5", // 1: Atas persetujuan dokter, 2: Dirujuk, 3: Atas permintaan sendiri, 4: Meninggal, 5: Lain-lain

"diagnosa" => "array",
"procedure" => "array",
Expand Down Expand Up @@ -106,7 +106,6 @@ public function rules()

"terapi_konvalesen" => "nullable|numeric",

// INFO : Tidak diperlukan per 1 Oktober 2021 (Manual Web Service 5.8.3b)
// "akses_naat" => "in:0,1",

"isoman_ind" => "nullable|numeric|in:0,1",
Expand All @@ -116,6 +115,11 @@ public function rules()
"dializer_single_use" => "nullable|numeric|in:0,1",
"kantong_darah" => "nullable|numeric",

// ==== sitb
"jkn_sitb_checked_ind" => "nullable|numeric|in:0,1",
"jkn_sitb_noreg" => "nullable|string",
// ==== / end sitb

// ==== apgar
// ==== / end apgar

Expand Down

0 comments on commit 9c957d2

Please sign in to comment.