Skip to content

update vclaim sedikit - #370

Merged
basoro merged 2 commits into
basoro:masterfrom
adlylee:latest-kirana
Jul 2, 2026
Merged

update vclaim sedikit#370
basoro merged 2 commits into
basoro:masterfrom
adlylee:latest-kirana

Conversation

@adlylee

@adlylee adlylee commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Summary by Sourcery

Support both creation and update of SEP records with corresponding VClaim API calls, enhance PRB-related control features, and refine referral (rujukan) management and display across VClaim views, while adjusting Vedika rendering and exposing an additional Farmasi JS endpoint.

New Features:

  • Allow updating existing SEP records via the VClaim update endpoint alongside current insert behavior.
  • Add PRB form data to planned control (Rencana Kontrol) requests and expose PRB-related input fields in the control UI.
  • Introduce server and UI support for deleting outgoing referrals (rujuk keluar) from both BPJS and local storage.

Bug Fixes:

  • Correct SEP discharge date updates to use the proper POST field when updating local SEP records.
  • Fix outgoing referral save logic to use the correct referral type field instead of an unrelated date value.
  • Ensure rujuk keluar displays and related JS target the correct containers and identifiers, including fields for referral numbers and updated column mappings.
  • Adjust VClaim rujukan delete behavior to optionally return raw JSON for internal reuse without always printing a response.
  • Fix diagnosis field mapping when selecting an existing SEP so the diagnosis code is populated correctly into the form.
  • Avoid double‑escaping Vedika data by passing the raw assign array to the template renderer.

Enhancements:

  • Extend VClaim rujukan queries to join SEP data so outgoing referrals include card and visit numbers in both list and display views.
  • Pre-fill SEP referral origin name from participant provider info when the field is empty to streamline SEP entry.
  • Tidy SEP history button layout by separating action buttons into distinct elements.
  • Prepare Farmasi for additional JS by wiring up a dedicated darurat stok JS endpoint with a placeholder for farmasi.js.

@vercel

vercel Bot commented Jul 2, 2026

Copy link
Copy Markdown

@adlylee is attempting to deploy a commit to the basoro's projects Team on Vercel.

A member of the Team first needs to authorize it.

@sourcery-ai

sourcery-ai Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Adds SEP update support, refines rujukan keluar (referral out) handling and display, introduces PRB metadata on control plans, tweaks several VClaim views/JS behaviors, relaxes HTML escaping in Vedika index, and adds a minor debug comment in Farmasi.

Sequence diagram for new SEP insert vs update flow in postSaveSEP

sequenceDiagram
  actor User
  participant Browser
  participant VclaimAdmin as Vclaim_Admin
  participant BpjsService
  participant BPJS_API

  User->>Browser: Submit SEP form
  Browser->>VclaimAdmin: POST postSaveSEP(no_sep, form_fields)
  alt [no_sep is empty]
    VclaimAdmin->>VclaimAdmin: Build insert SEP payload (noKartu, tglSep, rujukan, jaminan, ...)
    VclaimAdmin->>VclaimAdmin: Set url = api_url + SEP/2.0/insert
    VclaimAdmin->>BpjsService: post(url, data, consid, secretkey, user_key, tStamp)
  else [no_sep is present]
    VclaimAdmin->>VclaimAdmin: Build update SEP payload (noSep, klsRawat, jaminan, ...)
    VclaimAdmin->>VclaimAdmin: Set url = api_url + SEP/2.0/update
    VclaimAdmin->>BpjsService: put(url, data, consid, secretkey, user_key, tStamp)
  end
  BpjsService->>BPJS_API: HTTP request (POST or PUT)
  BPJS_API-->>BpjsService: JSON response
  BpjsService-->>VclaimAdmin: $output
  VclaimAdmin->>VclaimAdmin: json_decode($output)
  VclaimAdmin-->>Browser: Result message / redirect
  Browser-->>User: Show SEP save/update result
Loading

Sequence diagram for new rujuk keluar delete flow

