<?php $iName = $segment->segmentTemplate->internal_name; ?>
<?php $isLSSegment = strpos($iName, 'lifestyle_') === 0; ?>

<div class="border-bottom note-section visit-segment {{$note->is_signed_by_hcp ? '' : 'edit-trigger'}} {{strpos($iName, 'lifestyle_') === 0 && $iName !== 'lifestyle_general' ? 'zero-height' : ''}}"
     data-segment-uid="{{ $segment->uid }}"
     data-segment-template-uid="{{ $segment->segmentTemplate->uid }}"
     data-segment-template-name="{{ $segment->segmentTemplate->internal_name }}">

    <div class="d-flex align-items-baseline bg-light text-secondary p-2" style="border-bottom: 1px solid #dee2e6;">

    <!-- title -->

        <span class="font-weight-bold d-flex align-items-center {{$isLSSegment || $iName === 'medrisk_vigilence' ? '' : 'xxxmb-2'}}">
            <span style="color: black; text-decoration: underline; font-size: 13px;" class="{{!$segment->is_active ? 'opacity-35' : ''}}">
                {{$segment->display_title}}
            </span>
            @if($note->is_signed_by_hcp && $pro->pro_type === 'ADMIN')
                @if($segment->is_active)
                    <div moe class="ml-3">
                        <form url="/api/segment/deactivate" show>
                            <input type="hidden" name="uid" value="{{$segment->uid}}">
                            <button submit class="p-0 border-0 bg-transparent text-primary text-sm outline-0">Deactivate</button>
                        </form>
                    </div>
                @else
                    <div moe class="ml-3">
                        <form url="/api/segment/reactivate" show>
                            <input type="hidden" name="uid" value="{{$segment->uid}}">
                            <button submit class="p-0 border-0 bg-transparent text-primary text-sm outline-0">Reactivate</button>
                        </form>
                    </div>
                @endif
            @endif
        </span>

        @if($isLSSegment)
            @if($iName === 'lifestyle_general')
                <a href="#" class="ls-segment-trigger ml-2" data-target="lifestyle_general">General</a>
                <span class="mx-2 text-secondary text-sm">|</span>
                <a href="#" class="ls-segment-trigger" data-target="lifestyle_nutrition">Nutrition</a>
                <span class="mx-2 text-secondary text-sm">|</span>
                <a href="#" class="ls-segment-trigger" data-target="lifestyle_physical_activity">Physical Act.</a>
                <span class="mx-2 text-secondary text-sm">|</span>
                <a href="#" class="ls-segment-trigger" data-target="lifestyle_sleep">Sleep</a>
                <span class="mx-2 text-secondary text-sm">|</span>
                <a href="#" class="ls-segment-trigger" data-target="lifestyle_social">Social Relns.</a>
                <span class="mx-2 text-secondary text-sm">|</span>
                <a href="#" class="ls-segment-trigger" data-target="lifestyle_substances">Subst. Use</a>
                <span class="mx-2 text-secondary text-sm">|</span>
                <a href="#" class="ls-segment-trigger" data-target="lifestyle_stress">Stress</a>
            @else
                <span class="text-info ml-auto font-weight-normal">(click to view)</span>
            @endif
        @endif

    </div>

    <?php
    $rhsEdit = (in_array($segment->segmentTemplate->internal_name, [
            'informed_consent',
            'omega_informed_consent',
            'chief_complaint',
            'omega_cc',
            'ros',
            'omega_ros',
            'subjective_general',
            'omega_subjective_free_text',
            'objective_free_text',
            'omega_objective_free_text',
            'assessment_free_text',
            'omega_assessment_free_text',
            'plan_free_text',
            'omega_plan_free_text',
        ]) === TRUE);
    ?>

    @if(!$isLSSegment && $segment->is_active)
        <?php
            $html = '';
            if($note->is_signed_by_hcp && $segment->accepted_suggestion_summary_html) {
                $recalculated = $html = $segment->accepted_suggestion_summary_html;
            }
            else {
                $recalculated = $html = $segment->summary_html;
                if(in_array($segment->segmentTemplate->internal_name, ['chief_complaint', 'omega_cc']) === TRUE) {
                    $recalculated = $segment->getRecalculatedHtml($performer, $performer->session_key, true)['summaryHtml'];
                }
            }
        ?>
        @if(!$rhsEdit && !in_array($segment->display_title, ['Subjective', 'Plan']))
            <div class="inset-comment summary-container p-2">
                {!! $html !!}
            </div>
        @else
            <div class="d-flex align-items-stretch overridable">
                <div class="min-width-50">
                    <label class="font-weight-bold text-sm py-1 mb-0 ml-2">Current:</label>
                    <div class="inset-comment summary-container border-top p-2 lhs-read">
                        {!! $html !!}
                    </div>
                </div>
                <div class="min-width-50 rhs-edit">
                    <label class="font-weight-bold text-sm py-1 mb-0 ml-2">Override:</label>
                    <div contenteditable class="border border-info p-2">{!! trim($recalculated) !!}</div>
                    <div class="my-1">
                        <a href="#" class="btn-apply-override" data-segment-uid="{{$segment->uid}}">Apply</a>
                    </div>
                </div>
            </div>
        @endif
    @endif

</div>

