Skip to content

Commit 9c957d2

Browse files
committed
✨ Feat: Enhance SITB handling in SitbController and ClaimDataParser, add validation rules in SetKlaimDataRequest
1 parent 6f25157 commit 9c957d2

File tree

3 files changed

+84
-10
lines changed

3 files changed

+84
-10
lines changed

src/Controllers/SitbController.php

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
namespace Halim\EKlaim\Controllers;
44

5+
use Illuminate\Http\Request;
6+
use Illuminate\Support\Facades\Log;
57
use App\Http\Controllers\Controller;
68
use Halim\EKlaim\Builders\BodyBuilder;
79
use Halim\EKlaim\Services\EklaimService;
8-
use Illuminate\Http\Request;
910

1011
class SitbController extends Controller
1112
{
@@ -22,16 +23,59 @@ public function validateSitb(Request $request)
2223
'nomor_register_sitb' => $request->nomor_register_sitb,
2324
]);
2425

25-
return EklaimService::send(BodyBuilder::prepared());
26+
try {
27+
$res = EklaimService::send(BodyBuilder::prepared());
28+
29+
if ($res->getStatusCode() != 200) {
30+
$res = $res->getData();
31+
throw new \Exception($res->metadata->message);
32+
}
33+
34+
$res = $res->getData();
35+
if (!$res->response->validation) {
36+
throw new \Exception($res->response->status . " - " . $res->response->detail);
37+
}
38+
39+
return $res;
40+
} catch (\Exception $e) {
41+
return response()->json([
42+
'message' => $e->getMessage()
43+
], 500);
44+
}
2645
}
2746

2847
public function inValidateSitb($sep)
2948
{
49+
// RE-EDIT FIRST
50+
BodyBuilder::setMetadata('reedit_claim');
51+
BodyBuilder::setData(["nomor_sep" => $sep]);
52+
53+
EklaimService::send(BodyBuilder::prepared())->then(function ($response) use ($sep) {
54+
Log::channel(config('eklaim.log_channel'))->info("RE-EDIT FROM SITB", [
55+
"sep" => $sep,
56+
"response" => $response,
57+
]);
58+
});
59+
60+
// SITB INVALIDATE
3061
BodyBuilder::setMetadata('sitb_invalidate');
3162
BodyBuilder::setData([
3263
'nomor_sep' => $sep
3364
]);
3465

35-
return EklaimService::send(BodyBuilder::prepared());
66+
try {
67+
$res = EklaimService::send(BodyBuilder::prepared());
68+
69+
if ($res->getStatusCode() != 200) {
70+
$res = $res->getData();
71+
throw new \Exception($res->metadata->message);
72+
}
73+
74+
return $res->getData();
75+
} catch (\Exception $e) {
76+
return response()->json([
77+
'message' => $e->getMessage()
78+
], 500);
79+
}
3680
}
3781
}

src/Helpers/ClaimDataParser.php

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,28 @@ public static function parse(Request $request)
2424
self::handleTarifRsData($request, $data);
2525
self::handlePelayananDarahData($request, $data);
2626
self::handlePersalinanData($request, $data);
27+
self::handleSitbData($request, $data);
2728

2829
return $data;
2930
}
3031

32+
/**
33+
* Menangani data SITB yang diperlukan.
34+
*
35+
* @param Request $request
36+
* @param array $data
37+
* @return void
38+
*/
39+
public static function handleSitbData(Request $request, array &$data)
40+
{
41+
$sitbFields = ['jkn_sitb_noreg'];
42+
foreach ($sitbFields as $field) {
43+
if ($request->has($field)) {
44+
$data[$field] = $request->input($field);
45+
}
46+
}
47+
}
48+
3149
/**
3250
* Memproses data optional dari request dan menyimpannya dalam array data.
3351
*
@@ -51,7 +69,15 @@ protected static function parseOptionalData(Request $request, array &$data)
5169
'terapi_konvalesen',
5270
'tarif_poli_eks',
5371
'nama_dokter',
54-
'kode_tarif'
72+
'kode_tarif',
73+
74+
'pemulasaraan_jenazah',
75+
'kantong_jenazah',
76+
'peti_jenazah',
77+
'plastik_erat',
78+
'desinfektan_jenazah',
79+
'mobil_jenazah',
80+
'desinfektan_mobil_jenazah'
5581
];
5682

5783
foreach ($optionalFields as $field) {

src/Http/Requests/SetKlaimDataRequest.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ public function authorize()
1414
public function rules()
1515
{
1616
return [
17-
"coder_nik" => "numeric|digits:16", // mandatory
17+
"coder_nik" => "numeric|digits:16", // mandatory
1818

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

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

38+
"add_payment_pct" => "numeric",
3839
"upgrade_class_ind" => "numeric|in:0,1",
3940
"upgrade_class_class" => "in:kelas_1,kelas_2,vip,vvip",
4041
"upgrade_class_los" => "numeric",
41-
"add_payment_pct" => "numeric",
42-
"upgrade_class_payor" => "in:1,2,3",
42+
"upgrade_class_payor" => "in:1,2,3", // 1: Peserta, 2: Pemberi Kerja, 3: Asuransi Tambahan
4343

4444
"birth_weight" => "numeric",
4545

4646
"sistole" => "numeric",
4747
"diastole" => "numeric",
4848

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

5151
"diagnosa" => "array",
5252
"procedure" => "array",
@@ -106,7 +106,6 @@ public function rules()
106106

107107
"terapi_konvalesen" => "nullable|numeric",
108108

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

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

118+
// ==== sitb
119+
"jkn_sitb_checked_ind" => "nullable|numeric|in:0,1",
120+
"jkn_sitb_noreg" => "nullable|string",
121+
// ==== / end sitb
122+
119123
// ==== apgar
120124
// ==== / end apgar
121125

0 commit comments

Comments
 (0)