From 12199b615214232f2b8d30d5b92c4d14cd7cd8d2 Mon Sep 17 00:00:00 2001 From: Ryan Prather Date: Mon, 23 Dec 2024 03:06:40 +0000 Subject: [PATCH] add staffnote fixture --- src/DataFixtures/StaffNoteFixture.php | 61 +++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 src/DataFixtures/StaffNoteFixture.php diff --git a/src/DataFixtures/StaffNoteFixture.php b/src/DataFixtures/StaffNoteFixture.php new file mode 100644 index 0000000..14eae9c --- /dev/null +++ b/src/DataFixtures/StaffNoteFixture.php @@ -0,0 +1,61 @@ +getRepository(MemberCase::class)->findAll(); + + $gen = \Faker\Factory::create(); + + foreach ($cases as $case) { + /** @var MemberCase $case */ + $note = new StaffNote(); + $admitDate = new DateTime($case->getAdmitDate()?->format('Y-m-d').' '.$gen->time('H:i:s')); + $admitDate->add(\DateInterval::createFromDateString('7 day')); + $note->setDate($admitDate); + $note->setMemberCase($case); + $note->setServicesProvided($gen->randomElements(ReferralServiceType::class, $gen->numberBetween(1, 3))); + + while ($admitDate->getTimestamp() < time()) { + $workerSignDatetime = clone $admitDate; + $workerSignDatetime->setTime($gen->time('H'), $gen->time('i'), $gen->time('s')); + $workerSignDatetime->add(\DateInterval::createFromDateString('1 day')); + $note->setWorkerSignDatetime($workerSignDatetime); + + $supervisorSignDatetime = clone $admitDate; + $supervisorSignDatetime->setTime($gen->time('H'), $gen->time('i'), $gen->time('s')); + $supervisorSignDatetime->add(\DateInterval::createFromDateString('1 day')); + $note->setSupervisorSignDatetime($supervisorSignDatetime); + + $note->setNote($gen->text(200)); + $note->setRecommendations($gen->text(20)); + + $manager->persist($note); + + $admitDate->add(\DateInterval::createFromDateString('14 days')); + $note = clone $note; + $note->setDate($admitDate); + } + } + + $manager->flush(); + } + + public function getDependencies(): array + { + return [ + MemberCaseFixture::class, + ]; + } +}