PluginProbe
The Innovative Form Builder – IvyForms / 0.6
The Innovative Form Builder – IvyForms v0.6
1.5.1 1.5 1.4.1 1.4 trunk 0.1.2 0.2 0.2.1 0.3 0.3.1 0.4 0.5 0.6 0.6.1 0.6.1-backup 0.6.1.1 0.7 0.8 0.8.1 0.8.2 0.9 0.9.1 1.0 1.1 1.1.1 All 27 releases
ivyforms / backend / src / Services / Template / DoctorAppointmentBookingFormTemplate.php

DoctorAppointmentBookingFormTemplate.php in The Innovative Form Builder – IvyForms 0.6, at backend/src/Services/Template/DoctorAppointmentBookingFormTemplate.php

364 lines 12.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace IvyForms\Services\Template;
4
5 // phpcs:disable PSR1.Files.SideEffects
6 if (!defined('ABSPATH')) {
7 exit; // Exit if accessed directly
8 }
9
10 use IvyForms\Services\Translations\BackendStrings;
11
12 class DoctorAppointmentBookingFormTemplate
13 {
14 /**
15 * Get the doctor appointment booking form template
16 *
17 * @return array<string, mixed>
18 */
19 public static function getTemplate(): array
20 {
21 return [
22 'id' => 'doctor_appointment_booking_form',
23 'name' => BackendStrings::getTemplateStrings()['doctor_appointment_booking_form'],
24 'description' => BackendStrings::getTemplateStrings()['doctor_appointment_booking_form_desc'],
25 'category' => 'booking-forms',
26 'is_pro' => false,
27 'screenshot' => IVYFORMS_TEMPLATES_IMAGES_URL . 'doctor-appointment-booking-form.svg',
28 'form_data' => [
29 'name' => BackendStrings::getTemplateStrings()['doctor_appointment_booking_form'],
30 'published' => 1,
31 'showTitle' => 1,
32 'storeEntries' => 1,
33 'integrationSettings' => TemplateDefaults::getDefaultIntegrationSettings(),
34 'fields' => array_merge(
35 self::getPatientInformationFields(),
36 self::getAppointmentDetailsFields(),
37 self::getAdditionalInformationFields()
38 ),
39 'settings' => []
40 ]
41 ];
42 }
43
44 /**
45 * Get patient information fields
46 *
47 * @return array<int, array<string, mixed>>
48 */
49 private static function getPatientInformationFields(): array
50 {
51 return [
52 // Name Field - Parent
53 [
54 'id' => 0,
55 'fieldIndex' => 1,
56 'type' => 'name',
57 'label' => BackendStrings::getTemplateStrings()['full_name'],
58 'parentId' => null,
59 'defaultValue' => '',
60 'placeholder' => '',
61 'required' => true,
62 'readonly' => false,
63 'position' => 1,
64 ],
65 // First Name - Child of Name Field
66 [
67 'id' => 0,
68 'type' => 'text',
69 'label' => BackendStrings::getNewFormStrings()['first_name'],
70 'placeholder' => BackendStrings::getTemplateStrings()['enter_your_first_name'],
71 'required' => true,
72 'parentId' => 0,
73 'fieldIndex' => 1,
74 'defaultValue' => '',
75 'position' => 1,
76 'optionHide' => false,
77 'description' => '',
78 'settings' => json_encode(['nameFieldType' => 'nameField1']),
79 ],
80 // Last Name - Child of Name Field
81 [
82 'id' => 0,
83 'type' => 'text',
84 'label' => BackendStrings::getNewFormStrings()['last_name'],
85 'placeholder' => BackendStrings::getTemplateStrings()['enter_your_last_name'],
86 'required' => true,
87 'parentId' => 0,
88 'fieldIndex' => 1,
89 'defaultValue' => '',
90 'position' => 2,
91 'optionHide' => false,
92 'description' => '',
93 'settings' => json_encode(['nameFieldType' => 'nameField2']),
94 ],
95 // Email Address
96 [
97 'id' => 0,
98 'fieldIndex' => 2,
99 'type' => 'email',
100 'label' => BackendStrings::getTemplateStrings()['email_address'],
101 'placeholder' => '[email protected]',
102 'required' => true,
103 'parentId' => null,
104 'defaultValue' => '',
105 'position' => 2,
106 ],
107 // Phone Number
108 [
109 'id' => 0,
110 'fieldIndex' => 3,
111 'type' => 'phone',
112 'label' => BackendStrings::getTemplateStrings()['phone_number'],
113 'placeholder' => '+1 (_) _-_',
114 'required' => true,
115 'parentId' => null,
116 'defaultValue' => '',
117 'position' => 3,
118 'phoneAutoDetect' => true,
119 ],
120 ];
121 }
122
123 /**
124 * Get appointment details fields
125 *
126 * @return array<int, array<string, mixed>>
127 */
128 private static function getAppointmentDetailsFields(): array
129 {
130 return array_merge(
131 self::getDoctorSpecialistField(),
132 self::getPreferredAppointmentDateField(),
133 self::getPreferredTimeSlotField()
134 );
135 }
136
137 /**
138 * Get doctor/specialist field
139 *
140 * @return array<int, array<string, mixed>>
141 */
142 private static function getDoctorSpecialistField(): array
143 {
144 return [
145 [
146 'id' => 0,
147 'fieldIndex' => 4,
148 'type' => 'select',
149 'label' => BackendStrings::getTemplateStrings()['doctor_specialist'],
150 'placeholder' => BackendStrings::getTemplateStrings()['select_doctor_or_specialist'],
151 'required' => true,
152 'parentId' => null,
153 'defaultValue' => '',
154 'position' => 4,
155 'fieldOptions' => [
156 [
157 'id' => 0,
158 'label' => BackendStrings::getTemplateStrings()['general_practitioner'],
159 'value' => 'general_practitioner',
160 'isDefault' => false,
161 'position' => 1
162 ],
163 [
164 'id' => 0,
165 'label' => BackendStrings::getTemplateStrings()['dermatologist'],
166 'value' => 'dermatologist',
167 'isDefault' => false,
168 'position' => 2
169 ],
170 [
171 'id' => 0,
172 'label' => BackendStrings::getTemplateStrings()['pediatrician'],
173 'value' => 'pediatrician',
174 'isDefault' => false,
175 'position' => 3
176 ],
177 [
178 'id' => 0,
179 'label' => BackendStrings::getTemplateStrings()['cardiologist'],
180 'value' => 'cardiologist',
181 'isDefault' => false,
182 'position' => 4
183 ],
184 [
185 'id' => 0,
186 'label' => BackendStrings::getTemplateStrings()['other'],
187 'value' => 'other',
188 'isDefault' => false,
189 'position' => 5
190 ],
191 ]
192 ],
193 ];
194 }
195
196 /**
197 * Get preferred appointment date field
198 *
199 * @return array<int, array<string, mixed>>
200 */
201 private static function getPreferredAppointmentDateField(): array
202 {
203 return [
204 [
205 'id' => 0,
206 'fieldIndex' => 5,
207 'type' => 'date',
208 'label' => BackendStrings::getTemplateStrings()['preferred_appointment_date'],
209 'placeholder' => BackendStrings::getTemplateStrings()['select_preferred_date'],
210 'required' => true,
211 'parentId' => null,
212 'defaultValue' => '',
213 'position' => 5,
214 'dateFieldType' => 'picker',
215 'dateFormat' => 'MM/DD/YYYY',
216 ],
217 ];
218 }
219
220 /**
221 * Get preferred time slot field
222 *
223 * @return array<int, array<string, mixed>>
224 */
225 private static function getPreferredTimeSlotField(): array
226 {
227 return [
228 [
229 'id' => 0,
230 'fieldIndex' => 6,
231 'type' => 'time',
232 'label' => BackendStrings::getTemplateStrings()['preferred_time_slot'],
233 'placeholder' => BackendStrings::getTemplateStrings()['select_preferred_time'],
234 'required' => true,
235 'parentId' => null,
236 'defaultValue' => '',
237 'position' => 6,
238 'timeFieldType' => 'time-picker',
239 'timeFormat' => 'ampm',
240 ],
241 ];
242 }
243
244 /**
245 * Get additional information fields
246 *
247 * @return array<int, array<string, mixed>>
248 */
249 private static function getAdditionalInformationFields(): array
250 {
251 return array_merge(
252 self::getReasonForVisitField(),
253 self::getNeedTelemedicineField(),
254 self::getInsuranceProviderField()
255 );
256 }
257
258 /**
259 * Get reason for visit field
260 *
261 * @return array<int, array<string, mixed>>
262 */
263 private static function getReasonForVisitField(): array
264 {
265 return [
266 [
267 'id' => 0,
268 'fieldIndex' => 7,
269 'type' => 'textarea',
270 'label' => BackendStrings::getTemplateStrings()['reason_for_visit'],
271 'placeholder' => BackendStrings::getTemplateStrings()['describe_symptoms_or_reason'],
272 'parentId' => null,
273 'defaultValue' => '',
274 'position' => 7,
275 'required' => true,
276 'rows' => 4,
277 ],
278 ];
279 }
280
281 /**
282 * Get need telemedicine field
283 *
284 * @return array<int, array<string, mixed>>
285 */
286 private static function getNeedTelemedicineField(): array
287 {
288 return [
289 [
290 'id' => 0,
291 'fieldIndex' => 8,
292 'type' => 'checkbox',
293 'label' => BackendStrings::getTemplateStrings()['need_telemedicine'],
294 'parentId' => null,
295 'position' => 8,
296 'required' => false,
297 'defaultValue' => '',
298 'placeholder' => '',
299 'fieldOptions' => [
300 [
301 'id' => 0,
302 'label' => BackendStrings::getTemplateStrings()['yes'],
303 'value' => 'yes',
304 'isDefault' => false,
305 'position' => 1
306 ],
307 [
308 'id' => 0,
309 'label' => BackendStrings::getTemplateStrings()['no'],
310 'value' => 'no',
311 'isDefault' => false,
312 'position' => 2
313 ],
314 ]
315 ],
316 ];
317 }
318
319 /**
320 * Get insurance provider field
321 *
322 * @return array<int, array<string, mixed>>
323 */
324 private static function getInsuranceProviderField(): array
325 {
326 return [
327 [
328 'id' => 0,
329 'fieldIndex' => 9,
330 'type' => 'select',
331 'label' => BackendStrings::getTemplateStrings()['insurance_provider'],
332 'placeholder' => BackendStrings::getTemplateStrings()['select_insurance_provider'],
333 'required' => false,
334 'parentId' => null,
335 'defaultValue' => '',
336 'position' => 9,
337 'fieldOptions' => [
338 [
339 'id' => 0,
340 'label' => BackendStrings::getTemplateStrings()['provider_1'],
341 'value' => 'provider_1',
342 'isDefault' => false,
343 'position' => 1
344 ],
345 [
346 'id' => 0,
347 'label' => BackendStrings::getTemplateStrings()['provider_2'],
348 'value' => 'provider_2',
349 'isDefault' => false,
350 'position' => 2
351 ],
352 [
353 'id' => 0,
354 'label' => BackendStrings::getTemplateStrings()['other'],
355 'value' => 'other',
356 'isDefault' => false,
357 'position' => 3
358 ],
359 ]
360 ],
361 ];
362 }
363 }
364