src/Entity/Treatment.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\TreatmentRepository;
  4. use App\Traits\CreatedUpdatedTrait;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use JMS\Serializer\Annotation as Serializer;
  8. /**
  9.  * @ORM\Table(name="v_treatment")
  10.  * @ORM\Entity(repositoryClass=TreatmentRepository::class)
  11.  */
  12. class Treatment
  13. {
  14.     /**
  15.      * @ORM\Id
  16.      * @ORM\GeneratedValue
  17.      * @ORM\Column(type="integer")
  18.      */
  19.     private $id;
  20.     /**
  21.      * @var string
  22.      *
  23.      * @ORM\Column(name="tracking_code", type="string", length=255, nullable=true)
  24.      */
  25.     private $trackingCode;
  26.     /**
  27.      * @ORM\OneToOne(targetEntity="App\Entity\Patient")
  28.      */
  29.     private $patient;
  30.     /**
  31.      * @ORM\ManyToOne(targetEntity="App\Entity\Package", cascade={"persist"}, inversedBy="treatment")
  32.      * @ORM\JoinColumn(name="package_id", referencedColumnName="id", onDelete="SET NULL", nullable=true)
  33.      */
  34.     private $package;
  35.     /**
  36.      * @ORM\ManyToOne(targetEntity="App\Entity\ContentBlock")
  37.      * @Serializer\Type("Relation")
  38.      */
  39.     private $content;
  40.     /**
  41.      * @ORM\OneToMany(targetEntity="App\Entity\TreatmentActivity", mappedBy="treatment")
  42.      * @ORM\OrderBy({"day": "ASC"})
  43.      */
  44.     private $activities;
  45.     /**
  46.      * @var \DateTime
  47.      *
  48.      * @ORM\Column(name="start_date", type="date", nullable=false)
  49.      */
  50.     private $startDate;
  51.     /**
  52.      * @ORM\Column(name="deleted_at", type="datetime", nullable=true)
  53.      */
  54.     private $deletedAt;
  55.     use CreatedUpdatedTrait;
  56.     public function __construct(){
  57.         $this->activities = new ArrayCollection();
  58.         $this->setTrackingCode('iom-tp-'.date('Ymdhis').'-'.rand(1000,9999));
  59.     }
  60.     public function __toString(){
  61.         return $this->trackingCode;
  62.     }
  63.     public function getId(): ?int
  64.     {
  65.         return $this->id;
  66.     }
  67.     /**
  68.      * @return string
  69.      */
  70.     public function getTrackingCode(): ?string
  71.     {
  72.         return $this->trackingCode;
  73.     }
  74.     /**
  75.      * @param string $trackingCode
  76.      */
  77.     public function setTrackingCode(?string $trackingCode): void
  78.     {
  79.         $this->trackingCode $trackingCode;
  80.     }
  81.     /**
  82.      * @return mixed
  83.      */
  84.     public function getPatient()
  85.     {
  86.         return $this->patient;
  87.     }
  88.     /**
  89.      * @param mixed $patient
  90.      */
  91.     public function setPatient($patient): void
  92.     {
  93.         $this->patient $patient;
  94.     }
  95.     /**
  96.      * @return mixed
  97.      */
  98.     public function getPackage()
  99.     {
  100.         return $this->package;
  101.     }
  102.     /**
  103.      * @param mixed $package
  104.      */
  105.     public function setPackage($package): void
  106.     {
  107.         $this->package $package;
  108.     }
  109.     /**
  110.      * @return mixed
  111.      */
  112.     public function getContent()
  113.     {
  114.         return $this->content;
  115.     }
  116.     /**
  117.      * @param mixed $content
  118.      */
  119.     public function setContent($content): void
  120.     {
  121.         $this->content $content;
  122.     }
  123.     public function getActivities()
  124.     {
  125.         return $this->activities;
  126.     }
  127.     public function setActivities($activities){
  128.         $this->activities $activities;
  129.     }
  130.     /**
  131.      * @return \DateTime
  132.      */
  133.     public function getStartDate(): ?\DateTime
  134.     {
  135.         return $this->startDate;
  136.     }
  137.     /**
  138.      * @param \DateTime $startDate
  139.      */
  140.     public function setStartDate(?\DateTime $startDate): void
  141.     {
  142.         $this->startDate $startDate;
  143.     }
  144.     /**
  145.      * @return mixed
  146.      */
  147.     public function getDeletedAt()
  148.     {
  149.         return $this->deletedAt;
  150.     }
  151.     /**
  152.      * @param mixed $deletedAt
  153.      */
  154.     public function setDeletedAt($deletedAt): void
  155.     {
  156.         $this->deletedAt $deletedAt;
  157.     }
  158. }