Skip to content

Onboarding

Ivan William Harsono edited this page Nov 17, 2026 · 5 revisions

Onboarding (Python)

Bahasa / Language: English · Bahasa Indonesia


English

Quick start for satusehat-integration. The client is synchronous — requests under the hood — so there is no async/await anywhere in the SDK.

Prerequisites

  • Python 3.10+
  • A Satu Sehat developer account with OAuth2 credentials
  • pip

Step 1 — Install

pip install satusehat-integration

Check that the import works before writing code — a broken wheel is a five-second diagnosis at this point and an hour of confusion later:

python -c "import satusehat_integration; print(satusehat_integration.__file__)"

Step 2 — Configure the environment

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

Step 3 — Verify the token

import os

from dotenv import load_dotenv

from satusehat_integration import OAuth2Client

load_dotenv()

client = OAuth2Client(
    satusehat_env=os.getenv("SATUSEHAT_ENV", "DEV"),
    client_id=os.getenv("SATUSEHAT_CLIENT_ID", ""),
    client_secret=os.getenv("SATUSEHAT_CLIENT_SECRET", ""),
    organization_id=os.getenv("SATUSEHAT_ORGANIZATION_ID", ""),
)

print("Token OK:", bool(client.token()))

token() is cached for 50 minutes; refresh_token() forces a new request.

Step 4 — Your first POST

import os

from dotenv import load_dotenv

from satusehat_integration import OAuth2Client, SSRequest
from satusehat_integration.builder import PatientBuilder
from satusehat_integration.datatype import Identifier, HumanName
from satusehat_integration.terminology import SatusehatNonStandard

load_dotenv()

oauth2 = OAuth2Client(
    satusehat_env=os.getenv("SATUSEHAT_ENV", "DEV"),
    client_id=os.getenv("SATUSEHAT_CLIENT_ID", ""),
    client_secret=os.getenv("SATUSEHAT_CLIENT_SECRET", ""),
    organization_id=os.getenv("SATUSEHAT_ORGANIZATION_ID", ""),
)
ss = SSRequest(oauth2)

patient = (
    PatientBuilder()
    .add_identifier(
        Identifier(system=SatusehatNonStandard.NIK, value="3312345678901234", use="official")
    )
    .add_name(HumanName(family="Sitorus", given=["John"], use="official"))
    .set_gender("male")
    .set_birth_date("1990-01-15")
    .build()
)

response = ss.post("Patient", patient)

if response.is_success():
    print("Patient ID:", response.get_resource_id())
else:
    for message in response.get_error_messages():
        print("Error:", message)

Next steps

  • Usage — the full usage guide
  • FHIR-Resources — 141 builders, 141 parsers
  • FHIR-DataTypes — the data type reference
  • PayloadBuilder — the builder API
  • SSRequest-SSResponse — the HTTP layer
  • Error-Handling — validation errors and rule numbers

Bahasa Indonesia

Mulai cepat untuk satusehat-integration. Kliennya sinkron — memakai requests — jadi tidak ada async/await di SDK ini.

Prasyarat

  • Python 3.10+
  • Akun Satu Sehat developer dengan kredensial OAuth2
  • pip

Langkah 1 — Pasang

pip install satusehat-integration

Pastikan impornya bekerja sebelum menulis kode — wheel yang rusak adalah diagnosis lima detik di titik ini dan kebingungan satu jam setelahnya:

python -c "import satusehat_integration; print(satusehat_integration.__file__)"

Langkah 2 — Konfigurasi environment

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

Langkah 3 — Pastikan token

import os

from dotenv import load_dotenv

from satusehat_integration import OAuth2Client

load_dotenv()

client = OAuth2Client(
    satusehat_env=os.getenv("SATUSEHAT_ENV", "DEV"),
    client_id=os.getenv("SATUSEHAT_CLIENT_ID", ""),
    client_secret=os.getenv("SATUSEHAT_CLIENT_SECRET", ""),
    organization_id=os.getenv("SATUSEHAT_ORGANIZATION_ID", ""),
)

print("Token OK:", bool(client.token()))

token() disimpan 50 menit; refresh_token() memaksa permintaan baru.

Langkah 4 — POST pertama Anda

import os

from dotenv import load_dotenv

from satusehat_integration import OAuth2Client, SSRequest
from satusehat_integration.builder import PatientBuilder
from satusehat_integration.datatype import Identifier, HumanName
from satusehat_integration.terminology import SatusehatNonStandard

load_dotenv()

oauth2 = OAuth2Client(
    satusehat_env=os.getenv("SATUSEHAT_ENV", "DEV"),
    client_id=os.getenv("SATUSEHAT_CLIENT_ID", ""),
    client_secret=os.getenv("SATUSEHAT_CLIENT_SECRET", ""),
    organization_id=os.getenv("SATUSEHAT_ORGANIZATION_ID", ""),
)
ss = SSRequest(oauth2)

patient = (
    PatientBuilder()
    .add_identifier(
        Identifier(system=SatusehatNonStandard.NIK, value="3312345678901234", use="official")
    )
    .add_name(HumanName(family="Sitorus", given=["John"], use="official"))
    .set_gender("male")
    .set_birth_date("1990-01-15")
    .build()
)

response = ss.post("Patient", patient)

if response.is_success():
    print("Patient ID:", response.get_resource_id())
else:
    for message in response.get_error_messages():
        print("Error:", message)

Langkah berikutnya

  • Usage — panduan pemakaian lengkap
  • FHIR-Resources — 141 builder, 141 parser
  • FHIR-DataTypes — referensi tipe data
  • PayloadBuilder — API builder
  • SSRequest-SSResponse — lapisan HTTP
  • Error-Handling — galat validasi dan nomor aturan

Clone this wiki locally