<?php
namespace App\Entity;
use App\Repository\PatientRepository;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Validator\Constraints as Assert;
#[ORM\Entity(repositoryClass: PatientRepository::class)]
#[ORM\Table(name: 'patients'), UniqueEntity(fields: ['memberCode'], message: 'A patient already exists with this member code!')]
class Patient implements \Stringable
{
#[ORM\Id, ORM\GeneratedValue, ORM\Column(type: 'integer')]
private $id;
#[ORM\ManyToOne(targetEntity: Hospital::class), ORM\JoinColumn(nullable: false)]
private $hospital;
#[ORM\Column(type: 'string', length: 50)]
private string $uhId = 'UH-0001';
#[ORM\Column(type: 'string'), Assert\NotBlank]
#[Assert\Regex(pattern: '/^[a-z]+$/i', message: 'Your first name invalid')]
#[Assert\Length(
min: 2,
max: 15,
minMessage: 'Your first name must be at least {{ limit }} characters long',
maxMessage: 'Your first name cannot be longer than {{ limit }} characters'
)]
private $firstName;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Assert\Regex(pattern: '/^[a-z]+$/i', message: 'Your middle name invalid')]
#[Assert\Length(
min: 2,
max: 15,
minMessage: 'Your middle name must be at least {{ limit }} characters long',
maxMessage: 'Your middle name cannot be longer than {{ limit }} characters'
)]
private $middleName;
#[ORM\Column(type: 'string', length: 255), Assert\NotBlank]
#[Assert\Regex(pattern: '/^[a-z]+$/i', message: 'Your Last name invalid')]
#[Assert\Length(
min: 2,
max: 15,
minMessage: 'Your Last name must be at least {{ limit }} characters long',
maxMessage: 'Your Last name cannot be longer than {{ limit }} characters'
)]
private $lastName;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Assert\Regex(pattern: '/^[a-z]+$/i', message: 'Your Father/Husband`s Name invalid')]
#[Assert\Length(
min: 2,
max: 20,
minMessage: 'Your Father/Husband`s Name must be at least {{ limit }} characters long',
maxMessage: 'Your Father/Husband`s Name cannot be longer than {{ limit }} characters'
)]
private $fatherHusbandName;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $photo;
#[ORM\Column(name: 'gender', type: 'string', nullable: false, columnDefinition: "enum('Male', 'Female', 'Transgender')")]
#[Assert\NotBlank]
private $gender;
#[ORM\Column(name: 'marital_status', type: 'string', nullable: false, columnDefinition: "enum('Married', 'Unmarried', 'Other')")]
#[Assert\NotBlank]
private $maritalStatus;
#[ORM\Column(type: 'date'), Assert\NotBlank]
private $dob;
#[ORM\Column(type: 'string', length: 255), Assert\NotBlank]
private $housePlotNo;
#[ORM\Column(type: 'text', nullable: true)]
private $address;
#[ORM\ManyToOne(targetEntity: Village::class)]
#[ORM\JoinColumn(nullable: false), Assert\NotBlank]
private $village;
#[ORM\Column(type: 'string', length: 6), Assert\NotBlank]
#[Assert\Length(min: 6, maxMessage: 'Pincode must have max. 6 digits')]
#[Assert\Regex(pattern: '/^[0-9]*$/', message: 'Pincode must be in positive number')]
private $pincode;
#[ORM\Column(type: 'string', length: 15, nullable: true)]
#[Assert\Regex(pattern: '/^[0-9]*$/', message: 'Mobile No. must be in digits only')]
#[Assert\Length(min: 10, max: 15, minMessage: 'Mobile No. must have min. {{ limit }} digits', maxMessage: 'Mobile No. must have max. {{ limit }} digits')]
private $mobile;
#[ORM\Column(type: 'string', length: 100, nullable: true)]
private $email;
#[ORM\Column(type: 'string', length: 12, nullable: true)]
private $adharNum;
#[ORM\Column(type: 'string', length: 15, nullable: true)]
#[Assert\Regex(pattern: '/^[0-9a-zA-Z]+$/i', message: 'Your BPL Number invalid')]
#[Assert\Length(
max: 18,
maxMessage: 'Your BPL Number longer than {{ limit }} characters'
)]
private $bplNum;
#[ORM\Column(type: 'string', length: 50, nullable: true)]
private $healthIdNumber;
#[ORM\Column(type: 'string', length: 50, nullable: true)]
private $healthAddress;
#[ORM\Column(type: 'string', length: 50, nullable: true)]
private $abpmJay;
/* #[ORM\Column(name: 'cast', type: 'string', columnDefinition: "enum('General', 'OBC', 'SC', 'ST', 'SEBC', 'Nt-b', 'Nt-d')")]
private $cast; */
#[ORM\Column(type: 'string', length: 50, nullable: true)]
private $occupation;
#[ORM\Column(type: 'string', length: 10, nullable: true), Assert\NotBlank]
#[Assert\Length(min: 2, maxMessage: 'Family Income must have max. 2 digits')]
#[Assert\Regex(pattern: '/^[0-9]*$/', message: 'Family Income must be in positive number')]
private $familyIncome;
#[ORM\Column(type: 'boolean')]
private bool $isActive = true;
#[ORM\Column(type: 'string', length: 50, nullable: true)]
private $bankName;
#[ORM\Column(type: 'string', length: 50, nullable: true)]
private $bankBranch;
#[ORM\Column(type: 'text', nullable: true)]
private $bankBranchAddress;
#[ORM\Column(type: 'integer', length: 50, nullable: true)]
#[Assert\Regex(pattern: '/^[0-9]+$/i', message: 'Your Account Number invalid')]
#[Assert\Length(
max: 18,
maxMessage: 'Your Account Number longer than {{ limit }} characters'
)]
private $bankAccount;
#[ORM\Column(type: 'string', length: 25, nullable: true)]
#[Assert\Regex(pattern: '/^[a-zA-Z0-9]+$/i', message: 'IFSC code must be in alphabets')]
private $bankIfsCode;
#[Gedmo\Timestampable(on: 'create'), ORM\Column(type: 'datetime')]
private $createdAt;
#[Gedmo\Timestampable(on: 'update'), ORM\Column(type: 'datetime')]
private $updatedAt;
#[ORM\Column(type: 'string', length: 50, nullable: true, unique: true)]
private $memberCode;
#[ORM\Column(type: 'boolean', options: ['default' => '1'])]
private bool $isAlive = true;
#[ORM\ManyToOne(targetEntity: DeathCause::class)]
private $deathCause;
#[Gedmo\Blameable(on: 'create'), ORM\ManyToOne(targetEntity: User::class), ORM\JoinColumn(name: 'created_by')]
private $createdBy;
#[Gedmo\Blameable(on: 'update'), ORM\ManyToOne(targetEntity: User::class), ORM\JoinColumn(name: 'updated_by')]
private $updatedBy;
#[ORM\Column(type: 'datetime', nullable: true)]
private $expiredAt;
public function getId(): ?int
{
return $this->id;
}
public function getFirstName(): ?string
{
return $this->firstName;
}
public function setFirstName(string $firstName): self
{
$this->firstName = strip_tags($firstName);
return $this;
}
public function getDob(): ?\DateTimeInterface
{
return $this->dob;
}
public function setDob(\DateTimeInterface $dob): self
{
$this->dob = $dob;
return $this;
}
public function getAddress(): ?string
{
return $this->address;
}
public function setAddress(string $address): self
{
$this->address = strip_tags($address);
return $this;
}
public function getVillage(): ?Village
{
return $this->village;
}
public function setVillage(Village $village): self
{
$this->village = $village;
return $this;
}
public function getPincode(): ?string
{
return $this->pincode;
}
public function setPincode(string $pincode): self
{
$this->pincode = $pincode;
return $this;
}
public function getHospital(): ?Hospital
{
return $this->hospital;
}
public function setHospital(Hospital $hospital): self
{
$this->hospital = $hospital;
return $this;
}
public function getMobile(): ?string
{
return $this->mobile;
}
public function setMobile(string $mobile): self
{
$this->mobile = $mobile;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(?string $email): self
{
$this->email = strip_tags($email);
return $this;
}
public function getAdharNum(): ?string
{
return $this->adharNum;
}
public function setAdharNum(?string $adharNum): self
{
$this->adharNum = $adharNum;
return $this;
}
public function getUhId(): ?string
{
return $this->uhId;
}
public function setUhId(string $uhId): self
{
$this->uhId = $uhId;
return $this;
}
public function getIsActive(): ?bool
{
return $this->isActive;
}
public function setIsActive(bool $isActive): self
{
$this->isActive = $isActive;
return $this;
}
public function getIsAlive(): ?bool
{
return $this->isAlive;
}
public function setIsAlive(bool $isAlive): self
{
$this->isAlive = $isAlive;
return $this;
}
public function getDeathCause(): ?DeathCause
{
return $this->deathCause;
}
public function setDeathCause(?DeathCause $deathCause): self
{
$this->deathCause = $deathCause;
return $this;
}
public function getBankName(): ?string
{
return $this->bankName;
}
public function setBankName(string $bankName): self
{
$this->bankName = strip_tags($bankName);
return $this;
}
public function getBankBranch(): ?string
{
return $this->bankBranch;
}
public function setBankBranch(string $bankBranch): self
{
$this->bankBranch = strip_tags($bankBranch);
return $this;
}
public function getBankBranchAddress(): ?string
{
return $this->bankBranchAddress;
}
public function setBankBranchAddress(string $bankBranchAddress): self
{
$this->bankBranchAddress = strip_tags($bankBranchAddress);
return $this;
}
public function getBankAccount(): ?string
{
return $this->bankAccount;
}
public function setBankAccount(string $bankAccount): self
{
$this->bankAccount = $bankAccount;
return $this;
}
public function getBankIfsCode(): ?string
{
return $this->bankIfsCode;
}
public function setBankIfsCode(string $bankIfsCode): self
{
$this->bankIfsCode = strip_tags($bankIfsCode);
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
public function getName()
{
return $this->firstName . ' ' . $this->middleName . ' ' . $this->lastName;
}
public function getMiddleName(): ?string
{
return $this->middleName;
}
public function setMiddleName(?string $middleName): self
{
$this->middleName = strip_tags($middleName);
return $this;
}
public function getLastName(): ?string
{
return $this->lastName;
}
public function setLastName(string $lastName): self
{
$this->lastName = strip_tags($lastName);
return $this;
}
public function getPhoto(): ?string
{
return $this->photo;
}
public function setPhoto(string $photo): self
{
$this->photo = $photo;
return $this;
}
public function getFatherHusbandName(): ?string
{
return $this->fatherHusbandName;
}
public function setFatherHusbandName(string $fatherHusbandName): self
{
$this->fatherHusbandName = strip_tags($fatherHusbandName);
return $this;
}
public function getGender(): ?string
{
return $this->gender;
}
public function setGender(string $gender): self
{
$this->gender = $gender;
return $this;
}
public function getMaritalStatus(): ?string
{
return $this->maritalStatus;
}
public function setMaritalStatus(string $maritalStatus): self
{
$this->maritalStatus = $maritalStatus;
return $this;
}
public function getHousePlotNo(): ?string
{
return $this->housePlotNo;
}
public function setHousePlotNo(string $housePlotNo): self
{
$this->housePlotNo = strip_tags($housePlotNo);
return $this;
}
public function getBplNum(): ?string
{
return $this->bplNum;
}
public function setBplNum(?string $bplNum): self
{
$this->bplNum = $bplNum;
return $this;
}
public function getAbpmJay(): ?string
{
return $this->abpmJay;
}
public function setAbpmJay(?string $abpmJay): self
{
$this->abpmJay = strip_tags($abpmJay);
return $this;
}
/* public function getCast(): ?string
{
return $this->cast;
}
public function setCast(string $cast): self
{
$this->cast = $cast;
return $this;
} */
public function getOccupation(): ?string
{
return $this->occupation;
}
public function setOccupation(?string $occupation): self
{
$this->occupation = strip_tags($occupation);
return $this;
}
public function getFamilyIncome(): ?int
{
return $this->familyIncome;
}
public function setFamilyIncome(?int $familyIncome): self
{
$this->familyIncome = $familyIncome;
return $this;
}
public function getMemberCode(): ?string
{
return $this->memberCode;
}
public function setMemberCode(string $memberCode): self
{
$this->memberCode = $memberCode;
return $this;
}
public function getCreatedBy(): ?User
{
return $this->createdBy;
}
public function getUpdatedBy(): ?User
{
return $this->updatedBy;
}
public function getExpiredAt(): ?\DateTimeInterface
{
return $this->expiredAt;
}
public function setExpiredAt(?\DateTimeInterface $expiredAt): self
{
$this->expiredAt = $expiredAt;
return $this;
}
public function getHealthIdNumber(): ?string
{
return $this->healthIdNumber;
}
public function setHealthIdNumber(?string $healthIdNumber): self
{
$this->healthIdNumber = $healthIdNumber;
return $this;
}
public function getHealthAddress(): ?string
{
return $this->healthAddress;
}
public function setHealthAddress(?string $healthAddress): self
{
$this->healthAddress = $healthAddress;
return $this;
}
public function getAge()
{
$birth = $this->getDob();
$end = $this->getExpiredAt();
if (!$end) {
$end = new \DateTime('now');
}
$difference = $end->diff($birth);
return $difference->format('%y years, %m months');
}
public function __toString(): string
{
return $this->getName();
}
}