Skip to content

Commit

Permalink
Fix styling
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanwilliammd authored and github-actions[bot] committed Nov 13, 2024
1 parent 93bd1af commit 5f8bc74
Show file tree
Hide file tree
Showing 16 changed files with 162 additions and 171 deletions.
2 changes: 1 addition & 1 deletion src/Exception/FHIR/FHIRException.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class FHIRException extends Exception
{
public function __construct($message, $code = 0, ?Exception $previous = null)
{
$message = 'FHIR Exception: ' . $message;
$message = 'FHIR Exception: '.$message;

parent::__construct($message, $code, $previous);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/FHIR/FHIRInvalidPropertyValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class FHIRInvalidPropertyValue extends FHIRException
{
public function __construct($message)
{
$message = 'FHIR Invalid Property Value: ' . $message;
$message = 'FHIR Invalid Property Value: '.$message;

parent::__construct($message);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/FHIR/FHIRMissingProperty.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class FHIRMissingProperty extends FHIRException
{
public function __construct($message)
{
$message = 'FHIR Missing Property: ' . $message;
$message = 'FHIR Missing Property: '.$message;

parent::__construct($message);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@

namespace Satusehat\Integration\Exception\Terminology;

class TerminologyInvalidArgumentException extends TerminologyException
{
}
class TerminologyInvalidArgumentException extends TerminologyException {}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@

namespace Satusehat\Integration\Exception\Terminology;

class TerminologyMissingArgumentException extends TerminologyException
{
}
class TerminologyMissingArgumentException extends TerminologyException {}
27 changes: 14 additions & 13 deletions src/FHIR/Bundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,26 @@

namespace Satusehat\Integration\FHIR;

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

class Bundle extends OAuth2Client
{

public array $bundle = [
'resourceType' => 'Bundle',
'type' => 'transaction',
'entry' => [],
];

public $encounter_id, $encounter;
public $encounter_id;

public $encounter;

private function uuidV4()
{
$data = openssl_random_pseudo_bytes(16);
$data[6] = chr(ord($data[6]) & 0x0f | 0x40);
$data[8] = chr(ord($data[8]) & 0x3f | 0x80);
$data[6] = chr(ord($data[6]) & 0x0F | 0x40);
$data[8] = chr(ord($data[8]) & 0x3F | 0x80);
$uuid = bin2hex($data);
$formatted_uuid = sprintf(
'%s-%s-%s-%s-%s',
Expand All @@ -43,8 +44,8 @@ public function addEncounter(Encounter $encounter)
public function addCondition(Condition $condition)
{

if (!isset($this->encounter_id)) {
throw new FHIRException("Please call addEncounter method first before addCondition.");
if (! isset($this->encounter_id)) {
throw new FHIRException('Please call addEncounter method first before addCondition.');
}

$condition_uuid = $this->uuidV4();
Expand All @@ -55,26 +56,26 @@ public function addCondition(Condition $condition)
// Membuat referensi condition di encounter
$this->encounter->addDiagnosis($condition_uuid, $condition->condition['code']['coding'][0]['code'], '', true);

if (!isset($this->bundle['entry'][0])) {
if (! isset($this->bundle['entry'][0])) {
$this->bundle['entry'][0] = [
'fullUrl' => 'urn:uuid:' . $this->encounter_id,
'fullUrl' => 'urn:uuid:'.$this->encounter_id,
'resource' => '',
'request' => [
'method' => 'POST',
'url' => 'Encounter'
]
'url' => 'Encounter',
],
];
}

$this->bundle['entry'][0]['resource'] = json_decode($this->encounter->json());

$this->bundle['entry'][] = [
'fullUrl' => 'urn:uuid:' . $condition_uuid,
'fullUrl' => 'urn:uuid:'.$condition_uuid,
'resource' => json_decode($condition->json()),
'request' => [
'method' => 'POST',
'url' => 'Condition',
]
],
];
}

Expand Down
24 changes: 12 additions & 12 deletions src/FHIR/Condition.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace Satusehat\Integration\FHIR;

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

class Condition extends OAuth2Client
{
Expand Down Expand Up @@ -79,7 +79,7 @@ public function addCode($code = null, $display = null)
$code_check = Icd10::where('icd10_code', $code)->first();

// Handling if incomplete code / display
if (!$code_check) {
if (! $code_check) {
throw new FHIRException('Kode ICD10 tidak ditemukan');
}

Expand All @@ -94,14 +94,14 @@ public function addCode($code = null, $display = null)

public function setSubject($subjectId, $name)
{
$this->condition['subject']['reference'] = 'Patient/' . $subjectId;
$this->condition['subject']['reference'] = 'Patient/'.$subjectId;
$this->condition['subject']['display'] = $name;
}

public function setEncounter($encounterId, $display = null, $bundle = false)
{
$this->condition['encounter']['reference'] = ($bundle ? 'urn:uuid:' : 'Encounter/') . $encounterId;
$this->condition['encounter']['display'] = $display ? $display : 'Kunjungan ' . $encounterId;
$this->condition['encounter']['reference'] = ($bundle ? 'urn:uuid:' : 'Encounter/').$encounterId;
$this->condition['encounter']['display'] = $display ? $display : 'Kunjungan '.$encounterId;
}

public function setOnsetDateTime($onset_date_time = null)
Expand All @@ -121,37 +121,37 @@ public function setRecordedDate($recorded_date = null)
public function json()
{
// Add default clinical status
if (!array_key_exists('clinicalStatus', $this->condition)) {
if (! array_key_exists('clinicalStatus', $this->condition)) {
$this->addClinicalStatus();
}

// Add default category
if (!array_key_exists('category', $this->condition)) {
if (! array_key_exists('category', $this->condition)) {
$this->addCategory();
}

// Add default OnsetDateTime
if (!array_key_exists('onsetDateTime', $this->condition)) {
if (! array_key_exists('onsetDateTime', $this->condition)) {
$this->setOnsetDateTime();
}

// Add default RecordedDate
if (!array_key_exists('recordedDate', $this->condition)) {
if (! array_key_exists('recordedDate', $this->condition)) {
$this->setRecordedDate();
}

// Subject is required
if (!array_key_exists('subject', $this->condition)) {
if (! array_key_exists('subject', $this->condition)) {
return 'Please use condition->setSubject($subjectId, $name) to pass the data';
}

// Encounter is required
if (!array_key_exists('encounter', $this->condition)) {
if (! array_key_exists('encounter', $this->condition)) {
return 'Please use condition->setEncounter($encounterId) to pass the data';
}

// ICD-10 is required
if (!array_key_exists('code', $this->condition)) {
if (! array_key_exists('code', $this->condition)) {
return 'Please use condition->addCode($code, $display) to pass the data';
}

Expand Down
34 changes: 17 additions & 17 deletions src/FHIR/Encounter.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Encounter extends OAuth2Client

public function addRegistrationId($registration_id)
{
$identifier['system'] = 'http://sys-ids.kemkes.go.id/encounter/' . $this->organization_id;
$identifier['system'] = 'http://sys-ids.kemkes.go.id/encounter/'.$this->organization_id;
$identifier['value'] = $registration_id;

$this->encounter['identifier'][] = $identifier;
Expand All @@ -32,7 +32,7 @@ private function statusHistoryValidate($arr, $status)

public function setArrived($timestamp)
{
if (!isset($this->encounter['statusHistory'])) {
if (! isset($this->encounter['statusHistory'])) {
$this->encounter['statusHistory'] = [];
}

Expand All @@ -57,7 +57,7 @@ public function setArrived($timestamp)
public function setInProgress($timestamp_start, $timestamp_end)
{

if (!isset($this->encounter['statusHistory'])) {
if (! isset($this->encounter['statusHistory'])) {
return 'Please use $this->setArrived first';
}

Expand Down Expand Up @@ -89,7 +89,7 @@ public function setInProgress($timestamp_start, $timestamp_end)
public function setFinished($timestamp)
{

if (!isset($this->encounter['statusHistory'])) {
if (! isset($this->encounter['statusHistory'])) {
return 'Please use $this->setArrived first';
}

Expand Down Expand Up @@ -150,13 +150,13 @@ public function setConsultationMethod($consultation_method)

public function setSubject($subjectId, $name)
{
$this->encounter['subject']['reference'] = 'Patient/' . $subjectId;
$this->encounter['subject']['reference'] = 'Patient/'.$subjectId;
$this->encounter['subject']['display'] = $name;
}

public function addParticipant($participantId, $name, $type = 'ATND', $display = 'attender')
{
$participant['individual']['reference'] = 'Practitioner/' . $participantId;
$participant['individual']['reference'] = 'Practitioner/'.$participantId;
$participant['individual']['display'] = $name;
$participant['type'][]['coding'][] = [
'system' => 'http://terminology.hl7.org/CodeSystem/v3-ParticipationType',
Expand All @@ -169,15 +169,15 @@ public function addParticipant($participantId, $name, $type = 'ATND', $display =

public function addLocation($locationId, $name)
{
$location['location']['reference'] = 'Location/' . $locationId;
$location['location']['reference'] = 'Location/'.$locationId;
$location['location']['display'] = $name;

$this->encounter['location'][] = $location;
}

public function setServiceProvider()
{
$this->encounter['serviceProvider']['reference'] = 'Organization/' . $this->organization_id;
$this->encounter['serviceProvider']['reference'] = 'Organization/'.$this->organization_id;
}

public function addDiagnosis($id, $code, $display = null, $bundle = false)
Expand All @@ -186,14 +186,14 @@ public function addDiagnosis($id, $code, $display = null, $bundle = false)
$code_check = Icd10::where('icd10_code', $code)->first();

// Handling if incomplete code / display
if (!$code_check) {
if (! $code_check) {
return 'Kode ICD-10 invalid';
}

$display = $display ? $display : $code_check->icd10_en;

// Create Encounter.diagnosis content
$diagnosis['condition']['reference'] = ($bundle ? 'urn:uuid:' : 'Condition/') . $id;
$diagnosis['condition']['reference'] = ($bundle ? 'urn:uuid:' : 'Condition/').$id;
$diagnosis['condition']['display'] = $display;
$diagnosis['use']['coding'][] = [
'system' => 'http://terminology.hl7.org/CodeSystem/diagnosis-role',
Expand All @@ -202,7 +202,7 @@ public function addDiagnosis($id, $code, $display = null, $bundle = false)
];

// Determine ranking
if (!array_key_exists('diagnosis', $this->encounter)) {
if (! array_key_exists('diagnosis', $this->encounter)) {
$rank = 1;
} else {
$rank = count($this->encounter['diagnosis']) + 1;
Expand All @@ -215,32 +215,32 @@ public function addDiagnosis($id, $code, $display = null, $bundle = false)
public function json()
{
// Status is required
if (!array_key_exists('status', $this->encounter)) {
if (! array_key_exists('status', $this->encounter)) {
return 'Please use encounter->statusHistory([timestamp array]) to add the status';
}

// Class is required
if (!array_key_exists('class', $this->encounter)) {
if (! array_key_exists('class', $this->encounter)) {
return 'Please use encounter->setConsultationMethod($method) to pass the data';
}

// Subject is required
if (!array_key_exists('subject', $this->encounter)) {
if (! array_key_exists('subject', $this->encounter)) {
return 'Please use encounter->setSubject($subjectId, $name) to pass the data';
}

// Participant is required
if (!array_key_exists('participant', $this->encounter)) {
if (! array_key_exists('participant', $this->encounter)) {
return 'Please use encounter->addParticipant($participantId, $name) to pass the data';
}

// Location is required
if (!array_key_exists('location', $this->encounter)) {
if (! array_key_exists('location', $this->encounter)) {
return 'Please use encounter->addLocation($locationId, $name) to pass the data';
}

// Add default ServiceProvider
if (!array_key_exists('serviceProvider', $this->encounter)) {
if (! array_key_exists('serviceProvider', $this->encounter)) {
$this->setServiceProvider();
}

Expand Down
2 changes: 1 addition & 1 deletion src/FHIR/Location.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public function addPhysicalType($physical_type = null)
'ca' => 'Cabinet',
'rd' => 'Road',
'area' => 'Area',
'bd' => 'Bed'
'bd' => 'Bed',
];

$this->location['physicalType']['coding'][] = [
Expand Down
Loading

0 comments on commit 5f8bc74

Please sign in to comment.