<div class="mb-2">
    <span class="font-weight-bold">Entry Type</span>
    <div class="d-flex align-items-center mt-1">
        <button data-entry-type="Pre-Existing"
                class="btn-entry-type shadow-none btn btn-default border mr-2 bg-white">
            Pre-Existing
        </button>
        <button data-entry-type="Added during this visit"
                class="btn-entry-type shadow-none btn btn-default border mr-2 bg-white">
            {{@$addVerbPT ? ucwords($addVerbPT) : 'Added'}} during this visit
        </button>
        <button data-entry-type="Historic"
                class="btn-entry-type shadow-none btn btn-default border mr-2 bg-white">
            Historic
        </button>
        <button data-entry-type="Removed during this visit"
                class="btn-entry-type shadow-none btn btn-default border mr-2 bg-white">
            Removed during this visit
        </button>
    </div>
</div>

<div class="mb-2 d-none">
    <span class="font-weight-bold">Is this {{$label}} currently active?</span>
    <div class="d-flex align-items-baseline mt-1">
        <label class="my-0 d-inline-flex align-items-center">
            <input type="radio" name="isRemoved" required value="0" {{!$point || !$point->is_removed ? 'checked' : ''}}>
            <span class="ml-1">Yes</span>
        </label>
        <label class="ml-3 my-0 d-inline-flex align-items-center">
            <input type="radio" name="isRemoved" required value="1" {{$point && $point->is_removed ? 'checked' : ''}}>
            <span class="ml-1">No</span>
        </label>
    </div>
</div>

<div class="d-none">

    <hr class="mb-2 mt-0">

    <div class="mb-2">
        <span class="font-weight-bold">Is this pre-existing, or being {{@$addVerbPT ? strtolower($addVerbPT) : 'added'}} during this visit?</span>
        @if($point && $point->added_in_note_id !== $note->id && !$point->is_removed)
            <div class="mt-1">
                @if($point->addition_reason_category === 'ON_INTAKE')
                    Added as pre-existing on {{friendly_date($point->note->effective_dateest)}}
                @else
                    Added during visit on {{friendly_date($point->note->effective_dateest)}}
                @endif
                <input type="radio" name="additionReasonCategory" value="{{$point->addition_reason_category}}" checked class="d-none">
            </div>
        @else
            <div class="d-flex align-items-baseline mt-1">
                <label class="my-0 d-inline-flex align-items-center">
                    <input type="radio" name="additionReasonCategory" value="ON_INTAKE"
				            {{$point && $point->addition_reason_category === 'ON_INTAKE' ? 'checked' : ''}}
                            {{0 && $point && $point->added_in_note_id !== $note->id ? 'readonly disabled' : ''}}>
                    <span class="ml-1">Pre-existing</span>
                </label>
                <label class="ml-3 my-0 d-inline-flex align-items-center">
                    <input type="radio" name="additionReasonCategory" value="DURING_VISIT"
                            {{$point && $point->addition_reason_category === 'DURING_VISIT' ? 'checked' : ''}}
                            {{0 && $point && $point->added_in_note_id !== $note->id ? 'readonly disabled' : ''}}>
                    <span class="ml-1">{{@$addVerbPT ? ucwords($addVerbPT) : 'Added'}} during this visit (as part of my {{@$apTerm ? $apTerm : 'plan'}})</span>
                </label>
            </div>
        @endif
    </div>

</div>

<div class="d-none">

    <hr class="mb-2 mt-0">

    @if(@$point)
        <div class="mb-2">
            <span class="font-weight-bold">Is this {{$label}} being removed due to an entry error?</span>
            <div class="d-flex align-items-baseline mt-1">
                <label class="my-0 d-inline-flex align-items-center">
                    <input type="radio" name="isRemovedDueToEntryError" value="1" {{$point && $point->is_removed && $point->is_removed_due_to_entry_error ? 'checked' : ''}}>
                    <span class="ml-1">Yes</span>
                </label>
                <label class="ml-3 my-0 d-inline-flex align-items-center">
                    <input type="radio" name="isRemovedDueToEntryError" value="0" {{$point && $point->is_removed && !$point->is_removed_due_to_entry_error ? 'checked' : ''}}>
                    <span class="ml-1">No</span>
                </label>
            </div>
        </div>
    @endif

    <div {{@$point ? 'if-not-entry-error class="d-none"' : ''}}>

        <div class="mb-2">
            <span class="font-weight-bold">Was this {{$label}} removed PRIOR to this visit or DURING this visit?</span>
            @if($point && $point->added_in_note_id !== $note->id && $point->is_removed)
                <div class="mt-1">
                    @if($point->removal_reason_category === 'ON_INTAKE')
                        Removed prior to the visit on {{friendly_date($point->note->effective_dateest)}}
                    @else
                        Removed during visit on {{friendly_date($point->note->effective_dateest)}}
                    @endif
                    <input type="radio" name="removalReasonCategory" value="{{$point->removal_reason_category}}" checked class="d-none">
                </div>
            @else
                <div class="d-flex align-items-baseline mt-1">
                    <label class="my-0 d-inline-flex align-items-center">
                        <input type="radio" name="removalReasonCategory" value="ON_INTAKE" {{$point && $point->removal_reason_category === 'ON_INTAKE' ? 'checked' : ''}}>
                        <span class="ml-1">Prior to visit</span>
                    </label>
                    <label class="ml-3 my-0 d-inline-flex align-items-center">
                        <input type="radio" name="removalReasonCategory" value="DURING_VISIT" {{$point && $point->removal_reason_category === 'DURING_VISIT' ? 'checked' : ''}}>
                        <span class="ml-1">Removed during this visit (as part of my {{@$apTerm ? $apTerm : 'plan'}})</span>
                    </label>
                </div>
            @endif
        </div>

    </div>

