Repository navigation
Onboarding
Bahasa / Language: English · Bahasa Indonesia
Quick start for satusehat-integration. The client is synchronous — requests under the hood —
so there is no async/await anywhere in the SDK.
- Python 3.10+
- A Satu Sehat developer account with OAuth2 credentials
pip
pip install satusehat-integrationCheck 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__)"SATUSEHAT_ENV=DEV # DEV | STG | PROD
SATUSEHAT_CLIENT_ID=your_client_id
SATUSEHAT_CLIENT_SECRET=your_client_secret
SATUSEHAT_ORGANIZATION_ID=your_org_idimport 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.
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
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="https://fhir.kemkes.go.id/id/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)The NIK system is written as a literal here because this SDK has no SatusehatNonStandard class — the
constant exists in the PHP package. The value is the same: https://fhir.kemkes.go.id/id/nik, lower case.
- 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
Mulai cepat untuk satusehat-integration. Kliennya sinkron — memakai requests — jadi tidak ada
async/await di SDK ini.
- Python 3.10+
- Akun Satu Sehat developer dengan kredensial OAuth2
pip
pip install satusehat-integrationPastikan 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__)"SATUSEHAT_ENV=DEV # DEV | STG | PROD
SATUSEHAT_CLIENT_ID=your_client_id
SATUSEHAT_CLIENT_SECRET=your_client_secret
SATUSEHAT_ORGANIZATION_ID=your_org_idimport 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.
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
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="https://fhir.kemkes.go.id/id/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)System NIK ditulis sebagai literal di sini karena SDK ini belum punya kelas SatusehatNonStandard —
konstanta itu ada di paket PHP. Nilainya sama: https://fhir.kemkes.go.id/id/nik, huruf kecil.
- 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