<?php
    $suggestionModeOn = request()->get('suggestion_mode') == 'on' && $note->is_signed_by_hcp
?>
<div class="segments-list" id="note-segments-list">
    <?php
    $previousHeading = null;
    $previousSubHeading = null;
    ?>
    @foreach($note->segmentsLeft as $segment)
        <?php
        if ($segment->heading !== $previousHeading) {
            if (!empty($previousHeading)) {
                echo '</div></div>'; // <!-- end the previous parent section -->
            }
            if (!empty($segment->heading)) {

	    ?>
        <div class="note-content-node note-content-heading">
            <div class="py-2 px-2 border-bottom font-size-16 font-weight-bold bg-light text-dark {{ $previousHeading ? 'mt-4 border-top' : '' }}">
                {{ $segment->heading }}
            </div>
            <div class="note-content-children ml-5 border-left">
                <!-- open new node -->
            <?php
            }
                $previousHeading = $segment->heading;
            }
            ?>
            <div class="{{$segment->segmentTemplate->internal_name === 'medrisk_vigilence' ? 'd-none' : ''}}">
                @if($suggestionModeOn)
                    @include('app.patient.note.segment.suggestions_and_updates')
                @else
                    @if($note->visitTemplate->segments_always_open && !$note->is_signed_by_hcp)
                        @include('app.patient.note.segment-always-open')
                    @else
                        @include('app.patient.note.segment-slim')
                    @endif
                @endif
            </div>

    @endforeach
    <?php
    if (!empty($previousHeading)) {
        echo '</div></div>'; // <!-- close any open parent section -->
    }
    ?>
</div>
@include('app.patient.note.segment_script')
