Skip to content

Commit 7d104fb

Browse files
committed
Added DTOs and polling by date
Replaced the rather tedious mapping from Neon-json to associative array to standard object to associative array (via config.php) with some simple DTOs. Also added functionality to only get participantIds that have been update on or after (>=) a specified date. The function checks the fields entered_date and updated_date (WHERE with OR) in the tables persons, persons_applications_children, persons_applications, persons_assessment_worksheet, persons_introductory_survey, and persons_service_plan. The fields release to attorney/legistlator/employer/Governor's staff in the disclosure form still have issues. Neon has the checkbox values (whether or not the box is checked), but no obvious value for the text field for who the information should be disclosed to. We, on the other hand, seem to have both (Josh would have to confirm). Also, we don't seem to have the survey delivery checkboxes at the end of the disclosure form. Haven't checked if Neon has those yet. Lastly, Neon returns '403 Forbidden' at irregular intervals. Haven't figured out what triggers it. Could be late night/early morning issue due to maintenance.
1 parent 067db41 commit 7d104fb

11 files changed

Lines changed: 693 additions & 32 deletions

app/Console/Commands/PollNeonParticipants.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
use App\Services\Integrations\NeonApiService;
77
use App\Jobs\GenerateParticipantPdfJob;
88
use App\Models\NeonHash;
9+
use Carbon\Carbon;
10+
use Illuminate\Support\Facades\Log;
911

