<?php

$contentData = [
    "items" => []
];
if($patient->canvas_data) {
    $canvasData = json_decode($patient->canvas_data, true);
    if(isset($canvasData["dx"])) {
        $contentData = $canvasData["dx"];

        if(!isset($contentData['items'])){
            $contentData['items'] = [];
        }
    }
}

if(count($contentData['items'])) {
    for ($i = 0; $i < count($contentData['items']); $i++) {
        $item = $contentData['items'][$i];
?>
        <div class="mb-2 <?= @$item["included"] ? '' : 'hide-if-note' ?>">
            <div class="">
                <b><?= isset($item["title"]) ? $item["title"] :''  ?></b>
                <?= isset($item["icd"]) ? '/&nbsp;' . $item["icd"] : '' ?>
                <?= isset($item["coa"]) ? '/&nbsp;' . $item["coa"] : '' ?>
            </div>
            <?php
            $detailPlain = isset($item["detail"]) ? $item["detail"] : '';
            $detailPlain = trim(strip_tags($detailPlain));
            if(!empty($detailPlain)):
            ?>
                <div class="text-secondary font-weight-bold">Detail</div>
                <div class="ml-2"><?= $detailPlain ?></div>
            <?php endif; ?>
            <?php
            $planPlain = isset($item["plan"]) ? $item["plan"] : '';
            $planPlain = trim(strip_tags($planPlain));
            if(!empty($planPlain)):
            ?>
                <div class="text-secondary font-weight-bold">Plan</div>
                <div class="ml-2"><?= $planPlain ?></div>
            <?php endif; ?>
        </div>
<?php
    }
}
else {
    ?>
    <div class="text-secondary">Nothing here yet!</div>
    <?php
}
?>
