npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@rsud-jailolo/sep-engine

v2.0.0

Published

SEP Decision Engine untuk APM BPJS Kesehatan - Library untuk menentukan jenis SEP secara otomatis

Readme

@rsud-jailolo/sep-engine

SEP Decision Engine untuk APM BPJS Kesehatan.

Library TypeScript ini menangani logika penentuan SEP secara otomatis - apakah pasien butuh SEP Kunjungan, SEP Kontrol, atau harus ke loket manual.

Instalasi

npm install @rsud-jailolo/sep-engine
# atau
yarn add @rsud-jailolo/sep-engine
# atau
pnpm add @rsud-jailolo/sep-engine

Fitur Utama

  • Pure Decision Engine - Logika murni tanpa side-effect, gak kirim data ke API manapun
  • Auto-detection - Otomatis tentukan jenis SEP berdasarkan data BPJS
  • Parameter Builder - Build parameter VClaim siap pakai
  • Validasi Lengkap - Cek kelayakan pasien, rujukan, dan SKDP
  • TypeScript First - Type-safe dengan autocomplete lengkap
  • Zero Dependencies - Gak butuh library external
  • Multi-Platform - Works di Node.js, Deno, Bun

Penggunaan Cepat

import { 
  processDecision, 
  toVClaimFormat,
  type BookingInput,
  type DecisionResult 
} from '@rsud-jailolo/sep-engine';

// Data dari kiosk APM
const bookingInput: BookingInput = {
  nomorkartu: '0002257655409',
  nik: '8201014606210001',
  nohp: '081234567890',
  kodepoli: 'ANA',
  tanggalperiksa: '2026-02-03',
  kodedokter: '243709',
  jampraktek: '08:00-12:00',
  norm: '0-10-84-43',
  jenispasien: 'JKN',
  pasienbaru: '0',
  nama: 'JOHN DOE',
  jKelamin: 'L',
  tglLahir: '1990-01-15'
};

// Proses keputusan SEP
const result: DecisionResult = processDecision({
  input: bookingInput,
  rujukanFKTP: dataRujukanFKTP,   // dari API BPJS
  kontrolList: dataKontrol,        // dari API BPJS
  peserta: dataPeserta,            // dari API BPJS
  config: {
    hospital: { 
      kodePPK: '0089S001', 
      namaPPK: 'RSUD JAILOLO', 
      user: 'APM' 
    }
  }
});

// Cek hasil
if (result.success && result.sepParameter) {
  // Build request body untuk BPJS VClaim
  const requestBody = toVClaimFormat(result.sepParameter);
  
  // Kirim ke BPJS (implementasi di service layer)
  // await bpjsService.insertSEP(requestBody);
}

Arsitektur: Pure Decision Maker

Library ini berfungsi murni sebagai decision maker dan parameter builder. Dia TIDAK:

  • ❌ Memanggil API BPJS
  • ❌ Mengirim SEP
  • ❌ Menangani dry run / simulasi
  • ❌ Memiliki HTTP client

Semua eksekusi mutasi (insertSEP, tambahAntrean, dll) adalah tanggung jawab layer aplikasi (Express, Hono, dll). Flag dryRun juga ditangani di layer aplikasi sebagai gate sebelum pemanggilan API BPJS.

┌──────────────┐     ┌──────────────────┐     ┌──────────────┐
│  Kiosk APM   │────▶│  Express / Hono  │────▶│  BPJS VClaim │
│  (Frontend)  │     │  (Orchestrator)  │     │  (API)       │
└──────────────┘     └────────┬─────────┘     └──────────────┘
                              │
                     ┌────────▼─────────┐
                     │  sep-engine      │
                     │  (Pure Logic)    │
                     │  - Decision      │
                     │  - Parameters    │
                     │  - Validation    │
                     └──────────────────┘

API Reference

Core Functions

processDecision(params)

Fungsi utama untuk menentukan jenis SEP.

const result = processDecision({
  input: BookingInput,           // Data dari kiosk
  rujukanFKTP?: RujukanData[],   // Rujukan dari Puskesmas/Klinik
  rujukanRS?: RujukanData[],     // Rujukan antar RS
  kontrolList?: KontrolData[],   // Surat kontrol (SKDP)
  peserta: PesertaData,          // Data peserta BPJS
  config: EngineConfig           // Config rumah sakit
});

Possible Results:

| Decision | Keterangan | |----------|------------| | sep_kunjungan | SEP Kunjungan Awal (pertama kali) | | sep_kontrol | SEP Kontrol Rawat Jalan | | sep_kontrol_ri | SEP Kontrol Pasca Rawat Inap | | requires_selection | Ada multiple rujukan, perlu pilih manual | | rejected | Ditolak, harus ke loket | | non_sep | Tidak perlu SEP (pasien non-JKN) |

toVClaimFormat(sepParameter)

Convert parameter SEP ke format BPJS VClaim API.

