Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KFA Integration #38

Merged
merged 8 commits into from
Apr 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## 2.4.0 - 2024-04-03

### What's Changed

* Update: OAuth2Client, Patient, and Organization by @SyaefulKai in https://github.com/ivanwilliammd/satusehat-integration/pull/36
* Added compatibility for Patient Post with identifier `nik-ibu`

**Full Changelog**: https://github.com/ivanwilliammd/satusehat-integration/compare/2.3.3...2.4.0

## 2.3.3 - 2024-04-02

### What's Changed
Expand Down Expand Up @@ -118,6 +127,7 @@ class BaseController extends Controller




```
v1.2.x :

Expand Down Expand Up @@ -240,6 +250,7 @@ class BaseController extends Controller




```
## 1.2.1 - 2024-03-22

Expand Down
79 changes: 79 additions & 0 deletions src/FHIR/KFA.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?php

namespace Satusehat\Integration\FHIR;

use Satusehat\Integration\FHIR\Exception\FHIRException;
use Satusehat\Integration\OAuth2Client;

class KFA extends OAuth2Client
{
private array $identifier = ['kfa', 'lkpp', 'nie'];

/**
* Get Detail KFA Product
*
* @param string $identifier currently available stroed in : $identifier
* @param string $code
* @return void
*/
public function getProduct(string $identifier, string $code)
{
if (!in_array($identifier, $this->identifier)) {
throw new FHIRException("Identifier currently available : " . implode("','", $this->identifier));
}

if (empty($code)) {
throw new FHIRException("code product required", 422);
}

$queryStringBuilder = [
'identifier' => $identifier,
'code' => $code
];

$queryString = http_build_query($queryStringBuilder);

return $this->ss_kfa_get("products?", $queryString);
}
/**
* Get paginated KFA Products
*
* @param string $productType currently available : 'alkes' | 'farmasi'
* @param integer $page min 1 no max
* @param integer $size min 1 max 1000
* @param string|null $keyword
* @return void
*/
public function getProducts(string $productType, string $keyword = null, int $page = 1, int $size = 100)
{
if (empty($productType)) {
throw new FHIRException("Product type required", 422);
}

if (!in_array($productType, ['alkes', 'farmasi'])) {
throw new FHIRException("Product types of currently available for : 'alkes' | 'farmasi'", 422);
}

if ($size > 1000) {
throw new FHIRException("Maximum size record 1000/request", 422);
}

if ($page < 1 || $size < 1) {
throw new FHIRException("Page / Size can't be blank.");
}

$queryStringBuilder = [
'product_type' => $productType,
'page' => $page,
'size' => $size
];

if (!empty($keyword)) {
$queryStringBuilder['keyword'] = $keyword;
}

$queryString = http_build_query($queryStringBuilder);

return $this->ss_kfa_get('products/all?', $queryString);
}
}
Loading