add jsonSerialize
This commit is contained in:
parent
c78698ace4
commit
f9608bce18
@ -2,12 +2,14 @@
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Enums\ReferralServiceType;
|
||||
use App\Repository\StandardNoteRepository;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use JsonSerializable;
|
||||
|
||||
#[ORM\Entity(repositoryClass: StandardNoteRepository::class)]
|
||||
class StandardNote extends Note
|
||||
class StandardNote extends Note implements JsonSerializable
|
||||
{
|
||||
#[ORM\Column(type: Types::TEXT, nullable: true)]
|
||||
private ?string $note = null;
|
||||
@ -23,4 +25,26 @@ class StandardNote extends Note
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function jsonSerialize(): array
|
||||
{
|
||||
$members = [];
|
||||
foreach ($this->getMembers() as $member) {
|
||||
/** @var Member $member */
|
||||
$members[] = $member->getName();
|
||||
}
|
||||
return [
|
||||
'id' => $this->getId()->toString(),
|
||||
'date' => $this->getDate()->format('M j, Y'),
|
||||
'startTime' => $this->getStartTime()->format('g:i a'),
|
||||
'endTime' => $this->getEndTime()->format('g:i a'),
|
||||
'serviceCode' => $this->getReferral()->getServiceCode()->value,
|
||||
'noteType' => ($this->getReferral()->getServiceCode() == ReferralServiceType::VS_THBB ? 'visit' : 'standard'),
|
||||
'status' => $this->getStatus()->value,
|
||||
'location' => $this->getLocation()->value,
|
||||
'method' => ucwords(str_replace('_', ' ', strtolower($this->getMethod()->name))),
|
||||
'members' => implode(', ', $members),
|
||||
'duration' => $this->calcTimeUsed(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -2,13 +2,15 @@
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Enums\ReferralServiceType;
|
||||
use App\Enums\VisitQualityLevel;
|
||||
use App\Repository\VisitNoteRepository;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use JsonSerializable;
|
||||
|
||||
#[ORM\Entity(repositoryClass: VisitNoteRepository::class)]
|
||||
class VisitNote extends Note
|
||||
class VisitNote extends Note implements JsonSerializable
|
||||
{
|
||||
#[ORM\Column(type: Types::TEXT)]
|
||||
private ?string $narrative = null;
|
||||
@ -159,4 +161,36 @@ class VisitNote extends Note
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function jsonSerialize(): array
|
||||
{
|
||||
$members = [];
|
||||
foreach ($this->getMembers() as $member) {
|
||||
/** @var Member $member */
|
||||
$members[] = $member->getName();
|
||||
}
|
||||
return [
|
||||
'id' => $this->getId()->toString(),
|
||||
'date' => $this->getDate()->format('M j, Y'),
|
||||
'startTime' => $this->getStartTime()->format('g:i a'),
|
||||
'endTime' => $this->getEndTime()->format('g:i a'),
|
||||
'serviceCode' => $this->getReferral()->getServiceCode()->value,
|
||||
'noteType' => ($this->getReferral()->getServiceCode() == ReferralServiceType::VS_THBB ? 'visit' : 'standard'),
|
||||
'status' => $this->getStatus()->value,
|
||||
'location' => $this->getLocation()->value,
|
||||
'method' => ucwords(str_replace('_', ' ', strtolower($this->getMethod()->name))),
|
||||
'narrative' => $this->getNarrative(),
|
||||
'strengths' => $this->getStrengths(),
|
||||
'issues' => $this->getIssues(),
|
||||
'recommendation' => $this->getRecommendation(),
|
||||
'parentalRole' => $this->getParentalRole(),
|
||||
'childDevelopment' => $this->getChildDevelopment(),
|
||||
'appropriateResponse' => $this->getAppropriateResponse(),
|
||||
'childAheadOfSelf' => $this->getChildAheadOfSelf(),
|
||||
'showsEmpathy' => $this->getShowsEmpathy(),
|
||||
'childFocused' => $this->getChildFocused(),
|
||||
'members' => implode(', ', $members),
|
||||
'duration' => $this->calcTimeUsed(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user