deploy commit
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V1;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class AccountCollection extends ResourceCollection
|
||||
{
|
||||
/**
|
||||
* Transform the resource collection into an array.
|
||||
*
|
||||
* @return array<int|string, mixed>
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
// return [
|
||||
// 'data' => $this->collection,
|
||||
// 'status' => true,
|
||||
// ];
|
||||
return parent::toArray($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V1;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class AccountResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(Request $request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'name' => $this->name,
|
||||
'email' => $this->email,
|
||||
'phone' => $this->phone,
|
||||
'dob' => $this->dob,
|
||||
'role' => $this->role,
|
||||
'doctorProfile' => DoctorProfileResource::make($this->whenLoaded('doctorProfile')),
|
||||
'submission' => SubmissionResource::collection($this->whenLoaded('submission')),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
namespace App\Http\Resources\V1;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
|
||||
class DashboardStatsResource extends JsonResource
|
||||
{
|
||||
public function toArray(Request $request)
|
||||
{
|
||||
return [
|
||||
'totalPatients' => $this['totalPatients'],
|
||||
'pending' => $this['pendingCount'],
|
||||
'verified' => $this['verifiedCount'],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V1;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class DoctorHistorySubmissionResource extends JsonResource
|
||||
{
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'patientId' => $this->patient->id,
|
||||
'submittedAt' => optional($this->submitted_at)->format('Y-m-d'),
|
||||
'patientName' => $this->patient->name,
|
||||
'diagnosisAi' => $this->getDiagnosisAi(),
|
||||
'diagnosis' => $this->diagnosis,
|
||||
'doctorNote' => $this->doctor_note,
|
||||
];
|
||||
}
|
||||
|
||||
private function getDiagnosisAi(): ?string
|
||||
{
|
||||
$pct = $this->percentage;
|
||||
$threshold = config('ai.threshold');
|
||||
$labelPos = config('ai.label_positive');
|
||||
$labelNeg = config('ai.label_negative');
|
||||
|
||||
return is_numeric($pct)
|
||||
? sprintf('%d%% %s', round($pct * 1), $pct >= $threshold ? $labelPos : $labelNeg)
|
||||
: null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V1;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class DoctorListResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'name' => $this->name,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V1;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class DoctorProfileCollection extends ResourceCollection
|
||||
{
|
||||
/**
|
||||
* Transform the resource collection into an array.
|
||||
*
|
||||
* @return array<int|string, mixed>
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return parent::toArray($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V1;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class DoctorProfileResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(Request $request)
|
||||
{
|
||||
return [
|
||||
'userId' =>$this->user_id,
|
||||
'specialization' =>$this->specialization,
|
||||
'licenseNumber' =>$this->license_number,
|
||||
'licenseFilePath' =>$this->license_file_path,
|
||||
'diplomaFilePath' =>$this->diploma_file_path,
|
||||
'certification' =>$this->certification,
|
||||
'currentInstitution' =>$this->current_institution,
|
||||
//'yearsOfExperience' =>$this->years_of_experience,
|
||||
'workHistory' =>$this->work_history,
|
||||
'publications' =>$this->publications
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
namespace App\Http\Resources\V1;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class PatientDetectionDetailResource extends JsonResource
|
||||
{
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'doctorId' => $this->doctor_id,
|
||||
'imageUrl' => Storage::disk('public')->url($this->image_path),
|
||||
'diagnosis' => $this->diagnosis ?? 'Belum dapat dipastikan',
|
||||
'diagnosisAi' => $this->getDiagnosisAi(),
|
||||
'isSubmitted' => $this->is_submitted,
|
||||
'status' => $this->status,
|
||||
];
|
||||
}
|
||||
private function getDiagnosisAi(): ?string
|
||||
{
|
||||
$pct = $this->percentage;
|
||||
$threshold = config('ai.threshold');
|
||||
$labelPos = config('ai.label_positive');
|
||||
$labelNeg = config('ai.label_negative');
|
||||
|
||||
return is_numeric($pct)
|
||||
? sprintf('%d%% %s', round($pct * 1), $pct >= $threshold ? $labelPos : $labelNeg)
|
||||
: null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
namespace App\Http\Resources\V1;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class PatientDetectionHistoryResource extends JsonResource
|
||||
{
|
||||
public function toArray($request)
|
||||
{
|
||||
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'submittedAt' => optional($this->submitted_at)->format('Y-m-d'),
|
||||
'diagnosisAi' => $this->getDiagnosisAi(),
|
||||
'imageUrl' => Storage::disk('public')->url($this->image_path),
|
||||
'isSubmitted' => $this->is_submitted,
|
||||
'status' => $this->status,
|
||||
'complaint' => $this->complaint,
|
||||
];
|
||||
}
|
||||
|
||||
private function getDiagnosisAi(): ?string
|
||||
{
|
||||
$pct = $this->percentage;
|
||||
$threshold = config('ai.threshold');
|
||||
$labelPos = config('ai.label_positive');
|
||||
$labelNeg = config('ai.label_negative');
|
||||
|
||||
return is_numeric($pct)
|
||||
? sprintf('%d%% %s', round($pct * 1), $pct >= $threshold ? $labelPos : $labelNeg)
|
||||
: null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
namespace App\Http\Resources\V1;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class PatientListResource extends JsonResource
|
||||
{
|
||||
public function toArray(Request $request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'name' => $this->name,
|
||||
'phone' => $this->phone,
|
||||
'submissionCount' => $this->submission_count,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
namespace App\Http\Resources\V1;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class PatientSubmissionDetailResource extends JsonResource
|
||||
{
|
||||
public function toArray($request)
|
||||
{
|
||||
$user = $this->patient;
|
||||
|
||||
return [
|
||||
'imageUrl' => Storage::disk('public')->url($this->image_path),
|
||||
'verifiedBy' => $this->doctor?->name,
|
||||
'patient' => [
|
||||
'name' => $user->name,
|
||||
'phone' => $user->phone,
|
||||
'email' => $user->email,
|
||||
'dob' => optional($user->dob)->format('Y-m-d'),
|
||||
],
|
||||
'complaint' => $this->complaint,
|
||||
'diagnosis' => $this->diagnosis,
|
||||
'diagnosisAi' => $this->getDiagnosisAi(),
|
||||
'status' => $this->status,
|
||||
'doctorNote' => $this->doctor_note,
|
||||
];
|
||||
}
|
||||
private function getDiagnosisAi(): ?string
|
||||
{
|
||||
$pct = $this->percentage;
|
||||
$threshold = config('ai.threshold');
|
||||
$labelPos = config('ai.label_positive');
|
||||
$labelNeg = config('ai.label_negative');
|
||||
|
||||
return is_numeric($pct)
|
||||
? sprintf('%d%% %s', round($pct * 1), $pct >= $threshold ? $labelPos : $labelNeg)
|
||||
: null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
namespace App\Http\Resources\V1;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class PatientSubmissionHistoryResource extends JsonResource
|
||||
{
|
||||
public function toArray($request)
|
||||
{
|
||||
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'submittedAt' => optional($this->submitted_at)->format('Y-m-d'),
|
||||
'diagnosisAi' => $this->getDiagnosisAi(),
|
||||
'imageUrl' => Storage::disk('public')->url($this->image_path),
|
||||
'complaint' => $this->complaint,
|
||||
'status' => $this->status,
|
||||
'verifiedAt' => optional($this->verified_at)->format('Y-m-d'),
|
||||
'verifiedBy' => $this->doctor?->name,
|
||||
'diagnosis' => $this->diagnosis,
|
||||
'doctorNote' => $this->doctor_note,
|
||||
];
|
||||
}
|
||||
|
||||
private function getDiagnosisAi(): ?string
|
||||
{
|
||||
$pct = $this->percentage;
|
||||
$threshold = config('ai.threshold');
|
||||
$labelPos = config('ai.label_positive');
|
||||
$labelNeg = config('ai.label_negative');
|
||||
|
||||
return is_numeric($pct)
|
||||
? sprintf('%d%% %s', round($pct * 1), $pct >= $threshold ? $labelPos : $labelNeg)
|
||||
: null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V1;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class PendingVerificationResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return parent::toArray($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V1;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class SubmissionCollection extends ResourceCollection
|
||||
{
|
||||
/**
|
||||
* Transform the resource collection into an array.
|
||||
*
|
||||
* @return array<int|string, mixed>
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return parent::toArray($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
namespace App\Http\Resources\V1;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class SubmissionDetailResource extends JsonResource
|
||||
{
|
||||
public function toArray(Request $request)
|
||||
{
|
||||
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'doctorId' => $this->doctor_id,
|
||||
'patientId' => $this->patient->id,
|
||||
'patientName' => $this->patient->name,
|
||||
'patientPhone' => $this->patient->phone,
|
||||
'patientEmail' => $this->patient->email,
|
||||
'patientDob' => $this->patient->dob,
|
||||
'imageUrl' => Storage::disk('public')->url($this->image_path),
|
||||
'complaint' => $this->complaint,
|
||||
'status' => $this->status,
|
||||
'percentage' => $this->percentage,
|
||||
'diagnosis' => $this->diagnosis ?? 'Belum dapat dipastikan',
|
||||
'diagnosisAi' => $this->getDiagnosisAi(),
|
||||
'doctorNote' => $this->doctor_note,
|
||||
'isSubmitted' => $this->is_submitted,
|
||||
'submittedAt' => optional($this->submitted_at)->format('Y-m-d'),
|
||||
'verifiedAt' => optional($this->verified_at)->format('Y-m-d'),
|
||||
];
|
||||
}
|
||||
|
||||
private function getDiagnosisAi(): ?string
|
||||
{
|
||||
$pct = $this->percentage;
|
||||
$threshold = config('ai.threshold');
|
||||
$labelPos = config('ai.label_positive');
|
||||
$labelNeg = config('ai.label_negative');
|
||||
|
||||
return is_numeric($pct)
|
||||
? sprintf('%d%% %s', round($pct * 1), $pct >= $threshold ? $labelPos : $labelNeg)
|
||||
: null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
namespace App\Http\Resources\V1;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class SubmissionListResource extends JsonResource
|
||||
{
|
||||
public function toArray(Request $request)
|
||||
{
|
||||
$onlyPercentage = $request->get('only_percentage', false);
|
||||
|
||||
if ($onlyPercentage) {
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'patientId' => $this->patient->id,
|
||||
'patientName' => $this->patient->name,
|
||||
'submittedAt' => optional($this->submitted_at)->format('Y-m-d'),
|
||||
'imageUrl' => Storage::disk('public')->url($this->image_path),
|
||||
'diagnosisAi' => $this->percentage,
|
||||
];
|
||||
}
|
||||
|
||||
// versi full list
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'patientName' => $this->patient->name,
|
||||
'submittedAt' => optional($this->submitted_at)->format('Y-m-d'),
|
||||
'diagnosisAi' => $this->getDiagnosisAi(),
|
||||
];
|
||||
}
|
||||
|
||||
private function getDiagnosisAi(): ?string
|
||||
{
|
||||
$pct = $this->percentage;
|
||||
$threshold = config('ai.threshold');
|
||||
$labelPos = config('ai.label_positive');
|
||||
$labelNeg = config('ai.label_negative');
|
||||
|
||||
return is_numeric($pct)
|
||||
? sprintf('%d%% %s', round($pct * 1), $pct >= $threshold ? $labelPos : $labelNeg)
|
||||
: null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V1;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class SubmissionResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(Request $request)
|
||||
{
|
||||
$threshold = config('ai.threshold');
|
||||
$labelPos = config('ai.label_positive');
|
||||
$labelNeg = config('ai.label_negative');
|
||||
|
||||
$pct = $this->percentage;
|
||||
$diagnosisAi = is_numeric($pct)
|
||||
? ($pct >= $threshold ? $labelPos : $labelNeg)
|
||||
: null;
|
||||
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'patientId' => $this->patient_id,
|
||||
'patientName' =>$this->patient->name,
|
||||
'doctorId' => $this->doctor_id,
|
||||
'imageUrl' => Storage::disk('public')->url($this->image_path),
|
||||
'complaint' => $this->complaint,
|
||||
'status' => $this->status,
|
||||
'diagnosis' => $this->diagnosis ?? 'Belum dapat dipastikan',
|
||||
'doctorNote' => $this->doctor_note,
|
||||
'isSubmitted' => $this->is_submitted,
|
||||
'submittedAt' => optional($this->submitted_at)->format('Y-m-d'),
|
||||
'verifiedAt' => optional($this->verified_at)->format('Y-m-d'),
|
||||
'percentage' => $this->percentage,
|
||||
'diagnosisAi' => $diagnosisAi,
|
||||
];
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user