<?php
namespace App\Entity;
use App\Repository\RecetaRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\Criteria;
use Doctrine\ORM\Mapping as ORM;
use DateTime;
/**
* @ORM\Entity(repositoryClass=RecetaRepository::class)
* @ORM\HasLifecycleCallbacks
*/
class Receta
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="recetas")
* @ORM\JoinColumn(nullable=false)
*/
private $doctor;
/**
* @ORM\Column(type="boolean")
*/
private $estado;
/**
* @ORM\Column(type="datetime")
*/
private $fecha;
/**
* @ORM\Column(type="string", length=50)
*/
private $ip_crea;
/**
* @ORM\Column(type="string", length=50)
*/
private $ip_modifica;
/**
* @ORM\Column(type="integer")
*/
private $user_crea;
/**
* @ORM\Column(type="integer")
*/
private $user_modifica;
/**
* @ORM\Column(type="datetime")
*/
private $created_at;
/**
* @ORM\Column(type="datetime")
*/
private $updated_at;
/**
* @ORM\ManyToOne(targetEntity=Paciente::class, inversedBy="recetas")
*/
private $paciente;
/**
* @ORM\Column(type="boolean")
*/
private $cerrada;
/**
* @ORM\OneToMany(targetEntity=RecetaDetalle::class, mappedBy="receta")
*/
private $recetaDetalles;
/**
* @ORM\ManyToOne(targetEntity=HistoriaClinica::class, inversedBy="recetas")
* @ORM\JoinColumn(nullable=false)
*/
private $historia;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $observacion;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $rp;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $prescripcion;
/**
* @ORM\Column(type="string", length=25, nullable=true)
*/
private $tipo;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $notas_de_evolucion;
public function __construct()
{
$this->recetaDetalles = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getDoctor(): ?User
{
return $this->doctor;
}
public function setDoctor(?User $doctor): self
{
$this->doctor = $doctor;
return $this;
}
public function getEstado(): ?bool
{
return $this->estado;
}
public function setEstado(bool $estado): self
{
$this->estado = $estado;
return $this;
}
public function getFecha(): ?\DateTimeInterface
{
return $this->fecha;
}
public function setFecha(\DateTimeInterface $fecha): self
{
$this->fecha = $fecha;
return $this;
}
public function getIpCrea(): ?string
{
return $this->ip_crea;
}
public function setIpCrea(string $ip_crea): self
{
$this->ip_crea = $ip_crea;
return $this;
}
public function getIpModifica(): ?string
{
return $this->ip_modifica;
}
public function setIpModifica(string $ip_modifica): self
{
$this->ip_modifica = $ip_modifica;
return $this;
}
public function getUserCrea(): ?int
{
return $this->user_crea;
}
public function setUserCrea(int $user_crea): self
{
$this->user_crea = $user_crea;
return $this;
}
public function getUserModifica(): ?int
{
return $this->user_modifica;
}
public function setUserModifica(int $user_modifica): self
{
$this->user_modifica = $user_modifica;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->created_at;
}
public function setCreatedAt(\DateTimeInterface $created_at): self
{
$this->created_at = $created_at;
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updated_at;
}
public function setUpdatedAt(\DateTimeInterface $updated_at): self
{
$this->updated_at = $updated_at;
return $this;
}
public function getPaciente(): ?Paciente
{
return $this->paciente;
}
public function setPaciente(?Paciente $paciente): self
{
$this->paciente = $paciente;
return $this;
}
public function getCerrada(): ?bool
{
return $this->cerrada;
}
public function setCerrada(bool $cerrada): self
{
$this->cerrada = $cerrada;
return $this;
}
/**
* @return Collection|RecetaDetalle[]
*/
public function getRecetaDetalles(): Collection
{
return $this->recetaDetalles;
}
/**
* @return Collection|RecetaDetalle[]
*/
public function existe_examen($medicina): Collection
{
$criteria = Criteria::create()
->andWhere(Criteria::expr()->eq('medicina', $medicina));
return $this->recetaDetalles->matching($criteria);
}
public function addRecetaDetalle(RecetaDetalle $recetaDetalle): self
{
if (!$this->recetaDetalles->contains($recetaDetalle)) {
$this->recetaDetalles[] = $recetaDetalle;
$recetaDetalle->setReceta($this);
}
return $this;
}
public function removeRecetaDetalle(RecetaDetalle $recetaDetalle): self
{
if ($this->recetaDetalles->removeElement($recetaDetalle)) {
// set the owning side to null (unless already changed)
if ($recetaDetalle->getReceta() === $this) {
$recetaDetalle->setReceta(null);
}
}
return $this;
}
/**
* @ORM\PrePersist
* @ORM\PreUpdate
*/
public function updatedTimestamps(): void
{
$dateTimeNow = new DateTime('now');
$this->setUpdatedAt($dateTimeNow);
if ($this->getCreatedAt() === null) {
$this->setCreatedAt($dateTimeNow);
}
}
public function getHistoria(): ?HistoriaClinica
{
return $this->historia;
}
public function setHistoria(?HistoriaClinica $historia): self
{
$this->historia = $historia;
return $this;
}
public function getObservacion(): ?string
{
return $this->observacion;
}
public function setObservacion(?string $observacion): self
{
$this->observacion = $observacion;
return $this;
}
public function getRp(): ?string
{
return $this->rp;
}
public function setRp(?string $rp): self
{
$this->rp = $rp;
return $this;
}
public function getPrescripcion(): ?string
{
return $this->prescripcion;
}
public function setPrescripcion(?string $prescripcion): self
{
$this->prescripcion = $prescripcion;
return $this;
}
public function getTipo(): ?string
{
return $this->tipo;
}
public function setTipo(?string $tipo): self
{
$this->tipo = $tipo;
return $this;
}
public function getNotasDeEvolucion(): ?string
{
return $this->notas_de_evolucion;
}
public function setNotasDeEvolucion(?string $notas_de_evolucion): self
{
$this->notas_de_evolucion = $notas_de_evolucion;
return $this;
}
}