PHP code example of banguncode / php-ihs
1. Go to this page and download the library: Download banguncode/php-ihs library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
banguncode / php-ihs example snippets
use BangunCode\Ihs\Auth\FileTokenStorage;
use BangunCode\Ihs\Client;
use BangunCode\Ihs\Config;
use BangunCode\Ihs\Environment;
$client = new Client(
new Config(array(
'environment' => Environment::DEVELOPMENT,
'client_id' => 'CLIENT_ID',
'client_secret' => 'CLIENT_SECRET',
'organization_id' => '10000004',
)),
null,
new FileTokenStorage('/var/cache/satusehat')
);
use BangunCode\Ihs\Fhir\JsonPatch;
$patient = $client->patient()->findByNik('9271060312000001')->first();
$encounter = $client->encounter()->create(array(
'identifier' => array(array(
'system' => $client->identifierSystem('encounter'),
'value' => 'REG-0001',
)),
'status' => 'arrived',
'subject' => array('reference' => 'Patient/' . $patient['id']),
));
$encounter['status'] = 'in-progress';
$client->encounter()->update($encounter['id'], $encounter);
$client->clinicalImpression()->patch($impressionId, JsonPatch::create()
->add('/problem', array(array('reference' => 'Condition/' . $conditionId))));
foreach ($client->condition()->searchAll(array('subject' => $patient['id'])) as $condition) {
echo $condition['id'];
}
use BangunCode\Ihs\Fhir\TransactionBundle;
$bundle = new TransactionBundle();
$encounter = $bundle->create($encounterResource);
$bundle->create(array(
'resourceType' => 'Condition',
'encounter' => array('reference' => $encounter),
));
foreach ($client->transaction($bundle)->getCreatedIds() as $created) {
echo $created['resourceType'] . '/' . $created['id'];
}
$client->downloadDicomRouter('/tmp/dicom-router.zip', 'docker');
$client->serviceRequest()->create($serviceRequest);
$client->dicomRouter()->createServiceRequest($serviceRequest);
$study = $client->imagingStudy()->findByAccessionNumber($accessionNumber)->first();
$client->masterData()->cities(array('11', '12'));
$client->masterData()->regionPage('sub-districts', 1);
$client->masterData()->facilities('138');
$client->kfa()->product('93000108');
$client->kfa()->products('farmasi', 1, 100, array('keyword' => 'panadol'));
$client->kfa()->jknPrices('92000372');
$client->kptl()->codes('12027');
$client->kptl()->modifierValues('M006');
use BangunCode\Ihs\Exception\ConsentException;
$link = $client->nationalMedicalRecord()->createConsentLink($patientId, $patientName, $practitionerId, $practitionerName, 'Puskesmas Cibuntu');
try {
$record = $client->nationalMedicalRecord()->open($patientId, $patientName, $practitionerId, $practitionerName, 'Puskesmas Cibuntu');
$url = $record['data']['shlinkUrl'];
} catch (ConsentException $e) {
$url = $link['data']['verificationUrl'];
}
try {
$client->patient()->create($patient);
} catch (ValidationException $e) {
$outcome = $e->getOperationOutcome();
if ($outcome !== null && $outcome->isDuplicate()) {
$patient = $client->patient()->findByNik($nik)->first();
}
} catch (ApiException $e) {
error_log(sprintf('%s (%s), request id %s', $e->getMessage(), $e->getErrorCode(), $e->getRequestId()));
}
bash
composer