src/Entity/Patient.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\PatientRepository;
  4. use App\Traits\CreatedUpdatedTrait;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use JMS\Serializer\Annotation as Serializer;
  9. /**
  10.  * @ORM\Table(name="v_patient")
  11.  * @ORM\Entity(repositoryClass=PatientRepository::class)
  12.  */
  13. class Patient
  14. {
  15.     /**
  16.      * @ORM\Id
  17.      * @ORM\GeneratedValue
  18.      * @ORM\Column(type="integer")
  19.      */
  20.     private $id;
  21.     /**
  22.      * @ORM\Column(type="string", length=255)
  23.      */
  24.     private $name;
  25.     /**
  26.      * @ORM\Column(type="string", length=255, unique=true)
  27.      */
  28.     private $clinicCode;
  29.     /**
  30.      * @ORM\OneToOne(targetEntity="App\Entity\User")
  31.      * @Serializer\Type("Relation")
  32.      */
  33.     private $user;
  34.     /**
  35.      * @ORM\OneToOne(targetEntity="Treatment")
  36.      */
  37.     private $treatment;
  38.     /**
  39.      * @ORM\Column(name="deleted_at", type="datetime", nullable=true)
  40.      */
  41.     private $deletedAt;
  42.     /**
  43.      * @ORM\OneToMany(targetEntity=PatientPackage::class, mappedBy="patient")
  44.      */
  45.     private $packages;
  46.     public function __construct()
  47.     {
  48.         $this->packages = new ArrayCollection();
  49.     }
  50.     use CreatedUpdatedTrait;
  51.     public function __toString(){
  52.         return $this->name;
  53.     }
  54.     public function getId(): ?int
  55.     {
  56.         return $this->id;
  57.     }
  58.     public function getName(): ?string
  59.     {
  60.         return $this->name;
  61.     }
  62.     public function setName(string $name): self
  63.     {
  64.         $this->name $name;
  65.         return $this;
  66.     }
  67.     public function getClinicCode(): ?string
  68.     {
  69.         return $this->clinicCode;
  70.     }
  71.     public function setClinicCode(string $clinicCode): self
  72.     {
  73.         $this->clinicCode $clinicCode;
  74.         return $this;
  75.     }
  76.     /**
  77.      * @return mixed
  78.      */
  79.     public function getTreatment()
  80.     {
  81.         return $this->treatment;
  82.     }
  83.     /**
  84.      * @param mixed $treatment
  85.      */
  86.     public function setTreatment($treatment): void
  87.     {
  88.         $this->treatment $treatment;
  89.     }
  90.     /**
  91.      * @return mixed
  92.      */
  93.     public function getUser()
  94.     {
  95.         return $this->user;
  96.     }
  97.     /**
  98.      * @param mixed $user
  99.      */
  100.     public function setUser($user): void
  101.     {
  102.         $this->user $user;
  103.     }
  104.     /**
  105.      * @return mixed
  106.      */
  107.     public function getDeletedAt()
  108.     {
  109.         return $this->deletedAt;
  110.     }
  111.     /**
  112.      * @param mixed $deletedAt
  113.      */
  114.     public function setDeletedAt($deletedAt): void
  115.     {
  116.         $this->deletedAt $deletedAt;
  117.     }
  118.     /**
  119.      * @return Collection<int, PatientPackage>
  120.      */
  121.     public function getPackages(): Collection
  122.     {
  123.         return $this->packages;
  124.     }
  125.     public function addPackage(PatientPackage $package): self
  126.     {
  127.         if (!$this->packages->contains($package)) {
  128.             $this->packages[] = $package;
  129.             $package->setPatient($this);
  130.         }
  131.         return $this;
  132.     }
  133.     public function removePackage(PatientPackage $package): self
  134.     {
  135.         if ($this->packages->removeElement($package)) {
  136.             // set the owning side to null (unless already changed)
  137.             if ($package->getPatient() === $this) {
  138.                 $package->setPatient(null);
  139.             }
  140.         }
  141.         return $this;
  142.     }
  143. }