[WIP] Claim Encounters
This commit is contained in:
31
Modules/Internal/Transformers/EncounterResource.php
Normal file
31
Modules/Internal/Transformers/EncounterResource.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Internal\Transformers;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class EncounterResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
$encounter = parent::toArray($request);
|
||||
|
||||
$encounter['class_name'] = $this->service->name;
|
||||
$encounter['primary_diagnosis'] = $this->primaryDiagnoses->first();
|
||||
$encounter['primary_doctor'] = $this->doctors->first()
|
||||
? array_merge(
|
||||
$this->doctors->first()->person->toArray(),
|
||||
$this->doctors->first()->toArray()
|
||||
)
|
||||
: null;
|
||||
$encounter['medical_record_number'] = @$this->meta->MEDRECID ?? null;
|
||||
|
||||
return $encounter;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user