<?php
$iName = $segment->segmentTemplate->internal_name;

// if omega system segment - no only read mode
$isOmegaSystemSegment = (strpos($iName, 'omega_') === 0 && substr($iName, -7) === '_system') && $iName !== 'omega_objective_system';
$isOmegaHistorySegment = strpos($iName, 'omega_history_') === 0;
?>

<div class="border-bottom note-section visit-segment {{$isOmegaSystemSegment || $note->is_signed_by_hcp ? '' : 'edit-trigger'}}"
     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-start bg-light text-dark {{$segment->heading ? 'p-1' : 'py-1 pr-1'}}">

    <!-- title -->

            <?php
            $extraClass = $segment->heading ? 'min-width-110px max-width-110px' : 'min-width-140px pl-2';
            ?>

            @if(!!$segment->display_title)
            <div class="text-dark font-weight-bold font-size-13 mr-2 {{$extraClass}} {{!$segment->is_active ? 'opacity-35' : ''}}">
                {{$segment->display_title}}:
            </div>
            @endif

            <div class="flex-grow-1">
                @if($segment->is_active)
                    <div class="d-none if-not-edit inset-comment summary-container">
                        @if($note->is_signed_by_hcp && $segment->accepted_suggestion_summary_html)
                            {!! $segment->accepted_suggestion_summary_html !!}
                        @else
                            {!! $segment->summary_html !!}
                        @endif
                    </div>

                    <?php if($iName !== 'ros' && $iName !== 'omega_ros' && !$isOmegaHistorySegment) { ?>
                    <div class="d-none if-edit edit-container">
                        {!! $segment->edit_html !!}
                    </div>
                    <?php } ?>
                @else
                    <span class="text-warning-dark">Deactivated</span>
                @endif
            </div>


            @if(!$note->is_signed_by_hcp)
                @if(!$isOmegaSystemSegment)
                <a class="edit-trigger d-none if-edit c-pointer ml-3">
                    <i class="fas fa-caret-up font-size-16"></i>
                </a>
                @endif

                <!-- refresh -->
                <a class="ml-3 font-weight-normal refresh-segment c-pointer {{$iName === 'medrisk_vigilence' ? 'on-hover-only' : ''}} screen-only"
                data-segment-uid="{{$segment->uid}}"
                title="Update with latest patient data">
                    <i class="fa fa-sync on-hover-opaque"></i>
                </a>

            @endif

        {{-- if segment has log feature, link --}}
        @if($pro->pro_type === 'ADMIN' && file_exists(resource_path("views/app/patient/segment-templates/{$segment->segmentTemplate->internal_name}/log.blade.php")))
            <a native="" target="_blank"
               class="c-pointer ml-2 text-decoration-none"
               open-in-stag-popup=""
               title="{{$segment->display_title}} - Change Log"
               popup-style="medium"
               href="/note-segment-view/{{$patient->uid}}/{{$note->uid}}/{{$segment->uid}}/<?= $segment->segmentTemplate->internal_name ?>/log">
               <i class="fas fa-history on-hover-opaque"></i>
            </a>
        @endif

        @if($note->is_signed_by_hcp && $pro->pro_type === 'ADMIN')
            @if($segment->is_active)
                <div moe class="ml-2">
                    <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-2">
                    <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

    </div>




</div>
