12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- <?php
- namespace App\Repositories\Transformers\TCM;
- use Carbon\Carbon;
- use League\Fractal\TransformerAbstract;
- use App\Repositories\Models\TCM\Prescription;
- /**
- * Class PrescriptionTransformer.
- *
- * @package namespace App\Repositories\Transformers\TCM;
- */
- class PrescriptionTransformer extends TransformerAbstract
- {
- /**
- * Transform the Prescription entity.
- *
- * @param \App\Repositories\Models\TCM\Prescription $model
- *
- * @return array
- */
- public function transform(Prescription $model)
- {
- return [
- 'id' => (int)$model->id,
- "medical_record_id" => $model->prescription_id,
- 'medical_record' => $model->medical_record()->with(['department_category'])->select(['doctor', 'hospital', 'chief_complaint', 'chinese_tra_diagnosis', 'department'])->first(),
- "name" => $model->name,
- "drug_type" => $model->drug_type,
- "eat_type" => $model->eat_type,
- "number" => $model->number,
- "advice_type" => $model->advice_type,
- "advice_frequency" => $model->advice_frequency,
- "advice_frequency_text" => Prescription::$frequencyMap[$model->advice_frequency],
- "one_consumption" => $model->one_consumption,
- "use_unit" => $model->use_unit,
- "advice" => $model->advice,
- "drugs" => $model->drugs,
- "patient_id" => $model->patient_id,
- "patient" => $model->patient()->select(['name', 'sex', 'birth_date'])->first(),
- "status" => $model->status,
- 'created_at' => $model->created_at->format(Carbon::DEFAULT_TO_STRING_FORMAT),
- 'updated_at' => $model->updated_at->format(Carbon::DEFAULT_TO_STRING_FORMAT)
- ];
- }
- }
|