<?php
namespace App\Entity;
use App\Repository\OrdenProcedimientoRepository;
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=OrdenProcedimientoRepository::class)
* @ORM\HasLifecycleCallbacks
*/
class OrdenProcedimiento
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity=Agenda::class, inversedBy="ordenProcedimientos")
* @ORM\JoinColumn(nullable=false)
*/
private $agenda;
/**
* @ORM\ManyToOne(targetEntity=Procedimientos::class, inversedBy="ordenProcedimientos")
* @ORM\JoinColumn(nullable=false)
*/
private $procedimiento;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $observacion;
/**
* @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\Column(type="smallint")
*/
private $estado;
/**
* @ORM\ManyToOne(targetEntity=Paciente::class, inversedBy="ordenProcedimientos")
*/
private $paciente;
/**
* @ORM\ManyToOne(targetEntity=Agenda::class, inversedBy="ordenProcedimientos")
* @ORM\JoinColumn(nullable=true)
*/
private $agendado;
/**
* @ORM\ManyToOne(targetEntity=OrdenProcedimiento::class, inversedBy="ordenProcedimientos")
* @ORM\JoinColumn(nullable=true)
*/
private $orden_procedimiento;
/**
* @ORM\Column(type="string", length=100, nullable=true)
*/
private $tipo;
/**
* @ORM\OneToMany(targetEntity=OrdenProcedimiento::class, mappedBy="orden_procedimiento")
*/
private $ordenProcedimientos;
/**
* @ORM\Column(type="smallint", options={"default": 1})
*/
private $dia_receta;
public function getId(): ?int
{
return $this->id;
}
public function getAgenda(): ?Agenda
{
return $this->agenda;
}
public function setAgenda(?Agenda $agenda): self
{
$this->agenda = $agenda;
return $this;
}
public function getProcedimiento(): ?Procedimientos
{
return $this->procedimiento;
}
public function setProcedimiento(?Procedimientos $procedimiento): self
{
$this->procedimiento = $procedimiento;
return $this;
}
public function getObservacion(): ?string
{
return $this->observacion;
}
public function setObservacion(?string $observacion): self
{
$this->observacion = $observacion;
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;
}
/**
* @ORM\PrePersist
* @ORM\PreUpdate
*/
public function updatedTimestamps(): void
{
$dateTimeNow = new DateTime('now');
$this->setUpdatedAt($dateTimeNow);
if ($this->getCreatedAt() === null) {
$this->setCreatedAt($dateTimeNow);
}
}
public function getEstado(): ?int
{
return $this->estado;
}
public function setEstado(int $estado): self
{
$this->estado = $estado;
return $this;
}
public function getPaciente(): ?Paciente
{
return $this->paciente;
}
public function setPaciente(?Paciente $paciente): self
{
$this->paciente = $paciente;
return $this;
}
public function getAgendado(): ?Agenda
{
return $this->agendado;
}
public function setAgendado(?Agenda $agendado): self
{
$this->agendado = $agendado;
return $this;
}
public function getOrdenProcedimiento(): ?OrdenProcedimiento
{
return $this->orden_procedimiento;
}
public function setOrdenProcedimiento(?OrdenProcedimiento $orden_procedimiento): self
{
$this->orden_procedimiento = $orden_procedimiento;
return $this;
}
public function getTipo(): ?string
{
return $this->tipo;
}
public function setTipo(?string $tipo): self
{
$this->tipo = $tipo;
return $this;
}
/**
* @return Collection|OrdenProcedimiento[]
*/
public function getOrdenProcedimientosPend(): Collection
{
$criteria = Criteria::create()
->andWhere(Criteria::expr()->eq('estado', '1'))
//->orderBy(['createdAt' => 'DESC'])
;
//dd($this);
return $this->ordenProcedimientos->matching($criteria);
}
public function getDiaReceta(): ?int
{
return $this->dia_receta;
}
public function setDiaReceta(int $dia_receta): self
{
$this->dia_receta = $dia_receta;
return $this;
}
}