@include('layouts.shared/title-meta', ['title' => "Form"]) @include('layouts.shared/head-css', ["mode" => $mode ?? '', "demo" => $demo ?? ''])
processing...
@php // KEEP ORIGINAL DOCTOR LOGIC $doctors = []; foreach($questions as $question){ if($question->code == 'contact_id'){ $doctors = is_iterable($question->options ?? null) ? $question->options : []; } } // RX HISTORY DATA ONLY $history = Formhelper::getMultiformData( $form->partition, $form_id, $form->user_id ); $categorySubmissions = []; $categoryDoctorSubmissions = []; $categoryAttributes = [ 'erdosteine' => 'erdosteine', 'erdosteine + acebrophylline' => 'erdosteine_acebrophylline', 'nac + acebrophylline' => 'nac_acebrophylline', ]; $categoryMoleculeUse = [ 'erdosteine' => 'Erdosteine Prescriber', 'erdosteine + acebrophylline' => 'Erdosteine + Acebrophylline', 'nac + acebrophylline' => 'NAC + Acebrophylline', ]; $moleculeUseToCategory = [ 'erdosteine prescriber' => 'erdosteine', 'erdosteine' => 'erdosteine', 'erdosteine + acebrophylline' => 'erdosteine + acebrophylline', 'nac + acebrophylline' => 'nac + acebrophylline', ]; foreach (array_values($categoryAttributes) as $categoryIndex) { $categorySubmissions[$categoryIndex] = []; $categoryDoctorSubmissions[$categoryIndex] = []; } $doctorNameById = []; $doctorIdByName = []; foreach ($doctors as $doc) { $doctorNameById[$doc->value] = $doc->display; $doctorIdByName[trim($doc->display)] = $doc->value; } if (isset($history->data->submissions) && is_iterable($history->data->submissions)) { foreach ($history->data->submissions as $sub) { $formdata = $sub->formdata ?? null; if (!$formdata) { continue; } $normalizedMolecule = strtolower(trim($formdata->molecule_use ?? '')); $category = $moleculeUseToCategory[$normalizedMolecule] ?? $normalizedMolecule; if (!isset($categoryAttributes[$category])) { continue; } $rawDoctorId = ''; if (!empty($formdata->contact_id)) { $contactId = $formdata->contact_id; if (is_array($contactId) || $contactId instanceof \Traversable) { $contactValues = array_values((array) $contactId); $rawDoctorId = trim((string) ($contactValues[0] ?? '')); } else { $rawDoctorId = trim((string) $contactId); } } $doctorId = $rawDoctorId; if ( $doctorId !== '' && !isset($doctorNameById[$doctorId]) && isset($doctorIdByName[$doctorId]) ) { $doctorId = $doctorIdByName[$doctorId]; } $rxSupport = $formdata->rx_support ?? ''; if (is_array($rxSupport) || $rxSupport instanceof \Traversable) { $rxSupport = trim((string) (array_values((array) $rxSupport)[0] ?? '')); } else { $rxSupport = trim((string) $rxSupport); } $otherMolecule = $formdata->other_molecule_use ?? ''; if (is_array($otherMolecule) || $otherMolecule instanceof \Traversable) { $otherMolecule = trim((string) (array_values((array) $otherMolecule)[0] ?? '')); } else { $otherMolecule = trim((string) $otherMolecule); } $otherMoleculeRxSupport = $formdata->other_molecule_rx_support ?? ''; if (is_array($otherMoleculeRxSupport) || $otherMoleculeRxSupport instanceof \Traversable) { $otherMoleculeRxSupport = trim((string)(array_values((array)$otherMoleculeRxSupport)[0] ?? '')); } else { $otherMoleculeRxSupport = trim((string)$otherMoleculeRxSupport); } $recordDate = $formdata->record_date ?? ''; if (is_array($recordDate) || $recordDate instanceof \Traversable) { $recordDate = trim((string) (array_values((array) $recordDate)[0] ?? '')); } else { $recordDate = trim((string) $recordDate); } $categoryPrefix = $categoryAttributes[$category]; $submissionRow = [ 'submission_id' => $sub->id, 'category' => $category, 'category_field' => $categoryPrefix, 'molecule_use' => $formdata->molecule_use ?? '', 'doctor_id' => $doctorId, 'doctor_name' => $doctorNameById[$doctorId] ?? $rawDoctorId, 'rx_support' => $rxSupport, 'other_molecule_use' => $otherMolecule, 'other_molecule_rx_support' => $otherMoleculeRxSupport ?? '', 'record_date' => $recordDate, ]; $categorySubmissions[$categoryPrefix][] = $submissionRow; if ($doctorId !== '') { $categoryDoctorSubmissions[$categoryPrefix][$doctorId] = $submissionRow; } } } @endphp
@if(Session::has('error'))
{{Session::get('error')}}

