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

@digitalmedika/satusehat

v0.9.0

Published

Type-safe TypeScript wrapper for SATUSEHAT API.

Readme

@digitalmedika/satusehat

Type-safe TypeScript SDK untuk SATUSEHAT API.

SDK ini dirancang untuk:

  • validasi request dan response dengan runtime schema
  • type inference end-to-end di TypeScript
  • OAuth2 client credentials
  • token cache in-memory atau file-based
  • ergonomi SDK yang cocok untuk backend service dan internal tooling

Helpers

Helper builder yang saat ini tersedia:

  • createEncounterBuilder
  • createEncounterClassFromConsultationMethod
  • createEncounterDiagnosis
  • createEncounterConditionBuilder
  • createEncounterIdentifier
  • createEncounterLocation
  • createEncounterParticipant
  • createEncounterQueueBuilder
  • createEncounterServiceProviderReference
  • createEncounterStatusTimeline
  • createEncounterMedicationBuilder
  • createEncounterMedicationAdministrationBuilder
  • createEncounterMedicationRequestBuilder
  • createEncounterProcedureBuilder
  • createEmergencyEncounterHistory
  • createChestXRayStudyBuilder
  • createCompleteBloodCountPanelBuilder
  • createLaboratoryPanelBuilder
  • createOrganizationBuilder
  • createRiskAssessmentBuilder
  • createServiceRequestImagingStudyDiagnosticReportBuilder
  • createServiceRequestSpecimenObservationBuilder

Installation

bun add @digitalmedika/satusehat

Untuk development library ini sendiri:

bun install

Quick Start

import {
  createEncounterBuilder,
  createSatuSehatClientFromEnv,
} from "@digitalmedika/satusehat";

const client = createSatuSehatClientFromEnv();

const patientResult = await client.patient.search({
  identifier: "https://fhir.kemkes.go.id/id/nik|9271060312000001",
});

const patient = patientResult.entry?.[0]?.resource;

if (!patient?.id) {
  throw new Error("Patient tidak ditemukan");
}

const encounterDraft = createEncounterBuilder({
  preset: "outpatient",
  identifier: {
    system: "http://sys-ids.kemkes.go.id/encounter/10000004",
    use: "official",
    value: "RJ-20240001",
  },
  status: "arrived",
  subject: {
    reference: `Patient/${patient.id}`,
    display: patient.name?.[0]?.text ?? "Pasien SATUSEHAT",
  },
  period: {
    start: "2024-04-01T01:00:00+00:00",
    end: "2024-04-01T02:00:00+00:00",
  },
  reasonCode: {
    coding: [
      {
        system: "http://terminology.hl7.org/CodeSystem/encounter-reason",
        code: "185349003",
        display: "Encounter for check up",
      },
    ],
  },
  diagnosis: {
    condition: {
      reference: "Condition/4bbbe654-14f5-4ab3-a36e-a1e307f67bb8",
    },
    use: {
      coding: [
        {
          system: "https://www.hl7.org/fhir/Codesystem-diagnosis-role",
          code: "AD",
          display: "Admission diagnosis",
        },
      ],
    },
    rank: 1,
  },
  location: {
    location: {
      reference: "Location/408ba28c-3115-4df5-85c6-60f15b44e7fa",
      display: "Poliklinik Rawat Jalan",
    },
    status: "active",
  },
  serviceProvider: {
    reference: "Organization/10000004",
    display: "RS SATUSEHAT",
  },
}).build();

const encounter = await client.encounter.create(encounterDraft);

console.log({
  patientId: patient.id,
  encounterId: encounter.id,
});

Environment Variables

Salin template dari .env.example.

Variable utama:

  • SATUSEHAT_ENV
  • SATUSEHAT_BASE_URL
  • SATUSEHAT_AUTH_BASE_URL
  • SATUSEHAT_DICOM_BASE_URL
  • SATUSEHAT_CLIENT_ID
  • SATUSEHAT_CLIENT_SECRET
  • SATUSEHAT_TOKEN_CACHE_FILE

Available Resources

Saat ini resource yang sudah tersedia:

  • allergyIntolerance
  • clinicalImpression
  • composition
  • condition
  • dicomRouter
  • diagnosticReport
  • encounter
  • imagingStudy
  • medicationAdministration
  • observation
  • nutritionOrder
  • procedure
  • medication
  • medicationRequest
  • serviceRequest
  • specimen
  • patient
  • organization
  • location
  • practitioner
  • practitionerRole
  • questionnaireResponse
  • riskAssessment

Token Handling

Secara default SDK mendukung:

  • token provider berbasis OAuth2 client credentials
  • cache token in-memory
  • file-based token store opsional untuk local testing/internal tools
  • refresh otomatis saat token expired atau mendekati expired
  • retry sekali saat menerima 401 jika token bisa di-invalidasi

Development

bun run typecheck
bun test
bun run build

Smoke test ke SATUSEHAT live:

bun run smoke:live

Untuk environment sandbox, smoke test akan memakai dummy patient resmi SATUSEHAT bila parameter test belum diisi.

Documentation

DICOM Router

SDK ini juga mendukung download file docker-compose.yml untuk DICOM Router SATUSEHAT:

const dockerCompose = await client.dicomRouter.downloadConfig();

Secara default SDK akan memakai endpoint berikut:

  • sandbox: https://api-satusehat-stg.dto.kemkes.go.id/dicom-router
  • production: https://api-satusehat.kemkes.go.id/dicom-router

Buy Us a Coffee

Kalau project ini membantu, kamu bisa dukung Digital Medika lewat Saweria:

Premium Support

Untuk premium support dan implementasi, hubungi:

QR WhatsApp Digital Medika