</div>

<div if-entry-type-not-empty class="d-none">

<div {{@$point ? 'if-not-entry-error class="d-none"' : ''}}>
    <div if-addition-or-removal-on-intake-or-during-visit class="d-none">
        <div class="row mb-2">
            <div class="col-3 pr-0">
                <label class="text-sm mb-0 font-weight-bold">Start Date</label>
                <input type="date"
                       data-name="start_date"
                       value="{{@$point->data ? @$point->data->start_date : ''}}"
                       class="form-control form-control-sm min-width-unset">
            </div>
            <div class="col-3 pr-0">
                <label class="text-sm mb-0 font-weight-bold">{{@$addVerbPT ? ucwords($addVerbPT) : 'Added'}} By</label>
                <input type="text"
                       data-name="prescriber"
                       value="{{@$point->data ? @$point->data->prescriber : ''}}"
                       class="form-control form-control-sm min-width-unset">
            </div>
            <div class="col-3 pr-0">
                <div if-not-active class="d-none">
                    <div if-removal-on-intake-or-during-visit class="d-none">
                        <label class="text-sm mb-0 font-weight-bold">End Date</label>
                        <input type="date"
                               name="removalEffectiveDate"
                               value="{{@$point->removal_effective_date}}"
                               class="form-control form-control-sm min-width-unset">
                    </div>
                </div>
            </div>
            <div class="col-3">
                <div if-not-active class="d-none">
                    <div if-removal-on-intake-or-during-visit class="d-none">
                        <label class="text-sm mb-0 font-weight-bold">Removal By/Memo</label>
                        <input type="text"
                               name="removalReasonMemo"
                               value="{{@$point->removal_reason_memo}}"
                               class="form-control form-control-sm min-width-unset">
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<div {{@$point ? 'if-not-entry-error class="d-none"' : ''}}>
    <div if-active-or-not-active class="d-none">

    @if(1 || $patient->core_note_id !== $note->id) {{-- allow review/plan from core note --}}
	<div class="row">
        @if(!@$noReview)
            <?php
            list($currentChildReview, $previousChildReview) = @$point ? \App\Models\Point::getCurrentAndPreviousChildReviews($point, $note) : [null, null];
            ?>
            @if($label === 'medication')
                <div class="mb-2 col-md-3 pr-0 pb-2">
                    <label class="text-sm mb-0 font-weight-bold">Subj. Frequency</label>
                    <input type="text"
                           data-name="value"
                           data-container-name="childReviewData"
                           class="form-control form-control-sm min-width-unset">
                </div>
                <div class="mb-2 col-md-6 pr-0 pb-2">
                    <label class="text-sm mb-0 font-weight-bold">Subj. Experience</label>
                    <input type="text"
                           data-name="experience"
                           data-container-name="childReviewData"
                           class="form-control form-control-sm min-width-unset">
                </div>
            @else
                <div class="mb-2 col-md-6 pr-0">
                    <label class="text-sm mb-0 font-weight-bold">{{@$reviewLabel ? $reviewLabel : 'Subjective'}}</label>
                    <div note-rte
                         class="form-group mb-2 rte-holder bg-white border rounded"
                         data-field-name="reviewValue"><?= @($currentChildReview->data->value) ?></div>
                    <?php if($previousChildReview && @($previousChildReview->data->value)): ?>
                    <div class="mb-2">
                        <div class="d-flex align-items-baseline mb-1">
                            <span class="text-sm text-secondary">Previous {{@$reviewLabel ? $reviewLabel : 'Subjective'}} / <?= friendlier_date($previousChildReview->created_at) ?> (click to copy)</span>
                        </div>
                        <div class="p-1 bg-light border inline-html-container click-to-copy"><?= $previousChildReview->data->value ?></div>
                    </div>
                    <?php endif; ?>
                </div>
            @endif
        @endif

        @if(!@$noPlan)
            <?php
            list($currentChildPlan, $previousChildPlan) = @$point ? \App\Models\Point::getCurrentAndPreviousChildPlans($point, $note) : [null, null];
            ?>
            @if($label === 'medication')
                <div class="mb-2 col-md-3 pb-2">
                    <label class="text-sm mb-0 font-weight-bold">Plan Frequency</label>
                    <input type="text"
                           data-name="value"
                           data-container-name="childPlanData"
                           class="form-control form-control-sm min-width-unset">
                </div>
            @else
                <div class="mb-2 col-md-6">
                    <label class="text-sm mb-0 font-weight-bold">{{@$planLabel ? $planLabel : 'Plan'}}</label>
                    <div note-rte
                         class="form-group mb-2 rte-holder bg-white border rounded"
                         data-field-name="planValue"><?= @($currentChildPlan->data->value) ?></div>
                    <?php if($previousChildPlan && @($previousChildPlan->data->value)): ?>
                    <div class="mb-2">
                        <div class="d-flex align-items-baseline mb-1">
                            <span class="text-sm text-secondary">Previous {{@$planLabel ? $planLabel : 'Plan'}} / <?= friendlier_date($previousChildPlan->created_at) ?> (click to copy)</span>
                        </div>
                        <div class="p-1 bg-light border inline-html-container click-to-copy"><?= $previousChildPlan->data->value ?></div>
                    </div>
                    <?php endif; ?>
                </div>
            @endif
        @endif
	</div>
    @endif

    </div>
</div>

</div>