This unofficial SATUSEHAT FHIR PHP Library to help generate FHIR resources JSON and sent it via SATUSEHAT API.
As this is open source project, please kindly support this project by adding feature improvement or bug fixing. Styling fix (comma, delimiter, tab, spacing) will not be considered as contribution and will not considered for merge request. Significant contributor(s) will be mentioned to credits.
- Fork this repository
- Clone your forked repository
- Create new branch
- Make changes
- Commit and push
- Create pull request
Based on : SATUSEHAT Mandate PMK 24 tahun 2022 (Deadline December 2023) :
- OAuth2 (POST)
- KYC SATUSEHAT Platform (Centang Biru SATUSEHAT Mobile)
- Organization GET by ID
- Organization POST
- Organization PUT
- Location GET by ID
- Location POST
- Location PUT
- Patient GET by NIK
- Patient GET by ID
- Practitioner GET by NIK
- Practitioner GET by ID
- Encounter GET by ID
- Encounter POST
- Encounter PUT
- ICD-10 Masterdata (2022-12 Update)
- Condition GET by ID
- Condition POST
- Condition PUT
composer require ivanwilliammd/satusehat-integration
php artisan vendor:publish --provider="Satusehat\Integration\SatusehatIntegrationServiceProvider" --tag=config
php artisan vendor:publish --provider="Satusehat\Integration\SatusehatIntegrationServiceProvider" --tag=migrations
php artisan migrate
# Run to publish all assets regarding ICD-10
php artisan vendor:publish --provider="Satusehat\Integration\SatusehatIntegrationServiceProvider" --tag=icd10
# Run to migrate the ICD10 table
php artisan migrate
# Run to seed the data
php artisan db:seed --class=Icd10Seeder
Isilah Organization ID, Client ID dan Client Secret yang diberikan oleh SATUSEHAT di file .env
SATUSEHAT_ENV=xxxxxx (DEV/STG/PROD)
SATUSEHAT_AUTH_DEV=https://api-satusehat-dev.dto.kemkes.go.id/oauth2/v1
SATUSEHAT_FHIR_DEV=https://api-satusehat-dev.dto.kemkes.go.id/fhir-r4/v1
SATUSEHAT_AUTH_STG=https://api-satusehat-stg.dto.kemkes.go.id/oauth2/v1
SATUSEHAT_FHIR_STG=https://api-satusehat-stg.dto.kemkes.go.id/fhir-r4/v1
SATUSEHAT_AUTH_PROD=https://api-satusehat.kemkes.go.id/oauth2/v1
SATUSEHAT_FHIR_PROD=https://api-satusehat.kemkes.go.id/fhir-r4/v1
ORGID_DEV=xxxxxx
CLIENTID_DEV=xxxxxx
CLIENTSECRET_DEV=xxxxxx
ORGID_STG=xxxxxx
CLIENTID_STG=xxxxxx
CLIENTSECRET_STG=xxxxxx
ORGID_PROD=xxxxxx
CLIENTID_PROD=xxxxxx
CLIENTSECRET_PROD=xxxxxx
/**
* Uji coba echo Token yang sesuai dan di DB akan tersimpan
* Pastikan sudah mengisi konfigurasi di .env
*/
$client = new Satusehat\Integration\OAuth2Client;
echo $client->token();
*Note : Wajib dilakukan pada konfigurasi .env SATUEHAT_ENV=PROD
/**
* Pastikan sudah mengisi konfigurasi di .env
* Proses KYC tidak perlu lagi menggunakan deklarasi OAuth2Client->token()
*/
<?php
use Satusehat\Integration\KYC;
$kyc = new KYC;
// Isi nama verifikator & NIK verifikator untuk mendapatkan link KYC
$json = $kyc->generateUrl('{nama_verifikator}', '{nik_verifikator}');
$kyc_link = json_decode($json, true);
/**
* Melakukan route redirect ke link KYC
* saat ini hanya bisa dibuka pada tab baru / pop-up
* tidak bisa melalui iframe
*/
return redirect($kyc_link['data']['url']);
- Fungsi dasar GET, POST, PUT sudah ditambahkan pada kelas OAuth2Client.
- Proses GET / POST / PUT, tidak perlu lagi menggunakan deklarasi
OAuth2Client->token()
- Hasil balikan dari GET adalah kode status HTTP dan response body (JSON)
/**
* Hasil balikan dari GET / POST / PUT adalah kode status HTTP dan response body (JSON)
*/
<?php
use Satusehat\Integration\OAuth2Client;
$client = new OAuth2Client;
// Organization
[$statusCode, $response] = $client->get('Organization', '{id}');
// Location
[$statusCode, $response] = $client->get('Location', '{id}');
// Patient
[$statusCode, $response] = $client->get('Patient', '{id}');
// Practitioner
[$statusCode, $response] = $client->get('Practitioner', '{id}');
// Encounter
[$statusCode, $response] = $client->get('Encounter', '{id}');
// Condition
[$statusCode, $response] = $client->get('Condition', '{id}');
// Patient
[$statusCode, $response] = $client->get_by_nik('Patient', '{NIK Pasien}');
// Practitioner
[$statusCode, $response] = $client->get_by_nik('Practitioner', '{NIK Dokter}');
$client = new OAuth2Client;
$body = ...... ; // JSON Object
$resource = ......; // FHIR Resource (Organization, Location, Patient, Practitioner, Encounter, Condition)
// Format Agnostic POST
[$statusCode, $response] = $client->ss_post($resource, $body);
echo $statusCode, $response;
// Format Agnostic PUT
$id = ...... ; // SATUSEHAT response ID
[$statusCode, $response] = $client->ss_put($resource, $id, $body);
echo $statusCode, $response;
Untuk mempermudah pembuatan FHIR Object data type, dapat menggunakan class object yang sudah disediakan. Contoh penggunaan :
<?php
use Satusehat\Integration\FHIR\Organization;
use Satusehat\Integration\FHIR\Location;
use Satusehat\Integration\FHIR\Encounter;
use Satusehat\Integration\FHIR\Condition;
// Organization
$organization = new Organization;
$organization->addIdentifier('{kode_unik_suborganisasi}'); // unique string free text (increments / UUID / inisial)
$organization->setName('{nama_suborganisasi}'); // string free text
dd($organization->json());
// Location
$location = new Location;
$location->addIdentifier('{kode_unik_lokasi}'); // unique string free text (increments / UUID / inisial)
$location->setName('{nama_lokasi}'); // string free text
$location->addPhysicalType('{tipe_lokasi}'); // ro = ruangan, bu = bangunan, wi = sayap gedung, ve = kendaraan, ho = rumah, ca = kabined, rd = jalan, area = area. Default bila tidak dideklarasikan = ruangan
dd($location->json());
// Encounter
$encounter = new Encounter;
/**
* timestamp_kedatangan, timestamp_pemeriksaan, timestamp_pulang = format Y-m-dTH:i:s+UTC
* Contoh : 31 Desember 2022 15:45 WIB : 2022-12-31T15:45:00+07:00
*/
$statusHistory = ['arrived' => '{timestamp_kedatangan}',
'in-progress' => '{timestamp_pemeriksaan}',
'finished' => '{timestamp_pulang}'];
$encounter->addRegistrationId('{kode_registrasi}'); // unique string free text (increments / UUID)
$encounter->addStatusHistory($statusHistory); // array of timestamp
$encounter->setConsultationMethod('{metode_konsultasi}'); // RAJAL, IGD, RANAP, HOMECARE, TELEKONSULTASI
$encounter->setSubject('{id_patient}', '{nama_pasien}'); // ID SATUSEHAT Pasien dan Nama SATUSEHAT
$encounter->addParticipant('{id_practitioner}', '{nama_dokter}'); // ID SATUSEHAT Dokter, Nama Dokter
$encounter->addLocation('{id_location}', '{nama_poli}'); // ID SATUSEHAT Location, Nama Poli
$encounter->addDiagnosis('{id_condition}', '{kode_icd_10}'); // ID SATUSEHAT Condition, Kode ICD10
$dd($encounter->json());
// Condition
$condition = new Condition;
$condition->addClinicalStatus('{status_klinis}'); // active, inactive, resolved. Default bila tidak dideklarasi = active
$condition->addCategory('{kategori}'); // Diagnosis, Keluhan. Default : diagnosis
$condition->addCode('{kode_icd_10}'); // Kode ICD10
$condition->setSubject('{id_patient}', '{nama_pasien}'); // ID SATUSEHAT Pasien dan Nama SATUSEHAT
$condition->setEncounter('{id_encounter}'); // ID SATUSEHAT Encounter
$condition->setOnsetDateTime('{timestamp_onset}'); // timestamp onset. Timestamp sekarang
$condition->setRecordedDate('{timestamp_recorded}'); // timestamp recorded. Timestamp sekarang
$condition->json();
/**
* Proses GET / POST / PUT melalui FHIR class Object, tidak perlu lagi menggunakan deklarasi kelas OAuth2Client
* Hasil balikan dari POST & PUT adalah kode status HTTP dan response body (JSON)
*/
// Organization
[$statusCode, $response] = $organization->post();
[$statusCode, $response] = $organization->put('{organization_id}');
// Location
[$statusCode, $response] = $location->post();
[$statusCode, $response] = $location->put('{location_id}');
// Encounter
[$statusCode, $response] = $encounter->post();
[$statusCode, $response] = $encounter->put('{encounter_id}');
// Condition
[$statusCode, $response] = $condition->post();
[$statusCode, $response] = $condition->put('{condition_id}');
Please see CHANGELOG for more information on what has changed recently.
The MIT License (MIT). Please see License File for more information.