src/Entity/Receta.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\RecetaRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\Common\Collections\Criteria;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use DateTime;
  9. /**
  10.  * @ORM\Entity(repositoryClass=RecetaRepository::class)
  11.  * @ORM\HasLifecycleCallbacks
  12.  */
  13. class Receta
  14. {
  15.     /**
  16.      * @ORM\Id
  17.      * @ORM\GeneratedValue
  18.      * @ORM\Column(type="integer")
  19.      */
  20.     private $id;
  21.     /**
  22.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="recetas")
  23.      * @ORM\JoinColumn(nullable=false)
  24.      */
  25.     private $doctor;
  26.     /**
  27.      * @ORM\Column(type="boolean")
  28.      */
  29.     private $estado;
  30.     /**
  31.      * @ORM\Column(type="datetime")
  32.      */
  33.     private $fecha;
  34.     /**
  35.      * @ORM\Column(type="string", length=50)
  36.      */
  37.     private $ip_crea;
  38.     /**
  39.      * @ORM\Column(type="string", length=50)
  40.      */
  41.     private $ip_modifica;
  42.     /**
  43.      * @ORM\Column(type="integer")
  44.      */
  45.     private $user_crea;
  46.     /**
  47.      * @ORM\Column(type="integer")
  48.      */
  49.     private $user_modifica;
  50.     /**
  51.      * @ORM\Column(type="datetime")
  52.      */
  53.     private $created_at;
  54.     /**
  55.      * @ORM\Column(type="datetime")
  56.      */
  57.     private $updated_at;
  58.     /**
  59.      * @ORM\ManyToOne(targetEntity=Paciente::class, inversedBy="recetas")
  60.      */
  61.     private $paciente;
  62.     /**
  63.      * @ORM\Column(type="boolean")
  64.      */
  65.     private $cerrada;
  66.     /**
  67.      * @ORM\OneToMany(targetEntity=RecetaDetalle::class, mappedBy="receta")
  68.      */
  69.     private $recetaDetalles;
  70.     /**
  71.      * @ORM\ManyToOne(targetEntity=HistoriaClinica::class, inversedBy="recetas")
  72.      * @ORM\JoinColumn(nullable=false)
  73.      */
  74.     private $historia;
  75.     /**
  76.      * @ORM\Column(type="text", nullable=true)
  77.      */
  78.     private $observacion;
  79.     
  80.     /**
  81.      * @ORM\Column(type="text", nullable=true)
  82.      */
  83.     private $rp;
  84.     /**
  85.      * @ORM\Column(type="text", nullable=true)
  86.      */
  87.     private $prescripcion;
  88.     
  89.     /**
  90.      * @ORM\Column(type="string", length=25, nullable=true)
  91.      */
  92.     private $tipo;
  93.     /**
  94.      * @ORM\Column(type="text", nullable=true)
  95.      */
  96.     private $notas_de_evolucion;
  97.     public function __construct()
  98.     {
  99.         $this->recetaDetalles = new ArrayCollection();
  100.     }
  101.     public function getId(): ?int
  102.     {
  103.         return $this->id;
  104.     }
  105.     public function getDoctor(): ?User
  106.     {
  107.         return $this->doctor;
  108.     }
  109.     public function setDoctor(?User $doctor): self
  110.     {
  111.         $this->doctor $doctor;
  112.         return $this;
  113.     }
  114.     public function getEstado(): ?bool
  115.     {
  116.         return $this->estado;
  117.     }
  118.     public function setEstado(bool $estado): self
  119.     {
  120.         $this->estado $estado;
  121.         return $this;
  122.     }
  123.     public function getFecha(): ?\DateTimeInterface
  124.     {
  125.         return $this->fecha;
  126.     }
  127.     public function setFecha(\DateTimeInterface $fecha): self
  128.     {
  129.         $this->fecha $fecha;
  130.         return $this;
  131.     }
  132.     public function getIpCrea(): ?string
  133.     {
  134.         return $this->ip_crea;
  135.     }
  136.     public function setIpCrea(string $ip_crea): self
  137.     {
  138.         $this->ip_crea $ip_crea;
  139.         return $this;
  140.     }
  141.     public function getIpModifica(): ?string
  142.     {
  143.         return $this->ip_modifica;
  144.     }
  145.     public function setIpModifica(string $ip_modifica): self
  146.     {
  147.         $this->ip_modifica $ip_modifica;
  148.         return $this;
  149.     }
  150.     public function getUserCrea(): ?int
  151.     {
  152.         return $this->user_crea;
  153.     }
  154.     public function setUserCrea(int $user_crea): self
  155.     {
  156.         $this->user_crea $user_crea;
  157.         return $this;
  158.     }
  159.     public function getUserModifica(): ?int
  160.     {
  161.         return $this->user_modifica;
  162.     }
  163.     public function setUserModifica(int $user_modifica): self
  164.     {
  165.         $this->user_modifica $user_modifica;
  166.         return $this;
  167.     }
  168.     public function getCreatedAt(): ?\DateTimeInterface
  169.     {
  170.         return $this->created_at;
  171.     }
  172.     public function setCreatedAt(\DateTimeInterface $created_at): self
  173.     {
  174.         $this->created_at $created_at;
  175.         return $this;
  176.     }
  177.     public function getUpdatedAt(): ?\DateTimeInterface
  178.     {
  179.         return $this->updated_at;
  180.     }
  181.     public function setUpdatedAt(\DateTimeInterface $updated_at): self
  182.     {
  183.         $this->updated_at $updated_at;
  184.         return $this;
  185.     }
  186.     public function getPaciente(): ?Paciente
  187.     {
  188.         return $this->paciente;
  189.     }
  190.     public function setPaciente(?Paciente $paciente): self
  191.     {
  192.         $this->paciente $paciente;
  193.         return $this;
  194.     }
  195.     public function getCerrada(): ?bool
  196.     {
  197.         return $this->cerrada;
  198.     }
  199.     public function setCerrada(bool $cerrada): self
  200.     {
  201.         $this->cerrada $cerrada;
  202.         return $this;
  203.     }
  204.     /**
  205.      * @return Collection|RecetaDetalle[]
  206.      */
  207.     public function getRecetaDetalles(): Collection
  208.     {
  209.         return $this->recetaDetalles;
  210.     }
  211.     /**
  212.      * @return Collection|RecetaDetalle[]
  213.      */
  214.     public function existe_examen($medicina): Collection
  215.     {
  216.         $criteria Criteria::create()
  217.             ->andWhere(Criteria::expr()->eq('medicina'$medicina));
  218.         
  219.         return $this->recetaDetalles->matching($criteria);
  220.         
  221.     }
  222.     public function addRecetaDetalle(RecetaDetalle $recetaDetalle): self
  223.     {
  224.         if (!$this->recetaDetalles->contains($recetaDetalle)) {
  225.             $this->recetaDetalles[] = $recetaDetalle;
  226.             $recetaDetalle->setReceta($this);
  227.         }
  228.         return $this;
  229.     }
  230.     public function removeRecetaDetalle(RecetaDetalle $recetaDetalle): self
  231.     {
  232.         if ($this->recetaDetalles->removeElement($recetaDetalle)) {
  233.             // set the owning side to null (unless already changed)
  234.             if ($recetaDetalle->getReceta() === $this) {
  235.                 $recetaDetalle->setReceta(null);
  236.             }
  237.         }
  238.         return $this;
  239.     }
  240.     /**
  241.      * @ORM\PrePersist
  242.      * @ORM\PreUpdate
  243.      */
  244.     public function updatedTimestamps(): void
  245.     {
  246.         $dateTimeNow = new DateTime('now');
  247.         $this->setUpdatedAt($dateTimeNow);
  248.         if ($this->getCreatedAt() === null) {
  249.             $this->setCreatedAt($dateTimeNow);
  250.         }
  251.     }
  252.     public function getHistoria(): ?HistoriaClinica
  253.     {
  254.         return $this->historia;
  255.     }
  256.     public function setHistoria(?HistoriaClinica $historia): self
  257.     {
  258.         $this->historia $historia;
  259.         return $this;
  260.     }
  261.     public function getObservacion(): ?string
  262.     {
  263.         return $this->observacion;
  264.     }
  265.     public function setObservacion(?string $observacion): self
  266.     {
  267.         $this->observacion $observacion;
  268.         return $this;
  269.     }
  270.     
  271.     public function getRp(): ?string
  272.     {
  273.         return $this->rp;
  274.     }
  275.     public function setRp(?string $rp): self
  276.     {
  277.         $this->rp $rp;
  278.         return $this;
  279.     }
  280.     public function getPrescripcion(): ?string
  281.     {
  282.         return $this->prescripcion;
  283.     }
  284.     public function setPrescripcion(?string $prescripcion): self
  285.     {
  286.         $this->prescripcion $prescripcion;
  287.         return $this;
  288.     }
  289.     
  290.     public function getTipo(): ?string
  291.     {
  292.         return $this->tipo;
  293.     }
  294.     public function setTipo(?string $tipo): self
  295.     {
  296.         $this->tipo $tipo;
  297.         return $this;
  298.     }
  299.     public function getNotasDeEvolucion(): ?string
  300.     {
  301.         return $this->notas_de_evolucion;
  302.     }
  303.     public function setNotasDeEvolucion(?string $notas_de_evolucion): self
  304.     {
  305.         $this->notas_de_evolucion $notas_de_evolucion;
  306.         return $this;
  307.     }
  308. }