const requestBody = toVClaimFormat(result.sepParameter);
// Ready untuk POST ke /SEP/insert

validateParameter(sepParameter)

Validasi parameter sebelum kirim.

const validation = validateParameter(result.sepParameter);
if (!validation.valid) {
  console.error('Errors:', validation.errors);
}

Date Utilities

import { 
  isSKDPValid, 
  isRujukanValid, 
  calculateMasaBerlaku,
  calculateSKDPValidity 
} from '@rsud-jailolo/sep-engine';

// Cek SKDP masih valid (8 hari)
const skdpStatus = isSKDPValid('2026-01-28', '2026-02-03');
// { isValid: true, masaBerlaku: '2026-02-05', daysSinceIssued: 6 }

// Cek rujukan masih valid (90 hari)
const rujukanValid = isRujukanValid('2025-12-01', '2026-02-03');
// true (masih dalam 90 hari)

Validators

import { 
  checkPatientEligibility,
  classifyRujukan,
  classifyKontrol 
} from '@rsud-jailolo/sep-engine';

// Cek kelayakan pasien
const eligibility = checkPatientEligibility(bookingInput);
// { eligible: true, errors: [] }

// Klasifikasi rujukan
const classified = classifyRujukan(rujukanData, 'fktp', '2026-02-03');
// { jenis: 'rujukan_fktp', isValid: true, ... }

Contoh Implementasi

Express.js (dengan Dry Run di layer aplikasi)

import express from 'express';
import { processDecision, toVClaimFormat } from '@rsud-jailolo/sep-engine';

const router = express.Router();

router.post('/apm/tambahantrian', async (req, res) => {
  const input = req.body;
  const dryRun = input.dryRun || false; // flag ditangani di Express
  
  // Fetch data dari BPJS
  const [peserta, kontrolList, rujukanFKTP] = await Promise.all([
    bpjsService.getPeserta(input.nomorkartu),
    bpjsService.getKontrolList(input.nomorkartu),
    bpjsService.getRujukanFKTP(input.nomorkartu)
  ]);
  
  // Proses decision (engine gak tau soal dryRun)
  const decision = processDecision({
    input,
    peserta,
    kontrolList,
    rujukanFKTP,
    config: { hospital: RS_CONFIG }
  });
  
  // Dry run - return parameter aja, gak kirim ke BPJS
  if (dryRun) {
    return res.json({
      mode: 'dry_run',
      decision,
      sep_request_body: decision.sepParameter 
        ? toVClaimFormat(decision.sepParameter) 
        : null
    });
  }
  
  // Production - kirim ke BPJS
  if (decision.success && decision.sepParameter) {
    const sepResult = await bpjsService.insertSEP(
      toVClaimFormat(decision.sepParameter)
    );
    return res.json({ success: true, sep: sepResult });
  }
  
  return res.json(decision);
});

Hono

import { Hono } from 'hono';
import { processDecision, toVClaimFormat } from '@rsud-jailolo/sep-engine';

const app = new Hono();

app.post('/apm/tambahantrian', async (c) => {
  const input = await c.req.json();
  const dryRun = input.dryRun || false;
  
  const decision = processDecision({
    input,
    peserta: await getPeserta(input.nomorkartu),
    kontrolList: await getKontrolList(input.nomorkartu),
    rujukanFKTP: await getRujukanFKTP(input.nomorkartu),
    config: { hospital: RS_CONFIG }
  });
  
  if (dryRun) {
    return c.json({ mode: 'dry_run', decision });
  }
  
  // Production - kirim ke BPJS
  // ...
});

Cara Publish ke NPM

1. Setup Akun NPM

# Login ke npm (atau buat akun dulu di npmjs.com)
npm login

2. Setup Organization (untuk scoped package)

Kalo mau publish dengan scope @rsud-jailolo:

  1. Buka npmjs.com
  2. Klik avatar → Add Organization
  3. Buat organization dengan nama rsud-jailolo
  4. Invite member yang perlu

3. Build dan Test

# Install dependencies
cd sep-engine-ts
npm install

# Build
npm run build

# Test locally dengan npm pack
npm pack
# Ini bikin file .tgz yang bisa ditest di project lain

4. Test di Project Lain (Opsional)

# Di project lain, install dari tarball
npm install ../sep-engine-ts/rsud-jailolo-sep-engine-1.4.0.tgz

5. Publish

# Publish pertama kali (public)
npm publish --access public

# Update version (patch/minor/major)
npm version patch
npm publish

6. Update Version

# Patch (1.4.0 → 1.4.1) - bug fixes
npm version patch

# Minor (1.4.0 → 1.5.0) - fitur baru, backward compatible
npm version minor

# Major (1.4.0 → 2.0.0) - breaking changes
npm version major

# Lalu publish
npm publish

Changelog

Lihat CHANGELOG.md untuk detail perubahan tiap versi.

License

MIT © RSUD Jailolo