sequenceDiagram
  actor User
  participant Browser
  participant VclaimAdmin as Vclaim_Admin
  participant BpjsService
  participant BPJS_API
  participant DB as Database

  User->>Browser: Click delete rujukan (hapus_rujuk)
  Browser->>VclaimAdmin: POST postDeleteRujukKeluar(no_sep, no_rujukan)
  VclaimAdmin->>VclaimAdmin: Build request[t_rujukan](noRujukan, user)
  VclaimAdmin->>VclaimAdmin: json_encode(data)
  VclaimAdmin->>VclaimAdmin: postDeleteRujukan(data, isReturn = true)
  VclaimAdmin->>BpjsService: delete(api_url + Rujukan/delete, data, consid, secretkey, user_key, tStamp)
  BpjsService->>BPJS_API: HTTP DELETE
  BPJS_API-->>BpjsService: JSON response
  BpjsService-->>VclaimAdmin: $output
  VclaimAdmin->>VclaimAdmin: json_decode($output) as json
  VclaimAdmin-->>VclaimAdmin: return json to postDeleteRujukKeluar
  alt [json.metaData.code == 200]
    VclaimAdmin->>DB: delete from bridging_rujukan_bpjs where no_sep, no_rujukan
    VclaimAdmin-->>Browser: "Data Rujukan telah dihapus!!"
  else
    VclaimAdmin->>DB: delete from bridging_rujukan_bpjs where no_sep, no_rujukan
    VclaimAdmin-->>Browser: metaData.message (HTML-escaped)
  end
  Browser-->>User: Show deletion result and refresh rujukkeluardisplay
Loading

File-Level Changes

Change Details Files
Support both insert and update flows when saving SEP, switching HTTP verb and payload shape based on presence of an existing SEP number.
  • Wrap SEP request payload construction in a conditional on empty/non-empty POST no_sep.
  • For new SEPs, keep the existing full t_sep payload and send it to SEP/2.0/insert using BpjsService::post.
  • For existing SEPs, build a reduced update payload including noSep, updated class, notes, diagnosis, poli, coverage, guarantee, DPJP, phone and user, and send it to SEP/2.0/update using BpjsService::put.
plugins/vclaim/Admin.php
Fix and extend VClaim rujukan/rujuk keluar behavior, including DB key usage, delete endpoint behavior, and display data.
  • Change the tglpulang DB update lookup to use POST sep instead of no_sep.
  • Allow postDeleteRujukan to optionally return the decoded JSON for reuse and bypass the HTML/redirect flow when called programmatically.
  • Add postDeleteRujukKeluar to delete outbound referrals via BPJS API and then remove the local bridging_rujukan_bpjs record.
  • Update rujuk keluar DB queries to join bridging_sep and select SEP card and visit numbers.
  • Correct tipeRujukan to read from POST tipe_rujuk instead of tanggal_periksa when saving outbound referrals.
plugins/vclaim/Admin.php
Enhance rujuk keluar admin UI to support deleting referrals and align displayed fields with new backend behavior.
  • Rename hidden field from no_surkon to no_rujukan and wire it through the delete flow.
  • Switch UI element IDs from *_kontrol to *_rujuk in rujukan keluar context and ensure the proper display container (rujukdisplay) is used after operations.
  • Replace the previous save handler in the delete button with a call to the new deleterujukkeluar endpoint, passing no_sep and no_rujukan only.
  • Simplify the .pilih_nosurat and click handler logic to just populate no_rujukan and no_sep and show the delete button.
plugins/vclaim/view/admin/rujukkeluar.html
plugins/vclaim/view/admin/rujukkeluar.display.html
Add PRB-related fields in control (Rencana Kontrol) handling and make PRB UI conditional on participant status.
  • Extend postSaveKontrol request payload with a formPRB object containing kdStatusPRB from POST id_prb.
  • Add PRB selection and clinical metric inputs (PRB code, blood pressure, fasting blood sugar) to the kontrol form UI, wrapped in a .prb container.
  • In kontrol JS, show or hide the .prb section based on the .prolainis_peserta text value (Potensi PRB).
  • Include id_prb in the AJAX payload when saving control data.
