Add fixtures to generate randomized data
This commit is contained in:
parent
fe44642fee
commit
3391737c45
17
src/DataFixtures/AppFixtures.php
Normal file
17
src/DataFixtures/AppFixtures.php
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\DataFixtures;
|
||||||
|
|
||||||
|
use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||||
|
use Doctrine\Persistence\ObjectManager;
|
||||||
|
|
||||||
|
class AppFixtures extends Fixture
|
||||||
|
{
|
||||||
|
public function load(ObjectManager $manager): void
|
||||||
|
{
|
||||||
|
// $product = new Product();
|
||||||
|
// $manager->persist($product);
|
||||||
|
|
||||||
|
$manager->flush();
|
||||||
|
}
|
||||||
|
}
|
58
src/DataFixtures/MemberCaseFixture.php
Normal file
58
src/DataFixtures/MemberCaseFixture.php
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\DataFixtures;
|
||||||
|
|
||||||
|
use App\Entity\MemberCase;
|
||||||
|
use App\Entity\ReferralSource;
|
||||||
|
use App\Entity\User;
|
||||||
|
use App\Entity\UserCase;
|
||||||
|
use App\Enums\CaseLevel;
|
||||||
|
use App\Enums\County;
|
||||||
|
use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||||
|
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
|
||||||
|
use Doctrine\Persistence\ObjectManager;
|
||||||
|
|
||||||
|
class MemberCaseFixture extends Fixture implements DependentFixtureInterface
|
||||||
|
{
|
||||||
|
public function load(ObjectManager $manager): void
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
$sources = $manager->getRepository(ReferralSource::class)->findAll();
|
||||||
|
$users = $manager->getRepository(User::class)->findAll();
|
||||||
|
|
||||||
|
$gen = \Faker\Factory::create();
|
||||||
|
|
||||||
|
for ($x = 0; $x < 50; $x++) {
|
||||||
|
$case = new MemberCase();
|
||||||
|
$case->setCaseNumber($gen->numberBetween(1000000, 9999999))
|
||||||
|
->setDcsCaseId($gen->numberBetween(1000000, 9999999))
|
||||||
|
->setFirstName($gen->firstName())
|
||||||
|
->setLastName($gen->lastName())
|
||||||
|
->setCounty($gen->randomElement(County::class))
|
||||||
|
->setReferralSource($gen->randomElement($sources))
|
||||||
|
->setLevel($gen->randomElement(CaseLevel::class))
|
||||||
|
->setAdmitDate($gen->dateTimeBetween('-1 year', 'now'))
|
||||||
|
->setReferralType('DCS')
|
||||||
|
;
|
||||||
|
|
||||||
|
$uc = new UserCase();
|
||||||
|
$uc->setMemberCase($case);
|
||||||
|
$uc->setUser($gen->randomElement($users));
|
||||||
|
|
||||||
|
print "Adding member case {$case->getCaseNumber()}".PHP_EOL;
|
||||||
|
|
||||||
|
$manager->persist($case);
|
||||||
|
$manager->persist($uc);
|
||||||
|
}
|
||||||
|
|
||||||
|
$manager->flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDependencies(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
ReferralSourceFixture::class,
|
||||||
|
UserFixture::class,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
83
src/DataFixtures/MemberFixture.php
Normal file
83
src/DataFixtures/MemberFixture.php
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\DataFixtures;
|
||||||
|
|
||||||
|
use App\Entity\Member;
|
||||||
|
use App\Entity\MemberCase;
|
||||||
|
use App\Enums\GenderType;
|
||||||
|
use App\Enums\RaceType;
|
||||||
|
use App\Enums\RelationshipType;
|
||||||
|
use App\Enums\State;
|
||||||
|
use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||||
|
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
|
||||||
|
use Doctrine\Persistence\ObjectManager;
|
||||||
|
|
||||||
|
class MemberFixture extends Fixture implements DependentFixtureInterface
|
||||||
|
{
|
||||||
|
public function load(ObjectManager $manager): void
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
$gen = \Faker\Factory::create();
|
||||||
|
$cases = $manager->getRepository(MemberCase::class)->findAll();
|
||||||
|
|
||||||
|
foreach ($cases as $case) {
|
||||||
|
/** @var MemberCase $case */
|
||||||
|
$caseLastName = $case->getLastName();
|
||||||
|
print "Adding members for case {$case->getCaseName()}".PHP_EOL;
|
||||||
|
$memCount = $gen->numberBetween(0, 5);
|
||||||
|
for ($x = 0; $x < $memCount; $x++) {
|
||||||
|
$isChild = $gen->boolean();
|
||||||
|
$isParent = ($isChild ? false : $gen->boolean());
|
||||||
|
$isLegalGuardian = (!$isParent && !$isChild ? $gen->boolean() : false);
|
||||||
|
$dcsApproved = (!$isParent && !$isChild ? $gen->boolean() : false);
|
||||||
|
$sameLastName = $gen->boolean();
|
||||||
|
$mem = new Member();
|
||||||
|
$name = $gen->firstName().' '.$gen->lastName();
|
||||||
|
$username = strtolower(str_replace(' ', '.', $name));
|
||||||
|
$phone = substr(str_replace(['-', '+', ' ', '(', ')'], '', $gen->e164PhoneNumber()), -10);
|
||||||
|
|
||||||
|
$mem->setRelationship($gen->randomElement(RelationshipType::class))
|
||||||
|
->setPersonalId($gen->numberBetween(1000000, 9999999))
|
||||||
|
->setGender($gen->randomElement(GenderType::class))
|
||||||
|
->setRace($gen->randomElement(RaceType::class))
|
||||||
|
->setPhone($phone)
|
||||||
|
->setCellPhone($phone)
|
||||||
|
->setEmail($username.'@'.$gen->freeEmailDomain())
|
||||||
|
->setAddress($gen->streetAddress())
|
||||||
|
->setCity($gen->city())
|
||||||
|
->setState(State::IN->name)
|
||||||
|
->setZip($gen->postcode())
|
||||||
|
->setDob(
|
||||||
|
$gen->dateTimeBetween(
|
||||||
|
($isChild ? '-16 years' : '-50 years'),
|
||||||
|
($isParent || $isLegalGuardian ? '-16 years' : '-1 month')
|
||||||
|
)
|
||||||
|
)
|
||||||
|
->setFirstName($gen->firstName())
|
||||||
|
->setLastName($sameLastName ? $caseLastName : $gen->lastName())
|
||||||
|
->setChild($isChild)
|
||||||
|
->setParent($isParent)
|
||||||
|
->setLegalGuardian($isLegalGuardian)
|
||||||
|
->setAdultChild(false)
|
||||||
|
->setParentsLiveTogether(false)
|
||||||
|
->setDcsApproved($dcsApproved)
|
||||||
|
->setCaseId($case)
|
||||||
|
;
|
||||||
|
|
||||||
|
print "Adding member {$mem->getFirstName()} {$mem->getLastName()}".PHP_EOL;
|
||||||
|
|
||||||
|
$manager->persist($mem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$manager->flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDependencies(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
MemberCaseFixture::class,
|
||||||
|
ReferralFixture::class,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
110
src/DataFixtures/NoteFixture.php
Normal file
110
src/DataFixtures/NoteFixture.php
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\DataFixtures;
|
||||||
|
|
||||||
|
use App\Entity\MemberCase;
|
||||||
|
use App\Entity\Referral;
|
||||||
|
use App\Entity\StandardNote;
|
||||||
|
use App\Entity\VisitNote;
|
||||||
|
use App\Enums\NoteLocation;
|
||||||
|
use App\Enums\NoteMethod;
|
||||||
|
use App\Enums\NoteStatus;
|
||||||
|
use App\Enums\ReferralServiceType;
|
||||||
|
use App\Enums\VisitQualityLevel;
|
||||||
|
use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||||
|
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
|
||||||
|
use Doctrine\Persistence\ObjectManager;
|
||||||
|
|
||||||
|
class NoteFixture extends Fixture implements DependentFixtureInterface
|
||||||
|
{
|
||||||
|
public function load(ObjectManager $manager): void
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
$gen = \Faker\Factory::create();
|
||||||
|
$refs = $manager->getRepository(Referral::class)->findAll();
|
||||||
|
|
||||||
|
foreach ($refs as $ref) {
|
||||||
|
/** @var Referral $ref */
|
||||||
|
print "Adding notes for referral {$ref->getReferralId()}".PHP_EOL;
|
||||||
|
$noteCount = $gen->numberBetween(0, 10);
|
||||||
|
|
||||||
|
$case = $ref->getMemberCase();
|
||||||
|
$caseMembers = $case->getMembers();
|
||||||
|
|
||||||
|
for ($x = 0; $x < $noteCount; $x++) {
|
||||||
|
$startTime = $gen->dateTimeBetween('06:00:00', '14:00:00');
|
||||||
|
$endTime = $gen->dateTimeBetween('12:00:00', '21:00:00');
|
||||||
|
|
||||||
|
if ($startTime > $endTime) {
|
||||||
|
$tmp = clone $endTime;
|
||||||
|
$endTime = $startTime;
|
||||||
|
$startTime = $tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($ref->getServiceCode() === ReferralServiceType::VS_THBB) {
|
||||||
|
$note = new VisitNote();
|
||||||
|
$note->setReferral($ref)
|
||||||
|
->setDate($gen->dateTimeBetween($case->getAdmitDate()->format('Y-m-d'), 'now'))
|
||||||
|
->setStartTime($startTime)
|
||||||
|
->setEndTime($endTime)
|
||||||
|
->setStatus($gen->randomElement(NoteStatus::class))
|
||||||
|
->setLocation($gen->randomElement(NoteLocation::class))
|
||||||
|
->setMethod(NoteMethod::BILLABLE_SUPERVISED_VISIT)
|
||||||
|
->setParentalRole($gen->randomElement(VisitQualityLevel::class))
|
||||||
|
->setChildDevelopment($gen->randomElement(VisitQualityLevel::class))
|
||||||
|
->setAppropriateResponse($gen->randomElement(VisitQualityLevel::class))
|
||||||
|
->setChildAheadOfSelf($gen->randomElement(VisitQualityLevel::class))
|
||||||
|
->setShowsEmpathy($gen->randomElement(VisitQualityLevel::class))
|
||||||
|
->setChildFocused($gen->randomElement(VisitQualityLevel::class))
|
||||||
|
->setNarrative($gen->text(100))
|
||||||
|
->setStrengths($gen->text(100))
|
||||||
|
->setIssues($gen->text(100))
|
||||||
|
->setRecommendation($gen->text(100))
|
||||||
|
// ->setMembers(
|
||||||
|
// (
|
||||||
|
// count($caseMembers) > 0
|
||||||
|
// ?
|
||||||
|
// $gen->randomElements($caseMembers, $gen->numberBetween(1, count($caseMembers)))
|
||||||
|
// :
|
||||||
|
// null
|
||||||
|
// )
|
||||||
|
// )
|
||||||
|
;
|
||||||
|
// dd($note);
|
||||||
|
} else {
|
||||||
|
$note = new StandardNote();
|
||||||
|
$note->setReferral($ref)
|
||||||
|
->setDate($gen->dateTimeBetween('-1 year', 'now'))
|
||||||
|
->setStartTime($startTime)
|
||||||
|
->setEndTime($endTime)
|
||||||
|
->setStatus($gen->randomElement(NoteStatus::class))
|
||||||
|
->setLocation($gen->randomElement(NoteLocation::class))
|
||||||
|
->setMethod(NoteMethod::BILLABLE)
|
||||||
|
->setNote($gen->text(100))
|
||||||
|
// ->setMembers(
|
||||||
|
// (
|
||||||
|
// count($caseMembers) > 0
|
||||||
|
// ?
|
||||||
|
// $gen->randomElements($caseMembers, $gen->numberBetween(1, count($caseMembers)))
|
||||||
|
// :
|
||||||
|
// null
|
||||||
|
// )
|
||||||
|
// )
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
$manager->persist($note);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$manager->flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDependencies(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
MemberCaseFixture::class,
|
||||||
|
ReferralFixture::class,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
47
src/DataFixtures/ReferralFixture.php
Normal file
47
src/DataFixtures/ReferralFixture.php
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\DataFixtures;
|
||||||
|
|
||||||
|
use App\Entity\MemberCase;
|
||||||
|
use App\Entity\Referral;
|
||||||
|
use App\Enums\ReferralServiceType;
|
||||||
|
use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||||
|
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
|
||||||
|
use Doctrine\Persistence\ObjectManager;
|
||||||
|
|
||||||
|
class ReferralFixture extends Fixture implements DependentFixtureInterface
|
||||||
|
{
|
||||||
|
public function load(ObjectManager $manager): void
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
$gen = \Faker\Factory::create();
|
||||||
|
$cases = $manager->getRepository(MemberCase::class)->findAll();
|
||||||
|
|
||||||
|
foreach ($cases as $case) {
|
||||||
|
print "Adding referrals for case {$case->getCaseNumber()}".PHP_EOL;
|
||||||
|
$refCount = $gen->numberBetween(0, 2);
|
||||||
|
for ($x = 0; $x < $refCount; $x++) {
|
||||||
|
$ref = new Referral();
|
||||||
|
$ref->setReferralId($gen->numberBetween(1000000, 9999999))
|
||||||
|
->setMemberCase($case)
|
||||||
|
->setServiceCode($gen->randomElement(ReferralServiceType::class))
|
||||||
|
->setEndDate($gen->dateTimeBetween('+1 month', '+1 year'))
|
||||||
|
->setHours($gen->numberBetween(1, 75))
|
||||||
|
;
|
||||||
|
|
||||||
|
print "Adding referral {$ref->getReferralId()}".PHP_EOL;
|
||||||
|
|
||||||
|
$manager->persist($ref);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$manager->flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDependencies(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
MemberCaseFixture::class,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
39
src/DataFixtures/ReferralSourceFixture.php
Normal file
39
src/DataFixtures/ReferralSourceFixture.php
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\DataFixtures;
|
||||||
|
|
||||||
|
use App\Entity\ReferralSource;
|
||||||
|
use App\Enums\County;
|
||||||
|
use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||||
|
use Doctrine\Persistence\ObjectManager;
|
||||||
|
use Faker\Factory;
|
||||||
|
|
||||||
|
class ReferralSourceFixture extends Fixture
|
||||||
|
{
|
||||||
|
public function load(ObjectManager $manager): void
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
$gen = Factory::create();
|
||||||
|
|
||||||
|
for ($x = 0; $x < 20; $x++) {
|
||||||
|
$src = new ReferralSource();
|
||||||
|
$name = "{$gen->firstName()} {$gen->lastName()}";
|
||||||
|
$username = strtolower(str_replace(' ', '.', $name));
|
||||||
|
$src->setName($name)
|
||||||
|
->setEmail("{$username}@dcs.in.gov")
|
||||||
|
->setCounty((string) $gen->randomElement(County::class)->name)
|
||||||
|
->setAgency('DCS')
|
||||||
|
->setPhone(str_replace(['-', '+'], '', $gen->phoneNumber()))
|
||||||
|
;
|
||||||
|
|
||||||
|
print "Adding referral source {$src->getName()}".PHP_EOL;
|
||||||
|
|
||||||
|
$manager->persist($src);
|
||||||
|
}
|
||||||
|
|
||||||
|
// $product = new Product();
|
||||||
|
// $manager->persist($product);
|
||||||
|
|
||||||
|
$manager->flush();
|
||||||
|
}
|
||||||
|
}
|
67
src/DataFixtures/UserFixture.php
Normal file
67
src/DataFixtures/UserFixture.php
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\DataFixtures;
|
||||||
|
|
||||||
|
use App\Entity\Company;
|
||||||
|
use App\Entity\User;
|
||||||
|
use App\Enums\CaseLevel;
|
||||||
|
use App\Enums\RateType;
|
||||||
|
use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||||
|
use Doctrine\Persistence\ObjectManager;
|
||||||
|
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
|
||||||
|
|
||||||
|
class UserFixture extends Fixture
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
private readonly UserPasswordHasherInterface $userPasswordHasher,
|
||||||
|
) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function load(ObjectManager $manager): void
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
$comp = $manager->getRepository(Company::class)->findOneBy(['name' => 'Counseling Partners, LLC']);
|
||||||
|
$gen = \Faker\Factory::create();
|
||||||
|
for ($x = 0; $x < 20; $x++) {
|
||||||
|
$user = new User();
|
||||||
|
$name = $gen->firstName().' '.$gen->lastName();
|
||||||
|
$username = strtolower(str_replace(' ', '.', $name));
|
||||||
|
$cw = true;
|
||||||
|
$cm = $gen->boolean();
|
||||||
|
$t = $gen->boolean();
|
||||||
|
$su = $gen->boolean();
|
||||||
|
$roles = ['ROLE_USER', 'ROLE_CASE_WORKER'];
|
||||||
|
if ($cm) {
|
||||||
|
$roles[] = 'ROLE_CASE_MANAGER';
|
||||||
|
}
|
||||||
|
if ($t) {
|
||||||
|
$roles[] = 'ROLE_THERAPIST';
|
||||||
|
}
|
||||||
|
if ($su) {
|
||||||
|
$roles[] = 'ROLE_ADMIN';
|
||||||
|
}
|
||||||
|
|
||||||
|
$user->setName($name)
|
||||||
|
->setUsername($username)
|
||||||
|
->setEmail($username.'@counselingpartnersllc.com')
|
||||||
|
->setCaseManager($cm)
|
||||||
|
->setCaseWorker($cw)
|
||||||
|
->setTherapist($t)
|
||||||
|
->setSu($su)
|
||||||
|
->setRoles($roles)
|
||||||
|
->setRateType($gen->randomElement(RateType::class))
|
||||||
|
->setRate($gen->numberBetween(0, 100))
|
||||||
|
->setLevel($gen->randomElement(CaseLevel::class))
|
||||||
|
->setCompany($comp)
|
||||||
|
->setPassword($this->userPasswordHasher->hashPassword($user, 'password'))
|
||||||
|
;
|
||||||
|
|
||||||
|
print "Creating user $name - $username".PHP_EOL;
|
||||||
|
|
||||||
|
$manager->persist($user);
|
||||||
|
}
|
||||||
|
|
||||||
|
$manager->flush();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user