diff --git a/resources/views/form/rapport-team4/1781090899-2cedf382-9fbb-45ac-896b-94de9104a11b.blade.php b/resources/views/form/rapport-team4/1781090899-2cedf382-9fbb-45ac-896b-94de9104a11b.blade.php index 97325b73..5c286e11 100644 --- a/resources/views/form/rapport-team4/1781090899-2cedf382-9fbb-45ac-896b-94de9104a11b.blade.php +++ b/resources/views/form/rapport-team4/1781090899-2cedf382-9fbb-45ac-896b-94de9104a11b.blade.php @@ -1,1532 +1,750 @@ - - - - - - - @include('layouts.shared/title-meta', ['title' => "Form"]) - @include('layouts.shared/head-css', ["mode" => $mode ?? '', "demo" => $demo ?? '']) - - - - -
- processing... -
- -
-
-
-
-
-
- - @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', - 'month_1', - 'month_2', - 'month_3', - 'converted', - 'rx_support', - 'other_molecule_use' - ]; - - @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' ) ) -
-
-
- {{--
-
Tagged Doctors
-
--}} -
-
- @php -$doctors = []; - -foreach($questions as $question){ - if($question->code == 'contact_id'){ - $doctors = $question->options ?? []; - break; - } -} -@endphp - - - - - - - - - - - - -@for($i=1; $i<=5; $i++) - - - - - - - - - - - -@endfor - - -
Doctor NameRxn/Week SupportOther Molecule Use
- - - - - - - - -
-
-
-
-
- - -
- @endif -
- -
-
- - -
-
- -
- -
- - - -@include('layouts.shared/footer-script') - - - - - + + + + + + + @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', + ]; + + $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); + } + + $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, + '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' + ]; + + @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' ) ) +
+
+
+ {{--
+
Tagged Doctors
+
--}} +
+
+ @php + $doctors = []; + + foreach($questions as $question){ + if($question->code == 'contact_id'){ + $doctors = $question->options ?? []; + break; + } + } + @endphp + + + + + + + + + + + + + @for($i=1; $i<=5; $i++) + + + + + + + + + + + + @endfor + + +
Doctor NameRxn/Week SupportOther Molecule Use
+ + + + + + + +
+
+
+
+
+ + +
+ @endif +
+ +
+
+ + +
+
+ +
+ +
+ + + + + +@include('layouts.shared/footer-script') + + + + + \ No newline at end of file