plugins/vclaim/Admin.php
plugins/vclaim/view/admin/kontrol.html
Improve SEP form behavior for editing existing SEPs and auto-filling referral origin.
  • On focus/click of sep_asal_rujukan_nama, auto-fill from prov_umum_peserta text if the field is empty.
  • In the SEP history .ubah_sep handler, write the diagnosa value into sep_diagnosa_kode instead of sep_diagnosa_nama and log it to the console.
  • When submitting the SEP form, include get_no_sep as no_sep in the POST so the server can distinguish between create and update flows.
  • Slightly reformat the generated action buttons for SEP history entries without changing semantics.
plugins/vclaim/view/admin/form.sep.html
Adjust rujuk keluar display columns and data sources to match new model fields.
  • Update table headers to show Tgl. Rujukan and Tgl. Periksa and drop the Dokter column.
  • Bind displayed dates and poli name to tglRujukan, tglRencanaKunjungan, and nama_poliRujukan fields.
  • Use no_rujukan instead of no_surat for displayed referral numbers and associated data attributes in the rujuk keluar display list.
plugins/vclaim/view/admin/rujukkeluar.display.html
Relax HTML escaping in Vedika index rendering and add a small debug comment in Farmasi JS endpoint.
  • Change Vedika anyIndex to pass $this->assign directly into the template instead of wrapping it with htmlspecialchars_array, allowing raw data to be rendered/escaped by the view as needed.
  • Add a commented-out echo line in Farmasi getDaruratStokJS to easily switch to serving farmasi.js instead of daruratstok.js during debugging.
plugins/vedika/Admin.php
plugins/farmasi/Admin.php

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@basoro
basoro merged commit 57aa207 into basoro:master Jul 2, 2026
2 of 4 checks passed

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 2 issues, and left some high level feedback:

  • In postDeleteRujukKeluar, the user field is hardcoded to "Coba Ws"; consider wiring this to the actual authenticated/SEP user (similar to other SEP calls) so auditing and API semantics stay consistent.
  • The new postDeleteRujukKeluar deletes the bridging_rujukan_bpjs row even when the BPJS API returns an error, which could leave local data out of sync with BPJS; you may want to only delete locally on success or clearly handle the desync case.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `postDeleteRujukKeluar`, the `user` field is hardcoded to "Coba Ws"; consider wiring this to the actual authenticated/SEP user (similar to other SEP calls) so auditing and API semantics stay consistent.
- The new `postDeleteRujukKeluar` deletes the `bridging_rujukan_bpjs` row even when the BPJS API returns an error, which could leave local data out of sync with BPJS; you may want to only delete locally on success or clearly handle the desync case.

## Individual Comments

### Comment 1
<location path="plugins/vclaim/Admin.php" line_range="2019-2022" />
<code_context>
   }

