src/Entity/LabTest.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\LabTestRepository;
  4. use Doctrine\Common\Collections\{ ArrayCollectionCollection };
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Gedmo\Mapping\Annotation as Gedmo;
  7. use Symfony\Component\Validator\Constraints as Assert;
  8. #[ORM\Entity(repositoryClassLabTestRepository::class), ORM\Table(name'lab_tests')]
  9. class LabTest implements \Stringable
  10. {
  11.     #[ORM\IdORM\GeneratedValueORM\Column(type'integer')]
  12.     private $id;
  13.     #[ORM\Column(type'string'length255), Assert\NotBlank]
  14.     #[Assert\Length(
  15.         min2,
  16.         max20,
  17.         minMessage'Lab test name must be at least {{ limit }} characters long',
  18.         maxMessage'Lab test name cannot be longer than {{ limit }} characters'
  19.     )]
  20.     #[Assert\Regex(
  21.         pattern'/\d/',
  22.         match: false,
  23.         message'Lab test name cannot contain a number'
  24.     )]
  25.     private $name;
  26.     #[ORM\Column(type'boolean')]
  27.     private bool $isActive true;
  28.     #[ORM\Column(type'string'length255nullabletrue)]
  29.     private $resultUnit;
  30.     #[ORM\Column(type'string'length255nullabletrue)]
  31.     private $normalRange;
  32.     #[ORM\OneToMany(targetEntityLabTestMethod::class, mappedBy'method'orphanRemovaltrue)]
  33.     private $methods;
  34.     #[ORM\Column(type'boolean')]
  35.     private bool $isGeneral false;
  36.     #[ORM\Column(type'boolean')]
  37.     private bool $isUserDefined false;
  38.     #[ORM\Column(type'string'nullablefalsecolumnDefinition"enum('Biochemistry', 'Pathology', 'Microbiology', 'Radiology')")]
  39.     #[Assert\NotBlank]
  40.     private $labType;
  41.     #[Gedmo\Blameable(on'create'), ORM\ManyToOne(targetEntityUser::class), ORM\JoinColumn(name'created_by')]
  42.     private $createdBy;
  43.     #[Gedmo\Timestampable(on'create'), ORM\Column(type'datetime')]
  44.     private $createdAt;
  45.     #[Gedmo\Timestampable(on'update'), ORM\Column(type'datetime')]
  46.     private $updatedAt;
  47.     public function __construct()
  48.     {
  49.         $this->methods = new ArrayCollection();
  50.     }
  51.     public function getId(): ?int
  52.     {
  53.         return $this->id;
  54.     }
  55.     public function getName(): ?string
  56.     {
  57.         return $this->name;
  58.     }
  59.     public function setName(string $name): self
  60.     {
  61.         $this->name $name;
  62.         return $this;
  63.     }
  64.     public function getIsActive(): ?bool
  65.     {
  66.         return $this->isActive;
  67.     }
  68.     public function setIsActive(bool $isActive): self
  69.     {
  70.         $this->isActive $isActive;
  71.         return $this;
  72.     }
  73.     public function getResultUnit(): ?string
  74.     {
  75.         return $this->resultUnit;
  76.     }
  77.     public function setResultUnit(string $resultUnit): self
  78.     {
  79.         $this->resultUnit $resultUnit;
  80.         return $this;
  81.     }
  82.     public function getNormalRange(): ?string
  83.     {
  84.         return $this->normalRange;
  85.     }
  86.     public function setNormalRange(string $normalRange): self
  87.     {
  88.         $this->normalRange $normalRange;
  89.         return $this;
  90.     }
  91.     public function getMethods(): Collection
  92.     {
  93.         return $this->methods;
  94.     }
  95.     public function getIsGeneral(): ?bool
  96.     {
  97.         return $this->isGeneral;
  98.     }
  99.     public function setIsGeneral(bool $isGeneral): self
  100.     {
  101.         $this->isGeneral $isGeneral;
  102.         return $this;
  103.     }
  104.     public function getIsUserDefined(): ?bool
  105.     {
  106.         return $this->isUserDefined;
  107.     }
  108.     public function setIsUserDefined(bool $isUserDefined): self
  109.     {
  110.         $this->isUserDefined $isUserDefined;
  111.         return $this;
  112.     }
  113.     public function getLabType(): ?string
  114.     {
  115.         return $this->labType;
  116.     }
  117.     public function setLabType(string $labType): self
  118.     {
  119.         $this->labType $labType;
  120.         return $this;
  121.     }
  122.     public function getCreatedBy(): ?User
  123.     {
  124.         return $this->createdBy;
  125.     }
  126.     public function getCreatedAt(): ?\DateTimeInterface
  127.     {
  128.         return $this->createdAt;
  129.     }
  130.     public function getUpdatedAt(): ?\DateTimeInterface
  131.     {
  132.         return $this->updatedAt;
  133.     }
  134.     public function addMethod(LabTestMethod $method): self
  135.     {
  136.         if (!$this->methods->contains($method)) {
  137.             $this->methods[] = $method;
  138.             $method->setTest($this);
  139.         }
  140.         return $this;
  141.     }
  142.     public function removeMethod(LabTestMethod $method): self
  143.     {
  144.         if ($this->methods->removeElement($method)) {
  145.             if ($method->getTest() === $this) {
  146.                 $method->setMethod(null);
  147.             }
  148.         }
  149.         return $this;
  150.     }
  151.     public function __toString(): string
  152.     {
  153.         return $this->getName();
  154.     }
  155. }