### Install Satusehat Mediator Client PHP Source: https://context7.com/kemenkesri/satusehat-mediator-client-php/llms.txt Install the library using Composer by adding it to your project's composer.json file or by running the composer require command. ```bash composer require kemenkesri/satusehat-mediator-client-php ``` ```json { "repositories": [ { "type": "git", "url": "https://github.com/kemenkesri/satusehat-mediator-client-php.git" } ], "require": { "kemenkesri/satusehat-mediator-client-php": "*@dev" } } ``` -------------------------------- ### Configure Composer for Installation Source: https://github.com/kemenkesri/satusehat-mediator-client-php/blob/main/README.md Add the repository and package requirement to your project's composer.json file. ```json { "repositories": [ { "type": "git", "url": "https://github.com/kemenkesri/satusehat-mediator-client-php.git" } ], "require": { "kemenkesri/satusehat-mediator-client-php": "*@dev" } } ``` -------------------------------- ### Run Unit Tests Source: https://github.com/kemenkesri/satusehat-mediator-client-php/blob/main/README.md Execute the test suite using composer and PHPUnit. ```bash composer install ./vendor/bin/phpunit ``` -------------------------------- ### Instantiate Encounter Model using Setter Methods Source: https://context7.com/kemenkesri/satusehat-mediator-client-php/llms.txt Create an Encounter object and use setter methods to populate its properties. This approach allows for more granular control and chaining of method calls. Use class constants for classification and status. ```php setLocalId('ENC-2024-00001') ->setClassification(Encounter::$CLASSIFICATION_AMB) // Konstanta: AMB, EMER, IMP ->setPeriodStart('2024-05-24T09:00:00+07:00') ->setPeriodInProgress('2024-05-24T09:30:00+07:00') ->setPeriodEnd('2024-05-24T10:00:00+07:00'); // Status akhir menggunakan konstanta $encounter->setStatusAkhir(Encounter::$STATUS_AKHIR_SEMBUH); // Opsi: STATUS_AKHIR_PULANG_PAKSA, STATUS_AKHIR_DIRUJUK, STATUS_AKHIR_MENINGGAL, STATUS_AKHIR_SEMBUH // Nilai yang diperbolehkan untuk classification $allowedClassifications = $encounter->getClassificationAllowableValues(); // Output: ['AMB', 'EMER', 'IMP'] ``` -------------------------------- ### Create and Populate Patient Model with Setter Methods Source: https://context7.com/kemenkesri/satusehat-mediator-client-php/llms.txt Instantiate a Patient object and populate its properties using setter methods. This approach allows for more granular control and can be chained for brevity. Multiple AddressPatient objects can be added to the patient's address list. ```php // Atau menggunakan setter methods $patient = new Patient(); $patient->setNik('3515120000000000') ->setName('NAMA LENGKAP PASIEN') ->setBirthDate('1990-01-15'); // Menambahkan alamat $alamatKTP = new AddressPatient(); $alamatKTP->setUse('home') ->setCountry('id') ->setProvince('35') ->setCity('3578') ->setDistrict('357801') ->setVillage('3578011002') ->setRt('001') ->setRw('002') ->setPostalCode('60111') ->setLine(['Jl. Contoh No. 123']); $alamatDomisili = new AddressPatient(); $alamatDomisili->setUse('temp') ->setProvince('31') ->setCity('3171') ->setLine(['Jl. Domisili No. 456']); $patient->setAddress([$alamatKTP, $alamatDomisili]); ``` -------------------------------- ### Instantiate Encounter Model using Constructor Array Source: https://context7.com/kemenkesri/satusehat-mediator-client-php/llms.txt Create an Encounter object by passing an associative array to the constructor. Ensure 'local_id', 'classification', and 'period_start' are provided. 'id' is optional if it's a new encounter. ```php 'encounter-uuid', // ID dari SATUSEHAT (opsional) 'local_id' => 'ENC-2024-00001', // ID lokal dari sistem RME 'classification' => 'AMB', // AMB=Rawat Jalan, EMER=IGD, IMP=Rawat Inap 'status_akhir' => 'sembuh', // pulang_paksa, dirujuk, meninggal, sembuh 'period_start' => '2024-05-24T09:00:00+07:00', 'period_in_progress' => '2024-05-24T09:30:00+07:00', 'period_end' => '2024-05-24T10:00:00+07:00', 'referral_no' => 'REF-001' // Nomor rujukan (jika ada) ]); ``` -------------------------------- ### Create and Populate Patient Model with Constructor Source: https://context7.com/kemenkesri/satusehat-mediator-client-php/llms.txt Instantiate a Patient object using a constructor array, including basic patient details and a list of AddressPatient objects. The 'id' field is optional if the patient already exists in SATUSEHAT. ```php 'patient-uuid-from-satusehat', // ID dari SATUSEHAT (opsional) 'nik' => '3515120000000000', // NIK 16 digit (wajib) 'name' => 'NAMA LENGKAP PASIEN', // Nama sesuai KTP (wajib) 'birthDate' => '1990-01-15', // Format: YYYY-MM-DD (wajib) 'address' => [ new AddressPatient([ 'use' => 'home', // home = alamat KTP, temp = alamat domisili 'country' => 'id', // Kode negara ISO 3166-1 alpha-2 'province' => '35', // Kode Kemendagri 2 digit 'city' => '3578', // Kode Kemendagri 4 digit 'district' => '357801', // Kode Kemendagri 6 digit (kecamatan) 'village' => '3578011002', // Kode Kemendagri 10 digit (kelurahan) 'rt' => '001', 'rw' => '002', 'postal_code' => '60111', 'line' => ['Jl. Contoh No. 123, Blok A'] ]) ] ]); ``` -------------------------------- ### Instantiate Condition Model using Setter Methods Source: https://context7.com/kemenkesri/satusehat-mediator-client-php/llms.txt Create a Condition object and use setter methods to populate its properties. This method allows for chaining and explicit setting of diagnosis details. Note the different types for 'diagnosis_type'. ```php setCodeCondition('A15.0') ->setCodeSystem('icd-10') ->setCodeDetail('Tuberculosis of lung, confirmed by sputum microscopy') ->setCategory('encounter-diagnosis') ->setDiagnosisType('DD') // DD = Diagnosis Definitif ->setRank(1) ->setStatus('active') ->setOnsetDate('2024-05-01'); // Tipe diagnosis // AD = Admission Diagnosis // DD = Discharge Diagnosis / Diagnosis Definitif // CC = Chief Complaint // CM = Comorbidity // pre-op = Pre-operative Diagnosis // post-op = Post-operative Diagnosis // billing = Billing Diagnosis // Validasi if ($condition->valid()) { echo "Condition valid\n"; } ``` -------------------------------- ### Configure SATUSEHAT API Connection Source: https://context7.com/kemenkesri/satusehat-mediator-client-php/llms.txt Configure API connection settings using the Configuration class. This includes setting the endpoint URL, OAuth2 credentials, and other parameters for development and production environments. ```php getBaseUrl(); echo "Auth Type: " . $config->getAuthType(); // 'credential' atau 'bearer' ``` -------------------------------- ### Instantiate Condition Model using Constructor Array Source: https://context7.com/kemenkesri/satusehat-mediator-client-php/llms.txt Create a Condition object by passing an associative array to the constructor. Key fields include 'local_id', 'code_condition' (ICD-10), 'code_system', and 'category'. ```php 'condition-uuid', 'local_id' => 'COND-001', 'code_condition' => 'A15.0', // Kode ICD-10 'code_system' => 'icd-10', 'code_detail' => 'Tuberculosis of lung', 'category' => 'encounter-diagnosis', // encounter-diagnosis atau problem-list-item 'diagnosis_type' => 'DD', // AD, DD, CC, CM, pre-op, post-op, billing 'rank' => 1, // Urutan diagnosis (1 = utama) 'status' => 'active', // active, recurrence, relapse, inactive, remission, resolved, unknown 'onsetDate' => '2024-05-01', 'created' => '2024-05-24T09:00:00+07:00', 'recordDate' => '2024-05-24T09:00:00+07:00' ]); ``` -------------------------------- ### Manual Library Inclusion Source: https://github.com/kemenkesri/satusehat-mediator-client-php/blob/main/README.md Include the library manually by requiring the autoload file in your PHP script. ```php require_once('/path/to/satusehat-mediator-client-php/vendor/autoload.php'); ``` -------------------------------- ### Register Suspected TB Patient in PHP Source: https://context7.com/kemenkesri/satusehat-mediator-client-php/llms.txt Configures the API client, initializes the Terduga TB form, populates patient and clinical data, and submits the request to the SITB system. ```php setProfile(['TB']); $terduga->setOrganizationId('100011961'); $terduga->setLocationId('ef011065-38c9-46f8-9c35-d1fe68966a3e'); $terduga->setPractitionerNik('N10000001'); // Data pasien $patient = new Patient(); $patient->setNik("3515126510190001"); $patient->setName("FAUZIA HAYZA AHMAD"); $patient->setBirthDate("2019-10-25"); $patient->setAddress([ new AddressPatient([ "use" => "temp", "province" => "35", "city" => "3578", "district" => "357801", "village" => "3578011002", "rt" => "001", "rw" => "002", "postal_code" => "60111", "line" => ["Jl. Contoh No. 123"] ]) ]); $terduga->setPatient($patient); // Data terduga TB $terduga->setTbSuspect([ "id" => "2411101654557057", "tgl_daftar" => "2024-05-24", "asal_rujukan_id" => "3", // 1=Puskesmas, 2=RS, 3=Datang Sendiri, dll "fasyankes_id" => "1000063014", "jenis_fasyankes_id"=> "1", // 1=Puskesmas, 2=RS, 3=Klinik "terduga_tb_id" => "1", // 1=TB Paru, 2=TB Ekstra Paru "terduga_ro_id" => null, "tipe_pasien_id" => "1", // 1=Baru, 2=Kambuh, 3=Pindahan "status_dm_id" => "1", // 1=Tidak DM, 2=DM "status_hiv_id" => "3" // 1=Reaktif, 2=Non-Reaktif, 3=Tidak Diketahui ]); // Data encounter/kunjungan $terduga->setEncounter([ "local_id" => "9772321", "classification" => "AMB", "period_start" => "2024-05-24T09:28:01+07:00", "period_in_progress" => "2024-05-24T09:58:01+07:00", "period_end" => "2024-05-24T10:58:01+07:00" ]); // Tambah kondisi/diagnosis $terduga->addCondition( (new Condition())->setCodeCondition('Z10') // Kode ICD-10 ); // Build dan validasi $terduga->build(); $terduga->validate(); try { $response = $terduga->send(); print_r([ 'payload' => $terduga->getData(), 'response' => $response ]); } catch (RequestException $e) { echo "Error: " . $e->getMessage() . "\n"; $errorResponse = json_decode($e->getResponse()->getBody()->getContents()); print_r($errorResponse); } ``` -------------------------------- ### Retrieve Patient Information Source: https://github.com/kemenkesri/satusehat-mediator-client-php/blob/main/README.md Configure the API client and perform a POST request to fetch patient data. ```php 'https://api-satusehat-stg.dto.kemkes.go.id/oauth2/v1/accesstoken', 'tokenUrl' => 'https://api-satusehat-stg.dto.kemkes.go.id/oauth2/v1/refreshtoken', 'baseUrl' => 'https://mediator-satusehat.kemkes.go.id/api-dev/satusehat/rme/v1.0', // 'clientId' => $clientId, // 'clientSecret' => $clientSecret, 'bearerToken' => $bearerToken, ] ); $apiInstance = new PatientApi( // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. // This is optional, `GuzzleHttp\Client` will be used as default. new OAuthClient(Configuration::getDefaultConfiguration('development')) ); $body = new GetPatientRequest(); try { $result = $apiInstance->patientPost($body); print_r($result); } catch (Exception $e) { echo 'Exception when calling PatientApi->patientPost: ', $e->getMessage(), PHP_EOL; } ?> ``` -------------------------------- ### Submit TB Diagnosis Results - PHP Source: https://context7.com/kemenkesri/satusehat-mediator-client-php/llms.txt Use this snippet to configure the SatuSehat API client and submit TB diagnosis results. Ensure all required configuration constants and data models are correctly set before sending. ```php setProfile(['TB']); $form->setOrganizationId('100011961'); $form->setLocationId('ef011065-38c9-46f8-9c35-d1fe68966a3e'); $form->setPractitionerNik('N10000001'); // Data pasien $patient = new Patient(); $patient->setNik("3515126510190001"); $patient->setName("FAUZIA HAYZA AHMAD"); $patient->setBirthDate("2019-10-25"); $form->setPatient($patient); // Referensi terduga TB $form->setTbSuspect([ "id" => "2405101601149056", "fasyankes_id" => "1000119617", "jenis_fasyankes_id" => "1" ]); // Data encounter $form->setEncounter([ "local_id" => "2024-11-24 09:27:26.405593+07", "classification" => "AMB", "period_start" => "2024-11-24T09:28:01+07:00", "period_in_progress" => "2024-11-24T09:58:01+07:00", "period_end" => "2024-11-24T10:58:01+07:00" ]); $form->addCondition( (new Condition())->setCodeCondition("Z10") ); // Set data diagnosis $form ->setStatusPengobatan('not-started') ->setTanggalHasilDiagnosis('2024-11-24T09:28:01') ->setServiceRequest('N10000001') // NIK dokter yang melakukan diagnosis ->setXrayHasil('pos') // pos = Positif, neg = Negatif ->setXrayTanggalWaktu('2024-11-24T09:28:01') ->setXrayKesan('Infiltrat pada lobus superior paru kanan, sugestif TB Paru') ->setLokasiAnatomi('PTB') // PTB = Paru, EPTB = Ekstra Paru ->setHasilDiagnosis('1') // 1 = TB Terkonfirmasi ->setTipeDiagnosis('tb-bac') // tb-bac = TB Bakteriologis, tb-klinis = TB Klinis ->setTindakLanjutPengobatan('1') // 1 = Diobati, 2 = Dirujuk ->setTempatPengobatan('1000119617') // ID Faskes tempat pengobatan ->build(); $form->validate(); try { $response = $form->send(); echo "Diagnosis berhasil dikirim!\n"; print_r(['payload' => $form->getData(), 'response' => $response]); } catch (RequestException $e) { echo "Error: " . $e->getMessage() . "\n"; print_r(json_decode($e->getResponse()->getBody()->getContents())); } ``` -------------------------------- ### Retrieve Patient Information using PatientApi Source: https://context7.com/kemenkesri/satusehat-mediator-client-php/llms.txt Use this snippet to fetch patient details from SATUSEHAT by providing NIK, name, and birth date. Ensure the bearer token and configuration are set correctly before execution. Handles potential exceptions during the API call. ```php 'https://api-satusehat-stg.dto.kemkes.go.id/oauth2/v1/accesstoken', 'tokenUrl' => 'https://api-satusehat-stg.dto.kemkes.go.id/oauth2/v1/refreshtoken', 'baseUrl' => 'https://mediator-satusehat.kemkes.go.id/api-dev/satusehat/rme/v1.0', 'bearerToken' => $bearerToken, ] ); // Inisialisasi API dengan OAuth Client $apiInstance = new PatientApi( new OAuthClient(Configuration::getDefaultConfiguration('development')) ); // Buat request untuk mencari pasien $body = new GetPatientRequest([ 'profile' => ['TB'], // Profile yang digunakan (TB, ANC, dll) 'patient' => new PatientBasic([ 'nik' => '3515120000000000', 'name' => 'NAMA PASIEN', 'birthDate' => '1990-01-15' ]) ]); try { $result = $apiInstance->patientPost($body); // Hasil response $patient = $result->getPatient(); echo "Patient ID: " . $patient->getId() . "\n"; echo "NIK: " . $patient->getNik() . "\n"; echo "Nama: " . $patient->getName() . "\n"; echo "Tanggal Lahir: " . $patient->getBirthDate() . "\n"; // Alamat pasien $addresses = $patient->getAddress(); foreach ($addresses as $address) { echo "Provinsi: " . $address->getProvince() . "\n"; echo "Kota/Kabupaten: " . $address->getCity() . "\n"; } // Episode of Care (jika ada) $episodes = $result->getEpisodeOfCare(); foreach ($episodes as $episode) { echo "Episode ID: " . $episode->getId() . "\n"; echo "Status: " . $episode->getStatus() . "\n"; } } catch (Exception $e) { echo 'Error: ' . $e->getMessage() . "\n"; echo 'Code: ' . $e->getCode() . "\n"; } ``` -------------------------------- ### POST /patient Source: https://context7.com/kemenkesri/satusehat-mediator-client-php/llms.txt Retrieves patient information based on NIK, name, and birth date. ```APIDOC ## POST /patient ### Description Retrieves patient information from the SATUSEHAT platform based on NIK, name, and birth date. ### Method POST ### Request Body - **profile** (array) - Required - List of profiles used (e.g., TB, ANC) - **patient** (object) - Required - Patient identification details - **nik** (string) - Required - Nomor Induk Kependudukan - **name** (string) - Required - Full name of the patient - **birthDate** (string) - Required - Date of birth in YYYY-MM-DD format ### Request Example { "profile": ["TB"], "patient": { "nik": "3515120000000000", "name": "NAMA PASIEN", "birthDate": "1990-01-15" } } ### Response #### Success Response (200) - **patient** (object) - Patient demographic details including ID, NIK, name, birthDate, and address - **episodeOfCare** (array) - List of associated episode of care records ``` -------------------------------- ### Access Patient Data and Addresses Source: https://context7.com/kemenkesri/satusehat-mediator-client-php/llms.txt Retrieve patient information such as NIK, name, and birth date using getter methods. Iterate through the patient's addresses to access details like address type and street line. ```php // Mengakses data echo "NIK: " . $patient->getNik() . "\n"; echo "Nama: " . $patient->getName() . "\n"; echo "Tanggal Lahir: " . $patient->getBirthDate() . "\n"; foreach ($patient->getAddress() as $address) { echo "Alamat (" . $address->getUse() . "): "; echo implode(', ', $address->getLine()) . "\n"; echo "Kota: " . $address->getCity() . "\n"; } ``` -------------------------------- ### Submit RME Data to SATUSEHAT Source: https://context7.com/kemenkesri/satusehat-mediator-client-php/llms.txt Use this snippet to send RME data to SATUSEHAT. Ensure you have configured the API client with correct authentication and base URLs. The data includes patient, encounter, condition, and TB suspect details. ```php 'https://api-satusehat-stg.dto.kemkes.go.id/oauth2/v1/accesstoken', 'tokenUrl' => 'https://api-satusehat-stg.dto.kemkes.go.id/oauth2/v1/refreshtoken', 'baseUrl' => 'https://mediator-satusehat.kemkes.go.id/api-dev/satusehat/rme/v1.0', 'bearerToken' => 'your-bearer-token', ]); $apiInstance = new SubmitDataApi( new OAuthClient(Configuration::getDefaultConfiguration('development')) ); // Siapkan data pasien dengan alamat $patient = new Patient([ 'nik' => '3515120000000000', 'name' => 'NAMA PASIEN', 'birthDate' => '2019-10-25', 'address' => [ new AddressPatient([ 'use' => 'temp', // temp = alamat domisili, home = alamat KTP 'country' => 'id', 'province' => '35', // Kode Depdagri 2 digit provinsi 'city' => '3578', // Kode Depdagri 4 digit kab/kota 'district' => '357801', // Kode Depdagri 6 digit kecamatan 'village' => '3578011002',// Kode Depdagri 10 digit kelurahan 'rt' => '001', 'rw' => '002', 'postal_code' => '60111', 'line' => ['Jl. Contoh No. 123'] ]) ] ]); // Siapkan data encounter (kunjungan) $encounter = new Encounter([ 'local_id' => 'ENC-2024-001', 'classification' => 'AMB', // AMB = Ambulatory, EMER = Emergency, IMP = Inpatient 'period_start' => '2024-05-24T09:00:00+07:00', 'period_in_progress' => '2024-05-24T09:30:00+07:00', 'period_end' => '2024-05-24T10:00:00+07:00' ]); // Siapkan data kondisi/diagnosis $condition = new Condition([ 'code_condition' => 'A15.0', // Kode ICD-10 'category' => 'encounter-diagnosis', 'diagnosis_type' => 'DD' // DD = Diagnosis Diferensial ]); // Siapkan data terduga TB $tbSuspect = new TbSuspect([ 'tgl_daftar' => '2024-05-24', 'asal_rujukan_id' => '3', 'fasyankes_id' => '1000119617', 'jenis_fasyankes_id' => '1', 'terduga_tb_id' => '1', 'tipe_pasien_id' => '1', 'status_dm_id' => '1', 'status_hiv_id' => '3' ]); // Buat request submit $submitRequest = new SubmitRequest([ 'profile' => ['TB'], 'organization_id' => '100011961', 'location_id' => 'ef011065-38c9-46f8-9c35-d1fe68966a3e', 'practitioner_nik' => 'N10000001', 'patient' => $patient, 'encounter' => $encounter, 'condition' => [$condition], 'tb_suspect' => $tbSuspect ]); try { $result = $apiInstance->syncPost($submitRequest); // Response dari SATUSEHAT $satusehatResponses = $result->getSatusehat(); foreach ($satusehatResponses as $response) { echo "Resource Type: " . $response->getResourceType() . "\n"; echo "Resource ID: " . $response->getResourceID() . "\n"; echo "Status: " . $response->getStatus() . "\n"; echo "Location: " . $response->getLocation() . "\n"; } } catch (Exception $e) { echo 'Error: ' . $e->getMessage() . "\n"; } ``` -------------------------------- ### Submit TB Laboratory Examination Request Source: https://context7.com/kemenkesri/satusehat-mediator-client-php/llms.txt Configures the API client and populates the PermohonanLab form with patient, encounter, and clinical data before submission. ```php setProfile(['TB']); $form->setOrganizationId('100011961'); $form->setLocationId('ef011065-38c9-46f8-9c35-d1fe68966a3e'); $form->setPractitionerNik('N10000001'); // Data pasien $patient = new Patient(); $patient->setNik("3515126510190001"); $patient->setName("FAUZIA HAYZA AHMAD"); $patient->setBirthDate("2019-10-25"); $form->setPatient($patient); // Referensi terduga TB yang sudah terdaftar $form->setTbSuspect([ "id" => "2411101654557057", "fasyankes_id" => "100006298", "jenis_fasyankes_id" => "1", "terduga_tb_id" => "1", "tipe_pasien_id" => "1" ]); // Data encounter yang sudah ada $form->setEncounter([ "id" => "9a14708d-58cd-4c45-8d12-deb242fc9c18", "local_id" => "185", "classification" => "AMB", "period_start" => "2024-11-01T09:56:49+07:00", "period_in_progress" => "2024-11-01T09:56:49+07:00", "period_end" => "2024-11-01T09:56:55+07:00" ]); // Kondisi/diagnosis $form->addCondition( (new Condition()) ->setId('6c95dc8c-2f01-442f-abdd-7fd41162b094') ->setCodeCondition("A08.4") ); // Set detail permohonan lab $form->setTanggalPermohonan("2024-11-01") ->setDokterPengirim('10018234772') // NIK Dokter pengirim ->setFaskesTunjuan('100025765') // ID Faskes Lab tujuan ->setTanggalWaktuPengambilanContohUji("2024-11-01T10:10:00") ->setTanggalWaktuPengirimanContohUji("2024-11-01T12:10:00") ->setAlasanPemeriksaan('pemeriksaan_diagnosis') // pemeriksaan_diagnosis, follow_up, dll ->setDugaanLokasiAnatomi('PTB') // PTB = Paru, EPTB = Ekstra Paru ->setJenisPemeriksaan('tcm') // tcm, mikroskopis, biakan ->setJenisContohUji('dahak_sewaktu') // dahak_sewaktu, dahak_pagi, dll ->build(); $form->validate(); try { $response = $form->send(); echo "Permohonan Lab berhasil dikirim!\n"; print_r(['payload' => $form->getData(), 'response' => $response]); } catch (RequestException $e) { echo "Error: " . $e->getMessage() . "\n"; print_r(json_decode($e->getResponse()->getBody()->getContents())); } ``` -------------------------------- ### Submit TB Laboratory Results Source: https://context7.com/kemenkesri/satusehat-mediator-client-php/llms.txt Configures the API client and populates the TB laboratory form with patient, encounter, and examination data before submission. ```php Exception\\RequestException; use Mediator\\SatuSehat\\Lib\\Client\\Api\\SubmitDataApi; use Mediator\\SatuSehat\\Lib\\Client\\Configuration; use Mediator\\SatuSehat\\Lib\\Client\\ConfigurationConstant; use Mediator\\SatuSehat\\Lib\\Client\\Model\\Patient; use Mediator\\SatuSehat\\Lib\\Client\\Model\\Condition; use Mediator\\SatuSehat\\Lib\\Client\\OAuthClient; use Mediator\\SatuSehat\\Lib\\Client\\Profiles\\TB\\Forms\\HasilLab; require_once(__DIR__ . '/vendor/autoload.php'); Configuration::setConfigurationConstant( 'development', new ConfigurationConstant( 'https://api-satusehat-stg.dto.kemkes.go.id/oauth2/v1/accesstoken', 'https://api-satusehat-stg.dto.kemkes.go.id/oauth2/v1/refreshtoken', 'https://mediator-satusehat.kemkes.go.id/api-dev/satusehat/rme/v1.0', 'https://mediator-satusehat.kemkes.go.id/api-dev/satusehat/rme/v1.0', 'your-client-id', 'your-client-secret', null, '+07:00' ) ); $apiInstance = new SubmitDataApi( new OAuthClient(Configuration::getDefaultConfiguration()) ); $form = new HasilLab($apiInstance); $form->setProfile(['TB']); $form->setOrganizationId('100011961'); $form->setLocationId('ef011065-38c9-46f8-9c35-d1fe68966a3e'); $form->setPractitionerNik('N10000001'); // Data pasien $patient = new Patient(); $patient->setNik("3515126510190001"); $patient->setName("FAUZIA HAYZA AHMAD"); $patient->setBirthDate("2019-10-25"); $form->setPatient($patient); // Referensi terduga TB $form->setTbSuspect([ "id" => "2405101601149056", "person_id" => "1000001601149056", "fasyankes_id" => "1000119617", "jenis_fasyankes_id" => "1", "terduga_tb_id" => "1", "tipe_pasien_id" => "1" ]); // Data encounter $form->setEncounter([ "encounter_id" => "83ef7e32-64f3-40a7-87c4-3cc59d44b4c6", "local_id" => "2024-05-24 09:27:26.405593+07", "classification" => "AMB", "period_start" => "2024-05-24T09:28:01+07:00", "period_in_progress" => "2024-05-24T09:58:01+07:00", "period_end" => "2024-05-24T10:58:01+07:00" ]); // Kondisi/diagnosis $form->addCondition( (new Condition()) ->setId('e552612b-9bd4-41fb-9677-90a12bc0cc1c') ->setCodeCondition("Z10") ); // Set data hasil lab $hasil = $form ->setPermohonanLabId('permohonan-lab-id') // ID Permohonan Lab sebelumnya ->setJenisPemeriksaan('tcm') // tcm, mikroskopis ->setSpesimenId('specimen-uuid', 'specimen_1') ->setTanggalWaktuPenerimaanContohUji("2024-05-24T10:10:00") ->setKonfirmasiContohUji('baik', 'Tidak ada retakan pada tabung specimen') ->setPenerimaContohUji('N10000001') // NIK petugas penerima ->setTanggalWaktuRegisterLab('2024-05-24T10:10:00') ->setDokterPemeriksaLab('N10000001') ->getHasil(); // Set nilai hasil pemeriksaan $hasil->setContohUji('dahak_sewaktu') ->setTanggalHasil('2024-05-24T10:10:00') ->setNomorRegistrasiLab('LAB-123342') ->setNilai('2'); // Nilai hasil: 0=Negatif, 1-9=Positif (skala BTA) $form->build(); $form->validate(); try { $response = $form->send(); echo "Hasil Lab berhasil dikirim!\n"; print_r($response); } catch (RequestException $e) { echo "Error: " . $e->getMessage() . "\n"; print_r(json_decode($e->getResponse()->getBody()->getContents())); } ``` -------------------------------- ### Validate Patient Model Data Source: https://context7.com/kemenkesri/satusehat-mediator-client-php/llms.txt Check the validity of the patient data using the `valid()` method. If the data is invalid, `listInvalidProperties()` can be called to retrieve an array of validation errors. ```php // Validasi model if ($patient->valid()) { echo "Data pasien valid\n"; } else { print_r($patient->listInvalidProperties()); } ```