diff --git a/src/Controllers/SitbController.php b/src/Controllers/SitbController.php index 1c0d58f..051918d 100644 --- a/src/Controllers/SitbController.php +++ b/src/Controllers/SitbController.php @@ -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 { @@ -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); + } } } diff --git a/src/Helpers/ClaimDataParser.php b/src/Helpers/ClaimDataParser.php index 2ba1a92..d03181e 100644 --- a/src/Helpers/ClaimDataParser.php +++ b/src/Helpers/ClaimDataParser.php @@ -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. * @@ -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) { diff --git a/src/Http/Requests/SetKlaimDataRequest.php b/src/Http/Requests/SetKlaimDataRequest.php index 4d3baf0..19a0d03 100644 --- a/src/Http/Requests/SetKlaimDataRequest.php +++ b/src/Http/Requests/SetKlaimDataRequest.php @@ -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", @@ -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", @@ -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", @@ -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