<div id="note-section-list">
<?php $canvasData = json_decode($patient->canvas_data, true); ?>
<?php $previousHeading = null; ?>
@foreach($note->sections as $section)
<?php
/** @var \App\Models\Section $section */
if($section->heading !== $previousHeading) {
    if(!empty($previousHeading)) {
        echo '</div></div>'; // <!-- end the previous parent section -->
    }
    if(!empty($section->heading)) {
        echo '<div class="note-section-heading px-3 pt-3">' .
            '<div class="text-link font-weight-bold pb-2">' .
            $section->heading .
            '</div>' .
            '<div class="child-sections border-left">'; // <!-- open new parent section -->
    }
    $previousHeading = $section->heading;
}
?>
@include('app.patient.note.section')
@endforeach
<?php
if(!empty($previousHeading)) {
    echo '</div></div>'; // <!-- close any open parent section -->
}
?>
</div>
@include('app.patient.note.section_script')