-  public function postDeleteRujukan($data = [])
+  public function postDeleteRujukan($data = [],$isReturn = true)
   {
     date_default_timezone_set('UTC');
</code_context>
<issue_to_address>
**question (bug_risk):** Introducing `$isReturn` changes the behavior of existing callers of `postDeleteRujukan`.

With `$isReturn` defaulting to `true`, existing callers will now return `$json` instead of executing the decryption/echo/exit block. Previously this method always wrote the response and terminated. Any routes expecting that side-effect may now just return an array and continue execution. Consider defaulting `$isReturn` to `false` and only enabling the new behavior from `postDeleteRujukKeluar()`, or ensure all existing call sites are updated for the new contract.
</issue_to_address>

### Comment 2
<location path="plugins/vclaim/Admin.php" line_range="3316-3318" />
<code_context>
+    $no_rujukan = $_POST['no_rujukan'];
+    $data = [
+      'request' => [
+        "t_rujukan" => [
+                "noRujukan" => $no_rujukan,
+                "user" => "Coba Ws"
+        ]
+      ]
</code_context>
<issue_to_address>
**suggestion:** Hard-coded BPJS `user` value in delete-rujukan request reduces traceability.

The delete payload sets `"user" => "Coba Ws"` instead of using the authenticated user (or the existing `sep_user`-style value). This breaks consistency with other BPJS calls and reduces auditability. Please pass the actual operator identity here, or at least source the value from a shared configuration rather than hard-coding it.

Suggested implementation:

```
  public function postDeleteRujukKeluar()
  {
    $no_sep = $_POST['no_sep'];
    $no_rujukan = $_POST['no_rujukan'];

    // Prefer configured BPJS user; fall back to authenticated operator username
    $bpjsUser = $this->config->item('bpjs_user');
    if (empty($bpjsUser) && $this->session && $this->session->userdata('username')) {
      $bpjsUser = $this->session->userdata('username');
    }

    $data = [
      'request' => [
        't_rujukan' => [
          'noRujukan' => $no_rujukan,
          'user'      => $bpjsUser,
        ],
      ],
    ];

```

1. Ensure that the CodeIgniter config item `bpjs_user` is defined (e.g. in `application/config/config.php` or a BPJS-specific config file) and, if needed, aligned with the existing `sep_user`/BPJS user configuration pattern used elsewhere in `plugins/vclaim/Admin.php`.
2. Confirm that the session library is loaded and that `username` (or whichever field represents the operator identity) is the correct key; if your app uses a different field (e.g. `user_id`, `nama_user`, or `sep_user`), update the `userdata(...)` call accordingly.
3. For full consistency with other BPJS calls, you may want to refactor the logic that determines `$bpjsUser` into a shared helper or class property (e.g. `$this->getBpjsUser()` or `$this->sep_user`) and reuse it across all VClaim request builders.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread plugins/vclaim/Admin.php
Comment on lines +2019 to 2022
public function postDeleteRujukan($data = [],$isReturn = true)
{
date_default_timezone_set('UTC');
$tStamp = strval(time() - strtotime("1970-01-01 00:00:00"));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question (bug_risk): Introducing $isReturn changes the behavior of existing callers of postDeleteRujukan.

With $isReturn defaulting to true, existing callers will now return $json instead of executing the decryption/echo/exit block. Previously this method always wrote the response and terminated. Any routes expecting that side-effect may now just return an array and continue execution. Consider defaulting $isReturn to false and only enabling the new behavior from postDeleteRujukKeluar(), or ensure all existing call sites are updated for the new contract.

Comment thread plugins/vclaim/Admin.php
Comment on lines +3316 to +3318
"t_rujukan" => [
"noRujukan" => $no_rujukan,
"user" => "Coba Ws"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Hard-coded BPJS user value in delete-rujukan request reduces traceability.

The delete payload sets "user" => "Coba Ws" instead of using the authenticated user (or the existing sep_user-style value). This breaks consistency with other BPJS calls and reduces auditability. Please pass the actual operator identity here, or at least source the value from a shared configuration rather than hard-coding it.

Suggested implementation:

  public function postDeleteRujukKeluar()
  {
    $no_sep = $_POST['no_sep'];
    $no_rujukan = $_POST['no_rujukan'];

    // Prefer configured BPJS user; fall back to authenticated operator username
    $bpjsUser = $this->config->item('bpjs_user');
    if (empty($bpjsUser) && $this->session && $this->session->userdata('username')) {
      $bpjsUser = $this->session->userdata('username');
    }

    $data = [
      'request' => [
        't_rujukan' => [
          'noRujukan' => $no_rujukan,
          'user'      => $bpjsUser,
        ],
      ],
    ];

  1. Ensure that the CodeIgniter config item bpjs_user is defined (e.g. in application/config/config.php or a BPJS-specific config file) and, if needed, aligned with the existing sep_user/BPJS user configuration pattern used elsewhere in plugins/vclaim/Admin.php.
  2. Confirm that the session library is loaded and that username (or whichever field represents the operator identity) is the correct key; if your app uses a different field (e.g. user_id, nama_user, or sep_user), update the userdata(...) call accordingly.
  3. For full consistency with other BPJS calls, you may want to refactor the logic that determines $bpjsUser into a shared helper or class property (e.g. $this->getBpjsUser() or $this->sep_user) and reuse it across all VClaim request builders.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants