<?php
namespace App\Entity;
use App\Repository\MedicinaRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use DateTime;
/**
* @ORM\Entity(repositoryClass=MedicinaRepository::class)
* @ORM\HasLifecycleCallbacks
*/
class Medicina
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $nombre;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $presentacion;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $indicaciones;
/**
* @ORM\Column(type="boolean")
*/
private $estado;
/**
* @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=RecetaDetalle::class, mappedBy="medicina")
*/
private $recetaDetalles;
/**
* @ORM\ManyToMany(targetEntity=Generico::class, inversedBy="medicinas")
*/
private $generico;
/**
* @ORM\Column(type="string", length=50)
*/
private $codigo;
/**
* @ORM\Column(type="decimal", precision=10, scale=4)
*/
private $valor;
/**
* @ORM\Column(type="decimal", precision=10, scale=4)
*/
private $iva;
/**
* @ORM\Column(type="smallint")
*/
private $tipo;
/**
* @ORM\OneToOne(targetEntity=Producto::class)
* @ORM\JoinColumn(name="producto_id", referencedColumnName="id", nullable=true)
*/
private $producto;
public function __construct()
{
$this->recetaDetalles = new ArrayCollection();
$this->generico = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getNombre(): ?string
{
return $this->nombre;
}
public function setNombre(string $nombre): self
{
$this->nombre = $nombre;
return $this;
}
public function getPresentacion(): ?string
{
return $this->presentacion;
}
public function setPresentacion(string $presentacion): self
{
$this->presentacion = $presentacion;
return $this;
}
public function getIndicaciones(): ?string
{
return $this->indicaciones;
}
public function setIndicaciones(string $indicaciones): self
{
$this->indicaciones = $indicaciones;
return $this;
}
public function getEstado(): ?bool
{
return $this->estado;
}
public function setEstado(bool $estado): self
{
$this->estado = $estado;
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 getTipo(): ?int
{
return $this->tipo;
}
public function setTipo(int $tipo): self
{
$this->tipo = $tipo;
return $this;
}
/**
* @return Collection|RecetaDetalle[]
*/
public function getRecetaDetalles(): Collection
{
return $this->recetaDetalles;
}
public function addRecetaDetalle(RecetaDetalle $recetaDetalle): self
{
if (!$this->recetaDetalles->contains($recetaDetalle)) {
$this->recetaDetalles[] = $recetaDetalle;
$recetaDetalle->setMedicina($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->getMedicina() === $this) {
$recetaDetalle->setMedicina(null);
}
}
return $this;
}
/**
* @return Collection|Generico[]
*/
public function getGenerico(): Collection
{
return $this->generico;
}
public function addGenerico(Generico $generico): self
{
if (!$this->generico->contains($generico)) {
$this->generico[] = $generico;
}
return $this;
}
public function removeGenerico(Generico $generico): self
{
$this->generico->removeElement($generico);
return $this;
}
public function getCodigo(): ?string
{
return $this->codigo;
}
public function setCodigo(string $codigo): self
{
$this->codigo = $codigo;
return $this;
}
public function getValor(): ?string
{
return $this->valor;
}
public function setValor(string $valor): self
{
$this->valor = $valor;
return $this;
}
public function getIva(): ?string
{
return $this->iva;
}
public function setIva(string $iva): self
{
$this->iva = $iva;
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 getProducto(): ?Producto
{
return $this->producto;
}
public function setProducto(?Producto $producto): self
{
$this->producto = $producto;
return $this;
}
}