Skip to content

Commit e63a2d4

Browse files
committed
Encryption and DTO cleanup
- Added ShouldBeEncrypted-interface to GenerateParticipantJob and removed the calls to the Neon APIs, the job now receives the data through the queue - Split EnrollmentDTO into ContactInfoDTO and a container class for the DTOs called ParticipantUpdateData. The container holds the DTOs and does the flattening for the pdf generation. It also has a fullName-function for generating the full name for the email body - Added interface PdfArrayable to the DTOs - Switched to camel case in the DTOs - The ParticipantUpdateData-container is now passed to the job at dispatch in PollNeonParticipants, so there is one less call to Neon APIs - The NeonDTOTransformer is now a static class with static functions - Added type to the generate-function in PdfIntakeFormService - Added some logging to the getTodaysParticipantIds-function in NeonApiService - Updated intak-form.blade to use the fullName-function in ParticipantUpdatedData
1 parent 7d104fb commit e63a2d4

17 files changed

Lines changed: 476 additions & 450 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: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
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;
910
use Carbon\Carbon;
@@ -41,25 +42,29 @@ public function __construct(NeonApiService $neonApi)
4142
*/
4243
public function handle()
4344
{
44-
$today = Carbon::today()->format('m-d-Y');
45-
Log::info("Collecting participant records that have been added or updated today - {$today}....");
4645

4746
$participantIds = $this->neonApi->getTodaysParticipantIds();
48-
49-
$count = count($participantIds);
50-
Log::info("Found {$count} new or updated participant records.");
51-
47+
5248
foreach ($participantIds as $participantId) {
53-
// Build the full participant record
54-
$fullRecord = $this->neonApi->buildFullParticipantRecord($participantId);
49+
// Get the full participant record
50+
$fullRecord = $this->neonApi->buildFullParticipantRecord($participantId);
51+
5552

5653
// Create a hash of the full record
5754
$hash = hash('sha256', json_encode($fullRecord));
5855

5956
// Check if hash already exists
6057
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
6160
NeonHash::create(['id' => $hash]);
62-
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.");
6368
}
6469
}
6570

app/DTOs/AssessmentDTO.php

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,46 @@
22

33
namespace App\DTOs;
44

5-
class AssessmentDTO
5+
readonly class AssessmentDTO implements PdfArrayable
66
{
77
public function __construct(
8-
public readonly string $full_name,
8+
public readonly string $fullName,
99
public readonly string $dob,
10-
## Removed - we should not collect this information
11-
// public readonly ?string $ssn,
12-
public readonly string $eligibility_missouri_resident,
13-
public readonly string $eligibility_child_under_18,
14-
public readonly string $financial_eligibility,
15-
public readonly string $financial_drivers_licence,
16-
public readonly string $financial_utility_bill,
17-
public readonly string $financial_written_employer_statement,
18-
public readonly string $financial_ss_benefits_statement,
19-
public readonly string $financial_no_employment_income,
20-
public readonly string $financial_unemployment_compensation,
21-
public readonly string $financial_other,
22-
public readonly ?string $financial_other_description,
23-
public readonly string $poverty_monthly_income,
24-
public readonly string $poverty_household_members,
25-
public readonly string $poverty_percentage_fpl,
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,
2624
) {}
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+
}
2746
}
2847
?>

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: 70 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -2,60 +2,82 @@
22

33
namespace App\DTOs;
44

5-
class DisclosureDTO
5+
readonly class DisclosureDTO implements PdfArrayable
66
{
77
public function __construct(
8-
public readonly string $full_name,
8+
public readonly string $fullName,
99
public readonly string $phone,
1010
public readonly string $dob,
11-
## Removed - we should not collect this information
12-
// public readonly ?string $ssn,
1311
public readonly string $address,
1412
public readonly string $email,
15-
16-
// Divisions
17-
public readonly string $authorize_dys,
18-
public readonly string $authorize_mhd,
19-
public readonly string $authorize_dfas,
20-
public readonly string $authorize_mmac,
21-
public readonly string $authorize_other,
22-
public readonly ?string $authorize_discloser_form_other,
23-
public readonly string $authorize_cd,
24-
public readonly string $authorize_dls,
25-
26-
// Release to
27-
public readonly string $disclose_to_attorney, // Text field
28-
public readonly string $disclose_to_legislator,
29-
public readonly string $disclose_to_employer,
30-
public readonly string $disclose_to_governors_staff,
31-
## Removed - pre-filled
32-
// public readonly string $other_discloser,
33-
34-
// Purpose
35-
## Removed - pre-filled
36-
// public readonly string $purpose_eligibility_determination,
37-
## Removed - pre-filled
38-
// public readonly string $purpose_employment,
39-
public readonly string $purpose_continuity_of_services_care,
40-
public readonly string $purpose_legal_consultation_representation,
41-
public readonly string $purpose_complaint_investigation_resolution,
42-
public readonly string $purpose_background_investigation,
43-
public readonly string $purpose_legal_proceedings,
44-
public readonly string $purpose_treatment_planning,
45-
public readonly string $purpose_at_consumers_request,
46-
public readonly string $purpose_to_share_or_refer,
47-
public readonly string $purpose_other,
48-
49-
// To be disclosed
50-
public readonly string $licensure_information,
51-
public readonly string $disclosure_medical,
52-
public readonly string $hotline_investigations,
53-
public readonly string $home_studies,
54-
public readonly string $eligibility_determinations,
55-
public readonly string $substance_abuse_treatment,
56-
public readonly string $client_employment_records,
57-
58-
public readonly string $accept_text_messages,
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,
5942
) {}
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+
}
6082
}
6183
?>

0 commit comments

Comments
 (0)