<?php
namespace App\Entity;
use App\Repository\ExamenOrdenRepository;
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=ExamenOrdenRepository::class)
* @ORM\HasLifecycleCallbacks
*/
class ExamenOrden
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="boolean")
*/
private $estado;
/**
* @ORM\Column(type="integer")
*/
private $cantidad;
/**
* @ORM\Column(type="decimal", precision=10, scale=4)
*/
private $valor;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $observaciom;
/**
* @ORM\Column(type="float")
*/
private $descuento;
/**
* @ORM\Column(type="float")
*/
private $descuento_valor;
/**
* @ORM\Column(type="float")
*/
private $recargo;
/**
* @ORM\Column(type="float")
*/
private $recargo_valor;
/**
* @ORM\Column(type="float")
*/
private $total_valor;
/**
* @ORM\Column(type="datetime")
*/
private $fecha_orden;
/**
* @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\OneToMany(targetEntity=ExamenDetalle::class, mappedBy="examen_orden")
*/
private $examenDetalles;
/**
* @ORM\ManyToOne(targetEntity=SeguroPrivado::class, inversedBy="examenOrdens")
* @ORM\JoinColumn(nullable=false)
*/
private $seguro;
/**
* @ORM\ManyToOne(targetEntity=Paciente::class, inversedBy="examenOrdens")
* @ORM\JoinColumn(nullable=false)
*/
private $paciente;
/**
* @ORM\ManyToOne(targetEntity=HistoriaClinica::class, inversedBy="examenOrdens")
* @ORM\JoinColumn(nullable=false)
*/
private $historia;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="examenOrdens")
* @ORM\JoinColumn(nullable=false)
*/
private $doctor;
/**
* @ORM\Column(type="boolean", options={"default":0})
*/
private $agendado;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $fecha_agenda;
/**
* @ORM\OneToMany(targetEntity=ExamenOrdenResultado::class, mappedBy="orden")
*/
private $examenOrdenResultados;
public function __construct()
{
$this->examenDetalles = new ArrayCollection();
$this->examenOrdenResultados = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getEstado(): ?bool
{
return $this->estado;
}
public function setEstado(bool $estado): self
{
$this->estado = $estado;
return $this;
}
public function getCantidad(): ?int
{
return $this->cantidad;
}
public function setCantidad(int $cantidad): self
{
$this->cantidad = $cantidad;
return $this;
}
public function getValor(): ?float
{
return $this->valor;
}
public function setValor(float $valor): self
{
$this->valor = $valor;
return $this;
}
public function getObservaciom(): ?string
{
return $this->observaciom;
}
public function setObservaciom(?string $observaciom): self
{
$this->observaciom = $observaciom;
return $this;
}
public function getDescuento(): ?float
{
return $this->descuento;
}
public function setDescuento(float $descuento): self
{
$this->descuento = $descuento;
return $this;
}
public function getDescuentoValor(): ?float
{
return $this->descuento_valor;
}
public function setDescuentoValor(float $descuento_valor): self
{
$this->descuento_valor = $descuento_valor;
return $this;
}
public function getRecargo(): ?float
{
return $this->recargo;
}
public function setRecargo(float $recargo): self
{
$this->recargo = $recargo;
return $this;
}
public function getRecargoValor(): ?float
{
return $this->recargo_valor;
}
public function setRecargoValor(float $recargo_valor): self
{
$this->recargo_valor = $recargo_valor;
return $this;
}
public function getTotalValor(): ?float
{
return $this->total_valor;
}
public function setTotalValor(float $total_valor): self
{
$this->total_valor = $total_valor;
return $this;
}
public function getFechaOrden(): ?\DateTimeInterface
{
return $this->fecha_orden;
}
public function setFechaOrden(?\DateTimeInterface $fecha_orden): self
{
$this->fecha_orden = $fecha_orden;
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;
}
/**
* @return Collection|ExamenDetalle[]
*/
public function getExamenDetalles(): Collection
{
return $this->examenDetalles;
}
public function getExamenDetalles_By($examen)
{
$criteria = Criteria::create()
->andWhere(Criteria::expr()->eq('examen', $examen))
//->orderBy(['createdAt' => 'DESC'])
;
return $this->examenDetalles->matching($criteria);
/*foreach ($this->getExamenDetalles() as $detalle) {
//dd($detalle,$examen);
if($detalle->getExamen()==$examen){
return $examen;
}
}
return null;*/
//return $this->examenDetalles;
}
public function addExamenDetalle(ExamenDetalle $examenDetalle): self
{
if (!$this->examenDetalles->contains($examenDetalle)) {
$this->examenDetalles[] = $examenDetalle;
$examenDetalle->setExamenOrden($this);
}
return $this;
}
public function removeExamenDetalle(ExamenDetalle $examenDetalle): self
{
if ($this->examenDetalles->removeElement($examenDetalle)) {
// set the owning side to null (unless already changed)
if ($examenDetalle->getExamenOrden() === $this) {
$examenDetalle->setExamenOrden(null);
}
}
return $this;
}
public function getSeguro(): ?SeguroPrivado
{
return $this->seguro;
}
public function setSeguro(?SeguroPrivado $seguro): self
{
$this->seguro = $seguro;
return $this;
}
public function getPaciente(): ?Paciente
{
return $this->paciente;
}
public function setPaciente(?Paciente $paciente): self
{
$this->paciente = $paciente;
return $this;
}
public function getHistoria(): ?HistoriaClinica
{
return $this->historia;
}
public function setHistoria(?HistoriaClinica $historia): self
{
$this->historia = $historia;
return $this;
}
public function getDoctor(): ?User
{
return $this->doctor;
}
public function setDoctor(?User $doctor): self
{
$this->doctor = $doctor;
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 getAgendado()
{
return $this->agendado;
}
public function setAgendado($agendado): self
{
$this->agendado = $agendado;
return $this;
}
public function getFechaAgenda(): ?\DateTimeInterface
{
return $this->fecha_agenda;
}
public function setFechaAgenda(?\DateTimeInterface $fecha_agenda): self
{
$this->fecha_agenda = $fecha_agenda;
return $this;
}
/**
* @return Collection|ExamenOrdenResultado[]
*/
public function getExamenOrdenResultados(): Collection
{
$criteria = Criteria::create()
->andWhere(Criteria::expr()->eq('estado', 1))
->orderBy(['examen' => 'ASC', 'id' => 'ASC'])
;
return $this->examenOrdenResultados->matching($criteria);
}
public function getExamenOrdenResultadosOK(): Collection
{
$criteria = Criteria::create()
->andWhere(Criteria::expr()->neq('resultado', null))
->andWhere(Criteria::expr()->eq('estado', 1))
//->orderBy(['createdAt' => 'DESC'])
;
return $this->examenOrdenResultados->matching($criteria);
}
/**
* @return Collection|ExamenOrdenResultado[]
*/
public function getExamenOrdenResultadosTodos(): Collection
{
$criteria = Criteria::create()
//->andWhere(Criteria::expr()->eq('estado', 1))
->orderBy(['examen' => 'ASC', 'id' => 'ASC'])
;
return $this->examenOrdenResultados->matching($criteria);
}
/**
* @return Collection|ExamenOrdenResultado[]
*/
public function getExamenOrdenResultadosTodos_examen($examen): Collection
{
$criteria = Criteria::create()
->andWhere(Criteria::expr()->eq('examen', $examen))
->andWhere(Criteria::expr()->eq('estado', 1))
->orderBy(['examen' => 'ASC', 'id' => 'ASC'])
;
return $this->examenOrdenResultados->matching($criteria);
}
public function addExamenOrdenResultado(ExamenOrdenResultado $examenOrdenResultado): self
{
if (!$this->examenOrdenResultados->contains($examenOrdenResultado)) {
$this->examenOrdenResultados[] = $examenOrdenResultado;
$examenOrdenResultado->setOrden($this);
}
return $this;
}
public function removeExamenOrdenResultado(ExamenOrdenResultado $examenOrdenResultado): self
{
if ($this->examenOrdenResultados->removeElement($examenOrdenResultado)) {
// set the owning side to null (unless already changed)
if ($examenOrdenResultado->getOrden() === $this) {
$examenOrdenResultado->setOrden(null);
}
}
return $this;
}
}