Skip to content

Onboarding

Ivan William edited this page Aug 29, 2026 · 1 revision

Onboarding (Node.js)

Quick start guide for getting up and running with satusehat-integration-node.

Prerequisites

  • Node.js 18+
  • Satu Sehat Developer account with OAuth2 credentials
  • npm, yarn, or pnpm

Step 1 — Install

npm install satusehat-integration-node

Step 2 — Configure Environment

SATUSEHAT_ENV=DEV           # DEV | STAGING | PROD
SATUSEHAT_CLIENT_ID=your_client_id
SATUSEHAT_CLIENT_SECRET=your_client_secret
SATUSEHAT_ORGANIZATION_ID=your_org_id

Step 3 — Verify Token

import 'dotenv/config';
import { OAuth2Client } from 'satusehat-integration-node';

async function main() {
  const client = new OAuth2Client({
    clientId: process.env.SATUSEHAT_CLIENT_ID!,
    clientSecret: process.env.SATUSEHAT_CLIENT_SECRET!,
    organizationId: process.env.SATUSEHAT_ORGANIZATION_ID!,
    environment: (process.env.SATUSEHAT_ENV as 'DEV' | 'STAGING' | 'PROD') || 'DEV',
  });

  const token = await client.getToken();
  console.log("Token OK:", token !== null);
}

main();

If you see Token OK: true — credentials are valid.

Step 4 — Your First POST

import 'dotenv/config';
import {
  OAuth2Client,
  SSRequest,
  Identifier,
  HumanName,
  PayloadBuilderPatient,
} from 'satusehat-integration-node';

async function main() {
  const oauth2 = new OAuth2Client({
    clientId: process.env.SATUSEHAT_CLIENT_ID!,
    clientSecret: process.env.SATUSEHAT_CLIENT_SECRET!,
    organizationId: process.env.SATUSEHAT_ORGANIZATION_ID!,
    environment: 'DEV',
  });

  const ss = new SSRequest(oauth2);

  const patient = new PayloadBuilderPatient()
    .addIdentifier(
      new Identifier({
        system: 'http://sys-ids.kemkes.go.id/nik',
        value: '3312345678901234',
      })
    )
    .addName(
      new HumanName({
        family: 'Sitorus',
        given: ['John'],
        use: 'official',
      })
    )
    .setGender('male')
    .setBirthDate('1990-01-15')
    .build();

  const response = await ss.post('Patient', patient);
  if (response.isSuccess()) {
    console.log('Patient ID:', response.getResourceId());
  } else {
    for (const msg of response.getErrorMessages()) {
      console.log('Error:', msg);
    }
  }
}

main();

Next Steps

  • Usage.md — Full usage guide
  • FHIR-Resources.md — All 38 FHIR resources with code examples
  • FHIR-DataTypes.md — 32 DataType classes reference
  • PayloadBuilder.md — Builder API documentation
  • SSRequest-SSResponse.md — HTTP layer & response handling
  • Error-Handling.md — Validation errors & Rule Numbers
  • Installation.md — Detailed installation guide

Clone this wiki locally