Skip to content

Commit 84f20fd

Browse files
authored
Merge pull request #129 from nomedis/participant_polling_with_dto_and_datefilter
Added DTOs and polling by date
2 parents 067db41 + e63a2d4 commit 84f20fd

17 files changed

Lines changed: 752 additions & 65 deletions

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,6 @@ node_modules/
3333
/playwright-report/
3434
/blob-report/
3535
/playwright/.cache/
36+
37+
#Bruno collection config with api key
38+
**/meta.bru

app/Console/Commands/PdfFillFields.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ class PdfFillFields extends Command
1414

1515
public function handle()
1616
{
17-
$inputPath = storage_path('app/pdfs/intake-forms/enrollment_documents_fillable_gd_global_DRAFT_v1.pdf');
17+
$inputPath = storage_path('pdfs/intake-form/Enrollment_Form_Fillable_2026-01-27.pdf');
1818
$timestamp = now()->format('Ymd_His');
19-
$outputPath = storage_path("app/pdfs/intake-forms/enrollment_documents_fillable_gd_global_DRAFT_v1-{$timestamp}.pdf");
19+
$outputPath = storage_path("pdfs/intake-form/enrollment_documents_field_names-{$timestamp}.pdf");
2020

2121
// --- 1️⃣ First instance: Get all field names ---
2222
$reader = new Pdf($inputPath);

app/Console/Commands/PollNeonParticipants.php

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@
44

55
use Illuminate\Console\Command;
66
use App\Services\Integrations\NeonApiService;
7+
use App\Services\NeonDTOTransformer;
78
use App\Jobs\GenerateParticipantPdfJob;
89
use App\Models\NeonHash;
10+
use Carbon\Carbon;
11+
use Illuminate\Support\Facades\Log;
912

1013
class PollNeonParticipants extends Command
1114
{
@@ -39,21 +42,29 @@ public function __construct(NeonApiService $neonApi)
3942
*/
4043
public function handle()
4144
{
42-
$participants = $this->neonApi->getTodaysParticipants();
45+
46+
$participantIds = $this->neonApi->getTodaysParticipantIds();
47+
48+
foreach ($participantIds as $participantId) {
49+
// Get the full participant record
50+
$fullRecord = $this->neonApi->buildFullParticipantRecord($participantId);
4351

44-
foreach ($participants as $person) {
45-
$participantId = (int) $person['persons_id']['value'];
46-
47-
// Build the full participant record
48-
$fullRecord = $this->neonApi->buildFullParticipantRecord($participantId);
4952

5053
// Create a hash of the full record
5154
$hash = hash('sha256', json_encode($fullRecord));
5255

5356
// Check if hash already exists
5457
if (!NeonHash::where('id', $hash)->exists()) {
58+
Log::info("Participant ". $participantId . " has updated data. Queuing pdf regeneration.");
59+
// Store the hash for the participant data for future comparison
5560
NeonHash::create(['id' => $hash]);
56-
dispatch(new GenerateParticipantPdfJob($participantId));
61+
62+
// Transform the participant data into serializable DTOs
63+
$serializableDTOs = NeonDTOTransformer::transformParticipantData($fullRecord);
64+
// Queue the pdf generation job
65+
dispatch(new GenerateParticipantPdfJob($serializableDTOs));
66+
} else {
67+
Log::info("Participant ". $participantId . " has no updated data. Skipping pdf regeneration.");
5768
}
5869
}
5970

app/DTOs/AssessmentDTO.php

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
3+
namespace App\DTOs;
4+
5+
readonly class AssessmentDTO implements PdfArrayable
6+
{
7+
public function __construct(
8+
public readonly string $fullName,
9+
public readonly string $dob,
10+
public readonly string $eligibilityMissouriResident,
11+
public readonly string $eligibilityChildUnder18,
12+
public readonly string $financialEligibility,
13+
public readonly string $financialDriversLicence,
14+
public readonly string $financialUtilityBill,
15+
public readonly string $financialWrittenEmployerStatement,
16+
public readonly string $financialSsBenefitsStatement,
17+
public readonly string $financialNoEmploymentIncome,
18+
public readonly string $financialUnemploymentCompensation,
19+
public readonly string $financialOther,
20+
public readonly ?string $financialOtherDescription,
21+
public readonly string $povertyMonthlyIncome,
22+
public readonly string $povertyHouseholdMembers,
23+
public readonly string $povertyPercentageFpl,
24+
) {}
25+
26+
public function toPdfArray(): array {
27+
return [
28+
'participant_full_name' => $this->fullName,
29+
'participant_dob' => $this->dob,
30+
'eligibility_missouri_resident' => $this->eligibilityMissouriResident,
31+
'eligibility_child_under_18' => $this->eligibilityChildUnder18,
32+
'financial_assessment_eligibility' => $this->financialEligibility,
33+
'financial_assessment_drivers_licence' => $this->financialDriversLicence,
34+
'financial_assessment_utility_bill' => $this->financialUtilityBill,
35+
'financial_assessment_written_employer_statement' => $this->financialWrittenEmployerStatement,
36+
'financial_assessment_ss_benefits_statement' => $this->financialSsBenefitsStatement,
37+
'financial_assessment_no_employment_income' => $this->financialNoEmploymentIncome,
38+
'financial_assessment_unemployment_compensation' => $this->financialUnemploymentCompensation,
39+
'financial_assessment_other' => $this->financialOther,
40+
'financial_assessment_other_description' => $this->financialOtherDescription,
41+
'poverty_level_monthly_income' => $this->povertyMonthlyIncome,
42+
'poverty_level_number_of_household_members' => $this->povertyHouseholdMembers,
43+
'poverty_level_percentage_fpl' => $this->povertyPercentageFpl
44+
];
45+
}
46+
}
47+
?>

app/DTOs/ChildDTO.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace App\DTOs;
4+
5+
class ChildDTO
6+
{
7+
public function __construct(
8+
public readonly string $name,
9+
public readonly string $age,
10+
public readonly string $dob,
11+
) {}
12+
}
13+
?>

app/DTOs/ContactInfoDTO.php

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
3+
namespace App\DTOs;
4+
5+
readonly class ContactInfoDTO implements PdfArrayable
6+
{
7+
public function __construct(
8+
public readonly string $titleRegion,
9+
public readonly string $fullName,
10+
public readonly string $enteredDate,
11+
public readonly string $address,
12+
public readonly string $employer,
13+
public readonly string $tshirtSize,
14+
public readonly string $phone,
15+
public readonly string $workPhone,
16+
public readonly string $otherPhone,
17+
public readonly string $email,
18+
public readonly string $caseworkerName,
19+
public readonly string $caseworkerPhone,
20+
public readonly string $monthlyChildSupport,
21+
public readonly string $maritalStatus,
22+
public readonly string $ethnicity,
23+
public readonly string $contactWithChildren,
24+
public readonly string $childrenCustody,
25+
public readonly string $childrenVisitation,
26+
public readonly string $childrenPhone,
27+
) {}
28+
29+
public function toPdfArray(): array
30+
{
31+
return [
32+
'title_region' => $this->titleRegion,
33+
'full_name' => $this->fullName,
34+
'entered_date' => $this->enteredDate,
35+
'address' => $this->address,
36+
'employer' => $this->employer,
37+
'tshirt_size' => $this->tshirtSize,
38+
'phone' => $this->phone,
39+
'work_phone' => $this->workPhone,
40+
'other_phone' => $this->otherPhone,
41+
'email' => $this->email,
42+
'case_worker_name' => $this->caseworkerName,
43+
'case_worker_phone' => $this->caseworkerPhone,
44+
'monthly_child_support' => $this->monthlyChildSupport,
45+
'marital_status' => $this->maritalStatus,
46+
'ethnicity' => $this->ethnicity,
47+
'contact_with_children' => $this->contactWithChildren,
48+
'children_custody' => $this->childrenCustody,
49+
'children_visitation' => $this->childrenVisitation,
50+
'children_phone' => $this->childrenPhone,
51+
];
52+
}
53+
}
54+
?>

app/DTOs/DisclosureDTO.php

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<?php
2+
3+
namespace App\DTOs;
4+
5+
readonly class DisclosureDTO implements PdfArrayable
6+
{
7+
public function __construct(
8+
public readonly string $fullName,
9+
public readonly string $phone,
10+
public readonly string $dob,
11+
public readonly string $address,
12+
public readonly string $email,
13+
public readonly string $authorizeDys,
14+
public readonly string $authorizeMhd,
15+
public readonly string $authorizeDfas,
16+
public readonly string $authorizeMmac,
17+
public readonly string $authorizeOther,
18+
public readonly ?string $authorizeDiscloserFormOther,
19+
public readonly string $authorizeCd,
20+
public readonly string $authorizeDls,
21+
public readonly string $discloseToAttorney,
22+
public readonly string $discloseToLegislator,
23+
public readonly string $discloseToEmployer,
24+
public readonly string $discloseToGovernorsStaff,
25+
public readonly string $purposeContinuityOfServicesCare,
26+
public readonly string $purposeLegalConsultationRepresentation,
27+
public readonly string $purposeComplaintInvestigationResolution,
28+
public readonly string $purposeBackgroundInvestigation,
29+
public readonly string $purposeLegalProceedings,
30+
public readonly string $purposeTreatmentPlanning,
31+
public readonly string $purposeAtConsumersRequest,
32+
public readonly string $purposeToShareOrRefer,
33+
public readonly string $purposeOther,
34+
public readonly string $licensureInformation,
35+
public readonly string $disclosureMedical,
36+
public readonly string $hotlineInvestigations,
37+
public readonly string $homeStudies,
38+
public readonly string $eligibilityDeterminations,
39+
public readonly string $substanceAbuseTreatment,
40+
public readonly string $clientEmploymentRecords,
41+
public readonly string $acceptTextMessages,
42+
) {}
43+
44+
public function toPdfArray(): array {
45+
return [
46+
'authorize_full_name' => $this->fullName,
47+
'authorize_dys' => $this->authorizeDys,
48+
'authorize_mhd' => $this->authorizeMhd,
49+
'authorize_dfas' => $this->authorizeDfas,
50+
'authorize_mmac' => $this->authorizeMmac,
51+
'authorize_other' => $this->authorizeOther,
52+
'authorize_discloser_form_other' => $this->authorizeDiscloserFormOther,
53+
'authorize_cd' => $this->authorizeCd,
54+
'authorize_dls' => $this->authorizeDls,
55+
'disclose_full_name' => $this->fullName,
56+
'disclose_phone' => $this->phone,
57+
'disclose_dob' => $this->dob,
58+
'disclose_address' => $this->address,
59+
'disclose_email' => $this->email,
60+
'disclose_to_attorney' => $this->discloseToAttorney,
61+
'disclose_to_legislator' => $this->discloseToLegislator,
62+
'disclose_to_employer' => $this->discloseToEmployer,
63+
'disclose_to_governors_staff' => $this->discloseToGovernorsStaff,
64+
'disclosure_purpose_continuity_of_services_care' => $this->purposeContinuityOfServicesCare,
65+
'disclosure_purpose_legal_consultation_representation' => $this->purposeLegalConsultationRepresentation,
66+
'disclosure_purpose_complaint_investigation_resolution' => $this->purposeComplaintInvestigationResolution,
67+
'disclosure_purpose_background_investigation' => $this->purposeBackgroundInvestigation,
68+
'disclosure_purpose_legal_proceedings' => $this->purposeLegalProceedings,
69+
'disclosure_purpose_treatment_planning' => $this->purposeTreatmentPlanning,
70+
'disclosure_purpose_at_consumers_request' => $this->purposeAtConsumersRequest,
71+
'disclosure_purpose_to_share_or_refer' => $this->purposeToShareOrRefer,
72+
'disclosure_licensure_information' => $this->licensureInformation,
73+
'disclosure_medical' => $this->disclosureMedical,
74+
'disclose_hotline_investigations' => $this->hotlineInvestigations,
75+
'disclosure_home_studies' => $this->homeStudies,
76+
'disclosure_eligibility_determinations' => $this->eligibilityDeterminations,
77+
'disclosure_substance_abuse_treatment' => $this->substanceAbuseTreatment,
78+
'disclosure_client_employment_records' => $this->clientEmploymentRecords,
79+
'accept_text_messages' => $this->acceptTextMessages
80+
];
81+
}
82+
}
83+
?>

app/DTOs/ParticipantUpdateData.php

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
3+
namespace App\DTOs;
4+
5+
readonly class ParticipantUpdateData
6+
{
7+
/**
8+
* @param ChildDTO[] $children
9+
*/
10+
public function __construct(
11+
// Meta (not PDF fields, used for file generation)
12+
public readonly int $id,
13+
public readonly string $firstName,
14+
public readonly string $lastName,
15+
16+
// Enrollment form data
17+
public readonly ContactInfoDTO $contactInfo,
18+
public readonly array $children,
19+
public readonly DisclosureDTO $disclosure,
20+
public readonly AssessmentDTO $assessment,
21+
public readonly SurveyDTO $survey,
22+
public readonly ServicePlanDTO $servicePlan
23+
) {}
24+
25+
/**
26+
* This is for the email generation
27+
*/
28+
public function fullName(): string {
29+
return $this->firstName . ' ' . $this->lastName;
30+
}
31+
32+
public function toPdfArray(): array {
33+
34+
$children = [];
35+
36+
foreach ($this->children as $index => $child) {
37+
$adjusted_index = $index + 1;
38+
$children['child_name_' . $adjusted_index] = $child->name;
39+
$children['child_age_' . $adjusted_index] = $child->age;
40+
$children['child_dob_' . $adjusted_index] = $child->dob;
41+
42+
}
43+
44+
$arrays = [
45+
$this->contactInfo->toPdfArray(),
46+
$children,
47+
$this->disclosure->toPdfArray(),
48+
$this->assessment->toPdfArray(),
49+
$this->survey->toPdfArray(),
50+
$this->servicePlan->toPdfArray()
51+
];
52+
53+
return array_merge(...$arrays);
54+
}
55+
}
56+
?>

app/DTOs/PdfArrayable.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
namespace App\DTOs;
3+
4+
interface PdfArrayable {
5+
public function toPdfArray(): array;
6+
}
7+
?>

app/DTOs/ServicePlanDTO.php

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
3+
namespace App\DTOs;
4+
5+
readonly class ServicePlanDTO implements PdfArrayable
6+
{
7+
public function __construct(
8+
public readonly string $participantFullName,
9+
public readonly string $clientNumber,
10+
public readonly string $goal, // service_plan_goal
11+
public readonly string $serviceIdentified,
12+
public readonly string $strategies_1,
13+
public readonly string $personResponsible_1,
14+
public readonly string $timeline_1,
15+
public readonly string $measureOfSuccess_1,
16+
public readonly string $strategies_2,
17+
public readonly string $personResponsible_2,
18+
public readonly string $timeline_2,
19+
public readonly string $measureOfSuccess_2,
20+
public readonly string $strategies_3,
21+
public readonly string $personResponsible_3,
22+
public readonly string $timeline_3,
23+
public readonly string $measureOfSuccess_3,
24+
) {}
25+
26+
public function toPdfArray(): array {
27+
return [
28+
'service_plan_participant_full_name' => $this->participantFullName,
29+
'service_plan_client_number' => $this->clientNumber,
30+
'service_plan_goal' => $this->goal,
31+
'service_plan_service_identified' => $this->serviceIdentified,
32+
'service_plan_strategies_1' => $this->strategies_1,
33+
'service_plan_person_responsible_1' => $this->personResponsible_1,
34+
'service_plan_timeline_1' => $this->timeline_1,
35+
'service_plan_measure_of_success_1' => $this->measureOfSuccess_1,
36+
'service_plan_strategies_2' => $this->strategies_2,
37+
'service_plan_person_responsible_2' => $this->personResponsible_2,
38+
'service_plan_timeline_2' => $this->timeline_2,
39+
'service_plan_measure_of_success_2' => $this->measureOfSuccess_2,
40+
'service_plan_strategies_3' => $this->strategies_3,
41+
'service_plan_person_responsible_3' => $this->personResponsible_3,
42+
'service_plan_timeline_3' => $this->timeline_3,
43+
'service_plan_measure_of_success_3' => $this->measureOfSuccess_3
44+
];
45+
}
46+
}
47+
?>

0 commit comments

Comments
 (0)