@endif @if(session('success'))
{{ session('success') }}

@endif

{{$form->title}}

@if(!isset($form->is_approval) || (isset($form->is_approval) && $form->is_approval != 'yes' ) )
@if($form->link_type == 'form') @else Back @endif
@endif @if(isset($form->user_info))
Submitted By: {{$form->user_info->name}}
@endif
@csrf @if($id) @endif @if(isset($form->manager_can_submit) && $form->manager_can_submit == true)
@endif @foreach($questions as $question) @php $hideFields = [ 'contact_id', 'rx_support', 'other_molecule_use', 'molecule_use', 'other_molecule_rx_support', ]; @endphp @if(in_array($question->code, $hideFields)) @continue @endif
@switch($question->type) @case('hidden') @break @case('text') @case('email') @case('tel') @case('date') required == 'yes'?'required':'' }} value="{{isset($question->value)?$question->value:''}}"> @break @case('number') required == 'yes'?'required':'' }} value="{{isset($question->value)?$question->value:0}}"> @break @case('textarea') @break @case('dropdown') @break @case('radio') @foreach($question->options as $option)
@endforeach @break @case('radiometrix') @php // Decode the first option's value to use as heading labels $headings = count($question->options) > 0 ? json_decode($question->options[0]->value, true) : []; if(!is_array($headings)){ $headings = []; } @endphp {{-- Matrix Wrapper with Horizontal Scroll on Small Screens --}}
{{-- Table Headers --}}
{{-- Placeholder for row labels --}} @foreach ($headings as $head)
{{ $head }}
@endforeach
{{-- Table Rows --}} @foreach ($question->options as $option) @php $nn = json_decode($option->value, true); // fallback if invalid json if(!is_array($nn)){ $nn = []; } @endphp
{{ $option->display }}
@foreach ($nn as $value)
display) && $option->display != $option->display ? 'checked' : '' }}>
@endforeach
@endforeach
@break @case('checkbox') @foreach($question->options as $option)
value) && $question->value != '' && in_array($option->value, $question->value) ? 'checked':''}}>
@endforeach @break @case('file') @if(!isset($form->is_approval) || (isset($form->is_approval) && $form->is_approval != 'yes' ) ) required == 'yes'?'required':'' }}> @elseif(isset($question->value)) @endif @break @case('multitextbox')
@foreach($question->options as $option)
{{$option->display}}
@endforeach
@break @endswitch
@endforeach @if(!isset($form->is_approval) || (isset($form->is_approval) && $form->is_approval != 'yes' ) )
@php $globalRowIndex = 0; @endphp @foreach($categoryAttributes as $categoryLabel => $categoryPrefix)
{{--
{{ ucwords($categoryLabel) }}
--}}
{{ $categoryLabel == 'nac + acebrophylline' ? 'NAC + Acebrophylline' : ucwords($categoryLabel) }}
@for($i = 1; $i <= 5; $i++) @php $globalRowIndex++; @endphp @endfor
Doctor Name Rxn/Week Support Other Molecule Use
@endforeach
@endif
@include('layouts.shared/footer-script')