<?php

// info from patient chart
$drugs = \App\Models\Point::getPointsOfCategory($patient, "MEDICATION");

// filter out drugs without fdb info on them
$drugs = $drugs->filter(function ($_drug) {
    return @$_drug->data &&
        $_drug->data->name &&
        $_drug->data->medId &&
        $_drug->data->routedMedId &&
        $_drug->data->routedDosageFormMedId &&
        $_drug->data->gcnSeqno;
});

// get pivot allergy
$pivotAllergy = json_decode(json_encode([
    "data" => [
        "name" => request()->input('name'),
        "damConceptId" => request()->input('damConceptId'),
        "damConceptIdType" => request()->input('damConceptIdType')
    ]
]));

// dam
$dam = drug_allergy_info($drugs, [$pivotAllergy], false);

?>

@if(!!$dam)
    <div class="p-3 mb-3 mt-2 border bg-white mr-0">
        <p class="font-weight-bold m-0 font-size-14 text-info">Drug Allergy Notes</p>
        <div class="mt-3">
            {!! $dam !!}
        </div>
    </div>
@endif