1012
class PollNeonParticipants extends Command
1113
{
@@ -39,11 +41,15 @@ public function __construct(NeonApiService $neonApi)
3941
*/
4042
public function handle()
4143
{
42-
$participants = $this->neonApi->getTodaysParticipants();
43-
44-
foreach ($participants as $person) {
45-
$participantId = (int) $person['persons_id']['value'];
44+
$today = Carbon::today()->format('m-d-Y');
45+
Log::info("Collecting participant records that have been added or updated today - {$today}....");
46+
47+
$participantIds = $this->neonApi->getTodaysParticipantIds();
4648

49+
$count = count($participantIds);
50+
Log::info("Found {$count} new or updated participant records.");
51+
52+
foreach ($participantIds as $participantId) {
4753
// Build the full participant record
4854
$fullRecord = $this->neonApi->buildFullParticipantRecord($participantId);
4955

app/DTOs/AssessmentDTO.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
namespace App\DTOs;
4+
5+
class AssessmentDTO
6+
{
7+
public function __construct(
8+
public readonly string $full_name,
9+
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,
26+
) {}
27+
}
28+
?>

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/DisclosureDTO.php

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?php
2+
3+
namespace App\DTOs;
4+
5+
class DisclosureDTO
6+
{
7+
public function __construct(
8+
public readonly string $full_name,
9+
public readonly string $phone,
10+
public readonly string $dob,
11+
## Removed - we should not collect this information
12+
// public readonly ?string $ssn,
13+
public readonly string $address,
14+
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,
59+
) {}
60+
}
61+
?>

app/DTOs/EnrollmentFormDTO.php

Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
<?php
2+
3+
namespace App\DTOs;
4+
5+
class EnrollmentFormDTO
6+
{
7+
public function __construct(
8+
// Meta (not PDF fields, used for file generation)
9+
public readonly int $id,
10+
public readonly string $first_name,
11+
public readonly string $last_name,
12+
13+
// Page 1
14+
public readonly string $title_region,
15+
public readonly string $full_name,
16+
public readonly string $entered_date,
17+
public readonly string $address,
18+
public readonly string $employer,
19+
public readonly string $tshirt_size, // matches PDF field name exactly
20+
public readonly string $phone,
21+
public readonly string $work_phone,
22+
public readonly string $other_phone,
23+
public readonly string $email,
24+
public readonly string $case_worker_name,
25+
public readonly string $case_worker_phone,
26+
public readonly string $monthly_child_support,
27+
public readonly string $marital_status,
28+
public readonly string $ethnicity,
29+
public readonly string $contact_with_children,
30+
public readonly string $children_custody,
31+
public readonly string $children_visitation,
32+
public readonly string $children_phone,
33+
34+
/** @var ChildDTO[] */
35+
public readonly array $children,
36+
public readonly DisclosureDTO $disclosure,
37+
public readonly AssessmentDTO $assessment,
38+
public readonly SurveyDTO $survey,
39+
public readonly ServicePlanDTO $servicePlan,
40+
) {}
41+
42+
/**
43+
* Flattens all nested DTOs into a key => value array for pdftk.
44+
* Keys match PDF field names exactly from getDataFields() output.
45+
*/
46+
public function toPdfArray(): array
47+
{
48+
return [
49+
// Page 1 - Enrollment
50+
'title_region' => $this->title_region,
51+
'full_name' => $this->full_name,
52+
'entered_date' => $this->entered_date,
53+
'address' => $this->address,
54+
'employer' => $this->employer,
55+
'tshirt_size' => $this->tshirt_size,
56+
'phone' => $this->phone,
57+
'work_phone' => $this->work_phone,
58+
'other_phone' => $this->other_phone,
59+
'email' => $this->email,
60+
'case_worker_name' => $this->case_worker_name,
61+
'case_worker_phone' => $this->case_worker_phone,
62+
'monthly_child_support' => $this->monthly_child_support,
63+
'marital_status' => $this->marital_status,
64+
'ethnicity' => $this->ethnicity,
65+
'contact_with_children' => $this->contact_with_children,
66+
'children_custody' => $this->children_custody,
67+
'children_visitation' => $this->children_visitation,
68+
'children_phone' => $this->children_phone,
69+
70+
// Children
71+
'child_name_1' => $this->children[0]->name ?? '',
72+
'child_age_1' => $this->children[0]->age ?? '',
73+
'child_dob_1' => $this->children[0]->dob ?? '',
74+
'child_name_2' => $this->children[1]->name ?? '',
75+
'child_age_2' => $this->children[1]->age ?? '',
76+
'child_dob_2' => $this->children[1]->dob ?? '',
77+
'child_name_3' => $this->children[2]->name ?? '',
78+
'child_age_3' => $this->children[2]->age ?? '',
79+
'child_dob_3' => $this->children[2]->dob ?? '',
80+
'child_name_4' => $this->children[3]->name ?? '',
81+
'child_age_4' => $this->children[3]->age ?? '',
82+
'child_dob_4' => $this->children[3]->dob ?? '',
83+
'child_name_5' => $this->children[4]->name ?? '',
84+
'child_age_5' => $this->children[4]->age ?? '',
85+
'child_dob_5' => $this->children[4]->dob ?? '',
86+
87+
// Page 2 - Disclosure
88+
'authorize_full_name' => $this->full_name,
89+
'authorize_dys' => $this->disclosure->authorize_dys,
90+
'authorize_mhd' => $this->disclosure->authorize_mhd,
91+
'authorize_dfas' => $this->disclosure->authorize_dfas,
92+
'authorize_mmac' => $this->disclosure->authorize_mmac,
93+
'authorize_other' => $this->disclosure->authorize_other,
94+
'authorize_discloser_form_other' => $this->disclosure->authorize_discloser_form_other ?? '',
95+
'authorize_cd' => $this->disclosure->authorize_cd,
96+
'authorize_dls' => $this->disclosure->authorize_dls,
97+
'disclose_full_name' => $this->disclosure->full_name,
98+
'disclose_phone' => $this->disclosure->phone,
99+
'disclose_dob' => $this->disclosure->dob,
100+
### Removed - we should not collect this information
101+
// 'disclose_ssn' => $this->disclosure->ssn ?? '',
102+
'disclose_address' => $this->disclosure->address,
103+
'disclose_email' => $this->disclosure->email,
104+
// 'select_disclose_to_attorney' => $this->disclosure->select_disclose_to_attorney,
105+
'disclose_to_attorney' => $this->disclosure->disclose_to_attorney,
106+
'disclose_to_legislator' => $this->disclosure->disclose_to_legislator,
107+
'disclose_to_employer' => $this->disclosure->disclose_to_employer,
108+
'disclose_to_governors_staff' => $this->disclosure->disclose_to_governors_staff,
109+
## Removed - pre-filled
110+
// 'other_discloser' => $this->disclosure->other_discloser,
111+
## Removed - pre-filled
112+
// 'disclosure_purpose_eligibility_determination' => $this->disclosure->purpose_eligibility_determination,
113+
## Removed - pre-filled
114+
// 'disclosure_purpose_employment' => $this->disclosure->purpose_employment,
115+
'disclosure_purpose_continuity_of_services_care' => $this->disclosure->purpose_continuity_of_services_care,
116+
'disclosure_purpose_legal_consultation_representation' => $this->disclosure->purpose_legal_consultation_representation,
117+
'disclosure_purpose_complaint_investigation_resolution' => $this->disclosure->purpose_complaint_investigation_resolution,
118+
'disclosure_purpose_background_investigation' => $this->disclosure->purpose_background_investigation,
119+
'disclosure_purpose_legal_proceedings' => $this->disclosure->purpose_legal_proceedings,
120+
'disclosure_purpose_treatment_planning' => $this->disclosure->purpose_treatment_planning,
121+
'disclosure_purpose_at_consumers_request' => $this->disclosure->purpose_at_consumers_request,
122+
'disclosure_purpose_to_share_or_refer' => $this->disclosure->purpose_to_share_or_refer,
123+
## Removed - pre-filled
124+
// 'disclosure_purpose_other' => $this->disclosure->purpose_other,
125+
'disclosure_licensure_information' => $this->disclosure->licensure_information,
126+
'disclosure_medical' => $this->disclosure->disclosure_medical,
127+
'disclose_hotline_investigations' => $this->disclosure->hotline_investigations,
128+
'disclosure_home_studies' => $this->disclosure->home_studies,
129+
'disclosure_eligibility_determinations' => $this->disclosure->eligibility_determinations,
130+
'disclosure_substance_abuse_treatment' => $this->disclosure->substance_abuse_treatment,
131+
'disclosure_client_employment_records' => $this->disclosure->client_employment_records,
132+
133+
// Page 3
134+
'accept_text_messages' => $this->disclosure->accept_text_messages,
135+
136+
// Page 4 - Assessment
137+
'participant_full_name' => $this->assessment->full_name,
138+
'participant_dob' => $this->assessment->dob,
139+
## Removed - we should not collect this information
140+
// 'participant_ssn' => $this->assessment->ssn ?? '',
141+
'eligibility_missouri_resident' => $this->assessment->eligibility_missouri_resident,
142+
'eligibility_child_under_18' => $this->assessment->eligibility_child_under_18,
143+
'financial_assessment_eligibility' => $this->assessment->financial_eligibility,
144+
'financial_assessment_drivers_licence' => $this->assessment->financial_drivers_licence,
145+
'financial_assessment_utility_bill' => $this->assessment->financial_utility_bill,
146+
'financial_assessment_written_employer_statement' => $this->assessment->financial_written_employer_statement,
147+
'financial_assessment_ss_benefits_statement' => $this->assessment->financial_ss_benefits_statement,
148+
'financial_assessment_no_employment_income' => $this->assessment->financial_no_employment_income,
149+
'financial_assessment_unemployment_compensation' => $this->assessment->financial_unemployment_compensation,
150+
'financial_assessment_other' => $this->assessment->financial_other,
151+
'financial_assessment_other_description' => $this->assessment->financial_other_description ?? '',
152+
'poverty_level_monthly_income' => $this->assessment->poverty_monthly_income,
153+
'poverty_level_number_of_household_members' => $this->assessment->poverty_household_members,
154+
'poverty_level_percentage_fpl' => $this->assessment->poverty_percentage_fpl,
155+
156+
// Page 5 - Survey
157+
'survey_client_dob' => $this->survey->client_dob,
158+
'survey_delivery_method' => $this->survey->delivery_method,
159+
'survey_why' => $this->survey->why,
160+
'survey_other_description' => $this->survey->why_other,
161+
'survey_how' => $this->survey->how,
162+
'survey_how_other_description' => $this->survey->how_other,
163+
'survey_gain' => $this->survey->gain,
164+
'survey_gain_other_description' => $this->survey->gain_other,
165+
166+
// Page 6 - Service Plan
167+
'service_plan_participant_full_name' => $this->servicePlan->participant_full_name,
168+
'service_plan_client_number' => $this->servicePlan->client_number,
169+
'service_plan_goal' => $this->servicePlan->goal,
170+
'service_plan_service_identified' => $this->servicePlan->service_identified,
171+
'service_plan_strategies_1' => $this->servicePlan->strategies_1,
172+
'service_plan_person_responsible_1' => $this->servicePlan->person_responsible_1,
173+
'service_plan_timeline_1' => $this->servicePlan->timeline_1,
174+
'service_plan_measure_of_success_1' => $this->servicePlan->measure_of_success_1,
175+
'service_plan_strategies_2' => $this->servicePlan->strategies_2,
176+
'service_plan_person_responsible_2' => $this->servicePlan->person_responsible_2,
177+
'service_plan_timeline_2' => $this->servicePlan->timeline_2,
178+
'service_plan_measure_of_success_2' => $this->servicePlan->measure_of_success_2,
179+
'service_plan_strategies_3' => $this->servicePlan->strategies_3,
180+
'service_plan_person_responsible_3' => $this->servicePlan->person_responsible_3,
181+
'service_plan_timeline_3' => $this->servicePlan->timeline_3,
182+
'service_plan_measure_of_success_3' => $this->servicePlan->measure_of_success_3,
183+
];
184+
}
185+
}
186+
?>

app/DTOs/ServicePlanDTO.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
namespace App\DTOs;
4+
5+
class ServicePlanDTO
6+
{
7+
public function __construct(
8+
public readonly string $participant_full_name,
9+
public readonly string $client_number,
10+
public readonly string $goal, // service_plan_goal
11+
public readonly string $service_identified,
12+
public readonly string $strategies_1,
13+
public readonly string $person_responsible_1,
14+
public readonly string $timeline_1,
15+
public readonly string $measure_of_success_1,
16+
public readonly string $strategies_2,
17+
public readonly string $person_responsible_2,
18+
public readonly string $timeline_2,
19+
public readonly string $measure_of_success_2,
20+
public readonly string $strategies_3,
21+
public readonly string $person_responsible_3,
22+
public readonly string $timeline_3,
23+
public readonly string $measure_of_success_3,
24+
) {}
25+
}
26+
?>

0 commit comments

Comments
 (0)